manager_center_api_controller.go 79KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461
  1. package controllers
  2. import (
  3. "XT_New/enums"
  4. "XT_New/models"
  5. "XT_New/service"
  6. "XT_New/utils"
  7. "encoding/json"
  8. "fmt"
  9. "github.com/astaxie/beego"
  10. "github.com/jinzhu/gorm"
  11. "reflect"
  12. "strconv"
  13. "time"
  14. )
  15. type ManagerCenterApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func ManagerCenterRegistRouters() {
  19. //药品基础库
  20. beego.Router("/api/basedruglib/create", &ManagerCenterApiController{}, "post:CreateBaseDrugLib")
  21. beego.Router("/api/basedruglib/edit", &ManagerCenterApiController{}, "post:EditBaseDrugLib")
  22. beego.Router("/api/basedruglib/get", &ManagerCenterApiController{}, "get:GetBaseDrugLib")
  23. beego.Router("/api/basedruglib/list", &ManagerCenterApiController{}, "get:GetBaseDrugLibList")
  24. beego.Router("/api/medicineinsurancepercent/create", &ManagerCenterApiController{}, "post:CreateMedicineInsurancePercent")
  25. beego.Router("/api/drugunitsafeguard/create", &ManagerCenterApiController{}, "post:CreateDrugUnitSafeguard")
  26. beego.Router("/api/medicineinsurancepercent/get", &ManagerCenterApiController{}, "get:GetMedicineInsurancePercent")
  27. //beego.Router("/api/drugunitsafeguard/get", &ManagerCenterApiController{}, "get:GetDrugUnitSafeguard")
  28. beego.Router("/api/drug/basedruglib", &ManagerCenterApiController{}, "get:DeleteBaseDrugById")
  29. //专项字典
  30. beego.Router("/api/dictionary/getconfiglist", &ManagerCenterApiController{}, "get,post:GetConfigList")
  31. beego.Router("/api/dictionary/createconfig", &ManagerCenterApiController{}, "Post:CreateConfig")
  32. beego.Router("/api/dictionary/createchildconfig", &ManagerCenterApiController{}, "Post:CreateChildConfig")
  33. beego.Router("/api/dictionary/updatechildconfig", &ManagerCenterApiController{}, "Post:UpdateChildConfig")
  34. beego.Router("/api/dictionary/deletechildconfig", &ManagerCenterApiController{}, "Post:DeleteChildConfig")
  35. beego.Router("/api/dictionary/updatetemplate", &ManagerCenterApiController{}, "Post:UpdateTemplate")
  36. beego.Router("/api/dictionary/getmanageconfiglist", &ManagerCenterApiController{}, "get,post:GetManageConfigList")
  37. //经销商
  38. beego.Router("/api/stock/dealer/create", &ManagerCenterApiController{}, "post:CreateDealer")
  39. beego.Router("/api/stock/dealer/modify", &ManagerCenterApiController{}, "post:ModifyDealer")
  40. //经过测试这个接口完全不会执行,因为被另一个路由占用了
  41. beego.Router("/api/stock/dealer/list", &ManagerCenterApiController{}, "get:GetDealersList")
  42. beego.Router("/api/stock/dealer/delete", &ManagerCenterApiController{}, "post:DeleteDealer")
  43. beego.Router("/api/stock/dealer/get", &ManagerCenterApiController{}, "get:GetDealer")
  44. //厂商
  45. beego.Router("/api/stock/manufacturer/create", &ManagerCenterApiController{}, "post:CreateManufacturer")
  46. beego.Router("/api/stock/manufacturer/modify", &ManagerCenterApiController{}, "post:ModifyManufacturer")
  47. //经过测试这个接口也完全不会执行,因为被另一个路由占用了
  48. beego.Router("/api/stock/manufacturer/list", &ManagerCenterApiController{}, "get:GetManufacturerList")
  49. beego.Router("/api/stock/manufacturer/delete", &ManagerCenterApiController{}, "post:DeleteManufacturer")
  50. beego.Router("/api/stock/manufacturer/get", &ManagerCenterApiController{}, "get:GetManufacturer")
  51. beego.Router("/api/stock/good/info/create", &ManagerCenterApiController{}, "post:CreateGoodInfo")
  52. beego.Router("/api/stock/good/info/modify", &ManagerCenterApiController{}, "post:ModifyGoodInfo")
  53. beego.Router("/api/stock/good/info/list", &ManagerCenterApiController{}, "get:GetGoodInfoList")
  54. beego.Router("/api/info/delete", &ManagerCenterApiController{}, "post:DeleteGoodInfo")
  55. beego.Router("/api/stock/good/info/get", &ManagerCenterApiController{}, "get:GetGoodInfoByGoodId")
  56. beego.Router("/api/stock/good/info", &ManagerCenterApiController{}, "get:GetGoodInfoById")
  57. //门诊大病
  58. beego.Router("/api/mz/sick/create", &ManagerCenterApiController{}, "post:CreateMZSick")
  59. beego.Router("/api/mz/sick/modify", &ManagerCenterApiController{}, "post:ModifyMZSick")
  60. beego.Router("/api/mz/sick/list", &ManagerCenterApiController{}, "get:GetMZSickList")
  61. beego.Router("/api/mz/sick/delete", &ManagerCenterApiController{}, "post:DeleteMZSick")
  62. beego.Router("/api/mz/sick/get", &ManagerCenterApiController{}, "get:GetMZSick")
  63. beego.Router("/api/addition/create", &ManagerCenterApiController{}, "post:CreateAddition")
  64. beego.Router("/api/addition/modify", &ManagerCenterApiController{}, "post:ModifyAddition")
  65. beego.Router("/api/addition/list", &ManagerCenterApiController{}, "get:GetAdditionList")
  66. beego.Router("/api/addition/delete", &ManagerCenterApiController{}, "post:DeleteAddition")
  67. beego.Router("/api/addition/get", &ManagerCenterApiController{}, "get:GetAddition")
  68. //门诊诊断
  69. beego.Router("/api/diagnose/create", &ManagerCenterApiController{}, "post:CreateDiagnose")
  70. beego.Router("/api/diagnose/modify", &ManagerCenterApiController{}, "post:ModifyDiagnose")
  71. beego.Router("/api/diagnose/list", &ManagerCenterApiController{}, "get:GetDiagnoseList")
  72. beego.Router("/api/diagnose/delete", &ManagerCenterApiController{}, "post:DeleteDiagnose")
  73. beego.Router("/api/diagnose/get", &ManagerCenterApiController{}, "get:GetDiagnose")
  74. beego.Router("/api/drug/getalldruglist", &ManagerCenterApiController{}, "get:GetAllDrugList")
  75. beego.Router("/api/drug/postsearchdruglist", &ManagerCenterApiController{}, "get:GetSearchDrugList")
  76. beego.Router("/api/patient/addpatientdiagnose", &ManagerCenterApiController{}, "Post:AddPatientDiagnos")
  77. beego.Router("/api/patient/getpatientdiagnose", &ManagerCenterApiController{}, "Get:GetPatientDiagnose")
  78. beego.Router("/api/patient/getpatientdiagnosedetail", &ManagerCenterApiController{}, "Get:GetPatientDiagnoseDetail")
  79. beego.Router("/api/patient/updatepatientcase", &ManagerCenterApiController{}, "Post:UpdatePatientCase")
  80. beego.Router("/api/patient/deletepatientdiagnose", &ManagerCenterApiController{}, "Get:DeletePatientDiagnose")
  81. }
  82. func (c *ManagerCenterApiController) CreateBaseDrugLib() {
  83. drug_name := c.GetString("drug_name")
  84. pinyin := c.GetString("pinyin")
  85. wubi := c.GetString("wubi")
  86. drug_alias := c.GetString("drug_alias")
  87. drug_alias_pinyin := c.GetString("drug_alias_pinyin")
  88. drug_alias_wubi := c.GetString("drug_alias_wubi")
  89. drug_category, _ := c.GetInt64("drug_category")
  90. drug_spec := c.GetString("drug_spec")
  91. drug_type, _ := c.GetInt64("drug_type")
  92. drug_stock_limit := c.GetString("drug_stock_limit")
  93. drug_origin_place := c.GetString("drug_origin_place")
  94. drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
  95. medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
  96. max_unit := c.GetString("max_unit")
  97. min_unit := c.GetString("min_unit")
  98. unit_matrixing := c.GetString("unit_matrixing")
  99. retail_price, _ := c.GetFloat("retail_price")
  100. last_price, _ := c.GetFloat("last_price")
  101. drug_control, _ := c.GetInt64("drug_control")
  102. number := c.GetString("number")
  103. drug_classify := c.GetString("drug_classify")
  104. drug_dose, _ := c.GetFloat("drug_dose")
  105. drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
  106. medical_insurance_number := c.GetString("medical_insurance_number")
  107. provinces_code := c.GetString("provinces_code")
  108. manufacturer, _ := c.GetInt64("manufacturer")
  109. pharmacology_category, _ := c.GetInt64("pharmacology_category")
  110. statistics_category, _ := c.GetInt64("statistics_category")
  111. code := c.GetString("code")
  112. is_special_diseases, _ := c.GetInt64("is_special_diseases")
  113. is_record, _ := c.GetInt64("is_record")
  114. agent := c.GetString("agent")
  115. drug_status := c.GetString("drug_status")
  116. limit_remark := c.GetString("limit_remark")
  117. delivery_way := c.GetString("delivery_way")
  118. execution_frequency := c.GetString("execution_frequency")
  119. single_dose, _ := c.GetFloat("single_dose")
  120. fmt.Println(single_dose)
  121. prescribing_number, _ := c.GetFloat("prescribing_number")
  122. label, _ := c.GetInt64("label")
  123. sort, _ := c.GetInt64("sort")
  124. is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
  125. is_default, _ := c.GetInt64("is_default")
  126. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  127. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  128. is_charge_use, _ := c.GetInt64("is_charge_use")
  129. dealer, _ := c.GetInt64("dealer")
  130. prescription_mark, _ := c.GetInt64("prescription_mark")
  131. social_security_directory_code := c.GetString("social_security_directory_code")
  132. record_date := c.GetString("record_date")
  133. timeLayout := "2006-01-02"
  134. loc, _ := time.LoadLocation("Local")
  135. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  136. drug_remark := c.GetString("drug_remark")
  137. //dose, _ := c.GetFloat("dose")
  138. dose := c.GetString("dose")
  139. dose_unit := c.GetString("dose_unit")
  140. min_price, _ := c.GetFloat("min_price")
  141. min_number, _ := c.GetInt64("min_number")
  142. drug_day := c.GetString("drug_day")
  143. hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
  144. lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
  145. prescribing_number_unit := c.GetString("prescribing_number_unit")
  146. is_user, _ := c.GetInt64("is_user")
  147. is_pharmacy, _ := c.GetInt64("is_pharmacy")
  148. bbx01 := c.GetString("bbx01")
  149. bby01 := c.GetString("bby01")
  150. adminInfo := c.GetAdminUserInfo()
  151. drugLib := &models.BaseDrugLib{
  152. DrugName: drug_name,
  153. Pinyin: pinyin,
  154. Wubi: wubi,
  155. DrugAlias: drug_alias,
  156. DrugAliasPinyin: drug_alias_pinyin,
  157. DrugAliasWubi: drug_alias_wubi,
  158. DrugCategory: drug_category,
  159. DrugSpec: drug_spec,
  160. DrugType: drug_type,
  161. DrugStockLimit: drug_stock_limit,
  162. DrugOriginPlace: drug_origin_place,
  163. MedicalInsuranceLevel: medical_insurance_level,
  164. DrugDosageForm: drug_dosage_form,
  165. MaxUnit: max_unit,
  166. MinUnit: min_unit,
  167. UnitMatrixing: unit_matrixing,
  168. RetailPrice: retail_price,
  169. LastPrice: last_price,
  170. DrugControl: drug_control,
  171. Number: number,
  172. DrugClassify: drug_classify,
  173. DrugDose: drug_dose,
  174. DrugDoseUnit: drug_dose_unit,
  175. MedicalInsuranceNumber: medical_insurance_number,
  176. ProvincesCode: provinces_code,
  177. Manufacturer: manufacturer,
  178. PharmacologyCategory: pharmacology_category,
  179. StatisticsCategory: statistics_category,
  180. Code: code,
  181. IsSpecialDiseases: is_special_diseases,
  182. IsRecord: is_record,
  183. Agent: agent,
  184. DrugStatus: drug_status,
  185. LimitRemark: limit_remark,
  186. DeliveryWay: delivery_way,
  187. ExecutionFrequency: execution_frequency,
  188. SingleDose: drug_dose,
  189. PrescribingNumber: prescribing_number,
  190. Label: label,
  191. Sort: sort,
  192. IsUseDoctorAdvice: is_use_doctor_advice,
  193. IsDefault: is_default,
  194. IsChargePredict: is_charge_predict,
  195. IsStatisticsWork: is_statistics_work,
  196. IsChargeUse: is_charge_use,
  197. OrgId: adminInfo.CurrentOrgId,
  198. Status: 1,
  199. Ctime: time.Now().Unix(),
  200. Mtime: time.Now().Unix(),
  201. Dealer: dealer,
  202. PrescriptionMark: prescription_mark,
  203. SocialSecurityDirectoryCode: social_security_directory_code,
  204. RecordDate: theTime.Unix(),
  205. DrugRemark: drug_remark,
  206. DrugDay: drug_day,
  207. MinNumber: min_number,
  208. Dose: dose,
  209. MinPrice: min_price,
  210. DoseUnit: dose_unit,
  211. HospApprFlag: hosp_appr_flag,
  212. LmtUsedFlag: lmt_used_flag,
  213. PrescribingNumberUnit: prescribing_number_unit,
  214. IsUse: is_user,
  215. IsPharmacy: is_pharmacy,
  216. Bby01: bby01,
  217. ZuobiaoId: bbx01,
  218. Bbx01: bbx01,
  219. }
  220. total := service.FindAllDrugLibRecordTotal(adminInfo.CurrentOrgId)
  221. drug_code := strconv.FormatInt(total+1, 10)
  222. drug_code = "54000000" + drug_code
  223. drugLib.DrugCode = drug_code
  224. count := service.FindBaseDrugLibRecordCountOne(drugLib)
  225. if count == 0 {
  226. if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
  227. drugLib.DrugSpec = drugLib.Dose + drugLib.DoseUnit + "*" + string(drugLib.MinNumber) + drugLib.MinUnit + "/" + drugLib.MaxUnit
  228. }
  229. err := service.CreateBaseDrugLib(drugLib)
  230. if err == nil {
  231. c.ServeSuccessJSON(map[string]interface{}{
  232. "msg": "创建成功",
  233. })
  234. } else {
  235. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  236. return
  237. }
  238. return
  239. } else {
  240. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDrugRepeatDataException)
  241. return
  242. }
  243. }
  244. func (c *ManagerCenterApiController) EditBaseDrugLib() {
  245. id, _ := c.GetInt64("id")
  246. drug_name := c.GetString("drug_name")
  247. pinyin := c.GetString("pinyin")
  248. wubi := c.GetString("wubi")
  249. drug_alias := c.GetString("drug_alias")
  250. drug_alias_pinyin := c.GetString("drug_alias_pinyin")
  251. drug_alias_wubi := c.GetString("drug_alias_wubi")
  252. drug_category, _ := c.GetInt64("drug_category")
  253. drug_spec := c.GetString("drug_spec")
  254. drug_type, _ := c.GetInt64("drug_type")
  255. drug_stock_limit := c.GetString("drug_stock_limit")
  256. drug_origin_place := c.GetString("drug_origin_place")
  257. drug_dosage_form, _ := c.GetInt64("drug_dosage_form")
  258. medical_insurance_level, _ := c.GetInt64("medical_insurance_level")
  259. max_unit := c.GetString("max_unit")
  260. min_unit := c.GetString("min_unit")
  261. unit_matrixing := c.GetString("unit_matrixing")
  262. retail_price, _ := c.GetFloat("retail_price")
  263. last_price, _ := c.GetFloat("last_price")
  264. drug_control, _ := c.GetInt64("drug_control")
  265. number := c.GetString("number")
  266. drug_classify := c.GetString("drug_classify")
  267. drug_dose, _ := c.GetFloat("drug_dose")
  268. drug_dose_unit, _ := c.GetInt64("drug_dose_unit")
  269. medical_insurance_number := c.GetString("medical_insurance_number")
  270. provinces_code := c.GetString("provinces_code")
  271. manufacturer, _ := c.GetInt64("manufacturer")
  272. pharmacology_category, _ := c.GetInt64("pharmacology_category")
  273. statistics_category, _ := c.GetInt64("statistics_category")
  274. code := c.GetString("code")
  275. is_special_diseases, _ := c.GetInt64("is_special_diseases")
  276. is_record, _ := c.GetInt64("is_record")
  277. agent := c.GetString("agent")
  278. drug_status := c.GetString("drug_status")
  279. limit_remark := c.GetString("limit_remark")
  280. delivery_way := c.GetString("delivery_way")
  281. execution_frequency := c.GetString("execution_frequency")
  282. single_dose, _ := c.GetFloat("single_dose")
  283. fmt.Println("sigle_dose", single_dose)
  284. prescribing_number, _ := c.GetFloat("prescribing_number")
  285. label, _ := c.GetInt64("label")
  286. sort, _ := c.GetInt64("sort")
  287. is_use_doctor_advice, _ := c.GetInt64("is_use_doctor_advice")
  288. is_default, _ := c.GetInt64("is_default")
  289. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  290. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  291. is_charge_use, _ := c.GetInt64("is_charge_use")
  292. drug_code := c.GetString("drug_code")
  293. //unit := c.GetString("unit")
  294. dealer, _ := c.GetInt64("dealer")
  295. prescription_mark, _ := c.GetInt64("prescription_mark")
  296. social_security_directory_code := c.GetString("social_security_directory_code")
  297. record_date := c.GetString("record_date")
  298. timeLayout := "2006-01-02"
  299. loc, _ := time.LoadLocation("Local")
  300. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  301. drug_remark := c.GetString("drug_remark")
  302. min_number, _ := c.GetInt64("min_number")
  303. drug_day := c.GetString("drug_day")
  304. //dose, _ := c.GetFloat("dose")
  305. dose := c.GetString("dose")
  306. dose_unit := c.GetString("dose_unit")
  307. total, _ := c.GetFloat("total")
  308. min_price, _ := c.GetFloat("min_price")
  309. hosp_appr_flag, _ := c.GetInt64("hosp_appr_flag")
  310. lmt_used_flag, _ := c.GetInt64("lmt_used_flag")
  311. prescribing_number_unit := c.GetString("prescribing_number_unit")
  312. is_user, _ := c.GetInt64("is_user")
  313. sum_count, _ := c.GetInt64("sum_count")
  314. sum_in_count, _ := c.GetInt64("sum_in_count")
  315. is_pharmacy, _ := c.GetInt64("is_pharmacy")
  316. bbx01 := c.GetString("bbx01")
  317. bby01 := c.GetString("bby01")
  318. adminInfo := c.GetAdminUserInfo()
  319. drug, _ := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
  320. drugLib := &models.BaseDrugLib{
  321. ID: id,
  322. DrugName: drug_name,
  323. Pinyin: pinyin,
  324. Wubi: wubi,
  325. DrugAlias: drug_alias,
  326. DrugAliasPinyin: drug_alias_pinyin,
  327. DrugAliasWubi: drug_alias_wubi,
  328. DrugCategory: drug_category,
  329. DrugSpec: drug_spec,
  330. DrugType: drug_type,
  331. DrugStockLimit: drug_stock_limit,
  332. DrugOriginPlace: drug_origin_place,
  333. MedicalInsuranceLevel: medical_insurance_level,
  334. DrugDosageForm: drug_dosage_form,
  335. MaxUnit: max_unit,
  336. MinUnit: min_unit,
  337. UnitMatrixing: unit_matrixing,
  338. RetailPrice: retail_price,
  339. LastPrice: last_price,
  340. DrugControl: drug_control,
  341. Number: number,
  342. DrugClassify: drug_classify,
  343. DrugDose: drug_dose,
  344. DrugDoseUnit: drug_dose_unit,
  345. MedicalInsuranceNumber: medical_insurance_number,
  346. Manufacturer: manufacturer,
  347. PharmacologyCategory: pharmacology_category,
  348. StatisticsCategory: statistics_category,
  349. Code: code,
  350. IsSpecialDiseases: is_special_diseases,
  351. IsRecord: is_record,
  352. Agent: agent,
  353. DrugStatus: drug_status,
  354. LimitRemark: limit_remark,
  355. DeliveryWay: delivery_way,
  356. ExecutionFrequency: execution_frequency,
  357. PrescribingNumber: prescribing_number,
  358. Label: label,
  359. Sort: sort,
  360. IsUseDoctorAdvice: is_use_doctor_advice,
  361. IsDefault: is_default,
  362. IsChargePredict: is_charge_predict,
  363. IsStatisticsWork: is_statistics_work,
  364. IsChargeUse: is_charge_use,
  365. OrgId: adminInfo.CurrentOrgId,
  366. Status: 1,
  367. Ctime: drug.Ctime,
  368. Mtime: time.Now().Unix(),
  369. DrugCode: drug_code,
  370. Dealer: dealer,
  371. PrescriptionMark: prescription_mark,
  372. SocialSecurityDirectoryCode: social_security_directory_code,
  373. RecordDate: theTime.Unix(),
  374. DrugRemark: drug_remark,
  375. DrugDay: drug_day,
  376. HospApprFlag: hosp_appr_flag,
  377. LmtUsedFlag: lmt_used_flag,
  378. MinNumber: min_number,
  379. Dose: dose,
  380. MinPrice: min_price,
  381. DoseUnit: dose_unit,
  382. PrescribingNumberUnit: prescribing_number_unit,
  383. Total: total,
  384. SingleDose: drug_dose,
  385. ProvincesCode: provinces_code,
  386. IsUse: is_user,
  387. SumCount: sum_count,
  388. SumInCount: sum_in_count,
  389. IsPharmacy: is_pharmacy,
  390. ZuobiaoId: bbx01,
  391. Bby01: bby01,
  392. Bbx01: bbx01,
  393. }
  394. if adminInfo.CurrentOrgId == 10206 || adminInfo.CurrentOrgId == 10344 {
  395. drugLib.DrugSpec = drugLib.Dose + drugLib.DoseUnit + "*" + string(drugLib.MinNumber) + drugLib.MinUnit + "/" + drugLib.MaxUnit
  396. }
  397. err := service.UpdateBaseDrugLib(drugLib)
  398. //查询是否存在
  399. _, errOne := service.GetDrugNameIsExist(id, adminInfo.CurrentOrgId)
  400. if errOne == gorm.ErrRecordNotFound {
  401. c.ServeSuccessJSON(map[string]interface{}{
  402. "msg": "修改成功",
  403. })
  404. return
  405. } else if errOne == nil {
  406. //修改xt_drug_name 表
  407. drugName := models.XtDrugName{
  408. DrugName: drug_name,
  409. }
  410. service.UpdatedDrugName(id, adminInfo.CurrentOrgId, &drugName)
  411. }
  412. //查询是否存在
  413. _, errTwo := service.GetStandNameIsExist(id, adminInfo.CurrentOrgId)
  414. if errTwo == gorm.ErrRecordNotFound {
  415. c.ServeSuccessJSON(map[string]interface{}{
  416. "msg": "修改成功",
  417. })
  418. return
  419. } else if errTwo == nil {
  420. //修改规格xt_stand_name表
  421. standName := models.XtStandName{
  422. DrugName: drug_name,
  423. DrugSpec: drug_spec,
  424. DrugStockLimit: drug_stock_limit,
  425. MinUnit: min_unit,
  426. }
  427. service.UpdateStandName(id, adminInfo.CurrentOrgId, &standName)
  428. }
  429. _, errThree := service.GetSelfMedicalIsExist(id, adminInfo.CurrentOrgId)
  430. if errThree == gorm.ErrRecordNotFound {
  431. c.ServeSuccessJSON(map[string]interface{}{
  432. "msg": "修改成功",
  433. })
  434. return
  435. } else if errThree == nil {
  436. //修改药品表
  437. medical := models.XtSelfMedical{
  438. DrugName: drug_name,
  439. DrugSpec: drug_spec,
  440. ExecutionFrequency: execution_frequency,
  441. PrescribingNumber: prescribing_number,
  442. DeliveryWay: delivery_way,
  443. SingleDose: single_dose,
  444. MinUnit: min_unit,
  445. }
  446. service.UpdateSelfMedical(id, adminInfo.CurrentOrgId, &medical)
  447. }
  448. _, errFour := service.GetSelfStosckIsExist(id, adminInfo.CurrentOrgId)
  449. if errFour == gorm.ErrRecordNotFound {
  450. c.ServeSuccessJSON(map[string]interface{}{
  451. "msg": "修改成功",
  452. })
  453. return
  454. } else if errFour == nil {
  455. stock := models.XtSelfStock{
  456. DrugSpec: drug_spec,
  457. DrugName: drug_name,
  458. MinUnit: min_unit,
  459. }
  460. service.UpdatedSelfStock(&stock, id, adminInfo.CurrentOrgId)
  461. }
  462. _, errFive := service.GetOutSelfOutStockIsExist(id, adminInfo.CurrentOrgId)
  463. if errFive == gorm.ErrRecordNotFound {
  464. c.ServeSuccessJSON(map[string]interface{}{
  465. "msg": "修改成功",
  466. })
  467. return
  468. } else if errFive == nil {
  469. outStock := models.XtSelfOutStock{
  470. DrugName: drug_name,
  471. DrugSpec: drug_spec,
  472. }
  473. //修改出库表
  474. service.UpdatedOutSelfStock(&outStock, id, adminInfo.CurrentOrgId)
  475. }
  476. _, errSix := service.GetDoctorAdviceIsExist(id, adminInfo.CurrentOrgId)
  477. if errSix == gorm.ErrRecordNotFound {
  478. fmt.Println("进来了吗5")
  479. c.ServeSuccessJSON(map[string]interface{}{
  480. "msg": "修改成功",
  481. })
  482. return
  483. } else if errSix == nil {
  484. //查询未执行的医嘱
  485. advice := models.DoctorAdvice{
  486. AdviceName: drug_name,
  487. AdviceDesc: drug_spec,
  488. DeliveryWay: delivery_way,
  489. ExecutionFrequency: execution_frequency,
  490. SingleDose: single_dose,
  491. SingleDoseUnit: min_unit,
  492. }
  493. service.UpdateNoExcuteDoctorAdvice(id, adminInfo.CurrentOrgId, &advice)
  494. }
  495. _, errSeven := service.GetDoctorAdviceTemplateIsExist(id, adminInfo.CurrentOrgId)
  496. if errSeven == gorm.ErrRecordNotFound {
  497. fmt.Println("进来了吗6")
  498. c.ServeSuccessJSON(map[string]interface{}{
  499. "msg": "修改成功",
  500. })
  501. return
  502. } else if errSeven == nil {
  503. //修改医嘱模板
  504. template := models.DoctorAdviceTemplate{
  505. AdviceName: drug_name,
  506. AdviceDesc: drug_spec,
  507. DeliveryWay: delivery_way,
  508. ExecutionFrequency: execution_frequency,
  509. SingleDose: single_dose,
  510. SingleDoseUnit: min_unit,
  511. }
  512. service.UpdatedDoctorAdviceTemplate(id, adminInfo.CurrentOrgId, &template)
  513. }
  514. if err == nil {
  515. c.ServeSuccessJSON(map[string]interface{}{
  516. "msg": "修改成功",
  517. })
  518. return
  519. } else {
  520. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  521. return
  522. }
  523. }
  524. func (c *ManagerCenterApiController) GetBaseDrugLib() {
  525. id, _ := c.GetInt64("id")
  526. adminInfo := c.GetAdminUserInfo()
  527. drug, err := service.FindBaseDrugLibRecord(adminInfo.CurrentOrgId, id)
  528. if err == nil {
  529. c.ServeSuccessJSON(map[string]interface{}{
  530. "drug": drug,
  531. })
  532. return
  533. } else {
  534. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  535. return
  536. }
  537. }
  538. func (c *ManagerCenterApiController) GetBaseDrugLibList() {
  539. page, _ := c.GetInt64("page", 1)
  540. limit, _ := c.GetInt64("limit", 10)
  541. is_use, _ := c.GetInt64("is_use", 0)
  542. is_charge, _ := c.GetInt64("is_charge", 0)
  543. is_inject, _ := c.GetInt64("is_inject", 0)
  544. manufacturer, _ := c.GetInt64("manufacturer")
  545. is_record, _ := c.GetInt64("is_record")
  546. keyword := c.GetString("keyword")
  547. adminInfo := c.GetAdminUserInfo()
  548. if page <= 0 {
  549. page = 1
  550. }
  551. if limit <= 0 {
  552. limit = 10
  553. }
  554. list, total, _ := service.GetBaseDrugLibList(adminInfo.CurrentOrgId, keyword, page, limit, is_use, is_charge, is_inject, manufacturer, is_record)
  555. c.ServeSuccessJSON(map[string]interface{}{
  556. "list": list,
  557. "total": total,
  558. })
  559. return
  560. }
  561. func (c *ManagerCenterApiController) CreateMedicineInsurancePercent() {
  562. module, _ := c.GetInt64("module", 0)
  563. adminInfo := c.GetAdminUserInfo()
  564. dataBody := make(map[string]interface{}, 0)
  565. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  566. if err != nil {
  567. utils.ErrorLog(err.Error())
  568. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  569. return
  570. }
  571. var mips []*models.MedicineInsurancePercentage
  572. var errs error
  573. record_time := time.Now().Unix()
  574. if dataBody["mip"] != nil && reflect.TypeOf(dataBody["mip"]).String() == "[]interface {}" {
  575. mip_map, _ := dataBody["mip"].([]interface{})
  576. if len(mip_map) > 0 {
  577. for _, item := range mip_map {
  578. items := item.(map[string]interface{})
  579. if items["type_id"] == nil || reflect.TypeOf(items["type_id"]).String() != "float64" {
  580. utils.ErrorLog("type_id")
  581. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  582. return
  583. }
  584. type_id := int64(items["type_id"].(float64))
  585. if items["medicine_insurance_type"] == nil || reflect.TypeOf(items["medicine_insurance_type"]).String() != "float64" {
  586. utils.ErrorLog("medicine_insurance_type")
  587. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  588. return
  589. }
  590. types := int64(items["medicine_insurance_type"].(float64))
  591. if items["percent"] == nil || reflect.TypeOf(items["percent"]).String() != "string" {
  592. utils.ErrorLog("percent")
  593. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  594. return
  595. }
  596. percent, _ := strconv.ParseFloat(items["percent"].(string), 64)
  597. //percent := items["percent"].(float64)
  598. mip_temp := &models.MedicineInsurancePercentage{
  599. TypeId: type_id,
  600. Status: 1,
  601. Ctime: time.Now().Unix(),
  602. Mtime: time.Now().Unix(),
  603. RecordTime: record_time,
  604. MedicineInsuranceType: types,
  605. UserOrgId: adminInfo.CurrentOrgId,
  606. Percent: percent,
  607. Module: module,
  608. GoodId: 0,
  609. }
  610. mips = append(mips, mip_temp)
  611. }
  612. }
  613. for _, item := range mips {
  614. errs = service.CreateMedicineInsurancePercentage(item)
  615. }
  616. }
  617. if errs == nil {
  618. c.ServeSuccessJSON(map[string]interface{}{
  619. "msg": "添加成功",
  620. })
  621. return
  622. } else {
  623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  624. return
  625. }
  626. }
  627. func (c *ManagerCenterApiController) CreateDrugUnitSafeguard() {
  628. }
  629. // GetPatientsList 取配置信息列表
  630. func (c *ManagerCenterApiController) GetConfigList() {
  631. adminUserInfo := c.GetAdminUserInfo()
  632. configList, _ := service.GetDictionaryConfigList(adminUserInfo.CurrentOrgId)
  633. c.ServeSuccessJSON(map[string]interface{}{
  634. "configlist": configList,
  635. })
  636. return
  637. }
  638. func (c *ManagerCenterApiController) GetManageConfigList() {
  639. adminUserInfo := c.GetAdminUserInfo()
  640. configList, _ := service.GetConfigList(adminUserInfo.CurrentOrgId)
  641. fmt.Println("configListwowowowowowowowowowowowo", configList)
  642. c.ServeSuccessJSON(map[string]interface{}{
  643. "configlist": configList,
  644. })
  645. return
  646. }
  647. // CreateConfig 创建配置信息
  648. func (c *ManagerCenterApiController) CreateConfig() {
  649. adminUserInfo := c.GetAdminUserInfo()
  650. var dataconfig models.DictionaryDataconfig
  651. var resultConfig models.DictionaryConfigViewModel
  652. code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
  653. if code > 0 {
  654. c.ServeFailJSONWithSGJErrorCode(code)
  655. return
  656. }
  657. // 验证关键字段的值是否重复
  658. thisConfig, _ := service.FindDictionaryConfigByTitle(dataconfig.Module, dataconfig.FieldName, adminUserInfo.CurrentOrgId)
  659. if thisConfig.ID > 0 {
  660. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  661. return
  662. }
  663. fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, adminUserInfo.CurrentOrgId)
  664. dataconfig.Value = fieldValue + 1
  665. dataBody := make(map[string]interface{}, 0)
  666. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  667. if err != nil {
  668. utils.ErrorLog(err.Error())
  669. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  670. return
  671. }
  672. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  673. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  674. dataconfig.Status = 1
  675. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  676. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  677. dataconfig.Remark = string(dataBody["remark"].(string))
  678. if dataBody["order"] != nil {
  679. dataconfig.Order = int64(dataBody["order"].(float64))
  680. } else {
  681. dataconfig.Order = 0
  682. }
  683. err = service.CreateDictionaryConfig(&dataconfig)
  684. if err != nil {
  685. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  686. return
  687. } else {
  688. resultConfig.ID = dataconfig.ID
  689. resultConfig.Module = dataconfig.Module
  690. resultConfig.Name = dataconfig.Name
  691. resultConfig.OrgId = dataconfig.OrgId
  692. resultConfig.ParentId = dataconfig.ParentId
  693. resultConfig.FieldName = dataconfig.FieldName
  694. resultConfig.CreateUserId = dataconfig.CreateUserId
  695. resultConfig.Title = dataconfig.Title
  696. resultConfig.Content = dataconfig.Content
  697. }
  698. c.ServeSuccessJSON(map[string]interface{}{
  699. "dataconfig": resultConfig,
  700. "msg": "ok",
  701. })
  702. return
  703. }
  704. func (c *ManagerCenterApiController) UpdateTemplate() {
  705. adminUserInfo := c.GetAdminUserInfo()
  706. var dataconfig models.DictionaryDataconfig
  707. code := dictionaryConfigFormData(&dataconfig, c.Ctx.Input.RequestBody)
  708. if code > 0 {
  709. c.ServeFailJSONWithSGJErrorCode(code)
  710. return
  711. }
  712. dataBody := make(map[string]interface{}, 0)
  713. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  714. if err != nil {
  715. utils.ErrorLog(err.Error())
  716. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  717. return
  718. }
  719. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  720. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  721. dataconfig.Status = 1
  722. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  723. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  724. dataconfig.Remark = string(dataBody["remark"].(string))
  725. if dataBody["order"] != nil {
  726. dataconfig.Order = int64(dataBody["order"].(float64))
  727. } else {
  728. dataconfig.Order = 0
  729. }
  730. // 验证关键字段的值是否重复
  731. // cur_id := int64(dataBody["id"].(float64))
  732. // thisConfig,_:=service.FindConfigByTitleForUpdate(dataconfig.Module, dataconfig.Title,dataconfig.OrgId,cur_id)
  733. // if thisConfig.ID >0 {
  734. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  735. // return
  736. // }
  737. configOrgId := int64(dataBody["org_id"].(float64))
  738. if configOrgId == 0 {
  739. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  740. err := service.CreateDictionaryConfig(&dataconfig)
  741. if err != nil {
  742. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  743. return
  744. }
  745. } else {
  746. dataconfig.ID = int64(dataBody["id"].(float64))
  747. err = service.UpdateDictionaryTemplate(&dataconfig)
  748. if err != nil {
  749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  750. return
  751. }
  752. }
  753. c.ServeSuccessJSON(map[string]interface{}{
  754. "dataconfig": dataconfig,
  755. "msg": "ok",
  756. })
  757. return
  758. }
  759. func (c *ManagerCenterApiController) UpdateChildConfig() {
  760. adminUserInfo := c.GetAdminUserInfo()
  761. var dataconfig models.DictionaryDataconfig
  762. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  763. if code > 0 {
  764. c.ServeFailJSONWithSGJErrorCode(code)
  765. return
  766. }
  767. dataBody := make(map[string]interface{}, 0)
  768. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  769. if err != nil {
  770. utils.ErrorLog(err.Error())
  771. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  772. return
  773. }
  774. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  775. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  776. dataconfig.Status = 1
  777. dataconfig.Value = int(int64(dataBody["value"].(float64)))
  778. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  779. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  780. dataconfig.Remark = string(dataBody["remark"].(string))
  781. dataconfig.Order = int64(dataBody["orders"].(float64))
  782. dataconfig.Code = string(dataBody["code"].(string))
  783. //if dataBody["orders"] != nil {
  784. // dataconfig.Order = int64(dataBody["orders"].(float64))
  785. // fmt.Println("dataconfig",dataconfig.Order)
  786. //} else {
  787. // dataconfig.Order = 0
  788. //}
  789. configOrgId := int64(dataBody["org_id"].(float64))
  790. // 验证关键字段的值是否重复
  791. // configId := int64(dataBody["id"].(float64))
  792. // thisConfig,_:=service.FindConfigByNameForUpdate(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId,configId)
  793. // if thisConfig.ID >0 {
  794. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  795. // return
  796. // }
  797. if configOrgId == 0 {
  798. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  799. err := service.CreateDictionaryConfig(&dataconfig)
  800. if err != nil {
  801. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  802. return
  803. }
  804. } else {
  805. dataconfig.ID = int64(dataBody["id"].(float64))
  806. err = service.UpdateDictionaryChildConfig(&dataconfig)
  807. if err != nil {
  808. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  809. return
  810. }
  811. }
  812. c.ServeSuccessJSON(map[string]interface{}{
  813. "dataconfig": dataconfig,
  814. "msg": "ok",
  815. })
  816. return
  817. }
  818. func (c *ManagerCenterApiController) DeleteChildConfig() {
  819. adminUserInfo := c.GetAdminUserInfo()
  820. var dataconfig models.DictionaryDataconfig
  821. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  822. if code > 0 {
  823. c.ServeFailJSONWithSGJErrorCode(code)
  824. return
  825. }
  826. dataBody := make(map[string]interface{}, 0)
  827. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  828. if err != nil {
  829. utils.ErrorLog(err.Error())
  830. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  831. return
  832. }
  833. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  834. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  835. dataconfig.Status = 0
  836. dataconfig.Value = int(int64(dataBody["value"].(float64)))
  837. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  838. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  839. dataconfig.Remark = string(dataBody["remark"].(string))
  840. if dataBody["order"] != nil {
  841. dataconfig.Order = int64(dataBody["order"].(float64))
  842. } else {
  843. dataconfig.Order = 0
  844. }
  845. configOrgId := int64(dataBody["org_id"].(float64))
  846. if configOrgId == 0 {
  847. dataconfig.DeleteIdSystem = int64(dataBody["id"].(float64))
  848. err := service.CreateDictionaryConfig(&dataconfig)
  849. if err != nil {
  850. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  851. return
  852. }
  853. } else {
  854. dataconfig.ID = int64(dataBody["id"].(float64))
  855. err := service.DeleteDictionaryChildConfig(&dataconfig)
  856. if err != nil {
  857. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeUpdateConfig)
  858. return
  859. }
  860. }
  861. c.ServeSuccessJSON(map[string]interface{}{
  862. "dataconfig": dataconfig,
  863. "msg": "ok",
  864. })
  865. return
  866. }
  867. // CreateChildConfig 创建子配置信息
  868. func (c *ManagerCenterApiController) CreateChildConfig() {
  869. adminUserInfo := c.GetAdminUserInfo()
  870. var dataconfig models.DictionaryDataconfig
  871. code := dictionaryConfigChildFormData(&dataconfig, c.Ctx.Input.RequestBody)
  872. if code > 0 {
  873. c.ServeFailJSONWithSGJErrorCode(code)
  874. return
  875. }
  876. dataBody := make(map[string]interface{}, 0)
  877. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  878. if err != nil {
  879. utils.ErrorLog(err.Error())
  880. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  881. return
  882. }
  883. dataconfig.OrgId = adminUserInfo.CurrentOrgId
  884. dataconfig.CreateUserId = adminUserInfo.AdminUser.Id
  885. dataconfig.Status = 1
  886. dataconfig.CreatedTime = time.Now().Format("2006-01-02 15:04:05")
  887. dataconfig.UpdatedTime = time.Now().Format("2006-01-02 15:04:05")
  888. dataconfig.Remark = string(dataBody["remark"].(string))
  889. dataconfig.Code = string(dataBody["code"].(string))
  890. fmt.Println("3444444444", dataconfig.Code)
  891. if dataBody["order"] != nil {
  892. dataconfig.Order = int64(dataBody["order"].(float64))
  893. } else {
  894. dataconfig.Order = 0
  895. }
  896. // 验证关键字段的值是否重复
  897. // thisConfig,_:=service.FindConfigByName(dataconfig.Module, dataconfig.Name,dataconfig.ParentId,dataconfig.OrgId)
  898. // if thisConfig.ID >0 {
  899. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeFieldExist)
  900. // return
  901. // }
  902. fieldValue := service.GetDictionaryChildValue(dataconfig.Module, dataconfig.ParentId, dataconfig.OrgId)
  903. dataconfig.Value = fieldValue + 1
  904. err = service.CreateDictionaryConfig(&dataconfig)
  905. if err != nil {
  906. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  907. return
  908. }
  909. c.ServeSuccessJSON(map[string]interface{}{
  910. "dataconfig": dataconfig,
  911. "msg": "ok",
  912. })
  913. return
  914. }
  915. func dictionaryConfigFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
  916. configBody := make(map[string]interface{}, 0)
  917. err := json.Unmarshal(data, &configBody)
  918. utils.InfoLog(string(data))
  919. if err != nil {
  920. utils.ErrorLog(err.Error())
  921. code = enums.ErrorCodeParamWrong
  922. return
  923. }
  924. if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
  925. utils.ErrorLog("module")
  926. code = enums.ErrorCodeParamWrong
  927. return
  928. }
  929. module, _ := configBody["module"].(string)
  930. if len(module) == 0 {
  931. utils.ErrorLog("len(module) == 0")
  932. code = enums.ErrorCodeParamWrong
  933. return
  934. }
  935. dataconfig.Module = module
  936. if module == "education" || module == "summary" || module == "course_disease" || module == "rescue_record" || module == "nursing_record" || module == "special_record" {
  937. if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
  938. utils.ErrorLog("title")
  939. code = enums.ErrorCodeParamWrong
  940. return
  941. }
  942. title, _ := configBody["title"].(string)
  943. if len(title) == 0 {
  944. utils.ErrorLog("len(title) == 0")
  945. code = enums.ErrorCodeParamWrong
  946. return
  947. }
  948. dataconfig.Title = title
  949. if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
  950. utils.ErrorLog("content")
  951. code = enums.ErrorCodeParamWrong
  952. return
  953. }
  954. content, _ := configBody["content"].(string)
  955. if len(content) == 0 {
  956. utils.ErrorLog("len(content) == 0")
  957. code = enums.ErrorCodeParamWrong
  958. return
  959. }
  960. dataconfig.Content = content
  961. } else {
  962. if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
  963. utils.ErrorLog("name")
  964. code = enums.ErrorCodeParamWrong
  965. return
  966. }
  967. name, _ := configBody["name"].(string)
  968. if len(name) == 0 {
  969. utils.ErrorLog("len(name) == 0")
  970. code = enums.ErrorCodeParamWrong
  971. return
  972. }
  973. dataconfig.Name = name
  974. if configBody["field_name"] == nil || reflect.TypeOf(configBody["field_name"]).String() != "string" {
  975. utils.ErrorLog("field_name")
  976. code = enums.ErrorCodeParamWrong
  977. return
  978. }
  979. field_name, _ := configBody["field_name"].(string)
  980. if len(field_name) == 0 {
  981. utils.ErrorLog("len(field_name) == 0")
  982. code = enums.ErrorCodeParamWrong
  983. return
  984. }
  985. dataconfig.FieldName = field_name
  986. }
  987. return
  988. }
  989. func dictionaryConfigChildFormData(dataconfig *models.DictionaryDataconfig, data []byte) (code int) {
  990. configBody := make(map[string]interface{}, 0)
  991. err := json.Unmarshal(data, &configBody)
  992. utils.InfoLog(string(data))
  993. if err != nil {
  994. utils.ErrorLog(err.Error())
  995. code = enums.ErrorCodeParamWrong
  996. return
  997. }
  998. if configBody["module"] == nil || reflect.TypeOf(configBody["module"]).String() != "string" {
  999. utils.ErrorLog("module")
  1000. code = enums.ErrorCodeParamWrong
  1001. return
  1002. }
  1003. module, _ := configBody["module"].(string)
  1004. if len(module) == 0 {
  1005. utils.ErrorLog("len(module) == 0")
  1006. code = enums.ErrorCodeParamWrong
  1007. return
  1008. }
  1009. dataconfig.Module = module
  1010. if module == "education" || module == "summary" {
  1011. if configBody["title"] == nil || reflect.TypeOf(configBody["title"]).String() != "string" {
  1012. utils.ErrorLog("title")
  1013. code = enums.ErrorCodeParamWrong
  1014. return
  1015. }
  1016. title, _ := configBody["title"].(string)
  1017. if len(title) == 0 {
  1018. utils.ErrorLog("len(title) == 0")
  1019. code = enums.ErrorCodeParamWrong
  1020. return
  1021. }
  1022. dataconfig.Title = title
  1023. if configBody["content"] == nil || reflect.TypeOf(configBody["content"]).String() != "string" {
  1024. utils.ErrorLog("content")
  1025. code = enums.ErrorCodeParamWrong
  1026. return
  1027. }
  1028. content, _ := configBody["content"].(string)
  1029. if len(content) == 0 {
  1030. utils.ErrorLog("len(content) == 0")
  1031. code = enums.ErrorCodeParamWrong
  1032. return
  1033. }
  1034. dataconfig.Content = content
  1035. } else {
  1036. if configBody["parent_id"] == nil || reflect.TypeOf(configBody["parent_id"]).String() != "float64" {
  1037. utils.ErrorLog("module")
  1038. code = enums.ErrorCodeParamWrong
  1039. return
  1040. }
  1041. parent_id := int64(configBody["parent_id"].(float64))
  1042. if parent_id <= 0 {
  1043. utils.ErrorLog("parent_id <= 0")
  1044. code = enums.ErrorCodeParamWrong
  1045. return
  1046. }
  1047. dataconfig.ParentId = parent_id
  1048. if configBody["name"] == nil || reflect.TypeOf(configBody["name"]).String() != "string" {
  1049. utils.ErrorLog("name")
  1050. code = enums.ErrorCodeParamWrong
  1051. return
  1052. }
  1053. name, _ := configBody["name"].(string)
  1054. if len(name) == 0 {
  1055. utils.ErrorLog("len(name) == 0")
  1056. code = enums.ErrorCodeParamWrong
  1057. return
  1058. }
  1059. dataconfig.Name = name
  1060. }
  1061. return
  1062. }
  1063. func (c *ManagerCenterApiController) CreateDealer() {
  1064. dealer_name := c.GetString("dealer_name")
  1065. contact := c.GetString("contact")
  1066. contact_phone := c.GetString("contact_phone")
  1067. platform_number := c.GetString("platform_number")
  1068. email := c.GetString("email")
  1069. contact_address := c.GetString("contact_address")
  1070. remark := c.GetString("remark")
  1071. pinyin := c.GetString("pinyin")
  1072. wubi := c.GetString("wubi")
  1073. if len(dealer_name) <= 0 {
  1074. utils.ErrorLog("len(dealer_name) == 0")
  1075. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1076. return
  1077. }
  1078. adminUserInfo := c.GetAdminUserInfo()
  1079. total := service.FindAllDealerTotal(adminUserInfo.CurrentOrgId)
  1080. totalStr := strconv.FormatInt(total+1, 10)
  1081. code := "1000" + totalStr
  1082. dealer := models.Dealer{
  1083. DealerName: dealer_name,
  1084. Contact: contact,
  1085. ContactPhone: contact_phone,
  1086. ContactAddress: contact_address,
  1087. DealerCode: code,
  1088. Ctime: time.Now().Unix(),
  1089. Mtime: time.Now().Unix(),
  1090. Remark: remark,
  1091. Creater: adminUserInfo.AdminUser.Id,
  1092. Email: email,
  1093. PlatformNumber: platform_number,
  1094. OrgId: adminUserInfo.CurrentOrgId,
  1095. Status: 1,
  1096. PinYin: pinyin,
  1097. WuBi: wubi,
  1098. }
  1099. err, dealers := service.AddSigleDealer(&dealer)
  1100. if err == nil {
  1101. c.ServeSuccessJSON(map[string]interface{}{
  1102. "dealer": dealers,
  1103. })
  1104. } else {
  1105. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1106. }
  1107. }
  1108. func (c *ManagerCenterApiController) ModifyDealer() {
  1109. id, _ := c.GetInt64("id", 0)
  1110. dealer_name := c.GetString("dealer_name")
  1111. contact := c.GetString("contact")
  1112. contact_phone := c.GetString("contact_phone")
  1113. platform_number := c.GetString("platform_number")
  1114. dealer_code := c.GetString("dealer_code")
  1115. email := c.GetString("email")
  1116. contact_address := c.GetString("contact_address")
  1117. remark := c.GetString("remark")
  1118. pinyin := c.GetString("pinyin")
  1119. wubi := c.GetString("wubi")
  1120. if id <= 0 {
  1121. utils.ErrorLog("id == 0")
  1122. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1123. return
  1124. }
  1125. if len(dealer_name) <= 0 {
  1126. utils.ErrorLog("len(dealer_name) == 0")
  1127. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1128. return
  1129. }
  1130. adminUserInfo := c.GetAdminUserInfo()
  1131. dealer := models.Dealer{
  1132. ID: id,
  1133. DealerName: dealer_name,
  1134. Contact: contact,
  1135. ContactPhone: contact_phone,
  1136. ContactAddress: contact_address,
  1137. Mtime: time.Now().Unix(),
  1138. DealerCode: dealer_code,
  1139. Remark: remark,
  1140. Creater: adminUserInfo.AdminUser.Id,
  1141. Email: email,
  1142. PlatformNumber: platform_number,
  1143. Modifier: adminUserInfo.AdminUser.Id,
  1144. OrgId: adminUserInfo.CurrentOrgId,
  1145. Status: 1,
  1146. PinYin: pinyin,
  1147. WuBi: wubi,
  1148. }
  1149. err := service.ModifyDealer(&dealer)
  1150. if err == nil {
  1151. c.ServeSuccessJSON(map[string]interface{}{
  1152. "dealer": dealer,
  1153. })
  1154. } else {
  1155. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1156. }
  1157. }
  1158. func (c *ManagerCenterApiController) GetDealersList() {
  1159. page, _ := c.GetInt64("page", 1)
  1160. limit, _ := c.GetInt64("limit", 7)
  1161. key, _ := c.GetInt64("key", 0)
  1162. adminUserInfo := c.GetAdminUserInfo()
  1163. deales, total, err := service.FindAllDealerList(adminUserInfo.CurrentOrgId, page, limit, key)
  1164. if err == nil {
  1165. c.ServeSuccessJSON(map[string]interface{}{
  1166. "dealer": deales,
  1167. "total": total,
  1168. })
  1169. } else {
  1170. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1171. }
  1172. }
  1173. func (c *ManagerCenterApiController) DeleteDealer() {
  1174. id, _ := c.GetInt64("id", 0)
  1175. total, _ := service.FindStockInByDealerId(id)
  1176. if total > 0 {
  1177. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteDealerWrong)
  1178. return
  1179. }
  1180. err := service.DeleteDealerById(id)
  1181. if err == nil {
  1182. c.ServeSuccessJSON(map[string]interface{}{
  1183. "msg": "删除成功",
  1184. })
  1185. } else {
  1186. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1187. }
  1188. }
  1189. func (c *ManagerCenterApiController) GetDealer() {
  1190. id, _ := c.GetInt64("id", 0)
  1191. dealer, err := service.FindDealerById(id)
  1192. if err == nil {
  1193. c.ServeSuccessJSON(map[string]interface{}{
  1194. "dealer": dealer,
  1195. })
  1196. } else {
  1197. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1198. }
  1199. }
  1200. func (c *ManagerCenterApiController) CreateManufacturer() {
  1201. manufacturer_name := c.GetString("manufacturer_name")
  1202. contact := c.GetString("contact")
  1203. contact_phone := c.GetString("contact_phone")
  1204. platform_number := c.GetString("platform_number")
  1205. email := c.GetString("email")
  1206. contact_address := c.GetString("contact_address")
  1207. remark := c.GetString("remark")
  1208. pinyin := c.GetString("pinyin")
  1209. wubi := c.GetString("wubi")
  1210. if len(manufacturer_name) <= 0 {
  1211. utils.ErrorLog("len(manufacturer_name) == 0")
  1212. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1213. return
  1214. }
  1215. adminUserInfo := c.GetAdminUserInfo()
  1216. total := service.FindManufacturerTotal(adminUserInfo.CurrentOrgId)
  1217. totalStr := strconv.FormatInt(total+1, 10)
  1218. code := "2000" + totalStr
  1219. manufacturer := models.Manufacturer{
  1220. ManufacturerName: manufacturer_name,
  1221. Contact: contact,
  1222. ContactPhone: contact_phone,
  1223. ContactAddress: contact_address,
  1224. Ctime: time.Now().Unix(),
  1225. Mtime: time.Now().Unix(),
  1226. Remark: remark,
  1227. Creater: adminUserInfo.AdminUser.Id,
  1228. Email: email,
  1229. PlatformNumber: platform_number,
  1230. OrgId: adminUserInfo.CurrentOrgId,
  1231. Status: 1,
  1232. ManufacturerCode: code,
  1233. PinYin: pinyin,
  1234. WuBi: wubi,
  1235. }
  1236. err, manufacturers := service.AddSigleManufacturer(&manufacturer)
  1237. if err == nil {
  1238. c.ServeSuccessJSON(map[string]interface{}{
  1239. "manufacturer": manufacturers,
  1240. })
  1241. } else {
  1242. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1243. }
  1244. }
  1245. func (c *ManagerCenterApiController) ModifyManufacturer() {
  1246. id, _ := c.GetInt64("id", 0)
  1247. manufacturer_name := c.GetString("manufacturer_name")
  1248. contact := c.GetString("contact")
  1249. contact_phone := c.GetString("contact_phone")
  1250. platform_number := c.GetString("platform_number")
  1251. email := c.GetString("email")
  1252. contact_address := c.GetString("contact_address")
  1253. remark := c.GetString("remark")
  1254. manufacturer_code := c.GetString("manufacturer_code")
  1255. pinyin := c.GetString("pinyin")
  1256. wubi := c.GetString("wubi")
  1257. if id <= 0 {
  1258. utils.ErrorLog("id == 0")
  1259. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1260. return
  1261. }
  1262. if len(manufacturer_name) <= 0 {
  1263. utils.ErrorLog("len(manufacturer_name) == 0")
  1264. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1265. return
  1266. }
  1267. adminUserInfo := c.GetAdminUserInfo()
  1268. manufacturer := models.Manufacturer{
  1269. ID: id,
  1270. ManufacturerName: manufacturer_name,
  1271. Contact: contact,
  1272. ContactPhone: contact_phone,
  1273. ContactAddress: contact_address,
  1274. Mtime: time.Now().Unix(),
  1275. Remark: remark,
  1276. Creater: adminUserInfo.AdminUser.Id,
  1277. Email: email,
  1278. PlatformNumber: platform_number,
  1279. Modifier: adminUserInfo.AdminUser.Id,
  1280. OrgId: adminUserInfo.CurrentOrgId,
  1281. ManufacturerCode: manufacturer_code,
  1282. Status: 1,
  1283. PinYin: pinyin,
  1284. WuBi: wubi,
  1285. }
  1286. err := service.ModifyManufacturer(&manufacturer)
  1287. if err == nil {
  1288. c.ServeSuccessJSON(map[string]interface{}{
  1289. "manufacturer": manufacturer,
  1290. })
  1291. } else {
  1292. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1293. }
  1294. }
  1295. func (c *ManagerCenterApiController) GetManufacturerList() {
  1296. page, _ := c.GetInt64("page", 1)
  1297. limit, _ := c.GetInt64("limit", 10)
  1298. key, _ := c.GetInt64("key", 0)
  1299. adminUserInfo := c.GetAdminUserInfo()
  1300. manufacturer, total, err := service.FindAllManufacturerList(adminUserInfo.CurrentOrgId, page, limit, key)
  1301. if err == nil {
  1302. c.ServeSuccessJSON(map[string]interface{}{
  1303. "manufacturer": manufacturer,
  1304. "total": total,
  1305. })
  1306. } else {
  1307. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1308. }
  1309. }
  1310. func (c *ManagerCenterApiController) DeleteManufacturer() {
  1311. id, _ := c.GetInt64("id", 0)
  1312. total, _ := service.FindStockInByManufacturerId(id)
  1313. if total > 0 {
  1314. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteManufacturerWrong)
  1315. return
  1316. }
  1317. err := service.DeleteManufacturerById(id)
  1318. if err == nil {
  1319. c.ServeSuccessJSON(map[string]interface{}{
  1320. "msg": "删除成功",
  1321. })
  1322. } else {
  1323. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1324. }
  1325. }
  1326. func (c *ManagerCenterApiController) GetManufacturer() {
  1327. id, _ := c.GetInt64("id", 0)
  1328. manufacturer, err := service.FindManufacturerById(id)
  1329. if err == nil {
  1330. c.ServeSuccessJSON(map[string]interface{}{
  1331. "manufacturer": manufacturer,
  1332. })
  1333. } else {
  1334. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1335. }
  1336. }
  1337. func (c *ManagerCenterApiController) GetAllDealer() {
  1338. adminUserInfo := c.GetAdminUserInfo()
  1339. dealer, err := service.FindAllDealer(adminUserInfo.CurrentOrgId)
  1340. if err == nil {
  1341. c.ServeSuccessJSON(map[string]interface{}{
  1342. "dealer": dealer,
  1343. })
  1344. } else {
  1345. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1346. }
  1347. }
  1348. func (c *ManagerCenterApiController) GetAllManufacturer() {
  1349. adminUserInfo := c.GetAdminUserInfo()
  1350. manufacturer, err := service.FindAllManufacturer(adminUserInfo.CurrentOrgId)
  1351. if err == nil {
  1352. c.ServeSuccessJSON(map[string]interface{}{
  1353. "manufacturer": manufacturer,
  1354. })
  1355. } else {
  1356. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1357. }
  1358. }
  1359. func (c *ManagerCenterApiController) CreateGoodInfo() {
  1360. good_id, _ := c.GetInt64("good_id", 0)
  1361. specification_name := c.GetString("specification_name")
  1362. register_number := c.GetString("register_number")
  1363. good_unit, _ := c.GetInt64("good_unit", -1)
  1364. buy_price, _ := c.GetFloat("buy_price", 0)
  1365. sell_price, _ := c.GetFloat("sell_price", 0)
  1366. remark := c.GetString("remark")
  1367. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1368. dealer, _ := c.GetInt64("dealer", 0)
  1369. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1370. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1371. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1372. good_name := c.GetString("good_name")
  1373. pinyin := c.GetString("pinyin")
  1374. wubi := c.GetString("wubi")
  1375. good_kind, _ := c.GetInt64("good_kind", 0)
  1376. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1377. retail_price, _ := c.GetFloat("retail_price", 0)
  1378. fmt.Println(retail_price)
  1379. medical_insurance_number := c.GetString("medical_insurance_number")
  1380. provinces_code := c.GetString("provinces_code")
  1381. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1382. is_record, _ := c.GetInt64("is_record")
  1383. statistics_category, _ := c.GetInt64("statistics_category")
  1384. good_status := c.GetString("good_status")
  1385. default_count, _ := c.GetInt64("default_count")
  1386. sign, _ := c.GetInt64("sign")
  1387. is_default, _ := c.GetInt64("is_default")
  1388. is_charge_use, _ := c.GetInt64("is_charge_use")
  1389. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1390. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1391. sort, _ := c.GetInt64("sort")
  1392. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1393. agent := c.GetString("agent")
  1394. good_number := c.GetString("good_number")
  1395. social_security_directory_code := c.GetString("social_security_directory_code")
  1396. production_type := c.GetString("production_type")
  1397. special_medical := c.GetString("special_medical")
  1398. min_number, _ := c.GetInt64("min_number")
  1399. packing_unit := c.GetString("packing_unit")
  1400. packing_price, _ := c.GetFloat("packing_price")
  1401. min_unit := c.GetString("min_unit")
  1402. default_count_unit := c.GetString("default_count_unit")
  1403. is_user, _ := c.GetInt64("is_user")
  1404. number := c.GetString("number")
  1405. is_warehouse, _ := c.GetInt64("is_warehouse")
  1406. bbx01 := c.GetString("bbx01")
  1407. bby01 := c.GetString("bby01")
  1408. adminUserInfo := c.GetAdminUserInfo()
  1409. totals := service.FindGoodInfoByNameTwo(specification_name, adminUserInfo.CurrentOrgId, good_id, good_name)
  1410. if totals > 0 {
  1411. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1412. return
  1413. }
  1414. total := service.FindAllGoodInfoTotal(adminUserInfo.CurrentOrgId)
  1415. code := strconv.FormatInt(total+1, 10)
  1416. code = "24000000" + code
  1417. goodInfo := models.GoodInfo{
  1418. GoodCode: code,
  1419. SpecificationName: specification_name,
  1420. GoodTypeId: good_id,
  1421. GoodUnit: good_unit,
  1422. BuyPrice: buy_price,
  1423. SellPrice: sell_price,
  1424. Remark: remark,
  1425. Ctime: time.Now().Unix(),
  1426. Manufacturer: manufacturer,
  1427. Dealer: dealer,
  1428. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1429. StockWarnCount: stock_warn_count,
  1430. IsReuse: is_reuse,
  1431. Status: 1,
  1432. OrgId: adminUserInfo.CurrentOrgId,
  1433. Creater: adminUserInfo.AdminUser.Id,
  1434. GoodName: good_name,
  1435. Pinyin: pinyin,
  1436. Wubi: wubi,
  1437. GoodKind: good_kind,
  1438. MedicalInsuranceNumber: medical_insurance_number,
  1439. IsSpecialDiseases: is_special_diseases,
  1440. IsRecord: is_record,
  1441. StatisticsCategory: statistics_category,
  1442. GoodStatus: good_status,
  1443. DefaultCount: default_count,
  1444. Sign: sign,
  1445. IsDefault: is_default,
  1446. IsChargeUse: is_charge_use,
  1447. IsChargePredict: is_charge_predict,
  1448. IsStatisticsWork: is_statistics_work,
  1449. Sort: sort,
  1450. IsDoctorUse: is_doctor_use,
  1451. Agent: agent,
  1452. GoodNumber: good_number,
  1453. MedicalInsuranceLevel: medical_insurance_level,
  1454. RetailPrice: packing_price,
  1455. SocialSecurityDirectoryCode: social_security_directory_code,
  1456. ProductionType: production_type,
  1457. SpecialMedical: special_medical,
  1458. MinNumber: min_number,
  1459. PackingUnit: packing_unit,
  1460. PackingPrice: packing_price,
  1461. DefaultCountUnit: default_count_unit,
  1462. MinUnit: min_unit,
  1463. RegisterNumber: register_number,
  1464. ProvincesCode: provinces_code,
  1465. IsUser: is_user,
  1466. Number: number,
  1467. IsWarehouse: is_warehouse,
  1468. Bbx01: bbx01,
  1469. Bby01: bby01,
  1470. ZuobiaoId: bbx01,
  1471. }
  1472. err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
  1473. if err == nil {
  1474. c.ServeSuccessJSON(map[string]interface{}{
  1475. "goodInfo": goodInfos,
  1476. })
  1477. } else {
  1478. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1479. }
  1480. }
  1481. func (c *ManagerCenterApiController) ModifyGoodInfo() {
  1482. id, _ := c.GetInt64("id", 0)
  1483. good_id, _ := c.GetInt64("good_id", 0)
  1484. specification_name := c.GetString("specification_name")
  1485. good_unit, _ := c.GetInt64("good_unit", -1)
  1486. buy_price, _ := c.GetFloat("buy_price", 0)
  1487. sell_price, _ := c.GetFloat("sell_price", 0)
  1488. remark := c.GetString("remark")
  1489. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1490. dealer, _ := c.GetInt64("dealer", 0)
  1491. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1492. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1493. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1494. code := c.GetString("good_code")
  1495. provinces_code := c.GetString("provinces_code")
  1496. good_name := c.GetString("good_name")
  1497. pinyin := c.GetString("pinyin")
  1498. wubi := c.GetString("wubi")
  1499. good_kind, _ := c.GetInt64("good_kind", 0)
  1500. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1501. retail_price, _ := c.GetFloat("retail_price", 0)
  1502. fmt.Println(retail_price)
  1503. medical_insurance_number := c.GetString("medical_insurance_number")
  1504. //provinces_code := c.GetString("provinces_code")
  1505. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1506. is_record, _ := c.GetInt64("is_record")
  1507. statistics_category, _ := c.GetInt64("statistics_category")
  1508. good_status := c.GetString("good_status")
  1509. default_count, _ := c.GetInt64("default_count")
  1510. sign, _ := c.GetInt64("sign")
  1511. is_default, _ := c.GetInt64("is_default")
  1512. is_charge_use, _ := c.GetInt64("is_charge_use")
  1513. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1514. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1515. sort, _ := c.GetInt64("sort")
  1516. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1517. agent := c.GetString("agent")
  1518. good_number := c.GetString("good_number")
  1519. social_security_directory_code := c.GetString("social_security_directory_code")
  1520. production_type := c.GetString("production_type")
  1521. special_medical := c.GetString("special_medical")
  1522. min_number, _ := c.GetInt64("min_number")
  1523. packing_unit := c.GetString("packing_unit")
  1524. packing_price, _ := c.GetFloat("packing_price")
  1525. default_count_unit := c.GetString("default_count_unit")
  1526. min_unit := c.GetString("min_unit")
  1527. total, _ := c.GetFloat("total")
  1528. register_number := c.GetString("register_number")
  1529. is_user, _ := c.GetInt64("is_user")
  1530. number := c.GetString("number")
  1531. is_warehouse, _ := c.GetInt64("is_warehouse")
  1532. bbx01 := c.GetString("bbx01")
  1533. bby01 := c.GetString("bby01")
  1534. adminUserInfo := c.GetAdminUserInfo()
  1535. goodInfo := models.GoodInfo{
  1536. ID: id,
  1537. GoodCode: code,
  1538. SpecificationName: specification_name,
  1539. GoodTypeId: good_id,
  1540. GoodUnit: good_unit,
  1541. BuyPrice: buy_price,
  1542. SellPrice: sell_price,
  1543. Remark: remark,
  1544. Mtime: time.Now().Unix(),
  1545. Manufacturer: manufacturer,
  1546. Dealer: dealer,
  1547. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1548. StockWarnCount: stock_warn_count,
  1549. IsReuse: is_reuse,
  1550. Status: 1,
  1551. OrgId: adminUserInfo.CurrentOrgId,
  1552. Modifier: adminUserInfo.AdminUser.Id,
  1553. GoodName: good_name,
  1554. Pinyin: pinyin,
  1555. Wubi: wubi,
  1556. GoodKind: good_kind,
  1557. MedicalInsuranceNumber: medical_insurance_number,
  1558. ProvincesCode: provinces_code,
  1559. IsSpecialDiseases: is_special_diseases,
  1560. IsRecord: is_record,
  1561. StatisticsCategory: statistics_category,
  1562. GoodStatus: good_status,
  1563. DefaultCount: default_count,
  1564. Sign: sign,
  1565. IsDefault: is_default,
  1566. IsChargeUse: is_charge_use,
  1567. IsChargePredict: is_charge_predict,
  1568. IsStatisticsWork: is_statistics_work,
  1569. Sort: sort,
  1570. IsDoctorUse: is_doctor_use,
  1571. Agent: agent,
  1572. GoodNumber: good_number,
  1573. MedicalInsuranceLevel: medical_insurance_level,
  1574. RetailPrice: packing_price,
  1575. SpecialMedical: special_medical,
  1576. SocialSecurityDirectoryCode: social_security_directory_code,
  1577. ProductionType: production_type,
  1578. MinNumber: min_number,
  1579. PackingUnit: packing_unit,
  1580. PackingPrice: packing_price,
  1581. DefaultCountUnit: default_count_unit,
  1582. MinUnit: min_unit,
  1583. Total: total,
  1584. RegisterNumber: register_number,
  1585. IsUser: is_user,
  1586. Number: number,
  1587. IsWarehouse: is_warehouse,
  1588. Bbx01: bbx01,
  1589. Bby01: bby01,
  1590. ZuobiaoId: bbx01,
  1591. }
  1592. totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)
  1593. if totals > 0 {
  1594. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1595. return
  1596. }
  1597. err, goodInfos := service.ModifyGoodInfo(&goodInfo)
  1598. if err == nil {
  1599. c.ServeSuccessJSON(map[string]interface{}{
  1600. "goodInfo": goodInfos,
  1601. })
  1602. } else {
  1603. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1604. }
  1605. }
  1606. func (c *ManagerCenterApiController) GetGoodInfoList() {
  1607. page, _ := c.GetInt64("page", 1)
  1608. limit, _ := c.GetInt64("limit", 7)
  1609. keyword := c.GetString("keyword")
  1610. is_use, _ := c.GetInt64("is_use")
  1611. is_charge, _ := c.GetInt64("is_charge")
  1612. good_kind, _ := c.GetInt64("good_kind")
  1613. is_mark, _ := c.GetInt64("is_mark")
  1614. manufacturer, _ := c.GetInt64("manufacturer")
  1615. is_type, _ := c.GetInt64("is_type")
  1616. adminUserInfo := c.GetAdminUserInfo()
  1617. goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind, is_mark, manufacturer, is_type)
  1618. if err == nil {
  1619. c.ServeSuccessJSON(map[string]interface{}{
  1620. "list": goodInfos,
  1621. "total": total,
  1622. })
  1623. } else {
  1624. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1625. }
  1626. }
  1627. func (c *ManagerCenterApiController) DeleteGoodInfo() {
  1628. id, _ := c.GetInt64("id", 0)
  1629. adminUserInfo := c.GetAdminUserInfo()
  1630. total, _ := service.FindWarehouseInfoTotalByGoodId(id)
  1631. total2, _ := service.FindWarehouseOutInfoTotalByGoodId(id)
  1632. if total > 0 {
  1633. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1634. return
  1635. }
  1636. if total2 > 0 {
  1637. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1638. return
  1639. }
  1640. err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
  1641. if err == nil {
  1642. c.ServeSuccessJSON(map[string]interface{}{
  1643. "msg": "删除成功",
  1644. })
  1645. } else {
  1646. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1647. }
  1648. }
  1649. func (c *ManagerCenterApiController) GetGoodInfoByGoodId() {
  1650. id, _ := c.GetInt64("id", 0)
  1651. goodInfo, err := service.FindGoodInfoByGoodId(id)
  1652. if err == nil {
  1653. c.ServeSuccessJSON(map[string]interface{}{
  1654. "list": goodInfo,
  1655. })
  1656. } else {
  1657. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1658. }
  1659. }
  1660. func (c *ManagerCenterApiController) GetGoodInfoById() {
  1661. id, _ := c.GetInt64("id", 0)
  1662. goodInfo, err := service.FindGoodInfoById(id)
  1663. if err == nil {
  1664. c.ServeSuccessJSON(map[string]interface{}{
  1665. "goodInfo": goodInfo,
  1666. })
  1667. } else {
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1669. }
  1670. }
  1671. func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
  1672. adminUser := c.GetAdminUserInfo()
  1673. type_id, _ := c.GetInt64("type_id", 0)
  1674. module, _ := c.GetInt64("module", 0)
  1675. mip, err := service.GetLastMedicineInsurance(adminUser.CurrentOrgId, type_id, module)
  1676. if err == nil {
  1677. c.ServeSuccessJSON(map[string]interface{}{
  1678. "mip": mip,
  1679. })
  1680. } else {
  1681. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1682. }
  1683. }
  1684. func (c *ManagerCenterApiController) CreateMZSick() {
  1685. class_name := c.GetString("class_name")
  1686. content_code := c.GetString("content_code")
  1687. country_code := c.GetString("country_code")
  1688. country_content_name := c.GetString("country_content_name")
  1689. remark := c.GetString("remark")
  1690. pinyin := c.GetString("pinyin")
  1691. wubi := c.GetString("wubi")
  1692. if len(class_name) <= 0 {
  1693. utils.ErrorLog("len(class_name) == 0")
  1694. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1695. return
  1696. }
  1697. if len(content_code) <= 0 {
  1698. utils.ErrorLog("len(content_code) == 0")
  1699. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1700. return
  1701. }
  1702. adminUserInfo := c.GetAdminUserInfo()
  1703. dealer := models.OutpatientServiceSick{
  1704. ClassName: class_name,
  1705. ContentCode: content_code,
  1706. CountryCode: country_code,
  1707. CountryContentName: country_content_name,
  1708. Ctime: time.Now().Unix(),
  1709. Mtime: time.Now().Unix(),
  1710. Remark: remark,
  1711. UserOrgId: adminUserInfo.CurrentOrgId,
  1712. Status: 1,
  1713. Pinyin: pinyin,
  1714. Wubi: wubi,
  1715. }
  1716. err, dealers := service.AddSigleMZSick(&dealer)
  1717. if err == nil {
  1718. redis := service.RedisClient()
  1719. defer redis.Close()
  1720. sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
  1721. redis.Set(sick_keys, "", time.Second*60*60*18)
  1722. c.ServeSuccessJSON(map[string]interface{}{
  1723. "sick": dealers,
  1724. })
  1725. } else {
  1726. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1727. }
  1728. }
  1729. func (c *ManagerCenterApiController) ModifyMZSick() {
  1730. id, _ := c.GetInt64("id", 0)
  1731. class_name := c.GetString("class_name")
  1732. content_code := c.GetString("content_code")
  1733. country_code := c.GetString("country_code")
  1734. country_content_name := c.GetString("country_content_name")
  1735. remark := c.GetString("remark")
  1736. pinyin := c.GetString("pinyin")
  1737. wubi := c.GetString("wubi")
  1738. if id <= 0 {
  1739. utils.ErrorLog("id == 0")
  1740. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1741. return
  1742. }
  1743. if len(class_name) <= 0 {
  1744. utils.ErrorLog("len(class_name) == 0")
  1745. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1746. return
  1747. }
  1748. if len(content_code) <= 0 {
  1749. utils.ErrorLog("len(content_code) == 0")
  1750. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1751. return
  1752. }
  1753. adminUserInfo := c.GetAdminUserInfo()
  1754. dealer := models.OutpatientServiceSick{
  1755. ID: id,
  1756. ClassName: class_name,
  1757. ContentCode: content_code,
  1758. CountryCode: country_code,
  1759. CountryContentName: country_content_name,
  1760. Ctime: time.Now().Unix(),
  1761. Mtime: time.Now().Unix(),
  1762. Remark: remark,
  1763. UserOrgId: adminUserInfo.CurrentOrgId,
  1764. Pinyin: pinyin,
  1765. Wubi: wubi,
  1766. Status: 1,
  1767. }
  1768. err := service.ModifyMZSick(&dealer)
  1769. if err == nil {
  1770. redis := service.RedisClient()
  1771. defer redis.Close()
  1772. sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
  1773. redis.Set(sick_keys, "", time.Second*60*60*18)
  1774. c.ServeSuccessJSON(map[string]interface{}{
  1775. "sick": dealer,
  1776. })
  1777. } else {
  1778. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1779. }
  1780. }
  1781. func (c *ManagerCenterApiController) GetMZSickList() {
  1782. page, _ := c.GetInt64("page", 1)
  1783. limit, _ := c.GetInt64("limit", 7)
  1784. adminUserInfo := c.GetAdminUserInfo()
  1785. mzSick, total, err := service.FindAllMZSickList(adminUserInfo.CurrentOrgId, page, limit)
  1786. if err == nil {
  1787. c.ServeSuccessJSON(map[string]interface{}{
  1788. "sick": mzSick,
  1789. "total": total,
  1790. })
  1791. } else {
  1792. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1793. }
  1794. }
  1795. func (c *ManagerCenterApiController) DeleteMZSick() {
  1796. id, _ := c.GetInt64("id", 0)
  1797. err := service.DeleteMZSickById(id)
  1798. if err == nil {
  1799. redis := service.RedisClient()
  1800. defer redis.Close()
  1801. sick_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_sick"
  1802. redis.Set(sick_keys, "", time.Second*60*60*18)
  1803. c.ServeSuccessJSON(map[string]interface{}{
  1804. "msg": "删除成功",
  1805. })
  1806. } else {
  1807. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1808. }
  1809. }
  1810. func (c *ManagerCenterApiController) GetMZSick() {
  1811. id, _ := c.GetInt64("id", 0)
  1812. mzSick, err := service.FindMZSickById(id)
  1813. if err == nil {
  1814. c.ServeSuccessJSON(map[string]interface{}{
  1815. "sick": mzSick,
  1816. })
  1817. } else {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1819. }
  1820. }
  1821. func (c *ManagerCenterApiController) DeleteBaseDrugById() {
  1822. id, _ := c.GetInt64("id")
  1823. //查询入库单
  1824. _, errcode := service.GetDrugWareoutInfo(id)
  1825. if errcode == gorm.ErrRecordNotFound {
  1826. //查询出库单
  1827. _, errcodes := service.GetDrugWareOutById(id)
  1828. if errcodes == gorm.ErrRecordNotFound {
  1829. //删除
  1830. service.DeleteBaseDrugById(id)
  1831. returnData := make(map[string]interface{}, 0)
  1832. returnData["msg"] = "ok"
  1833. c.ServeSuccessJSON(returnData)
  1834. return
  1835. } else if errcodes == nil {
  1836. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已出库")
  1837. return
  1838. }
  1839. } else if errcode == nil {
  1840. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已入库")
  1841. return
  1842. }
  1843. }
  1844. func (c *ManagerCenterApiController) CreateAddition() {
  1845. name := c.GetString("name")
  1846. code := c.GetString("code")
  1847. //price, _ := c.GetFloat("price")
  1848. price := c.GetString("price")
  1849. price_float, _ := strconv.ParseFloat(price, 64)
  1850. if len(name) <= 0 {
  1851. utils.ErrorLog("len(name) == 0")
  1852. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1853. return
  1854. }
  1855. //if len(code) <= 0 {
  1856. // utils.ErrorLog("len(code) == 0")
  1857. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1858. // return
  1859. //}
  1860. adminUserInfo := c.GetAdminUserInfo()
  1861. addition := models.XtHisAddtionConfig{
  1862. Name: name,
  1863. Code: code,
  1864. Status: 1,
  1865. Price: price_float,
  1866. Ctime: time.Now().Unix(),
  1867. Mtime: time.Now().Unix(),
  1868. UserOrgId: adminUserInfo.CurrentOrgId,
  1869. }
  1870. err, additions := service.AddSigleAddition(&addition)
  1871. if err == nil {
  1872. c.ServeSuccessJSON(map[string]interface{}{
  1873. "addition": additions,
  1874. })
  1875. } else {
  1876. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1877. }
  1878. }
  1879. func (c *ManagerCenterApiController) ModifyAddition() {
  1880. id, _ := c.GetInt64("id", 0)
  1881. name := c.GetString("name")
  1882. code := c.GetString("code")
  1883. price, _ := c.GetFloat("price")
  1884. if id <= 0 {
  1885. utils.ErrorLog("id == 0")
  1886. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1887. return
  1888. }
  1889. if len(name) <= 0 {
  1890. utils.ErrorLog("len(class_name) == 0")
  1891. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1892. return
  1893. }
  1894. //if len(code) <= 0 {
  1895. // utils.ErrorLog("len(content_code) == 0")
  1896. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1897. // return
  1898. //}
  1899. adminUserInfo := c.GetAdminUserInfo()
  1900. addition := models.XtHisAddtionConfig{
  1901. ID: id,
  1902. Name: name,
  1903. Code: code,
  1904. Ctime: time.Now().Unix(),
  1905. Mtime: time.Now().Unix(),
  1906. UserOrgId: adminUserInfo.CurrentOrgId,
  1907. Price: price,
  1908. Status: 1,
  1909. }
  1910. err := service.ModifyAddition(&addition)
  1911. if err == nil {
  1912. c.ServeSuccessJSON(map[string]interface{}{
  1913. "addition": addition,
  1914. })
  1915. } else {
  1916. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1917. }
  1918. }
  1919. func (c *ManagerCenterApiController) GetAdditionList() {
  1920. page, _ := c.GetInt64("page", 1)
  1921. limit, _ := c.GetInt64("limit", 7)
  1922. adminUserInfo := c.GetAdminUserInfo()
  1923. addition, total, err := service.FindAllAdditionList(adminUserInfo.CurrentOrgId, page, limit)
  1924. if err == nil {
  1925. c.ServeSuccessJSON(map[string]interface{}{
  1926. "addition": addition,
  1927. "total": total,
  1928. })
  1929. } else {
  1930. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1931. }
  1932. }
  1933. func (c *ManagerCenterApiController) DeleteAddition() {
  1934. id, _ := c.GetInt64("id", 0)
  1935. err := service.DeleteAdditionById(id)
  1936. if err == nil {
  1937. c.ServeSuccessJSON(map[string]interface{}{
  1938. "msg": "删除成功",
  1939. })
  1940. } else {
  1941. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1942. }
  1943. }
  1944. func (c *ManagerCenterApiController) GetAddition() {
  1945. id, _ := c.GetInt64("id", 0)
  1946. addition, err := service.FindAdditionById(id)
  1947. if err == nil {
  1948. c.ServeSuccessJSON(map[string]interface{}{
  1949. "addition": addition,
  1950. })
  1951. } else {
  1952. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1953. }
  1954. }
  1955. func (c *ManagerCenterApiController) CreateDiagnose() {
  1956. class_name := c.GetString("class_name")
  1957. content_code := c.GetString("content_code")
  1958. country_code := c.GetString("country_code")
  1959. country_content_name := c.GetString("country_content_name")
  1960. remark := c.GetString("remark")
  1961. pinyin := c.GetString("pinyin")
  1962. wubi := c.GetString("wubi")
  1963. sort, _ := c.GetInt64("sort")
  1964. fmt.Println("sort-------------------", sort)
  1965. if len(class_name) <= 0 {
  1966. utils.ErrorLog("len(class_name) == 0")
  1967. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1968. return
  1969. }
  1970. if len(content_code) <= 0 {
  1971. utils.ErrorLog("len(content_code) == 0")
  1972. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1973. return
  1974. }
  1975. adminUserInfo := c.GetAdminUserInfo()
  1976. dealer := models.HisXtDiagnoseConfig{
  1977. ClassName: class_name,
  1978. ContentCode: content_code,
  1979. CountryCode: country_code,
  1980. CountryContentName: country_content_name,
  1981. Ctime: time.Now().Unix(),
  1982. Mtime: time.Now().Unix(),
  1983. Remark: remark,
  1984. UserOrgId: adminUserInfo.CurrentOrgId,
  1985. Status: 1,
  1986. Pinyin: pinyin,
  1987. Wubi: wubi,
  1988. Sort: sort,
  1989. }
  1990. err, dealers := service.AddSigleDiagnose(&dealer)
  1991. if err == nil {
  1992. redis := service.RedisClient()
  1993. defer redis.Close()
  1994. diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
  1995. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  1996. c.ServeSuccessJSON(map[string]interface{}{
  1997. "sick": dealers,
  1998. })
  1999. } else {
  2000. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2001. }
  2002. }
  2003. func (c *ManagerCenterApiController) ModifyDiagnose() {
  2004. id, _ := c.GetInt64("id", 0)
  2005. class_name := c.GetString("class_name")
  2006. content_code := c.GetString("content_code")
  2007. country_code := c.GetString("country_code")
  2008. country_content_name := c.GetString("country_content_name")
  2009. remark := c.GetString("remark")
  2010. pinyin := c.GetString("pinyin")
  2011. wubi := c.GetString("wubi")
  2012. sort, _ := c.GetInt64("sort")
  2013. if id <= 0 {
  2014. utils.ErrorLog("id == 0")
  2015. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2016. return
  2017. }
  2018. if len(class_name) <= 0 {
  2019. utils.ErrorLog("len(class_name) == 0")
  2020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2021. return
  2022. }
  2023. if len(content_code) <= 0 {
  2024. utils.ErrorLog("len(content_code) == 0")
  2025. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2026. return
  2027. }
  2028. adminUserInfo := c.GetAdminUserInfo()
  2029. dealer := models.HisXtDiagnoseConfig{
  2030. ID: id,
  2031. ClassName: class_name,
  2032. ContentCode: content_code,
  2033. CountryCode: country_code,
  2034. CountryContentName: country_content_name,
  2035. Ctime: time.Now().Unix(),
  2036. Mtime: time.Now().Unix(),
  2037. Remark: remark,
  2038. UserOrgId: adminUserInfo.CurrentOrgId,
  2039. Pinyin: pinyin,
  2040. Wubi: wubi,
  2041. Status: 1,
  2042. Sort: sort,
  2043. }
  2044. err := service.ModifyDiagnose(&dealer)
  2045. if err == nil {
  2046. redis := service.RedisClient()
  2047. defer redis.Close()
  2048. diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
  2049. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  2050. c.ServeSuccessJSON(map[string]interface{}{
  2051. "sick": dealer,
  2052. })
  2053. } else {
  2054. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2055. }
  2056. }
  2057. func (c *ManagerCenterApiController) GetDiagnoseList() {
  2058. page, _ := c.GetInt64("page", 1)
  2059. limit, _ := c.GetInt64("limit", 7)
  2060. adminUserInfo := c.GetAdminUserInfo()
  2061. mzSick, total, err := service.FindAllDiagnoseList(adminUserInfo.CurrentOrgId, page, limit)
  2062. if err == nil {
  2063. c.ServeSuccessJSON(map[string]interface{}{
  2064. "sick": mzSick,
  2065. "total": total,
  2066. })
  2067. } else {
  2068. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2069. }
  2070. }
  2071. func (c *ManagerCenterApiController) DeleteDiagnose() {
  2072. id, _ := c.GetInt64("id", 0)
  2073. err := service.DeleteDiagnoseById(id)
  2074. if err == nil {
  2075. redis := service.RedisClient()
  2076. defer redis.Close()
  2077. diagnose_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_diagnose"
  2078. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  2079. c.ServeSuccessJSON(map[string]interface{}{
  2080. "msg": "删除成功",
  2081. })
  2082. } else {
  2083. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2084. }
  2085. }
  2086. func (c *ManagerCenterApiController) GetDiagnose() {
  2087. id, _ := c.GetInt64("id", 0)
  2088. mzSick, err := service.FindDiagnoseById(id)
  2089. if err == nil {
  2090. c.ServeSuccessJSON(map[string]interface{}{
  2091. "sick": mzSick,
  2092. })
  2093. } else {
  2094. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2095. }
  2096. }
  2097. func (c *ManagerCenterApiController) GetAllDrugList() {
  2098. orgId := c.GetAdminUserInfo().CurrentOrgId
  2099. list, err := service.GetAllDrugList(orgId)
  2100. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  2101. dealerList, _ := service.GetAllDealerList(orgId)
  2102. if err == nil {
  2103. c.ServeSuccessJSON(map[string]interface{}{
  2104. "list": list,
  2105. "manufacturerList": manufacturerList,
  2106. "dealerList": dealerList,
  2107. })
  2108. } else {
  2109. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2110. }
  2111. }
  2112. func (c *ManagerCenterApiController) GetSearchDrugList() {
  2113. keyword := c.GetString("keyword")
  2114. orgId := c.GetAdminUserInfo().CurrentOrgId
  2115. storehouse_id, _ := c.GetInt64("storehouse_id")
  2116. list, err := service.GetSearchDrugListSix(keyword, orgId, storehouse_id)
  2117. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  2118. dealerList, _ := service.GetAllDealerList(orgId)
  2119. if err == nil {
  2120. c.ServeSuccessJSON(map[string]interface{}{
  2121. "list": list,
  2122. "manufacturerList": manufacturerList,
  2123. "dealerList": dealerList,
  2124. })
  2125. } else {
  2126. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2127. }
  2128. }
  2129. func (c *ManagerCenterApiController) AddPatientDiagnos() {
  2130. dataBody := make(map[string]interface{}, 0)
  2131. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  2132. class_name := dataBody["class_name"].(string)
  2133. sort := int64(dataBody["sort"].(float64))
  2134. orgId := c.GetAdminUserInfo().CurrentOrgId
  2135. diagnose := models.XtPatientDiagnose{
  2136. ClassName: class_name,
  2137. Sort: sort,
  2138. UserOrgId: orgId,
  2139. Status: 1,
  2140. Ctime: time.Now().Unix(),
  2141. Mtime: 0,
  2142. }
  2143. err = service.CreatePatientDiagnose(diagnose)
  2144. if err == nil {
  2145. c.ServeSuccessJSON(map[string]interface{}{
  2146. "diagnose": diagnose,
  2147. })
  2148. } else {
  2149. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2150. }
  2151. }
  2152. func (c *ManagerCenterApiController) GetPatientDiagnose() {
  2153. limit, _ := c.GetInt64("limit")
  2154. page, _ := c.GetInt64("page")
  2155. orgId := c.GetAdminUserInfo().CurrentOrgId
  2156. list, total, err := service.GetPatientDiagnose(limit, page, orgId)
  2157. if err == nil {
  2158. c.ServeSuccessJSON(map[string]interface{}{
  2159. "list": list,
  2160. "total": total,
  2161. })
  2162. } else {
  2163. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2164. }
  2165. }
  2166. func (c *ManagerCenterApiController) GetPatientDiagnoseDetail() {
  2167. id, _ := c.GetInt64("id")
  2168. detail, err := service.GetPatientDiagnoseDetail(id)
  2169. if err == nil {
  2170. c.ServeSuccessJSON(map[string]interface{}{
  2171. "detail": detail,
  2172. })
  2173. } else {
  2174. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2175. }
  2176. }
  2177. func (c *ManagerCenterApiController) UpdatePatientCase() {
  2178. dataBody := make(map[string]interface{}, 0)
  2179. err := json.Unmarshal(c.Ctx.Input.RequestBody, &dataBody)
  2180. class_name := dataBody["class_name"].(string)
  2181. sort := int64(dataBody["sort"].(float64))
  2182. id := int64(dataBody["id"].(float64))
  2183. err = service.UpdatePatientCase(class_name, sort, id)
  2184. if err == nil {
  2185. c.ServeSuccessJSON(map[string]interface{}{
  2186. "msg": "msg",
  2187. })
  2188. } else {
  2189. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2190. }
  2191. }
  2192. func (c *ManagerCenterApiController) DeletePatientDiagnose() {
  2193. id, _ := c.GetInt64("id")
  2194. service.DeletePatientDiagnose(id)
  2195. returnData := make(map[string]interface{}, 0)
  2196. returnData["msg"] = "ok"
  2197. c.ServeSuccessJSON(returnData)
  2198. return
  2199. }