manager_center_api_controller.go 83KB

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