manager_center_api_controller.go 74KB

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