self_drug_api_congtroller.go 69KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111
  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. "strings"
  14. "time"
  15. )
  16. type SelfDrugApiController struct {
  17. BaseAuthAPIController
  18. }
  19. func SelfDrugRouters() {
  20. beego.Router("/api/drug/getcurrentpatient", &SelfDrugApiController{}, "Get:GetCurrentPatient")
  21. beego.Router("/api/drug/getalldrugname", &SelfDrugApiController{}, "Get:GetAllDrugName")
  22. beego.Router("/api/drug/savedrugname", &SelfDrugApiController{}, "Get:SaveDrugName")
  23. beego.Router("/api/drug/getdrugnamelist", &SelfDrugApiController{}, "Get:GetDrugNameList")
  24. beego.Router("/api/drug/getrullename", &SelfDrugApiController{}, "Get:GetRulleName")
  25. beego.Router("/api/drug/getunitbybaseid", &SelfDrugApiController{}, "Get:GetUnitByBaseId")
  26. beego.Router("/api/drug/saverullename", &SelfDrugApiController{}, "Get:SaveRulleName")
  27. beego.Router("/api/drug/editrullername", &SelfDrugApiController{}, "Get:EditRullerName")
  28. beego.Router("/api/drug/updatedrullername", &SelfDrugApiController{}, "Get:UpdatedRullerName")
  29. beego.Router("/api/drug/getalldrugnamelist", &SelfDrugApiController{}, "Get:GetAllDrugNameList")
  30. beego.Router("/api/drug/getrulllistbydrugname", &SelfDrugApiController{}, "Get:GetRullerListByDrugName")
  31. beego.Router("/api/drug/saveselfmedicines", &SelfDrugApiController{}, "Post:SaveSelfMedicines")
  32. beego.Router("/api/drug/getcurrentorgallstaff", &SelfDrugApiController{}, "Get:GetCurrentOrgAllStaff")
  33. beego.Router("/api/drug/savestock", &SelfDrugApiController{}, "Post:SaveStock")
  34. beego.Router("/api/drug/saveoutstock", &SelfDrugApiController{}, "Post:SaveOutStock")
  35. beego.Router("/api/drug/deletedrugbyid", &SelfDrugApiController{}, "Get:DeleteDrugById")
  36. beego.Router("/api/drug/saveradio", &SelfDrugApiController{}, "Get:SaveRadio")
  37. beego.Router("/api/drug/deletedrugstand", &SelfDrugApiController{}, "Get:DeleteDrugStand")
  38. beego.Router("/api/drug/getstocklist", &SelfDrugApiController{}, "Get:GetStockList")
  39. beego.Router("/api/drug/deletedrugname", &SelfDrugApiController{}, "Get:DeleteDrugName")
  40. beego.Router("/api/drug/getdrugdetail", &SelfDrugApiController{}, "Get:GetDrugDetail")
  41. beego.Router("/api/drug/getallpatientstocklist", &SelfDrugApiController{}, "Get:GetAllPatientStockList")
  42. beego.Router("/api/drug/getdrugdatabypatientid", &SelfDrugApiController{}, "Get:GetDrugDataByPatientId")
  43. beego.Router("/api/drug/getselfmedicallist", &SelfDrugApiController{}, "Get:GetSelfMedicalList")
  44. beego.Router("/api/drug/getdrugdescbydrugname", &SelfDrugApiController{}, "Get:GetDrugDescByDrugName")
  45. beego.Router("/api/drug/getdrugset", &SelfDrugApiController{}, "Get:GetDrugSet")
  46. beego.Router("/api/drug/getallmedicallist", &SelfDrugApiController{}, "Get:GetAllMedicalList")
  47. beego.Router("/api/drug/getstandname", &SelfDrugApiController{}, "Get:GetStandName")
  48. beego.Router("/api/drug/getrullerlist", &SelfDrugApiController{}, "Get:GetRullerList")
  49. beego.Router("/api/drug/deleteDrugNamebyid", &SelfDrugApiController{}, "Get:DeleteDrugNameById")
  50. beego.Router("/api/drug/getpatientdetail", &SelfDrugApiController{}, "Get:GetPatientDetail")
  51. //beego.Router("/api/drug/getpatientdetail",&SelfDrugApiController{},"Get:ToPatientDetail")
  52. beego.Router("/api/drug/getselfstockquery", &SelfDrugApiController{}, "Get:GetSelfStockQuery")
  53. beego.Router("/api/drug/postsearchdrugwarehouselist", &SelfDrugApiController{}, "Get:PostSearchDrugWarehouseList")
  54. beego.Router("/api/drug/savedrugpriceone", &SelfDrugApiController{}, "Post:SaveDrugPrice")
  55. beego.Router("/api/drug/drugpricelist", &SelfDrugApiController{}, "Get:GetDrugPriceList")
  56. beego.Router("/api/drug/savecheckdrugprice", &SelfDrugApiController{}, "Get:SaveCheckDrugPrice")
  57. beego.Router("/api/drug/savedrugdamageone", &SelfDrugApiController{}, "Post:SaveDrugDamage")
  58. beego.Router("/api/drug/getdrugdamagelist", &SelfDrugApiController{}, "Get:GetDrugDamageList")
  59. beego.Router("/api/drug/savedrugdamageprice", &SelfDrugApiController{}, "Get:SaveDrugDamagePrice")
  60. beego.Router("/api/drug/getdrugmodifyprice", &SelfDrugApiController{}, "Get:GetDrugModifyPrice")
  61. beego.Router("/api/drug/modifydrugprice", &SelfDrugApiController{}, "Get:ModifyDrugPrice")
  62. beego.Router("/api/drug/getmodifypriceprint", &SelfDrugApiController{}, "Get:GetModifyPricePrint")
  63. beego.Router("/api/drug/getdrugdamagedetail", &SelfDrugApiController{}, "Get:GetDrugDamageDetail")
  64. beego.Router("/api/drug/modifydrugdamage", &SelfDrugApiController{}, "Get:ModifyDrugDamage")
  65. beego.Router("/api/drug/deletedrugdamage", &SelfDrugApiController{}, "Get:DeleteDrugDamage")
  66. beego.Router("/api/drug/getdrugdamageprint", &SelfDrugApiController{}, "Get:GetDrugDamagePrint")
  67. beego.Router("/api/drug/warehouseinfobyid", &SelfDrugApiController{}, "Get:GetWarehoseInfoById")
  68. beego.Router("/api/drug/savedruginventory", &SelfDrugApiController{}, "Post:SaveDrugInventory")
  69. beego.Router("/api/drug/getdruginventorylist", &SelfDrugApiController{}, "Get:GetDrugInventoryList")
  70. beego.Router("/api/drug/savedrugcheckinventory", &SelfDrugApiController{}, "Get:SaveDrugCheckInventory")
  71. beego.Router("/api/drug/getdruginventorydetail", &SelfDrugApiController{}, "Get:GetDrugInventoryDetail")
  72. beego.Router("/api/drug/modifyinventory", &SelfDrugApiController{}, "Get:ModifyInventory")
  73. beego.Router("/api/drug/deletedruginventory", &SelfDrugApiController{}, "Delete:DeleteDrugInventory")
  74. beego.Router("/api/drug/getdruginventoryprintlist", &SelfDrugApiController{}, "Get:GetDrugInventoryPrintList")
  75. beego.Router("/api/drug/getinventorydetaillist", &SelfDrugApiController{}, "Get:GetDrugInventoryDetailList")
  76. beego.Router("/api/drug/savedrugproofinventory", &SelfDrugApiController{}, "Get:SaveDrugProofInventory")
  77. }
  78. func (this *SelfDrugApiController) GetCurrentPatient() {
  79. adminUserInfo := this.GetAdminUserInfo()
  80. orgId := adminUserInfo.CurrentOrgId
  81. patient, err := service.GetCurrentPatient(orgId)
  82. if err != nil {
  83. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  84. return
  85. }
  86. this.ServeSuccessJSON(map[string]interface{}{
  87. "patient": patient,
  88. })
  89. }
  90. func (this *SelfDrugApiController) GetAllDrugName() {
  91. adminUserInfo := this.GetAdminUserInfo()
  92. orgId := adminUserInfo.CurrentOrgId
  93. //查询药品库是否开启
  94. //configStock, _ := service.GetDrugStockConfig(orgId)
  95. //if configStock.IsOpen == 1 {
  96. //
  97. //}
  98. drugName, err := service.GetAllDrugName(orgId)
  99. if err != nil {
  100. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查寻成功")
  101. return
  102. }
  103. this.ServeSuccessJSON(map[string]interface{}{
  104. "drugName": drugName,
  105. })
  106. }
  107. func (this *SelfDrugApiController) SaveDrugName() {
  108. adminUserInfo := this.GetAdminUserInfo()
  109. orgId := adminUserInfo.CurrentOrgId
  110. drug_name := this.GetString("drug_name")
  111. id, _ := this.GetInt64("id")
  112. //fmt.Println("drug_name", drug_name)
  113. drugName := models.XtDrugName{
  114. UserOrgId: orgId,
  115. DrugName: drug_name,
  116. Status: 1,
  117. CreatedTime: time.Now().Unix(),
  118. DrugId: id,
  119. }
  120. _, errcode := service.GetDrugName(drug_name, orgId)
  121. if errcode == gorm.ErrRecordNotFound {
  122. err := service.SaveDrugName(&drugName)
  123. if err != nil {
  124. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  125. return
  126. }
  127. this.ServeSuccessJSON(map[string]interface{}{
  128. "drugName": drugName,
  129. })
  130. } else {
  131. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  132. return
  133. }
  134. }
  135. func (this *SelfDrugApiController) GetDrugNameList() {
  136. adminUserInfo := this.GetAdminUserInfo()
  137. orgId := adminUserInfo.CurrentOrgId
  138. list, err := service.GetDrugNameList(orgId)
  139. if err != nil {
  140. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  141. return
  142. }
  143. this.ServeSuccessJSON(map[string]interface{}{
  144. "list": list,
  145. })
  146. }
  147. func (this *SelfDrugApiController) GetRulleName() {
  148. adminUserInfo := this.GetAdminUserInfo()
  149. orgId := adminUserInfo.CurrentOrgId
  150. id, _ := this.GetInt64("id")
  151. drugId, _ := service.GetDrugId(id)
  152. rullerList, err := service.GetRulleList(orgId, drugId.DrugId)
  153. if err != nil {
  154. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  155. return
  156. }
  157. this.ServeSuccessJSON(map[string]interface{}{
  158. "rullerList": rullerList,
  159. })
  160. }
  161. func (this *SelfDrugApiController) GetUnitByBaseId() {
  162. id, _ := this.GetInt64("id")
  163. baseList, err := service.GetUnitByBaseId(id)
  164. if err != nil {
  165. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  166. return
  167. }
  168. this.ServeSuccessJSON(map[string]interface{}{
  169. "baseList": baseList,
  170. })
  171. }
  172. func (this *SelfDrugApiController) SaveRulleName() {
  173. drug_name := this.GetString("drug_name")
  174. drug_spec := this.GetString("drug_spec")
  175. drug_stock_limit := this.GetString("drug_stock_limit")
  176. drug_name_id, _ := this.GetInt64("drug_name_id")
  177. drug_id, _ := this.GetInt64("drug_id")
  178. price, _ := this.GetInt64("price")
  179. prices := strconv.FormatInt(price, 10)
  180. durg_price, _ := strconv.ParseFloat(prices, 64)
  181. unit := this.GetString("unit")
  182. adminUserInfo := this.GetAdminUserInfo()
  183. orgId := adminUserInfo.CurrentOrgId
  184. fmt.Println(drug_name, drug_stock_limit, unit, price, drug_spec, orgId)
  185. drugSpecName := models.XtStandName{
  186. DrugName: drug_name,
  187. DrugSpec: drug_spec,
  188. DrugStockLimit: drug_stock_limit,
  189. DrugNameId: drug_name_id,
  190. Price: durg_price,
  191. MinUnit: unit,
  192. UserOrgId: orgId,
  193. Status: 1,
  194. CreatedTime: time.Now().Unix(),
  195. DrugId: drug_id,
  196. }
  197. //查询该机构下药品规格名称是否存在
  198. _, errcode := service.IsExistStandName(drug_name, drug_spec, adminUserInfo.CurrentOrgId)
  199. if errcode == gorm.ErrRecordNotFound {
  200. err := service.SaveRulleName(&drugSpecName)
  201. if err != nil {
  202. this.ServeFailJsonSend(enums.ErrorCodeDataException, "创建规格失败")
  203. return
  204. }
  205. this.ServeSuccessJSON(map[string]interface{}{
  206. "RullerName": drugSpecName,
  207. })
  208. } else if errcode == nil {
  209. this.ServeFailJsonSend(enums.ErrorCodeDataException, "规格已存在")
  210. return
  211. }
  212. }
  213. func (this *SelfDrugApiController) EditRullerName() {
  214. id, _ := this.GetInt64("id")
  215. rullerDetail, err := service.GetRullerNameDetail(id)
  216. if err != nil {
  217. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  218. return
  219. }
  220. this.ServeSuccessJSON(map[string]interface{}{
  221. "rullerDetail": rullerDetail,
  222. })
  223. }
  224. func (this *SelfDrugApiController) UpdatedRullerName() {
  225. id, _ := this.GetInt64("id")
  226. drug_name := this.GetString("drug_name")
  227. drug_stock_limit := this.GetString("drug_stock_limit")
  228. price, _ := this.GetInt64("price")
  229. prices := strconv.FormatInt(price, 10)
  230. durg_price, _ := strconv.ParseFloat(prices, 64)
  231. drug_spec := this.GetString("drug_spec")
  232. unit := this.GetString("unit")
  233. drug_name_id, _ := this.GetInt64("drug_name_id")
  234. drug_id, _ := this.GetInt64("drug_id")
  235. RullerName := models.XtStandName{
  236. DrugName: drug_name,
  237. DrugStockLimit: drug_stock_limit,
  238. Price: durg_price,
  239. DrugSpec: drug_spec,
  240. MinUnit: unit,
  241. DrugNameId: drug_name_id,
  242. DrugId: drug_id,
  243. }
  244. _, errcode := service.GetIsExit(drug_name, drug_spec, id)
  245. if errcode == gorm.ErrRecordNotFound {
  246. err := service.UpdatedRullerName(id, &RullerName)
  247. if err != nil {
  248. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  249. return
  250. }
  251. this.ServeSuccessJSON(map[string]interface{}{
  252. "RullerName": RullerName,
  253. })
  254. } else if errcode == nil {
  255. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  256. return
  257. }
  258. }
  259. func (this *SelfDrugApiController) GetAllDrugNameList() {
  260. adminUserInfo := this.GetAdminUserInfo()
  261. orgId := adminUserInfo.CurrentOrgId
  262. rullerName, err := service.GetAllDrugNameList(orgId)
  263. list, err := service.GetMedicalDrugNameList(orgId)
  264. if err != nil {
  265. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  266. return
  267. }
  268. this.ServeSuccessJSON(map[string]interface{}{
  269. "rullerName": rullerName,
  270. "list": list,
  271. })
  272. }
  273. func (this *SelfDrugApiController) GetRullerListByDrugName() {
  274. id := this.GetString("id")
  275. adminUserInfo := this.GetAdminUserInfo()
  276. orgId := adminUserInfo.CurrentOrgId
  277. fmt.Println("orgid", orgId)
  278. drugName, err := service.GetRullerListByDrugName(id, orgId)
  279. if err != nil {
  280. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  281. return
  282. }
  283. this.ServeSuccessJSON(map[string]interface{}{
  284. "drugName": drugName,
  285. })
  286. }
  287. func (this *SelfDrugApiController) SaveSelfMedicines() {
  288. dataBody := make(map[string]interface{}, 0)
  289. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  290. fmt.Println(err)
  291. patient_id := int64(dataBody["patient_id"].(float64))
  292. medicineData, _ := dataBody["medicineData"].([]interface{})
  293. adminUserInfo := this.GetAdminUserInfo()
  294. orgId := adminUserInfo.CurrentOrgId
  295. for _, item := range medicineData {
  296. items := item.(map[string]interface{})
  297. drug_name := items["drug_name"].(string)
  298. drug_name_id := int64(items["drug_name_id"].(float64))
  299. drug_spec := items["drug_spec"].(string)
  300. min_unit := items["min_unit"].(string)
  301. drug_id := int64(items["drug_id"].(float64))
  302. //根据drug_id
  303. drugMedical, _ := service.GetBaseDrugMedical(drug_name_id)
  304. medical := models.XtSelfMedical{
  305. DrugName: drug_name,
  306. DrugNameId: drug_name_id,
  307. DrugSpec: drug_spec,
  308. CreatedTime: time.Now().Unix(),
  309. Status: 1,
  310. UserOrgId: orgId,
  311. PatientId: patient_id,
  312. MinUnit: min_unit,
  313. ExecutionFrequency: drugMedical.ExecutionFrequency,
  314. PrescribingNumber: drugMedical.PrescribingNumber,
  315. DeliveryWay: drugMedical.DeliveryWay,
  316. SingleDose: drugMedical.SingleDose,
  317. DrugId: drug_id,
  318. }
  319. //查询同个病人同个药品同个规格是否已存在
  320. _, errcode := service.GetSelfMedicalByDrugName(drug_name, drug_spec, patient_id)
  321. if errcode == gorm.ErrRecordNotFound {
  322. err := service.CreateSelfMedical(&medical)
  323. fmt.Println(err)
  324. } else if errcode == nil {
  325. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  326. return
  327. }
  328. }
  329. returnData := make(map[string]interface{}, 0)
  330. returnData["msg"] = "ok"
  331. this.ServeSuccessJSON(returnData)
  332. return
  333. }
  334. func (this *SelfDrugApiController) GetCurrentOrgAllStaff() {
  335. adminUserInfo := this.GetAdminUserInfo()
  336. orgid := adminUserInfo.CurrentOrgId
  337. //fmt.Println(orgid)
  338. appId := adminUserInfo.CurrentAppId
  339. staff, err := service.GetCurrentOrgAllStaff(orgid, appId)
  340. if err != nil {
  341. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  342. return
  343. }
  344. this.ServeSuccessJSON(map[string]interface{}{
  345. "staff": staff,
  346. })
  347. }
  348. func (this *SelfDrugApiController) SaveStock() {
  349. timeLayout := "2006-01-02"
  350. loc, _ := time.LoadLocation("Local")
  351. start_time := this.GetString("start_time")
  352. fmt.Println("start_time", start_time)
  353. admin_user_id, _ := this.GetInt64("admin_user_id")
  354. fmt.Println("admin_user_id", admin_user_id)
  355. patient_id, _ := this.GetInt64("patient_id")
  356. dataBody := make(map[string]interface{}, 0)
  357. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  358. fmt.Println(err)
  359. stocks, _ := dataBody["stocks"].([]interface{})
  360. adminUserInfo := this.GetAdminUserInfo()
  361. orgId := adminUserInfo.CurrentOrgId
  362. for _, item := range stocks {
  363. items := item.(map[string]interface{})
  364. drug_name := items["drug_name"].(string)
  365. fmt.Println("drug_name", drug_name)
  366. drug_name_id := int64(items["drug_name_id"].(float64))
  367. fmt.Println("parient_id", drug_name_id)
  368. drug_spec := items["drug_spec"].(string)
  369. store_number := items["store_number"].(string)
  370. fmt.Println("store_number", store_number)
  371. storeNumber, _ := strconv.ParseInt(store_number, 10, 64)
  372. remarks := items["remarks"].(string)
  373. min_unit := items["min_unit"].(string)
  374. medic_id := int64(items["id"].(float64))
  375. timeStr := time.Now().Format("2006-01-02")
  376. timeArr := strings.Split(timeStr, "-")
  377. total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
  378. total = total + 1
  379. warehousing_in_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  380. number, _ := strconv.ParseInt(warehousing_in_order, 10, 64)
  381. number = number + total
  382. warehousing_in_order = "RKD" + strconv.FormatInt(number, 10)
  383. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  384. stock := models.XtSelfStock{
  385. DrugName: drug_name,
  386. DrugNameId: drug_name_id,
  387. DrugSpec: drug_spec,
  388. StoreNumber: storeNumber,
  389. Remarks: remarks,
  390. AdminUserId: admin_user_id,
  391. StorckTime: theTime.Unix(),
  392. CreatedTime: time.Now().Unix(),
  393. Status: 1,
  394. UserOrgId: orgId,
  395. StockInNumber: warehousing_in_order,
  396. PatientId: patient_id,
  397. MinUnit: min_unit,
  398. StorageMode: 1,
  399. MedicId: medic_id,
  400. }
  401. err := service.CreateStock(&stock)
  402. fmt.Println("err", err)
  403. }
  404. returnData := make(map[string]interface{}, 0)
  405. returnData["msg"] = "ok"
  406. this.ServeSuccessJSON(returnData)
  407. return
  408. }
  409. func (this *SelfDrugApiController) SaveOutStock() {
  410. timeLayout := "2006-01-02"
  411. loc, _ := time.LoadLocation("Local")
  412. start_time := this.GetString("start_time")
  413. admin_user_id, _ := this.GetInt64("admin_user_id")
  414. patient_id, _ := this.GetInt64("patient_id")
  415. dataBody := make(map[string]interface{}, 0)
  416. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  417. fmt.Println(err)
  418. outStocks, _ := dataBody["outStocks"].([]interface{})
  419. adminUserInfo := this.GetAdminUserInfo()
  420. orgId := adminUserInfo.CurrentOrgId
  421. for _, item := range outStocks {
  422. items := item.(map[string]interface{})
  423. drug_name := items["drug_name"].(string)
  424. drug_name_id := int64(items["drug_name_id"].(float64))
  425. drug_spec := items["drug_spec"].(string)
  426. outstore_number := items["outstore_number"].(string)
  427. outStoreNumber, _ := strconv.ParseInt(outstore_number, 10, 64)
  428. remarks := items["remarks"].(string)
  429. medic_id := int64(items["id"].(float64))
  430. timeStr := time.Now().Format("2006-01-02")
  431. timeArr := strings.Split(timeStr, "-")
  432. total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
  433. total = total + 1
  434. warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  435. number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
  436. number = number + total
  437. warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
  438. fmt.Println(remarks)
  439. fmt.Println(items)
  440. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  441. stock := models.XtSelfOutStock{
  442. DrugName: drug_name,
  443. DrugNameId: drug_name_id,
  444. DrugSpec: drug_spec,
  445. OutstoreNumber: outStoreNumber,
  446. Remarks: remarks,
  447. AdminUserId: admin_user_id,
  448. StorckTime: theTime.Unix(),
  449. CreatedTime: time.Now().Unix(),
  450. Status: 1,
  451. UserOrgId: orgId,
  452. StockOutNumber: warehousing_out_order,
  453. PatientId: patient_id,
  454. ExitMode: 1,
  455. MedicId: medic_id,
  456. }
  457. err := service.CreateOutStock(&stock)
  458. fmt.Println("err", err)
  459. }
  460. returnData := make(map[string]interface{}, 0)
  461. returnData["msg"] = "ok"
  462. this.ServeSuccessJSON(returnData)
  463. return
  464. }
  465. func (this *SelfDrugApiController) DeleteDrugById() {
  466. id, _ := this.GetInt64("id")
  467. drug_name := this.GetString("drug_name")
  468. adminUserInfo := this.GetAdminUserInfo()
  469. orgId := adminUserInfo.CurrentOrgId
  470. _, errcode := service.GetStandDrugByDrugName(drug_name, orgId)
  471. if errcode == gorm.ErrRecordNotFound {
  472. service.DeleteDrugName(id)
  473. returnData := make(map[string]interface{}, 0)
  474. returnData["msg"] = "ok"
  475. this.ServeSuccessJSON(returnData)
  476. } else if errcode == nil {
  477. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  478. return
  479. }
  480. }
  481. func (this *SelfDrugApiController) SaveRadio() {
  482. radio, _ := this.GetInt64("radio")
  483. adminUserInfo := this.GetAdminUserInfo()
  484. orgId := adminUserInfo.CurrentOrgId
  485. drugSet := models.XtDrugSet{
  486. DrugStart: radio,
  487. UserOrgId: orgId,
  488. Status: 1,
  489. CreatedTime: time.Now().Unix(),
  490. }
  491. _, errcode := service.GetDrugSetByUserOrgId(orgId)
  492. if errcode == gorm.ErrRecordNotFound {
  493. err := service.SaveRadio(&drugSet)
  494. if err != nil {
  495. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  496. return
  497. }
  498. this.ServeSuccessJSON(map[string]interface{}{
  499. "drugSet": drugSet,
  500. })
  501. } else if errcode == nil {
  502. err := service.UpdateDrugSet(&drugSet, orgId)
  503. if err != nil {
  504. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  505. return
  506. }
  507. this.ServeSuccessJSON(map[string]interface{}{
  508. "drugSet": drugSet,
  509. })
  510. }
  511. }
  512. func (this *SelfDrugApiController) DeleteDrugStand() {
  513. id, _ := this.GetInt64("id")
  514. name := this.GetString("name")
  515. adminUserInfo := this.GetAdminUserInfo()
  516. orgId := adminUserInfo.CurrentOrgId
  517. _, errcode := service.GetMedicalsByName(orgId, name)
  518. if errcode == gorm.ErrRecordNotFound {
  519. err := service.DeleteDrugStand(id)
  520. fmt.Println(err)
  521. returnData := make(map[string]interface{}, 0)
  522. returnData["msg"] = "ok"
  523. this.ServeSuccessJSON(returnData)
  524. } else if errcode == nil {
  525. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  526. return
  527. }
  528. }
  529. func (this *SelfDrugApiController) GetStockList() {
  530. patientid, _ := this.GetInt64("id")
  531. start_time := this.GetString("start_time")
  532. fmt.Println("开始时间", start_time)
  533. timeLayout := "2006-01-02"
  534. loc, _ := time.LoadLocation("Local")
  535. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  536. startimeUnix := theTime.Unix()
  537. keyword := this.GetString("keyword")
  538. fmt.Println("keyword", keyword)
  539. adminUserInfo := this.GetAdminUserInfo()
  540. orgId := adminUserInfo.CurrentOrgId
  541. //获取
  542. medicalList, _ := service.GetMedicalList(patientid, orgId, keyword)
  543. //统计总数量
  544. stocklist, err := service.GetStockList(patientid, startimeUnix, keyword, orgId)
  545. //统计出库数量
  546. outStocklist, err := service.GetOutStockList(patientid, startimeUnix, keyword, orgId)
  547. //统计该病人时间段内出库条数
  548. outList, err := service.GetTotalOutStockList(patientid, startimeUnix, keyword, orgId)
  549. if err != nil {
  550. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  551. return
  552. }
  553. this.ServeSuccessJSON(map[string]interface{}{
  554. "medicalList": medicalList,
  555. "stocklist": stocklist,
  556. "outStocklist": outStocklist,
  557. "outList": outList,
  558. })
  559. }
  560. func (this *SelfDrugApiController) DeleteDrugName() {
  561. drug_name := this.GetString("drugname")
  562. patient_id, _ := this.GetInt64("patientid")
  563. //查询该药品是否出库
  564. stocklist, _ := service.GetStockOutDetail(drug_name, patient_id)
  565. if len(stocklist) == 0 {
  566. //删除该药品
  567. service.DeleteDrugStockNumber(drug_name, patient_id)
  568. returnData := make(map[string]interface{}, 0)
  569. returnData["msg"] = "ok"
  570. this.ServeSuccessJSON(returnData)
  571. } else {
  572. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  573. return
  574. }
  575. }
  576. func (this *SelfDrugApiController) GetDrugDetail() {
  577. timeLayout := "2006-01-02"
  578. loc, _ := time.LoadLocation("Local")
  579. drug_name := this.GetString("drug_name")
  580. drug_spec := this.GetString("drug_spec")
  581. start_time := this.GetString("start_time")
  582. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  583. end_time := this.GetString("end_time")
  584. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  585. patient_id, _ := this.GetInt64("patient_id")
  586. adminUserInfo := this.GetAdminUserInfo()
  587. orgId := adminUserInfo.CurrentOrgId
  588. //查询入库明细
  589. stockDetail, err := service.GetStockDetail(drug_name, drug_spec, startTime.Unix(), endTime.Unix(), patient_id, orgId)
  590. //查询出库明细
  591. outStockDetail, err := service.GetOutStockDetail(drug_name, drug_spec, startTime.Unix(), endTime.Unix(), patient_id, orgId)
  592. if err != nil {
  593. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  594. return
  595. }
  596. this.ServeSuccessJSON(map[string]interface{}{
  597. "stockDetail": stockDetail,
  598. "outStockDetail": outStockDetail,
  599. })
  600. }
  601. func (this *SelfDrugApiController) GetAllPatientStockList() {
  602. timeLayout := "2006-01-02"
  603. loc, _ := time.LoadLocation("Local")
  604. drug_name := this.GetString("drug_name")
  605. drug_spec := this.GetString("drug_spec")
  606. start_time := this.GetString("start_time")
  607. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  608. startUnix := theTime.Unix()
  609. end_time := this.GetString("end_time")
  610. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  611. endTimeUnix := endTimes.Unix()
  612. keywords := this.GetString("search_input")
  613. adminUserInfo := this.GetAdminUserInfo()
  614. orgId := adminUserInfo.CurrentOrgId
  615. //入库
  616. stocklist, err := service.GetAllPatientStockList(drug_name, drug_spec, startUnix, endTimeUnix, keywords, orgId)
  617. //出库
  618. outStockList, err := service.GetAllPatientOutStockList(drug_name, drug_spec, startUnix, endTimeUnix, keywords, orgId)
  619. if err != nil {
  620. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  621. return
  622. }
  623. this.ServeSuccessJSON(map[string]interface{}{
  624. "stocklist": stocklist,
  625. "outStockList": outStockList,
  626. })
  627. }
  628. func (this *SelfDrugApiController) GetDrugDataByPatientId() {
  629. patient_id, _ := this.GetInt64("patient_id")
  630. fmt.Println("patient_id", patient_id)
  631. medicalList, err := service.GetDrugDataByPatientId(patient_id)
  632. if err != nil {
  633. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  634. return
  635. }
  636. this.ServeSuccessJSON(map[string]interface{}{
  637. "medicalList": medicalList,
  638. })
  639. }
  640. func (this *SelfDrugApiController) GetSelfMedicalList() {
  641. patient_id, _ := this.GetInt64("patient_id")
  642. adminUserInfo := this.GetAdminUserInfo()
  643. orgId := adminUserInfo.CurrentOrgId
  644. _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(orgId)
  645. privateDrugConfig, _ := service.GetDrugSetByUserOrgId(orgId)
  646. drugList, _ := service.GetAllBaseDrugLibList(orgId)
  647. privateDrugList, _ := service.GetPrivateDrugList(patient_id, orgId)
  648. this.ServeSuccessJSON(map[string]interface{}{
  649. "base_drug_config": drugStockConfig,
  650. "private_drug_config": privateDrugConfig,
  651. "base_drug_list": drugList,
  652. "private_drug_list": privateDrugList,
  653. })
  654. ////查询是否开启药品库
  655. //config, _ := service.GetDruckStockConfig(orgId)
  656. //
  657. //fmt.Println("--------------------------",config.IsOpen)
  658. ////开启
  659. //if config.IsOpen == 1 {
  660. // //查询该机构下的药品库
  661. // drugName, _ := service.GetAllDrugName(orgId)
  662. //
  663. // //查询该机构是否开启自备药
  664. // medical, _ := service.GetSetSelfMedical(orgId)
  665. // fmt.Println("medical+++++++++++++++++",medical.DrugStart)
  666. // //开启
  667. // if medical.DrugStart == 1 {
  668. // list, err := service.GetSelfMedicalList(patient_id)
  669. // if err != nil {
  670. // this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  671. // return
  672. // }
  673. // this.ServeSuccessJSON(map[string]interface{}{
  674. // "medicalList": list,
  675. // "drugName": drugName,
  676. // })
  677. // } else {
  678. // this.ServeSuccessJSON(map[string]interface{}{
  679. // "drugName": drugName,
  680. // })
  681. // }
  682. //}
  683. }
  684. func (this *SelfDrugApiController) GetDrugDescByDrugName() {
  685. drug_name := this.GetString("drug_name")
  686. patient_id, _ := this.GetInt64("patient_id")
  687. way, _ := this.GetInt64("way")
  688. adminUserInfo := this.GetAdminUserInfo()
  689. orgId := adminUserInfo.CurrentOrgId
  690. drug_id, _ := this.GetInt64("id")
  691. //从基础库查询
  692. if way == 1 {
  693. //查询基础库数据
  694. medcal, err := service.GetBaseMedcal(drug_name, orgId)
  695. //统计入库数量
  696. countInfo, err := service.GetTotalBaseMedicalCount(drug_id, orgId)
  697. //统计出库数量
  698. countout, err := service.GetTotalBaseMedicalCountOut(drug_id, orgId)
  699. if err != nil {
  700. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  701. return
  702. }
  703. this.ServeSuccessJSON(map[string]interface{}{
  704. "drugspec": medcal,
  705. "countInfo": countInfo,
  706. "countout": countout,
  707. })
  708. }
  709. //从自备药库查询
  710. if way == 2 {
  711. drugspec, err := service.GetDrugDescByDrugName(drug_name, patient_id, orgId)
  712. if err != nil {
  713. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  714. return
  715. }
  716. this.ServeSuccessJSON(map[string]interface{}{
  717. "drugspec": drugspec,
  718. })
  719. }
  720. }
  721. func (this *SelfDrugApiController) GetDrugSet() {
  722. adminUserInfo := this.GetAdminUserInfo()
  723. orgId := adminUserInfo.CurrentOrgId
  724. drugSet, err := service.GetDrugSet(orgId)
  725. if err != nil {
  726. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  727. return
  728. }
  729. this.ServeSuccessJSON(map[string]interface{}{
  730. "drugSet": drugSet,
  731. })
  732. }
  733. func (this *SelfDrugApiController) GetAllMedicalList() {
  734. adminUserInfo := this.GetAdminUserInfo()
  735. orgId := adminUserInfo.CurrentOrgId
  736. list, err := service.GetAllMedicalList(orgId)
  737. if err != nil {
  738. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  739. return
  740. }
  741. this.ServeSuccessJSON(map[string]interface{}{
  742. "drugName": list,
  743. })
  744. }
  745. func (this *SelfDrugApiController) GetStandName() {
  746. name := this.GetString("name")
  747. adminUserInfo := this.GetAdminUserInfo()
  748. orgId := adminUserInfo.CurrentOrgId
  749. rullerlist, err := service.GetRulleName(orgId, name)
  750. if err != nil {
  751. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  752. return
  753. }
  754. this.ServeSuccessJSON(map[string]interface{}{
  755. "rullerlist": rullerlist,
  756. })
  757. }
  758. func (this *SelfDrugApiController) GetRullerList() {
  759. id, _ := this.GetInt64("id")
  760. adminUserInfo := this.GetAdminUserInfo()
  761. orgId := adminUserInfo.CurrentOrgId
  762. rullerList, err := service.GetRulleList(orgId, id)
  763. if err != nil {
  764. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  765. return
  766. }
  767. this.ServeSuccessJSON(map[string]interface{}{
  768. "rullerlist": rullerList,
  769. })
  770. }
  771. func (this *SelfDrugApiController) DeleteDrugNameById() {
  772. id, _ := this.GetInt64("id")
  773. drug_name := this.GetString("drug_name")
  774. adminUserInfo := this.GetAdminUserInfo()
  775. orgId := adminUserInfo.CurrentOrgId
  776. _, errcode := service.GetStandDrugByDrugName(drug_name, orgId)
  777. if errcode == gorm.ErrRecordNotFound {
  778. service.DeleteDrugNameById(id)
  779. returnData := make(map[string]interface{}, 0)
  780. returnData["msg"] = "ok"
  781. this.ServeSuccessJSON(returnData)
  782. } else if errcode == nil {
  783. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  784. return
  785. }
  786. }
  787. func (this *SelfDrugApiController) GetPatientDetail() {
  788. id, _ := this.GetInt64("id")
  789. adminUserInfo := this.GetAdminUserInfo()
  790. patientDetail, err := service.GetPatientDetail(id, adminUserInfo.CurrentOrgId)
  791. if err != nil {
  792. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  793. return
  794. }
  795. this.ServeSuccessJSON(map[string]interface{}{
  796. "patientDetail": patientDetail,
  797. })
  798. }
  799. //func (this *SelfDrugApiController) ToPatientDetail() {
  800. //
  801. // keyword := this.GetString("keyword")
  802. // adminUser := this.GetAdminUserInfo()
  803. // orgId := adminUser.CurrentOrgId
  804. // patient, err := service.ToSeachPatient(keyword, orgId)
  805. // if err != nil {
  806. // this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  807. // return
  808. // }
  809. // this.ServeSuccessJSON(map[string]interface{}{
  810. // "patient": patient,
  811. // })
  812. //}
  813. func (this *SelfDrugApiController) GetSelfStockQuery() {
  814. adminUserInfo := this.GetAdminUserInfo()
  815. orgId := adminUserInfo.CurrentOrgId
  816. type_name, _ := this.GetInt64("type_name")
  817. keywords := this.GetString("keywords")
  818. timeLayout := "2006-01-02"
  819. loc, _ := time.LoadLocation("Local")
  820. start_time := this.GetString("start_time")
  821. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  822. startUnix := theTime.Unix()
  823. end_time := this.GetString("end_time")
  824. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  825. endTimeUnix := endTimes.Unix()
  826. page, _ := this.GetInt64("page")
  827. limit, _ := this.GetInt64("limit")
  828. //统计入库数量
  829. stockQuery, total, err := service.GetSelfStockQuery(type_name, keywords, startUnix, endTimeUnix, orgId, limit, page)
  830. //统计出库数量
  831. stockOutQuery, err := service.GetSelfOutStockQuery(startUnix, endTimeUnix, orgId)
  832. if err != nil {
  833. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  834. return
  835. }
  836. this.ServeSuccessJSON(map[string]interface{}{
  837. "stockQuery": stockQuery,
  838. "total": total,
  839. "stockOutQuery": stockOutQuery,
  840. })
  841. }
  842. func (this *SelfDrugApiController) PostSearchDrugWarehouseList() {
  843. keyword := this.GetString("keyword")
  844. orgId := this.GetAdminUserInfo().CurrentOrgId
  845. list, err := service.PostSearchDrugWarehouseList(keyword, orgId)
  846. manufacturerList, err := service.GetAllManufacturerList(orgId)
  847. dealerList, err := service.GetAllDealerList(orgId)
  848. if err != nil {
  849. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  850. return
  851. }
  852. this.ServeSuccessJSON(map[string]interface{}{
  853. "list": list,
  854. "manufacturerList": manufacturerList,
  855. "dealerList": dealerList,
  856. })
  857. }
  858. func (this *SelfDrugApiController) SaveDrugPrice() {
  859. fmt.Println("999999999999999999999")
  860. timeLayout := "2006-01-02"
  861. loc, _ := time.LoadLocation("Local")
  862. dataBody := make(map[string]interface{}, 0)
  863. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  864. fmt.Println(err)
  865. tableData, _ := dataBody["tableData"].([]interface{})
  866. fmt.Println("999939433443", tableData)
  867. if len(tableData) > 0 {
  868. for _, item := range tableData {
  869. items := item.(map[string]interface{})
  870. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  871. utils.ErrorLog("drug_name")
  872. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  873. return
  874. }
  875. drug_name := items["drug_name"].(string)
  876. fmt.Println("drug_aname23232323232", drug_name)
  877. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  878. utils.ErrorLog("drug_name")
  879. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  880. return
  881. }
  882. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  883. utils.ErrorLog("retail_price")
  884. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  885. return
  886. }
  887. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  888. if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
  889. utils.ErrorLog("warehousing_order")
  890. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  891. return
  892. }
  893. warehousing_order := items["warehousing_order"].(string)
  894. if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
  895. utils.ErrorLog("number")
  896. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  897. return
  898. }
  899. number := items["number"].(string)
  900. if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
  901. utils.ErrorLog("dealer")
  902. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  903. return
  904. }
  905. dealer := items["dealer"].(string)
  906. if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
  907. utils.ErrorLog("manufacturer")
  908. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  909. return
  910. }
  911. manufacturer := items["manufacturer"].(string)
  912. //if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
  913. // utils.ErrorLog("specification_name")
  914. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  915. // return
  916. //}
  917. //specification_name := items["specification_name"].(string)
  918. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  919. utils.ErrorLog("remark")
  920. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  921. return
  922. }
  923. remark := items["remark"].(string)
  924. if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
  925. utils.ErrorLog("warehousing_unit")
  926. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  927. return
  928. }
  929. warehousing_unit := items["warehousing_unit"].(string)
  930. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  931. utils.ErrorLog("last_price")
  932. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  933. return
  934. }
  935. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  936. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
  937. utils.ErrorLog("count")
  938. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  939. return
  940. }
  941. count := int64(items["count"].(float64))
  942. if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
  943. utils.ErrorLog("new_price")
  944. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  945. return
  946. }
  947. new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
  948. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  949. utils.ErrorLog("drug_id")
  950. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  951. return
  952. }
  953. drug_id := int64(items["drug_id"].(float64))
  954. if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
  955. utils.ErrorLog("start_time")
  956. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  957. return
  958. }
  959. var startTime int64
  960. start_time := items["start_time"].(string)
  961. if len(start_time) > 0 {
  962. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  963. if err != nil {
  964. fmt.Println(err)
  965. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  966. return
  967. }
  968. startTime = theTime.Unix()
  969. }
  970. orgId := this.GetAdminUserInfo().CurrentOrgId
  971. Creater := this.GetAdminUserInfo().AdminUser.Id
  972. drugAdjust := models.XtDrugAdjustPrice{
  973. DrugName: drug_name,
  974. SpecificationName: "",
  975. WarehousingUnit: warehousing_unit,
  976. Count: count,
  977. LastPrice: last_price,
  978. RetailPrice: retail_price,
  979. NewPrice: new_price,
  980. Manufacturer: manufacturer,
  981. Dealer: dealer,
  982. Remark: remark,
  983. DrugId: drug_id,
  984. UserOrgId: orgId,
  985. Ctime: time.Now().Unix(),
  986. Mtime: 0,
  987. Status: 1,
  988. WarehousingOrder: warehousing_order,
  989. Number: number,
  990. StartTime: startTime,
  991. Creater: Creater,
  992. Checker: 0,
  993. CheckerStatus: 2,
  994. CheckerTime: 0,
  995. }
  996. err := service.CreateDrugPrice(drugAdjust)
  997. fmt.Println(err)
  998. }
  999. }
  1000. returnData := make(map[string]interface{}, 0)
  1001. returnData["msg"] = "ok"
  1002. this.ServeSuccessJSON(returnData)
  1003. return
  1004. }
  1005. func (this *SelfDrugApiController) GetDrugPriceList() {
  1006. timeLayout := "2006-01-02"
  1007. loc, _ := time.LoadLocation("Local")
  1008. dataBody := make(map[string]interface{}, 0)
  1009. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1010. fmt.Println(err)
  1011. orgId := this.GetAdminUserInfo().CurrentOrgId
  1012. keyword := this.GetString("keyword")
  1013. start_time := this.GetString("start_time")
  1014. end_time := this.GetString("end_time")
  1015. var startTime int64
  1016. if len(start_time) > 0 {
  1017. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1018. if err != nil {
  1019. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1020. return
  1021. }
  1022. startTime = theTime.Unix()
  1023. }
  1024. var endTime int64
  1025. if len(end_time) > 0 {
  1026. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1027. if err != nil {
  1028. utils.ErrorLog(err.Error())
  1029. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1030. return
  1031. }
  1032. endTime = theTime.Unix()
  1033. }
  1034. limit, _ := this.GetInt64("limit")
  1035. page, _ := this.GetInt64("page")
  1036. list, total, err := service.GetDrugPriceList(startTime, endTime, orgId, keyword, limit, page)
  1037. doctorList, err := service.GetAllDoctorThree(orgId)
  1038. if err != nil {
  1039. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1040. return
  1041. }
  1042. this.ServeSuccessJSON(map[string]interface{}{
  1043. "total": total,
  1044. "list": list,
  1045. "doctorList": doctorList,
  1046. })
  1047. }
  1048. func (this *SelfDrugApiController) SaveCheckDrugPrice() {
  1049. timeLayout := "2006-01-02"
  1050. loc, _ := time.LoadLocation("Local")
  1051. dataBody := make(map[string]interface{}, 0)
  1052. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1053. fmt.Println(err)
  1054. idstr := this.GetString("ids")
  1055. ids := strings.Split(idstr, ",")
  1056. check_time := this.GetString("check_time")
  1057. var checkTime int64
  1058. if len(check_time) > 0 {
  1059. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
  1060. if err != nil {
  1061. fmt.Println(err)
  1062. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1063. return
  1064. }
  1065. checkTime = theTime.Unix()
  1066. }
  1067. checker, _ := this.GetInt64("checker")
  1068. adjustPrice := models.XtDrugAdjustPrice{
  1069. Checker: checker,
  1070. CheckerStatus: 1,
  1071. CheckerTime: checkTime,
  1072. }
  1073. err = service.UpdateDrugAdjuestPrice(ids, adjustPrice)
  1074. fmt.Println("err", err)
  1075. list, _ := service.GetDrugAdjuestPrice(ids)
  1076. for _, item := range list {
  1077. drug := models.BaseDrugLib{
  1078. RetailPrice: item.RetailPrice,
  1079. }
  1080. service.UpdateBaseDrugOne(drug, item.DrugId)
  1081. }
  1082. this.ServeSuccessJSON(map[string]interface{}{
  1083. "adjustPrice": adjustPrice,
  1084. })
  1085. }
  1086. func (this *SelfDrugApiController) SaveDrugDamage() {
  1087. timeLayout := "2006-01-02"
  1088. loc, _ := time.LoadLocation("Local")
  1089. dataBody := make(map[string]interface{}, 0)
  1090. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1091. fmt.Println(err)
  1092. tableData, _ := dataBody["tableData"].([]interface{})
  1093. fmt.Println("999939433443", tableData)
  1094. if len(tableData) > 0 {
  1095. for _, item := range tableData {
  1096. items := item.(map[string]interface{})
  1097. drug_name := items["drug_name"].(string)
  1098. fmt.Println("durg_nae232333223332232323323223232323", drug_name)
  1099. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  1100. utils.ErrorLog("drug_name")
  1101. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1102. return
  1103. }
  1104. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  1105. utils.ErrorLog("retail_price")
  1106. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1107. return
  1108. }
  1109. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  1110. if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
  1111. utils.ErrorLog("warehousing_order")
  1112. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1113. return
  1114. }
  1115. warehousing_order := items["warehousing_order"].(string)
  1116. if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
  1117. utils.ErrorLog("number")
  1118. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1119. return
  1120. }
  1121. number := items["number"].(string)
  1122. if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
  1123. utils.ErrorLog("dealer")
  1124. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1125. return
  1126. }
  1127. dealer := items["dealer"].(string)
  1128. if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
  1129. utils.ErrorLog("manufacturer")
  1130. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1131. return
  1132. }
  1133. manufacturer := items["manufacturer"].(string)
  1134. if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
  1135. utils.ErrorLog("specification_name")
  1136. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1137. return
  1138. }
  1139. specification_name := items["specification_name"].(string)
  1140. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  1141. utils.ErrorLog("remark")
  1142. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1143. return
  1144. }
  1145. remark := items["remark"].(string)
  1146. if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
  1147. utils.ErrorLog("warehousing_unit")
  1148. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1149. return
  1150. }
  1151. warehousing_unit := items["warehousing_unit"].(string)
  1152. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  1153. utils.ErrorLog("last_price")
  1154. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1155. return
  1156. }
  1157. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  1158. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
  1159. utils.ErrorLog("count")
  1160. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1161. return
  1162. }
  1163. count := int64(items["count"].(float64))
  1164. if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
  1165. utils.ErrorLog("new_price")
  1166. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1167. return
  1168. }
  1169. new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
  1170. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  1171. utils.ErrorLog("drug_id")
  1172. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1173. return
  1174. }
  1175. drug_id := int64(items["drug_id"].(float64))
  1176. if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
  1177. utils.ErrorLog("start_time")
  1178. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1179. return
  1180. }
  1181. var startTime int64
  1182. start_time := items["start_time"].(string)
  1183. if len(start_time) > 0 {
  1184. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1185. if err != nil {
  1186. fmt.Println(err)
  1187. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1188. return
  1189. }
  1190. startTime = theTime.Unix()
  1191. }
  1192. if items["warehousing_info_id"] == nil || reflect.TypeOf(items["warehousing_info_id"]).String() != "float64" {
  1193. utils.ErrorLog("warehousing_info_id")
  1194. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1195. return
  1196. }
  1197. warehousing_info_id := int64(items["warehousing_info_id"].(float64))
  1198. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
  1199. utils.ErrorLog("expiry_date")
  1200. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1201. return
  1202. }
  1203. expiry_date := int64(items["expiry_date"].(float64))
  1204. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
  1205. utils.ErrorLog("product_date")
  1206. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1207. return
  1208. }
  1209. product_date := int64(items["product_date"].(float64))
  1210. if items["drug_origin_place"] == nil || reflect.TypeOf(items["drug_origin_place"]).String() != "string" {
  1211. utils.ErrorLog("drug_origin_place")
  1212. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1213. return
  1214. }
  1215. drug_origin_place := items["drug_origin_place"].(string)
  1216. orgId := this.GetAdminUserInfo().CurrentOrgId
  1217. Creater := this.GetAdminUserInfo().AdminUser.Id
  1218. drugDamage := models.XtDrugDamage{
  1219. DrugName: drug_name,
  1220. SpecificationName: specification_name,
  1221. WarehousingUnit: warehousing_unit,
  1222. Count: count,
  1223. LastPrice: last_price,
  1224. RetailPrice: retail_price,
  1225. NewPrice: new_price,
  1226. Manufacturer: manufacturer,
  1227. Dealer: dealer,
  1228. Remark: remark,
  1229. DrugId: drug_id,
  1230. UserOrgId: orgId,
  1231. Ctime: time.Now().Unix(),
  1232. Mtime: 0,
  1233. Status: 1,
  1234. WarehousingOrder: warehousing_order,
  1235. Number: number,
  1236. StartTime: startTime,
  1237. Creater: Creater,
  1238. Checker: 0,
  1239. CheckerStatus: 2,
  1240. CheckerTime: 0,
  1241. ExpiryDate: expiry_date,
  1242. ProductDate: product_date,
  1243. WarehousingInfoId: warehousing_info_id,
  1244. DrugOriginPlace: drug_origin_place,
  1245. }
  1246. err := service.CreateDrugDamage(drugDamage)
  1247. fmt.Println(err)
  1248. }
  1249. }
  1250. returnData := make(map[string]interface{}, 0)
  1251. returnData["msg"] = "ok"
  1252. this.ServeSuccessJSON(returnData)
  1253. }
  1254. func (this *SelfDrugApiController) GetDrugDamageList() {
  1255. timeLayout := "2006-01-02"
  1256. loc, _ := time.LoadLocation("Local")
  1257. dataBody := make(map[string]interface{}, 0)
  1258. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1259. fmt.Println(err)
  1260. orgId := this.GetAdminUserInfo().CurrentOrgId
  1261. keyword := this.GetString("keyword")
  1262. fmt.Println("keywoer2r2r32rwrwr", keyword)
  1263. start_time := this.GetString("start_time")
  1264. end_time := this.GetString("end_time")
  1265. var startTime int64
  1266. if len(start_time) > 0 {
  1267. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1268. if err != nil {
  1269. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1270. return
  1271. }
  1272. startTime = theTime.Unix()
  1273. }
  1274. var endTime int64
  1275. if len(end_time) > 0 {
  1276. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1277. if err != nil {
  1278. utils.ErrorLog(err.Error())
  1279. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1280. return
  1281. }
  1282. endTime = theTime.Unix()
  1283. }
  1284. limit, _ := this.GetInt64("limit")
  1285. page, _ := this.GetInt64("page")
  1286. list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page)
  1287. doctorList, err := service.GetAllDoctorThree(orgId)
  1288. if err != nil {
  1289. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1290. return
  1291. }
  1292. this.ServeSuccessJSON(map[string]interface{}{
  1293. "total": total,
  1294. "list": list,
  1295. "doctorList": doctorList,
  1296. })
  1297. }
  1298. func (this *SelfDrugApiController) SaveDrugDamagePrice() {
  1299. timeLayout := "2006-01-02"
  1300. loc, _ := time.LoadLocation("Local")
  1301. dataBody := make(map[string]interface{}, 0)
  1302. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1303. fmt.Println(err)
  1304. idstr := this.GetString("ids")
  1305. ids := strings.Split(idstr, ",")
  1306. check_time := this.GetString("check_time")
  1307. var checkTime int64
  1308. if len(check_time) > 0 {
  1309. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
  1310. if err != nil {
  1311. fmt.Println(err)
  1312. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1313. return
  1314. }
  1315. checkTime = theTime.Unix()
  1316. }
  1317. checker, _ := this.GetInt64("checker")
  1318. damage := models.XtDrugDamage{
  1319. Checker: checker,
  1320. CheckerStatus: 1,
  1321. CheckerTime: checkTime,
  1322. }
  1323. err = service.UpdateDrugDamage(ids, damage)
  1324. fmt.Println(err)
  1325. list, _ := service.GetDrugDamage(ids)
  1326. ctime := time.Now().Unix()
  1327. adminUserInfo := this.GetAdminUserInfo()
  1328. manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
  1329. dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
  1330. var manufacturer_id int64
  1331. var dealer_id int64
  1332. for _, item := range list {
  1333. for _, it := range manufacturerList {
  1334. if item.Manufacturer == it.ManufacturerName {
  1335. manufacturer_id = it.ID
  1336. }
  1337. }
  1338. for _, its := range dealerList {
  1339. if its.DealerName == item.Dealer {
  1340. dealer_id = its.ID
  1341. }
  1342. }
  1343. timeStr := time.Now().Format("2006-01-02")
  1344. timeArr := strings.Split(timeStr, "-")
  1345. total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
  1346. total = total + 1
  1347. warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  1348. number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
  1349. number = number + total
  1350. warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
  1351. operation_time := time.Now().Unix()
  1352. creater := adminUserInfo.AdminUser.Id
  1353. warehouseOut := models.DrugWarehouseOut{
  1354. WarehouseOutOrderNumber: warehousing_out_order,
  1355. OperationTime: operation_time,
  1356. OrgId: adminUserInfo.CurrentOrgId,
  1357. Creater: creater,
  1358. Ctime: ctime,
  1359. Status: 1,
  1360. WarehouseOutTime: time.Now().Unix(),
  1361. Type: 1,
  1362. }
  1363. warehouseOutInfo := models.XtDrugWarehouseOutInfo{
  1364. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1365. WarehouseOutId: warehouseOut.ID,
  1366. DrugId: item.DrugId,
  1367. Count: item.Count,
  1368. Price: item.RetailPrice,
  1369. Status: 1,
  1370. Ctime: ctime,
  1371. Remark: item.Remark,
  1372. OrgId: adminUserInfo.CurrentOrgId,
  1373. Type: 1,
  1374. Manufacturer: manufacturer_id,
  1375. Dealer: dealer_id,
  1376. RetailPrice: item.RetailPrice,
  1377. CountUnit: item.WarehousingUnit,
  1378. ExpiryDate: item.ExpiryDate,
  1379. ProductDate: item.ProductDate,
  1380. Number: item.Number,
  1381. BatchNumber: item.BatchNumber,
  1382. IsSys: 0,
  1383. WarehouseInfoId: item.WarehousingInfoId,
  1384. }
  1385. drugflow := models.DrugFlow{
  1386. WarehouseOutId: warehouseOut.ID,
  1387. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1388. DrugId: item.DrugId,
  1389. Number: item.Number,
  1390. ProductDate: item.ProductDate,
  1391. ExpireDate: item.ExpiryDate,
  1392. Count: item.Count,
  1393. Price: item.RetailPrice,
  1394. Status: 1,
  1395. Ctime: ctime,
  1396. UserOrgId: adminUserInfo.CurrentOrgId,
  1397. Manufacturer: manufacturer_id,
  1398. Dealer: dealer_id,
  1399. BatchNumber: item.BatchNumber,
  1400. MaxUnit: item.WarehousingUnit,
  1401. ConsumableType: 5,
  1402. IsEdit: 1,
  1403. Creator: adminUserInfo.AdminUser.Id,
  1404. IsSys: 0,
  1405. }
  1406. service.CreateWareHouseOutInfo(&warehouseOutInfo)
  1407. service.AddSigleDrugWarehouseOut(&warehouseOut)
  1408. service.CreateDrugFlowOne(drugflow)
  1409. }
  1410. this.ServeSuccessJSON(map[string]interface{}{
  1411. "damage": damage,
  1412. })
  1413. }
  1414. func (this *SelfDrugApiController) GetDrugModifyPrice() {
  1415. id, _ := this.GetInt64("id")
  1416. detail, err := service.GetDrugModifyPrice(id)
  1417. fmt.Println(err)
  1418. this.ServeSuccessJSON(map[string]interface{}{
  1419. "detail": detail,
  1420. })
  1421. }
  1422. func (this *SelfDrugApiController) ModifyDrugPrice() {
  1423. drug_name := this.GetString("drug_name")
  1424. retailPrice := this.GetString("retail_price")
  1425. retail_price, _ := strconv.ParseFloat(retailPrice, 64)
  1426. newPrice := this.GetString("new_price")
  1427. new_price, _ := strconv.ParseFloat(newPrice, 64)
  1428. count, _ := this.GetInt64("count")
  1429. remark := this.GetString("remark")
  1430. id, _ := this.GetInt64("id")
  1431. adjustPrice := models.XtDrugAdjustPrice{
  1432. DrugName: drug_name,
  1433. Count: count,
  1434. RetailPrice: retail_price,
  1435. NewPrice: new_price,
  1436. Remark: remark,
  1437. }
  1438. err := service.ModifyDrugPrice(id, adjustPrice)
  1439. fmt.Println(err)
  1440. this.ServeSuccessJSON(map[string]interface{}{
  1441. "adjustPrice": adjustPrice,
  1442. })
  1443. }
  1444. func (this *SelfDrugApiController) GetModifyPricePrint() {
  1445. ids := this.GetString("ids")
  1446. idsSplit := strings.Split(ids, ",")
  1447. list, err := service.GetModifyPricePrint(idsSplit)
  1448. fmt.Println(err)
  1449. this.ServeSuccessJSON(map[string]interface{}{
  1450. "list": list,
  1451. })
  1452. }
  1453. func (this *SelfDrugApiController) GetDrugDamageDetail() {
  1454. id, _ := this.GetInt64("id")
  1455. detail, _ := service.GetDrugDamageDetail(id)
  1456. this.ServeSuccessJSON(map[string]interface{}{
  1457. "detail": detail,
  1458. })
  1459. }
  1460. func (this *SelfDrugApiController) ModifyDrugDamage() {
  1461. id, _ := this.GetInt64("id")
  1462. drug_id, _ := this.GetInt64("drug_id")
  1463. drug_name := this.GetString("drug_name")
  1464. //drug_origin_place := this.GetString("drug_origin_place")
  1465. lastPrice := this.GetString("last_price")
  1466. last_price, _ := strconv.ParseFloat(lastPrice, 64)
  1467. newPrice := this.GetString("new_price")
  1468. new_price, _ := strconv.ParseFloat(newPrice, 64)
  1469. manufacturer := this.GetString("manufacturer")
  1470. number := this.GetString("number")
  1471. retailPrice := this.GetString("retail_price")
  1472. retail_price, _ := strconv.ParseFloat(retailPrice, 64)
  1473. remark := this.GetString("remark")
  1474. count, _ := this.GetInt64("count")
  1475. warehousing_unit := this.GetString("warehousing_unit")
  1476. damage := models.XtDrugDamage{
  1477. DrugName: drug_name,
  1478. SpecificationName: "",
  1479. WarehousingUnit: warehousing_unit,
  1480. Count: count,
  1481. LastPrice: last_price,
  1482. RetailPrice: retail_price,
  1483. NewPrice: new_price,
  1484. Manufacturer: manufacturer,
  1485. Dealer: "",
  1486. Remark: remark,
  1487. DrugId: drug_id,
  1488. Number: number,
  1489. }
  1490. err := service.ModifyDrugDamage(id, damage)
  1491. fmt.Println(err)
  1492. this.ServeSuccessJSON(map[string]interface{}{
  1493. "damage": damage,
  1494. })
  1495. }
  1496. func (this *SelfDrugApiController) DeleteDrugDamage() {
  1497. id, _ := this.GetInt64("id")
  1498. err := service.DeleteDrugDamage(id)
  1499. fmt.Println(err)
  1500. returnData := make(map[string]interface{}, 0)
  1501. returnData["msg"] = "ok"
  1502. this.ServeSuccessJSON(returnData)
  1503. }
  1504. func (this *SelfDrugApiController) GetDrugDamagePrint() {
  1505. idsSplit := this.GetString("ids")
  1506. ids := strings.Split(idsSplit, ",")
  1507. list, _ := service.GetDrugDamagePrint(ids)
  1508. this.ServeSuccessJSON(map[string]interface{}{
  1509. "list": list,
  1510. })
  1511. }
  1512. func (this *SelfDrugApiController) GetWarehoseInfoById() {
  1513. id, _ := this.GetInt64("id")
  1514. list, _ := service.GetWarehoseInfoById(id)
  1515. this.ServeSuccessJSON(map[string]interface{}{
  1516. "list": list,
  1517. })
  1518. }
  1519. func (this *SelfDrugApiController) SaveDrugInventory() {
  1520. timeLayout := "2006-01-02"
  1521. loc, _ := time.LoadLocation("Local")
  1522. dataBody := make(map[string]interface{}, 0)
  1523. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1524. fmt.Println(err)
  1525. tableData, _ := dataBody["tableData"].([]interface{})
  1526. fmt.Println("999939433443", tableData)
  1527. if len(tableData) > 0 {
  1528. for _, item := range tableData {
  1529. items := item.(map[string]interface{})
  1530. drug_name := items["drug_name"].(string)
  1531. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  1532. utils.ErrorLog("drug_name")
  1533. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1534. return
  1535. }
  1536. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  1537. utils.ErrorLog("retail_price")
  1538. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1539. return
  1540. }
  1541. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  1542. if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
  1543. utils.ErrorLog("warehousing_order")
  1544. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1545. return
  1546. }
  1547. warehousing_order := items["warehousing_order"].(string)
  1548. if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
  1549. utils.ErrorLog("dealer")
  1550. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1551. return
  1552. }
  1553. dealer := items["dealer"].(string)
  1554. if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
  1555. utils.ErrorLog("manufacturer")
  1556. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1557. return
  1558. }
  1559. manufacturer := items["manufacturer"].(string)
  1560. if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
  1561. utils.ErrorLog("specification_name")
  1562. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1563. return
  1564. }
  1565. specification_name := items["specification_name"].(string)
  1566. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  1567. utils.ErrorLog("remark")
  1568. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1569. return
  1570. }
  1571. remark := items["remark"].(string)
  1572. if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
  1573. utils.ErrorLog("warehousing_unit")
  1574. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1575. return
  1576. }
  1577. warehousing_unit := items["warehousing_unit"].(string)
  1578. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  1579. utils.ErrorLog("last_price")
  1580. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1581. return
  1582. }
  1583. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  1584. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
  1585. utils.ErrorLog("count")
  1586. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1587. return
  1588. }
  1589. count := int64(items["count"].(float64))
  1590. if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
  1591. utils.ErrorLog("new_price")
  1592. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1593. return
  1594. }
  1595. new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
  1596. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  1597. utils.ErrorLog("drug_id")
  1598. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1599. return
  1600. }
  1601. drug_id := int64(items["drug_id"].(float64))
  1602. if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
  1603. utils.ErrorLog("start_time")
  1604. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1605. return
  1606. }
  1607. var startTime int64
  1608. start_time := items["start_time"].(string)
  1609. if len(start_time) > 0 {
  1610. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1611. if err != nil {
  1612. fmt.Println(err)
  1613. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1614. return
  1615. }
  1616. startTime = theTime.Unix()
  1617. }
  1618. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
  1619. utils.ErrorLog("product_date")
  1620. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1621. return
  1622. }
  1623. product_date := int64(items["product_date"].(float64))
  1624. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
  1625. utils.ErrorLog("expiry_date")
  1626. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1627. return
  1628. }
  1629. expiry_date := int64(items["expiry_date"].(float64))
  1630. orgId := this.GetAdminUserInfo().CurrentOrgId
  1631. Creater := this.GetAdminUserInfo().AdminUser.Id
  1632. if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
  1633. utils.ErrorLog("number")
  1634. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1635. return
  1636. }
  1637. numbers := items["number"].(string)
  1638. //if items["batch_number"] == nil || reflect.TypeOf(items["batch_number"]).String() != "string" {
  1639. // utils.ErrorLog("batch_number")
  1640. // this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1641. // return
  1642. //}
  1643. //
  1644. //batch_number := items["batch_number"].(string)
  1645. if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
  1646. utils.ErrorLog("warehouse_info_id")
  1647. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1648. return
  1649. }
  1650. warehouse_info_id := int64(items["warehouse_info_id"].(float64))
  1651. if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "string" {
  1652. utils.ErrorLog("total")
  1653. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1654. return
  1655. }
  1656. total := items["total"].(string)
  1657. inventory := models.XtDrugInventory{
  1658. DrugName: drug_name,
  1659. SpecificationName: specification_name,
  1660. WarehousingUnit: warehousing_unit,
  1661. Count: count,
  1662. LastPrice: last_price,
  1663. RetailPrice: retail_price,
  1664. NewPrice: new_price,
  1665. Manufacturer: manufacturer,
  1666. Dealer: dealer,
  1667. Remark: remark,
  1668. DrugId: drug_id,
  1669. UserOrgId: orgId,
  1670. Ctime: time.Now().Unix(),
  1671. Mtime: 0,
  1672. Status: 1,
  1673. WarehousingOrder: warehousing_order,
  1674. LicenseNumber: "",
  1675. StartTime: startTime,
  1676. Creater: Creater,
  1677. Checker: 0,
  1678. CheckerStatus: 2,
  1679. CheckerTime: 0,
  1680. ExpiryDate: expiry_date,
  1681. ProductDate: product_date,
  1682. Number: numbers,
  1683. //BatchNumber: batch_number,
  1684. Total: total,
  1685. WarehouseInfoId: warehouse_info_id,
  1686. }
  1687. err = service.CreateDrugInventory(inventory)
  1688. fmt.Println(err)
  1689. }
  1690. }
  1691. this.ServeSuccessJSON(map[string]interface{}{
  1692. "msg": "msg",
  1693. })
  1694. }
  1695. func (this *SelfDrugApiController) GetDrugInventoryList() {
  1696. timeLayout := "2006-01-02"
  1697. loc, _ := time.LoadLocation("Local")
  1698. dataBody := make(map[string]interface{}, 0)
  1699. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1700. fmt.Println(err)
  1701. orgId := this.GetAdminUserInfo().CurrentOrgId
  1702. keyword := this.GetString("keyword")
  1703. start_time := this.GetString("start_time")
  1704. end_time := this.GetString("end_time")
  1705. var startTime int64
  1706. if len(start_time) > 0 {
  1707. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1708. if err != nil {
  1709. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1710. return
  1711. }
  1712. startTime = theTime.Unix()
  1713. }
  1714. var endTime int64
  1715. if len(end_time) > 0 {
  1716. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1717. if err != nil {
  1718. utils.ErrorLog(err.Error())
  1719. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1720. return
  1721. }
  1722. endTime = theTime.Unix()
  1723. }
  1724. limit, _ := this.GetInt64("limit")
  1725. page, _ := this.GetInt64("page")
  1726. list, total, err := service.GetDrugInventoryList(keyword, page, limit, orgId, startTime, endTime)
  1727. fmt.Println("list23232323223", list)
  1728. doctorList, _ := service.GetAllDoctorThree(orgId)
  1729. if err != nil {
  1730. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1731. return
  1732. }
  1733. this.ServeSuccessJSON(map[string]interface{}{
  1734. "total": total,
  1735. "list": list,
  1736. "doctorList": doctorList,
  1737. })
  1738. }
  1739. func (this *SelfDrugApiController) SaveDrugCheckInventory() {
  1740. timeLayout := "2006-01-02"
  1741. loc, _ := time.LoadLocation("Local")
  1742. dataBody := make(map[string]interface{}, 0)
  1743. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1744. fmt.Println(err)
  1745. idstr := this.GetString("ids")
  1746. ids := strings.Split(idstr, ",")
  1747. check_time := this.GetString("check_time")
  1748. var checkTime int64
  1749. if len(check_time) > 0 {
  1750. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
  1751. if err != nil {
  1752. fmt.Println(err)
  1753. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1754. return
  1755. }
  1756. checkTime = theTime.Unix()
  1757. }
  1758. checker, _ := this.GetInt64("checker")
  1759. inventory := models.XtDrugInventory{
  1760. Checker: checker,
  1761. CheckerStatus: 1,
  1762. CheckerTime: checkTime,
  1763. }
  1764. err = service.UpdateDrugInventory(ids, inventory)
  1765. fmt.Println(err)
  1766. returnData := make(map[string]interface{}, 0)
  1767. returnData["msg"] = "ok"
  1768. this.ServeSuccessJSON(returnData)
  1769. }
  1770. func (this *SelfDrugApiController) GetDrugInventoryDetail() {
  1771. id, _ := this.GetInt64("id")
  1772. detail, err := service.GetDrugInventoryDetail(id)
  1773. if err != nil {
  1774. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1775. return
  1776. }
  1777. this.ServeSuccessJSON(map[string]interface{}{
  1778. "detail": detail,
  1779. })
  1780. }
  1781. func (this *SelfDrugApiController) ModifyInventory() {
  1782. id, _ := this.GetInt64("id")
  1783. drug_id, _ := this.GetInt64("drug_id")
  1784. drug_name := this.GetString("drug_name")
  1785. specification_name := this.GetString("specification_name")
  1786. retailPrice := this.GetString("retail_price")
  1787. retail_price, _ := strconv.ParseFloat(retailPrice, 64)
  1788. warehousing_order := this.GetString("warehousing_order")
  1789. number := this.GetString("number")
  1790. manufacturer := this.GetString("manufacturer")
  1791. remark := this.GetString("remark")
  1792. warehousing_unit := this.GetString("warehousing_unit")
  1793. total := this.GetString("total")
  1794. lastPrice := this.GetString("last_price")
  1795. last_price, _ := strconv.ParseFloat(lastPrice, 64)
  1796. count, _ := this.GetInt64("count")
  1797. drug_origin_place := this.GetString("drug_origin_place")
  1798. inventory := models.XtDrugInventory{
  1799. DrugName: drug_name,
  1800. SpecificationName: specification_name,
  1801. WarehousingUnit: warehousing_unit,
  1802. Count: count,
  1803. LastPrice: last_price,
  1804. RetailPrice: retail_price,
  1805. Manufacturer: manufacturer,
  1806. Remark: remark,
  1807. DrugId: drug_id,
  1808. WarehousingOrder: warehousing_order,
  1809. Number: number,
  1810. Total: total,
  1811. DrugOriginPlace: drug_origin_place,
  1812. }
  1813. err := service.ModifyDrugInventory(id, inventory)
  1814. if err != nil {
  1815. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1816. return
  1817. }
  1818. this.ServeSuccessJSON(map[string]interface{}{
  1819. "inventory": inventory,
  1820. })
  1821. }
  1822. func (this *SelfDrugApiController) DeleteDrugInventory() {
  1823. id, _ := this.GetInt64("id")
  1824. err := service.DeleteDrugInventory(id)
  1825. fmt.Println(err)
  1826. returnData := make(map[string]interface{}, 0)
  1827. returnData["msg"] = "ok"
  1828. this.ServeSuccessJSON(returnData)
  1829. }
  1830. func (this *SelfDrugApiController) GetDrugInventoryPrintList() {
  1831. ids := this.GetString("ids")
  1832. idssplit := strings.Split(ids, ",")
  1833. list, err := service.GetDrugInventoryPrintList(idssplit)
  1834. if err != nil {
  1835. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1836. return
  1837. }
  1838. this.ServeSuccessJSON(map[string]interface{}{
  1839. "list": list,
  1840. })
  1841. }
  1842. func (this *SelfDrugApiController) GetDrugInventoryDetailList() {
  1843. keyword := this.GetString("keyword")
  1844. limit, _ := this.GetInt64("limit")
  1845. page, _ := this.GetInt64("page")
  1846. orgId := this.GetAdminUserInfo().CurrentOrgId
  1847. list, total, err := service.GetDrugInventoryDetailList(keyword, page, limit, orgId)
  1848. fmt.Println("list23232323223", list)
  1849. doctorList, _ := service.GetAllDoctorThree(orgId)
  1850. if err != nil {
  1851. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1852. return
  1853. }
  1854. this.ServeSuccessJSON(map[string]interface{}{
  1855. "total": total,
  1856. "list": list,
  1857. "doctorList": doctorList,
  1858. })
  1859. }
  1860. func (this *SelfDrugApiController) SaveDrugProofInventory() {
  1861. id, _ := this.GetInt64("id")
  1862. warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
  1863. warehousing_unit := this.GetString("warehousing_unit")
  1864. remark := this.GetString("remark")
  1865. //total := this.GetString("total")
  1866. prof_count, _ := this.GetInt64("prof_count")
  1867. inventory := models.XtDrugInventory{
  1868. WarehouseInfoId: warehouse_info_id,
  1869. ProofCount: prof_count,
  1870. WarehousingUnit: warehousing_unit,
  1871. Remark: remark,
  1872. }
  1873. err := service.UpdateDrugProofInventory(warehouse_info_id, &inventory)
  1874. info := models.XtDrugWarehouseInfo{
  1875. StockMaxNumber: prof_count,
  1876. }
  1877. service.UpdateDrugWarehouseInfoById(id, &info)
  1878. if err != nil {
  1879. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1880. return
  1881. }
  1882. this.ServeSuccessJSON(map[string]interface{}{
  1883. "inventory": inventory,
  1884. })
  1885. }