manager_center_api_controller.go 74KB

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