manager_center_api_controller.go 74KB

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