manager_center_api_controller.go 64KB

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