manage_api_controller.go 106KB

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