manager_center_api_controller.go 78KB

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