manager_center_api_controller.go 81KB

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