manager_center_api_controller.go 81KB

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