manager_center_api_controller.go 83KB

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