manager_center_api_controller.go 81KB

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