manager_center_api_controller.go 81KB

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