manager_center_api_controller.go 74KB

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