self_drug_api_congtroller.go 87KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629
  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{}, "Get: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. beego.Router("/api/drug/getdrugwarehouseinfototal", &StockManagerApiController{}, "Get:GetDrugWarehouseInfoTotal")
  78. beego.Router("/api/drug/saveinentorylist", &SelfDrugApiController{}, "Post:SaveInventoryList")
  79. beego.Router("/api/drug/getdamagebydrugid", &SelfDrugApiController{}, "Get:GetDamageByDrugId")
  80. beego.Router("/api/drug/getinventorymodelist", &SelfDrugApiController{}, "Get:GetInventoryModeList")
  81. }
  82. func (this *SelfDrugApiController) GetCurrentPatient() {
  83. adminUserInfo := this.GetAdminUserInfo()
  84. orgId := adminUserInfo.CurrentOrgId
  85. patient, err := service.GetCurrentPatient(orgId)
  86. if err != nil {
  87. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  88. return
  89. }
  90. this.ServeSuccessJSON(map[string]interface{}{
  91. "patient": patient,
  92. })
  93. }
  94. func (this *SelfDrugApiController) GetAllDrugName() {
  95. adminUserInfo := this.GetAdminUserInfo()
  96. orgId := adminUserInfo.CurrentOrgId
  97. //查询药品库是否开启
  98. //configStock, _ := service.GetDrugStockConfig(orgId)
  99. //if configStock.IsOpen == 1 {
  100. //
  101. //}
  102. drugName, err := service.GetAllDrugName(orgId)
  103. if err != nil {
  104. this.ServeFailJsonSend(enums.ErrorCodeDataException, "查寻成功")
  105. return
  106. }
  107. this.ServeSuccessJSON(map[string]interface{}{
  108. "drugName": drugName,
  109. })
  110. }
  111. func (this *SelfDrugApiController) SaveDrugName() {
  112. adminUserInfo := this.GetAdminUserInfo()
  113. orgId := adminUserInfo.CurrentOrgId
  114. drug_name := this.GetString("drug_name")
  115. id, _ := this.GetInt64("id")
  116. //fmt.Println("drug_name", drug_name)
  117. drugName := models.XtDrugName{
  118. UserOrgId: orgId,
  119. DrugName: drug_name,
  120. Status: 1,
  121. CreatedTime: time.Now().Unix(),
  122. DrugId: id,
  123. }
  124. _, errcode := service.GetDrugName(drug_name, orgId)
  125. if errcode == gorm.ErrRecordNotFound {
  126. err := service.SaveDrugName(&drugName)
  127. if err != nil {
  128. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  129. return
  130. }
  131. this.ServeSuccessJSON(map[string]interface{}{
  132. "drugName": drugName,
  133. })
  134. } else {
  135. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  136. return
  137. }
  138. }
  139. func (this *SelfDrugApiController) GetDrugNameList() {
  140. adminUserInfo := this.GetAdminUserInfo()
  141. orgId := adminUserInfo.CurrentOrgId
  142. list, err := service.GetDrugNameList(orgId)
  143. if err != nil {
  144. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  145. return
  146. }
  147. this.ServeSuccessJSON(map[string]interface{}{
  148. "list": list,
  149. })
  150. }
  151. func (this *SelfDrugApiController) GetRulleName() {
  152. adminUserInfo := this.GetAdminUserInfo()
  153. orgId := adminUserInfo.CurrentOrgId
  154. id, _ := this.GetInt64("id")
  155. drugId, _ := service.GetDrugId(id)
  156. rullerList, err := service.GetRulleList(orgId, drugId.DrugId)
  157. if err != nil {
  158. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  159. return
  160. }
  161. this.ServeSuccessJSON(map[string]interface{}{
  162. "rullerList": rullerList,
  163. })
  164. }
  165. func (this *SelfDrugApiController) GetUnitByBaseId() {
  166. id, _ := this.GetInt64("id")
  167. baseList, err := service.GetUnitByBaseId(id)
  168. if err != nil {
  169. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  170. return
  171. }
  172. this.ServeSuccessJSON(map[string]interface{}{
  173. "baseList": baseList,
  174. })
  175. }
  176. func (this *SelfDrugApiController) SaveRulleName() {
  177. drug_name := this.GetString("drug_name")
  178. drug_spec := this.GetString("drug_spec")
  179. drug_stock_limit := this.GetString("drug_stock_limit")
  180. drug_name_id, _ := this.GetInt64("drug_name_id")
  181. drug_id, _ := this.GetInt64("drug_id")
  182. price, _ := this.GetInt64("price")
  183. prices := strconv.FormatInt(price, 10)
  184. durg_price, _ := strconv.ParseFloat(prices, 64)
  185. unit := this.GetString("unit")
  186. adminUserInfo := this.GetAdminUserInfo()
  187. orgId := adminUserInfo.CurrentOrgId
  188. fmt.Println(drug_name, drug_stock_limit, unit, price, drug_spec, orgId)
  189. drugSpecName := models.XtStandName{
  190. DrugName: drug_name,
  191. DrugSpec: drug_spec,
  192. DrugStockLimit: drug_stock_limit,
  193. DrugNameId: drug_name_id,
  194. Price: durg_price,
  195. MinUnit: unit,
  196. UserOrgId: orgId,
  197. Status: 1,
  198. CreatedTime: time.Now().Unix(),
  199. DrugId: drug_id,
  200. }
  201. //查询该机构下药品规格名称是否存在
  202. _, errcode := service.IsExistStandName(drug_name, drug_spec, adminUserInfo.CurrentOrgId)
  203. if errcode == gorm.ErrRecordNotFound {
  204. err := service.SaveRulleName(&drugSpecName)
  205. if err != nil {
  206. this.ServeFailJsonSend(enums.ErrorCodeDataException, "创建规格失败")
  207. return
  208. }
  209. this.ServeSuccessJSON(map[string]interface{}{
  210. "RullerName": drugSpecName,
  211. })
  212. } else if errcode == nil {
  213. this.ServeFailJsonSend(enums.ErrorCodeDataException, "规格已存在")
  214. return
  215. }
  216. }
  217. func (this *SelfDrugApiController) EditRullerName() {
  218. id, _ := this.GetInt64("id")
  219. rullerDetail, err := service.GetRullerNameDetail(id)
  220. if err != nil {
  221. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  222. return
  223. }
  224. this.ServeSuccessJSON(map[string]interface{}{
  225. "rullerDetail": rullerDetail,
  226. })
  227. }
  228. func (this *SelfDrugApiController) UpdatedRullerName() {
  229. id, _ := this.GetInt64("id")
  230. drug_name := this.GetString("drug_name")
  231. drug_stock_limit := this.GetString("drug_stock_limit")
  232. price, _ := this.GetInt64("price")
  233. prices := strconv.FormatInt(price, 10)
  234. durg_price, _ := strconv.ParseFloat(prices, 64)
  235. drug_spec := this.GetString("drug_spec")
  236. unit := this.GetString("unit")
  237. drug_name_id, _ := this.GetInt64("drug_name_id")
  238. drug_id, _ := this.GetInt64("drug_id")
  239. RullerName := models.XtStandName{
  240. DrugName: drug_name,
  241. DrugStockLimit: drug_stock_limit,
  242. Price: durg_price,
  243. DrugSpec: drug_spec,
  244. MinUnit: unit,
  245. DrugNameId: drug_name_id,
  246. DrugId: drug_id,
  247. }
  248. _, errcode := service.GetIsExit(drug_name, drug_spec, id)
  249. if errcode == gorm.ErrRecordNotFound {
  250. err := service.UpdatedRullerName(id, &RullerName)
  251. if err != nil {
  252. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  253. return
  254. }
  255. this.ServeSuccessJSON(map[string]interface{}{
  256. "RullerName": RullerName,
  257. })
  258. } else if errcode == nil {
  259. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  260. return
  261. }
  262. }
  263. func (this *SelfDrugApiController) GetAllDrugNameList() {
  264. adminUserInfo := this.GetAdminUserInfo()
  265. orgId := adminUserInfo.CurrentOrgId
  266. rullerName, err := service.GetAllDrugNameList(orgId)
  267. list, err := service.GetMedicalDrugNameList(orgId)
  268. if err != nil {
  269. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  270. return
  271. }
  272. this.ServeSuccessJSON(map[string]interface{}{
  273. "rullerName": rullerName,
  274. "list": list,
  275. })
  276. }
  277. func (this *SelfDrugApiController) GetRullerListByDrugName() {
  278. id := this.GetString("id")
  279. adminUserInfo := this.GetAdminUserInfo()
  280. orgId := adminUserInfo.CurrentOrgId
  281. fmt.Println("orgid", orgId)
  282. drugName, err := service.GetRullerListByDrugName(id, orgId)
  283. if err != nil {
  284. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  285. return
  286. }
  287. this.ServeSuccessJSON(map[string]interface{}{
  288. "drugName": drugName,
  289. })
  290. }
  291. func (this *SelfDrugApiController) SaveSelfMedicines() {
  292. dataBody := make(map[string]interface{}, 0)
  293. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  294. fmt.Println(err)
  295. patient_id := int64(dataBody["patient_id"].(float64))
  296. medicineData, _ := dataBody["medicineData"].([]interface{})
  297. adminUserInfo := this.GetAdminUserInfo()
  298. orgId := adminUserInfo.CurrentOrgId
  299. for _, item := range medicineData {
  300. items := item.(map[string]interface{})
  301. drug_name := items["drug_name"].(string)
  302. drug_name_id := int64(items["drug_name_id"].(float64))
  303. drug_spec := items["drug_spec"].(string)
  304. min_unit := items["min_unit"].(string)
  305. drug_id := int64(items["drug_id"].(float64))
  306. //根据drug_id
  307. drugMedical, _ := service.GetBaseDrugMedical(drug_name_id)
  308. medical := models.XtSelfMedical{
  309. DrugName: drug_name,
  310. DrugNameId: drug_name_id,
  311. DrugSpec: drug_spec,
  312. CreatedTime: time.Now().Unix(),
  313. Status: 1,
  314. UserOrgId: orgId,
  315. PatientId: patient_id,
  316. MinUnit: min_unit,
  317. ExecutionFrequency: drugMedical.ExecutionFrequency,
  318. PrescribingNumber: drugMedical.PrescribingNumber,
  319. DeliveryWay: drugMedical.DeliveryWay,
  320. SingleDose: drugMedical.SingleDose,
  321. DrugId: drug_id,
  322. }
  323. //查询同个病人同个药品同个规格是否已存在
  324. _, errcode := service.GetSelfMedicalByDrugName(drug_name, drug_spec, patient_id)
  325. if errcode == gorm.ErrRecordNotFound {
  326. err := service.CreateSelfMedical(&medical)
  327. fmt.Println(err)
  328. } else if errcode == nil {
  329. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  330. return
  331. }
  332. }
  333. returnData := make(map[string]interface{}, 0)
  334. returnData["msg"] = "ok"
  335. this.ServeSuccessJSON(returnData)
  336. return
  337. }
  338. func (this *SelfDrugApiController) GetCurrentOrgAllStaff() {
  339. adminUserInfo := this.GetAdminUserInfo()
  340. orgid := adminUserInfo.CurrentOrgId
  341. //fmt.Println(orgid)
  342. appId := adminUserInfo.CurrentAppId
  343. staff, err := service.GetCurrentOrgAllStaff(orgid, appId)
  344. if err != nil {
  345. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  346. return
  347. }
  348. this.ServeSuccessJSON(map[string]interface{}{
  349. "staff": staff,
  350. })
  351. }
  352. func (this *SelfDrugApiController) SaveStock() {
  353. timeLayout := "2006-01-02"
  354. loc, _ := time.LoadLocation("Local")
  355. start_time := this.GetString("start_time")
  356. fmt.Println("start_time", start_time)
  357. admin_user_id, _ := this.GetInt64("admin_user_id")
  358. fmt.Println("admin_user_id", admin_user_id)
  359. patient_id, _ := this.GetInt64("patient_id")
  360. dataBody := make(map[string]interface{}, 0)
  361. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  362. fmt.Println(err)
  363. stocks, _ := dataBody["stocks"].([]interface{})
  364. adminUserInfo := this.GetAdminUserInfo()
  365. orgId := adminUserInfo.CurrentOrgId
  366. for _, item := range stocks {
  367. items := item.(map[string]interface{})
  368. drug_name := items["drug_name"].(string)
  369. fmt.Println("drug_name", drug_name)
  370. drug_name_id := int64(items["drug_name_id"].(float64))
  371. fmt.Println("parient_id", drug_name_id)
  372. drug_spec := items["drug_spec"].(string)
  373. store_number := items["store_number"].(string)
  374. fmt.Println("store_number", store_number)
  375. storeNumber, _ := strconv.ParseInt(store_number, 10, 64)
  376. remarks := items["remarks"].(string)
  377. min_unit := items["min_unit"].(string)
  378. medic_id := int64(items["id"].(float64))
  379. timeStr := time.Now().Format("2006-01-02")
  380. timeArr := strings.Split(timeStr, "-")
  381. total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
  382. total = total + 1
  383. warehousing_in_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  384. number, _ := strconv.ParseInt(warehousing_in_order, 10, 64)
  385. number = number + total
  386. warehousing_in_order = "RKD" + strconv.FormatInt(number, 10)
  387. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  388. stock := models.XtSelfStock{
  389. DrugName: drug_name,
  390. DrugNameId: drug_name_id,
  391. DrugSpec: drug_spec,
  392. StoreNumber: storeNumber,
  393. Remarks: remarks,
  394. AdminUserId: admin_user_id,
  395. StorckTime: theTime.Unix(),
  396. CreatedTime: time.Now().Unix(),
  397. Status: 1,
  398. UserOrgId: orgId,
  399. StockInNumber: warehousing_in_order,
  400. PatientId: patient_id,
  401. MinUnit: min_unit,
  402. StorageMode: 1,
  403. MedicId: medic_id,
  404. }
  405. err := service.CreateStock(&stock)
  406. fmt.Println("err", err)
  407. }
  408. returnData := make(map[string]interface{}, 0)
  409. returnData["msg"] = "ok"
  410. this.ServeSuccessJSON(returnData)
  411. return
  412. }
  413. func (this *SelfDrugApiController) SaveOutStock() {
  414. timeLayout := "2006-01-02"
  415. loc, _ := time.LoadLocation("Local")
  416. start_time := this.GetString("start_time")
  417. admin_user_id, _ := this.GetInt64("admin_user_id")
  418. patient_id, _ := this.GetInt64("patient_id")
  419. dataBody := make(map[string]interface{}, 0)
  420. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  421. fmt.Println(err)
  422. outStocks, _ := dataBody["outStocks"].([]interface{})
  423. adminUserInfo := this.GetAdminUserInfo()
  424. orgId := adminUserInfo.CurrentOrgId
  425. for _, item := range outStocks {
  426. items := item.(map[string]interface{})
  427. drug_name := items["drug_name"].(string)
  428. drug_name_id := int64(items["drug_name_id"].(float64))
  429. drug_spec := items["drug_spec"].(string)
  430. outstore_number := items["outstore_number"].(string)
  431. outStoreNumber, _ := strconv.ParseInt(outstore_number, 10, 64)
  432. remarks := items["remarks"].(string)
  433. medic_id := int64(items["id"].(float64))
  434. timeStr := time.Now().Format("2006-01-02")
  435. timeArr := strings.Split(timeStr, "-")
  436. total, _ := service.FindAllWarehouseOut(adminUserInfo.CurrentOrgId)
  437. total = total + 1
  438. warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  439. number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
  440. number = number + total
  441. warehousing_out_order = "CKD" + strconv.FormatInt(number, 10)
  442. fmt.Println(remarks)
  443. fmt.Println(items)
  444. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  445. stock := models.XtSelfOutStock{
  446. DrugName: drug_name,
  447. DrugNameId: drug_name_id,
  448. DrugSpec: drug_spec,
  449. OutstoreNumber: outStoreNumber,
  450. Remarks: remarks,
  451. AdminUserId: admin_user_id,
  452. StorckTime: theTime.Unix(),
  453. CreatedTime: time.Now().Unix(),
  454. Status: 1,
  455. UserOrgId: orgId,
  456. StockOutNumber: warehousing_out_order,
  457. PatientId: patient_id,
  458. ExitMode: 1,
  459. MedicId: medic_id,
  460. }
  461. err := service.CreateOutStock(&stock)
  462. fmt.Println("err", err)
  463. }
  464. returnData := make(map[string]interface{}, 0)
  465. returnData["msg"] = "ok"
  466. this.ServeSuccessJSON(returnData)
  467. return
  468. }
  469. func (this *SelfDrugApiController) DeleteDrugById() {
  470. id, _ := this.GetInt64("id")
  471. drug_name := this.GetString("drug_name")
  472. adminUserInfo := this.GetAdminUserInfo()
  473. orgId := adminUserInfo.CurrentOrgId
  474. _, errcode := service.GetStandDrugByDrugName(drug_name, orgId)
  475. if errcode == gorm.ErrRecordNotFound {
  476. service.DeleteDrugName(id)
  477. returnData := make(map[string]interface{}, 0)
  478. returnData["msg"] = "ok"
  479. this.ServeSuccessJSON(returnData)
  480. } else if errcode == nil {
  481. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  482. return
  483. }
  484. }
  485. func (this *SelfDrugApiController) SaveRadio() {
  486. radio, _ := this.GetInt64("radio")
  487. adminUserInfo := this.GetAdminUserInfo()
  488. orgId := adminUserInfo.CurrentOrgId
  489. drugSet := models.XtDrugSet{
  490. DrugStart: radio,
  491. UserOrgId: orgId,
  492. Status: 1,
  493. CreatedTime: time.Now().Unix(),
  494. }
  495. _, errcode := service.GetDrugSetByUserOrgId(orgId)
  496. if errcode == gorm.ErrRecordNotFound {
  497. err := service.SaveRadio(&drugSet)
  498. if err != nil {
  499. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  500. return
  501. }
  502. this.ServeSuccessJSON(map[string]interface{}{
  503. "drugSet": drugSet,
  504. })
  505. } else if errcode == nil {
  506. err := service.UpdateDrugSet(&drugSet, orgId)
  507. if err != nil {
  508. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  509. return
  510. }
  511. this.ServeSuccessJSON(map[string]interface{}{
  512. "drugSet": drugSet,
  513. })
  514. }
  515. }
  516. func (this *SelfDrugApiController) DeleteDrugStand() {
  517. id, _ := this.GetInt64("id")
  518. name := this.GetString("name")
  519. adminUserInfo := this.GetAdminUserInfo()
  520. orgId := adminUserInfo.CurrentOrgId
  521. _, errcode := service.GetMedicalsByName(orgId, name)
  522. if errcode == gorm.ErrRecordNotFound {
  523. err := service.DeleteDrugStand(id)
  524. fmt.Println(err)
  525. returnData := make(map[string]interface{}, 0)
  526. returnData["msg"] = "ok"
  527. this.ServeSuccessJSON(returnData)
  528. } else if errcode == nil {
  529. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  530. return
  531. }
  532. }
  533. func (this *SelfDrugApiController) GetStockList() {
  534. patientid, _ := this.GetInt64("id")
  535. start_time := this.GetString("start_time")
  536. fmt.Println("开始时间", start_time)
  537. timeLayout := "2006-01-02"
  538. loc, _ := time.LoadLocation("Local")
  539. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  540. startimeUnix := theTime.Unix()
  541. keyword := this.GetString("keyword")
  542. fmt.Println("keyword", keyword)
  543. adminUserInfo := this.GetAdminUserInfo()
  544. orgId := adminUserInfo.CurrentOrgId
  545. //获取
  546. medicalList, _ := service.GetMedicalList(patientid, orgId, keyword)
  547. //统计总数量
  548. stocklist, err := service.GetStockList(patientid, startimeUnix, keyword, orgId)
  549. //统计出库数量
  550. outStocklist, err := service.GetOutStockList(patientid, startimeUnix, keyword, orgId)
  551. //统计该病人时间段内出库条数
  552. outList, err := service.GetTotalOutStockList(patientid, startimeUnix, keyword, orgId)
  553. if err != nil {
  554. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  555. return
  556. }
  557. this.ServeSuccessJSON(map[string]interface{}{
  558. "medicalList": medicalList,
  559. "stocklist": stocklist,
  560. "outStocklist": outStocklist,
  561. "outList": outList,
  562. })
  563. }
  564. func (this *SelfDrugApiController) DeleteDrugName() {
  565. drug_name := this.GetString("drugname")
  566. patient_id, _ := this.GetInt64("patientid")
  567. //查询该药品是否出库
  568. stocklist, _ := service.GetStockOutDetail(drug_name, patient_id)
  569. if len(stocklist) == 0 {
  570. //删除该药品
  571. service.DeleteDrugStockNumber(drug_name, patient_id)
  572. returnData := make(map[string]interface{}, 0)
  573. returnData["msg"] = "ok"
  574. this.ServeSuccessJSON(returnData)
  575. } else {
  576. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  577. return
  578. }
  579. }
  580. func (this *SelfDrugApiController) GetDrugDetail() {
  581. timeLayout := "2006-01-02"
  582. loc, _ := time.LoadLocation("Local")
  583. drug_name := this.GetString("drug_name")
  584. drug_spec := this.GetString("drug_spec")
  585. start_time := this.GetString("start_time")
  586. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  587. end_time := this.GetString("end_time")
  588. endTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  589. patient_id, _ := this.GetInt64("patient_id")
  590. adminUserInfo := this.GetAdminUserInfo()
  591. orgId := adminUserInfo.CurrentOrgId
  592. //查询入库明细
  593. stockDetail, err := service.GetStockDetail(drug_name, drug_spec, startTime.Unix(), endTime.Unix(), patient_id, orgId)
  594. //查询出库明细
  595. outStockDetail, err := service.GetOutStockDetail(drug_name, drug_spec, startTime.Unix(), endTime.Unix(), patient_id, orgId)
  596. if err != nil {
  597. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  598. return
  599. }
  600. this.ServeSuccessJSON(map[string]interface{}{
  601. "stockDetail": stockDetail,
  602. "outStockDetail": outStockDetail,
  603. })
  604. }
  605. func (this *SelfDrugApiController) GetAllPatientStockList() {
  606. timeLayout := "2006-01-02"
  607. loc, _ := time.LoadLocation("Local")
  608. drug_name := this.GetString("drug_name")
  609. drug_spec := this.GetString("drug_spec")
  610. start_time := this.GetString("start_time")
  611. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  612. startUnix := theTime.Unix()
  613. end_time := this.GetString("end_time")
  614. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  615. endTimeUnix := endTimes.Unix()
  616. keywords := this.GetString("search_input")
  617. adminUserInfo := this.GetAdminUserInfo()
  618. orgId := adminUserInfo.CurrentOrgId
  619. //入库
  620. stocklist, err := service.GetAllPatientStockList(drug_name, drug_spec, startUnix, endTimeUnix, keywords, orgId)
  621. //出库
  622. outStockList, err := service.GetAllPatientOutStockList(drug_name, drug_spec, startUnix, endTimeUnix, keywords, orgId)
  623. if err != nil {
  624. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  625. return
  626. }
  627. this.ServeSuccessJSON(map[string]interface{}{
  628. "stocklist": stocklist,
  629. "outStockList": outStockList,
  630. })
  631. }
  632. func (this *SelfDrugApiController) GetDrugDataByPatientId() {
  633. patient_id, _ := this.GetInt64("patient_id")
  634. fmt.Println("patient_id", patient_id)
  635. medicalList, err := service.GetDrugDataByPatientId(patient_id)
  636. if err != nil {
  637. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  638. return
  639. }
  640. this.ServeSuccessJSON(map[string]interface{}{
  641. "medicalList": medicalList,
  642. })
  643. }
  644. func (this *SelfDrugApiController) GetSelfMedicalList() {
  645. patient_id, _ := this.GetInt64("patient_id")
  646. adminUserInfo := this.GetAdminUserInfo()
  647. orgId := adminUserInfo.CurrentOrgId
  648. _, drugStockConfig := service.FindDrugStockAutomaticReduceRecordByOrgId(orgId)
  649. privateDrugConfig, _ := service.GetDrugSetByUserOrgId(orgId)
  650. drugList, _ := service.GetAllBaseDrugLibList(orgId)
  651. privateDrugList, _ := service.GetPrivateDrugList(patient_id, orgId)
  652. this.ServeSuccessJSON(map[string]interface{}{
  653. "base_drug_config": drugStockConfig,
  654. "private_drug_config": privateDrugConfig,
  655. "base_drug_list": drugList,
  656. "private_drug_list": privateDrugList,
  657. })
  658. ////查询是否开启药品库
  659. //config, _ := service.GetDruckStockConfig(orgId)
  660. //
  661. //fmt.Println("--------------------------",config.IsOpen)
  662. ////开启
  663. //if config.IsOpen == 1 {
  664. // //查询该机构下的药品库
  665. // drugName, _ := service.GetAllDrugName(orgId)
  666. //
  667. // //查询该机构是否开启自备药
  668. // medical, _ := service.GetSetSelfMedical(orgId)
  669. // fmt.Println("medical+++++++++++++++++",medical.DrugStart)
  670. // //开启
  671. // if medical.DrugStart == 1 {
  672. // list, err := service.GetSelfMedicalList(patient_id)
  673. // if err != nil {
  674. // this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  675. // return
  676. // }
  677. // this.ServeSuccessJSON(map[string]interface{}{
  678. // "medicalList": list,
  679. // "drugName": drugName,
  680. // })
  681. // } else {
  682. // this.ServeSuccessJSON(map[string]interface{}{
  683. // "drugName": drugName,
  684. // })
  685. // }
  686. //}
  687. }
  688. func (this *SelfDrugApiController) GetDrugDescByDrugName() {
  689. drug_name := this.GetString("drug_name")
  690. patient_id, _ := this.GetInt64("patient_id")
  691. way, _ := this.GetInt64("way")
  692. adminUserInfo := this.GetAdminUserInfo()
  693. orgId := adminUserInfo.CurrentOrgId
  694. drug_id, _ := this.GetInt64("id")
  695. //从基础库查询
  696. if way == 1 {
  697. //查询基础库数据
  698. medcal, err := service.GetBaseMedcal(drug_name, orgId)
  699. //统计入库数量
  700. countInfo, err := service.GetTotalBaseMedicalCount(drug_id, orgId)
  701. //统计出库数量
  702. countout, err := service.GetTotalBaseMedicalCountOut(drug_id, orgId)
  703. if err != nil {
  704. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  705. return
  706. }
  707. this.ServeSuccessJSON(map[string]interface{}{
  708. "drugspec": medcal,
  709. "countInfo": countInfo,
  710. "countout": countout,
  711. })
  712. }
  713. //从自备药库查询
  714. if way == 2 {
  715. drugspec, err := service.GetDrugDescByDrugName(drug_name, patient_id, orgId)
  716. if err != nil {
  717. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  718. return
  719. }
  720. this.ServeSuccessJSON(map[string]interface{}{
  721. "drugspec": drugspec,
  722. })
  723. }
  724. }
  725. func (this *SelfDrugApiController) GetDrugSet() {
  726. adminUserInfo := this.GetAdminUserInfo()
  727. orgId := adminUserInfo.CurrentOrgId
  728. drugSet, err := service.GetDrugSet(orgId)
  729. if err != nil {
  730. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  731. return
  732. }
  733. this.ServeSuccessJSON(map[string]interface{}{
  734. "drugSet": drugSet,
  735. })
  736. }
  737. func (this *SelfDrugApiController) GetAllMedicalList() {
  738. adminUserInfo := this.GetAdminUserInfo()
  739. orgId := adminUserInfo.CurrentOrgId
  740. list, err := service.GetAllMedicalList(orgId)
  741. if err != nil {
  742. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  743. return
  744. }
  745. this.ServeSuccessJSON(map[string]interface{}{
  746. "drugName": list,
  747. })
  748. }
  749. func (this *SelfDrugApiController) GetStandName() {
  750. name := this.GetString("name")
  751. adminUserInfo := this.GetAdminUserInfo()
  752. orgId := adminUserInfo.CurrentOrgId
  753. rullerlist, err := service.GetRulleName(orgId, name)
  754. if err != nil {
  755. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  756. return
  757. }
  758. this.ServeSuccessJSON(map[string]interface{}{
  759. "rullerlist": rullerlist,
  760. })
  761. }
  762. func (this *SelfDrugApiController) GetRullerList() {
  763. id, _ := this.GetInt64("id")
  764. adminUserInfo := this.GetAdminUserInfo()
  765. orgId := adminUserInfo.CurrentOrgId
  766. rullerList, err := service.GetRulleList(orgId, id)
  767. if err != nil {
  768. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  769. return
  770. }
  771. this.ServeSuccessJSON(map[string]interface{}{
  772. "rullerlist": rullerList,
  773. })
  774. }
  775. func (this *SelfDrugApiController) DeleteDrugNameById() {
  776. id, _ := this.GetInt64("id")
  777. drug_name := this.GetString("drug_name")
  778. adminUserInfo := this.GetAdminUserInfo()
  779. orgId := adminUserInfo.CurrentOrgId
  780. _, errcode := service.GetStandDrugByDrugName(drug_name, orgId)
  781. if errcode == gorm.ErrRecordNotFound {
  782. service.DeleteDrugNameById(id)
  783. returnData := make(map[string]interface{}, 0)
  784. returnData["msg"] = "ok"
  785. this.ServeSuccessJSON(returnData)
  786. } else if errcode == nil {
  787. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodePatientNoExist)
  788. return
  789. }
  790. }
  791. func (this *SelfDrugApiController) GetPatientDetail() {
  792. id, _ := this.GetInt64("id")
  793. adminUserInfo := this.GetAdminUserInfo()
  794. patientDetail, err := service.GetPatientDetail(id, adminUserInfo.CurrentOrgId)
  795. if err != nil {
  796. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  797. return
  798. }
  799. this.ServeSuccessJSON(map[string]interface{}{
  800. "patientDetail": patientDetail,
  801. })
  802. }
  803. //func (this *SelfDrugApiController) ToPatientDetail() {
  804. //
  805. // keyword := this.GetString("keyword")
  806. // adminUser := this.GetAdminUserInfo()
  807. // orgId := adminUser.CurrentOrgId
  808. // patient, err := service.ToSeachPatient(keyword, orgId)
  809. // if err != nil {
  810. // this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  811. // return
  812. // }
  813. // this.ServeSuccessJSON(map[string]interface{}{
  814. // "patient": patient,
  815. // })
  816. //}
  817. func (this *SelfDrugApiController) GetSelfStockQuery() {
  818. adminUserInfo := this.GetAdminUserInfo()
  819. orgId := adminUserInfo.CurrentOrgId
  820. type_name, _ := this.GetInt64("type_name")
  821. keywords := this.GetString("keywords")
  822. timeLayout := "2006-01-02"
  823. loc, _ := time.LoadLocation("Local")
  824. start_time := this.GetString("start_time")
  825. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  826. startUnix := theTime.Unix()
  827. end_time := this.GetString("end_time")
  828. endTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  829. endTimeUnix := endTimes.Unix()
  830. page, _ := this.GetInt64("page")
  831. limit, _ := this.GetInt64("limit")
  832. //统计入库数量
  833. stockQuery, total, err := service.GetSelfStockQuery(type_name, keywords, startUnix, endTimeUnix, orgId, limit, page)
  834. //统计出库数量
  835. stockOutQuery, err := service.GetSelfOutStockQuery(startUnix, endTimeUnix, orgId)
  836. if err != nil {
  837. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  838. return
  839. }
  840. this.ServeSuccessJSON(map[string]interface{}{
  841. "stockQuery": stockQuery,
  842. "total": total,
  843. "stockOutQuery": stockOutQuery,
  844. })
  845. }
  846. func (this *SelfDrugApiController) PostSearchDrugWarehouseList() {
  847. keyword := this.GetString("keyword")
  848. orgId := this.GetAdminUserInfo().CurrentOrgId
  849. list, err := service.PostSearchDrugWarehouseList(keyword, orgId)
  850. manufacturerList, err := service.GetAllManufacturerList(orgId)
  851. dealerList, err := service.GetAllDealerList(orgId)
  852. if err != nil {
  853. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  854. return
  855. }
  856. this.ServeSuccessJSON(map[string]interface{}{
  857. "list": list,
  858. "manufacturerList": manufacturerList,
  859. "dealerList": dealerList,
  860. })
  861. }
  862. func (this *SelfDrugApiController) SaveDrugPrice() {
  863. timeLayout := "2006-01-02"
  864. loc, _ := time.LoadLocation("Local")
  865. dataBody := make(map[string]interface{}, 0)
  866. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  867. fmt.Println(err)
  868. tableData, _ := dataBody["tableData"].([]interface{})
  869. fmt.Println("999939433443", tableData)
  870. if len(tableData) > 0 {
  871. for _, item := range tableData {
  872. items := item.(map[string]interface{})
  873. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  874. utils.ErrorLog("drug_name")
  875. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  876. return
  877. }
  878. drug_name := items["drug_name"].(string)
  879. fmt.Println("drug_aname23232323232", drug_name)
  880. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  881. utils.ErrorLog("drug_name")
  882. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  883. return
  884. }
  885. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  886. utils.ErrorLog("retail_price")
  887. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  888. return
  889. }
  890. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  891. if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
  892. utils.ErrorLog("warehousing_order")
  893. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  894. return
  895. }
  896. warehousing_order := items["warehousing_order"].(string)
  897. if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
  898. utils.ErrorLog("number")
  899. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  900. return
  901. }
  902. number := items["number"].(string)
  903. if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
  904. utils.ErrorLog("dealer")
  905. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  906. return
  907. }
  908. dealer := items["dealer"].(string)
  909. if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
  910. utils.ErrorLog("manufacturer")
  911. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  912. return
  913. }
  914. manufacturer := items["manufacturer"].(string)
  915. if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
  916. utils.ErrorLog("specification_name")
  917. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  918. return
  919. }
  920. specification_name := items["specification_name"].(string)
  921. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  922. utils.ErrorLog("remark")
  923. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  924. return
  925. }
  926. remark := items["remark"].(string)
  927. if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
  928. utils.ErrorLog("warehousing_unit")
  929. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  930. return
  931. }
  932. warehousing_unit := items["warehousing_unit"].(string)
  933. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  934. utils.ErrorLog("last_price")
  935. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  936. return
  937. }
  938. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  939. if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
  940. utils.ErrorLog("new_price")
  941. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  942. return
  943. }
  944. new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
  945. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  946. utils.ErrorLog("drug_id")
  947. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  948. return
  949. }
  950. drug_id := int64(items["drug_id"].(float64))
  951. if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
  952. utils.ErrorLog("start_time")
  953. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  954. return
  955. }
  956. var startTime int64
  957. start_time := items["start_time"].(string)
  958. if len(start_time) > 0 {
  959. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  960. if err != nil {
  961. fmt.Println(err)
  962. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  963. return
  964. }
  965. startTime = theTime.Unix()
  966. }
  967. orgId := this.GetAdminUserInfo().CurrentOrgId
  968. Creater := this.GetAdminUserInfo().AdminUser.Id
  969. drugAdjust := models.XtDrugAdjustPrice{
  970. DrugName: drug_name,
  971. SpecificationName: specification_name,
  972. WarehousingUnit: warehousing_unit,
  973. LastPrice: last_price,
  974. RetailPrice: retail_price,
  975. NewPrice: new_price,
  976. Manufacturer: manufacturer,
  977. Dealer: dealer,
  978. Remark: remark,
  979. DrugId: drug_id,
  980. UserOrgId: orgId,
  981. Ctime: time.Now().Unix(),
  982. Mtime: 0,
  983. Status: 1,
  984. WarehousingOrder: warehousing_order,
  985. Number: number,
  986. StartTime: startTime,
  987. Creater: Creater,
  988. Checker: 0,
  989. CheckerStatus: 2,
  990. CheckerTime: 0,
  991. }
  992. err := service.CreateDrugPrice(drugAdjust)
  993. fmt.Println(err)
  994. }
  995. }
  996. returnData := make(map[string]interface{}, 0)
  997. returnData["msg"] = "ok"
  998. this.ServeSuccessJSON(returnData)
  999. return
  1000. }
  1001. func (this *SelfDrugApiController) GetDrugPriceList() {
  1002. timeLayout := "2006-01-02"
  1003. loc, _ := time.LoadLocation("Local")
  1004. dataBody := make(map[string]interface{}, 0)
  1005. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1006. fmt.Println(err)
  1007. orgId := this.GetAdminUserInfo().CurrentOrgId
  1008. keyword := this.GetString("keyword")
  1009. start_time := this.GetString("start_time")
  1010. end_time := this.GetString("end_time")
  1011. var startTime int64
  1012. if len(start_time) > 0 {
  1013. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1014. if err != nil {
  1015. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1016. return
  1017. }
  1018. startTime = theTime.Unix()
  1019. }
  1020. var endTime int64
  1021. if len(end_time) > 0 {
  1022. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1023. if err != nil {
  1024. utils.ErrorLog(err.Error())
  1025. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1026. return
  1027. }
  1028. endTime = theTime.Unix()
  1029. }
  1030. limit, _ := this.GetInt64("limit")
  1031. page, _ := this.GetInt64("page")
  1032. list, total, err := service.GetDrugPriceList(startTime, endTime, orgId, keyword, limit, page)
  1033. doctorList, err := service.GetAllDoctorThree(orgId)
  1034. if err != nil {
  1035. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1036. return
  1037. }
  1038. this.ServeSuccessJSON(map[string]interface{}{
  1039. "total": total,
  1040. "list": list,
  1041. "doctorList": doctorList,
  1042. })
  1043. }
  1044. func (this *SelfDrugApiController) SaveCheckDrugPrice() {
  1045. timeLayout := "2006-01-02"
  1046. loc, _ := time.LoadLocation("Local")
  1047. dataBody := make(map[string]interface{}, 0)
  1048. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1049. fmt.Println(err)
  1050. idstr := this.GetString("ids")
  1051. ids := strings.Split(idstr, ",")
  1052. check_time := this.GetString("check_time")
  1053. var checkTime int64
  1054. if len(check_time) > 0 {
  1055. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
  1056. if err != nil {
  1057. fmt.Println(err)
  1058. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1059. return
  1060. }
  1061. checkTime = theTime.Unix()
  1062. }
  1063. checker, _ := this.GetInt64("checker")
  1064. adjustPrice := models.XtDrugAdjustPrice{
  1065. Checker: checker,
  1066. CheckerStatus: 1,
  1067. CheckerTime: checkTime,
  1068. }
  1069. err = service.UpdateDrugAdjuestPrice(ids, adjustPrice)
  1070. fmt.Println("err", err)
  1071. list, _ := service.GetDrugAdjuestPrice(ids)
  1072. for _, item := range list {
  1073. drug := models.BaseDrugLib{
  1074. RetailPrice: item.NewPrice,
  1075. LastPrice: item.NewPrice,
  1076. }
  1077. service.UpdateBaseDrugOne(drug, item.DrugId)
  1078. }
  1079. this.ServeSuccessJSON(map[string]interface{}{
  1080. "adjustPrice": adjustPrice,
  1081. })
  1082. }
  1083. func (this *SelfDrugApiController) SaveDrugDamage() {
  1084. timeLayout := "2006-01-02"
  1085. loc, _ := time.LoadLocation("Local")
  1086. dataBody := make(map[string]interface{}, 0)
  1087. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1088. fmt.Println(err)
  1089. tableData, _ := dataBody["tableData"].([]interface{})
  1090. fmt.Println("999939433443", tableData)
  1091. if len(tableData) > 0 {
  1092. for _, item := range tableData {
  1093. items := item.(map[string]interface{})
  1094. drug_name := items["drug_name"].(string)
  1095. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  1096. utils.ErrorLog("drug_name")
  1097. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1098. return
  1099. }
  1100. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  1101. utils.ErrorLog("retail_price")
  1102. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1103. return
  1104. }
  1105. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  1106. if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
  1107. utils.ErrorLog("warehousing_order")
  1108. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1109. return
  1110. }
  1111. warehousing_order := items["warehousing_order"].(string)
  1112. if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
  1113. utils.ErrorLog("number")
  1114. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1115. return
  1116. }
  1117. number := items["number"].(string)
  1118. if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
  1119. utils.ErrorLog("dealer")
  1120. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1121. return
  1122. }
  1123. dealer := items["dealer"].(string)
  1124. if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
  1125. utils.ErrorLog("manufacturer")
  1126. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1127. return
  1128. }
  1129. manufacturer := items["manufacturer"].(string)
  1130. if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
  1131. utils.ErrorLog("specification_name")
  1132. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1133. return
  1134. }
  1135. specification_name := items["specification_name"].(string)
  1136. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  1137. utils.ErrorLog("remark")
  1138. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1139. return
  1140. }
  1141. remark := items["remark"].(string)
  1142. if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
  1143. utils.ErrorLog("warehousing_unit")
  1144. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1145. return
  1146. }
  1147. warehousing_unit := items["warehousing_unit"].(string)
  1148. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  1149. utils.ErrorLog("last_price")
  1150. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1151. return
  1152. }
  1153. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  1154. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
  1155. utils.ErrorLog("count")
  1156. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1157. return
  1158. }
  1159. count := int64(items["count"].(float64))
  1160. if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
  1161. utils.ErrorLog("new_price")
  1162. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1163. return
  1164. }
  1165. new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
  1166. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  1167. utils.ErrorLog("drug_id")
  1168. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1169. return
  1170. }
  1171. drug_id := int64(items["drug_id"].(float64))
  1172. if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
  1173. utils.ErrorLog("start_time")
  1174. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1175. return
  1176. }
  1177. var startTime int64
  1178. start_time := items["start_time"].(string)
  1179. if len(start_time) > 0 {
  1180. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1181. if err != nil {
  1182. fmt.Println(err)
  1183. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1184. return
  1185. }
  1186. startTime = theTime.Unix()
  1187. }
  1188. if items["warehousing_info_id"] == nil || reflect.TypeOf(items["warehousing_info_id"]).String() != "float64" {
  1189. utils.ErrorLog("warehousing_info_id")
  1190. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1191. return
  1192. }
  1193. warehousing_info_id := int64(items["warehousing_info_id"].(float64))
  1194. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
  1195. utils.ErrorLog("expiry_date")
  1196. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1197. return
  1198. }
  1199. expiry_date := int64(items["expiry_date"].(float64))
  1200. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
  1201. utils.ErrorLog("product_date")
  1202. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1203. return
  1204. }
  1205. product_date := int64(items["product_date"].(float64))
  1206. if items["drug_origin_place"] == nil || reflect.TypeOf(items["drug_origin_place"]).String() != "string" {
  1207. utils.ErrorLog("drug_origin_place")
  1208. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1209. return
  1210. }
  1211. drug_origin_place := items["drug_origin_place"].(string)
  1212. orgId := this.GetAdminUserInfo().CurrentOrgId
  1213. Creater := this.GetAdminUserInfo().AdminUser.Id
  1214. if items["stock_max_number"] == nil || reflect.TypeOf(items["stock_max_number"]).String() != "float64" {
  1215. utils.ErrorLog("stock_max_number")
  1216. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1217. return
  1218. }
  1219. stock_max_number := int64(items["stock_max_number"].(float64))
  1220. if items["stock_min_number"] == nil || reflect.TypeOf(items["stock_min_number"]).String() != "float64" {
  1221. utils.ErrorLog("stock_min_number")
  1222. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1223. return
  1224. }
  1225. stock_min_number := int64(items["stock_min_number"].(float64))
  1226. if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "string" {
  1227. utils.ErrorLog("total")
  1228. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1229. return
  1230. }
  1231. total := items["total"].(string)
  1232. drugDamage := models.XtDrugDamage{
  1233. DrugName: drug_name,
  1234. SpecificationName: specification_name,
  1235. WarehousingUnit: warehousing_unit,
  1236. Count: count,
  1237. LastPrice: last_price,
  1238. RetailPrice: retail_price,
  1239. NewPrice: new_price,
  1240. Manufacturer: manufacturer,
  1241. Dealer: dealer,
  1242. Remark: remark,
  1243. DrugId: drug_id,
  1244. UserOrgId: orgId,
  1245. Ctime: time.Now().Unix(),
  1246. Mtime: 0,
  1247. Status: 1,
  1248. WarehousingOrder: warehousing_order,
  1249. Number: number,
  1250. StartTime: startTime,
  1251. Creater: Creater,
  1252. Checker: 0,
  1253. CheckerStatus: 2,
  1254. CheckerTime: 0,
  1255. ExpiryDate: expiry_date,
  1256. ProductDate: product_date,
  1257. WarehousingInfoId: warehousing_info_id,
  1258. DrugOriginPlace: drug_origin_place,
  1259. StockMaxNumber: stock_max_number,
  1260. StockMinNumber: stock_min_number,
  1261. Total: total,
  1262. }
  1263. err := service.CreateDrugDamage(drugDamage)
  1264. fmt.Println(err)
  1265. }
  1266. }
  1267. returnData := make(map[string]interface{}, 0)
  1268. returnData["msg"] = "ok"
  1269. this.ServeSuccessJSON(returnData)
  1270. }
  1271. func (this *SelfDrugApiController) GetDrugDamageList() {
  1272. timeLayout := "2006-01-02"
  1273. loc, _ := time.LoadLocation("Local")
  1274. dataBody := make(map[string]interface{}, 0)
  1275. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1276. fmt.Println(err)
  1277. orgId := this.GetAdminUserInfo().CurrentOrgId
  1278. keyword := this.GetString("keyword")
  1279. start_time := this.GetString("start_time")
  1280. end_time := this.GetString("end_time")
  1281. var startTime int64
  1282. if len(start_time) > 0 {
  1283. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1284. if err != nil {
  1285. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1286. return
  1287. }
  1288. startTime = theTime.Unix()
  1289. }
  1290. var endTime int64
  1291. if len(end_time) > 0 {
  1292. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1293. if err != nil {
  1294. utils.ErrorLog(err.Error())
  1295. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1296. return
  1297. }
  1298. endTime = theTime.Unix()
  1299. }
  1300. limit, _ := this.GetInt64("limit")
  1301. page, _ := this.GetInt64("page")
  1302. list, total, err := service.GetDrugDamageList(startTime, endTime, orgId, keyword, limit, page)
  1303. damagelist, _ := service.GetDrugDamageByOrgId(orgId)
  1304. doctorList, err := service.GetAllDoctorThree(orgId)
  1305. if err != nil {
  1306. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1307. return
  1308. }
  1309. this.ServeSuccessJSON(map[string]interface{}{
  1310. "total": total,
  1311. "list": list,
  1312. "damagelist": damagelist,
  1313. "doctorList": doctorList,
  1314. })
  1315. }
  1316. func (this *SelfDrugApiController) SaveDrugDamagePrice() {
  1317. timeLayout := "2006-01-02"
  1318. loc, _ := time.LoadLocation("Local")
  1319. dataBody := make(map[string]interface{}, 0)
  1320. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1321. fmt.Println(err)
  1322. idstr := this.GetString("ids")
  1323. ids := strings.Split(idstr, ",")
  1324. check_time := this.GetString("check_time")
  1325. var checkTime int64
  1326. if len(check_time) > 0 {
  1327. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
  1328. if err != nil {
  1329. fmt.Println(err)
  1330. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1331. return
  1332. }
  1333. checkTime = theTime.Unix()
  1334. }
  1335. checker, _ := this.GetInt64("checker")
  1336. damage := models.XtDrugDamage{
  1337. Checker: checker,
  1338. CheckerStatus: 1,
  1339. CheckerTime: checkTime,
  1340. }
  1341. err = service.UpdateDrugDamage(ids, damage)
  1342. fmt.Println(err)
  1343. list, _ := service.GetDrugDamage(ids)
  1344. ctime := time.Now().Unix()
  1345. adminUserInfo := this.GetAdminUserInfo()
  1346. manufacturerList, _ := service.GetAllManufacturerList(adminUserInfo.CurrentOrgId)
  1347. dealerList, _ := service.GetAllDealerList(adminUserInfo.CurrentOrgId)
  1348. var manufacturer_id int64
  1349. var dealer_id int64
  1350. timeStr := time.Now().Format("2006-01-02")
  1351. timeArr := strings.Split(timeStr, "-")
  1352. total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
  1353. total = total + 1
  1354. warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  1355. number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
  1356. number = number + total
  1357. warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
  1358. operation_time := time.Now().Unix()
  1359. creater := adminUserInfo.AdminUser.Id
  1360. warehouseOut := models.DrugWarehouseOut{
  1361. WarehouseOutOrderNumber: warehousing_out_order,
  1362. OperationTime: operation_time,
  1363. OrgId: adminUserInfo.CurrentOrgId,
  1364. Creater: creater,
  1365. Ctime: ctime,
  1366. Status: 1,
  1367. WarehouseOutTime: time.Now().Unix(),
  1368. Type: 1,
  1369. }
  1370. service.AddSigleDrugWarehouseOut(&warehouseOut)
  1371. for _, item := range list {
  1372. for _, it := range manufacturerList {
  1373. if item.Manufacturer == it.ManufacturerName {
  1374. manufacturer_id = it.ID
  1375. }
  1376. }
  1377. for _, its := range dealerList {
  1378. if its.DealerName == item.Dealer {
  1379. dealer_id = its.ID
  1380. }
  1381. }
  1382. warehouseOutInfo := models.XtDrugWarehouseOutInfo{
  1383. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1384. WarehouseOutId: warehouseOut.ID,
  1385. DrugId: item.DrugId,
  1386. Count: item.Count,
  1387. Price: item.RetailPrice,
  1388. Status: 1,
  1389. Ctime: ctime,
  1390. Remark: item.Remark,
  1391. OrgId: adminUserInfo.CurrentOrgId,
  1392. Type: 1,
  1393. Manufacturer: manufacturer_id,
  1394. Dealer: dealer_id,
  1395. RetailPrice: item.RetailPrice,
  1396. CountUnit: item.WarehousingUnit,
  1397. ExpiryDate: item.ExpiryDate,
  1398. ProductDate: item.ProductDate,
  1399. Number: item.Number,
  1400. BatchNumber: item.BatchNumber,
  1401. IsSys: 0,
  1402. WarehouseInfoId: item.WarehousingInfoId,
  1403. }
  1404. drugflow := models.DrugFlow{
  1405. WarehouseOutId: warehouseOut.ID,
  1406. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1407. DrugId: item.DrugId,
  1408. Number: item.Number,
  1409. ProductDate: item.ProductDate,
  1410. ExpireDate: item.ExpiryDate,
  1411. Count: item.Count,
  1412. Price: item.RetailPrice,
  1413. Status: 1,
  1414. Ctime: ctime,
  1415. UserOrgId: adminUserInfo.CurrentOrgId,
  1416. Manufacturer: manufacturer_id,
  1417. Dealer: dealer_id,
  1418. BatchNumber: item.BatchNumber,
  1419. MaxUnit: item.WarehousingUnit,
  1420. ConsumableType: 5,
  1421. IsEdit: 1,
  1422. Creator: adminUserInfo.AdminUser.Id,
  1423. IsSys: 0,
  1424. }
  1425. service.CreateWareHouseOutInfo(&warehouseOutInfo)
  1426. service.CreateDrugFlowOne(drugflow)
  1427. info, _ := service.GetDrugByWarehouseInfo(item.WarehousingInfoId)
  1428. //扣减库存
  1429. warehouseInfo := models.XtDrugWarehouseInfo{
  1430. StockMaxNumber: info.StockMaxNumber - info.StockMaxNumber,
  1431. }
  1432. service.UpdateDrugWarehouseingInfo(item.WarehousingInfoId, warehouseInfo)
  1433. }
  1434. this.ServeSuccessJSON(map[string]interface{}{
  1435. "damage": damage,
  1436. })
  1437. }
  1438. func (this *SelfDrugApiController) GetDrugModifyPrice() {
  1439. id, _ := this.GetInt64("id")
  1440. detail, err := service.GetDrugModifyPrice(id)
  1441. fmt.Println(err)
  1442. this.ServeSuccessJSON(map[string]interface{}{
  1443. "detail": detail,
  1444. })
  1445. }
  1446. func (this *SelfDrugApiController) ModifyDrugPrice() {
  1447. drug_name := this.GetString("drug_name")
  1448. specification_name := this.GetString("specification_name")
  1449. warehousing_unit := this.GetString("warehousing_unit")
  1450. manufacturer := this.GetString("manufacturer")
  1451. number := this.GetString("number")
  1452. retailPrice := this.GetString("retail_price")
  1453. retail_price, _ := strconv.ParseFloat(retailPrice, 64)
  1454. newPrice := this.GetString("new_price")
  1455. new_price, _ := strconv.ParseFloat(newPrice, 64)
  1456. count, _ := this.GetInt64("count")
  1457. remark := this.GetString("remark")
  1458. id, _ := this.GetInt64("id")
  1459. drug_id, _ := this.GetInt64("drug_id")
  1460. adjustPrice := models.XtDrugAdjustPrice{
  1461. DrugName: drug_name,
  1462. Count: count,
  1463. RetailPrice: retail_price,
  1464. NewPrice: new_price,
  1465. Remark: remark,
  1466. SpecificationName: specification_name,
  1467. WarehousingUnit: warehousing_unit,
  1468. Manufacturer: manufacturer,
  1469. Number: number,
  1470. DrugId: drug_id,
  1471. }
  1472. err := service.ModifyDrugPrice(id, adjustPrice)
  1473. fmt.Println(err)
  1474. this.ServeSuccessJSON(map[string]interface{}{
  1475. "adjustPrice": adjustPrice,
  1476. })
  1477. }
  1478. func (this *SelfDrugApiController) GetModifyPricePrint() {
  1479. ids := this.GetString("ids")
  1480. idsSplit := strings.Split(ids, ",")
  1481. list, err := service.GetModifyPricePrint(idsSplit)
  1482. fmt.Println(err)
  1483. this.ServeSuccessJSON(map[string]interface{}{
  1484. "list": list,
  1485. })
  1486. }
  1487. func (this *SelfDrugApiController) GetDrugDamageDetail() {
  1488. id, _ := this.GetInt64("id")
  1489. detail, _ := service.GetDrugDamageDetail(id)
  1490. this.ServeSuccessJSON(map[string]interface{}{
  1491. "detail": detail,
  1492. })
  1493. }
  1494. func (this *SelfDrugApiController) ModifyDrugDamage() {
  1495. id, _ := this.GetInt64("id")
  1496. drug_id, _ := this.GetInt64("drug_id")
  1497. drug_name := this.GetString("drug_name")
  1498. drug_origin_place := this.GetString("drug_origin_place")
  1499. lastPrice := this.GetString("last_price")
  1500. last_price, _ := strconv.ParseFloat(lastPrice, 64)
  1501. newPrice := this.GetString("new_price")
  1502. new_price, _ := strconv.ParseFloat(newPrice, 64)
  1503. manufacturer := this.GetString("manufacturer")
  1504. number := this.GetString("number")
  1505. retailPrice := this.GetString("retail_price")
  1506. retail_price, _ := strconv.ParseFloat(retailPrice, 64)
  1507. remark := this.GetString("remark")
  1508. count, _ := this.GetInt64("count")
  1509. warehousing_unit := this.GetString("warehousing_unit")
  1510. stock_max_number, _ := this.GetInt64("stock_max_number")
  1511. stock_min_number, _ := this.GetInt64("stock_min_number")
  1512. warehousing_info_id, _ := this.GetInt64("warehousing_info_id")
  1513. damage := models.XtDrugDamage{
  1514. DrugName: drug_name,
  1515. SpecificationName: "",
  1516. WarehousingUnit: warehousing_unit,
  1517. Count: count,
  1518. LastPrice: last_price,
  1519. RetailPrice: retail_price,
  1520. NewPrice: new_price,
  1521. Manufacturer: manufacturer,
  1522. Dealer: "",
  1523. Remark: remark,
  1524. DrugId: drug_id,
  1525. Number: number,
  1526. StockMaxNumber: stock_max_number,
  1527. StockMinNumber: stock_min_number,
  1528. WarehousingInfoId: warehousing_info_id,
  1529. DrugOriginPlace: drug_origin_place,
  1530. }
  1531. err := service.ModifyDrugDamage(id, damage)
  1532. fmt.Println(err)
  1533. this.ServeSuccessJSON(map[string]interface{}{
  1534. "damage": damage,
  1535. })
  1536. }
  1537. func (this *SelfDrugApiController) DeleteDrugDamage() {
  1538. id, _ := this.GetInt64("id")
  1539. err := service.DeleteDrugDamage(id)
  1540. fmt.Println(err)
  1541. returnData := make(map[string]interface{}, 0)
  1542. returnData["msg"] = "ok"
  1543. this.ServeSuccessJSON(returnData)
  1544. }
  1545. func (this *SelfDrugApiController) GetDrugDamagePrint() {
  1546. idsSplit := this.GetString("ids")
  1547. ids := strings.Split(idsSplit, ",")
  1548. list, _ := service.GetDrugDamagePrint(ids)
  1549. this.ServeSuccessJSON(map[string]interface{}{
  1550. "list": list,
  1551. })
  1552. }
  1553. func (this *SelfDrugApiController) GetWarehoseInfoById() {
  1554. id, _ := this.GetInt64("id")
  1555. list, _ := service.GetWarehoseInfoById(id)
  1556. this.ServeSuccessJSON(map[string]interface{}{
  1557. "list": list,
  1558. })
  1559. }
  1560. func (this *SelfDrugApiController) SaveDrugInventory() {
  1561. timeLayout := "2006-01-02"
  1562. loc, _ := time.LoadLocation("Local")
  1563. dataBody := make(map[string]interface{}, 0)
  1564. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1565. fmt.Println(err)
  1566. tableData, _ := dataBody["tableData"].([]interface{})
  1567. fmt.Println("999939433443", tableData)
  1568. if len(tableData) > 0 {
  1569. for _, item := range tableData {
  1570. items := item.(map[string]interface{})
  1571. drug_name := items["drug_name"].(string)
  1572. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  1573. utils.ErrorLog("drug_name")
  1574. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1575. return
  1576. }
  1577. if items["retail_price"] == nil || reflect.TypeOf(items["retail_price"]).String() != "string" {
  1578. utils.ErrorLog("retail_price")
  1579. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1580. return
  1581. }
  1582. retail_price, _ := strconv.ParseFloat(items["retail_price"].(string), 64)
  1583. if items["warehousing_order"] == nil || reflect.TypeOf(items["warehousing_order"]).String() != "string" {
  1584. utils.ErrorLog("warehousing_order")
  1585. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1586. return
  1587. }
  1588. warehousing_order := items["warehousing_order"].(string)
  1589. if items["dealer"] == nil || reflect.TypeOf(items["dealer"]).String() != "string" {
  1590. utils.ErrorLog("dealer")
  1591. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1592. return
  1593. }
  1594. dealer := items["dealer"].(string)
  1595. if items["manufacturer"] == nil || reflect.TypeOf(items["manufacturer"]).String() != "string" {
  1596. utils.ErrorLog("manufacturer")
  1597. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1598. return
  1599. }
  1600. manufacturer := items["manufacturer"].(string)
  1601. if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
  1602. utils.ErrorLog("specification_name")
  1603. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1604. return
  1605. }
  1606. specification_name := items["specification_name"].(string)
  1607. if items["remark"] == nil || reflect.TypeOf(items["remark"]).String() != "string" {
  1608. utils.ErrorLog("remark")
  1609. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1610. return
  1611. }
  1612. remark := items["remark"].(string)
  1613. if items["warehousing_unit"] == nil || reflect.TypeOf(items["warehousing_unit"]).String() != "string" {
  1614. utils.ErrorLog("warehousing_unit")
  1615. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1616. return
  1617. }
  1618. warehousing_unit := items["warehousing_unit"].(string)
  1619. if items["last_price"] == nil || reflect.TypeOf(items["last_price"]).String() != "string" {
  1620. utils.ErrorLog("last_price")
  1621. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1622. return
  1623. }
  1624. last_price, _ := strconv.ParseFloat(items["last_price"].(string), 64)
  1625. if items["count"] == nil || reflect.TypeOf(items["count"]).String() != "float64" {
  1626. utils.ErrorLog("count")
  1627. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1628. return
  1629. }
  1630. count := int64(items["count"].(float64))
  1631. if items["new_price"] == nil || reflect.TypeOf(items["new_price"]).String() != "string" {
  1632. utils.ErrorLog("new_price")
  1633. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1634. return
  1635. }
  1636. new_price, _ := strconv.ParseFloat(items["new_price"].(string), 64)
  1637. if items["drug_id"] == nil || reflect.TypeOf(items["drug_id"]).String() != "float64" {
  1638. utils.ErrorLog("drug_id")
  1639. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1640. return
  1641. }
  1642. drug_id := int64(items["drug_id"].(float64))
  1643. if items["start_time"] == nil || reflect.TypeOf(items["start_time"]).String() != "string" {
  1644. utils.ErrorLog("start_time")
  1645. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1646. return
  1647. }
  1648. var startTime int64
  1649. start_time := items["start_time"].(string)
  1650. if len(start_time) > 0 {
  1651. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1652. if err != nil {
  1653. fmt.Println(err)
  1654. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1655. return
  1656. }
  1657. startTime = theTime.Unix()
  1658. }
  1659. if items["product_date"] == nil || reflect.TypeOf(items["product_date"]).String() != "float64" {
  1660. utils.ErrorLog("product_date")
  1661. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1662. return
  1663. }
  1664. product_date := int64(items["product_date"].(float64))
  1665. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
  1666. utils.ErrorLog("expiry_date")
  1667. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1668. return
  1669. }
  1670. expiry_date := int64(items["expiry_date"].(float64))
  1671. orgId := this.GetAdminUserInfo().CurrentOrgId
  1672. Creater := this.GetAdminUserInfo().AdminUser.Id
  1673. if items["number"] == nil || reflect.TypeOf(items["number"]).String() != "string" {
  1674. utils.ErrorLog("number")
  1675. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1676. return
  1677. }
  1678. numbers := items["number"].(string)
  1679. if items["warehouse_info_id"] == nil || reflect.TypeOf(items["warehouse_info_id"]).String() != "float64" {
  1680. utils.ErrorLog("warehouse_info_id")
  1681. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1682. return
  1683. }
  1684. warehouse_info_id := int64(items["warehouse_info_id"].(float64))
  1685. if items["total"] == nil || reflect.TypeOf(items["total"]).String() != "string" {
  1686. utils.ErrorLog("total")
  1687. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1688. return
  1689. }
  1690. total := items["total"].(string)
  1691. drug_origin_place := items["drug_origin_place"].(string)
  1692. min_count := int64(items["min_count"].(float64))
  1693. min_unit := items["min_unit"].(string)
  1694. inventory := models.XtDrugInventory{
  1695. DrugName: drug_name,
  1696. SpecificationName: specification_name,
  1697. WarehousingUnit: warehousing_unit,
  1698. Count: count,
  1699. LastPrice: last_price,
  1700. RetailPrice: retail_price,
  1701. NewPrice: new_price,
  1702. Manufacturer: manufacturer,
  1703. Dealer: dealer,
  1704. Remark: remark,
  1705. DrugId: drug_id,
  1706. UserOrgId: orgId,
  1707. Ctime: time.Now().Unix(),
  1708. Mtime: 0,
  1709. Status: 1,
  1710. WarehousingOrder: warehousing_order,
  1711. LicenseNumber: "",
  1712. StartTime: startTime,
  1713. Creater: Creater,
  1714. Checker: 0,
  1715. CheckerStatus: 2,
  1716. CheckerTime: 0,
  1717. ExpiryDate: expiry_date,
  1718. ProductDate: product_date,
  1719. Number: numbers,
  1720. //BatchNumber: batch_number,
  1721. Total: total,
  1722. WarehouseInfoId: warehouse_info_id,
  1723. DrugOriginPlace: drug_origin_place,
  1724. MinUnit: min_unit,
  1725. MinCount: min_count,
  1726. }
  1727. err = service.CreateDrugInventory(inventory)
  1728. fmt.Println(err)
  1729. }
  1730. }
  1731. this.ServeSuccessJSON(map[string]interface{}{
  1732. "msg": "msg",
  1733. })
  1734. }
  1735. func (this *SelfDrugApiController) GetDrugInventoryList() {
  1736. timeLayout := "2006-01-02"
  1737. loc, _ := time.LoadLocation("Local")
  1738. dataBody := make(map[string]interface{}, 0)
  1739. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1740. fmt.Println(err)
  1741. orgId := this.GetAdminUserInfo().CurrentOrgId
  1742. keyword := this.GetString("keyword")
  1743. start_time := this.GetString("start_time")
  1744. end_time := this.GetString("end_time")
  1745. var startTime int64
  1746. if len(start_time) > 0 {
  1747. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  1748. if err != nil {
  1749. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1750. return
  1751. }
  1752. startTime = theTime.Unix()
  1753. }
  1754. var endTime int64
  1755. if len(end_time) > 0 {
  1756. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  1757. if err != nil {
  1758. utils.ErrorLog(err.Error())
  1759. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1760. return
  1761. }
  1762. endTime = theTime.Unix()
  1763. }
  1764. limit, _ := this.GetInt64("limit")
  1765. page, _ := this.GetInt64("page")
  1766. list, total, err := service.GetDrugInventoryList(keyword, page, limit, orgId, startTime, endTime)
  1767. fmt.Println("list23232323223", list)
  1768. doctorList, _ := service.GetAllDoctorThree(orgId)
  1769. if err != nil {
  1770. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  1771. return
  1772. }
  1773. this.ServeSuccessJSON(map[string]interface{}{
  1774. "total": total,
  1775. "list": list,
  1776. "doctorList": doctorList,
  1777. })
  1778. }
  1779. func (this *SelfDrugApiController) SaveDrugCheckInventory() {
  1780. timeLayout := "2006-01-02"
  1781. loc, _ := time.LoadLocation("Local")
  1782. dataBody := make(map[string]interface{}, 0)
  1783. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1784. fmt.Println(err)
  1785. idstr := this.GetString("ids")
  1786. ids := strings.Split(idstr, ",")
  1787. check_time := this.GetString("check_time")
  1788. var checkTime int64
  1789. if len(check_time) > 0 {
  1790. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", check_time+" 00:00:00", loc)
  1791. if err != nil {
  1792. fmt.Println(err)
  1793. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  1794. return
  1795. }
  1796. checkTime = theTime.Unix()
  1797. }
  1798. checker, _ := this.GetInt64("checker")
  1799. inventory := models.XtDrugInventory{
  1800. Checker: checker,
  1801. CheckerStatus: 1,
  1802. CheckerTime: checkTime,
  1803. }
  1804. err = service.UpdateDrugInventory(ids, inventory)
  1805. fmt.Println(err)
  1806. list, _ := service.GetDrugInventoryListByIds(ids)
  1807. adminUserInfo := this.GetAdminUserInfo()
  1808. var stock_total int64
  1809. var proof_count int64
  1810. var maxNumber int64
  1811. var minNumber int64
  1812. for _, item := range list {
  1813. //查询药品信息
  1814. drug, _ := service.GetDrugDetailByDrugId(item.DrugId)
  1815. //查询库存
  1816. info, _ := service.GetDrugWareInfoByIdTwo(item.WarehouseInfoId)
  1817. var max_count int64
  1818. var min_count int64
  1819. for _, it := range info {
  1820. max_count += it.StockMaxNumber
  1821. min_count += it.StockMinNumber
  1822. }
  1823. //获取最晚的库存数量
  1824. lastInfo, _ := service.GetLastDrugWarehouseInfo(item.DrugId)
  1825. firstInfo, _ := service.GetFirstDrugWarehouseInfo(item.DrugId)
  1826. stock_total = max_count*drug.MinNumber + min_count
  1827. proof_count = item.Count*drug.MinNumber + item.MinCount
  1828. fmt.Println("stock_total", stock_total)
  1829. fmt.Println("proof_count", proof_count)
  1830. //判断 如果库存数量 大于盘点库存,则出库
  1831. if stock_total > proof_count {
  1832. minNumber = (stock_total - proof_count) % drug.MinNumber
  1833. maxNumber = (stock_total - proof_count) / drug.MinNumber
  1834. ctime := time.Now().Unix()
  1835. timeStr := time.Now().Format("2006-01-02")
  1836. timeArr := strings.Split(timeStr, "-")
  1837. total, _ := service.FindAllDrugWarehouseOut(adminUserInfo.CurrentOrgId)
  1838. total = total + 1
  1839. warehousing_out_order := strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000"
  1840. number, _ := strconv.ParseInt(warehousing_out_order, 10, 64)
  1841. number = number + total
  1842. warehousing_out_order = "YPCKD" + strconv.FormatInt(number, 10)
  1843. operation_time := time.Now().Unix()
  1844. creater := adminUserInfo.AdminUser.Id
  1845. warehouseOut := models.DrugWarehouseOut{
  1846. WarehouseOutOrderNumber: warehousing_out_order,
  1847. OperationTime: operation_time,
  1848. OrgId: adminUserInfo.CurrentOrgId,
  1849. Creater: creater,
  1850. Ctime: ctime,
  1851. Status: 1,
  1852. WarehouseOutTime: ctime,
  1853. Type: 1,
  1854. }
  1855. service.AddSigleDrugWarehouseOut(&warehouseOut)
  1856. warehouse, _ := service.GetLastDrugWarehouseOut(adminUserInfo.CurrentOrgId)
  1857. warehouseOutInfo := models.DrugWarehouseOutInfo{
  1858. WarehouseOutOrderNumber: warehouseOut.WarehouseOutOrderNumber,
  1859. WarehouseOutId: warehouse.ID,
  1860. DrugId: item.DrugId,
  1861. Count: maxNumber,
  1862. Price: firstInfo.Price,
  1863. TotalPrice: firstInfo.TotalPrice,
  1864. Status: 1,
  1865. Ctime: ctime,
  1866. Remark: item.Remark,
  1867. OrgId: adminUserInfo.CurrentOrgId,
  1868. Type: 1,
  1869. Manufacturer: firstInfo.Manufacturer,
  1870. Dealer: firstInfo.Dealer,
  1871. RetailPrice: firstInfo.RetailPrice,
  1872. RetailTotalPrice: firstInfo.RetailTotalPrice,
  1873. CountUnit: drug.MaxUnit,
  1874. ExpiryDate: firstInfo.ExpiryDate,
  1875. ProductDate: firstInfo.ProductDate,
  1876. Number: firstInfo.Number,
  1877. BatchNumber: firstInfo.BatchNumber,
  1878. IsSys: 0,
  1879. WarehouseInfoId: firstInfo.ID,
  1880. }
  1881. drugflow := models.DrugFlow{
  1882. WarehouseOutId: warehouseOut.ID,
  1883. WarehouseOutOrderNumber: warehousing_out_order,
  1884. DrugId: item.DrugId,
  1885. Number: firstInfo.Number,
  1886. ProductDate: firstInfo.ProductDate,
  1887. ExpireDate: firstInfo.ExpiryDate,
  1888. Count: maxNumber,
  1889. Price: firstInfo.Price,
  1890. Status: 1,
  1891. Ctime: ctime,
  1892. UserOrgId: adminUserInfo.CurrentOrgId,
  1893. Manufacturer: firstInfo.Manufacturer,
  1894. Dealer: firstInfo.Dealer,
  1895. BatchNumber: firstInfo.BatchNumber,
  1896. MaxUnit: drug.MaxUnit,
  1897. ConsumableType: 2,
  1898. IsEdit: 1,
  1899. Creator: adminUserInfo.AdminUser.Id,
  1900. IsSys: 0,
  1901. }
  1902. service.CreateDrugWarehouseOutInfo(warehouseOutInfo)
  1903. service.CreateDrugFlowOne(drugflow)
  1904. //扣减当前批次号的库存
  1905. var total_count int64
  1906. //查询当前批次库存的数量
  1907. warehosueInfoList, _ := service.GetCurrentWarehosueInfo(item.WarehouseInfoId)
  1908. fmt.Println(warehosueInfoList)
  1909. for _, item := range warehosueInfoList {
  1910. total_count += item.StockMaxNumber*drug.MinNumber + item.StockMinNumber
  1911. }
  1912. //判断当前批次库存 和 需要出库的数据
  1913. //出库
  1914. if proof_count <= total_count {
  1915. //var total_count_one int64
  1916. //获取当前批次号的库存
  1917. //warehouseinfoOne, _ := service.GetCurrentWarehosueInfoOne(item.WarehouseInfoId)
  1918. //total_count_one = warehouseinfoOne.StockMaxNumber * drug.MinNumber + warehouseinfoOne.StockMinNumber
  1919. }
  1920. //报错提示
  1921. if proof_count > total_count {
  1922. this.ServeSuccessJSON(map[string]interface{}{
  1923. "msg": "1",
  1924. })
  1925. }
  1926. }
  1927. //判断 如果库存数量 小于于盘点库存,则入库
  1928. fmt.Println("stock_total2332322323223", stock_total, proof_count)
  1929. if stock_total < proof_count {
  1930. maxNumber = (proof_count - stock_total) / drug.MinNumber
  1931. minNumber = (proof_count - stock_total) % drug.MinNumber
  1932. fmt.Println("min_number23233232323223322323", minNumber)
  1933. ctime := time.Now().Unix()
  1934. timeStr := time.Now().Format("2006-01-02")
  1935. timeArr := strings.Split(timeStr, "-")
  1936. total, _ := service.FindAllWarehouseTotalOne(adminUserInfo.CurrentOrgId)
  1937. total = total + 1
  1938. fmt.Println("total2323232323232", total)
  1939. warehousing_order := "YPRKD" + strconv.FormatInt(adminUserInfo.CurrentOrgId, 10) + timeArr[0] + timeArr[1] + timeArr[2] + "000" + strconv.FormatInt(total, 10)
  1940. operation_time := time.Now().Unix()
  1941. creater := adminUserInfo.AdminUser.Id
  1942. warehousing := models.DrugWarehouse{
  1943. WarehousingOrder: warehousing_order,
  1944. OperationTime: operation_time,
  1945. OrgId: adminUserInfo.CurrentOrgId,
  1946. Creater: creater,
  1947. Ctime: ctime,
  1948. Status: 1,
  1949. WarehousingTime: ctime,
  1950. Type: 1,
  1951. }
  1952. service.AddSigleDrugWarehouse(&warehousing)
  1953. warehouse, _ := service.GetLastDrugWarehouse(adminUserInfo.CurrentOrgId)
  1954. warehouseInfo := models.DrugWarehouseInfo{
  1955. WarehousingOrder: warehousing.WarehousingOrder,
  1956. WarehousingId: warehouse.ID,
  1957. DrugId: item.DrugId,
  1958. Number: lastInfo.Number,
  1959. ProductDate: lastInfo.ProductDate,
  1960. ExpiryDate: lastInfo.ExpiryDate,
  1961. WarehousingCount: maxNumber,
  1962. Price: lastInfo.Price,
  1963. TotalPrice: lastInfo.TotalPrice,
  1964. Status: 1,
  1965. Ctime: ctime,
  1966. Remark: item.Remark,
  1967. OrgId: adminUserInfo.CurrentOrgId,
  1968. Type: 1,
  1969. Manufacturer: lastInfo.Manufacturer,
  1970. Dealer: lastInfo.Dealer,
  1971. StockMaxNumber: maxNumber,
  1972. StockMinNumber: minNumber,
  1973. RetailTotalPrice: lastInfo.RetailTotalPrice,
  1974. BatchNumber: lastInfo.BatchNumber,
  1975. MaxUnit: drug.MaxUnit,
  1976. MinUnit: drug.MinUnit,
  1977. WarehousingInfoId: item.WarehouseInfoId,
  1978. }
  1979. drugflow := models.DrugFlow{
  1980. WarehousingOrder: warehousing.WarehousingOrder,
  1981. WarehousingId: warehouse.ID,
  1982. DrugId: item.DrugId,
  1983. Number: lastInfo.Number,
  1984. ProductDate: lastInfo.ProductDate,
  1985. ExpireDate: lastInfo.ExpiryDate,
  1986. Count: maxNumber,
  1987. Price: lastInfo.Price,
  1988. Status: 1,
  1989. Ctime: ctime,
  1990. UserOrgId: adminUserInfo.CurrentOrgId,
  1991. Manufacturer: lastInfo.Manufacturer,
  1992. Dealer: lastInfo.Dealer,
  1993. BatchNumber: lastInfo.BatchNumber,
  1994. MaxUnit: drug.MaxUnit,
  1995. MinUnit: drug.MinUnit,
  1996. ConsumableType: 1,
  1997. IsEdit: 1,
  1998. Creator: adminUserInfo.AdminUser.Id,
  1999. IsSys: 0,
  2000. }
  2001. service.CreateDrugWarehouseInfo(warehouseInfo)
  2002. service.CreateDrugFlowOne(drugflow)
  2003. }
  2004. }
  2005. returnData := make(map[string]interface{}, 0)
  2006. returnData["msg"] = "ok"
  2007. this.ServeSuccessJSON(returnData)
  2008. }
  2009. func (this *SelfDrugApiController) GetDrugInventoryDetail() {
  2010. id, _ := this.GetInt64("id")
  2011. detail, err := service.GetDrugInventoryDetail(id)
  2012. if err != nil {
  2013. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2014. return
  2015. }
  2016. this.ServeSuccessJSON(map[string]interface{}{
  2017. "detail": detail,
  2018. })
  2019. }
  2020. func (this *SelfDrugApiController) ModifyInventory() {
  2021. id, _ := this.GetInt64("id")
  2022. drug_id, _ := this.GetInt64("drug_id")
  2023. drug_name := this.GetString("drug_name")
  2024. specification_name := this.GetString("specification_name")
  2025. retailPrice := this.GetString("retail_price")
  2026. retail_price, _ := strconv.ParseFloat(retailPrice, 64)
  2027. warehousing_order := this.GetString("warehousing_order")
  2028. number := this.GetString("number")
  2029. manufacturer := this.GetString("manufacturer")
  2030. remark := this.GetString("remark")
  2031. warehousing_unit := this.GetString("warehousing_unit")
  2032. total := this.GetString("total")
  2033. lastPrice := this.GetString("last_price")
  2034. last_price, _ := strconv.ParseFloat(lastPrice, 64)
  2035. count, _ := this.GetInt64("count")
  2036. drug_origin_place := this.GetString("drug_origin_place")
  2037. stock_max_number, _ := this.GetInt64("stock_max_number")
  2038. stock_min_number, _ := this.GetInt64("stock_min_number")
  2039. warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
  2040. min_count, _ := this.GetInt64("min_count")
  2041. min_unit := this.GetString("min_unit")
  2042. inventory := models.XtDrugInventory{
  2043. DrugName: drug_name,
  2044. SpecificationName: specification_name,
  2045. WarehousingUnit: warehousing_unit,
  2046. Count: count,
  2047. LastPrice: last_price,
  2048. RetailPrice: retail_price,
  2049. Manufacturer: manufacturer,
  2050. Remark: remark,
  2051. DrugId: drug_id,
  2052. WarehousingOrder: warehousing_order,
  2053. Number: number,
  2054. Total: total,
  2055. DrugOriginPlace: drug_origin_place,
  2056. StockMaxNumber: stock_max_number,
  2057. StockMinNumber: stock_min_number,
  2058. WarehouseInfoId: warehouse_info_id,
  2059. MinCount: min_count,
  2060. MinUnit: min_unit,
  2061. }
  2062. err := service.ModifyDrugInventory(id, inventory)
  2063. if err != nil {
  2064. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2065. return
  2066. }
  2067. this.ServeSuccessJSON(map[string]interface{}{
  2068. "inventory": inventory,
  2069. })
  2070. }
  2071. func (this *SelfDrugApiController) DeleteDrugInventory() {
  2072. id, _ := this.GetInt64("id")
  2073. err := service.DeleteDrugInventory(id)
  2074. fmt.Println(err)
  2075. returnData := make(map[string]interface{}, 0)
  2076. returnData["msg"] = "ok"
  2077. this.ServeSuccessJSON(returnData)
  2078. }
  2079. func (this *SelfDrugApiController) GetDrugInventoryPrintList() {
  2080. ids := this.GetString("ids")
  2081. idssplit := strings.Split(ids, ",")
  2082. list, err := service.GetDrugInventoryPrintList(idssplit)
  2083. if err != nil {
  2084. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2085. return
  2086. }
  2087. this.ServeSuccessJSON(map[string]interface{}{
  2088. "list": list,
  2089. })
  2090. }
  2091. func (this *SelfDrugApiController) GetDrugInventoryDetailList() {
  2092. keyword := this.GetString("keyword")
  2093. limit, _ := this.GetInt64("limit")
  2094. page, _ := this.GetInt64("page")
  2095. orgId := this.GetAdminUserInfo().CurrentOrgId
  2096. list, total, err := service.GetDrugInventoryDetailList(keyword, page, limit, orgId)
  2097. fmt.Println("list23232323223", list)
  2098. doctorList, _ := service.GetAllDoctorThree(orgId)
  2099. if err != nil {
  2100. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2101. return
  2102. }
  2103. this.ServeSuccessJSON(map[string]interface{}{
  2104. "total": total,
  2105. "list": list,
  2106. "doctorList": doctorList,
  2107. })
  2108. }
  2109. func (this *SelfDrugApiController) SaveDrugProofInventory() {
  2110. id, _ := this.GetInt64("id")
  2111. warehouse_info_id, _ := this.GetInt64("warehouse_info_id")
  2112. warehousing_unit := this.GetString("warehousing_unit")
  2113. remark := this.GetString("remark")
  2114. proof_count, _ := this.GetInt64("proof_count")
  2115. inventory := models.XtDrugInventory{
  2116. WarehouseInfoId: warehouse_info_id,
  2117. ProofCount: proof_count,
  2118. WarehousingUnit: warehousing_unit,
  2119. Remark: remark,
  2120. }
  2121. err := service.UpdateDrugProofInventory(id, &inventory)
  2122. info := models.XtDrugWarehouseInfo{
  2123. StockMaxNumber: proof_count,
  2124. }
  2125. service.UpdateDrugWarehouseInfoById(warehouse_info_id, &info)
  2126. if err != nil {
  2127. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2128. return
  2129. }
  2130. this.ServeSuccessJSON(map[string]interface{}{
  2131. "inventory": inventory,
  2132. })
  2133. }
  2134. func (this *StockManagerApiController) GetDrugWarehouseInfoTotal() {
  2135. id, _ := this.GetInt64("id")
  2136. list, _ := service.GetDrugWarehouseInfoTotal(id)
  2137. this.ServeSuccessJSON(map[string]interface{}{
  2138. "list": list,
  2139. })
  2140. }
  2141. //新改造
  2142. func (this *SelfDrugApiController) SaveInventoryList() {
  2143. dataBody := make(map[string]interface{}, 0)
  2144. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2145. fmt.Println(err)
  2146. tableData, _ := dataBody["tableData"].([]interface{})
  2147. if len(tableData) > 0 {
  2148. for _, item := range tableData {
  2149. items := item.(map[string]interface{})
  2150. drug_name := items["drug_name"].(string)
  2151. if items["drug_name"] == nil || reflect.TypeOf(items["drug_name"]).String() != "string" {
  2152. utils.ErrorLog("drug_name")
  2153. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2154. return
  2155. }
  2156. fmt.Println("drug_name", drug_name)
  2157. specification_name := items["specification_name"].(string)
  2158. if items["specification_name"] == nil || reflect.TypeOf(items["specification_name"]).String() != "string" {
  2159. utils.ErrorLog("specification_name")
  2160. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2161. return
  2162. }
  2163. max_unit := items["max_unit"].(string)
  2164. if items["max_unit"] == nil || reflect.TypeOf(items["max_unit"]).String() != "string" {
  2165. utils.ErrorLog("max_unit")
  2166. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2167. return
  2168. }
  2169. min_unit := items["min_unit"].(string)
  2170. if items["min_unit"] == nil || reflect.TypeOf(items["min_unit"]).String() != "string" {
  2171. utils.ErrorLog("min_unit")
  2172. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2173. return
  2174. }
  2175. drug_id := int64(items["drug_id"].(float64))
  2176. min_number := int64(items["min_number"].(float64))
  2177. stock_max_number := int64(items["stock_max_number"].(float64))
  2178. stock_min_number := int64(items["stock_min_number"].(float64))
  2179. last_stock_max_number := int64(items["last_stock_max_number"].(float64))
  2180. last_stock_min_number := int64(items["last_stock_min_number"].(float64))
  2181. warehousing_order := items["warehousing_order"].(string)
  2182. price := items["price"].(float64)
  2183. manufacturer_name := items["manufacturer_name"].(string)
  2184. batch_number := items["batch_number"].(string)
  2185. id := int64(items["id"].(float64))
  2186. orgId := this.GetAdminUserInfo().CurrentOrgId
  2187. type_id := int64(items["type"].(float64))
  2188. if items["expiry_date"] == nil || reflect.TypeOf(items["expiry_date"]).String() != "float64" {
  2189. utils.ErrorLog("expiry_date")
  2190. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  2191. return
  2192. }
  2193. expiry_date := int64(items["expiry_date"].(float64))
  2194. manufacturer := int64(items["manufacturer"].(float64))
  2195. timeLayout := "2006-01-02"
  2196. loc, _ := time.LoadLocation("Local")
  2197. timeNow := time.Now().Format("2006-01-02")
  2198. locationTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", timeNow+" 00:00:00", loc)
  2199. var consumable_type int64
  2200. var consumable_count int64
  2201. var ord_total int64
  2202. var new_total int64
  2203. ord_total = stock_max_number*min_number + stock_min_number
  2204. new_total = last_stock_max_number*min_number + last_stock_min_number
  2205. if ord_total > new_total {
  2206. consumable_type = 11
  2207. consumable_count = ord_total - new_total
  2208. }
  2209. if ord_total < new_total {
  2210. consumable_type = 10
  2211. consumable_count = new_total - ord_total
  2212. }
  2213. fmt.Println("ord_total", ord_total)
  2214. fmt.Println("new_total23323232323223", new_total)
  2215. fmt.Println("consumable_count", consumable_count)
  2216. //改变库存
  2217. info := models.DrugWarehouseInfo{
  2218. DrugId: drug_id,
  2219. StockMaxNumber: last_stock_max_number,
  2220. StockMinNumber: last_stock_min_number,
  2221. }
  2222. err = service.ModifyDrugWarehouseInfo(&info, id)
  2223. inventory := models.XtDrugInventory{
  2224. DrugName: drug_name,
  2225. SpecificationName: specification_name,
  2226. WarehousingUnit: max_unit,
  2227. Count: consumable_count,
  2228. LastPrice: price,
  2229. RetailPrice: 0,
  2230. NewPrice: 0,
  2231. Manufacturer: manufacturer_name,
  2232. Dealer: "",
  2233. Remark: "",
  2234. DrugId: drug_id,
  2235. UserOrgId: orgId,
  2236. Ctime: time.Now().Unix(),
  2237. Mtime: 0,
  2238. Status: 1,
  2239. WarehousingOrder: warehousing_order,
  2240. LicenseNumber: "",
  2241. StartTime: locationTime.Unix(),
  2242. Creater: this.GetAdminUserInfo().AdminUser.Id,
  2243. Checker: 0,
  2244. CheckerStatus: 0,
  2245. CheckerTime: 0,
  2246. ExpiryDate: expiry_date,
  2247. ProductDate: 0,
  2248. Number: "",
  2249. BatchNumber: batch_number,
  2250. Total: "",
  2251. DrugOriginPlace: "",
  2252. WarehouseInfoId: id,
  2253. ProofCount: 0,
  2254. StockMaxNumber: stock_max_number,
  2255. StockMinNumber: stock_min_number,
  2256. MinCount: 0,
  2257. MinUnit: min_unit,
  2258. LastStockMaxNumber: last_stock_max_number,
  2259. LastStockMinNumber: last_stock_min_number,
  2260. InventoryType: consumable_type,
  2261. Type: type_id,
  2262. }
  2263. err = service.CreateDrugInventory(inventory)
  2264. flow := models.DrugFlow{
  2265. WarehousingId: id,
  2266. DrugId: drug_id,
  2267. Number: "",
  2268. BatchNumber: batch_number,
  2269. Count: consumable_count,
  2270. UserOrgId: orgId,
  2271. PatientId: 0,
  2272. SystemTime: locationTime.Unix(),
  2273. ConsumableType: consumable_type,
  2274. IsSys: 1,
  2275. WarehousingOrder: warehousing_order,
  2276. WarehouseOutId: 0,
  2277. WarehouseOutOrderNumber: "",
  2278. IsEdit: 0,
  2279. CancelStockId: 0,
  2280. CancelOrderNumber: "",
  2281. Manufacturer: manufacturer,
  2282. Dealer: 0,
  2283. Creator: this.GetAdminUserInfo().AdminUser.Id,
  2284. UpdateCreator: 0,
  2285. Status: 1,
  2286. Ctime: time.Now().Unix(),
  2287. Mtime: 0,
  2288. Price: price,
  2289. WarehousingDetailId: id,
  2290. WarehouseOutDetailId: 0,
  2291. CancelOutDetailId: 0,
  2292. ExpireDate: expiry_date,
  2293. ProductDate: 0,
  2294. MaxUnit: min_unit,
  2295. MinUnit: min_unit,
  2296. }
  2297. if ord_total != new_total {
  2298. service.CreateDrugFlowOne(flow)
  2299. }
  2300. if err != nil {
  2301. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2302. return
  2303. }
  2304. this.ServeSuccessJSON(map[string]interface{}{
  2305. "inventory": inventory,
  2306. })
  2307. }
  2308. }
  2309. }
  2310. func (this *SelfDrugApiController) GetDamageByDrugId() {
  2311. drug_id, _ := this.GetInt64("drug_id")
  2312. warehousing_order := this.GetString("warehousing_order")
  2313. drug_type, _ := this.GetInt64("type")
  2314. list, err := service.GetDamageByDrugId(drug_id, warehousing_order, drug_type)
  2315. if err != nil {
  2316. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2317. return
  2318. }
  2319. this.ServeSuccessJSON(map[string]interface{}{
  2320. "list": list,
  2321. })
  2322. }
  2323. func (this *SelfDrugApiController) GetInventoryModeList() {
  2324. orgId := this.GetAdminUserInfo().CurrentOrgId
  2325. list, err := service.GetInventoryModeList(orgId)
  2326. manufacturerList, err := service.GetAllManufacturerList(orgId)
  2327. if err != nil {
  2328. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  2329. return
  2330. }
  2331. this.ServeSuccessJSON(map[string]interface{}{
  2332. "list": list,
  2333. "manufacturerList": manufacturerList,
  2334. })
  2335. }