manage_api_controller.go 108KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133
  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. "strconv"
  12. "time"
  13. "unsafe"
  14. )
  15. type MachineApiController struct {
  16. BaseAuthAPIController
  17. }
  18. func ManageRouters() {
  19. beego.Router("/api/management/savemanageinfo", &MachineApiController{}, "post:SaveManageInfo")
  20. beego.Router("/api/management/updatemachineinfo", &MachineApiController{}, "post:UpdateMachineInfo")
  21. beego.Router("/api/manage/updatemacheinettwo", &MachineApiController{}, "post:Updatemacheinetwo")
  22. beego.Router("/api/management/getallequimentname", &MachineApiController{}, "get:GetAllEquimentName")
  23. beego.Router("/api/management/saveplan", &MachineApiController{}, "post:SavePlan")
  24. beego.Router("/api/management/getallplan", &MachineApiController{}, "get:GetAllPlan")
  25. beego.Router("/api/management/getallplandetail", &MachineApiController{}, "get:GetAllPlanDetail")
  26. beego.Router("/api/management/geteditmachine", &MachineApiController{}, "get:GetEditMahchine")
  27. beego.Router("/api/staff/deleteplans", &MachineApiController{}, "delete:DeletePlans")
  28. beego.Router("/api/manage/editplandetail", &MachineApiController{}, "get:EditPlanDetail")
  29. beego.Router("/api/manage/updateplaninfo", &MachineApiController{}, "post:UpdatePlanInfo")
  30. beego.Router("/api/manage/getcomprehensive", &MachineApiController{}, "get:GetComprehensive")
  31. beego.Router("/api/manage/saveinformation", &MachineApiController{}, "Post:SaveInformation")
  32. beego.Router("/api/manage/getpatientinfo", &MachineApiController{}, "Get:GetPatientInfo")
  33. beego.Router("/api/manage/changeclass", &MachineApiController{}, "Get:GetPatient")
  34. beego.Router("/api/manage/changepatient", &MachineApiController{}, "Get:ChangePatient")
  35. beego.Router("/api/manage/getallorganization", &MachineApiController{}, "Get:GetAllOrganization")
  36. beego.Router("/api/manage/getregisterinfo", &MachineApiController{}, "Get:GetRegisterInfo")
  37. beego.Router("/api/manage/getinformationdata", &MachineApiController{}, "Get:GetInformationData")
  38. beego.Router("/api/manage/getorgname", &MachineApiController{}, "Get:GetOrgName")
  39. beego.Router("/api/manage/savebacteria", &MachineApiController{}, "Post:SaveBacteria")
  40. beego.Router("/api/manage/savelincomycin", &MachineApiController{}, "Post:SaveLinconmycin")
  41. beego.Router("/api/manage/savequalitycontrol", &MachineApiController{}, "Post:SaveQualityControl")
  42. beego.Router("/api/manage/getallqulityinfo", &MachineApiController{}, "Get:GetAllQulityInfo")
  43. beego.Router("/api/manage/editculture", &MachineApiController{}, "Get:EditCulture")
  44. beego.Router("/api/manage/updateculture", &MachineApiController{}, "Post:UpdateCulture")
  45. beego.Router("/api/manage/deletecultrue", &MachineApiController{}, "delete:DeleteCultrue")
  46. beego.Router("/api/manage/editdialystate", &MachineApiController{}, "Get:EditDialystate")
  47. beego.Router("/api/manage/updatedialystate", &MachineApiController{}, "Post:Updatedialystate")
  48. beego.Router("/api/manage/deletedialystate", &MachineApiController{}, "delete:DeleteDialystate")
  49. beego.Router("/api/manage/edition", &MachineApiController{}, "Get:Edition")
  50. beego.Router("/api/manage/updateion", &MachineApiController{}, "Post:UpdateIon")
  51. beego.Router("/api/manage/deleteion", &MachineApiController{}, "delete:DeleteIon")
  52. beego.Router("/api/manage/query", &MachineApiController{}, "Get:GetQuery")
  53. beego.Router("/api/manage/saverepair", &MachineApiController{}, "Post:SaveRepair")
  54. beego.Router("/api/manage/getallrepair", &MachineApiController{}, "Get:GetAllRepair")
  55. beego.Router("/api/manage/editrepair", &MachineApiController{}, "Get:EditRepair")
  56. beego.Router("/api/manage/updaterepair", &MachineApiController{}, "Post:UpdateRepair")
  57. beego.Router("/api/manage/deleterepair", &MachineApiController{}, "delete:DeleteRepair")
  58. beego.Router("/api/manage/queryrepair", &MachineApiController{}, "Get:GetRepair")
  59. beego.Router("/api/manage/edituser", &MachineApiController{}, "Get:EditUser")
  60. beego.Router("/api/manage/deleteform", &MachineApiController{}, "delete:DeleteForm")
  61. beego.Router("/api/manage/updateform", &MachineApiController{}, "Post:UpdateForm")
  62. beego.Router("/api/manage/queryinfo", &MachineApiController{}, "Get:QueryInfo")
  63. beego.Router("/api/manage/insertautodata", &MachineApiController{}, "Get:InsertAutoData")
  64. beego.Router("/api/manage/getallequittype", &MachineApiController{}, "Get:GetAllEquitType")
  65. beego.Router("/api/manage/getuserform", &MachineApiController{}, "Get:GetUserForm")
  66. beego.Router("/api/manage/getbedform", &MachineApiController{}, "Get:GetBedForm")
  67. beego.Router("/api/manage/gettotalcount", &MachineApiController{}, "Get:GetTotalCount")
  68. beego.Router("/api/manage/getotalnumber", &MachineApiController{}, "Get:GetTotalNumber")
  69. beego.Router("/api/manage/gettimewarning", &MachineApiController{}, "Get:GetTimeWarning")
  70. beego.Router("/api/manage/savemanageinfotwo", &MachineApiController{}, "post:SaveManageinfoTwo")
  71. beego.Router("/api/management/updatemachineinfotwo", &MachineApiController{}, "post:UpdateMachinetwo")
  72. beego.Router("/api/manage/getallpatient", &MachineApiController{}, "get:GetAllpatient")
  73. beego.Router("/api/manage/changebed", &MachineApiController{}, "get:ChangeBed")
  74. beego.Router("/api/manage/getpatientdetail", &MachineApiController{}, "get:GetPatientDetail")
  75. beego.Router("/api/manage/changrun", &MachineApiController{}, "post:SaveReminder")
  76. beego.Router("/api/manage/getremanderdata", &MachineApiController{}, "get:GetRemanderData")
  77. beego.Router("/api/manage/opendelete", &MachineApiController{}, "delete:OpenDelete")
  78. beego.Router("/api/manage/deleteuserlogin", &MachineApiController{}, "delete:DeleteUserLogin")
  79. beego.Router("/api/manage/deletecultrues", &MachineApiController{}, "delete:DeleteCultrues")
  80. beego.Router("/api/manage/deletedialystates", &MachineApiController{}, "delete:DeleteDialystates")
  81. beego.Router("/api/manage/deleteions", &MachineApiController{}, "delete:Deleteions")
  82. beego.Router("/api/manage/deleterepairs", &MachineApiController{}, "delete:DeleteRepairs")
  83. beego.Router("/api/manage/savemode", &MachineApiController{}, "post:SaveMode")
  84. beego.Router("/api/manage/getallmode", &MachineApiController{}, "get:GetAllMode")
  85. beego.Router("/api/manage/editmode", &MachineApiController{}, "get:EditMode")
  86. beego.Router("/api/manage/updatemode", &MachineApiController{}, "post:UpdateMode")
  87. beego.Router("/api/manage/deletemode", &MachineApiController{}, "delete:DeleteMode")
  88. beego.Router("/api/manage/selectchange", &MachineApiController{}, "Get:SelectChange")
  89. beego.Router("/api/manage/selectbed", &MachineApiController{}, "get:SelectBed")
  90. beego.Router("/api/manage/getime", &MachineApiController{}, "get:GetTimeData")
  91. beego.Router("/api/manage/deleteimages", &MachineApiController{}, "delete:DeleteImages")
  92. beego.Router("/api/manage/getusermachtotalcount", &MachineApiController{}, "Get:GetUserMachTotalCount")
  93. beego.Router("/api/manage/getusertotalcount", &MachineApiController{}, "Get:GetUserTotalCount")
  94. beego.Router("/api/manage/deletemanagement", &MachineApiController{}, "Get:DeleteManagement")
  95. }
  96. func (this *MachineApiController) SaveManageInfo() {
  97. adminUserInfo := this.GetAdminUserInfo()
  98. orgid := adminUserInfo.CurrentOrgId
  99. //fmt.Println("机构id", orgid)
  100. dataBody := make(map[string]interface{}, 0)
  101. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  102. //fmt.Println("err", err)
  103. //serial_numbe := int64(dataBody["serial_number"].(float64))
  104. serial_numbe := dataBody["serial_number"].(string)
  105. //fmt.Println("序列号", serial_numbe)
  106. device_type := int64(dataBody["device_type"].(float64))
  107. //fmt.Println("设备类型", device_type)
  108. bed_number := int64(dataBody["bed_number"].(float64))
  109. // fmt.Println("床位号", bed_number)
  110. //通过床位id获取区号id
  111. number, err := service.GetZoneId(bed_number, orgid)
  112. //fmt.Println("number", number)
  113. // fmt.Println("获取分区id错误", err)
  114. device_name := dataBody["device_name"].(string)
  115. // fmt.Println("设备名称", device_name)
  116. manufacture_factory := dataBody["manufacture_factory"].(string)
  117. //fmt.Println("生产厂家", manufacture_factory)
  118. service_manufacturer := dataBody["service_manufacturer"].(string)
  119. // fmt.Println("维修厂家", service_manufacturer)
  120. unittype := int64(dataBody["unit_type"].(float64))
  121. unit_type := strconv.FormatInt(unittype, 10)
  122. // fmt.Println("设备型号", unit_type)
  123. use_section := dataBody["use_section"].(string)
  124. //fmt.Println("使用科室", use_section)
  125. section_number := dataBody["section_number"].(string)
  126. // fmt.Println("科室编号", section_number)
  127. buy_date := dataBody["buy_date"].(string)
  128. // fmt.Println("buy_date", buy_date)
  129. timeLayout := "2006-01-02 15:04:05"
  130. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  131. buydate := theTime.Unix()
  132. int_num := *(*int)(unsafe.Pointer(&buydate))
  133. if int_num < 0 {
  134. buydate = 0
  135. }
  136. // fmt.Println("购买日期", buydate)
  137. install_date := dataBody["install_date"].(string)
  138. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  139. installdate := toTime.Unix()
  140. buy_num := *(*int)(unsafe.Pointer(&installdate))
  141. if buy_num < 0 {
  142. installdate = 0
  143. }
  144. //fmt.Println("安装日期", installdate)
  145. start_date := dataBody["start_date"].(string)
  146. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  147. startdate := stringToTime.Unix()
  148. start_num := *(*int)(unsafe.Pointer(&startdate))
  149. if start_num < 0 {
  150. startdate = 0
  151. }
  152. // fmt.Println("启用日期", startdate)
  153. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  154. //fmt.Println("维修工程", maintenance_engineer)
  155. telephone := dataBody["telephone"].(string)
  156. //fmt.Println("telephone", telephone)
  157. guarantee_date := dataBody["guarantee_date"].(string)
  158. // fmt.Println("保修期限", guarantee_date)
  159. machine_status := int64(dataBody["machine_status"].(float64))
  160. //fmt.Println("机器状态", machine_status)
  161. user_total := dataBody["user_total"].(string)
  162. //fmt.Println("初次使用次数", user_total)
  163. disinfection_mode := int64(dataBody["Disinfection_mode"].(float64))
  164. //fmt.Println("消毒方式", disinfection_mode)
  165. remarks := dataBody["remarks"].(string)
  166. //fmt.Println("备注", remarks)
  167. rubbish_date := dataBody["rubbish_date"].(string)
  168. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  169. rubbishdate := timeStringToTime.Unix()
  170. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  171. if rubb_num < 0 {
  172. rubbishdate = 0
  173. }
  174. //fmt.Println("报废日期", rubbishdate)
  175. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  176. //fmt.Println("报废原因", rubbish_reason)
  177. user_year := dataBody["user_year"].(string)
  178. // fmt.Println("使用年限", user_year)
  179. work_time := dataBody["work_time"].(string)
  180. //fmt.Println("工作时长", work_time)
  181. treat_types := dataBody["treat_type"].([]interface{})
  182. revers := int64(dataBody["revers_mode"].(float64))
  183. //fmt.Println("反渗模式", revers)
  184. ids := make([]int64, 0)
  185. for _, treat := range treat_types {
  186. id := int64(treat.(float64))
  187. ids = append(ids, id)
  188. }
  189. //查询机位号是否绑定设备
  190. thisAddmacher, err := service.GetEquitmentByBedID(bed_number, orgid)
  191. if thisAddmacher.ID > 0 {
  192. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeEquitNoExist)
  193. return
  194. }
  195. addmacher := &models.DeviceAddmacher{
  196. SerialNumber: serial_numbe,
  197. DeviceType: device_type,
  198. BedNumber: number.Number,
  199. BedId: bed_number,
  200. //ZoneId: number.ZoneID,
  201. DeviceName: device_name,
  202. ManufactureFactory: manufacture_factory,
  203. ServiceManufacturer: service_manufacturer,
  204. UnitType: unittype,
  205. UseSection: use_section,
  206. SectionNumber: section_number,
  207. BuyDate: buydate,
  208. InstallDate: installdate,
  209. StartDate: startdate,
  210. MaintenaceEngineer: maintenance_engineer,
  211. Telephone: telephone,
  212. GuaranteeDate: guarantee_date,
  213. MachineStatus: machine_status,
  214. UserTotal: user_total,
  215. DisinfectionMode: disinfection_mode,
  216. Remarks: remarks,
  217. RubbishDate: rubbishdate,
  218. RubbishReason: rubbish_reason,
  219. UserYear: user_year,
  220. WorkTime: work_time,
  221. ReversMode: revers,
  222. Status: 1,
  223. Ctime: time.Now().Unix(),
  224. UserOrgId: orgid,
  225. }
  226. err = service.CreateMacher(addmacher)
  227. //fmt.Println("什么原因啊", err)
  228. if err != nil {
  229. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  230. return
  231. }
  232. deviceAddmacher, err := service.GetLastMacherData(orgid)
  233. // fmt.Println("错误是什么", err)
  234. equimentname := models.DeviceEquimentname{
  235. EquitmentName: unit_type,
  236. Status: 1,
  237. UserOrgId: orgid,
  238. Ctime: time.Now().Unix(),
  239. EquitmentId: deviceAddmacher.ID,
  240. BedId: bed_number,
  241. }
  242. error := service.AddTreatMode(deviceAddmacher.ID, orgid, ids)
  243. fmt.Println("error:", error)
  244. name, errcode := service.GetEquitmentName(unit_type, orgid)
  245. fmt.Print("错误", errcode)
  246. fmt.Print("name", name)
  247. err = service.CreateEquimentName(equimentname)
  248. //if errcode == gorm.ErrRecordNotFound {
  249. // err = service.CreateEquimentName(equimentname)
  250. //} else if errcode == nil {
  251. // fmt.Print("设备类型已经存在")
  252. //} else {
  253. // fmt.Print("设备类型已经存在")
  254. //}
  255. fmt.Println("添加设备型号失败", err)
  256. this.ServeSuccessJSON(map[string]interface{}{
  257. "addmacher": addmacher,
  258. })
  259. }
  260. func (this *MachineApiController) UpdateMachineInfo() {
  261. adminUserInfo := this.GetAdminUserInfo()
  262. orgid := adminUserInfo.CurrentOrgId
  263. //fmt.Println("机构id", orgid)
  264. dataBody := make(map[string]interface{}, 0)
  265. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  266. //fmt.Println("错误是", err)
  267. id := int64(dataBody["id"].(float64))
  268. fmt.Println("id是什么", id)
  269. //serial_number := int64(dataBody["serial_number"].(float64))
  270. serial_number := dataBody["serial_number"].(string)
  271. fmt.Println("序列号", serial_number)
  272. device_type := int64(dataBody["devicetype"].(float64))
  273. fmt.Println("设备类型", device_type)
  274. bed_number := int64(dataBody["bed_number"].(float64))
  275. fmt.Println("机位号", bed_number)
  276. number, err := service.GetZoneId(bed_number, orgid)
  277. //fmt.Println("number是多少", number)
  278. device_name := dataBody["device_name"].(string)
  279. //fmt.Println("设备名称", device_name)
  280. manufacture_factory := dataBody["manufacture_factory"].(string)
  281. //fmt.Println("生产厂家", manufacture_factory)
  282. service_manufacturer := dataBody["service_manufacturer"].(string)
  283. //fmt.Println("维修厂家", service_manufacturer)
  284. unit_type := int64(dataBody["unit_type"].(float64))
  285. //unit_type := strconv.FormatInt(unittype, 10)
  286. fmt.Println("设备型号", unit_type)
  287. use_section := dataBody["use_section"].(string)
  288. //fmt.Println("使用科室", use_section)
  289. section_number := dataBody["section_number"].(string)
  290. //fmt.Println("科室编号", section_number)
  291. buy_date := dataBody["buy_date"].(string)
  292. // fmt.Println("buy_date", buy_date)
  293. timeLayout := "2006-01-02 15:04:05"
  294. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  295. buydate := theTime.Unix()
  296. int_num := *(*int)(unsafe.Pointer(&buydate))
  297. if int_num < 0 {
  298. buydate = 0
  299. }
  300. fmt.Println("购买日期", buydate)
  301. install_date := dataBody["install_date"].(string)
  302. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  303. installdate := toTime.Unix()
  304. buy_num := *(*int)(unsafe.Pointer(&installdate))
  305. if buy_num < 0 {
  306. installdate = 0
  307. }
  308. //fmt.Println("安装日期", installdate)
  309. start_date := dataBody["start_date"].(string)
  310. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  311. startdate := stringToTime.Unix()
  312. start_num := *(*int)(unsafe.Pointer(&startdate))
  313. if start_num < 0 {
  314. startdate = 0
  315. }
  316. //fmt.Println("启用日期", startdate)
  317. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  318. //fmt.Println("维修工程", maintenance_engineer)
  319. telephone := dataBody["telephone"].(string)
  320. //fmt.Println("telephone", telephone)
  321. guarantee_date := dataBody["guarantee_date"].(string)
  322. //fmt.Println("保修期限", guarantee_date)
  323. machine_status := int64(dataBody["machine_status"].(float64))
  324. //fmt.Println("机器状态", machine_status)
  325. user_total := dataBody["user_total"].(string)
  326. //fmt.Println("初次使用次数", user_total)
  327. remarks := dataBody["remarks"].(string)
  328. //fmt.Println("备注", remarks)
  329. rubbish_date := dataBody["rubbish_date"].(string)
  330. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  331. rubbishdate := timeStringToTime.Unix()
  332. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  333. if rubb_num < 0 {
  334. rubbishdate = 0
  335. }
  336. //fmt.Println("报废日期", rubbishdate)
  337. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  338. //fmt.Println("报废原因", rubbish_reason)
  339. user_year := dataBody["user_year"].(string)
  340. //fmt.Println("使用年限", user_year)
  341. work_time := dataBody["work_time"].(string)
  342. //fmt.Println("工作时长", work_time)
  343. treat_types := dataBody["treat_type"].([]interface{})
  344. ids := make([]int64, 0)
  345. for _, treat := range treat_types {
  346. id := int64(treat.(float64))
  347. ids = append(ids, id)
  348. }
  349. fmt.Println("ids", ids)
  350. //service.GetModeName(unit_type)
  351. thisAddmacher, err := service.GetEquitmentByBedID(bed_number, orgid)
  352. if thisAddmacher.ID > 0 && thisAddmacher.ID != id {
  353. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisNoExist)
  354. return
  355. }
  356. addmacher := models.DeviceAddmacher{
  357. ID: id,
  358. SerialNumber: serial_number,
  359. DeviceType: device_type,
  360. BedNumber: number.Number,
  361. BedId: bed_number,
  362. DeviceName: device_name,
  363. ManufactureFactory: manufacture_factory,
  364. ServiceManufacturer: service_manufacturer,
  365. UnitType: unit_type,
  366. UseSection: use_section,
  367. SectionNumber: section_number,
  368. BuyDate: buydate,
  369. InstallDate: installdate,
  370. StartDate: startdate,
  371. MaintenaceEngineer: maintenance_engineer,
  372. Telephone: telephone,
  373. GuaranteeDate: guarantee_date,
  374. MachineStatus: machine_status,
  375. UserTotal: user_total,
  376. Remarks: remarks,
  377. RubbishDate: rubbishdate,
  378. RubbishReason: rubbish_reason,
  379. UserYear: user_year,
  380. WorkTime: work_time,
  381. }
  382. //fmt.Println("addmacher", addmacher)
  383. err = service.UpdateMachine(id, orgid, &addmacher)
  384. //mt.Println("报错", err)
  385. //zone, err := service.GetZoneName(number.ZoneID, orgid)
  386. //fmt.Println("zoneerr",err)
  387. errors := service.UpdateTreatMode(id, orgid, ids)
  388. fmt.Println("更新透析模式失败", errors)
  389. if err != nil {
  390. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  391. return
  392. }
  393. this.ServeSuccessJSON(map[string]interface{}{
  394. "addmacher": addmacher,
  395. })
  396. }
  397. func (this *MachineApiController) UpdateMachinetwo() {
  398. adminUserInfo := this.GetAdminUserInfo()
  399. orgid := adminUserInfo.CurrentOrgId
  400. //fmt.Println("机构id", orgid)
  401. dataBody := make(map[string]interface{}, 0)
  402. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  403. //fmt.Println("错误是", err)
  404. id := int64(dataBody["id"].(float64))
  405. //fmt.Println("id是什么", id)
  406. //serial_number := int64(dataBody["serial_number"].(float64))
  407. bed_nunmber := dataBody["beds"].(string)
  408. //fmt.Print("机位号z", bes)
  409. // bed_nunmber := strconv.FormatInt(bes,10)
  410. serial_number := dataBody["serial_number"].(string)
  411. //fmt.Println("序列号", serial_number)
  412. device_type := int64(dataBody["devicetype"].(float64))
  413. //fmt.Println("设备类型", device_type)
  414. // bed_nunmber := dataBody["bed_number"].(string)
  415. //fmt.Println("床位好", bed_nunmber)
  416. device_name := dataBody["device_name"].(string)
  417. //fmt.Println("设备名称", device_name)
  418. manufacture_factory := dataBody["manufacture_factory"].(string)
  419. //fmt.Println("生产厂家", manufacture_factory)
  420. service_manufacturer := dataBody["service_manufacturer"].(string)
  421. //fmt.Println("维修厂家", service_manufacturer)
  422. unit_type := int64(dataBody["unit_type"].(float64))
  423. //unit_type := strconv.FormatInt(unittype, 10)
  424. //fmt.Println("设备型号", unit_type)
  425. use_section := dataBody["use_section"].(string)
  426. //fmt.Println("使用科室", use_section)
  427. section_number := dataBody["section_number"].(string)
  428. //fmt.Println("科室编号", section_number)
  429. buy_date := dataBody["buy_date"].(string)
  430. //fmt.Println("buy_date", buy_date)
  431. timeLayout := "2006-01-02 15:04:05"
  432. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  433. buydate := theTime.Unix()
  434. int_num := *(*int)(unsafe.Pointer(&buydate))
  435. if int_num < 0 {
  436. buydate = 0
  437. }
  438. //fmt.Println("购买日期", buydate)
  439. install_date := dataBody["install_date"].(string)
  440. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  441. installdate := toTime.Unix()
  442. buy_num := *(*int)(unsafe.Pointer(&installdate))
  443. if buy_num < 0 {
  444. installdate = 0
  445. }
  446. //fmt.Println("安装日期", installdate)
  447. start_date := dataBody["start_date"].(string)
  448. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  449. startdate := stringToTime.Unix()
  450. start_num := *(*int)(unsafe.Pointer(&startdate))
  451. if start_num < 0 {
  452. startdate = 0
  453. }
  454. //fmt.Println("启用日期", startdate)
  455. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  456. //fmt.Println("维修工程", maintenance_engineer)
  457. telephone := dataBody["telephone"].(string)
  458. //fmt.Println("telephone", telephone)
  459. guarantee_date := dataBody["guarantee_date"].(string)
  460. //fmt.Println("保修期限", guarantee_date)
  461. machine_status := int64(dataBody["machine_status"].(float64))
  462. //fmt.Println("机器状态", machine_status)
  463. user_total := dataBody["user_total"].(string)
  464. //fmt.Println("初次使用次数", user_total)
  465. remarks := dataBody["remarks"].(string)
  466. //fmt.Println("备注", remarks)
  467. rubbish_date := dataBody["rubbish_date"].(string)
  468. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  469. rubbishdate := timeStringToTime.Unix()
  470. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  471. if rubb_num < 0 {
  472. rubbishdate = 0
  473. }
  474. //fmt.Println("报废日期", rubbishdate)
  475. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  476. //fmt.Println("报废原因", rubbish_reason)
  477. user_year := dataBody["user_year"].(string)
  478. //fmt.Println("使用年限", user_year)
  479. work_time := dataBody["work_time"].(string)
  480. //fmt.Println("工作时长", work_time)
  481. disinfection_mode := int64(dataBody["Disinfection_mode"].(float64))
  482. revers_modes := int64(dataBody["revers_mode"].(float64))
  483. addmacher := models.DeviceAddmacher{
  484. ID: id,
  485. SerialNumber: serial_number,
  486. DeviceType: device_type,
  487. BedNumber: bed_nunmber,
  488. DeviceName: device_name,
  489. ManufactureFactory: manufacture_factory,
  490. ServiceManufacturer: service_manufacturer,
  491. UnitType: unit_type,
  492. UseSection: use_section,
  493. SectionNumber: section_number,
  494. BuyDate: buydate,
  495. InstallDate: installdate,
  496. StartDate: startdate,
  497. MaintenaceEngineer: maintenance_engineer,
  498. Telephone: telephone,
  499. GuaranteeDate: guarantee_date,
  500. MachineStatus: machine_status,
  501. UserTotal: user_total,
  502. Remarks: remarks,
  503. RubbishDate: rubbishdate,
  504. RubbishReason: rubbish_reason,
  505. UserYear: user_year,
  506. WorkTime: work_time,
  507. DisinfectionMode: disinfection_mode,
  508. ReversMode: revers_modes,
  509. }
  510. fmt.Println("addmacher", addmacher)
  511. err = service.UpdateMachine(id, orgid, &addmacher)
  512. fmt.Println("报错", err)
  513. if err != nil {
  514. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  515. return
  516. }
  517. this.ServeSuccessJSON(map[string]interface{}{
  518. "addmacher": addmacher,
  519. })
  520. }
  521. func (this *MachineApiController) Updatemacheinetwo() {
  522. adminUserInfo := this.GetAdminUserInfo()
  523. orgid := adminUserInfo.CurrentOrgId
  524. //fmt.Println("机构id", orgid)
  525. dataBody := make(map[string]interface{}, 0)
  526. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  527. //fmt.Println("错误是", err)
  528. id := int64(dataBody["id"].(float64))
  529. //fmt.Println("id是什么", id)
  530. //serial_number := int64(dataBody["serial_number"].(float64))
  531. serial_number := dataBody["serial_number"].(string)
  532. //fmt.Println("序列号", serial_number)
  533. device_type := int64(dataBody["devicetype"].(float64))
  534. //fmt.Println("设备类型", device_type)
  535. //bed_number := int64(dataBody["bed_number"].(float64))
  536. //fmt.Println("机位号", bed_number)
  537. bednumber := dataBody["bed_numbers"].(string)
  538. //fmt.Println("机位号", bednumber)
  539. //number, err := service.GetZoneId(bed_number, orgid)
  540. //fmt.Println("number是多少", number)
  541. device_name := dataBody["device_name"].(string)
  542. //fmt.Println("设备名称", device_name)
  543. manufacture_factory := dataBody["manufacture_factory"].(string)
  544. //fmt.Println("生产厂家", manufacture_factory)
  545. service_manufacturer := dataBody["service_manufacturer"].(string)
  546. //fmt.Println("维修厂家", service_manufacturer)
  547. unittype := int64(dataBody["unit_type"].(float64))
  548. //unit_type := strconv.FormatInt(unittype, 10)
  549. //fmt.Println("设备型号", unit_type)
  550. use_section := dataBody["use_section"].(string)
  551. //fmt.Println("使用科室", use_section)
  552. section_number := dataBody["section_number"].(string)
  553. //fmt.Println("科室编号", section_number)
  554. buy_date := dataBody["buy_date"].(string)
  555. //fmt.Println("buy_date", buy_date)
  556. timeLayout := "2006-01-02 15:04:05"
  557. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  558. buydate := theTime.Unix()
  559. int_num := *(*int)(unsafe.Pointer(&buydate))
  560. if int_num < 0 {
  561. buydate = 0
  562. }
  563. //fmt.Println("购买日期", buydate)
  564. install_date := dataBody["install_date"].(string)
  565. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  566. installdate := toTime.Unix()
  567. buy_num := *(*int)(unsafe.Pointer(&installdate))
  568. if buy_num < 0 {
  569. installdate = 0
  570. }
  571. //fmt.Println("安装日期", installdate)
  572. start_date := dataBody["start_date"].(string)
  573. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  574. startdate := stringToTime.Unix()
  575. start_num := *(*int)(unsafe.Pointer(&startdate))
  576. if start_num < 0 {
  577. startdate = 0
  578. }
  579. //fmt.Println("启用日期", startdate)
  580. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  581. //fmt.Println("维修工程", maintenance_engineer)
  582. telephone := dataBody["telephone"].(string)
  583. //fmt.Println("telephone", telephone)
  584. guarantee_date := dataBody["guarantee_date"].(string)
  585. //fmt.Println("保修期限", guarantee_date)
  586. machine_status := int64(dataBody["machine_status"].(float64))
  587. //fmt.Println("机器状态", machine_status)
  588. user_total := dataBody["user_total"].(string)
  589. //fmt.Println("初次使用次数", user_total)
  590. remarks := dataBody["remarks"].(string)
  591. //fmt.Println("备注", remarks)
  592. rubbish_date := dataBody["rubbish_date"].(string)
  593. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  594. rubbishdate := timeStringToTime.Unix()
  595. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  596. if rubb_num < 0 {
  597. rubbishdate = 0
  598. }
  599. //fmt.Println("报废日期", rubbishdate)
  600. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  601. //fmt.Println("报废原因", rubbish_reason)
  602. user_year := dataBody["user_year"].(string)
  603. //fmt.Println("使用年限", user_year)
  604. work_time := dataBody["work_time"].(string)
  605. //fmt.Println("工作时长", work_time)
  606. addmacher := models.DeviceAddmacher{
  607. ID: id,
  608. SerialNumber: serial_number,
  609. DeviceType: device_type,
  610. BedNumber: bednumber,
  611. DeviceName: device_name,
  612. ManufactureFactory: manufacture_factory,
  613. ServiceManufacturer: service_manufacturer,
  614. UnitType: unittype,
  615. UseSection: use_section,
  616. SectionNumber: section_number,
  617. BuyDate: buydate,
  618. InstallDate: installdate,
  619. StartDate: startdate,
  620. MaintenaceEngineer: maintenance_engineer,
  621. Telephone: telephone,
  622. GuaranteeDate: guarantee_date,
  623. MachineStatus: machine_status,
  624. UserTotal: user_total,
  625. Remarks: remarks,
  626. RubbishDate: rubbishdate,
  627. RubbishReason: rubbish_reason,
  628. UserYear: user_year,
  629. WorkTime: work_time,
  630. }
  631. //fmt.Println("addmacher", addmacher)
  632. err = service.UpdateMachine(id, orgid, &addmacher)
  633. //fmt.Println("报错", err)
  634. if err != nil {
  635. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  636. return
  637. }
  638. this.ServeSuccessJSON(map[string]interface{}{
  639. "addmacher": addmacher,
  640. })
  641. }
  642. func (this *MachineApiController) GetAllEquimentName() {
  643. adminUser := this.GetAdminUserInfo()
  644. orgid := adminUser.CurrentOrgId
  645. equit, err := service.GetAllEquimentName(orgid)
  646. if err != nil {
  647. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  648. return
  649. }
  650. this.ServeSuccessJSON(map[string]interface{}{
  651. "equit": equit,
  652. })
  653. }
  654. func (this *MachineApiController) SavePlan() {
  655. id, _ := this.GetInt64("id")
  656. //fmt.Println("设备id", id)
  657. adminUserInfo := this.GetAdminUserInfo()
  658. orgid := adminUserInfo.CurrentOrgId
  659. //fmt.Println("机构id", orgid)
  660. dataBody := make(map[string]interface{}, 0)
  661. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  662. //fmt.Println("错误是", err)
  663. device_type := int64(dataBody["device_type"].(float64))
  664. //fmt.Println("设备型号", device_type)
  665. disinfec_time := dataBody["disinfec_time"].(string)
  666. //fmt.Println("消毒时长", disinfec_time)
  667. time := dataBody["time"].([]interface{})
  668. //fmt.Println("时间", time)
  669. ids := make([]int64, 0)
  670. for _, t := range time {
  671. id := int64(t.(float64))
  672. ids = append(ids, id)
  673. }
  674. //fmt.Println("ids", ids)
  675. classtime := dataBody["class_time"].([]interface{})
  676. //fmt.Println("班次", classtime)
  677. classids := make([]int64, 0)
  678. for _, class := range classtime {
  679. id := int64(class.(float64))
  680. classids = append(classids, id)
  681. }
  682. //fmt.Println("classids", classids)
  683. way := int64(dataBody["way"].(float64))
  684. //fmt.Println("基表消毒方式", way)
  685. machinedisinfectant := int64(dataBody["machine_disinfectant"].(float64))
  686. //fmt.Println("基表消毒液", machinedisinfectant)
  687. disinfectantway := int64(dataBody["disinfectant_way"].(float64))
  688. //fmt.Println("液路消毒方式", disinfectantway)
  689. disinfectant := int64(dataBody["disinfectant"].(float64))
  690. //fmt.Println("液路消毒液", disinfectant)
  691. bed, err := service.GetBed(id)
  692. _, errcode := service.QueryPlan(orgid, device_type, ids, classids, id)
  693. fmt.Print("errcode ---------", errcode)
  694. if errcode == gorm.ErrRecordNotFound {
  695. err = service.AddPlan(orgid, device_type, disinfec_time, ids, classids, way, machinedisinfectant, disinfectantway, disinfectant, id, bed.BedId)
  696. if err != nil {
  697. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加计划失败")
  698. return
  699. }
  700. this.ServeSuccessJSON(map[string]interface{}{
  701. "msg": "msg",
  702. })
  703. } else if errcode == nil {
  704. this.ServeFailJsonSend(enums.ErrorCodeDataException, "已存在")
  705. return
  706. } else {
  707. this.ServeFailJsonSend(enums.ErrorCodeDataException, "已存在")
  708. return
  709. }
  710. }
  711. func (this *MachineApiController) GetAllPlan() {
  712. adminUserin := this.GetAdminUserInfo()
  713. orgid := adminUserin.CurrentOrgId
  714. plan, err := service.GetAllPlan(orgid)
  715. if err != nil {
  716. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  717. return
  718. }
  719. this.ServeSuccessJSON(map[string]interface{}{
  720. "plan": plan,
  721. })
  722. }
  723. func (this *MachineApiController) GetAllPlanDetail() {
  724. //id, _ := this.GetInt64("id")
  725. //更据设备ID获取设备型号
  726. //fmt.Print("=================失败ID",id)
  727. unitype := this.GetString("unitype")
  728. deviceType, err2 := service.GetDeviceType(unitype)
  729. fmt.Print("eer2", err2)
  730. adminUserInfo := this.GetAdminUserInfo()
  731. orgid := adminUserInfo.CurrentOrgId
  732. //fmt.Println("orgid", orgid)
  733. plandetail, err := service.GetAllPlanDetail(deviceType.ID, orgid)
  734. if err != nil {
  735. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  736. return
  737. }
  738. this.ServeSuccessJSON(map[string]interface{}{
  739. "plandetail": plandetail,
  740. })
  741. }
  742. func (this *MachineApiController) GetEditMahchine() {
  743. id, _ := this.GetInt64("id")
  744. fmt.Print("id", id)
  745. }
  746. func (this *MachineApiController) DeletePlans() {
  747. adminUserInfo := this.GetAdminUserInfo()
  748. OrgID := adminUserInfo.CurrentOrgId
  749. dataBody := make(map[string]interface{}, 0)
  750. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  751. if err != nil {
  752. utils.ErrorLog(err.Error())
  753. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  754. return
  755. }
  756. idsInters := dataBody["ids"].([]interface{})
  757. if len(idsInters) == 0 {
  758. if err != nil {
  759. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  760. return
  761. }
  762. }
  763. ids := make([]int64, 0)
  764. for _, idsInter := range idsInters {
  765. id := int64(idsInter.(float64))
  766. ids = append(ids, id)
  767. }
  768. err = service.DeletePlans(OrgID, ids)
  769. if err != nil {
  770. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  771. return
  772. }
  773. returnData := make(map[string]interface{}, 0)
  774. returnData["msg"] = "ok"
  775. this.ServeSuccessJSON(returnData)
  776. return
  777. }
  778. func (this *MachineApiController) EditPlanDetail() {
  779. id, _ := this.GetInt64("id")
  780. adminUserInfo := this.GetAdminUserInfo()
  781. orgId := adminUserInfo.CurrentOrgId
  782. plan, err := service.GetPlanDetailById(id, orgId)
  783. fmt.Println("err", err)
  784. if err != nil {
  785. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  786. return
  787. }
  788. this.ServeSuccessJSON(map[string]interface{}{
  789. "plan": plan,
  790. })
  791. }
  792. func (this *MachineApiController) UpdatePlanInfo() {
  793. dataBody := make(map[string]interface{}, 0)
  794. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  795. //fmt.Println("错误是", err)
  796. id := int64(dataBody["id"].(float64))
  797. //fmt.Println("id", id)
  798. device_type := int64(dataBody["device_type"].(float64))
  799. //fmt.Println("设备型号", device_type)
  800. disinfec_time := int64(dataBody["disinfec_time"].(float64))
  801. //fmt.Println("消毒时长", disinfec_time)
  802. time := int64(dataBody["time"].(float64))
  803. //fmt.Println("时间", time)
  804. classtime := int64(dataBody["class_time"].(float64))
  805. //fmt.Println("班次", classtime)
  806. way := int64(dataBody["way"].(float64))
  807. //fmt.Println("基表消毒方式", way)
  808. machinedisinfectant := int64(dataBody["machine_disinfectant"].(float64))
  809. //fmt.Println("基表消毒液", machinedisinfectant)
  810. disinfectantway := int64(dataBody["disinfectant_way"].(float64))
  811. fmt.Println("液路消毒方式", disinfectantway)
  812. disinfectant := int64(dataBody["disinfectant"].(float64))
  813. //fmt.Println("液路消毒液", disinfectant)
  814. adminUserInfo := this.GetAdminUserInfo()
  815. orgid := adminUserInfo.CurrentOrgId
  816. //fmt.Println("orgid", orgid)
  817. plan := models.DevicePlan{
  818. DeviceType: device_type,
  819. DisinfecTime: disinfec_time,
  820. Time: time,
  821. Classtime: classtime,
  822. Way: way,
  823. MachineDisinfectant: machinedisinfectant,
  824. DisinfectanWay: disinfectantway,
  825. Disinfectant: disinfectant,
  826. }
  827. err = service.UpdatePlanInfo(id, orgid, plan)
  828. fmt.Println("err", err)
  829. if err != nil {
  830. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  831. return
  832. }
  833. this.ServeSuccessJSON(map[string]interface{}{
  834. "plan": plan,
  835. })
  836. }
  837. func (this *MachineApiController) GetComprehensive() {
  838. zone, _ := this.GetInt64("zone")
  839. //fmt.Println("分区", zone)
  840. number, _ := this.GetInt64("number")
  841. //fmt.Println("机号", number)
  842. devicetype, _ := this.GetInt64("devicetype")
  843. //fmt.Println("type", devicetype)
  844. year, _ := this.GetInt64("year")
  845. //fmt.Println("year", year)
  846. startTime := this.GetString("starttime")
  847. //fmt.Println("开始时间", startTime)
  848. timeLayout := "2006-01-02"
  849. loc, _ := time.LoadLocation("Local")
  850. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  851. starts := theTime.Unix()
  852. //fmt.Println("开始日期", starts)
  853. endtime := this.GetString("endtime")
  854. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  855. end := location.Unix()
  856. //fmt.Println("endtime", end)
  857. adminUserInfo := this.GetAdminUserInfo()
  858. orgid := adminUserInfo.CurrentOrgId
  859. macher, err := service.GetComprehensive(zone, number, devicetype, year, starts, end, orgid)
  860. if err != nil {
  861. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  862. return
  863. }
  864. this.ServeSuccessJSON(map[string]interface{}{
  865. "macher": macher,
  866. })
  867. }
  868. func (this *MachineApiController) GetPatientInfo() {
  869. adminUser := this.GetAdminUserInfo()
  870. orgid := adminUser.CurrentOrgId
  871. //fmt.Println("机构id", orgid)
  872. id, _ := this.GetInt64("id")
  873. //fmt.Println("设备id", id)
  874. addmacher, _ := service.GetBedId(id)
  875. //fmt.Println("addmacher", addmacher.BedId)
  876. timeStr := time.Now().Format("2006-01-02")
  877. timeLayout := "2006-01-02 15:04:05"
  878. //fmt.Println("timeStr:", timeStr)
  879. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  880. timenow := timeStringToTime.Unix()
  881. fmt.Println("timenow是什么", timenow)
  882. //fmt.Println("时间搓", timeStringToTime.Unix())
  883. //获取当天床位号排班的所有病人
  884. schedules, err := service.GetPatientInfo(addmacher.BedId, timenow, orgid)
  885. //fmt.Println("错误", err)
  886. if err != nil {
  887. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  888. return
  889. }
  890. this.ServeSuccessJSON(map[string]interface{}{
  891. "schedules": schedules,
  892. })
  893. }
  894. func (this *MachineApiController) GetPatient() {
  895. adminUser := this.GetAdminUserInfo()
  896. orgid := adminUser.CurrentOrgId
  897. //fmt.Println("机构id", orgid)
  898. equitid, _ := this.GetInt64("equitid")
  899. //fmt.Println("设备id", equitid)
  900. addmacher, _ := service.GetBedId(equitid)
  901. id, _ := this.GetInt64("id")
  902. //fmt.Println("班次id", id)
  903. timeStr := time.Now().Format("2006-01-02")
  904. timeLayout := "2006-01-02 15:04:05"
  905. //fmt.Println("timeStr:", timeStr)
  906. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  907. timenow := timeStringToTime.Unix()
  908. //fmt.Println("timenow是什么", timenow)
  909. schedules, err := service.GetPatient(addmacher.BedId, orgid, id, timenow)
  910. //fmt.Println("schedules", schedules.PartitionId)
  911. //获取区号姓名
  912. zone, _ := service.GetPartitionName(schedules.PartitionId)
  913. //获取机位号
  914. number, _ := service.GetPatientNumber(schedules.BedId)
  915. //获取上机时间和下机时间
  916. order, _ := service.GetDialysisOrder(timenow, schedules.PatientId, orgid)
  917. //获取透析方式
  918. prescription, _ := service.GetDialysisWay(timenow, schedules.PatientId, orgid)
  919. //获取透析时长
  920. dislysis, _ := service.GetDialysisTime(timenow, schedules.PatientId, orgid)
  921. if err != nil {
  922. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  923. return
  924. }
  925. this.ServeSuccessJSON(map[string]interface{}{
  926. "patients": schedules,
  927. "zone": zone,
  928. "number": number,
  929. "order": order,
  930. "prescription": prescription,
  931. "dislysis": dislysis,
  932. })
  933. }
  934. func (this *MachineApiController) GetAllOrganization() {
  935. adminUserInfo := this.GetAdminUserInfo()
  936. orgid := adminUserInfo.CurrentOrgId
  937. //fmt.Println("orgid", orgid)
  938. appid := adminUserInfo.CurrentAppId
  939. //fmt.Println("appid", appid)
  940. approle, err := service.GetAllOrganization(orgid, appid)
  941. if err != nil {
  942. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  943. return
  944. }
  945. this.ServeSuccessJSON(map[string]interface{}{
  946. "approle": approle,
  947. })
  948. }
  949. func (this *MachineApiController) SaveInformation() {
  950. eid, _ := this.GetInt64("eid")
  951. fmt.Print("eid-------", eid)
  952. dataBody := make(map[string]interface{}, 0)
  953. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  954. //fmt.Println("错误是", err)
  955. adminUserInfo := this.GetAdminUserInfo()
  956. orgid := adminUserInfo.CurrentOrgId
  957. id := int64(dataBody["id"].(float64))
  958. fmt.Println("id", id)
  959. date := dataBody["date"].(string)
  960. timeLayout := "2006-01-02"
  961. loc, _ := time.LoadLocation("Local")
  962. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  963. startdate := theTime.Unix()
  964. //fmt.Println("日期", startdate)
  965. classtype := int64(dataBody["classtype"].(float64))
  966. //fmt.Println("班次", classtype)
  967. zone := int64(dataBody["zone"].(float64))
  968. //fmt.Println("分区", zone)
  969. bednumber := int64(dataBody["bed_number"].(float64))
  970. //fmt.Println("床位号", bednumber)
  971. number, err := service.GetNumbers(bednumber, orgid)
  972. patient_time := int64(dataBody["patient_id"].(float64))
  973. //fmt.Println("患者", patient_time)
  974. contagion := dataBody["contagion"].(string)
  975. //fmt.Println("传染病", contagion)
  976. dialysis_mode := int64(dataBody["dialysis_mode"].(float64))
  977. //fmt.Println("透析方式", dialysis_mode)
  978. startDateStr := dataBody["start_time"].(string)
  979. //fmt.Println("上机时间", startDateStr)
  980. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  981. //fmt.Println("上机时间", startDate.Unix())
  982. endDateStr := dataBody["end_time"].(string)
  983. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endDateStr)
  984. //fmt.Println("下机时间", endDate.Unix())
  985. dialysis_time := dataBody["dialysis_time"].(string)
  986. //fmt.Println("透析时长", dialysis_time)
  987. //hyperfiletration := dataBody["hyperfiltratio"].(string)
  988. hyperfiletration := dataBody["hyperfiltratio"].(float64)
  989. //hyperfiletration := strconv.FormatInt(hyperfiltratios, 10)
  990. fmt.Println("实际超滤量", hyperfiletration)
  991. //weight_loss := dataBody["weight_loss"].(string)
  992. weight_loss := dataBody["weight_loss"].(float64)
  993. //weight_loss := strconv.FormatInt(weightloss, 10)
  994. fmt.Println("体重减少", weight_loss)
  995. warining_value := dataBody["warning_value"].(string)
  996. fmt.Println("预警值", warining_value)
  997. //user_total := dataBody["user_total"].(string)
  998. //fmt.Println("使用次数",user_total)
  999. usertotal := int64(dataBody["user_total"].(float64))
  1000. user_total := strconv.FormatInt(usertotal, 10)
  1001. run := int64(dataBody["run"].(float64))
  1002. //fmt.Println("运行", run)
  1003. failure_stage := int64(dataBody["failure_stage"].(float64))
  1004. //fmt.Println("故事发生阶段", failure_stage)
  1005. falult_desciription := dataBody["fault_description"].(string)
  1006. //fmt.Println("故障描述", falult_desciription)
  1007. code_information := dataBody["code_information"].(string)
  1008. //fmt.Println("故障提示及代码", code_information)
  1009. //机器消毒
  1010. disinfect_type := int64(dataBody["disinfect_type"].(float64))
  1011. //fmt.Println("消毒方式", disinfect_type)
  1012. disinfectant_type := int64(dataBody["disinfectant_type"].(float64))
  1013. //fmt.Println("消毒液", disinfectant_type)
  1014. disinfection := int64(dataBody["disinfection"].(float64))
  1015. //fmt.Println("消毒状态", disinfection)
  1016. machine_run := int64(dataBody["machine_run"].(float64))
  1017. //fmt.Println("运行", machine_run)
  1018. //液路
  1019. fluid_path := int64(dataBody["fluid_path"].(float64))
  1020. //fmt.Println("液路消毒方式", fluid_path)
  1021. disinfectant := int64(dataBody["disinfectant"].(float64))
  1022. //fmt.Println("消毒液", disinfectant)
  1023. disinfection_status := int64(dataBody["disinfection_status"].(float64))
  1024. //fmt.Println("消毒状态", disinfection_status)
  1025. disinfection_residue := int64(dataBody["disinfection_residue"].(float64))
  1026. //fmt.Println("消毒液残留", disinfection_residue)
  1027. longtime := dataBody["longtime"].(string)
  1028. //fmt.Println("消毒时长", longtime)
  1029. start_DateStr := dataBody["starttime"].(string)
  1030. //fmt.Println("出发时间", startDateStr)
  1031. start_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_DateStr)
  1032. //fmt.Println("触发事件", start_Date.Unix())
  1033. end_DateStr := dataBody["endtime"].(string)
  1034. //fmt.Println("出发时间", startDateStr)
  1035. end_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", end_DateStr)
  1036. //fmt.Println("触发事件", end_Date.Unix())
  1037. dialysis_checked := int64(dataBody["dialysis_checked"].(float64))
  1038. //fmt.Println("更换", dialysis_checked)
  1039. dialysis_name := int64(dataBody["dialysis_name"].(float64))
  1040. //fmt.Println("名称", dialysis_name)
  1041. norms := dataBody["norms"].(string)
  1042. //fmt.Println("规格", norms)
  1043. dialysis_concentration := int64(dataBody["dialysis_concentration"].(float64))
  1044. //fmt.Println("浓度", dialysis_concentration)
  1045. germ_checked := int64(dataBody["germ_checked"].(float64))
  1046. //fmt.Println("更换", germ_checked)
  1047. germ_name := int64(dataBody["germ_name"].(float64))
  1048. //fmt.Println("名称", germ_name)
  1049. germ_number := dataBody["germ_number"].(string)
  1050. //fmt.Println("数量", germ_number)
  1051. clean := int64(dataBody["clean"].(float64))
  1052. //fmt.Println("清洁", clean)
  1053. sign_name := int64(dataBody["sign_name"].(float64))
  1054. //fmt.Println("签名", sign_name)
  1055. information, errinfor := service.GetInformation(eid, startdate, orgid)
  1056. fmt.Print("errinfor", errinfor)
  1057. fmt.Print("information", information)
  1058. if errinfor == gorm.ErrRecordNotFound {
  1059. infor := models.DeviceInformation{
  1060. Date: startdate,
  1061. Class: classtype,
  1062. // Zone: zone,
  1063. BedNumber: bednumber,
  1064. PatientId: patient_time,
  1065. Contagion: contagion,
  1066. DialysisMode: dialysis_mode,
  1067. StartTime: startDate.Unix(),
  1068. EndTime: endDate.Unix(),
  1069. DialysisHour: dialysis_time,
  1070. Hyperfiltratio: hyperfiletration,
  1071. WeightLoss: weight_loss,
  1072. WarningValue: warining_value,
  1073. UserTotal: user_total,
  1074. Move: run,
  1075. FailureStage: failure_stage,
  1076. FaultDescription: falult_desciription,
  1077. CodeInformation: code_information,
  1078. DisinfectantType: disinfectant_type,
  1079. DisinfectType: disinfect_type,
  1080. Disinfection: disinfection,
  1081. MachineRun: machine_run,
  1082. FluidPath: fluid_path,
  1083. Disinfectant: disinfectant,
  1084. DisinfectionStatus: disinfection_status,
  1085. DisinfectionResidue: disinfection_residue,
  1086. LongTime: longtime,
  1087. DisinfecStartime: start_Date.Unix(),
  1088. DisinfecEndtime: end_Date.Unix(),
  1089. DialysisChecked: dialysis_checked,
  1090. DialysisName: dialysis_name,
  1091. Norms: norms,
  1092. DialysisConcentration: dialysis_concentration,
  1093. GermChecked: germ_checked,
  1094. GermName: germ_name,
  1095. GermNumber: germ_number,
  1096. Clean: clean,
  1097. SignName: sign_name,
  1098. Ctime: time.Now().Unix(),
  1099. Status: 1,
  1100. UserOrgId: orgid,
  1101. EquimentId: eid,
  1102. Bed: number.Number,
  1103. Stime: startdate,
  1104. }
  1105. err = service.CreateUserInformation(&infor)
  1106. fmt.Println("使用登记错误是什么", err)
  1107. this.ServeSuccessJSON(map[string]interface{}{
  1108. "information": infor,
  1109. })
  1110. } else if errinfor == nil {
  1111. infor := models.DeviceInformation{
  1112. Date: startdate,
  1113. Class: classtype,
  1114. Zone: zone,
  1115. BedNumber: bednumber,
  1116. PatientId: patient_time,
  1117. Contagion: contagion,
  1118. DialysisMode: dialysis_mode,
  1119. StartTime: startDate.Unix(),
  1120. EndTime: endDate.Unix(),
  1121. DialysisHour: dialysis_time,
  1122. Hyperfiltratio: hyperfiletration,
  1123. WeightLoss: weight_loss,
  1124. WarningValue: warining_value,
  1125. UserTotal: user_total,
  1126. Move: run,
  1127. FailureStage: failure_stage,
  1128. FaultDescription: falult_desciription,
  1129. CodeInformation: code_information,
  1130. DisinfectantType: disinfectant_type,
  1131. DisinfectType: disinfect_type,
  1132. Disinfection: disinfection,
  1133. MachineRun: machine_run,
  1134. FluidPath: fluid_path,
  1135. Disinfectant: disinfectant,
  1136. DisinfectionStatus: disinfection_status,
  1137. DisinfectionResidue: disinfection_residue,
  1138. LongTime: longtime,
  1139. DisinfecStartime: start_Date.Unix(),
  1140. DisinfecEndtime: end_Date.Unix(),
  1141. DialysisChecked: dialysis_checked,
  1142. DialysisName: dialysis_name,
  1143. Norms: norms,
  1144. DialysisConcentration: dialysis_concentration,
  1145. GermChecked: germ_checked,
  1146. GermName: germ_name,
  1147. GermNumber: germ_number,
  1148. Clean: clean,
  1149. SignName: sign_name,
  1150. Ctime: time.Now().Unix(),
  1151. Status: 1,
  1152. UserOrgId: orgid,
  1153. EquimentId: eid,
  1154. Bed: number.Number,
  1155. }
  1156. informationdata, err := service.GetLastInformationdata(eid, startdate, orgid)
  1157. fmt.Print("informationdata----", informationdata.ID)
  1158. errors := service.UpadateForm(informationdata.ID, orgid, &infor)
  1159. //fmt.Print("报错", errors)
  1160. if errors != nil {
  1161. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1162. return
  1163. }
  1164. this.ServeSuccessJSON(map[string]interface{}{
  1165. "infor": infor,
  1166. })
  1167. } else {
  1168. }
  1169. }
  1170. func (this *MachineApiController) ChangePatient() {
  1171. adminUser := this.GetAdminUserInfo()
  1172. orgid := adminUser.CurrentOrgId
  1173. fmt.Println("机构id", orgid)
  1174. equitid, _ := this.GetInt64("equitid")
  1175. fmt.Println("equitid", equitid)
  1176. id, _ := this.GetInt64("id")
  1177. fmt.Println("id", id)
  1178. }
  1179. func (this *MachineApiController) GetRegisterInfo() {
  1180. timeStr := time.Now().Format("2006-01-02")
  1181. timeLayout := "2006-01-02 15:04:05"
  1182. //fmt.Println("timeStr:", timeStr)
  1183. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  1184. timenow := timeStringToTime.Unix()
  1185. //fmt.Println("timenow是什么", timenow)
  1186. adminUser := this.GetAdminUserInfo()
  1187. orgid := adminUser.CurrentOrgId
  1188. appid := adminUser.CurrentAppId
  1189. id, _ := this.GetInt64("id")
  1190. //fmt.Println("设备id", id)
  1191. information, err := service.GetRegisterInfo(orgid, id, timenow)
  1192. fmt.Print("错误", err)
  1193. role, err := service.GetSignName(information.SignName, orgid, appid)
  1194. dislysis, _ := service.GetDialysisTime(timenow, information.PatientId, orgid)
  1195. //if err != nil {
  1196. // // this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1197. // // return
  1198. // //}
  1199. this.ServeSuccessJSON(map[string]interface{}{
  1200. "information": information,
  1201. "role": role,
  1202. "dislysis": dislysis,
  1203. })
  1204. }
  1205. func (this *MachineApiController) GetInformationData() {
  1206. limit, _ := this.GetInt64("limit")
  1207. //fmt.Println("limit2", limit)
  1208. page, _ := this.GetInt64("page")
  1209. //fmt.Println("page", page)
  1210. adminUser := this.GetAdminUserInfo()
  1211. orgId := adminUser.CurrentOrgId
  1212. information, total, err := service.GetInformationData(limit, page, orgId)
  1213. if err != nil {
  1214. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1215. return
  1216. }
  1217. this.ServeSuccessJSON(map[string]interface{}{
  1218. "information": information,
  1219. "total": total,
  1220. })
  1221. }
  1222. func (this *MachineApiController) GetOrgName() {
  1223. adminUser := this.GetAdminUserInfo()
  1224. orgid := adminUser.CurrentOrgId
  1225. org, err := service.GetOrgName(orgid)
  1226. if err != nil {
  1227. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1228. return
  1229. }
  1230. this.ServeSuccessJSON(map[string]interface{}{
  1231. "org": org,
  1232. })
  1233. }
  1234. func (this *MachineApiController) SaveBacteria() {
  1235. id, _ := this.GetInt64("id")
  1236. //fmt.Println("id", id)
  1237. addmacher, _ := service.GetBedId(id)
  1238. //fmt.Println("addmache", addmacher.BedId)
  1239. adminUserInfo := this.GetAdminUserInfo()
  1240. orgid := adminUserInfo.CurrentOrgId
  1241. //fmt.Println("机构id", orgid)
  1242. dataBody := make(map[string]interface{}, 0)
  1243. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1244. //fmt.Println("err", err)
  1245. date := dataBody["date"].(string)
  1246. //fmt.Println("取样日期", date)
  1247. timeLayout := "2006-01-02"
  1248. loc, _ := time.LoadLocation("Local")
  1249. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  1250. state_date := theTime.Unix()
  1251. //fmt.Println("取样日期", state_date)
  1252. specimen := int64(dataBody["specimen"].(float64))
  1253. //fmt.Println("取样标本", specimen)
  1254. cona := dataBody["concentrate_noa"].(string)
  1255. //fmt.Println("A浓缩液批号", cona)
  1256. conb := dataBody["concentrate_nob"].(string)
  1257. //fmt.Println("B浓批号", conb)
  1258. samplingLoactiona := int64(dataBody["sampling_locationa"].(float64))
  1259. //fmt.Println("采样部位", samplingLoactiona)
  1260. detectionUnit := dataBody["detection_unit"].(string)
  1261. //fmt.Println("检测单位", detectionUnit)
  1262. sampler := int64(dataBody["sampler"].(float64))
  1263. //fmt.Println("取样者", sampler)
  1264. reportDate := dataBody["reporting_date"].(string)
  1265. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  1266. repDate := reportTime.Unix()
  1267. //fmt.Println("出报告日期", repDate)
  1268. detectionResult := dataBody["detection_result"].(string)
  1269. //fmt.Println("检测结果", detectionResult)
  1270. culture := models.DeviceCulture{
  1271. BedId: addmacher.BedId,
  1272. SpelingDate: state_date,
  1273. Specimen: specimen,
  1274. ConcentrateNoa: cona,
  1275. ConcentrateNob: conb,
  1276. SamplingLocationa: samplingLoactiona,
  1277. DetectionUnit: detectionUnit,
  1278. Sampler: sampler,
  1279. ReportingDate: repDate,
  1280. DetectionResult: detectionResult,
  1281. Ctime: time.Now().Unix(),
  1282. Status: 1,
  1283. UserOrgId: orgid,
  1284. EquitmentId: id,
  1285. Bed: addmacher.BedNumber,
  1286. }
  1287. err = service.CreateCulture(&culture)
  1288. //fmt.Println("创建细菌检测", err)
  1289. if err != nil {
  1290. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1291. return
  1292. }
  1293. this.ServeSuccessJSON(map[string]interface{}{
  1294. "culture": culture,
  1295. })
  1296. }
  1297. func (this *MachineApiController) SaveLinconmycin() {
  1298. timeLayout := "2006-01-02"
  1299. loc, _ := time.LoadLocation("Local")
  1300. id, _ := this.GetInt64("id")
  1301. //fmt.Println("id", id)
  1302. addmacher, _ := service.GetBedId(id)
  1303. //fmt.Println("addmache", addmacher.BedId)
  1304. adminUserInfo := this.GetAdminUserInfo()
  1305. orgid := adminUserInfo.CurrentOrgId
  1306. //fmt.Println("机构id", orgid)
  1307. dataBody := make(map[string]interface{}, 0)
  1308. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1309. //fmt.Println("err", err)
  1310. date := dataBody["sampling_date"].(string)
  1311. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  1312. samp_date := theTime.Unix()
  1313. specimen := int64(dataBody["specimenb"].(float64))
  1314. //fmt.Println("取样标本", specimen)
  1315. cona := dataBody["concentrate_noc"].(string)
  1316. //fmt.Println("A浓缩液批号", cona)
  1317. conb := dataBody["concentrateb_nod"].(string)
  1318. //fmt.Println("B浓批号", conb)
  1319. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  1320. //fmt.Println("采样部位", samplinglocationb)
  1321. detectionUnit := dataBody["detection_unit"].(string)
  1322. //fmt.Println("检测单位", detectionUnit)
  1323. samplerb := int64(dataBody["samplerb"].(float64))
  1324. //fmt.Println("取样者", samplerb)
  1325. reportDate := dataBody["reporting_dateb"].(string)
  1326. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  1327. repDate := reportTime.Unix()
  1328. //fmt.Println("出报告日期", repDate)
  1329. detectionResult := dataBody["detection_resultb"].(string)
  1330. //fmt.Println("检测结果2", detectionResult)
  1331. dialysate := models.DeviceDialysate{
  1332. SamplingDate: samp_date,
  1333. Specimenb: specimen,
  1334. ConcentrateNoc: cona,
  1335. ConcentratebNod: conb,
  1336. SamplingLocationb: samplinglocationb,
  1337. DetectionUnit: detectionUnit,
  1338. Samplerb: samplerb,
  1339. ReportingDateb: repDate,
  1340. DetectionResultb: detectionResult,
  1341. Ctime: time.Now().Unix(),
  1342. Status: 1,
  1343. UserOrgId: orgid,
  1344. BedId: addmacher.BedId,
  1345. EquitmentId: id,
  1346. Bed: addmacher.BedNumber,
  1347. }
  1348. err = service.CreateDialysate(&dialysate)
  1349. //fmt.Println("报错", err)
  1350. if err != nil {
  1351. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1352. return
  1353. }
  1354. this.ServeSuccessJSON(map[string]interface{}{
  1355. "dialysate": dialysate,
  1356. })
  1357. }
  1358. func (this *MachineApiController) SaveQualityControl() {
  1359. id, _ := this.GetInt64("id")
  1360. //fmt.Println("id", id)
  1361. addmacher, _ := service.GetBedId(id)
  1362. //fmt.Println("addmache", addmacher.BedId)
  1363. adminUserInfo := this.GetAdminUserInfo()
  1364. orgid := adminUserInfo.CurrentOrgId
  1365. //fmt.Println("机构id", orgid)
  1366. dataBody := make(map[string]interface{}, 0)
  1367. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1368. //fmt.Println("err", err)
  1369. timeLayout := "2006-01-02"
  1370. loc, _ := time.LoadLocation("Local")
  1371. // 透析液离子浓度检测
  1372. dateb := dataBody["dateb"].(string)
  1373. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateb+" 00:00:00", loc)
  1374. dateB := inLocation.Unix()
  1375. //fmt.Println("取样日期", dateB)
  1376. samplerc := int64(dataBody["samplerc"].(float64))
  1377. //fmt.Println("取样者", samplerc)
  1378. concentratenof := dataBody["concentrate_nof"].(string)
  1379. //fmt.Println("浓A", concentratenof)
  1380. concentrateonog := dataBody["concentrate_nog"].(string)
  1381. //fmt.Println("浓B", concentrateonog)
  1382. dateReportc := dataBody["date_reportc"].(string)
  1383. parseInLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateReportc+" 00:00:00", loc)
  1384. datec := parseInLocation.Unix()
  1385. //fmt.Println("报告日期", datec)
  1386. actualNa := dataBody["actual_na"].(string)
  1387. //fmt.Println("钠", actualNa)
  1388. actualPna := dataBody["actual_pna"].(string)
  1389. //fmt.Println("配钠", actualPna)
  1390. actualK := dataBody["actual_k"].(string)
  1391. //fmt.Println("钾", actualK)
  1392. actualCa := dataBody["actual_ca"].(string)
  1393. //fmt.Println("钙", actualCa)
  1394. actualCi := dataBody["actual_ci"].(string)
  1395. //fmt.Println("氯", actualCi)
  1396. actualHco := dataBody["actual_hco"].(string)
  1397. //fmt.Println("HCO", actualHco)
  1398. actualMg := dataBody["actual_mg"].(string)
  1399. //fmt.Println("actualMg", actualMg)
  1400. actulaPH := dataBody["actual_ph"].(string)
  1401. //fmt.Println("PH", actulaPH)
  1402. remakes := dataBody["remakes"].(string)
  1403. //fmt.Println("备注", remakes)
  1404. detectionUnit := dataBody["detection_unit"].(string)
  1405. //fmt.Println("检测单位", detectionUnit)
  1406. ion := models.DeviceIon{
  1407. SamplingDate: dateB,
  1408. Samplerc: samplerc,
  1409. DetectionUnit: detectionUnit,
  1410. ConcentrateNof: concentratenof,
  1411. ConcentrateNog: concentrateonog,
  1412. DateReportc: datec,
  1413. ActualNa: actualNa,
  1414. ActualPna: actualPna,
  1415. ActualK: actualK,
  1416. ActualCa: actualCa,
  1417. ActualCi: actualCi,
  1418. ActualHco: actualHco,
  1419. ActualMg: actualMg,
  1420. ActualPh: actulaPH,
  1421. Remakes: remakes,
  1422. EquitmentId: id,
  1423. Status: 1,
  1424. UserOrgId: orgid,
  1425. Ctime: time.Now().Unix(),
  1426. BedId: addmacher.BedId,
  1427. Bed: addmacher.BedNumber,
  1428. }
  1429. createIon := service.CreateIon(&ion)
  1430. fmt.Println("报错", createIon)
  1431. if err != nil {
  1432. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1433. return
  1434. }
  1435. this.ServeSuccessJSON(map[string]interface{}{
  1436. "ion": ion,
  1437. })
  1438. }
  1439. func (this *MachineApiController) GetAllQulityInfo() {
  1440. adminUser := this.GetAdminUserInfo()
  1441. orgID := adminUser.CurrentOrgId
  1442. //fmt.Println("机构id", orgID)
  1443. cultures, err := service.GetAllCulture(orgID)
  1444. dialysate, _ := service.GetAllDialysate(orgID)
  1445. ions, _ := service.GetAllDeviceIon(orgID)
  1446. if err != nil {
  1447. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1448. return
  1449. }
  1450. this.ServeSuccessJSON(map[string]interface{}{
  1451. "cultures": cultures,
  1452. "dialysate": dialysate,
  1453. "ions": ions,
  1454. })
  1455. }
  1456. func (this *MachineApiController) EditCulture() {
  1457. id, _ := this.GetInt64("id")
  1458. //fmt.Println("id", id)
  1459. userid, _ := this.GetInt64("userid")
  1460. //fmt.Println("userid", userid)
  1461. role, _ := service.GetSampler(userid)
  1462. culture, err := service.GetCultureById(id)
  1463. if err != nil {
  1464. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1465. return
  1466. }
  1467. this.ServeSuccessJSON(map[string]interface{}{
  1468. "culture": culture,
  1469. "role": role,
  1470. })
  1471. }
  1472. func (this *MachineApiController) UpdateCulture() {
  1473. dataBody := make(map[string]interface{}, 0)
  1474. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1475. //fmt.Println("err", err)
  1476. id := int64(dataBody["id"].(float64))
  1477. //fmt.Println("id", id)
  1478. date := dataBody["date"].(string)
  1479. //fmt.Println("取样日期", date)
  1480. timeLayout := "2006-01-02"
  1481. loc, _ := time.LoadLocation("Local")
  1482. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  1483. state_date := theTime.Unix()
  1484. //fmt.Println("取样日期", state_date)
  1485. specimen := int64(dataBody["specimen"].(float64))
  1486. //fmt.Println("取样标本", specimen)
  1487. cona := dataBody["concentrate_noa"].(string)
  1488. //fmt.Println("A浓缩液批号", cona)
  1489. conb := dataBody["concentrate_nob"].(string)
  1490. //fmt.Println("B浓批号", conb)
  1491. samplingLoactiona := int64(dataBody["sampling_locationa"].(float64))
  1492. //fmt.Println("采样部位", samplingLoactiona)
  1493. detectionUnit := dataBody["detection_unit"].(string)
  1494. //fmt.Println("检测单位", detectionUnit)
  1495. sampler := int64(dataBody["sampler"].(float64))
  1496. //fmt.Println("取样者", sampler)
  1497. reportDate := dataBody["reporting_date"].(string)
  1498. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  1499. repDate := reportTime.Unix()
  1500. //fmt.Println("出报告日期", repDate)
  1501. detectionResult := dataBody["detection_result"].(string)
  1502. //fmt.Println("检测结果", detectionResult)
  1503. adminUser := this.GetAdminUserInfo()
  1504. orgId := adminUser.CurrentOrgId
  1505. culture := models.DeviceCulture{
  1506. SpelingDate: state_date,
  1507. Specimen: specimen,
  1508. ConcentrateNoa: cona,
  1509. ConcentrateNob: conb,
  1510. SamplingLocationa: samplingLoactiona,
  1511. DetectionUnit: detectionUnit,
  1512. Sampler: sampler,
  1513. ReportingDate: repDate,
  1514. DetectionResult: detectionResult,
  1515. }
  1516. err = service.UpdateCulture(id, orgId, &culture)
  1517. if err != nil {
  1518. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1519. return
  1520. }
  1521. this.ServeSuccessJSON(map[string]interface{}{
  1522. "culture": culture,
  1523. })
  1524. }
  1525. func (this *MachineApiController) DeleteCultrue() {
  1526. adminUserInfo := this.GetAdminUserInfo()
  1527. OrgID := adminUserInfo.CurrentOrgId
  1528. dataBody := make(map[string]interface{}, 0)
  1529. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1530. if err != nil {
  1531. utils.ErrorLog(err.Error())
  1532. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1533. return
  1534. }
  1535. idsInters := dataBody["ids"].([]interface{})
  1536. if len(idsInters) == 0 {
  1537. if err != nil {
  1538. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  1539. return
  1540. }
  1541. }
  1542. ids := make([]int64, 0)
  1543. for _, idsInter := range idsInters {
  1544. id := int64(idsInter.(float64))
  1545. ids = append(ids, id)
  1546. }
  1547. fmt.Println("ids", ids)
  1548. err = service.DeleteCultrue(OrgID, ids)
  1549. fmt.Println("err", err)
  1550. if err != nil {
  1551. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  1552. return
  1553. }
  1554. returnData := make(map[string]interface{}, 0)
  1555. returnData["msg"] = "ok"
  1556. this.ServeSuccessJSON(returnData)
  1557. return
  1558. }
  1559. func (this *MachineApiController) EditDialystate() {
  1560. id, _ := this.GetInt64("id")
  1561. fmt.Println("id是什么", id)
  1562. dialysate, err := service.GetDialystate(id)
  1563. if err != nil {
  1564. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1565. return
  1566. }
  1567. this.ServeSuccessJSON(map[string]interface{}{
  1568. "dialysate": dialysate,
  1569. })
  1570. }
  1571. func (this *MachineApiController) Updatedialystate() {
  1572. timeLayout := "2006-01-02"
  1573. loc, _ := time.LoadLocation("Local")
  1574. dataBody := make(map[string]interface{}, 0)
  1575. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1576. fmt.Println("err", err)
  1577. id := int64(dataBody["id"].(float64))
  1578. fmt.Println("id", id)
  1579. samplingDate := dataBody["sampling_date"].(string)
  1580. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  1581. samp_date := sampdate.Unix()
  1582. fmt.Println("取样日期", samp_date)
  1583. specimentb := int64(dataBody["specimenb"].(float64))
  1584. fmt.Println("取样标本", specimentb)
  1585. concentratec := dataBody["concentrate_noc"].(string)
  1586. fmt.Println("A浓缩液批号", concentratec)
  1587. concentraeb := dataBody["concentrateb_nod"].(string)
  1588. fmt.Println("B浓缩", concentraeb)
  1589. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  1590. fmt.Println("采样部位", samplinglocationb)
  1591. samplerb := int64(dataBody["samplerb"].(float64))
  1592. fmt.Println("取样者", samplerb)
  1593. reportDateb := dataBody["reporting_dateb"].(string)
  1594. //fmt.Println("日期", reportDateb)
  1595. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  1596. report_date := location.Unix()
  1597. fmt.Println("出报告2日期", report_date)
  1598. detectionResultb := dataBody["detection_resultb"].(string)
  1599. fmt.Println("检测结果", detectionResultb)
  1600. detectionUnit := dataBody["detection_unit"].(string)
  1601. fmt.Println("检测单位", detectionUnit)
  1602. adminUser := this.GetAdminUserInfo()
  1603. orgid := adminUser.CurrentOrgId
  1604. dialysate := models.DeviceDialysate{
  1605. SamplingDate: samp_date,
  1606. Specimenb: specimentb,
  1607. ConcentrateNoc: concentratec,
  1608. ConcentratebNod: concentraeb,
  1609. SamplingLocationb: samplinglocationb,
  1610. DetectionUnit: detectionUnit,
  1611. Samplerb: samplerb,
  1612. ReportingDateb: report_date,
  1613. DetectionResultb: detectionResultb,
  1614. }
  1615. err = service.Updatedialystate(id, orgid, &dialysate)
  1616. if err != nil {
  1617. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1618. return
  1619. }
  1620. this.ServeSuccessJSON(map[string]interface{}{
  1621. "dialysate": dialysate,
  1622. })
  1623. }
  1624. func (this *MachineApiController) DeleteDialystate() {
  1625. adminUserInfo := this.GetAdminUserInfo()
  1626. OrgID := adminUserInfo.CurrentOrgId
  1627. dataBody := make(map[string]interface{}, 0)
  1628. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1629. if err != nil {
  1630. utils.ErrorLog(err.Error())
  1631. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1632. return
  1633. }
  1634. idsInters := dataBody["ids"].([]interface{})
  1635. if len(idsInters) == 0 {
  1636. if err != nil {
  1637. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  1638. return
  1639. }
  1640. }
  1641. ids := make([]int64, 0)
  1642. for _, idsInter := range idsInters {
  1643. id := int64(idsInter.(float64))
  1644. ids = append(ids, id)
  1645. }
  1646. fmt.Println("ids", ids)
  1647. err = service.DeleteDialystate(OrgID, ids)
  1648. fmt.Println("err", err)
  1649. if err != nil {
  1650. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  1651. return
  1652. }
  1653. returnData := make(map[string]interface{}, 0)
  1654. returnData["msg"] = "ok"
  1655. this.ServeSuccessJSON(returnData)
  1656. return
  1657. }
  1658. func (this *MachineApiController) Edition() {
  1659. id, _ := this.GetInt64("id")
  1660. fmt.Println("id", id)
  1661. ion, err := service.GetIon(id)
  1662. if err != nil {
  1663. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1664. return
  1665. }
  1666. this.ServeSuccessJSON(map[string]interface{}{
  1667. "ion": ion,
  1668. })
  1669. }
  1670. func (this *MachineApiController) UpdateIon() {
  1671. timeLayout := "2006-01-02"
  1672. loc, _ := time.LoadLocation("Local")
  1673. dataBody := make(map[string]interface{}, 0)
  1674. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1675. fmt.Println("err", err)
  1676. id := int64(dataBody["id"].(float64))
  1677. fmt.Println("id", id)
  1678. dateb := dataBody["dateb"].(string)
  1679. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateb+" 00:00:00", loc)
  1680. dateB := inLocation.Unix()
  1681. fmt.Println("取样日期", dateB)
  1682. samplerc := int64(dataBody["samplerc"].(float64))
  1683. fmt.Println("取样者", samplerc)
  1684. concentratenof := dataBody["concentrate_nof"].(string)
  1685. fmt.Println("浓A", concentratenof)
  1686. concentrateonog := dataBody["concentrate_nog"].(string)
  1687. fmt.Println("浓B", concentrateonog)
  1688. dateReportc := dataBody["date_reportc"].(string)
  1689. parseInLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateReportc+" 00:00:00", loc)
  1690. datec := parseInLocation.Unix()
  1691. fmt.Println("报告日期", datec)
  1692. actualNa := dataBody["actual_na"].(string)
  1693. fmt.Println("钠", actualNa)
  1694. actualPna := dataBody["actual_pna"].(string)
  1695. fmt.Println("配钠", actualPna)
  1696. actualK := dataBody["actual_k"].(string)
  1697. fmt.Println("钾", actualK)
  1698. actualCa := dataBody["actual_ca"].(string)
  1699. fmt.Println("钙", actualCa)
  1700. actualCi := dataBody["actual_ci"].(string)
  1701. fmt.Println("氯", actualCi)
  1702. actualHco := dataBody["actual_hco"].(string)
  1703. fmt.Println("HCO", actualHco)
  1704. actualMg := dataBody["actual_mg"].(string)
  1705. fmt.Println("actualMg", actualMg)
  1706. actulaPH := dataBody["actual_ph"].(string)
  1707. fmt.Println("PH", actulaPH)
  1708. remakes := dataBody["remakes"].(string)
  1709. fmt.Println("备注", remakes)
  1710. detectionUnit := dataBody["detection_unit"].(string)
  1711. fmt.Println("检测单位", detectionUnit)
  1712. ion := models.DeviceIon{
  1713. SamplingDate: dateB,
  1714. Samplerc: samplerc,
  1715. DetectionUnit: detectionUnit,
  1716. ConcentrateNof: concentratenof,
  1717. ConcentrateNog: concentrateonog,
  1718. DateReportc: datec,
  1719. ActualNa: actualNa,
  1720. ActualPna: actualPna,
  1721. ActualK: actualK,
  1722. ActualCa: actualCa,
  1723. ActualCi: actualCi,
  1724. ActualHco: actualHco,
  1725. ActualMg: actualMg,
  1726. ActualPh: actulaPH,
  1727. Remakes: remakes,
  1728. }
  1729. adminUser := this.GetAdminUserInfo()
  1730. orgId := adminUser.CurrentOrgId
  1731. err = service.UpdateIon(id, orgId, &ion)
  1732. if err != nil {
  1733. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1734. return
  1735. }
  1736. this.ServeSuccessJSON(map[string]interface{}{
  1737. "ion": ion,
  1738. })
  1739. }
  1740. func (this *MachineApiController) DeleteIon() {
  1741. adminUserInfo := this.GetAdminUserInfo()
  1742. OrgID := adminUserInfo.CurrentOrgId
  1743. dataBody := make(map[string]interface{}, 0)
  1744. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1745. if err != nil {
  1746. utils.ErrorLog(err.Error())
  1747. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1748. return
  1749. }
  1750. idsInters := dataBody["ids"].([]interface{})
  1751. if len(idsInters) == 0 {
  1752. if err != nil {
  1753. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  1754. return
  1755. }
  1756. }
  1757. ids := make([]int64, 0)
  1758. for _, idsInter := range idsInters {
  1759. id := int64(idsInter.(float64))
  1760. ids = append(ids, id)
  1761. }
  1762. fmt.Println("ids", ids)
  1763. err = service.DeleteIon(OrgID, ids)
  1764. if err != nil {
  1765. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  1766. return
  1767. }
  1768. returnData := make(map[string]interface{}, 0)
  1769. returnData["msg"] = "ok"
  1770. this.ServeSuccessJSON(returnData)
  1771. return
  1772. }
  1773. func (this *MachineApiController) GetQuery() {
  1774. timeLayout := "2006-01-02"
  1775. loc, _ := time.LoadLocation("Local")
  1776. adminUserInfo := this.GetAdminUserInfo()
  1777. OrgID := adminUserInfo.CurrentOrgId
  1778. fmt.Println("orgid", OrgID)
  1779. bedid, _ := this.GetInt64("bedid")
  1780. fmt.Println("bedid", bedid)
  1781. startime := this.GetString("startime")
  1782. fmt.Println("starttime", startime)
  1783. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  1784. start := inLocation.Unix()
  1785. fmt.Println("start", start)
  1786. endtime := this.GetString("endtime")
  1787. fmt.Println("endtime", endtime)
  1788. endLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  1789. end := endLocation.Unix()
  1790. fmt.Println("end", end)
  1791. cultures, err := service.GetCultureData(bedid, start, end, OrgID)
  1792. fmt.Print(err)
  1793. dialysate, err := service.GetDialysateData(bedid, start, end, OrgID)
  1794. ions, err := service.GetDeviceIonData(bedid, start, end, OrgID)
  1795. if err != nil {
  1796. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1797. return
  1798. }
  1799. this.ServeSuccessJSON(map[string]interface{}{
  1800. "cultures": cultures,
  1801. "dialysate": dialysate,
  1802. "ions": ions,
  1803. })
  1804. }
  1805. func (this *MachineApiController) SaveRepair() {
  1806. timeLayout := "2006-01-02"
  1807. loc, _ := time.LoadLocation("Local")
  1808. adminUserInfo := this.GetAdminUserInfo()
  1809. id, _ := this.GetInt64("id")
  1810. fmt.Println("id", id)
  1811. addmacher, _ := service.GetBedId(id)
  1812. OrgID := adminUserInfo.CurrentOrgId
  1813. fmt.Println("orgid", OrgID)
  1814. dataBody := make(map[string]interface{}, 0)
  1815. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1816. fmt.Println("err", err)
  1817. gua_date := dataBody["guarantee_date"].(string)
  1818. fmt.Println("保修日期", gua_date)
  1819. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", gua_date+" 00:00:00", loc)
  1820. guaDate := inLocation.Unix()
  1821. fmt.Println("保修日期", guaDate)
  1822. startDateStr := dataBody["start_time"].(string)
  1823. fmt.Println("出发时间", startDateStr)
  1824. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  1825. fmt.Println("触发事件", startDate.Unix())
  1826. arriveDateStr := dataBody["arrive_time"].(string)
  1827. fmt.Println("到达时间", arriveDateStr)
  1828. arriveDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", arriveDateStr)
  1829. fmt.Println("到达时间", arriveDate.Unix())
  1830. finishDateStr := dataBody["finish_time"].(string)
  1831. fmt.Println("完成时间", finishDateStr)
  1832. finishDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", finishDateStr)
  1833. fmt.Println("完成时间", finishDate.Unix())
  1834. totaldistance := dataBody["total_distance"].(string)
  1835. fmt.Println("总公里输", totaldistance)
  1836. failurestate := int64(dataBody["failure_stage"].(float64))
  1837. fmt.Println("故事范式阶段", failurestate)
  1838. codeInformation := dataBody["code_information"].(string)
  1839. fmt.Println("故事提示信息及代码", codeInformation)
  1840. faultdescription := dataBody["fault_description"].(string)
  1841. fmt.Println("故障描述", faultdescription)
  1842. causeAnalysis := dataBody["cause_analysis"].(string)
  1843. fmt.Println("原因分析", causeAnalysis)
  1844. treatmentprocess := dataBody["treatment_process"].(string)
  1845. fmt.Println("处理过程", treatmentprocess)
  1846. images := dataBody["images"].(string)
  1847. fmt.Println("上传图片", images)
  1848. exclude := int64(dataBody["exclude"].(float64))
  1849. fmt.Println("故障是否排除", exclude)
  1850. reason := dataBody["reason"].(string)
  1851. fmt.Println("原因", reason)
  1852. imageName := dataBody["imageName"].(string)
  1853. repair := models.DeviceRepair{
  1854. BedId: addmacher.BedId,
  1855. EquitmentId: id,
  1856. GuaranteeDate: guaDate,
  1857. StartTime: startDate.Unix(),
  1858. ArriveTime: arriveDate.Unix(),
  1859. FinishTime: finishDate.Unix(),
  1860. TotalDistance: totaldistance,
  1861. FailureStage: failurestate,
  1862. FaultDescription: faultdescription,
  1863. CauseAnalysis: causeAnalysis,
  1864. TreatmentProcess: treatmentprocess,
  1865. Images: images,
  1866. Exclude: exclude,
  1867. Reason: reason,
  1868. Status: 1,
  1869. UserOrgId: OrgID,
  1870. Ctime: time.Now().Unix(),
  1871. CodeInformation: codeInformation,
  1872. ImageName: imageName,
  1873. }
  1874. err = service.CreateRepair(&repair)
  1875. if err != nil {
  1876. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1877. return
  1878. }
  1879. this.ServeSuccessJSON(map[string]interface{}{
  1880. "repair": repair,
  1881. })
  1882. }
  1883. func (this *MachineApiController) GetAllRepair() {
  1884. limit, _ := this.GetInt64("limit")
  1885. page, _ := this.GetInt64("page")
  1886. adminUser := this.GetAdminUserInfo()
  1887. orgID := adminUser.CurrentOrgId
  1888. repair, total, err := service.GetAllRepair(orgID, limit, page)
  1889. if err != nil {
  1890. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1891. return
  1892. }
  1893. this.ServeSuccessJSON(map[string]interface{}{
  1894. "repair": repair,
  1895. "total": total,
  1896. })
  1897. }
  1898. func (this *MachineApiController) EditRepair() {
  1899. id, _ := this.GetInt64("id")
  1900. fmt.Println("id", id)
  1901. repair, err := service.EditRepair(id)
  1902. if err != nil {
  1903. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1904. return
  1905. }
  1906. this.ServeSuccessJSON(map[string]interface{}{
  1907. "repair": repair,
  1908. })
  1909. }
  1910. func (this *MachineApiController) UpdateRepair() {
  1911. timeLayout := "2006-01-02"
  1912. loc, _ := time.LoadLocation("Local")
  1913. adminUserInfo := this.GetAdminUserInfo()
  1914. OrgID := adminUserInfo.CurrentOrgId
  1915. fmt.Println("orgid", OrgID)
  1916. dataBody := make(map[string]interface{}, 0)
  1917. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1918. fmt.Println("err", err)
  1919. id := int64(dataBody["id"].(float64))
  1920. gua_date := dataBody["guarantee_date"].(string)
  1921. fmt.Println("保修日期", gua_date)
  1922. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", gua_date+" 00:00:00", loc)
  1923. guaDate := inLocation.Unix()
  1924. fmt.Println("保修日期", guaDate)
  1925. startDateStr := dataBody["start_time"].(string)
  1926. fmt.Println("出发时间", startDateStr)
  1927. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  1928. fmt.Println("触发事件", startDate.Unix())
  1929. arriveDateStr := dataBody["arrive_time"].(string)
  1930. fmt.Println("到达时间", arriveDateStr)
  1931. arriveDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", arriveDateStr)
  1932. fmt.Println("到达时间", arriveDate.Unix())
  1933. finishDateStr := dataBody["finish_time"].(string)
  1934. fmt.Println("完成时间", finishDateStr)
  1935. finishDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", finishDateStr)
  1936. fmt.Println("完成时间", finishDate.Unix())
  1937. totaldistance := dataBody["total_distance"].(string)
  1938. fmt.Println("总公里输", totaldistance)
  1939. failurestate := int64(dataBody["failure_stage"].(float64))
  1940. fmt.Println("故事范式阶段", failurestate)
  1941. codeInformation := dataBody["code_information"].(string)
  1942. fmt.Println("故事提示信息及代码", codeInformation)
  1943. faultdescription := dataBody["fault_description"].(string)
  1944. fmt.Println("故障描述", faultdescription)
  1945. causeAnalysis := dataBody["cause_analysis"].(string)
  1946. fmt.Println("原因分析", causeAnalysis)
  1947. treatmentprocess := dataBody["treatment_process"].(string)
  1948. fmt.Println("处理过程", treatmentprocess)
  1949. images := dataBody["images"].(string)
  1950. fmt.Println("上传图片", images)
  1951. exclude := int64(dataBody["exclude"].(float64))
  1952. fmt.Println("故障是否排除", exclude)
  1953. reason := dataBody["reason"].(string)
  1954. fmt.Println("原因", reason)
  1955. imageName := dataBody["image_name"].(string)
  1956. deviceRepair := models.DeviceRepair{
  1957. GuaranteeDate: guaDate,
  1958. StartTime: startDate.Unix(),
  1959. ArriveTime: arriveDate.Unix(),
  1960. FinishTime: finishDate.Unix(),
  1961. TotalDistance: totaldistance,
  1962. FailureStage: failurestate,
  1963. FaultDescription: faultdescription,
  1964. CauseAnalysis: causeAnalysis,
  1965. TreatmentProcess: treatmentprocess,
  1966. Images: images,
  1967. Exclude: exclude,
  1968. Reason: reason,
  1969. CodeInformation: codeInformation,
  1970. ImageName: imageName,
  1971. }
  1972. err = service.UpdateRepair(id, OrgID, &deviceRepair)
  1973. if err != nil {
  1974. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1975. return
  1976. }
  1977. this.ServeSuccessJSON(map[string]interface{}{
  1978. "repair": deviceRepair,
  1979. })
  1980. }
  1981. func (this *MachineApiController) DeleteRepair() {
  1982. adminUserInfo := this.GetAdminUserInfo()
  1983. OrgID := adminUserInfo.CurrentOrgId
  1984. dataBody := make(map[string]interface{}, 0)
  1985. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1986. if err != nil {
  1987. utils.ErrorLog(err.Error())
  1988. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1989. return
  1990. }
  1991. idsInters := dataBody["ids"].([]interface{})
  1992. if len(idsInters) == 0 {
  1993. if err != nil {
  1994. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  1995. return
  1996. }
  1997. }
  1998. ids := make([]int64, 0)
  1999. for _, idsInter := range idsInters {
  2000. id := int64(idsInter.(float64))
  2001. ids = append(ids, id)
  2002. }
  2003. fmt.Println("ids", ids)
  2004. err = service.DeleteRepair(OrgID, ids)
  2005. if err != nil {
  2006. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  2007. return
  2008. }
  2009. returnData := make(map[string]interface{}, 0)
  2010. returnData["msg"] = "ok"
  2011. this.ServeSuccessJSON(returnData)
  2012. return
  2013. }
  2014. func (this *MachineApiController) GetRepair() {
  2015. timeLayout := "2006-01-02"
  2016. loc, _ := time.LoadLocation("Local")
  2017. adminUserInfo := this.GetAdminUserInfo()
  2018. OrgID := adminUserInfo.CurrentOrgId
  2019. fmt.Println("orgid", OrgID)
  2020. bedid, _ := this.GetInt64("bedid")
  2021. fmt.Println("bedid", bedid)
  2022. startime := this.GetString("startime")
  2023. fmt.Println("starttime", startime)
  2024. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  2025. start := inLocation.Unix()
  2026. fmt.Println("start", start)
  2027. endtime := this.GetString("endtime")
  2028. fmt.Println("endtime", endtime)
  2029. endLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  2030. end := endLocation.Unix()
  2031. fmt.Println("end", end)
  2032. repair, err := service.GetRepair(bedid, start, end, OrgID)
  2033. if err != nil {
  2034. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  2035. return
  2036. }
  2037. this.ServeSuccessJSON(map[string]interface{}{
  2038. "repair": repair,
  2039. })
  2040. }
  2041. func (this *MachineApiController) EditUser() {
  2042. adminUser := this.GetAdminUserInfo()
  2043. orgId := adminUser.CurrentOrgId
  2044. id, _ := this.GetInt64("id")
  2045. fmt.Println("id", id)
  2046. patientid, _ := this.GetInt64("patientid")
  2047. device, err := service.GetUserInformation(id)
  2048. //获取初次使用记录
  2049. macher, err := service.GetUserTotalByMacher(device.EquimentId)
  2050. count, err := service.GetUserTotalCount(orgId, device.BedNumber)
  2051. patients, err := service.GetPatientInfoMation(patientid)
  2052. if err != nil {
  2053. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  2054. return
  2055. }
  2056. this.ServeSuccessJSON(map[string]interface{}{
  2057. "device": device,
  2058. "patients": patients,
  2059. "count": count,
  2060. "macher": macher,
  2061. })
  2062. }
  2063. func (this *MachineApiController) DeleteForm() {
  2064. adminUserInfo := this.GetAdminUserInfo()
  2065. OrgID := adminUserInfo.CurrentOrgId
  2066. dataBody := make(map[string]interface{}, 0)
  2067. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2068. if err != nil {
  2069. utils.ErrorLog(err.Error())
  2070. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  2071. return
  2072. }
  2073. idsInters := dataBody["ids"].([]interface{})
  2074. if len(idsInters) == 0 {
  2075. if err != nil {
  2076. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  2077. return
  2078. }
  2079. }
  2080. ids := make([]int64, 0)
  2081. for _, idsInter := range idsInters {
  2082. id := int64(idsInter.(float64))
  2083. ids = append(ids, id)
  2084. }
  2085. fmt.Println("ids", ids)
  2086. err = service.DeleteForm(OrgID, ids)
  2087. if err != nil {
  2088. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  2089. return
  2090. }
  2091. returnData := make(map[string]interface{}, 0)
  2092. returnData["msg"] = "ok"
  2093. this.ServeSuccessJSON(returnData)
  2094. return
  2095. }
  2096. func (this *MachineApiController) UpdateForm() {
  2097. dataBody := make(map[string]interface{}, 0)
  2098. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2099. fmt.Println("错误是", err)
  2100. adminUserInfo := this.GetAdminUserInfo()
  2101. orgid := adminUserInfo.CurrentOrgId
  2102. date := dataBody["spling_date"].(string)
  2103. timeLayout := "2006-01-02"
  2104. loc, _ := time.LoadLocation("Local")
  2105. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  2106. startdate := theTime.Unix()
  2107. fmt.Println("日期", startdate)
  2108. id := int64(dataBody["id"].(float64))
  2109. fmt.Println("id", id)
  2110. classtype := int64(dataBody["classtype"].(float64))
  2111. fmt.Println("班次", classtype)
  2112. zone := int64(dataBody["zone"].(float64))
  2113. fmt.Println("分区", zone)
  2114. bednumber := int64(dataBody["bed_number"].(float64))
  2115. fmt.Println("床位号", bednumber)
  2116. number, _ := service.GetNumbers(bednumber, orgid)
  2117. patient_id := int64(dataBody["patient_id"].(float64))
  2118. fmt.Println("患者", patient_id)
  2119. contagion := dataBody["contagion"].(string)
  2120. fmt.Println("传染病", contagion)
  2121. dialysis_mode := int64(dataBody["dialysis_mode"].(float64))
  2122. fmt.Println("透析方式", dialysis_mode)
  2123. startDateStr := dataBody["start_time"].(string)
  2124. fmt.Println("上机时间", startDateStr)
  2125. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  2126. fmt.Println("上机时间", startDate.Unix())
  2127. endDateStr := dataBody["end_time"].(string)
  2128. fmt.Println("上机时间", startDateStr)
  2129. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endDateStr)
  2130. fmt.Println("上机时间", endDate.Unix())
  2131. dialysis_time := dataBody["dialysis_time"].(string)
  2132. fmt.Println("透析时长", dialysis_time)
  2133. hyperfiletration := dataBody["hyperfiltratio"].(float64)
  2134. fmt.Println("实际超滤量", hyperfiletration)
  2135. weight_loss := dataBody["weight_loss"].(float64)
  2136. fmt.Println("体重减少", weight_loss)
  2137. warining_value := dataBody["warning_value"].(string)
  2138. fmt.Println("预警值", warining_value)
  2139. //user_total := int64(dataBody["user_total"].(float64))
  2140. user_total := dataBody["user_total"].(string)
  2141. fmt.Println("使用次数", user_total)
  2142. run := int64(dataBody["run"].(float64))
  2143. fmt.Println("运行", run)
  2144. failure_stage := int64(dataBody["failure_stage"].(float64))
  2145. fmt.Println("故事发生阶段", failure_stage)
  2146. falult_desciription := dataBody["fault_description"].(string)
  2147. fmt.Println("故障描述", falult_desciription)
  2148. code_information := dataBody["code_information"].(string)
  2149. fmt.Println("故障提示及代码", code_information)
  2150. //机器消毒
  2151. disinfect_type := int64(dataBody["disinfect_type"].(float64))
  2152. fmt.Println("消毒方式", disinfect_type)
  2153. disinfectant_type := int64(dataBody["disinfectant_type"].(float64))
  2154. fmt.Println("消毒液", disinfectant_type)
  2155. disinfection := int64(dataBody["disinfection"].(float64))
  2156. fmt.Println("消毒状态", disinfection)
  2157. machine_run := int64(dataBody["machine_run"].(float64))
  2158. fmt.Println("运行", machine_run)
  2159. //液路
  2160. fluid_path := int64(dataBody["fluid_path"].(float64))
  2161. fmt.Println("液路消毒方式", fluid_path)
  2162. disinfectant := int64(dataBody["disinfectant"].(float64))
  2163. fmt.Println("消毒液", disinfectant)
  2164. disinfection_status := int64(dataBody["disinfection_status"].(float64))
  2165. fmt.Println("消毒状态", disinfection_status)
  2166. disinfection_residue := int64(dataBody["disinfection_residue"].(float64))
  2167. fmt.Println("消毒液残留", disinfection_residue)
  2168. longtime := dataBody["longtime"].(string)
  2169. fmt.Println("消毒时长", longtime)
  2170. starttime := dataBody["starttime"].(string)
  2171. disstarttime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", starttime)
  2172. distartime := disstarttime.Unix()
  2173. if distartime < 0 {
  2174. distartime = 0
  2175. }
  2176. //fmt.Println("开始消毒时间====", distartime)
  2177. entime := dataBody["endtime"].(string)
  2178. disendtime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", entime)
  2179. diendtime := disendtime.Unix()
  2180. fmt.Println("结束消毒时间", diendtime)
  2181. if diendtime < 0 {
  2182. diendtime = 0
  2183. }
  2184. dialysis_checked := int64(dataBody["dialysis_checked"].(float64))
  2185. //fmt.Println("更换", dialysis_checked)
  2186. dialysis_name := int64(dataBody["dialysis_name"].(float64))
  2187. fmt.Println("名称", dialysis_name)
  2188. norms := dataBody["norms"].(string)
  2189. fmt.Println("规格", norms)
  2190. dialysis_concentration := int64(dataBody["dialysis_concentration"].(float64))
  2191. fmt.Println("浓度", dialysis_concentration)
  2192. germ_checked := int64(dataBody["germ_checked"].(float64))
  2193. fmt.Println("更换", germ_checked)
  2194. germ_name := int64(dataBody["germ_name"].(float64))
  2195. fmt.Println("名称", germ_name)
  2196. //germ_number := int64(dataBody["germ_number"].(float64))
  2197. germ_number := dataBody["germ_number"].(string)
  2198. fmt.Println("数量", germ_number)
  2199. clean := int64(dataBody["clean"].(float64))
  2200. fmt.Println("清洁", clean)
  2201. sign_name := int64(dataBody["sign_name"].(float64))
  2202. fmt.Println("签名", sign_name)
  2203. equitment_id := int64(dataBody["equiment_id"].(float64))
  2204. fmt.Println("设备ID", equitment_id)
  2205. addmacher := models.DeviceAddmacher{
  2206. BedId: bednumber,
  2207. }
  2208. //更新床位号
  2209. err = service.UpdateAddMacherBedID(equitment_id, orgid, &addmacher)
  2210. fmt.Println("更新设备失败", err)
  2211. //更新区号
  2212. deviceNumber := models.DeviceNumber{
  2213. ZoneID: zone,
  2214. }
  2215. err = service.UpdatedZoneID(bednumber, orgid, &deviceNumber)
  2216. fmt.Println("更新区号失败", err)
  2217. information := models.DeviceInformation{
  2218. Date: startdate,
  2219. Class: classtype,
  2220. Zone: zone,
  2221. BedNumber: bednumber,
  2222. Contagion: contagion,
  2223. DialysisMode: dialysis_mode,
  2224. StartTime: startDate.Unix(),
  2225. EndTime: endDate.Unix(),
  2226. DialysisHour: dialysis_time,
  2227. Hyperfiltratio: hyperfiletration,
  2228. WeightLoss: weight_loss,
  2229. WarningValue: warining_value,
  2230. UserTotal: user_total,
  2231. Move: run,
  2232. FailureStage: failure_stage,
  2233. FaultDescription: falult_desciription,
  2234. CodeInformation: code_information,
  2235. DisinfectantType: disinfectant_type,
  2236. DisinfectType: disinfect_type,
  2237. Disinfection: disinfection,
  2238. MachineRun: machine_run,
  2239. FluidPath: fluid_path,
  2240. Disinfectant: disinfectant,
  2241. DisinfectionStatus: disinfection_status,
  2242. DisinfectionResidue: disinfection_residue,
  2243. LongTime: longtime,
  2244. DisinfecStartime: distartime,
  2245. DisinfecEndtime: diendtime,
  2246. DialysisChecked: dialysis_checked,
  2247. DialysisName: dialysis_name,
  2248. Norms: norms,
  2249. DialysisConcentration: dialysis_concentration,
  2250. GermChecked: germ_checked,
  2251. GermName: germ_name,
  2252. GermNumber: germ_number,
  2253. Clean: clean,
  2254. SignName: sign_name,
  2255. Ctime: time.Now().Unix(),
  2256. Status: 1,
  2257. UserOrgId: orgid,
  2258. EquimentId: id,
  2259. Bed: number.Number,
  2260. PatientId: patient_id,
  2261. }
  2262. err = service.UpadateForm(id, orgid, &information)
  2263. fmt.Println("报错", err)
  2264. if err != nil {
  2265. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "修改失败:("+err.Error()+")")
  2266. return
  2267. }
  2268. this.ServeSuccessJSON(map[string]interface{}{
  2269. "information": information,
  2270. })
  2271. }
  2272. func (this *MachineApiController) QueryInfo() {
  2273. zone, _ := this.GetInt64("zone")
  2274. fmt.Println("zone", zone)
  2275. //bed, _ := this.GetInt64("bed")
  2276. //fmt.Println("bed", bed)
  2277. bed, _ := this.GetInt64("bed")
  2278. startime := this.GetString("startime")
  2279. timeLayout := "2006-01-02"
  2280. loc, _ := time.LoadLocation("Local")
  2281. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  2282. startdate := theTime.Unix()
  2283. fmt.Println("开始时间", startdate)
  2284. endtime := this.GetString("endtime")
  2285. theTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  2286. endtimes := theTimes.Unix()
  2287. fmt.Println("结束", endtimes)
  2288. limit, _ := this.GetInt64("limit")
  2289. fmt.Println("limit", limit)
  2290. page, _ := this.GetInt64("page")
  2291. fmt.Println("page", page)
  2292. adminUser := this.GetAdminUserInfo()
  2293. orgId := adminUser.CurrentOrgId
  2294. infor, total, err := service.QueryInfo(bed, startdate, endtimes, orgId, limit, page)
  2295. if err != nil {
  2296. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2297. return
  2298. }
  2299. this.ServeSuccessJSON(map[string]interface{}{
  2300. "infor": infor,
  2301. "total": total,
  2302. })
  2303. }
  2304. func (this *MachineApiController) InsertAutoData() {
  2305. id, _ := this.GetInt64("id")
  2306. addmacher, _ := service.GetBedId(id)
  2307. fmt.Println("床位号", addmacher.BedId)
  2308. adminUser := this.GetAdminUserInfo()
  2309. timeStr := time.Now().Format("2006-01-02")
  2310. timeLayout := "2006-01-02 15:04:05"
  2311. fmt.Println("timeStr:", timeStr)
  2312. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  2313. timenow := timeStringToTime.Unix()
  2314. fmt.Println("timenow是什么", timenow)
  2315. orgId := adminUser.CurrentOrgId
  2316. dialysis, err := service.GetPatientID(id, orgId, timenow)
  2317. if err != nil {
  2318. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2319. return
  2320. }
  2321. this.ServeSuccessJSON(map[string]interface{}{
  2322. "dialysis": dialysis,
  2323. })
  2324. }
  2325. func (this *MachineApiController) GetAllEquitType() {
  2326. adminUserInfo := this.GetAdminUserInfo()
  2327. orgID := adminUserInfo.CurrentOrgId
  2328. fmt.Println("orgId", orgID)
  2329. //equitname, err := service.GetAllEquitType(orgID)
  2330. //name, err := service.GetAllEquitName(orgID)
  2331. mode, err := service.GetAllMode(orgID)
  2332. fmt.Print(err)
  2333. if err != nil {
  2334. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2335. return
  2336. }
  2337. this.ServeSuccessJSON(map[string]interface{}{
  2338. "mode": mode,
  2339. })
  2340. }
  2341. func (this *MachineApiController) GetUserForm() {
  2342. id, _ := this.GetInt64("id")
  2343. fmt.Println("id是什么", id)
  2344. limit, _ := this.GetInt64("limit")
  2345. fmt.Println("limit", limit)
  2346. page, _ := this.GetInt64("page")
  2347. fmt.Println("page", page)
  2348. adminUserInfo := this.GetAdminUserInfo()
  2349. orgID := adminUserInfo.CurrentOrgId
  2350. fmt.Println("orgId", orgID)
  2351. information, total, err := service.GetUserForm(id, orgID, limit, page)
  2352. fmt.Print("information", information)
  2353. fmt.Println("错误", err)
  2354. addmacher, _ := service.GetBedNumber(id, orgID)
  2355. fmt.Println("addmacher", addmacher)
  2356. if err != nil {
  2357. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2358. return
  2359. }
  2360. this.ServeSuccessJSON(map[string]interface{}{
  2361. "information": information,
  2362. "total": total,
  2363. "addmacher": addmacher,
  2364. })
  2365. }
  2366. func (this *MachineApiController) GetBedForm() {
  2367. adminUser := this.GetAdminUserInfo()
  2368. orgId := adminUser.CurrentOrgId
  2369. id, _ := this.GetInt64("id")
  2370. fmt.Println("id", id)
  2371. addmacher, err := service.GetZoneForm(id)
  2372. bed, err := service.GetZoneId(addmacher.BedId, orgId)
  2373. fmt.Println("bed--------------------", bed.ZoneID)
  2374. number, err := service.GetBedForm(bed.ZoneID)
  2375. if err != nil {
  2376. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2377. return
  2378. }
  2379. this.ServeSuccessJSON(map[string]interface{}{
  2380. "addmacher": addmacher,
  2381. "number": number,
  2382. })
  2383. }
  2384. func (this *MachineApiController) GetTotalCount() {
  2385. info := this.GetAdminUserInfo()
  2386. orgid := info.CurrentOrgId
  2387. _, total, err := service.GetTotalCount(orgid)
  2388. fmt.Print("------------------------------声优", err)
  2389. if err != nil {
  2390. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2391. return
  2392. }
  2393. this.ServeSuccessJSON(map[string]interface{}{
  2394. "total": total,
  2395. })
  2396. }
  2397. func (this *MachineApiController) GetTotalNumber() {
  2398. id, _ := this.GetInt64("id")
  2399. fmt.Println("id", id)
  2400. info := this.GetAdminUserInfo()
  2401. orgId := info.CurrentOrgId
  2402. total, _ := service.GetTotalNumber(id, orgId)
  2403. //fmt.Println("total",total)
  2404. //fmt.Println("====================真的",err)
  2405. //if err != nil {
  2406. // this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2407. // return
  2408. //}
  2409. this.ServeSuccessJSON(map[string]interface{}{
  2410. "total": total,
  2411. })
  2412. }
  2413. func (this *MachineApiController) GetTimeWarning() {
  2414. id, _ := this.GetInt64("id")
  2415. fmt.Println("设备id", id)
  2416. adminUserInfo := this.GetAdminUserInfo()
  2417. orgId := adminUserInfo.CurrentOrgId
  2418. //获取透析机消毒液更换的最后一次更换日期
  2419. information, err := service.GetTimeWarning(id, orgId)
  2420. //获取透析机消毒液细菌过滤器的最后一次更换日期
  2421. deviceInformation, err := service.GetTimeLast(id, orgId)
  2422. //获取空气滤网清洁最后一次更换日期
  2423. clean, err := service.GetTimeLastData(id, orgId)
  2424. if err != nil {
  2425. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2426. return
  2427. }
  2428. this.ServeSuccessJSON(map[string]interface{}{
  2429. "informations": information,
  2430. "deviceInformation": deviceInformation,
  2431. "clean": clean,
  2432. })
  2433. }
  2434. func (this *MachineApiController) SaveManageinfoTwo() {
  2435. adminUserInfo := this.GetAdminUserInfo()
  2436. orgid := adminUserInfo.CurrentOrgId
  2437. fmt.Println("机构id", orgid)
  2438. dataBody := make(map[string]interface{}, 0)
  2439. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2440. fmt.Println("err", err)
  2441. serial_numbe := dataBody["serial_number"].(string)
  2442. fmt.Println("序列号", serial_numbe)
  2443. device_type := int64(dataBody["device_type"].(float64))
  2444. fmt.Println("设备类型", device_type)
  2445. //bed_number := dataBody["beds"].(string)
  2446. //fmt.Println("床位号", bed_number)
  2447. bed_number := this.GetString("beds")
  2448. device_name := dataBody["device_name"].(string)
  2449. fmt.Println("设备名称", device_name)
  2450. manufacture_factory := dataBody["manufacture_factory"].(string)
  2451. fmt.Println("生产厂家", manufacture_factory)
  2452. service_manufacturer := dataBody["service_manufacturer"].(string)
  2453. fmt.Println("维修厂家", service_manufacturer)
  2454. unit_type := int64(dataBody["unit_type"].(float64))
  2455. //unit_type := strconv.FormatInt(unittype, 10)
  2456. //fmt.Println("设备型号", unit_type)
  2457. use_section := dataBody["use_section"].(string)
  2458. fmt.Println("使用科室", use_section)
  2459. section_number := dataBody["section_number"].(string)
  2460. fmt.Println("科室编号", section_number)
  2461. buy_date := dataBody["buy_date"].(string)
  2462. fmt.Println("buy_date", buy_date)
  2463. timeLayout := "2006-01-02 15:04:05"
  2464. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  2465. buydate := theTime.Unix()
  2466. int_num := *(*int)(unsafe.Pointer(&buydate))
  2467. if int_num < 0 {
  2468. buydate = 0
  2469. }
  2470. fmt.Println("购买日期", buydate)
  2471. install_date := dataBody["install_date"].(string)
  2472. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  2473. installdate := toTime.Unix()
  2474. buy_num := *(*int)(unsafe.Pointer(&installdate))
  2475. if buy_num < 0 {
  2476. installdate = 0
  2477. }
  2478. fmt.Println("安装日期", installdate)
  2479. start_date := dataBody["start_date"].(string)
  2480. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  2481. startdate := stringToTime.Unix()
  2482. start_num := *(*int)(unsafe.Pointer(&startdate))
  2483. if start_num < 0 {
  2484. startdate = 0
  2485. }
  2486. fmt.Println("启用日期", startdate)
  2487. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  2488. fmt.Println("维修工程", maintenance_engineer)
  2489. telephone := dataBody["telephone"].(string)
  2490. fmt.Println("telephone", telephone)
  2491. guarantee_date := dataBody["guarantee_date"].(string)
  2492. fmt.Println("保修期限", guarantee_date)
  2493. machine_status := int64(dataBody["machine_status"].(float64))
  2494. fmt.Println("机器状态", machine_status)
  2495. disinfection_mode := int64(dataBody["Disinfection_mode"].(float64))
  2496. fmt.Println("消毒方式", disinfection_mode)
  2497. remarks := dataBody["remarks"].(string)
  2498. fmt.Println("备注", remarks)
  2499. rubbish_date := dataBody["rubbish_date"].(string)
  2500. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  2501. rubbishdate := timeStringToTime.Unix()
  2502. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  2503. if rubb_num < 0 {
  2504. rubbishdate = 0
  2505. }
  2506. fmt.Println("报废日期", rubbishdate)
  2507. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  2508. fmt.Println("报废原因", rubbish_reason)
  2509. user_year := dataBody["user_year"].(string)
  2510. fmt.Println("使用年限", user_year)
  2511. work_time := dataBody["work_time"].(string)
  2512. fmt.Println("工作时长", work_time)
  2513. revers := int64(dataBody["revers_mode"].(float64))
  2514. fmt.Println("反渗模式", revers)
  2515. addmacher := &models.DeviceAddmacher{
  2516. SerialNumber: serial_numbe,
  2517. DeviceType: device_type,
  2518. BedNumber: bed_number,
  2519. DeviceName: device_name,
  2520. ManufactureFactory: manufacture_factory,
  2521. ServiceManufacturer: service_manufacturer,
  2522. UnitType: unit_type,
  2523. UseSection: use_section,
  2524. SectionNumber: section_number,
  2525. BuyDate: buydate,
  2526. InstallDate: installdate,
  2527. StartDate: startdate,
  2528. MaintenaceEngineer: maintenance_engineer,
  2529. Telephone: telephone,
  2530. GuaranteeDate: guarantee_date,
  2531. MachineStatus: machine_status,
  2532. DisinfectionMode: disinfection_mode,
  2533. Remarks: remarks,
  2534. RubbishDate: rubbishdate,
  2535. RubbishReason: rubbish_reason,
  2536. UserYear: user_year,
  2537. WorkTime: work_time,
  2538. ReversMode: revers,
  2539. Status: 1,
  2540. Ctime: time.Now().Unix(),
  2541. UserOrgId: orgid,
  2542. }
  2543. err = service.CreateMacher(addmacher)
  2544. fmt.Println("什么原因啊", err)
  2545. if err != nil {
  2546. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2547. return
  2548. }
  2549. this.ServeSuccessJSON(map[string]interface{}{
  2550. "addmacher": addmacher,
  2551. })
  2552. }
  2553. func (this *MachineApiController) GetAllpatient() {
  2554. adminUserInfo := this.GetAdminUserInfo()
  2555. orgid := adminUserInfo.CurrentOrgId
  2556. allpatient, err := service.GetAllpatient(orgid)
  2557. fmt.Print(err)
  2558. if err != nil {
  2559. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2560. return
  2561. }
  2562. this.ServeSuccessJSON(map[string]interface{}{
  2563. "allpatient": allpatient,
  2564. })
  2565. }
  2566. func (this *MachineApiController) ChangeBed() {
  2567. id, _ := this.GetInt64("id")
  2568. fmt.Print("id", id)
  2569. info := this.GetAdminUserInfo()
  2570. orgId := info.CurrentOrgId
  2571. bed, err := service.ChangeBed(id, orgId)
  2572. if err != nil {
  2573. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2574. return
  2575. }
  2576. this.ServeSuccessJSON(map[string]interface{}{
  2577. "bed": bed,
  2578. })
  2579. }
  2580. func (this *MachineApiController) GetPatientDetail() {
  2581. id, _ := this.GetInt64("id")
  2582. fmt.Print("id", id)
  2583. info := this.GetAdminUserInfo()
  2584. orgid := info.CurrentOrgId
  2585. patient, err := service.GetPatientDetail(id, orgid)
  2586. if err != nil {
  2587. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2588. return
  2589. }
  2590. this.ServeSuccessJSON(map[string]interface{}{
  2591. "patient": patient,
  2592. })
  2593. }
  2594. func (this *MachineApiController) SaveReminder() {
  2595. id, _ := this.GetInt64("id")
  2596. fmt.Print("码字", id)
  2597. info := this.GetAdminUserInfo()
  2598. orgId := info.CurrentOrgId
  2599. remander := models.DeviceRemander{
  2600. IsRun: id,
  2601. Status: 1,
  2602. UserOrgId: orgId,
  2603. Ctime: time.Now().Unix(),
  2604. }
  2605. data, errs := service.GetRemanderData(orgId)
  2606. if errs == gorm.ErrRecordNotFound {
  2607. err := service.CreateRemander(&remander).Error()
  2608. fmt.Print(err)
  2609. } else if errs == nil {
  2610. deviceRemander := models.DeviceRemander{
  2611. ID: data.ID,
  2612. IsRun: id,
  2613. Status: 1,
  2614. UserOrgId: orgId,
  2615. Mtime: time.Now().Unix(),
  2616. }
  2617. err := service.UpdateRemander(&deviceRemander)
  2618. if err != nil {
  2619. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2620. return
  2621. }
  2622. }
  2623. this.ServeSuccessJSON(map[string]interface{}{
  2624. "id": id,
  2625. })
  2626. return
  2627. }
  2628. func (this *MachineApiController) GetRemanderData() {
  2629. info := this.GetAdminUserInfo()
  2630. orgid := info.CurrentOrgId
  2631. data, err := service.GetRemanderData(orgid)
  2632. if err != nil {
  2633. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2634. return
  2635. }
  2636. this.ServeSuccessJSON(map[string]interface{}{
  2637. "remander": data,
  2638. })
  2639. }
  2640. func (this *MachineApiController) OpenDelete() {
  2641. id, _ := this.GetInt64("id")
  2642. err := service.DeletePlan(id)
  2643. if err != nil {
  2644. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2645. return
  2646. }
  2647. returnData := make(map[string]interface{}, 0)
  2648. returnData["msg"] = "ok"
  2649. this.ServeSuccessJSON(returnData)
  2650. return
  2651. }
  2652. func (this *MachineApiController) DeleteUserLogin() {
  2653. id, _ := this.GetInt64("id")
  2654. err := service.DeleteUserLogin(id)
  2655. if err != nil {
  2656. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2657. return
  2658. }
  2659. returnData := make(map[string]interface{}, 0)
  2660. returnData["msg"] = "ok"
  2661. this.ServeSuccessJSON(returnData)
  2662. return
  2663. }
  2664. func (this *MachineApiController) DeleteCultrues() {
  2665. id, _ := this.GetInt64("id")
  2666. err := service.DeleteCultrues(id)
  2667. if err != nil {
  2668. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2669. return
  2670. }
  2671. returnData := make(map[string]interface{}, 0)
  2672. returnData["msg"] = "ok"
  2673. this.ServeSuccessJSON(returnData)
  2674. return
  2675. }
  2676. func (this *MachineApiController) DeleteDialystates() {
  2677. id, _ := this.GetInt64("id")
  2678. err := service.DeleteDialystates(id)
  2679. if err != nil {
  2680. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2681. return
  2682. }
  2683. returnData := make(map[string]interface{}, 0)
  2684. returnData["msg"] = "ok"
  2685. this.ServeSuccessJSON(returnData)
  2686. return
  2687. }
  2688. func (this *MachineApiController) Deleteions() {
  2689. id, _ := this.GetInt64("id")
  2690. err := service.DeleteIons(id)
  2691. if err != nil {
  2692. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2693. return
  2694. }
  2695. returnData := make(map[string]interface{}, 0)
  2696. returnData["msg"] = "ok"
  2697. this.ServeSuccessJSON(returnData)
  2698. return
  2699. }
  2700. func (this *MachineApiController) DeleteRepairs() {
  2701. id, _ := this.GetInt64("id")
  2702. err := service.DeleteRepairs(id)
  2703. if err != nil {
  2704. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2705. return
  2706. }
  2707. returnData := make(map[string]interface{}, 0)
  2708. returnData["msg"] = "ok"
  2709. this.ServeSuccessJSON(returnData)
  2710. return
  2711. }
  2712. func (this *MachineApiController) SaveMode() {
  2713. adminUserInfo := this.GetAdminUserInfo()
  2714. orgid := adminUserInfo.CurrentOrgId
  2715. fmt.Println("机构id", orgid)
  2716. dataBody := make(map[string]interface{}, 0)
  2717. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2718. fmt.Println("err", err)
  2719. device_mode := dataBody["device_mode"].(string)
  2720. mode := models.DeviceMode{
  2721. DeviceMode: device_mode,
  2722. UserOrgId: orgid,
  2723. Status: 1,
  2724. Ctime: time.Now().Unix(),
  2725. }
  2726. _, errcode := service.GetMode(device_mode, orgid)
  2727. if errcode == gorm.ErrRecordNotFound {
  2728. err = service.SaveMode(&mode)
  2729. } else if errcode == nil {
  2730. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2731. return
  2732. } else {
  2733. }
  2734. if err != nil {
  2735. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2736. return
  2737. }
  2738. this.ServeSuccessJSON(map[string]interface{}{
  2739. "mode": mode,
  2740. })
  2741. }
  2742. func (this *MachineApiController) GetAllMode() {
  2743. fmt.Println("进来了没哟")
  2744. adminUserInfo := this.GetAdminUserInfo()
  2745. orgid := adminUserInfo.CurrentOrgId
  2746. mode, err := service.GetAllMode(orgid)
  2747. if err != nil {
  2748. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2749. return
  2750. }
  2751. this.ServeSuccessJSON(map[string]interface{}{
  2752. "mode": mode,
  2753. })
  2754. }
  2755. func (this *MachineApiController) EditMode() {
  2756. id, _ := this.GetInt64("id")
  2757. mode, err := service.GetModeById(id)
  2758. if err != nil {
  2759. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2760. return
  2761. }
  2762. this.ServeSuccessJSON(map[string]interface{}{
  2763. "mode": mode,
  2764. })
  2765. }
  2766. func (this *MachineApiController) UpdateMode() {
  2767. id, _ := this.GetInt64("id")
  2768. dataBody := make(map[string]interface{}, 0)
  2769. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2770. fmt.Println("err", err)
  2771. device_mode := dataBody["device_mode"].(string)
  2772. mode := models.DeviceMode{DeviceMode: device_mode}
  2773. err = service.UpdateMode(id, mode)
  2774. if err != nil {
  2775. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2776. return
  2777. }
  2778. this.ServeSuccessJSON(map[string]interface{}{
  2779. "mode": mode,
  2780. })
  2781. }
  2782. func (this *MachineApiController) DeleteMode() {
  2783. id, _ := this.GetInt64("id")
  2784. adminUserInfo := this.GetAdminUserInfo()
  2785. orgid := adminUserInfo.CurrentOrgId
  2786. _, errcode := service.QueryDeviceMode(id, orgid)
  2787. if errcode == gorm.ErrRecordNotFound {
  2788. service.DeleteMode(id)
  2789. returnData := make(map[string]interface{}, 0)
  2790. returnData["msg"] = "ok"
  2791. this.ServeSuccessJSON(returnData)
  2792. return
  2793. } else if errcode == nil {
  2794. return
  2795. } else {
  2796. fmt.Print("设备型号已存在")
  2797. }
  2798. }
  2799. func (this *MachineApiController) SelectChange() {
  2800. id, _ := this.GetInt64("id")
  2801. adminUserInfo := this.GetAdminUserInfo()
  2802. orgid := adminUserInfo.CurrentOrgId
  2803. change, err := service.SelectChange(id, orgid)
  2804. //fmt.Print("---------------------------", err)
  2805. if err != nil {
  2806. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2807. return
  2808. }
  2809. this.ServeSuccessJSON(map[string]interface{}{
  2810. "change": change,
  2811. })
  2812. }
  2813. func (this *MachineApiController) SelectBed() {
  2814. id, _ := this.GetInt64("id")
  2815. adminUserInfo := this.GetAdminUserInfo()
  2816. orgid := adminUserInfo.CurrentOrgId
  2817. bed, err := service.SelectBed(id, orgid)
  2818. if err != nil {
  2819. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2820. return
  2821. }
  2822. this.ServeSuccessJSON(map[string]interface{}{
  2823. "zone": bed,
  2824. })
  2825. }
  2826. func (this *MachineApiController) GetTimeData() {
  2827. equitid, _ := this.GetInt64("equitid")
  2828. fmt.Print("equitid", equitid)
  2829. timeLayout := "2006-01-02 15:04:05"
  2830. todaytime := this.GetString("todaytime")
  2831. theTime, _ := utils.ParseTimeStringToTime(timeLayout, todaytime+" 00:00:00")
  2832. fmt.Print("时间", theTime.Unix())
  2833. adminUserInfo := this.GetAdminUserInfo()
  2834. orgid := adminUserInfo.CurrentOrgId
  2835. timeData, err := service.GetTimeData(equitid, orgid, theTime.Unix())
  2836. fmt.Print("报错", err)
  2837. timeDataTwo, err := service.GetTimeTwo(equitid, orgid, theTime.Unix())
  2838. timeDataThree, err := service.GetTimeThree(equitid, orgid, theTime.Unix())
  2839. fmt.Print("err报错了没有", err)
  2840. if err != nil {
  2841. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2842. return
  2843. }
  2844. this.ServeSuccessJSON(map[string]interface{}{
  2845. "timeData": timeData,
  2846. "timeDataTwo": timeDataTwo,
  2847. "timeDataThree": timeDataThree,
  2848. })
  2849. }
  2850. func (this *MachineApiController) DeleteImages() {
  2851. id, _ := this.GetInt64("id")
  2852. err := service.DeleteImages(id)
  2853. fmt.Print("err", err)
  2854. if err != nil {
  2855. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2856. return
  2857. }
  2858. returnData := make(map[string]interface{}, 0)
  2859. returnData["msg"] = "ok"
  2860. this.ServeSuccessJSON(returnData)
  2861. return
  2862. }
  2863. func (this *MachineApiController) GetUserMachTotalCount() {
  2864. adminUserInfo := this.GetAdminUserInfo()
  2865. orgid := adminUserInfo.CurrentOrgId
  2866. count, err := service.GetUserMachTotalCount(orgid)
  2867. if err != nil {
  2868. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2869. return
  2870. }
  2871. this.ServeSuccessJSON(map[string]interface{}{
  2872. "count": count,
  2873. })
  2874. }
  2875. func (this *MachineApiController) GetUserTotalCount() {
  2876. adminUserInfo := this.GetAdminUserInfo()
  2877. orgid := adminUserInfo.CurrentOrgId
  2878. id, _ := this.GetInt64("id")
  2879. count, err := service.GetUserTotalCount(orgid, id)
  2880. addmacher, err := service.GetUserTotal(orgid, id)
  2881. if err != nil {
  2882. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2883. return
  2884. }
  2885. this.ServeSuccessJSON(map[string]interface{}{
  2886. "count": count,
  2887. "addmacher": addmacher,
  2888. })
  2889. }
  2890. func (this *MachineApiController) DeleteManagement() {
  2891. id, _ := this.GetInt64("id")
  2892. _, err := service.DeleteEquit(id)
  2893. if err != nil {
  2894. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2895. return
  2896. }
  2897. returnData := make(map[string]interface{}, 0)
  2898. returnData["msg"] = "ok"
  2899. this.ServeSuccessJSON(returnData)
  2900. return
  2901. }