manager_center_api_controller.go 75KB

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