manager_center_api_controller.go 73KB

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