manager_center_api_controller.go 73KB

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