manager_center_api_controller.go 74KB

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