manage_api_controller.go 105KB

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