manager_center_api_controller.go 74KB

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