manage_api_controller.go 105KB

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