manager_center_api_controller.go 74KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293
  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. number := c.GetString("number")
  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. Number: number,
  1420. }
  1421. err, goodInfos := service.AddSigleGoodInfo(&goodInfo)
  1422. if err == nil {
  1423. c.ServeSuccessJSON(map[string]interface{}{
  1424. "goodInfo": goodInfos,
  1425. })
  1426. } else {
  1427. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1428. }
  1429. }
  1430. func (c *ManagerCenterApiController) ModifyGoodInfo() {
  1431. id, _ := c.GetInt64("id", 0)
  1432. good_id, _ := c.GetInt64("good_id", 0)
  1433. specification_name := c.GetString("specification_name")
  1434. good_unit, _ := c.GetInt64("good_unit", -1)
  1435. buy_price, _ := c.GetFloat("buy_price", 0)
  1436. sell_price, _ := c.GetFloat("sell_price", 0)
  1437. remark := c.GetString("remark")
  1438. manufacturer, _ := c.GetInt64("manufacturer", 0)
  1439. dealer, _ := c.GetInt64("dealer", 0)
  1440. expiry_date_warn_day_count, _ := c.GetInt64("expiry_date_warn_day_count", 0)
  1441. stock_warn_count, _ := c.GetInt64("stock_warn_count", 0)
  1442. is_reuse, _ := c.GetInt64("is_reuse", 0)
  1443. code := c.GetString("good_code")
  1444. provinces_code := c.GetString("provinces_code")
  1445. good_name := c.GetString("good_name")
  1446. pinyin := c.GetString("pinyin")
  1447. wubi := c.GetString("wubi")
  1448. good_kind, _ := c.GetInt64("good_kind", 0)
  1449. medical_insurance_level, _ := c.GetInt64("medical_insurance_level", 0)
  1450. retail_price, _ := c.GetFloat("retail_price", 0)
  1451. fmt.Println(retail_price)
  1452. medical_insurance_number := c.GetString("medical_insurance_number")
  1453. //provinces_code := c.GetString("provinces_code")
  1454. is_special_diseases, _ := c.GetInt64("is_special_diseases", 0)
  1455. is_record, _ := c.GetInt64("is_record")
  1456. statistics_category, _ := c.GetInt64("statistics_category")
  1457. good_status := c.GetString("good_status")
  1458. default_count, _ := c.GetInt64("default_count")
  1459. sign, _ := c.GetInt64("sign")
  1460. is_default, _ := c.GetInt64("is_default")
  1461. is_charge_use, _ := c.GetInt64("is_charge_use")
  1462. is_charge_predict, _ := c.GetInt64("is_charge_predict")
  1463. is_statistics_work, _ := c.GetInt64("is_statistics_work")
  1464. sort, _ := c.GetInt64("sort")
  1465. is_doctor_use, _ := c.GetInt64("is_doctor_use")
  1466. agent := c.GetString("agent")
  1467. good_number := c.GetString("good_number")
  1468. social_security_directory_code := c.GetString("social_security_directory_code")
  1469. production_type := c.GetString("production_type")
  1470. special_medical := c.GetString("special_medical")
  1471. min_number, _ := c.GetInt64("min_number")
  1472. packing_unit := c.GetString("packing_unit")
  1473. packing_price, _ := c.GetFloat("packing_price")
  1474. default_count_unit := c.GetString("default_count_unit")
  1475. min_unit := c.GetString("min_unit")
  1476. total, _ := c.GetFloat("total")
  1477. register_number := c.GetString("register_number")
  1478. is_user, _ := c.GetInt64("is_user")
  1479. number := c.GetString("number")
  1480. adminUserInfo := c.GetAdminUserInfo()
  1481. goodInfo := models.GoodInfo{
  1482. ID: id,
  1483. GoodCode: code,
  1484. SpecificationName: specification_name,
  1485. GoodTypeId: good_id,
  1486. GoodUnit: good_unit,
  1487. BuyPrice: buy_price,
  1488. SellPrice: sell_price,
  1489. Remark: remark,
  1490. Mtime: time.Now().Unix(),
  1491. Manufacturer: manufacturer,
  1492. Dealer: dealer,
  1493. ExpiryDateWarnDayCount: expiry_date_warn_day_count,
  1494. StockWarnCount: stock_warn_count,
  1495. IsReuse: is_reuse,
  1496. Status: 1,
  1497. OrgId: adminUserInfo.CurrentOrgId,
  1498. Modifier: adminUserInfo.AdminUser.Id,
  1499. GoodName: good_name,
  1500. Pinyin: pinyin,
  1501. Wubi: wubi,
  1502. GoodKind: good_kind,
  1503. MedicalInsuranceNumber: medical_insurance_number,
  1504. ProvincesCode: provinces_code,
  1505. IsSpecialDiseases: is_special_diseases,
  1506. IsRecord: is_record,
  1507. StatisticsCategory: statistics_category,
  1508. GoodStatus: good_status,
  1509. DefaultCount: default_count,
  1510. Sign: sign,
  1511. IsDefault: is_default,
  1512. IsChargeUse: is_charge_use,
  1513. IsChargePredict: is_charge_predict,
  1514. IsStatisticsWork: is_statistics_work,
  1515. Sort: sort,
  1516. IsDoctorUse: is_doctor_use,
  1517. Agent: agent,
  1518. GoodNumber: good_number,
  1519. MedicalInsuranceLevel: medical_insurance_level,
  1520. RetailPrice: packing_price,
  1521. SpecialMedical: special_medical,
  1522. SocialSecurityDirectoryCode: social_security_directory_code,
  1523. ProductionType: production_type,
  1524. MinNumber: min_number,
  1525. PackingUnit: packing_unit,
  1526. PackingPrice: packing_price,
  1527. DefaultCountUnit: default_count_unit,
  1528. MinUnit: min_unit,
  1529. Total: total,
  1530. RegisterNumber: register_number,
  1531. IsUser: is_user,
  1532. Number: number,
  1533. }
  1534. totals := service.FindGoodInfoByNameOne(specification_name, adminUserInfo.CurrentOrgId, good_id, id, good_name)
  1535. if totals > 0 {
  1536. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeGoodInfoNameExistError)
  1537. return
  1538. }
  1539. err, goodInfos := service.ModifyGoodInfo(&goodInfo)
  1540. if err == nil {
  1541. c.ServeSuccessJSON(map[string]interface{}{
  1542. "goodInfo": goodInfos,
  1543. })
  1544. } else {
  1545. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1546. }
  1547. }
  1548. func (c *ManagerCenterApiController) GetGoodInfoList() {
  1549. page, _ := c.GetInt64("page", 1)
  1550. limit, _ := c.GetInt64("limit", 7)
  1551. keyword := c.GetString("keyword")
  1552. is_use, _ := c.GetInt64("is_use")
  1553. is_charge, _ := c.GetInt64("is_charge")
  1554. good_kind, _ := c.GetInt64("good_kind")
  1555. is_mark, _ := c.GetInt64("is_mark")
  1556. manufacturer, _ := c.GetInt64("manufacturer")
  1557. is_type, _ := c.GetInt64("is_type")
  1558. adminUserInfo := c.GetAdminUserInfo()
  1559. goodInfos, total, err := service.FindGoodInfoList(adminUserInfo.CurrentOrgId, page, limit, keyword, is_use, is_charge, good_kind, is_mark, manufacturer, is_type)
  1560. if err == nil {
  1561. c.ServeSuccessJSON(map[string]interface{}{
  1562. "list": goodInfos,
  1563. "total": total,
  1564. })
  1565. } else {
  1566. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1567. }
  1568. }
  1569. func (c *ManagerCenterApiController) DeleteGoodInfo() {
  1570. id, _ := c.GetInt64("id", 0)
  1571. adminUserInfo := c.GetAdminUserInfo()
  1572. total, _ := service.FindWarehouseInfoTotalByGoodId(id)
  1573. total2, _ := service.FindWarehouseOutInfoTotalByGoodId(id)
  1574. if total > 0 {
  1575. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1576. return
  1577. }
  1578. if total2 > 0 {
  1579. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDeleteGoodInfoFail)
  1580. return
  1581. }
  1582. err := service.DeleteGoodInfoById(id, adminUserInfo.AdminUser.Id)
  1583. if err == nil {
  1584. c.ServeSuccessJSON(map[string]interface{}{
  1585. "msg": "删除成功",
  1586. })
  1587. } else {
  1588. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1589. }
  1590. }
  1591. func (c *ManagerCenterApiController) GetGoodInfoByGoodId() {
  1592. id, _ := c.GetInt64("id", 0)
  1593. goodInfo, err := service.FindGoodInfoByGoodId(id)
  1594. if err == nil {
  1595. c.ServeSuccessJSON(map[string]interface{}{
  1596. "list": goodInfo,
  1597. })
  1598. } else {
  1599. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1600. }
  1601. }
  1602. func (c *ManagerCenterApiController) GetGoodInfoById() {
  1603. id, _ := c.GetInt64("id", 0)
  1604. goodInfo, err := service.FindGoodInfoById(id)
  1605. if err == nil {
  1606. c.ServeSuccessJSON(map[string]interface{}{
  1607. "goodInfo": goodInfo,
  1608. })
  1609. } else {
  1610. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1611. }
  1612. }
  1613. func (c *ManagerCenterApiController) GetMedicineInsurancePercent() {
  1614. adminUser := c.GetAdminUserInfo()
  1615. type_id, _ := c.GetInt64("type_id", 0)
  1616. module, _ := c.GetInt64("module", 0)
  1617. mip, err := service.GetLastMedicineInsurance(adminUser.CurrentOrgId, type_id, module)
  1618. if err == nil {
  1619. c.ServeSuccessJSON(map[string]interface{}{
  1620. "mip": mip,
  1621. })
  1622. } else {
  1623. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1624. }
  1625. }
  1626. func (c *ManagerCenterApiController) CreateMZSick() {
  1627. class_name := c.GetString("class_name")
  1628. content_code := c.GetString("content_code")
  1629. country_code := c.GetString("country_code")
  1630. country_content_name := c.GetString("country_content_name")
  1631. remark := c.GetString("remark")
  1632. pinyin := c.GetString("pinyin")
  1633. wubi := c.GetString("wubi")
  1634. if len(class_name) <= 0 {
  1635. utils.ErrorLog("len(class_name) == 0")
  1636. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1637. return
  1638. }
  1639. if len(content_code) <= 0 {
  1640. utils.ErrorLog("len(content_code) == 0")
  1641. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1642. return
  1643. }
  1644. adminUserInfo := c.GetAdminUserInfo()
  1645. dealer := models.OutpatientServiceSick{
  1646. ClassName: class_name,
  1647. ContentCode: content_code,
  1648. CountryCode: country_code,
  1649. CountryContentName: country_content_name,
  1650. Ctime: time.Now().Unix(),
  1651. Mtime: time.Now().Unix(),
  1652. Remark: remark,
  1653. UserOrgId: adminUserInfo.CurrentOrgId,
  1654. Status: 1,
  1655. Pinyin: pinyin,
  1656. Wubi: wubi,
  1657. }
  1658. err, dealers := service.AddSigleMZSick(&dealer)
  1659. if err == nil {
  1660. redis := service.RedisClient()
  1661. defer redis.Close()
  1662. sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
  1663. redis.Set(sick_keys, "", time.Second*60*60*18)
  1664. c.ServeSuccessJSON(map[string]interface{}{
  1665. "sick": dealers,
  1666. })
  1667. } else {
  1668. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1669. }
  1670. }
  1671. func (c *ManagerCenterApiController) ModifyMZSick() {
  1672. id, _ := c.GetInt64("id", 0)
  1673. class_name := c.GetString("class_name")
  1674. content_code := c.GetString("content_code")
  1675. country_code := c.GetString("country_code")
  1676. country_content_name := c.GetString("country_content_name")
  1677. remark := c.GetString("remark")
  1678. pinyin := c.GetString("pinyin")
  1679. wubi := c.GetString("wubi")
  1680. if id <= 0 {
  1681. utils.ErrorLog("id == 0")
  1682. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1683. return
  1684. }
  1685. if len(class_name) <= 0 {
  1686. utils.ErrorLog("len(class_name) == 0")
  1687. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1688. return
  1689. }
  1690. if len(content_code) <= 0 {
  1691. utils.ErrorLog("len(content_code) == 0")
  1692. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1693. return
  1694. }
  1695. adminUserInfo := c.GetAdminUserInfo()
  1696. dealer := models.OutpatientServiceSick{
  1697. ID: id,
  1698. ClassName: class_name,
  1699. ContentCode: content_code,
  1700. CountryCode: country_code,
  1701. CountryContentName: country_content_name,
  1702. Ctime: time.Now().Unix(),
  1703. Mtime: time.Now().Unix(),
  1704. Remark: remark,
  1705. UserOrgId: adminUserInfo.CurrentOrgId,
  1706. Pinyin: pinyin,
  1707. Wubi: wubi,
  1708. Status: 1,
  1709. }
  1710. err := service.ModifyMZSick(&dealer)
  1711. if err == nil {
  1712. redis := service.RedisClient()
  1713. defer redis.Close()
  1714. sick_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_sick"
  1715. redis.Set(sick_keys, "", time.Second*60*60*18)
  1716. c.ServeSuccessJSON(map[string]interface{}{
  1717. "sick": dealer,
  1718. })
  1719. } else {
  1720. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1721. }
  1722. }
  1723. func (c *ManagerCenterApiController) GetMZSickList() {
  1724. page, _ := c.GetInt64("page", 1)
  1725. limit, _ := c.GetInt64("limit", 7)
  1726. adminUserInfo := c.GetAdminUserInfo()
  1727. mzSick, total, err := service.FindAllMZSickList(adminUserInfo.CurrentOrgId, page, limit)
  1728. if err == nil {
  1729. c.ServeSuccessJSON(map[string]interface{}{
  1730. "sick": mzSick,
  1731. "total": total,
  1732. })
  1733. } else {
  1734. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1735. }
  1736. }
  1737. func (c *ManagerCenterApiController) DeleteMZSick() {
  1738. id, _ := c.GetInt64("id", 0)
  1739. err := service.DeleteMZSickById(id)
  1740. if err == nil {
  1741. redis := service.RedisClient()
  1742. defer redis.Close()
  1743. sick_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_sick"
  1744. redis.Set(sick_keys, "", time.Second*60*60*18)
  1745. c.ServeSuccessJSON(map[string]interface{}{
  1746. "msg": "删除成功",
  1747. })
  1748. } else {
  1749. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1750. }
  1751. }
  1752. func (c *ManagerCenterApiController) GetMZSick() {
  1753. id, _ := c.GetInt64("id", 0)
  1754. mzSick, err := service.FindMZSickById(id)
  1755. if err == nil {
  1756. c.ServeSuccessJSON(map[string]interface{}{
  1757. "sick": mzSick,
  1758. })
  1759. } else {
  1760. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1761. }
  1762. }
  1763. func (c *ManagerCenterApiController) DeleteBaseDrugById() {
  1764. id, _ := c.GetInt64("id")
  1765. //查询入库单
  1766. _, errcode := service.GetDrugWareoutInfo(id)
  1767. if errcode == gorm.ErrRecordNotFound {
  1768. //查询出库单
  1769. _, errcodes := service.GetDrugWareOutById(id)
  1770. if errcodes == gorm.ErrRecordNotFound {
  1771. //删除
  1772. service.DeleteBaseDrugById(id)
  1773. returnData := make(map[string]interface{}, 0)
  1774. returnData["msg"] = "ok"
  1775. c.ServeSuccessJSON(returnData)
  1776. return
  1777. } else if errcodes == nil {
  1778. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已出库")
  1779. return
  1780. }
  1781. } else if errcode == nil {
  1782. c.ServeFailJsonSend(enums.ErrorCodeDataException, "已入库")
  1783. return
  1784. }
  1785. }
  1786. func (c *ManagerCenterApiController) CreateAddition() {
  1787. name := c.GetString("name")
  1788. code := c.GetString("code")
  1789. //price, _ := c.GetFloat("price")
  1790. price := c.GetString("price")
  1791. price_float, _ := strconv.ParseFloat(price, 64)
  1792. if len(name) <= 0 {
  1793. utils.ErrorLog("len(name) == 0")
  1794. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1795. return
  1796. }
  1797. //if len(code) <= 0 {
  1798. // utils.ErrorLog("len(code) == 0")
  1799. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1800. // return
  1801. //}
  1802. adminUserInfo := c.GetAdminUserInfo()
  1803. addition := models.XtHisAddtionConfig{
  1804. Name: name,
  1805. Code: code,
  1806. Status: 1,
  1807. Price: price_float,
  1808. Ctime: time.Now().Unix(),
  1809. Mtime: time.Now().Unix(),
  1810. UserOrgId: adminUserInfo.CurrentOrgId,
  1811. }
  1812. err, additions := service.AddSigleAddition(&addition)
  1813. if err == nil {
  1814. c.ServeSuccessJSON(map[string]interface{}{
  1815. "addition": additions,
  1816. })
  1817. } else {
  1818. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1819. }
  1820. }
  1821. func (c *ManagerCenterApiController) ModifyAddition() {
  1822. id, _ := c.GetInt64("id", 0)
  1823. name := c.GetString("name")
  1824. code := c.GetString("code")
  1825. price, _ := c.GetFloat("price")
  1826. if id <= 0 {
  1827. utils.ErrorLog("id == 0")
  1828. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1829. return
  1830. }
  1831. if len(name) <= 0 {
  1832. utils.ErrorLog("len(class_name) == 0")
  1833. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1834. return
  1835. }
  1836. //if len(code) <= 0 {
  1837. // utils.ErrorLog("len(content_code) == 0")
  1838. // c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1839. // return
  1840. //}
  1841. adminUserInfo := c.GetAdminUserInfo()
  1842. addition := models.XtHisAddtionConfig{
  1843. ID: id,
  1844. Name: name,
  1845. Code: code,
  1846. Ctime: time.Now().Unix(),
  1847. Mtime: time.Now().Unix(),
  1848. UserOrgId: adminUserInfo.CurrentOrgId,
  1849. Price: price,
  1850. Status: 1,
  1851. }
  1852. err := service.ModifyAddition(&addition)
  1853. if err == nil {
  1854. c.ServeSuccessJSON(map[string]interface{}{
  1855. "addition": addition,
  1856. })
  1857. } else {
  1858. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1859. }
  1860. }
  1861. func (c *ManagerCenterApiController) GetAdditionList() {
  1862. page, _ := c.GetInt64("page", 1)
  1863. limit, _ := c.GetInt64("limit", 7)
  1864. adminUserInfo := c.GetAdminUserInfo()
  1865. addition, total, err := service.FindAllAdditionList(adminUserInfo.CurrentOrgId, page, limit)
  1866. if err == nil {
  1867. c.ServeSuccessJSON(map[string]interface{}{
  1868. "addition": addition,
  1869. "total": total,
  1870. })
  1871. } else {
  1872. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1873. }
  1874. }
  1875. func (c *ManagerCenterApiController) DeleteAddition() {
  1876. id, _ := c.GetInt64("id", 0)
  1877. err := service.DeleteAdditionById(id)
  1878. if err == nil {
  1879. c.ServeSuccessJSON(map[string]interface{}{
  1880. "msg": "删除成功",
  1881. })
  1882. } else {
  1883. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1884. }
  1885. }
  1886. func (c *ManagerCenterApiController) GetAddition() {
  1887. id, _ := c.GetInt64("id", 0)
  1888. addition, err := service.FindAdditionById(id)
  1889. if err == nil {
  1890. c.ServeSuccessJSON(map[string]interface{}{
  1891. "addition": addition,
  1892. })
  1893. } else {
  1894. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1895. }
  1896. }
  1897. func (c *ManagerCenterApiController) CreateDiagnose() {
  1898. class_name := c.GetString("class_name")
  1899. content_code := c.GetString("content_code")
  1900. country_code := c.GetString("country_code")
  1901. country_content_name := c.GetString("country_content_name")
  1902. remark := c.GetString("remark")
  1903. pinyin := c.GetString("pinyin")
  1904. wubi := c.GetString("wubi")
  1905. if len(class_name) <= 0 {
  1906. utils.ErrorLog("len(class_name) == 0")
  1907. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1908. return
  1909. }
  1910. if len(content_code) <= 0 {
  1911. utils.ErrorLog("len(content_code) == 0")
  1912. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1913. return
  1914. }
  1915. adminUserInfo := c.GetAdminUserInfo()
  1916. dealer := models.HisXtDiagnoseConfig{
  1917. ClassName: class_name,
  1918. ContentCode: content_code,
  1919. CountryCode: country_code,
  1920. CountryContentName: country_content_name,
  1921. Ctime: time.Now().Unix(),
  1922. Mtime: time.Now().Unix(),
  1923. Remark: remark,
  1924. UserOrgId: adminUserInfo.CurrentOrgId,
  1925. Status: 1,
  1926. Pinyin: pinyin,
  1927. Wubi: wubi,
  1928. }
  1929. err, dealers := service.AddSigleDiagnose(&dealer)
  1930. if err == nil {
  1931. redis := service.RedisClient()
  1932. defer redis.Close()
  1933. diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
  1934. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  1935. c.ServeSuccessJSON(map[string]interface{}{
  1936. "sick": dealers,
  1937. })
  1938. } else {
  1939. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1940. }
  1941. }
  1942. func (c *ManagerCenterApiController) ModifyDiagnose() {
  1943. id, _ := c.GetInt64("id", 0)
  1944. class_name := c.GetString("class_name")
  1945. content_code := c.GetString("content_code")
  1946. country_code := c.GetString("country_code")
  1947. country_content_name := c.GetString("country_content_name")
  1948. remark := c.GetString("remark")
  1949. pinyin := c.GetString("pinyin")
  1950. wubi := c.GetString("wubi")
  1951. if id <= 0 {
  1952. utils.ErrorLog("id == 0")
  1953. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1954. return
  1955. }
  1956. if len(class_name) <= 0 {
  1957. utils.ErrorLog("len(class_name) == 0")
  1958. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1959. return
  1960. }
  1961. if len(content_code) <= 0 {
  1962. utils.ErrorLog("len(content_code) == 0")
  1963. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1964. return
  1965. }
  1966. adminUserInfo := c.GetAdminUserInfo()
  1967. dealer := models.HisXtDiagnoseConfig{
  1968. ID: id,
  1969. ClassName: class_name,
  1970. ContentCode: content_code,
  1971. CountryCode: country_code,
  1972. CountryContentName: country_content_name,
  1973. Ctime: time.Now().Unix(),
  1974. Mtime: time.Now().Unix(),
  1975. Remark: remark,
  1976. UserOrgId: adminUserInfo.CurrentOrgId,
  1977. Pinyin: pinyin,
  1978. Wubi: wubi,
  1979. Status: 1,
  1980. }
  1981. err := service.ModifyDiagnose(&dealer)
  1982. if err == nil {
  1983. redis := service.RedisClient()
  1984. defer redis.Close()
  1985. diagnose_keys := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + "_diagnose"
  1986. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  1987. c.ServeSuccessJSON(map[string]interface{}{
  1988. "sick": dealer,
  1989. })
  1990. } else {
  1991. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  1992. }
  1993. }
  1994. func (c *ManagerCenterApiController) GetDiagnoseList() {
  1995. page, _ := c.GetInt64("page", 1)
  1996. limit, _ := c.GetInt64("limit", 7)
  1997. adminUserInfo := c.GetAdminUserInfo()
  1998. mzSick, total, err := service.FindAllDiagnoseList(adminUserInfo.CurrentOrgId, page, limit)
  1999. if err == nil {
  2000. c.ServeSuccessJSON(map[string]interface{}{
  2001. "sick": mzSick,
  2002. "total": total,
  2003. })
  2004. } else {
  2005. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2006. }
  2007. }
  2008. func (c *ManagerCenterApiController) DeleteDiagnose() {
  2009. id, _ := c.GetInt64("id", 0)
  2010. err := service.DeleteDiagnoseById(id)
  2011. if err == nil {
  2012. redis := service.RedisClient()
  2013. defer redis.Close()
  2014. diagnose_keys := strconv.FormatInt(c.GetAdminUserInfo().CurrentOrgId, 10) + "_diagnose"
  2015. redis.Set(diagnose_keys, "", time.Second*60*60*18)
  2016. c.ServeSuccessJSON(map[string]interface{}{
  2017. "msg": "删除成功",
  2018. })
  2019. } else {
  2020. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2021. }
  2022. }
  2023. func (c *ManagerCenterApiController) GetDiagnose() {
  2024. id, _ := c.GetInt64("id", 0)
  2025. mzSick, err := service.FindDiagnoseById(id)
  2026. if err == nil {
  2027. c.ServeSuccessJSON(map[string]interface{}{
  2028. "sick": mzSick,
  2029. })
  2030. } else {
  2031. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2032. }
  2033. }
  2034. func (c *ManagerCenterApiController) GetAllDrugList() {
  2035. orgId := c.GetAdminUserInfo().CurrentOrgId
  2036. list, err := service.GetAllDrugList(orgId)
  2037. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  2038. dealerList, _ := service.GetAllDealerList(orgId)
  2039. if err == nil {
  2040. c.ServeSuccessJSON(map[string]interface{}{
  2041. "list": list,
  2042. "manufacturerList": manufacturerList,
  2043. "dealerList": dealerList,
  2044. })
  2045. } else {
  2046. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2047. }
  2048. }
  2049. func (c *ManagerCenterApiController) GetSearchDrugList() {
  2050. keyword := c.GetString("keyword")
  2051. orgId := c.GetAdminUserInfo().CurrentOrgId
  2052. list, err := service.GetSearchDrugList(keyword, orgId)
  2053. manufacturerList, _ := service.GetAllManufacturerList(orgId)
  2054. dealerList, _ := service.GetAllDealerList(orgId)
  2055. if err == nil {
  2056. c.ServeSuccessJSON(map[string]interface{}{
  2057. "list": list,
  2058. "manufacturerList": manufacturerList,
  2059. "dealerList": dealerList,
  2060. })
  2061. } else {
  2062. c.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeSystemError)
  2063. }
  2064. }