manager_center_api_controller.go 81KB

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