manage_api_controller.go 135KB

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