manager_center_api_controller.go 79KB

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