manager_center_api_controller.go 79KB

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