manager_center_api_controller.go 78KB

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