manage_api_controller.go 218KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356235723582359236023612362236323642365236623672368236923702371237223732374237523762377237823792380238123822383238423852386238723882389239023912392239323942395239623972398239924002401240224032404240524062407240824092410241124122413241424152416241724182419242024212422242324242425242624272428242924302431243224332434243524362437243824392440244124422443244424452446244724482449245024512452245324542455245624572458245924602461246224632464246524662467246824692470247124722473247424752476247724782479248024812482248324842485248624872488248924902491249224932494249524962497249824992500250125022503250425052506250725082509251025112512251325142515251625172518251925202521252225232524252525262527252825292530253125322533253425352536253725382539254025412542254325442545254625472548254925502551255225532554255525562557255825592560256125622563256425652566256725682569257025712572257325742575257625772578257925802581258225832584258525862587258825892590259125922593259425952596259725982599260026012602260326042605260626072608260926102611261226132614261526162617261826192620262126222623262426252626262726282629263026312632263326342635263626372638263926402641264226432644264526462647264826492650265126522653265426552656265726582659266026612662266326642665266626672668266926702671267226732674267526762677267826792680268126822683268426852686268726882689269026912692269326942695269626972698269927002701270227032704270527062707270827092710271127122713271427152716271727182719272027212722272327242725272627272728272927302731273227332734273527362737273827392740274127422743274427452746274727482749275027512752275327542755275627572758275927602761276227632764276527662767276827692770277127722773277427752776277727782779278027812782278327842785278627872788278927902791279227932794279527962797279827992800280128022803280428052806280728082809281028112812281328142815281628172818281928202821282228232824282528262827282828292830283128322833283428352836283728382839284028412842284328442845284628472848284928502851285228532854285528562857285828592860286128622863286428652866286728682869287028712872287328742875287628772878287928802881288228832884288528862887288828892890289128922893289428952896289728982899290029012902290329042905290629072908290929102911291229132914291529162917291829192920292129222923292429252926292729282929293029312932293329342935293629372938293929402941294229432944294529462947294829492950295129522953295429552956295729582959296029612962296329642965296629672968296929702971297229732974297529762977297829792980298129822983298429852986298729882989299029912992299329942995299629972998299930003001300230033004300530063007300830093010301130123013301430153016301730183019302030213022302330243025302630273028302930303031303230333034303530363037303830393040304130423043304430453046304730483049305030513052305330543055305630573058305930603061306230633064306530663067306830693070307130723073307430753076307730783079308030813082308330843085308630873088308930903091309230933094309530963097309830993100310131023103310431053106310731083109311031113112311331143115311631173118311931203121312231233124312531263127312831293130313131323133313431353136313731383139314031413142314331443145314631473148314931503151315231533154315531563157315831593160316131623163316431653166316731683169317031713172317331743175317631773178317931803181318231833184318531863187318831893190319131923193319431953196319731983199320032013202320332043205320632073208320932103211321232133214321532163217321832193220322132223223322432253226322732283229323032313232323332343235323632373238323932403241324232433244324532463247324832493250325132523253325432553256325732583259326032613262326332643265326632673268326932703271327232733274327532763277327832793280328132823283328432853286328732883289329032913292329332943295329632973298329933003301330233033304330533063307330833093310331133123313331433153316331733183319332033213322332333243325332633273328332933303331333233333334333533363337333833393340334133423343334433453346334733483349335033513352335333543355335633573358335933603361336233633364336533663367336833693370337133723373337433753376337733783379338033813382338333843385338633873388338933903391339233933394339533963397339833993400340134023403340434053406340734083409341034113412341334143415341634173418341934203421342234233424342534263427342834293430343134323433343434353436343734383439344034413442344334443445344634473448344934503451345234533454345534563457345834593460346134623463346434653466346734683469347034713472347334743475347634773478347934803481348234833484348534863487348834893490349134923493349434953496349734983499350035013502350335043505350635073508350935103511351235133514351535163517351835193520352135223523352435253526352735283529353035313532353335343535353635373538353935403541354235433544354535463547354835493550355135523553355435553556355735583559356035613562356335643565356635673568356935703571357235733574357535763577357835793580358135823583358435853586358735883589359035913592359335943595359635973598359936003601360236033604360536063607360836093610361136123613361436153616361736183619362036213622362336243625362636273628362936303631363236333634363536363637363836393640364136423643364436453646364736483649365036513652365336543655365636573658365936603661366236633664366536663667366836693670367136723673367436753676367736783679368036813682368336843685368636873688368936903691369236933694369536963697369836993700370137023703370437053706370737083709371037113712371337143715371637173718371937203721372237233724372537263727372837293730373137323733373437353736373737383739374037413742374337443745374637473748374937503751375237533754375537563757375837593760376137623763376437653766376737683769377037713772377337743775377637773778377937803781378237833784378537863787378837893790379137923793379437953796379737983799380038013802380338043805380638073808380938103811381238133814381538163817381838193820382138223823382438253826382738283829383038313832383338343835383638373838383938403841384238433844384538463847384838493850385138523853385438553856385738583859386038613862386338643865386638673868386938703871387238733874387538763877387838793880388138823883388438853886388738883889389038913892389338943895389638973898389939003901390239033904390539063907390839093910391139123913391439153916391739183919392039213922392339243925392639273928392939303931393239333934393539363937393839393940394139423943394439453946394739483949395039513952395339543955395639573958395939603961396239633964396539663967396839693970397139723973397439753976397739783979398039813982398339843985398639873988398939903991399239933994399539963997399839994000400140024003400440054006400740084009401040114012401340144015401640174018401940204021402240234024402540264027402840294030403140324033403440354036403740384039404040414042404340444045404640474048404940504051405240534054405540564057405840594060406140624063406440654066406740684069407040714072407340744075407640774078407940804081408240834084408540864087408840894090409140924093409440954096409740984099410041014102410341044105410641074108410941104111411241134114411541164117411841194120412141224123412441254126412741284129413041314132413341344135413641374138413941404141414241434144414541464147414841494150415141524153415441554156415741584159416041614162416341644165416641674168416941704171417241734174417541764177417841794180418141824183418441854186418741884189419041914192419341944195419641974198419942004201420242034204420542064207420842094210421142124213421442154216421742184219422042214222422342244225422642274228422942304231423242334234423542364237423842394240424142424243424442454246424742484249425042514252425342544255425642574258425942604261426242634264426542664267426842694270427142724273427442754276427742784279428042814282428342844285428642874288428942904291429242934294429542964297429842994300430143024303430443054306430743084309431043114312431343144315431643174318431943204321432243234324432543264327432843294330433143324333433443354336433743384339434043414342434343444345434643474348434943504351435243534354435543564357435843594360436143624363436443654366436743684369437043714372437343744375437643774378437943804381438243834384438543864387438843894390439143924393439443954396439743984399440044014402440344044405440644074408440944104411441244134414441544164417441844194420442144224423442444254426442744284429443044314432443344344435443644374438443944404441444244434444444544464447444844494450445144524453445444554456445744584459446044614462446344644465446644674468446944704471447244734474447544764477447844794480448144824483448444854486448744884489449044914492449344944495449644974498449945004501450245034504450545064507450845094510451145124513451445154516451745184519452045214522452345244525452645274528452945304531453245334534453545364537453845394540454145424543454445454546454745484549455045514552455345544555455645574558455945604561456245634564456545664567456845694570457145724573457445754576457745784579458045814582458345844585458645874588458945904591459245934594459545964597459845994600460146024603460446054606460746084609461046114612461346144615461646174618461946204621462246234624462546264627462846294630463146324633463446354636463746384639464046414642464346444645464646474648464946504651465246534654465546564657465846594660466146624663466446654666466746684669467046714672467346744675467646774678467946804681468246834684468546864687468846894690469146924693469446954696469746984699470047014702470347044705470647074708470947104711471247134714471547164717471847194720472147224723472447254726472747284729473047314732473347344735473647374738473947404741474247434744474547464747474847494750475147524753475447554756475747584759476047614762476347644765476647674768476947704771477247734774477547764777477847794780478147824783478447854786478747884789479047914792479347944795479647974798479948004801480248034804480548064807480848094810481148124813481448154816481748184819482048214822482348244825482648274828482948304831483248334834483548364837483848394840484148424843484448454846484748484849485048514852485348544855485648574858485948604861486248634864486548664867486848694870487148724873487448754876487748784879488048814882488348844885488648874888488948904891489248934894489548964897489848994900490149024903490449054906490749084909491049114912491349144915491649174918491949204921492249234924492549264927492849294930493149324933493449354936493749384939494049414942494349444945494649474948494949504951495249534954495549564957495849594960496149624963496449654966496749684969497049714972497349744975497649774978497949804981498249834984498549864987498849894990499149924993499449954996499749984999500050015002500350045005500650075008500950105011501250135014501550165017501850195020502150225023502450255026502750285029503050315032503350345035503650375038503950405041504250435044504550465047504850495050505150525053505450555056505750585059506050615062506350645065506650675068506950705071507250735074507550765077507850795080508150825083508450855086508750885089509050915092509350945095509650975098509951005101510251035104510551065107510851095110511151125113511451155116511751185119512051215122512351245125512651275128512951305131513251335134513551365137513851395140514151425143514451455146514751485149515051515152515351545155515651575158515951605161516251635164516551665167516851695170517151725173517451755176517751785179518051815182518351845185518651875188518951905191519251935194519551965197519851995200520152025203520452055206520752085209521052115212521352145215521652175218521952205221522252235224522552265227522852295230523152325233523452355236523752385239524052415242524352445245524652475248524952505251525252535254525552565257525852595260526152625263526452655266526752685269527052715272527352745275527652775278527952805281528252835284528552865287528852895290529152925293529452955296529752985299530053015302530353045305530653075308530953105311531253135314531553165317531853195320532153225323532453255326532753285329533053315332533353345335533653375338533953405341534253435344534553465347534853495350535153525353535453555356535753585359536053615362536353645365536653675368536953705371537253735374537553765377537853795380538153825383538453855386538753885389539053915392539353945395539653975398539954005401540254035404540554065407540854095410541154125413541454155416541754185419542054215422542354245425542654275428542954305431543254335434543554365437543854395440544154425443544454455446544754485449545054515452545354545455545654575458545954605461546254635464546554665467546854695470547154725473547454755476547754785479548054815482548354845485548654875488548954905491549254935494549554965497549854995500550155025503550455055506550755085509551055115512551355145515551655175518551955205521552255235524552555265527552855295530553155325533553455355536553755385539554055415542554355445545554655475548554955505551555255535554555555565557555855595560556155625563556455655566556755685569557055715572557355745575557655775578557955805581558255835584558555865587558855895590559155925593559455955596559755985599560056015602560356045605560656075608560956105611561256135614561556165617561856195620562156225623562456255626562756285629563056315632563356345635563656375638563956405641564256435644564556465647564856495650565156525653565456555656565756585659566056615662566356645665566656675668566956705671567256735674567556765677567856795680568156825683568456855686568756885689569056915692569356945695569656975698569957005701570257035704570557065707570857095710571157125713571457155716571757185719572057215722572357245725572657275728572957305731573257335734573557365737573857395740574157425743574457455746574757485749575057515752575357545755575657575758575957605761576257635764576557665767576857695770577157725773577457755776577757785779578057815782578357845785578657875788578957905791579257935794579557965797579857995800580158025803580458055806580758085809581058115812581358145815581658175818581958205821582258235824582558265827582858295830583158325833583458355836583758385839584058415842584358445845584658475848584958505851585258535854585558565857585858595860586158625863586458655866586758685869587058715872587358745875587658775878587958805881588258835884588558865887588858895890589158925893589458955896589758985899590059015902590359045905590659075908590959105911591259135914591559165917591859195920592159225923592459255926592759285929593059315932593359345935593659375938593959405941594259435944594559465947594859495950595159525953595459555956595759585959596059615962596359645965596659675968596959705971597259735974597559765977597859795980598159825983598459855986598759885989599059915992599359945995599659975998599960006001600260036004600560066007600860096010601160126013601460156016601760186019602060216022602360246025602660276028602960306031603260336034603560366037603860396040604160426043604460456046604760486049605060516052605360546055605660576058605960606061606260636064606560666067606860696070607160726073607460756076607760786079608060816082608360846085608660876088608960906091609260936094609560966097609860996100610161026103610461056106610761086109611061116112611361146115611661176118611961206121612261236124612561266127612861296130613161326133613461356136613761386139614061416142614361446145614661476148614961506151615261536154615561566157615861596160616161626163616461656166616761686169617061716172617361746175617661776178617961806181618261836184618561866187618861896190619161926193619461956196619761986199620062016202620362046205620662076208620962106211621262136214621562166217621862196220622162226223622462256226622762286229623062316232623362346235623662376238623962406241624262436244624562466247624862496250625162526253625462556256625762586259626062616262626362646265626662676268626962706271627262736274627562766277627862796280628162826283628462856286628762886289629062916292629362946295629662976298629963006301630263036304630563066307630863096310631163126313631463156316631763186319632063216322632363246325632663276328632963306331633263336334633563366337633863396340634163426343634463456346634763486349635063516352635363546355635663576358635963606361636263636364
  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. beego.Router("/api/manage/getalldoctorlist", &MachineApiController{}, "Get:GetAllDoctorList")
  124. beego.Router("/api/manage/savewaterlist", &MachineApiController{}, "Post:SaveWaterList")
  125. beego.Router("/api/manage/getwaterformlist", &MachineApiController{}, "Get:GetWaterFormList")
  126. beego.Router("/api/manage/dialysisdeletewater", &MachineApiController{}, "Get:DeleteDialysisWater")
  127. beego.Router("/api/manage/getdialysiswaterdetail", &MachineApiController{}, "Get:GetDialysisWaterDetail")
  128. beego.Router("/api/manage/updatedialysiswater", &MachineApiController{}, "Post:UpdateDialysisWater")
  129. beego.Router("/api/manage/deletebatchdialysiswater", &MachineApiController{}, "Delete:DeleteBatchDialysisWater")
  130. beego.Router("/api/manage/savenewairdisinfect", &MachineApiController{}, "Post:SaveNewAirDisInfect")
  131. beego.Router("/api/manage/getnewairdisinfectlist", &MachineApiController{}, "Get:GetNewAirDisinfectList")
  132. beego.Router("/api/manage/getnewairdisinfectbyidlist", &MachineApiController{}, "Get:GetNewAirDisinfectByIdList")
  133. beego.Router("/api/manage/updatenewairdisinfect", &MachineApiController{}, "Post:UpdateNewAirDisInfect")
  134. beego.Router("/api/manage/deletenewairdisinfect", &MachineApiController{}, "Get:DeleteNewAirDisinfect")
  135. beego.Router("/api/manage/saveobjtabledisinfect", &MachineApiController{}, "Post:SaveObjTableDisInfect")
  136. beego.Router("/api/manage/getobjcttabledisinfectlist", &MachineApiController{}, "Get:GetObjectTableDisinfectList")
  137. beego.Router("/api/manage/getobjecttabledisinfectbyidlist", &MachineApiController{}, "Get:GetObjectTableDisinfectByList")
  138. beego.Router("/api/manage/updateobjecttabledisinfect", &MachineApiController{}, "Post:UpdateObjectTableDisinfect")
  139. beego.Router("/api/manage/deleteobjecttabledisinfect", &MachineApiController{}, "Get:DeleteObjectTableDisinfect")
  140. beego.Router("/api/manage/getairdisinfectionlongtime", &MachineApiController{}, "Get:GetAirDisinfectionLongTime")
  141. beego.Router("/api/manage/getobjcttabledisinfectlongtime", &MachineApiController{}, "Get:GetObjectDisInfectionLongTime")
  142. beego.Router("/api/manage/getinformationmanalist", &MachineApiController{}, "Get:GetInformationmanalist")
  143. beego.Router("/api/manage/saveobjectregistration", &MachineApiController{}, "Post:SaveObjectRegistration")
  144. beego.Router("/api/manage/getregistrationdisinfectlist", &MachineApiController{}, "Get:GetRegistrationDisinfectList")
  145. beego.Router("/api/manage/getobjectregistrationbyidlist", &MachineApiController{}, "Get:GetObjectRegistrationByIdList")
  146. beego.Router("/api/manage/updateobjectregistration", &MachineApiController{}, "Post:UpdateObjectRegistration")
  147. beego.Router("/api/manage/deleteobjectregistration", &MachineApiController{}, "Get:DeleteObjectTregistration")
  148. beego.Router("/api/manage/getregistgoodinforlist", &MachineApiController{}, "Get:GetRegistGoodInforList")
  149. beego.Router("/api/manage/getregistnumber", &MachineApiController{}, "Get:GetRegistNumber")
  150. beego.Router("/api/manage/savesetairdisinfect", &MachineApiController{}, "Get:SaveSetAirDisInfect")
  151. beego.Router("/api/manage/getsetairinfectbyid", &MachineApiController{}, "Get:GetSetAirInfectById")
  152. beego.Router("/api/manage/savenewairwaydisinfect", &MachineApiController{}, "Post:SaveNewAirWayDisinfect")
  153. beego.Router("/api/manage/getnewairwaydisinfectlist", &MachineApiController{}, "Get:GetNewAirWayDisinfectList")
  154. beego.Router("/api/manage/getairdisinfectwaylongtime", &MachineApiController{}, "Get:GetAirDisinfectWayLongTime")
  155. beego.Router("/api/manage/getnewairwaydisinfectbyidlist", &MachineApiController{}, "Get:GetNewAirWayDisinfectByIdList")
  156. beego.Router("/api/manage/updatenewairwaydisinfect", &MachineApiController{}, "Post:UpdateNewAirWayDisInfect")
  157. beego.Router("/api/manage/deletenewairwaydisinfect", &MachineApiController{}, "Get:DeleteNewAirWayDisinfect")
  158. beego.Router("/api/manage/setobjectdisinfect", &MachineApiController{}, "Get:SaveSetObjectDisinfect")
  159. beego.Router("/api/manage/getobjectwaydisinfect", &MachineApiController{}, "Get:GetObjectWayDisinect")
  160. beego.Router("/api/manage/saveobjectwaytabledisinfect", &MachineApiController{}, "Post:SaveObjectWayTableDisinfect")
  161. beego.Router("/api/manage/getobjcettabledisinfectwaylist", &MachineApiController{}, "Get:GetObjectAbleDisInfectWayList")
  162. beego.Router("/api/manage/getobjecttabledisinfectwaybylist", &MachineApiController{}, "Get:GetObjectAbledDisInfectWayById")
  163. beego.Router("/api/manage/updateobjectwaytabledisinfect", &MachineApiController{}, "Post:UpdateObjectWayAbleDisinfect")
  164. beego.Router("/api/manage/deleteobjecttablewaydisinfect", &MachineApiController{}, "Get:DeleteObjectAbleWayDisinfect")
  165. }
  166. func (this *MachineApiController) SaveManageInfo() {
  167. adminUserInfo := this.GetAdminUserInfo()
  168. orgid := adminUserInfo.CurrentOrgId
  169. dataBody := make(map[string]interface{}, 0)
  170. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  171. serial_numbe := dataBody["serial_number"].(string)
  172. device_type := int64(dataBody["device_type"].(float64))
  173. bed_number := int64(dataBody["bed_number"].(float64))
  174. //通过床位id获取区号id
  175. number, err := service.GetZoneId(bed_number, orgid)
  176. device_name := dataBody["device_name"].(string)
  177. manufacture_factory := dataBody["manufacture_factory"].(string)
  178. service_manufacturer := dataBody["service_manufacturer"].(string)
  179. unittype := int64(dataBody["unit_type"].(float64))
  180. unit_type := strconv.FormatInt(unittype, 10)
  181. use_section := dataBody["use_section"].(string)
  182. section_number := dataBody["section_number"].(string)
  183. buy_date := dataBody["buy_date"].(string)
  184. timeLayout := "2006-01-02 15:04:05"
  185. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  186. buydate := theTime.Unix()
  187. int_num := *(*int)(unsafe.Pointer(&buydate))
  188. if int_num < 0 {
  189. buydate = 0
  190. }
  191. install_date := dataBody["install_date"].(string)
  192. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  193. installdate := toTime.Unix()
  194. buy_num := *(*int)(unsafe.Pointer(&installdate))
  195. if buy_num < 0 {
  196. installdate = 0
  197. }
  198. start_date := dataBody["start_date"].(string)
  199. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  200. startdate := stringToTime.Unix()
  201. start_num := *(*int)(unsafe.Pointer(&startdate))
  202. if start_num < 0 {
  203. startdate = 0
  204. }
  205. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  206. telephone := dataBody["telephone"].(string)
  207. guarantee_date := dataBody["guarantee_date"].(string)
  208. machine_status := int64(dataBody["machine_status"].(float64))
  209. user_total := dataBody["user_total"].(string)
  210. disinfection_mode := int64(dataBody["Disinfection_mode"].(float64))
  211. remarks := dataBody["remarks"].(string)
  212. rubbish_date := dataBody["rubbish_date"].(string)
  213. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  214. rubbishdate := timeStringToTime.Unix()
  215. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  216. if rubb_num < 0 {
  217. rubbishdate = 0
  218. }
  219. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  220. user_year := dataBody["user_year"].(string)
  221. work_time := dataBody["work_time"].(string)
  222. treat_types := dataBody["treat_type"].([]interface{})
  223. revers := int64(dataBody["revers_mode"].(float64))
  224. zone_id := int64(dataBody["zone_id"].(float64))
  225. ids := make([]int64, 0)
  226. for _, treat := range treat_types {
  227. id := int64(treat.(float64))
  228. ids = append(ids, id)
  229. }
  230. //查询机位号是否绑定设备
  231. thisAddmacher, err := service.GetEquitmentByBedID(bed_number, orgid)
  232. if thisAddmacher.ID > 0 {
  233. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeEquitNoExist)
  234. return
  235. }
  236. addmacher := &models.DeviceAddmacher{
  237. SerialNumber: serial_numbe,
  238. DeviceType: device_type,
  239. BedNumber: number.Number,
  240. BedId: bed_number,
  241. ZoneId: zone_id,
  242. DeviceName: device_name,
  243. ManufactureFactory: manufacture_factory,
  244. ServiceManufacturer: service_manufacturer,
  245. UnitType: unittype,
  246. UseSection: use_section,
  247. SectionNumber: section_number,
  248. BuyDate: buydate,
  249. InstallDate: installdate,
  250. StartDate: startdate,
  251. MaintenaceEngineer: maintenance_engineer,
  252. Telephone: telephone,
  253. GuaranteeDate: guarantee_date,
  254. MachineStatus: machine_status,
  255. UserTotal: user_total,
  256. DisinfectionMode: disinfection_mode,
  257. Remarks: remarks,
  258. RubbishDate: rubbishdate,
  259. RubbishReason: rubbish_reason,
  260. UserYear: user_year,
  261. WorkTime: work_time,
  262. ReversMode: revers,
  263. Status: 1,
  264. Ctime: time.Now().Unix(),
  265. UserOrgId: orgid,
  266. }
  267. err = service.CreateMacher(addmacher)
  268. if err != nil {
  269. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  270. return
  271. }
  272. deviceAddmacher, err := service.GetLastMacherData(orgid)
  273. // fmt.Println("错误是什么", err)
  274. equimentname := models.DeviceEquimentname{
  275. EquitmentName: unit_type,
  276. Status: 1,
  277. UserOrgId: orgid,
  278. Ctime: time.Now().Unix(),
  279. EquitmentId: deviceAddmacher.ID,
  280. BedId: bed_number,
  281. }
  282. error := service.AddTreatMode(deviceAddmacher.ID, orgid, ids)
  283. fmt.Println("error:", error)
  284. err = service.CreateEquimentName(equimentname)
  285. fmt.Println("添加设备型号失败", err)
  286. this.ServeSuccessJSON(map[string]interface{}{
  287. "addmacher": addmacher,
  288. })
  289. }
  290. func (this *MachineApiController) UpdateMachineInfo() {
  291. adminUserInfo := this.GetAdminUserInfo()
  292. orgid := adminUserInfo.CurrentOrgId
  293. dataBody := make(map[string]interface{}, 0)
  294. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  295. id := int64(dataBody["id"].(float64))
  296. serial_number := dataBody["serial_number"].(string)
  297. device_type := int64(dataBody["devicetype"].(float64))
  298. bed_number := int64(dataBody["bed_number"].(float64))
  299. number, err := service.GetZoneId(bed_number, orgid)
  300. device_name := dataBody["device_name"].(string)
  301. manufacture_factory := dataBody["manufacture_factory"].(string)
  302. service_manufacturer := dataBody["service_manufacturer"].(string)
  303. unit_type := int64(dataBody["unit_type"].(float64))
  304. use_section := dataBody["use_section"].(string)
  305. section_number := dataBody["section_number"].(string)
  306. buy_date := dataBody["buy_date"].(string)
  307. timeLayout := "2006-01-02 15:04:05"
  308. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  309. buydate := theTime.Unix()
  310. int_num := *(*int)(unsafe.Pointer(&buydate))
  311. if int_num < 0 {
  312. buydate = 0
  313. }
  314. install_date := dataBody["install_date"].(string)
  315. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  316. installdate := toTime.Unix()
  317. buy_num := *(*int)(unsafe.Pointer(&installdate))
  318. if buy_num < 0 {
  319. installdate = 0
  320. }
  321. start_date := dataBody["start_date"].(string)
  322. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  323. startdate := stringToTime.Unix()
  324. start_num := *(*int)(unsafe.Pointer(&startdate))
  325. if start_num < 0 {
  326. startdate = 0
  327. }
  328. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  329. telephone := dataBody["telephone"].(string)
  330. guarantee_date := dataBody["guarantee_date"].(string)
  331. machine_status := int64(dataBody["machine_status"].(float64))
  332. user_total := dataBody["user_total"].(string)
  333. remarks := dataBody["remarks"].(string)
  334. rubbish_date := dataBody["rubbish_date"].(string)
  335. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  336. rubbishdate := timeStringToTime.Unix()
  337. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  338. if rubb_num < 0 {
  339. rubbishdate = 0
  340. }
  341. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  342. user_year := dataBody["user_year"].(string)
  343. work_time := dataBody["work_time"].(string)
  344. treat_types := dataBody["treat_type"].([]interface{})
  345. ids := make([]int64, 0)
  346. for _, treat := range treat_types {
  347. id := int64(treat.(float64))
  348. ids = append(ids, id)
  349. }
  350. thisAddmacher, err := service.GetEquitmentByBedID(bed_number, orgid)
  351. if thisAddmacher.ID > 0 && thisAddmacher.ID != id {
  352. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeDialysisNoExist)
  353. return
  354. }
  355. zone_id := int64(dataBody["zone_id"].(float64))
  356. addmacher := models.DeviceAddmacher{
  357. ID: id,
  358. SerialNumber: serial_number,
  359. DeviceType: device_type,
  360. BedNumber: number.Number,
  361. BedId: bed_number,
  362. DeviceName: device_name,
  363. ManufactureFactory: manufacture_factory,
  364. ServiceManufacturer: service_manufacturer,
  365. UnitType: unit_type,
  366. UseSection: use_section,
  367. SectionNumber: section_number,
  368. BuyDate: buydate,
  369. InstallDate: installdate,
  370. StartDate: startdate,
  371. MaintenaceEngineer: maintenance_engineer,
  372. Telephone: telephone,
  373. GuaranteeDate: guarantee_date,
  374. MachineStatus: machine_status,
  375. UserTotal: user_total,
  376. Remarks: remarks,
  377. RubbishDate: rubbishdate,
  378. RubbishReason: rubbish_reason,
  379. UserYear: user_year,
  380. WorkTime: work_time,
  381. ZoneId: zone_id,
  382. }
  383. err = service.UpdateMachine(id, orgid, &addmacher)
  384. errors := service.UpdateTreatMode(id, orgid, ids)
  385. fmt.Println("更新透析模式失败", errors)
  386. if err != nil {
  387. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  388. return
  389. }
  390. this.ServeSuccessJSON(map[string]interface{}{
  391. "addmacher": addmacher,
  392. })
  393. }
  394. func (this *MachineApiController) UpdateMachinetwo() {
  395. adminUserInfo := this.GetAdminUserInfo()
  396. orgid := adminUserInfo.CurrentOrgId
  397. dataBody := make(map[string]interface{}, 0)
  398. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  399. id := int64(dataBody["id"].(float64))
  400. bed_nunmber := dataBody["beds"].(string)
  401. serial_number := dataBody["serial_number"].(string)
  402. device_type := int64(dataBody["devicetype"].(float64))
  403. device_name := dataBody["device_name"].(string)
  404. manufacture_factory := dataBody["manufacture_factory"].(string)
  405. service_manufacturer := dataBody["service_manufacturer"].(string)
  406. unit_type := int64(dataBody["unit_type"].(float64))
  407. use_section := dataBody["use_section"].(string)
  408. section_number := dataBody["section_number"].(string)
  409. buy_date := dataBody["buy_date"].(string)
  410. timeLayout := "2006-01-02 15:04:05"
  411. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  412. buydate := theTime.Unix()
  413. int_num := *(*int)(unsafe.Pointer(&buydate))
  414. if int_num < 0 {
  415. buydate = 0
  416. }
  417. install_date := dataBody["install_date"].(string)
  418. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  419. installdate := toTime.Unix()
  420. buy_num := *(*int)(unsafe.Pointer(&installdate))
  421. if buy_num < 0 {
  422. installdate = 0
  423. }
  424. start_date := dataBody["start_date"].(string)
  425. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  426. startdate := stringToTime.Unix()
  427. start_num := *(*int)(unsafe.Pointer(&startdate))
  428. if start_num < 0 {
  429. startdate = 0
  430. }
  431. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  432. telephone := dataBody["telephone"].(string)
  433. guarantee_date := dataBody["guarantee_date"].(string)
  434. machine_status := int64(dataBody["machine_status"].(float64))
  435. user_total := dataBody["user_total"].(string)
  436. remarks := dataBody["remarks"].(string)
  437. rubbish_date := dataBody["rubbish_date"].(string)
  438. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  439. rubbishdate := timeStringToTime.Unix()
  440. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  441. if rubb_num < 0 {
  442. rubbishdate = 0
  443. }
  444. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  445. user_year := dataBody["user_year"].(string)
  446. work_time := dataBody["work_time"].(string)
  447. disinfection_mode := int64(dataBody["Disinfection_mode"].(float64))
  448. revers_modes := int64(dataBody["revers_mode"].(float64))
  449. zone_id := int64(dataBody["zone_id"].(float64))
  450. addmacher := models.DeviceAddmacher{
  451. ID: id,
  452. SerialNumber: serial_number,
  453. DeviceType: device_type,
  454. BedNumber: bed_nunmber,
  455. DeviceName: device_name,
  456. ManufactureFactory: manufacture_factory,
  457. ServiceManufacturer: service_manufacturer,
  458. UnitType: unit_type,
  459. UseSection: use_section,
  460. SectionNumber: section_number,
  461. BuyDate: buydate,
  462. InstallDate: installdate,
  463. StartDate: startdate,
  464. MaintenaceEngineer: maintenance_engineer,
  465. Telephone: telephone,
  466. GuaranteeDate: guarantee_date,
  467. MachineStatus: machine_status,
  468. UserTotal: user_total,
  469. Remarks: remarks,
  470. RubbishDate: rubbishdate,
  471. RubbishReason: rubbish_reason,
  472. UserYear: user_year,
  473. WorkTime: work_time,
  474. DisinfectionMode: disinfection_mode,
  475. ReversMode: revers_modes,
  476. ZoneId: zone_id,
  477. }
  478. err = service.UpdateMachine(id, orgid, &addmacher)
  479. fmt.Println("报错", err)
  480. if err != nil {
  481. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  482. return
  483. }
  484. this.ServeSuccessJSON(map[string]interface{}{
  485. "addmacher": addmacher,
  486. })
  487. }
  488. func (this *MachineApiController) Updatemacheinetwo() {
  489. adminUserInfo := this.GetAdminUserInfo()
  490. orgid := adminUserInfo.CurrentOrgId
  491. //fmt.Println("机构id", orgid)
  492. dataBody := make(map[string]interface{}, 0)
  493. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  494. //fmt.Println("错误是", err)
  495. id := int64(dataBody["id"].(float64))
  496. //fmt.Println("id是什么", id)
  497. //serial_number := int64(dataBody["serial_number"].(float64))
  498. serial_number := dataBody["serial_number"].(string)
  499. //fmt.Println("序列号", serial_number)
  500. device_type := int64(dataBody["devicetype"].(float64))
  501. //fmt.Println("设备类型", device_type)
  502. //bed_number := int64(dataBody["bed_number"].(float64))
  503. //fmt.Println("机位号", bed_number)
  504. bednumber := dataBody["bed_numbers"].(string)
  505. //fmt.Println("机位号", bednumber)
  506. //number, err := service.GetZoneId(bed_number, orgid)
  507. //fmt.Println("number是多少", number)
  508. device_name := dataBody["device_name"].(string)
  509. //fmt.Println("设备名称", device_name)
  510. manufacture_factory := dataBody["manufacture_factory"].(string)
  511. //fmt.Println("生产厂家", manufacture_factory)
  512. service_manufacturer := dataBody["service_manufacturer"].(string)
  513. //fmt.Println("维修厂家", service_manufacturer)
  514. unittype := int64(dataBody["unit_type"].(float64))
  515. //unit_type := strconv.FormatInt(unittype, 10)
  516. //fmt.Println("设备型号", unit_type)
  517. use_section := dataBody["use_section"].(string)
  518. //fmt.Println("使用科室", use_section)
  519. section_number := dataBody["section_number"].(string)
  520. //fmt.Println("科室编号", section_number)
  521. buy_date := dataBody["buy_date"].(string)
  522. //fmt.Println("buy_date", buy_date)
  523. timeLayout := "2006-01-02 15:04:05"
  524. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  525. buydate := theTime.Unix()
  526. int_num := *(*int)(unsafe.Pointer(&buydate))
  527. if int_num < 0 {
  528. buydate = 0
  529. }
  530. //fmt.Println("购买日期", buydate)
  531. install_date := dataBody["install_date"].(string)
  532. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  533. installdate := toTime.Unix()
  534. buy_num := *(*int)(unsafe.Pointer(&installdate))
  535. if buy_num < 0 {
  536. installdate = 0
  537. }
  538. //fmt.Println("安装日期", installdate)
  539. start_date := dataBody["start_date"].(string)
  540. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  541. startdate := stringToTime.Unix()
  542. start_num := *(*int)(unsafe.Pointer(&startdate))
  543. if start_num < 0 {
  544. startdate = 0
  545. }
  546. //fmt.Println("启用日期", startdate)
  547. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  548. //fmt.Println("维修工程", maintenance_engineer)
  549. telephone := dataBody["telephone"].(string)
  550. //fmt.Println("telephone", telephone)
  551. guarantee_date := dataBody["guarantee_date"].(string)
  552. //fmt.Println("保修期限", guarantee_date)
  553. machine_status := int64(dataBody["machine_status"].(float64))
  554. //fmt.Println("机器状态", machine_status)
  555. user_total := dataBody["user_total"].(string)
  556. //fmt.Println("初次使用次数", user_total)
  557. remarks := dataBody["remarks"].(string)
  558. //fmt.Println("备注", remarks)
  559. rubbish_date := dataBody["rubbish_date"].(string)
  560. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  561. rubbishdate := timeStringToTime.Unix()
  562. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  563. if rubb_num < 0 {
  564. rubbishdate = 0
  565. }
  566. //fmt.Println("报废日期", rubbishdate)
  567. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  568. //fmt.Println("报废原因", rubbish_reason)
  569. user_year := dataBody["user_year"].(string)
  570. //fmt.Println("使用年限", user_year)
  571. work_time := dataBody["work_time"].(string)
  572. //fmt.Println("工作时长", work_time)
  573. addmacher := models.DeviceAddmacher{
  574. ID: id,
  575. SerialNumber: serial_number,
  576. DeviceType: device_type,
  577. BedNumber: bednumber,
  578. DeviceName: device_name,
  579. ManufactureFactory: manufacture_factory,
  580. ServiceManufacturer: service_manufacturer,
  581. UnitType: unittype,
  582. UseSection: use_section,
  583. SectionNumber: section_number,
  584. BuyDate: buydate,
  585. InstallDate: installdate,
  586. StartDate: startdate,
  587. MaintenaceEngineer: maintenance_engineer,
  588. Telephone: telephone,
  589. GuaranteeDate: guarantee_date,
  590. MachineStatus: machine_status,
  591. UserTotal: user_total,
  592. Remarks: remarks,
  593. RubbishDate: rubbishdate,
  594. RubbishReason: rubbish_reason,
  595. UserYear: user_year,
  596. WorkTime: work_time,
  597. }
  598. //fmt.Println("addmacher", addmacher)
  599. err = service.UpdateMachine(id, orgid, &addmacher)
  600. //fmt.Println("报错", err)
  601. if err != nil {
  602. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  603. return
  604. }
  605. this.ServeSuccessJSON(map[string]interface{}{
  606. "addmacher": addmacher,
  607. })
  608. }
  609. func (this *MachineApiController) GetAllEquimentName() {
  610. adminUser := this.GetAdminUserInfo()
  611. orgid := adminUser.CurrentOrgId
  612. equit, err := service.GetAllEquimentName(orgid)
  613. list, _ := service.GetAllDeviceMode(orgid)
  614. if err != nil {
  615. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  616. return
  617. }
  618. this.ServeSuccessJSON(map[string]interface{}{
  619. "equit": equit,
  620. "list": list,
  621. })
  622. }
  623. func (this *MachineApiController) SavePlan() {
  624. id, _ := this.GetInt64("id")
  625. adminUserInfo := this.GetAdminUserInfo()
  626. orgid := adminUserInfo.CurrentOrgId
  627. dataBody := make(map[string]interface{}, 0)
  628. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  629. device_type := int64(dataBody["device_type"].(float64))
  630. disinfec_time := dataBody["disinfec_time"].(string)
  631. time := dataBody["time"].([]interface{})
  632. ids := make([]int64, 0)
  633. for _, t := range time {
  634. id := int64(t.(float64))
  635. ids = append(ids, id)
  636. }
  637. classtime := dataBody["class_time"].([]interface{})
  638. classids := make([]int64, 0)
  639. for _, class := range classtime {
  640. id := int64(class.(float64))
  641. classids = append(classids, id)
  642. }
  643. way := int64(dataBody["way"].(float64))
  644. machinedisinfectant := int64(dataBody["machine_disinfectant"].(float64))
  645. disinfectantway := int64(dataBody["disinfectant_way"].(float64))
  646. disinfectant := int64(dataBody["disinfectant"].(float64))
  647. bed_way := int64(dataBody["bed_way"].(float64))
  648. bed, err := service.GetBed(id)
  649. _, errcode := service.QueryPlan(orgid, device_type, ids, classids, id)
  650. if errcode == gorm.ErrRecordNotFound {
  651. err = service.AddPlan(orgid, device_type, disinfec_time, ids, classids, way, machinedisinfectant, disinfectantway, disinfectant, id, bed.BedId, bed_way)
  652. if err != nil {
  653. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加计划失败")
  654. return
  655. }
  656. this.ServeSuccessJSON(map[string]interface{}{
  657. "msg": "msg",
  658. })
  659. } else if errcode == nil {
  660. this.ServeFailJsonSend(enums.ErrorCodeDataException, "已存在")
  661. return
  662. } else {
  663. this.ServeFailJsonSend(enums.ErrorCodeDataException, "已存在")
  664. return
  665. }
  666. }
  667. func (this *MachineApiController) GetAllPlan() {
  668. adminUserin := this.GetAdminUserInfo()
  669. orgid := adminUserin.CurrentOrgId
  670. plan, err := service.GetAllPlan(orgid)
  671. if err != nil {
  672. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  673. return
  674. }
  675. this.ServeSuccessJSON(map[string]interface{}{
  676. "plan": plan,
  677. })
  678. }
  679. func (this *MachineApiController) GetAllPlanDetail() {
  680. //id, _ := this.GetInt64("id")
  681. //更据设备ID获取设备型号
  682. //fmt.Print("=================失败ID",id)
  683. unitype := this.GetString("unitype")
  684. deviceType, err2 := service.GetDeviceType(unitype)
  685. fmt.Print("eer2", err2)
  686. adminUserInfo := this.GetAdminUserInfo()
  687. orgid := adminUserInfo.CurrentOrgId
  688. //fmt.Println("orgid", orgid)
  689. plandetail, err := service.GetAllPlanDetail(deviceType.ID, orgid)
  690. if err != nil {
  691. this.ServeFailJsonSend(enums.ErrorCodeDataException, "更新设备失败")
  692. return
  693. }
  694. this.ServeSuccessJSON(map[string]interface{}{
  695. "plandetail": plandetail,
  696. })
  697. }
  698. func (this *MachineApiController) GetEditMahchine() {
  699. id, _ := this.GetInt64("id")
  700. fmt.Print("id", id)
  701. }
  702. func (this *MachineApiController) DeletePlans() {
  703. adminUserInfo := this.GetAdminUserInfo()
  704. OrgID := adminUserInfo.CurrentOrgId
  705. dataBody := make(map[string]interface{}, 0)
  706. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  707. if err != nil {
  708. utils.ErrorLog(err.Error())
  709. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  710. return
  711. }
  712. idsInters := dataBody["ids"].([]interface{})
  713. if len(idsInters) == 0 {
  714. if err != nil {
  715. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  716. return
  717. }
  718. }
  719. ids := make([]int64, 0)
  720. for _, idsInter := range idsInters {
  721. id := int64(idsInter.(float64))
  722. ids = append(ids, id)
  723. }
  724. err = service.DeletePlans(OrgID, ids)
  725. if err != nil {
  726. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  727. return
  728. }
  729. returnData := make(map[string]interface{}, 0)
  730. returnData["msg"] = "ok"
  731. this.ServeSuccessJSON(returnData)
  732. return
  733. }
  734. func (this *MachineApiController) EditPlanDetail() {
  735. id, _ := this.GetInt64("id")
  736. adminUserInfo := this.GetAdminUserInfo()
  737. orgId := adminUserInfo.CurrentOrgId
  738. plan, err := service.GetPlanDetailById(id, orgId)
  739. fmt.Println("err", err)
  740. if err != nil {
  741. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  742. return
  743. }
  744. this.ServeSuccessJSON(map[string]interface{}{
  745. "plan": plan,
  746. })
  747. }
  748. func (this *MachineApiController) UpdatePlanInfo() {
  749. dataBody := make(map[string]interface{}, 0)
  750. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  751. //fmt.Println("错误是", err)
  752. id := int64(dataBody["id"].(float64))
  753. //fmt.Println("id", id)
  754. device_type := int64(dataBody["device_type"].(float64))
  755. //fmt.Println("设备型号", device_type)
  756. disinfec_time := int64(dataBody["disinfec_time"].(float64))
  757. //fmt.Println("消毒时长", disinfec_time)
  758. time := int64(dataBody["time"].(float64))
  759. //fmt.Println("时间", time)
  760. classtime := int64(dataBody["class_time"].(float64))
  761. //fmt.Println("班次", classtime)
  762. way := int64(dataBody["way"].(float64))
  763. //fmt.Println("基表消毒方式", way)
  764. machinedisinfectant := int64(dataBody["machine_disinfectant"].(float64))
  765. //fmt.Println("基表消毒液", machinedisinfectant)
  766. disinfectantway := int64(dataBody["disinfectant_way"].(float64))
  767. fmt.Println("液路消毒方式", disinfectantway)
  768. disinfectant := int64(dataBody["disinfectant"].(float64))
  769. //fmt.Println("液路消毒液", disinfectant)
  770. adminUserInfo := this.GetAdminUserInfo()
  771. orgid := adminUserInfo.CurrentOrgId
  772. //fmt.Println("orgid", orgid)
  773. plan := models.DevicePlan{
  774. DeviceType: device_type,
  775. DisinfecTime: disinfec_time,
  776. Time: time,
  777. Classtime: classtime,
  778. Way: way,
  779. MachineDisinfectant: machinedisinfectant,
  780. DisinfectanWay: disinfectantway,
  781. Disinfectant: disinfectant,
  782. }
  783. err = service.UpdatePlanInfo(id, orgid, plan)
  784. fmt.Println("err", err)
  785. if err != nil {
  786. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  787. return
  788. }
  789. this.ServeSuccessJSON(map[string]interface{}{
  790. "plan": plan,
  791. })
  792. }
  793. func (this *MachineApiController) GetComprehensive() {
  794. zone, _ := this.GetInt64("zone")
  795. number, _ := this.GetInt64("number")
  796. devicetype, _ := this.GetInt64("devicetype")
  797. year, _ := this.GetInt64("year")
  798. startTime := this.GetString("starttime")
  799. device_mode, _ := this.GetInt64("device_mode")
  800. fmt.Println("hh232323233232232233223232323", device_mode)
  801. timeLayout := "2006-01-02"
  802. loc, _ := time.LoadLocation("Local")
  803. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", startTime+" 00:00:00", loc)
  804. starts := theTime.Unix()
  805. endtime := this.GetString("endtime")
  806. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  807. end := location.Unix()
  808. adminUserInfo := this.GetAdminUserInfo()
  809. orgid := adminUserInfo.CurrentOrgId
  810. macher, err := service.GetComprehensive(zone, number, devicetype, year, starts, end, orgid, device_mode)
  811. if err != nil {
  812. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  813. return
  814. }
  815. this.ServeSuccessJSON(map[string]interface{}{
  816. "macher": macher,
  817. })
  818. }
  819. func (this *MachineApiController) GetPatientInfo() {
  820. adminUser := this.GetAdminUserInfo()
  821. orgid := adminUser.CurrentOrgId
  822. id, _ := this.GetInt64("id")
  823. addmacher, _ := service.GetBedId(id)
  824. timeStr := time.Now().Format("2006-01-02")
  825. timeLayout := "2006-01-02 15:04:05"
  826. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  827. timenow := timeStringToTime.Unix()
  828. //获取当天床位号排班的所有病人
  829. schedules, err := service.GetPatientInfo(addmacher.BedId, timenow, orgid)
  830. if err != nil {
  831. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  832. return
  833. }
  834. this.ServeSuccessJSON(map[string]interface{}{
  835. "schedules": schedules,
  836. })
  837. }
  838. func (this *MachineApiController) GetPatient() {
  839. adminUser := this.GetAdminUserInfo()
  840. orgid := adminUser.CurrentOrgId
  841. //fmt.Println("机构id", orgid)
  842. equitid, _ := this.GetInt64("equitid")
  843. //fmt.Println("设备id", equitid)
  844. addmacher, _ := service.GetBedId(equitid)
  845. id, _ := this.GetInt64("id")
  846. //fmt.Println("班次id", id)
  847. timeStr := time.Now().Format("2006-01-02")
  848. timeLayout := "2006-01-02 15:04:05"
  849. //fmt.Println("timeStr:", timeStr)
  850. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  851. timenow := timeStringToTime.Unix()
  852. //fmt.Println("timenow是什么", timenow)
  853. schedules, err := service.GetPatient(addmacher.BedId, orgid, id, timenow)
  854. //fmt.Println("schedules", schedules.PartitionId)
  855. //获取区号姓名
  856. zone, _ := service.GetPartitionName(schedules.PartitionId)
  857. //获取机位号
  858. number, _ := service.GetPatientNumber(schedules.BedId)
  859. //获取上机时间和下机时间
  860. order, _ := service.GetDialysisOrder(timenow, schedules.PatientId, orgid)
  861. //获取透析方式
  862. prescription, _ := service.GetDialysisWay(timenow, schedules.PatientId, orgid)
  863. //获取透析时长
  864. dislysis, _ := service.GetDialysisTime(timenow, schedules.PatientId, orgid)
  865. if err != nil {
  866. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  867. return
  868. }
  869. this.ServeSuccessJSON(map[string]interface{}{
  870. "patients": schedules,
  871. "zone": zone,
  872. "number": number,
  873. "order": order,
  874. "prescription": prescription,
  875. "dislysis": dislysis,
  876. })
  877. }
  878. func (this *MachineApiController) GetAllOrganization() {
  879. adminUserInfo := this.GetAdminUserInfo()
  880. orgid := adminUserInfo.CurrentOrgId
  881. appid := adminUserInfo.CurrentAppId
  882. approle, err := service.GetAllOrganization(orgid, appid)
  883. operators, err := service.GetAdminUserEsOne(adminUserInfo.CurrentOrgId)
  884. if err != nil {
  885. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  886. return
  887. }
  888. this.ServeSuccessJSON(map[string]interface{}{
  889. "approle": approle,
  890. "operators": operators,
  891. })
  892. }
  893. func (this *MachineApiController) SaveInformation() {
  894. eid, _ := this.GetInt64("eid")
  895. dataBody := make(map[string]interface{}, 0)
  896. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  897. adminUserInfo := this.GetAdminUserInfo()
  898. orgid := adminUserInfo.CurrentOrgId
  899. id := int64(dataBody["id"].(float64))
  900. fmt.Println("id", id)
  901. date := dataBody["date"].(string)
  902. timeLayout := "2006-01-02"
  903. loc, _ := time.LoadLocation("Local")
  904. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  905. startdate := theTime.Unix()
  906. classtype := int64(dataBody["classtype"].(float64))
  907. zone := int64(dataBody["zone"].(float64))
  908. bednumber := int64(dataBody["bed_number"].(float64))
  909. number, err := service.GetNumbers(bednumber, orgid)
  910. patient_time := int64(dataBody["patient_id"].(float64))
  911. contagion := dataBody["contagion"].(string)
  912. dialysis_mode := int64(dataBody["dialysis_mode"].(float64))
  913. startDateStr := dataBody["start_time"].(string)
  914. var startDataUnix int64
  915. if len(startDateStr) > 0 {
  916. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  917. startDataUnix = startDate.Unix()
  918. }
  919. endDateStr := dataBody["end_time"].(string)
  920. var endDateUnix int64
  921. if len(endDateStr) > 0 {
  922. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endDateStr)
  923. endDateUnix = endDate.Unix()
  924. }
  925. dialysis_time := dataBody["dialysis_time"].(string)
  926. hyperfiletration := dataBody["hyperfiltratio"].(float64)
  927. weight_loss := dataBody["weight_loss"].(float64)
  928. warining_value := dataBody["warning_value"].(string)
  929. usertotal := int64(dataBody["user_total"].(float64))
  930. user_total := strconv.FormatInt(usertotal, 10)
  931. run := int64(dataBody["run"].(float64))
  932. failure_stage := int64(dataBody["failure_stage"].(float64))
  933. falult_desciription := dataBody["fault_description"].(string)
  934. code_information := dataBody["code_information"].(string)
  935. //机器消毒
  936. disinfect_type := int64(dataBody["disinfect_type"].(float64))
  937. disinfectant_type := int64(dataBody["disinfectant_type"].(float64))
  938. disinfection := int64(dataBody["disinfection"].(float64))
  939. machine_run := int64(dataBody["machine_run"].(float64))
  940. //液路
  941. fluid_path := int64(dataBody["fluid_path"].(float64))
  942. disinfectant := int64(dataBody["disinfectant"].(float64))
  943. disinfection_status := int64(dataBody["disinfection_status"].(float64))
  944. disinfection_residue := int64(dataBody["disinfection_residue"].(float64))
  945. longtime := dataBody["longtime"].(string)
  946. start_DateStr := dataBody["starttime"].(string)
  947. var start_DateStr_Unix int64
  948. if len(start_DateStr) > 0 {
  949. start_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", start_DateStr)
  950. start_DateStr_Unix = start_Date.Unix()
  951. }
  952. end_DateStr := dataBody["endtime"].(string)
  953. var end_DateStr_Unix int64
  954. if len(end_DateStr) > 0 {
  955. end_Date, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", end_DateStr)
  956. end_DateStr_Unix = end_Date.Unix()
  957. }
  958. dialysis_checked := int64(dataBody["dialysis_checked"].(float64))
  959. dialysis_name := int64(dataBody["dialysis_name"].(float64))
  960. norms := dataBody["norms"].(string)
  961. dialysis_concentration := int64(dataBody["dialysis_concentration"].(float64))
  962. germ_checked := int64(dataBody["germ_checked"].(float64))
  963. germ_name := int64(dataBody["germ_name"].(float64))
  964. germ_number := dataBody["germ_number"].(string)
  965. clean := int64(dataBody["clean"].(float64))
  966. sign_name := int64(dataBody["sign_name"].(float64))
  967. information, errinfor := service.GetInformation(eid, startdate, orgid, classtype)
  968. fmt.Print("information", information)
  969. //获取该机器最后一次的透析次数
  970. lastInformation, _ := service.GetLastInformationById(eid, orgid)
  971. parseIntUserTotal, err := strconv.ParseInt(user_total, 10, 64)
  972. if parseIntUserTotal == 0 {
  973. var total int
  974. // 字符串 转 int
  975. intNum, _ := strconv.Atoi(lastInformation.UserTotal)
  976. total = intNum + 1
  977. itoa := strconv.Itoa(total)
  978. if errinfor == gorm.ErrRecordNotFound {
  979. infor := models.DeviceInformation{
  980. Date: startdate,
  981. Class: classtype,
  982. BedNumber: bednumber,
  983. PatientId: patient_time,
  984. Contagion: contagion,
  985. DialysisMode: dialysis_mode,
  986. StartTime: startDataUnix,
  987. EndTime: endDateUnix,
  988. DialysisHour: dialysis_time,
  989. Hyperfiltratio: hyperfiletration,
  990. WeightLoss: weight_loss,
  991. WarningValue: warining_value,
  992. UserTotal: itoa,
  993. Move: run,
  994. FailureStage: failure_stage,
  995. FaultDescription: falult_desciription,
  996. CodeInformation: code_information,
  997. DisinfectantType: disinfectant_type,
  998. DisinfectType: disinfect_type,
  999. Disinfection: disinfection,
  1000. MachineRun: machine_run,
  1001. FluidPath: fluid_path,
  1002. Disinfectant: disinfectant,
  1003. DisinfectionStatus: disinfection_status,
  1004. DisinfectionResidue: disinfection_residue,
  1005. LongTime: longtime,
  1006. DisinfecStartime: start_DateStr_Unix,
  1007. DisinfecEndtime: end_DateStr_Unix,
  1008. DialysisChecked: dialysis_checked,
  1009. DialysisName: dialysis_name,
  1010. Norms: norms,
  1011. DialysisConcentration: dialysis_concentration,
  1012. GermChecked: germ_checked,
  1013. GermName: germ_name,
  1014. GermNumber: germ_number,
  1015. Clean: clean,
  1016. SignName: sign_name,
  1017. Ctime: time.Now().Unix(),
  1018. Status: 1,
  1019. UserOrgId: orgid,
  1020. EquimentId: eid,
  1021. Bed: number.Number,
  1022. Stime: startdate,
  1023. }
  1024. if germ_checked == 1 {
  1025. infor.UserTotal = ""
  1026. }
  1027. err = service.CreateUserInformation(&infor)
  1028. fmt.Println("使用登记错误是什么", err)
  1029. this.ServeSuccessJSON(map[string]interface{}{
  1030. "information": infor,
  1031. })
  1032. } else if errinfor == nil {
  1033. infor := models.DeviceInformation{
  1034. Date: startdate,
  1035. Class: classtype,
  1036. Zone: zone,
  1037. BedNumber: bednumber,
  1038. PatientId: patient_time,
  1039. Contagion: contagion,
  1040. DialysisMode: dialysis_mode,
  1041. StartTime: startDataUnix,
  1042. EndTime: endDateUnix,
  1043. DialysisHour: dialysis_time,
  1044. Hyperfiltratio: hyperfiletration,
  1045. WeightLoss: weight_loss,
  1046. WarningValue: warining_value,
  1047. UserTotal: user_total,
  1048. Move: run,
  1049. FailureStage: failure_stage,
  1050. FaultDescription: falult_desciription,
  1051. CodeInformation: code_information,
  1052. DisinfectantType: disinfectant_type,
  1053. DisinfectType: disinfect_type,
  1054. Disinfection: disinfection,
  1055. MachineRun: machine_run,
  1056. FluidPath: fluid_path,
  1057. Disinfectant: disinfectant,
  1058. DisinfectionStatus: disinfection_status,
  1059. DisinfectionResidue: disinfection_residue,
  1060. LongTime: longtime,
  1061. DisinfecStartime: start_DateStr_Unix,
  1062. DisinfecEndtime: end_DateStr_Unix,
  1063. DialysisChecked: dialysis_checked,
  1064. DialysisName: dialysis_name,
  1065. Norms: norms,
  1066. DialysisConcentration: dialysis_concentration,
  1067. GermChecked: germ_checked,
  1068. GermName: germ_name,
  1069. GermNumber: germ_number,
  1070. Clean: clean,
  1071. SignName: sign_name,
  1072. Ctime: time.Now().Unix(),
  1073. Status: 1,
  1074. UserOrgId: orgid,
  1075. EquimentId: eid,
  1076. Bed: number.Number,
  1077. }
  1078. informationdata, err := service.GetLastInformationdata(eid, startdate, orgid)
  1079. if germ_checked == 1 {
  1080. infor.UserTotal = ""
  1081. }
  1082. errors := service.UpadateForm(informationdata.ID, orgid, &infor)
  1083. //fmt.Print("报错", errors)
  1084. if errors != nil {
  1085. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1086. return
  1087. }
  1088. this.ServeSuccessJSON(map[string]interface{}{
  1089. "infor": infor,
  1090. })
  1091. }
  1092. }
  1093. if parseIntUserTotal > 0 {
  1094. if errinfor == gorm.ErrRecordNotFound {
  1095. infor := models.DeviceInformation{
  1096. Date: startdate,
  1097. Class: classtype,
  1098. BedNumber: bednumber,
  1099. PatientId: patient_time,
  1100. Contagion: contagion,
  1101. DialysisMode: dialysis_mode,
  1102. StartTime: startDataUnix,
  1103. EndTime: endDateUnix,
  1104. DialysisHour: dialysis_time,
  1105. Hyperfiltratio: hyperfiletration,
  1106. WeightLoss: weight_loss,
  1107. WarningValue: warining_value,
  1108. UserTotal: user_total,
  1109. Move: run,
  1110. FailureStage: failure_stage,
  1111. FaultDescription: falult_desciription,
  1112. CodeInformation: code_information,
  1113. DisinfectantType: disinfectant_type,
  1114. DisinfectType: disinfect_type,
  1115. Disinfection: disinfection,
  1116. MachineRun: machine_run,
  1117. FluidPath: fluid_path,
  1118. Disinfectant: disinfectant,
  1119. DisinfectionStatus: disinfection_status,
  1120. DisinfectionResidue: disinfection_residue,
  1121. LongTime: longtime,
  1122. DisinfecStartime: start_DateStr_Unix,
  1123. DisinfecEndtime: end_DateStr_Unix,
  1124. DialysisChecked: dialysis_checked,
  1125. DialysisName: dialysis_name,
  1126. Norms: norms,
  1127. DialysisConcentration: dialysis_concentration,
  1128. GermChecked: germ_checked,
  1129. GermName: germ_name,
  1130. GermNumber: germ_number,
  1131. Clean: clean,
  1132. SignName: sign_name,
  1133. Ctime: time.Now().Unix(),
  1134. Status: 1,
  1135. UserOrgId: orgid,
  1136. EquimentId: eid,
  1137. Bed: number.Number,
  1138. Stime: startdate,
  1139. }
  1140. if germ_checked == 1 {
  1141. infor.UserTotal = ""
  1142. }
  1143. err = service.CreateUserInformation(&infor)
  1144. fmt.Println("使用登记错误是什么", err)
  1145. this.ServeSuccessJSON(map[string]interface{}{
  1146. "information": infor,
  1147. })
  1148. } else if errinfor == nil {
  1149. infor := models.DeviceInformation{
  1150. Date: startdate,
  1151. Class: classtype,
  1152. Zone: zone,
  1153. BedNumber: bednumber,
  1154. PatientId: patient_time,
  1155. Contagion: contagion,
  1156. DialysisMode: dialysis_mode,
  1157. StartTime: startDataUnix,
  1158. EndTime: endDateUnix,
  1159. DialysisHour: dialysis_time,
  1160. Hyperfiltratio: hyperfiletration,
  1161. WeightLoss: weight_loss,
  1162. WarningValue: warining_value,
  1163. UserTotal: user_total,
  1164. Move: run,
  1165. FailureStage: failure_stage,
  1166. FaultDescription: falult_desciription,
  1167. CodeInformation: code_information,
  1168. DisinfectantType: disinfectant_type,
  1169. DisinfectType: disinfect_type,
  1170. Disinfection: disinfection,
  1171. MachineRun: machine_run,
  1172. FluidPath: fluid_path,
  1173. Disinfectant: disinfectant,
  1174. DisinfectionStatus: disinfection_status,
  1175. DisinfectionResidue: disinfection_residue,
  1176. LongTime: longtime,
  1177. DisinfecStartime: start_DateStr_Unix,
  1178. DisinfecEndtime: end_DateStr_Unix,
  1179. DialysisChecked: dialysis_checked,
  1180. DialysisName: dialysis_name,
  1181. Norms: norms,
  1182. DialysisConcentration: dialysis_concentration,
  1183. GermChecked: germ_checked,
  1184. GermName: germ_name,
  1185. GermNumber: germ_number,
  1186. Clean: clean,
  1187. SignName: sign_name,
  1188. Ctime: time.Now().Unix(),
  1189. Status: 1,
  1190. UserOrgId: orgid,
  1191. EquimentId: eid,
  1192. Bed: number.Number,
  1193. }
  1194. informationdata, err := service.GetLastInformationdata(eid, startdate, orgid)
  1195. if germ_checked == 1 {
  1196. infor.UserTotal = ""
  1197. }
  1198. errors := service.UpadateForm(informationdata.ID, orgid, &infor)
  1199. //fmt.Print("报错", errors)
  1200. if errors != nil {
  1201. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1202. return
  1203. }
  1204. this.ServeSuccessJSON(map[string]interface{}{
  1205. "infor": infor,
  1206. })
  1207. }
  1208. }
  1209. }
  1210. func (this *MachineApiController) ChangePatient() {
  1211. adminUser := this.GetAdminUserInfo()
  1212. orgid := adminUser.CurrentOrgId
  1213. fmt.Println("机构id", orgid)
  1214. equitid, _ := this.GetInt64("equitid")
  1215. fmt.Println("equitid", equitid)
  1216. id, _ := this.GetInt64("id")
  1217. fmt.Println("id", id)
  1218. }
  1219. func (this *MachineApiController) GetRegisterInfo() {
  1220. timeStr := time.Now().Format("2006-01-02")
  1221. timeLayout := "2006-01-02 15:04:05"
  1222. //fmt.Println("timeStr:", timeStr)
  1223. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  1224. timenow := timeStringToTime.Unix()
  1225. //fmt.Println("timenow是什么", timenow)
  1226. adminUser := this.GetAdminUserInfo()
  1227. orgid := adminUser.CurrentOrgId
  1228. appid := adminUser.CurrentAppId
  1229. id, _ := this.GetInt64("id")
  1230. //fmt.Println("设备id", id)
  1231. information, err := service.GetRegisterInfo(orgid, id, timenow)
  1232. fmt.Print("错误", err)
  1233. role, err := service.GetSignName(information.SignName, orgid, appid)
  1234. dislysis, _ := service.GetDialysisTime(timenow, information.PatientId, orgid)
  1235. //if err != nil {
  1236. // // this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1237. // // return
  1238. // //}
  1239. this.ServeSuccessJSON(map[string]interface{}{
  1240. "information": information,
  1241. "role": role,
  1242. "dislysis": dislysis,
  1243. })
  1244. }
  1245. func (this *MachineApiController) GetInformationData() {
  1246. limit, _ := this.GetInt64("limit")
  1247. //fmt.Println("limit2", limit)
  1248. page, _ := this.GetInt64("page")
  1249. //fmt.Println("page", page)
  1250. adminUser := this.GetAdminUserInfo()
  1251. orgId := adminUser.CurrentOrgId
  1252. information, total, err := service.GetInformationData(limit, page, orgId)
  1253. if err != nil {
  1254. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1255. return
  1256. }
  1257. this.ServeSuccessJSON(map[string]interface{}{
  1258. "information": information,
  1259. "total": total,
  1260. })
  1261. }
  1262. func (this *MachineApiController) GetOrgName() {
  1263. adminUser := this.GetAdminUserInfo()
  1264. orgid := adminUser.CurrentOrgId
  1265. org, err := service.GetOrgName(orgid)
  1266. if err != nil {
  1267. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1268. return
  1269. }
  1270. this.ServeSuccessJSON(map[string]interface{}{
  1271. "org": org,
  1272. })
  1273. }
  1274. func (this *MachineApiController) SaveBacteria() {
  1275. id, _ := this.GetInt64("id")
  1276. addmacher, _ := service.GetBedId(id)
  1277. adminUserInfo := this.GetAdminUserInfo()
  1278. orgid := adminUserInfo.CurrentOrgId
  1279. dataBody := make(map[string]interface{}, 0)
  1280. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1281. date := dataBody["date"].(string)
  1282. timeLayout := "2006-01-02"
  1283. loc, _ := time.LoadLocation("Local")
  1284. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  1285. state_date := theTime.Unix()
  1286. specimen := int64(dataBody["specimen"].(float64))
  1287. cona := dataBody["concentrate_noa"].(string)
  1288. conb := dataBody["concentrate_nob"].(string)
  1289. samplingLoactiona := int64(dataBody["sampling_locationa"].(float64))
  1290. detectionUnit := dataBody["detection_unit"].(string)
  1291. sampler := int64(dataBody["sampler"].(float64))
  1292. reportDate := dataBody["reporting_date"].(string)
  1293. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  1294. repDate := reportTime.Unix()
  1295. detectionResult := dataBody["detection_result"].(string)
  1296. sort := dataBody["sort"].(string)
  1297. examination := dataBody["pass_examination"].(string)
  1298. pass_examination, err := strconv.ParseInt(examination, 10, 64)
  1299. modifications := int64(dataBody["modifications"].(float64))
  1300. culture := models.DeviceCulture{
  1301. BedId: addmacher.BedId,
  1302. SpelingDate: state_date,
  1303. Specimen: specimen,
  1304. ConcentrateNoa: cona,
  1305. ConcentrateNob: conb,
  1306. SamplingLocationa: samplingLoactiona,
  1307. DetectionUnit: detectionUnit,
  1308. Sampler: sampler,
  1309. ReportingDate: repDate,
  1310. DetectionResult: detectionResult,
  1311. Ctime: time.Now().Unix(),
  1312. Status: 1,
  1313. UserOrgId: orgid,
  1314. EquitmentId: id,
  1315. Bed: addmacher.BedNumber,
  1316. Sort: sort,
  1317. PassExamination: pass_examination,
  1318. Modifications: modifications,
  1319. }
  1320. err = service.CreateCulture(&culture)
  1321. //fmt.Println("创建细菌检测", err)
  1322. if err != nil {
  1323. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1324. return
  1325. }
  1326. this.ServeSuccessJSON(map[string]interface{}{
  1327. "culture": culture,
  1328. })
  1329. }
  1330. func (this *MachineApiController) SaveLinconmycin() {
  1331. timeLayout := "2006-01-02"
  1332. loc, _ := time.LoadLocation("Local")
  1333. id, _ := this.GetInt64("id")
  1334. addmacher, _ := service.GetBedId(id)
  1335. adminUserInfo := this.GetAdminUserInfo()
  1336. orgid := adminUserInfo.CurrentOrgId
  1337. dataBody := make(map[string]interface{}, 0)
  1338. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1339. date := dataBody["sampling_date"].(string)
  1340. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  1341. samp_date := theTime.Unix()
  1342. specimen := int64(dataBody["specimenb"].(float64))
  1343. cona := dataBody["concentrate_noc"].(string)
  1344. conb := dataBody["concentrateb_nod"].(string)
  1345. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  1346. detectionUnit := dataBody["detection_unit"].(string)
  1347. samplerb := int64(dataBody["samplerb"].(float64))
  1348. reportDate := dataBody["reporting_dateb"].(string)
  1349. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  1350. repDate := reportTime.Unix()
  1351. detectionResult := dataBody["detection_resultb"].(string)
  1352. sort := dataBody["sort"].(string)
  1353. modifications := int64(dataBody["modifications"].(float64))
  1354. examination := dataBody["pass_examination"].(string)
  1355. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  1356. dialysate := models.DeviceDialysate{
  1357. SamplingDate: samp_date,
  1358. Specimenb: specimen,
  1359. ConcentrateNoc: cona,
  1360. ConcentratebNod: conb,
  1361. SamplingLocationb: samplinglocationb,
  1362. DetectionUnit: detectionUnit,
  1363. Samplerb: samplerb,
  1364. ReportingDateb: repDate,
  1365. DetectionResultb: detectionResult,
  1366. Ctime: time.Now().Unix(),
  1367. Status: 1,
  1368. UserOrgId: orgid,
  1369. BedId: addmacher.BedId,
  1370. EquitmentId: id,
  1371. Bed: addmacher.BedNumber,
  1372. Sort: sort,
  1373. PassExamination: pass_examination,
  1374. Modifications: modifications,
  1375. }
  1376. err = service.CreateDialysate(&dialysate)
  1377. //fmt.Println("报错", err)
  1378. if err != nil {
  1379. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1380. return
  1381. }
  1382. this.ServeSuccessJSON(map[string]interface{}{
  1383. "dialysate": dialysate,
  1384. })
  1385. }
  1386. func (this *MachineApiController) SaveQualityControl() {
  1387. id, _ := this.GetInt64("id")
  1388. addmacher, _ := service.GetBedId(id)
  1389. adminUserInfo := this.GetAdminUserInfo()
  1390. orgid := adminUserInfo.CurrentOrgId
  1391. dataBody := make(map[string]interface{}, 0)
  1392. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1393. timeLayout := "2006-01-02"
  1394. loc, _ := time.LoadLocation("Local")
  1395. // 透析液离子浓度检测
  1396. dateb := dataBody["dateb"].(string)
  1397. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateb+" 00:00:00", loc)
  1398. dateB := inLocation.Unix()
  1399. samplerc := int64(dataBody["samplerc"].(float64))
  1400. concentratenof := dataBody["concentrate_nof"].(string)
  1401. concentrateonog := dataBody["concentrate_nog"].(string)
  1402. dateReportc := dataBody["date_reportc"].(string)
  1403. parseInLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateReportc+" 00:00:00", loc)
  1404. datec := parseInLocation.Unix()
  1405. actualNa := dataBody["actual_na"].(string)
  1406. actualPna := dataBody["actual_pna"].(string)
  1407. actualK := dataBody["actual_k"].(string)
  1408. actualCa := dataBody["actual_ca"].(string)
  1409. actualCi := dataBody["actual_ci"].(string)
  1410. actualHco := dataBody["actual_hco"].(string)
  1411. actualMg := dataBody["actual_mg"].(string)
  1412. actulaPH := dataBody["actual_ph"].(string)
  1413. remakes := dataBody["remakes"].(string)
  1414. detectionUnit := dataBody["detection_unit"].(string)
  1415. sort := dataBody["sort"].(string)
  1416. modifications := int64(dataBody["modifications"].(float64))
  1417. examination := dataBody["pass_examination"].(string)
  1418. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  1419. ion := models.DeviceIon{
  1420. SamplingDate: dateB,
  1421. Samplerc: samplerc,
  1422. DetectionUnit: detectionUnit,
  1423. ConcentrateNof: concentratenof,
  1424. ConcentrateNog: concentrateonog,
  1425. DateReportc: datec,
  1426. ActualNa: actualNa,
  1427. ActualPna: actualPna,
  1428. ActualK: actualK,
  1429. ActualCa: actualCa,
  1430. ActualCi: actualCi,
  1431. ActualHco: actualHco,
  1432. ActualMg: actualMg,
  1433. ActualPh: actulaPH,
  1434. Remakes: remakes,
  1435. EquitmentId: id,
  1436. Status: 1,
  1437. UserOrgId: orgid,
  1438. Ctime: time.Now().Unix(),
  1439. BedId: addmacher.BedId,
  1440. Bed: addmacher.BedNumber,
  1441. Sort: sort,
  1442. PassExamination: pass_examination,
  1443. Modifications: modifications,
  1444. }
  1445. createIon := service.CreateIon(&ion)
  1446. fmt.Println("报错", createIon)
  1447. if err != nil {
  1448. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1449. return
  1450. }
  1451. this.ServeSuccessJSON(map[string]interface{}{
  1452. "ion": ion,
  1453. })
  1454. }
  1455. func (this *MachineApiController) GetAllQulityInfo() {
  1456. adminUser := this.GetAdminUserInfo()
  1457. orgID := adminUser.CurrentOrgId
  1458. cultures, err := service.GetAllCulture(orgID)
  1459. dialysate, _ := service.GetAllDialysate(orgID)
  1460. ions, _ := service.GetAllDeviceIon(orgID)
  1461. oxygenates, _ := service.GetAllDeviceOxygenates(orgID)
  1462. water, err := service.GetAllHadWater(orgID)
  1463. deviceWater, err := service.GetDeviceWater(orgID)
  1464. devicePh, err := service.GetDevicePH(orgID)
  1465. if err != nil {
  1466. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "添加失败:("+err.Error()+")")
  1467. return
  1468. }
  1469. this.ServeSuccessJSON(map[string]interface{}{
  1470. "cultures": cultures,
  1471. "dialysate": dialysate,
  1472. "ions": ions,
  1473. "oxygenates": oxygenates,
  1474. "hadwater": water,
  1475. "deviceWater": deviceWater,
  1476. "devicePh": devicePh,
  1477. })
  1478. }
  1479. func (this *MachineApiController) EditCulture() {
  1480. id, _ := this.GetInt64("id")
  1481. //fmt.Println("id", id)
  1482. userid, _ := this.GetInt64("userid")
  1483. //fmt.Println("userid", userid)
  1484. role, _ := service.GetSampler(userid)
  1485. culture, err := service.GetCultureById(id)
  1486. if err != nil {
  1487. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1488. return
  1489. }
  1490. this.ServeSuccessJSON(map[string]interface{}{
  1491. "culture": culture,
  1492. "role": role,
  1493. })
  1494. }
  1495. func (this *MachineApiController) UpdateCulture() {
  1496. dataBody := make(map[string]interface{}, 0)
  1497. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1498. id := int64(dataBody["id"].(float64))
  1499. date := dataBody["date"].(string)
  1500. timeLayout := "2006-01-02"
  1501. loc, _ := time.LoadLocation("Local")
  1502. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  1503. state_date := theTime.Unix()
  1504. specimen := int64(dataBody["specimen"].(float64))
  1505. cona := dataBody["concentrate_noa"].(string)
  1506. conb := dataBody["concentrate_nob"].(string)
  1507. samplingLoactiona := int64(dataBody["sampling_locationa"].(float64))
  1508. detectionUnit := dataBody["detection_unit"].(string)
  1509. sampler := int64(dataBody["sampler"].(float64))
  1510. reportDate := dataBody["reporting_date"].(string)
  1511. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  1512. repDate := reportTime.Unix()
  1513. detectionResult := dataBody["detection_result"].(string)
  1514. sort := dataBody["sort"].(string)
  1515. pass_examination := int64(dataBody["pass_examination"].(float64))
  1516. modifications := int64(dataBody["modifications"].(float64))
  1517. adminUser := this.GetAdminUserInfo()
  1518. orgId := adminUser.CurrentOrgId
  1519. culture := models.DeviceCulture{
  1520. SpelingDate: state_date,
  1521. Specimen: specimen,
  1522. ConcentrateNoa: cona,
  1523. ConcentrateNob: conb,
  1524. SamplingLocationa: samplingLoactiona,
  1525. DetectionUnit: detectionUnit,
  1526. Sampler: sampler,
  1527. ReportingDate: repDate,
  1528. DetectionResult: detectionResult,
  1529. Sort: sort,
  1530. PassExamination: pass_examination,
  1531. Modifications: modifications,
  1532. }
  1533. err = service.UpdateCulture(id, orgId, &culture)
  1534. if err != nil {
  1535. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1536. return
  1537. }
  1538. this.ServeSuccessJSON(map[string]interface{}{
  1539. "culture": culture,
  1540. })
  1541. }
  1542. func (this *MachineApiController) DeleteCultrue() {
  1543. adminUserInfo := this.GetAdminUserInfo()
  1544. OrgID := adminUserInfo.CurrentOrgId
  1545. dataBody := make(map[string]interface{}, 0)
  1546. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1547. if err != nil {
  1548. utils.ErrorLog(err.Error())
  1549. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1550. return
  1551. }
  1552. idsInters := dataBody["ids"].([]interface{})
  1553. if len(idsInters) == 0 {
  1554. if err != nil {
  1555. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  1556. return
  1557. }
  1558. }
  1559. ids := make([]int64, 0)
  1560. for _, idsInter := range idsInters {
  1561. id := int64(idsInter.(float64))
  1562. ids = append(ids, id)
  1563. }
  1564. fmt.Println("ids", ids)
  1565. err = service.DeleteCultrue(OrgID, ids)
  1566. fmt.Println("err", err)
  1567. if err != nil {
  1568. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  1569. return
  1570. }
  1571. returnData := make(map[string]interface{}, 0)
  1572. returnData["msg"] = "ok"
  1573. this.ServeSuccessJSON(returnData)
  1574. return
  1575. }
  1576. func (this *MachineApiController) EditDialystate() {
  1577. id, _ := this.GetInt64("id")
  1578. fmt.Println("id是什么", id)
  1579. dialysate, err := service.GetDialystate(id)
  1580. if err != nil {
  1581. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1582. return
  1583. }
  1584. this.ServeSuccessJSON(map[string]interface{}{
  1585. "dialysate": dialysate,
  1586. })
  1587. }
  1588. func (this *MachineApiController) Updatedialystate() {
  1589. timeLayout := "2006-01-02"
  1590. loc, _ := time.LoadLocation("Local")
  1591. dataBody := make(map[string]interface{}, 0)
  1592. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1593. fmt.Println("err", err)
  1594. id := int64(dataBody["id"].(float64))
  1595. fmt.Println("id", id)
  1596. samplingDate := dataBody["sampling_date"].(string)
  1597. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  1598. samp_date := sampdate.Unix()
  1599. fmt.Println("取样日期", samp_date)
  1600. specimentb := int64(dataBody["specimenb"].(float64))
  1601. fmt.Println("取样标本", specimentb)
  1602. concentratec := dataBody["concentrate_noc"].(string)
  1603. fmt.Println("A浓缩液批号", concentratec)
  1604. concentraeb := dataBody["concentrateb_nod"].(string)
  1605. fmt.Println("B浓缩", concentraeb)
  1606. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  1607. fmt.Println("采样部位", samplinglocationb)
  1608. samplerb := int64(dataBody["samplerb"].(float64))
  1609. fmt.Println("取样者", samplerb)
  1610. reportDateb := dataBody["reporting_dateb"].(string)
  1611. //fmt.Println("日期", reportDateb)
  1612. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  1613. report_date := location.Unix()
  1614. fmt.Println("出报告2日期", report_date)
  1615. detectionResultb := dataBody["detection_resultb"].(string)
  1616. fmt.Println("检测结果", detectionResultb)
  1617. detectionUnit := dataBody["detection_unit"].(string)
  1618. fmt.Println("检测单位", detectionUnit)
  1619. sort := dataBody["sort"].(string)
  1620. pass_examination := int64(dataBody["pass_examination"].(float64))
  1621. modifications := int64(dataBody["modifications"].(float64))
  1622. adminUser := this.GetAdminUserInfo()
  1623. orgid := adminUser.CurrentOrgId
  1624. dialysate := models.DeviceDialysate{
  1625. SamplingDate: samp_date,
  1626. Specimenb: specimentb,
  1627. ConcentrateNoc: concentratec,
  1628. ConcentratebNod: concentraeb,
  1629. SamplingLocationb: samplinglocationb,
  1630. DetectionUnit: detectionUnit,
  1631. Samplerb: samplerb,
  1632. ReportingDateb: report_date,
  1633. DetectionResultb: detectionResultb,
  1634. Sort: sort,
  1635. PassExamination: pass_examination,
  1636. Modifications: modifications,
  1637. }
  1638. err = service.Updatedialystate(id, orgid, &dialysate)
  1639. if err != nil {
  1640. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1641. return
  1642. }
  1643. this.ServeSuccessJSON(map[string]interface{}{
  1644. "dialysate": dialysate,
  1645. })
  1646. }
  1647. func (this *MachineApiController) DeleteDialystate() {
  1648. adminUserInfo := this.GetAdminUserInfo()
  1649. OrgID := adminUserInfo.CurrentOrgId
  1650. dataBody := make(map[string]interface{}, 0)
  1651. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1652. if err != nil {
  1653. utils.ErrorLog(err.Error())
  1654. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1655. return
  1656. }
  1657. idsInters := dataBody["ids"].([]interface{})
  1658. if len(idsInters) == 0 {
  1659. if err != nil {
  1660. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  1661. return
  1662. }
  1663. }
  1664. ids := make([]int64, 0)
  1665. for _, idsInter := range idsInters {
  1666. id := int64(idsInter.(float64))
  1667. ids = append(ids, id)
  1668. }
  1669. fmt.Println("ids", ids)
  1670. err = service.DeleteDialystate(OrgID, ids)
  1671. fmt.Println("err", err)
  1672. if err != nil {
  1673. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  1674. return
  1675. }
  1676. returnData := make(map[string]interface{}, 0)
  1677. returnData["msg"] = "ok"
  1678. this.ServeSuccessJSON(returnData)
  1679. return
  1680. }
  1681. func (this *MachineApiController) Edition() {
  1682. id, _ := this.GetInt64("id")
  1683. fmt.Println("id", id)
  1684. ion, err := service.GetIon(id)
  1685. if err != nil {
  1686. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1687. return
  1688. }
  1689. this.ServeSuccessJSON(map[string]interface{}{
  1690. "ion": ion,
  1691. })
  1692. }
  1693. func (this *MachineApiController) UpdateIon() {
  1694. timeLayout := "2006-01-02"
  1695. loc, _ := time.LoadLocation("Local")
  1696. dataBody := make(map[string]interface{}, 0)
  1697. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1698. fmt.Println("err", err)
  1699. id := int64(dataBody["id"].(float64))
  1700. fmt.Println("id", id)
  1701. dateb := dataBody["dateb"].(string)
  1702. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateb+" 00:00:00", loc)
  1703. dateB := inLocation.Unix()
  1704. samplerc := int64(dataBody["samplerc"].(float64))
  1705. concentratenof := dataBody["concentrate_nof"].(string)
  1706. concentrateonog := dataBody["concentrate_nog"].(string)
  1707. dateReportc := dataBody["date_reportc"].(string)
  1708. parseInLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", dateReportc+" 00:00:00", loc)
  1709. datec := parseInLocation.Unix()
  1710. actualNa := dataBody["actual_na"].(string)
  1711. actualPna := dataBody["actual_pna"].(string)
  1712. actualK := dataBody["actual_k"].(string)
  1713. actualCa := dataBody["actual_ca"].(string)
  1714. actualCi := dataBody["actual_ci"].(string)
  1715. actualHco := dataBody["actual_hco"].(string)
  1716. actualMg := dataBody["actual_mg"].(string)
  1717. actulaPH := dataBody["actual_ph"].(string)
  1718. remakes := dataBody["remakes"].(string)
  1719. detectionUnit := dataBody["detection_unit"].(string)
  1720. sort := dataBody["sort"].(string)
  1721. pass_examination := int64(dataBody["pass_examination"].(float64))
  1722. modifications := int64(dataBody["modifications"].(float64))
  1723. ion := models.DeviceIon{
  1724. SamplingDate: dateB,
  1725. Samplerc: samplerc,
  1726. DetectionUnit: detectionUnit,
  1727. ConcentrateNof: concentratenof,
  1728. ConcentrateNog: concentrateonog,
  1729. DateReportc: datec,
  1730. ActualNa: actualNa,
  1731. ActualPna: actualPna,
  1732. ActualK: actualK,
  1733. ActualCa: actualCa,
  1734. ActualCi: actualCi,
  1735. ActualHco: actualHco,
  1736. ActualMg: actualMg,
  1737. ActualPh: actulaPH,
  1738. Remakes: remakes,
  1739. Sort: sort,
  1740. PassExamination: pass_examination,
  1741. Modifications: modifications,
  1742. }
  1743. adminUser := this.GetAdminUserInfo()
  1744. orgId := adminUser.CurrentOrgId
  1745. err = service.UpdateIon(id, orgId, &ion)
  1746. if err != nil {
  1747. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1748. return
  1749. }
  1750. this.ServeSuccessJSON(map[string]interface{}{
  1751. "ion": ion,
  1752. })
  1753. }
  1754. func (this *MachineApiController) DeleteIon() {
  1755. adminUserInfo := this.GetAdminUserInfo()
  1756. OrgID := adminUserInfo.CurrentOrgId
  1757. dataBody := make(map[string]interface{}, 0)
  1758. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1759. if err != nil {
  1760. utils.ErrorLog(err.Error())
  1761. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  1762. return
  1763. }
  1764. idsInters := dataBody["ids"].([]interface{})
  1765. if len(idsInters) == 0 {
  1766. if err != nil {
  1767. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  1768. return
  1769. }
  1770. }
  1771. ids := make([]int64, 0)
  1772. for _, idsInter := range idsInters {
  1773. id := int64(idsInter.(float64))
  1774. ids = append(ids, id)
  1775. }
  1776. fmt.Println("ids", ids)
  1777. err = service.DeleteIon(OrgID, ids)
  1778. if err != nil {
  1779. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  1780. return
  1781. }
  1782. returnData := make(map[string]interface{}, 0)
  1783. returnData["msg"] = "ok"
  1784. this.ServeSuccessJSON(returnData)
  1785. return
  1786. }
  1787. func (this *MachineApiController) GetQuery() {
  1788. timeLayout := "2006-01-02"
  1789. loc, _ := time.LoadLocation("Local")
  1790. adminUserInfo := this.GetAdminUserInfo()
  1791. OrgID := adminUserInfo.CurrentOrgId
  1792. fmt.Println("orgid", OrgID)
  1793. bedid, _ := this.GetInt64("bedid")
  1794. fmt.Println("bedid", bedid)
  1795. startime := this.GetString("startime")
  1796. fmt.Println("starttime", startime)
  1797. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  1798. start := inLocation.Unix()
  1799. fmt.Println("start", start)
  1800. endtime := this.GetString("endtime")
  1801. fmt.Println("endtime", endtime)
  1802. endLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  1803. end := endLocation.Unix()
  1804. fmt.Println("end", end)
  1805. cultures, err := service.GetCultureData(bedid, start, end, OrgID)
  1806. fmt.Print(err)
  1807. dialysate, err := service.GetDialysateData(bedid, start, end, OrgID)
  1808. ions, err := service.GetDeviceIonData(bedid, start, end, OrgID)
  1809. oxygenates, err := service.GetOxygenates(bedid, start, end, OrgID)
  1810. hadwater, err := service.GetHardWater(bedid, start, end, OrgID)
  1811. water, err := service.GetWater(bedid, start, end, OrgID)
  1812. deviceph, err := service.GetDevicePh(bedid, start, end, OrgID)
  1813. if err != nil {
  1814. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1815. return
  1816. }
  1817. this.ServeSuccessJSON(map[string]interface{}{
  1818. "cultures": cultures,
  1819. "dialysate": dialysate,
  1820. "ions": ions,
  1821. "oxygenates": oxygenates,
  1822. "hadwater": hadwater,
  1823. "water": water,
  1824. "deviceph": deviceph,
  1825. })
  1826. }
  1827. func (this *MachineApiController) SaveRepair() {
  1828. timeLayout := "2006-01-02"
  1829. loc, _ := time.LoadLocation("Local")
  1830. adminUserInfo := this.GetAdminUserInfo()
  1831. id, _ := this.GetInt64("id")
  1832. addmacher, _ := service.GetBedId(id)
  1833. OrgID := adminUserInfo.CurrentOrgId
  1834. dataBody := make(map[string]interface{}, 0)
  1835. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1836. fmt.Println("err", err)
  1837. gua_date := dataBody["guarantee_date"].(string)
  1838. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", gua_date+" 00:00:00", loc)
  1839. guaDate := inLocation.Unix()
  1840. startDateStr := dataBody["start_time"].(string)
  1841. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  1842. arriveDateStr := dataBody["arrive_time"].(string)
  1843. arriveDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", arriveDateStr)
  1844. finishDateStr := dataBody["finish_time"].(string)
  1845. finishDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", finishDateStr)
  1846. totaldistance := dataBody["total_distance"].(string)
  1847. failurestate := int64(dataBody["failure_stage"].(float64))
  1848. codeInformation := dataBody["code_information"].(string)
  1849. faultdescription := dataBody["fault_description"].(string)
  1850. causeAnalysis := dataBody["cause_analysis"].(string)
  1851. treatmentprocess := dataBody["treatment_process"].(string)
  1852. images := dataBody["images"].(string)
  1853. exclude := int64(dataBody["exclude"].(float64))
  1854. reason := dataBody["reason"].(string)
  1855. imageName := dataBody["imageName"].(string)
  1856. function_accessories_inspection := dataBody["function_accessories_inspection"].(string)
  1857. other_information := dataBody["other_information"].(string)
  1858. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  1859. repair := models.DeviceRepair{
  1860. BedId: addmacher.BedId,
  1861. EquitmentId: id,
  1862. GuaranteeDate: guaDate,
  1863. StartTime: startDate.Unix(),
  1864. ArriveTime: arriveDate.Unix(),
  1865. FinishTime: finishDate.Unix(),
  1866. TotalDistance: totaldistance,
  1867. FailureStage: failurestate,
  1868. FaultDescription: faultdescription,
  1869. CauseAnalysis: causeAnalysis,
  1870. TreatmentProcess: treatmentprocess,
  1871. Images: images,
  1872. Exclude: exclude,
  1873. Reason: reason,
  1874. Status: 1,
  1875. UserOrgId: OrgID,
  1876. Ctime: time.Now().Unix(),
  1877. CodeInformation: codeInformation,
  1878. ImageName: imageName,
  1879. FunctionAccessoriesInspection: function_accessories_inspection,
  1880. OtherInformation: other_information,
  1881. AdminUserId: admin_user_id,
  1882. }
  1883. err = service.CreateRepair(&repair)
  1884. if err != nil {
  1885. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1886. return
  1887. }
  1888. this.ServeSuccessJSON(map[string]interface{}{
  1889. "repair": repair,
  1890. })
  1891. }
  1892. func (this *MachineApiController) GetAllRepair() {
  1893. limit, _ := this.GetInt64("limit")
  1894. page, _ := this.GetInt64("page")
  1895. adminUser := this.GetAdminUserInfo()
  1896. orgID := adminUser.CurrentOrgId
  1897. appId := adminUser.CurrentAppId
  1898. repair, total, err := service.GetAllRepair(orgID, limit, page)
  1899. addmacher, _ := service.GetAllMachineByOrgId(orgID)
  1900. docList, _ := service.GetAllDoctor(orgID, appId)
  1901. if err != nil {
  1902. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1903. return
  1904. }
  1905. this.ServeSuccessJSON(map[string]interface{}{
  1906. "repair": repair,
  1907. "total": total,
  1908. "macherList": addmacher,
  1909. "docList": docList,
  1910. })
  1911. }
  1912. func (this *MachineApiController) EditRepair() {
  1913. id, _ := this.GetInt64("id")
  1914. appId := this.GetAdminUserInfo().CurrentAppId
  1915. orgId := this.GetAdminUserInfo().CurrentOrgId
  1916. repair, err := service.EditRepair(id)
  1917. docList, _ := service.GetAllDoctor(orgId, appId)
  1918. if err != nil {
  1919. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1920. return
  1921. }
  1922. this.ServeSuccessJSON(map[string]interface{}{
  1923. "repair": repair,
  1924. "docList": docList,
  1925. })
  1926. }
  1927. func (this *MachineApiController) UpdateRepair() {
  1928. timeLayout := "2006-01-02"
  1929. loc, _ := time.LoadLocation("Local")
  1930. adminUserInfo := this.GetAdminUserInfo()
  1931. OrgID := adminUserInfo.CurrentOrgId
  1932. fmt.Println("orgid", OrgID)
  1933. dataBody := make(map[string]interface{}, 0)
  1934. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  1935. fmt.Println("err", err)
  1936. id := int64(dataBody["id"].(float64))
  1937. gua_date := dataBody["guarantee_date"].(string)
  1938. fmt.Println("保修日期", gua_date)
  1939. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", gua_date+" 00:00:00", loc)
  1940. guaDate := inLocation.Unix()
  1941. fmt.Println("保修日期", guaDate)
  1942. startDateStr := dataBody["start_time"].(string)
  1943. fmt.Println("出发时间", startDateStr)
  1944. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  1945. fmt.Println("触发事件", startDate.Unix())
  1946. arriveDateStr := dataBody["arrive_time"].(string)
  1947. fmt.Println("到达时间", arriveDateStr)
  1948. arriveDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", arriveDateStr)
  1949. fmt.Println("到达时间", arriveDate.Unix())
  1950. finishDateStr := dataBody["finish_time"].(string)
  1951. fmt.Println("完成时间", finishDateStr)
  1952. finishDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", finishDateStr)
  1953. fmt.Println("完成时间", finishDate.Unix())
  1954. totaldistance := dataBody["total_distance"].(string)
  1955. fmt.Println("总公里输", totaldistance)
  1956. failurestate := int64(dataBody["failure_stage"].(float64))
  1957. fmt.Println("故事范式阶段", failurestate)
  1958. codeInformation := dataBody["code_information"].(string)
  1959. fmt.Println("故事提示信息及代码", codeInformation)
  1960. faultdescription := dataBody["fault_description"].(string)
  1961. fmt.Println("故障描述", faultdescription)
  1962. causeAnalysis := dataBody["cause_analysis"].(string)
  1963. fmt.Println("原因分析", causeAnalysis)
  1964. treatmentprocess := dataBody["treatment_process"].(string)
  1965. fmt.Println("处理过程", treatmentprocess)
  1966. images := dataBody["images"].(string)
  1967. fmt.Println("上传图片", images)
  1968. exclude := int64(dataBody["exclude"].(float64))
  1969. fmt.Println("故障是否排除", exclude)
  1970. reason := dataBody["reason"].(string)
  1971. fmt.Println("原因", reason)
  1972. imageName := dataBody["image_name"].(string)
  1973. function_accessories_inspection := dataBody["function_accessories_inspection"].(string)
  1974. other_information := dataBody["other_information"].(string)
  1975. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  1976. deviceRepair := models.DeviceRepair{
  1977. GuaranteeDate: guaDate,
  1978. StartTime: startDate.Unix(),
  1979. ArriveTime: arriveDate.Unix(),
  1980. FinishTime: finishDate.Unix(),
  1981. TotalDistance: totaldistance,
  1982. FailureStage: failurestate,
  1983. FaultDescription: faultdescription,
  1984. CauseAnalysis: causeAnalysis,
  1985. TreatmentProcess: treatmentprocess,
  1986. Images: images,
  1987. Exclude: exclude,
  1988. Reason: reason,
  1989. CodeInformation: codeInformation,
  1990. ImageName: imageName,
  1991. FunctionAccessoriesInspection: function_accessories_inspection,
  1992. OtherInformation: other_information,
  1993. AdminUserId: admin_user_id,
  1994. }
  1995. err = service.UpdateRepair(id, OrgID, &deviceRepair)
  1996. if err != nil {
  1997. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  1998. return
  1999. }
  2000. this.ServeSuccessJSON(map[string]interface{}{
  2001. "repair": deviceRepair,
  2002. })
  2003. }
  2004. func (this *MachineApiController) DeleteRepair() {
  2005. adminUserInfo := this.GetAdminUserInfo()
  2006. OrgID := adminUserInfo.CurrentOrgId
  2007. dataBody := make(map[string]interface{}, 0)
  2008. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2009. if err != nil {
  2010. utils.ErrorLog(err.Error())
  2011. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  2012. return
  2013. }
  2014. idsInters := dataBody["ids"].([]interface{})
  2015. if len(idsInters) == 0 {
  2016. if err != nil {
  2017. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  2018. return
  2019. }
  2020. }
  2021. ids := make([]int64, 0)
  2022. for _, idsInter := range idsInters {
  2023. id := int64(idsInter.(float64))
  2024. ids = append(ids, id)
  2025. }
  2026. fmt.Println("ids", ids)
  2027. err = service.DeleteRepair(OrgID, ids)
  2028. if err != nil {
  2029. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  2030. return
  2031. }
  2032. returnData := make(map[string]interface{}, 0)
  2033. returnData["msg"] = "ok"
  2034. this.ServeSuccessJSON(returnData)
  2035. return
  2036. }
  2037. func (this *MachineApiController) GetRepair() {
  2038. timeLayout := "2006-01-02"
  2039. loc, _ := time.LoadLocation("Local")
  2040. adminUserInfo := this.GetAdminUserInfo()
  2041. OrgID := adminUserInfo.CurrentOrgId
  2042. fmt.Println("orgid", OrgID)
  2043. bedid, _ := this.GetInt64("bedid")
  2044. fmt.Println("bedid", bedid)
  2045. startime := this.GetString("startime")
  2046. fmt.Println("starttime", startime)
  2047. inLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  2048. start := inLocation.Unix()
  2049. fmt.Println("start", start)
  2050. endtime := this.GetString("endtime")
  2051. fmt.Println("endtime", endtime)
  2052. endLocation, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  2053. end := endLocation.Unix()
  2054. fmt.Println("end", end)
  2055. repair, err := service.GetRepair(bedid, start, end, OrgID)
  2056. if err != nil {
  2057. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询失败:("+err.Error()+")")
  2058. return
  2059. }
  2060. this.ServeSuccessJSON(map[string]interface{}{
  2061. "repair": repair,
  2062. })
  2063. }
  2064. func (this *MachineApiController) EditUser() {
  2065. adminUser := this.GetAdminUserInfo()
  2066. orgId := adminUser.CurrentOrgId
  2067. id, _ := this.GetInt64("id")
  2068. fmt.Println("id", id)
  2069. patientid, _ := this.GetInt64("patientid")
  2070. device, _ := service.GetUserInformation(id)
  2071. //获取初次使用记录
  2072. macher, _ := service.GetUserTotalByMacher(device.EquimentId)
  2073. count, _ := service.GetUserTotalCount(orgId, device.BedNumber)
  2074. patients, _ := service.GetPatientInfoMation(patientid)
  2075. this.ServeSuccessJSON(map[string]interface{}{
  2076. "device": device,
  2077. "patients": patients,
  2078. "count": count,
  2079. "macher": macher,
  2080. })
  2081. }
  2082. func (this *MachineApiController) DeleteForm() {
  2083. adminUserInfo := this.GetAdminUserInfo()
  2084. OrgID := adminUserInfo.CurrentOrgId
  2085. dataBody := make(map[string]interface{}, 0)
  2086. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2087. if err != nil {
  2088. utils.ErrorLog(err.Error())
  2089. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  2090. return
  2091. }
  2092. idsInters := dataBody["ids"].([]interface{})
  2093. if len(idsInters) == 0 {
  2094. if err != nil {
  2095. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除会员失败:(没有选择会员)")
  2096. return
  2097. }
  2098. }
  2099. ids := make([]int64, 0)
  2100. for _, idsInter := range idsInters {
  2101. id := int64(idsInter.(float64))
  2102. ids = append(ids, id)
  2103. }
  2104. fmt.Println("ids", ids)
  2105. err = service.DeleteForm(OrgID, ids)
  2106. if err != nil {
  2107. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败:("+err.Error()+")")
  2108. return
  2109. }
  2110. returnData := make(map[string]interface{}, 0)
  2111. returnData["msg"] = "ok"
  2112. this.ServeSuccessJSON(returnData)
  2113. return
  2114. }
  2115. func (this *MachineApiController) UpdateForm() {
  2116. dataBody := make(map[string]interface{}, 0)
  2117. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2118. fmt.Println("错误是", err)
  2119. adminUserInfo := this.GetAdminUserInfo()
  2120. orgid := adminUserInfo.CurrentOrgId
  2121. date := dataBody["spling_date"].(string)
  2122. timeLayout := "2006-01-02"
  2123. loc, _ := time.LoadLocation("Local")
  2124. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  2125. startdate := theTime.Unix()
  2126. fmt.Println("日期", startdate)
  2127. id := int64(dataBody["id"].(float64))
  2128. fmt.Println("id", id)
  2129. classtype := int64(dataBody["classtype"].(float64))
  2130. fmt.Println("班次", classtype)
  2131. zone := int64(dataBody["zone"].(float64))
  2132. fmt.Println("分区", zone)
  2133. bednumber := int64(dataBody["bed_number"].(float64))
  2134. fmt.Println("床位号", bednumber)
  2135. number, _ := service.GetNumbers(bednumber, orgid)
  2136. patient_id := int64(dataBody["patient_id"].(float64))
  2137. fmt.Println("患者", patient_id)
  2138. contagion := dataBody["contagion"].(string)
  2139. fmt.Println("传染病", contagion)
  2140. dialysis_mode := int64(dataBody["dialysis_mode"].(float64))
  2141. fmt.Println("透析方式", dialysis_mode)
  2142. startDateStr := dataBody["start_time"].(string)
  2143. fmt.Println("上机时间", startDateStr)
  2144. startDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", startDateStr)
  2145. fmt.Println("上机时间", startDate.Unix())
  2146. endDateStr := dataBody["end_time"].(string)
  2147. fmt.Println("上机时间", startDateStr)
  2148. endDate, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", endDateStr)
  2149. fmt.Println("上机时间", endDate.Unix())
  2150. dialysis_time := dataBody["dialysis_time"].(string)
  2151. fmt.Println("透析时长", dialysis_time)
  2152. hyperfiletration := dataBody["hyperfiltratio"].(float64)
  2153. fmt.Println("实际超滤量", hyperfiletration)
  2154. weight_loss := dataBody["weight_loss"].(float64)
  2155. fmt.Println("体重减少", weight_loss)
  2156. warining_value := dataBody["warning_value"].(string)
  2157. fmt.Println("预警值", warining_value)
  2158. //user_total := int64(dataBody["user_total"].(float64))
  2159. user_total := dataBody["user_total"].(string)
  2160. fmt.Println("使用次数", user_total)
  2161. run := int64(dataBody["run"].(float64))
  2162. fmt.Println("运行", run)
  2163. failure_stage := int64(dataBody["failure_stage"].(float64))
  2164. fmt.Println("故事发生阶段", failure_stage)
  2165. falult_desciription := dataBody["fault_description"].(string)
  2166. fmt.Println("故障描述", falult_desciription)
  2167. code_information := dataBody["code_information"].(string)
  2168. fmt.Println("故障提示及代码", code_information)
  2169. //机器消毒
  2170. disinfect_type := int64(dataBody["disinfect_type"].(float64))
  2171. fmt.Println("消毒方式", disinfect_type)
  2172. disinfectant_type := int64(dataBody["disinfectant_type"].(float64))
  2173. fmt.Println("消毒液", disinfectant_type)
  2174. disinfection := int64(dataBody["disinfection"].(float64))
  2175. fmt.Println("消毒状态", disinfection)
  2176. machine_run := int64(dataBody["machine_run"].(float64))
  2177. fmt.Println("运行", machine_run)
  2178. //液路
  2179. fluid_path := int64(dataBody["fluid_path"].(float64))
  2180. fmt.Println("液路消毒方式", fluid_path)
  2181. disinfectant := int64(dataBody["disinfectant"].(float64))
  2182. fmt.Println("消毒液", disinfectant)
  2183. disinfection_status := int64(dataBody["disinfection_status"].(float64))
  2184. fmt.Println("消毒状态", disinfection_status)
  2185. disinfection_residue := int64(dataBody["disinfection_residue"].(float64))
  2186. fmt.Println("消毒液残留", disinfection_residue)
  2187. longtime := dataBody["longtime"].(string)
  2188. fmt.Println("消毒时长", longtime)
  2189. starttime := dataBody["starttime"].(string)
  2190. disstarttime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", starttime)
  2191. distartime := disstarttime.Unix()
  2192. if distartime < 0 {
  2193. distartime = 0
  2194. }
  2195. //fmt.Println("开始消毒时间====", distartime)
  2196. entime := dataBody["endtime"].(string)
  2197. disendtime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", entime)
  2198. diendtime := disendtime.Unix()
  2199. fmt.Println("结束消毒时间", diendtime)
  2200. if diendtime < 0 {
  2201. diendtime = 0
  2202. }
  2203. dialysis_checked := int64(dataBody["dialysis_checked"].(float64))
  2204. //fmt.Println("更换", dialysis_checked)
  2205. dialysis_name := int64(dataBody["dialysis_name"].(float64))
  2206. fmt.Println("名称", dialysis_name)
  2207. norms := dataBody["norms"].(string)
  2208. fmt.Println("规格", norms)
  2209. dialysis_concentration := int64(dataBody["dialysis_concentration"].(float64))
  2210. fmt.Println("浓度", dialysis_concentration)
  2211. germ_checked := int64(dataBody["germ_checked"].(float64))
  2212. fmt.Println("更换", germ_checked)
  2213. germ_name := int64(dataBody["germ_name"].(float64))
  2214. fmt.Println("名称", germ_name)
  2215. //germ_number := int64(dataBody["germ_number"].(float64))
  2216. germ_number := dataBody["germ_number"].(string)
  2217. fmt.Println("数量", germ_number)
  2218. clean := int64(dataBody["clean"].(float64))
  2219. fmt.Println("清洁", clean)
  2220. sign_name := int64(dataBody["sign_name"].(float64))
  2221. fmt.Println("签名", sign_name)
  2222. equitment_id := int64(dataBody["equiment_id"].(float64))
  2223. fmt.Println("设备ID", equitment_id)
  2224. addmacher := models.DeviceAddmacher{
  2225. BedId: bednumber,
  2226. }
  2227. //更新床位号
  2228. err = service.UpdateAddMacherBedID(equitment_id, orgid, &addmacher)
  2229. fmt.Println("更新设备失败", err)
  2230. //更新区号
  2231. //deviceNumber := models.DeviceNumber{
  2232. // ZoneID: zone,
  2233. //}
  2234. //err = service.UpdatedZoneID(bednumber, orgid, &deviceNumber)
  2235. //fmt.Println("更新区号失败", err)
  2236. information := models.DeviceInformation{
  2237. Date: startdate,
  2238. Class: classtype,
  2239. Zone: zone,
  2240. BedNumber: bednumber,
  2241. Contagion: contagion,
  2242. DialysisMode: dialysis_mode,
  2243. StartTime: startDate.Unix(),
  2244. EndTime: endDate.Unix(),
  2245. DialysisHour: dialysis_time,
  2246. Hyperfiltratio: hyperfiletration,
  2247. WeightLoss: weight_loss,
  2248. WarningValue: warining_value,
  2249. UserTotal: user_total,
  2250. Move: run,
  2251. FailureStage: failure_stage,
  2252. FaultDescription: falult_desciription,
  2253. CodeInformation: code_information,
  2254. DisinfectantType: disinfectant_type,
  2255. DisinfectType: disinfect_type,
  2256. Disinfection: disinfection,
  2257. MachineRun: machine_run,
  2258. FluidPath: fluid_path,
  2259. Disinfectant: disinfectant,
  2260. DisinfectionStatus: disinfection_status,
  2261. DisinfectionResidue: disinfection_residue,
  2262. LongTime: longtime,
  2263. DisinfecStartime: distartime,
  2264. DisinfecEndtime: diendtime,
  2265. DialysisChecked: dialysis_checked,
  2266. DialysisName: dialysis_name,
  2267. Norms: norms,
  2268. DialysisConcentration: dialysis_concentration,
  2269. GermChecked: germ_checked,
  2270. GermName: germ_name,
  2271. GermNumber: germ_number,
  2272. Clean: clean,
  2273. SignName: sign_name,
  2274. Ctime: time.Now().Unix(),
  2275. Status: 1,
  2276. UserOrgId: orgid,
  2277. EquimentId: id,
  2278. Bed: number.Number,
  2279. PatientId: patient_id,
  2280. }
  2281. err = service.UpadateForm(id, orgid, &information)
  2282. fmt.Println("报错", err)
  2283. if err != nil {
  2284. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "修改失败:("+err.Error()+")")
  2285. return
  2286. }
  2287. this.ServeSuccessJSON(map[string]interface{}{
  2288. "information": information,
  2289. })
  2290. }
  2291. func (this *MachineApiController) QueryInfo() {
  2292. zone, _ := this.GetInt64("zone")
  2293. fmt.Println("zone", zone)
  2294. //bed, _ := this.GetInt64("bed")
  2295. //fmt.Println("bed", bed)
  2296. bed, _ := this.GetInt64("bed")
  2297. startime := this.GetString("startime")
  2298. timeLayout := "2006-01-02"
  2299. loc, _ := time.LoadLocation("Local")
  2300. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", startime+" 00:00:00", loc)
  2301. startdate := theTime.Unix()
  2302. fmt.Println("开始时间", startdate)
  2303. endtime := this.GetString("endtime")
  2304. theTimes, _ := time.ParseInLocation(timeLayout+" 15:04:05", endtime+" 00:00:00", loc)
  2305. endtimes := theTimes.Unix()
  2306. fmt.Println("结束", endtimes)
  2307. limit, _ := this.GetInt64("limit")
  2308. fmt.Println("limit", limit)
  2309. page, _ := this.GetInt64("page")
  2310. fmt.Println("page", page)
  2311. adminUser := this.GetAdminUserInfo()
  2312. orgId := adminUser.CurrentOrgId
  2313. infor, total, err := service.QueryInfo(bed, startdate, endtimes, orgId, limit, page)
  2314. if err != nil {
  2315. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2316. return
  2317. }
  2318. this.ServeSuccessJSON(map[string]interface{}{
  2319. "infor": infor,
  2320. "total": total,
  2321. })
  2322. }
  2323. func (this *MachineApiController) InsertAutoData() {
  2324. id, _ := this.GetInt64("id")
  2325. addmacher, _ := service.GetBedId(id)
  2326. fmt.Println("床位号", addmacher.BedId)
  2327. adminUser := this.GetAdminUserInfo()
  2328. timeStr := time.Now().Format("2006-01-02")
  2329. timeLayout := "2006-01-02 15:04:05"
  2330. fmt.Println("timeStr:", timeStr)
  2331. timeStringToTime, _ := utils.ParseTimeStringToTime(timeLayout, timeStr+" 00:00:00")
  2332. timenow := timeStringToTime.Unix()
  2333. fmt.Println("timenow是什么", timenow)
  2334. orgId := adminUser.CurrentOrgId
  2335. dialysis, err := service.GetPatientID(id, orgId, timenow)
  2336. if err != nil {
  2337. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2338. return
  2339. }
  2340. this.ServeSuccessJSON(map[string]interface{}{
  2341. "dialysis": dialysis,
  2342. })
  2343. }
  2344. func (this *MachineApiController) GetAllEquitType() {
  2345. adminUserInfo := this.GetAdminUserInfo()
  2346. orgID := adminUserInfo.CurrentOrgId
  2347. fmt.Println("orgId", orgID)
  2348. //equitname, err := service.GetAllEquitType(orgID)
  2349. //name, err := service.GetAllEquitName(orgID)
  2350. mode, err := service.GetAllMode(orgID)
  2351. fmt.Print(err)
  2352. if err != nil {
  2353. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2354. return
  2355. }
  2356. this.ServeSuccessJSON(map[string]interface{}{
  2357. "mode": mode,
  2358. })
  2359. }
  2360. func (this *MachineApiController) GetUserForm() {
  2361. id, _ := this.GetInt64("id")
  2362. fmt.Println("id是什么", id)
  2363. limit, _ := this.GetInt64("limit")
  2364. fmt.Println("limit", limit)
  2365. page, _ := this.GetInt64("page")
  2366. fmt.Println("page", page)
  2367. adminUserInfo := this.GetAdminUserInfo()
  2368. orgID := adminUserInfo.CurrentOrgId
  2369. fmt.Println("orgId", orgID)
  2370. information, total, err := service.GetUserForm(id, orgID, limit, page)
  2371. fmt.Print("information", information)
  2372. fmt.Println("错误", err)
  2373. addmacher, _ := service.GetBedNumber(id, orgID)
  2374. fmt.Println("addmacher", addmacher)
  2375. if err != nil {
  2376. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2377. return
  2378. }
  2379. this.ServeSuccessJSON(map[string]interface{}{
  2380. "information": information,
  2381. "total": total,
  2382. "addmacher": addmacher,
  2383. })
  2384. }
  2385. func (this *MachineApiController) GetBedForm() {
  2386. adminUser := this.GetAdminUserInfo()
  2387. orgId := adminUser.CurrentOrgId
  2388. id, _ := this.GetInt64("id")
  2389. fmt.Println("id", id)
  2390. addmacher, err := service.GetZoneForm(id)
  2391. bed, err := service.GetZoneId(addmacher.BedId, orgId)
  2392. number, err := service.GetBedForm(bed.ZoneID)
  2393. if err != nil {
  2394. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2395. return
  2396. }
  2397. this.ServeSuccessJSON(map[string]interface{}{
  2398. "addmacher": addmacher,
  2399. "number": number,
  2400. })
  2401. }
  2402. func (this *MachineApiController) GetTotalCount() {
  2403. info := this.GetAdminUserInfo()
  2404. orgid := info.CurrentOrgId
  2405. _, total, err := service.GetTotalCount(orgid)
  2406. fmt.Print("------------------------------声优", err)
  2407. if err != nil {
  2408. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2409. return
  2410. }
  2411. this.ServeSuccessJSON(map[string]interface{}{
  2412. "total": total,
  2413. })
  2414. }
  2415. func (this *MachineApiController) GetTotalNumber() {
  2416. id, _ := this.GetInt64("id")
  2417. fmt.Println("id", id)
  2418. info := this.GetAdminUserInfo()
  2419. orgId := info.CurrentOrgId
  2420. total, _ := service.GetTotalNumber(id, orgId)
  2421. //fmt.Println("total",total)
  2422. //fmt.Println("====================真的",err)
  2423. //if err != nil {
  2424. // this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2425. // return
  2426. //}
  2427. this.ServeSuccessJSON(map[string]interface{}{
  2428. "total": total,
  2429. })
  2430. }
  2431. func (this *MachineApiController) GetTimeWarning() {
  2432. id, _ := this.GetInt64("id")
  2433. fmt.Println("设备id", id)
  2434. adminUserInfo := this.GetAdminUserInfo()
  2435. orgId := adminUserInfo.CurrentOrgId
  2436. //获取透析机消毒液更换的最后一次更换日期
  2437. information, err := service.GetTimeWarning(id, orgId)
  2438. //获取透析机消毒液细菌过滤器的最后一次更换日期
  2439. deviceInformation, err := service.GetTimeLast(id, orgId)
  2440. //获取空气滤网清洁最后一次更换日期
  2441. clean, err := service.GetTimeLastData(id, orgId)
  2442. if err != nil {
  2443. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "查询:("+err.Error()+")")
  2444. return
  2445. }
  2446. this.ServeSuccessJSON(map[string]interface{}{
  2447. "informations": information,
  2448. "deviceInformation": deviceInformation,
  2449. "clean": clean,
  2450. })
  2451. }
  2452. func (this *MachineApiController) SaveManageinfoTwo() {
  2453. adminUserInfo := this.GetAdminUserInfo()
  2454. orgid := adminUserInfo.CurrentOrgId
  2455. dataBody := make(map[string]interface{}, 0)
  2456. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2457. fmt.Println("err", err)
  2458. serial_numbe := dataBody["serial_number"].(string)
  2459. device_type := int64(dataBody["device_type"].(float64))
  2460. bed_number := this.GetString("beds")
  2461. device_name := dataBody["device_name"].(string)
  2462. manufacture_factory := dataBody["manufacture_factory"].(string)
  2463. service_manufacturer := dataBody["service_manufacturer"].(string)
  2464. unit_type := int64(dataBody["unit_type"].(float64))
  2465. use_section := dataBody["use_section"].(string)
  2466. section_number := dataBody["section_number"].(string)
  2467. buy_date := dataBody["buy_date"].(string)
  2468. timeLayout := "2006-01-02 15:04:05"
  2469. theTime, err := utils.ParseTimeStringToTime(timeLayout, buy_date+" 00:00:00")
  2470. buydate := theTime.Unix()
  2471. int_num := *(*int)(unsafe.Pointer(&buydate))
  2472. if int_num < 0 {
  2473. buydate = 0
  2474. }
  2475. install_date := dataBody["install_date"].(string)
  2476. toTime, err := utils.ParseTimeStringToTime(timeLayout, install_date+" 00:00:00")
  2477. installdate := toTime.Unix()
  2478. buy_num := *(*int)(unsafe.Pointer(&installdate))
  2479. if buy_num < 0 {
  2480. installdate = 0
  2481. }
  2482. start_date := dataBody["start_date"].(string)
  2483. stringToTime, err := utils.ParseTimeStringToTime(timeLayout, start_date+" 00:00:00")
  2484. startdate := stringToTime.Unix()
  2485. start_num := *(*int)(unsafe.Pointer(&startdate))
  2486. if start_num < 0 {
  2487. startdate = 0
  2488. }
  2489. maintenance_engineer := dataBody["maintenance_engineer"].(string)
  2490. telephone := dataBody["telephone"].(string)
  2491. guarantee_date := dataBody["guarantee_date"].(string)
  2492. machine_status := int64(dataBody["machine_status"].(float64))
  2493. disinfection_mode := int64(dataBody["Disinfection_mode"].(float64))
  2494. remarks := dataBody["remarks"].(string)
  2495. rubbish_date := dataBody["rubbish_date"].(string)
  2496. timeStringToTime, err := utils.ParseTimeStringToTime(timeLayout, rubbish_date+" 00:00:00")
  2497. rubbishdate := timeStringToTime.Unix()
  2498. rubb_num := *(*int)(unsafe.Pointer(&rubbishdate))
  2499. if rubb_num < 0 {
  2500. rubbishdate = 0
  2501. }
  2502. rubbish_reason := int64(dataBody["rubbish_reason"].(float64))
  2503. user_year := dataBody["user_year"].(string)
  2504. work_time := dataBody["work_time"].(string)
  2505. revers := int64(dataBody["revers_mode"].(float64))
  2506. zone_id := int64(dataBody["zone_id"].(float64))
  2507. addmacher := &models.DeviceAddmacher{
  2508. SerialNumber: serial_numbe,
  2509. DeviceType: device_type,
  2510. BedNumber: bed_number,
  2511. DeviceName: device_name,
  2512. ManufactureFactory: manufacture_factory,
  2513. ServiceManufacturer: service_manufacturer,
  2514. UnitType: unit_type,
  2515. UseSection: use_section,
  2516. SectionNumber: section_number,
  2517. BuyDate: buydate,
  2518. InstallDate: installdate,
  2519. StartDate: startdate,
  2520. MaintenaceEngineer: maintenance_engineer,
  2521. Telephone: telephone,
  2522. GuaranteeDate: guarantee_date,
  2523. MachineStatus: machine_status,
  2524. DisinfectionMode: disinfection_mode,
  2525. Remarks: remarks,
  2526. RubbishDate: rubbishdate,
  2527. RubbishReason: rubbish_reason,
  2528. UserYear: user_year,
  2529. WorkTime: work_time,
  2530. ReversMode: revers,
  2531. Status: 1,
  2532. Ctime: time.Now().Unix(),
  2533. UserOrgId: orgid,
  2534. ZoneId: zone_id,
  2535. }
  2536. err = service.CreateMacher(addmacher)
  2537. fmt.Println("什么原因啊", err)
  2538. if err != nil {
  2539. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2540. return
  2541. }
  2542. this.ServeSuccessJSON(map[string]interface{}{
  2543. "addmacher": addmacher,
  2544. })
  2545. }
  2546. func (this *MachineApiController) GetAllpatient() {
  2547. adminUserInfo := this.GetAdminUserInfo()
  2548. orgid := adminUserInfo.CurrentOrgId
  2549. allpatient, err := service.GetAllpatient(orgid)
  2550. fmt.Print(err)
  2551. if err != nil {
  2552. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2553. return
  2554. }
  2555. this.ServeSuccessJSON(map[string]interface{}{
  2556. "allpatient": allpatient,
  2557. })
  2558. }
  2559. func (this *MachineApiController) ChangeBed() {
  2560. id, _ := this.GetInt64("id")
  2561. fmt.Print("id", id)
  2562. info := this.GetAdminUserInfo()
  2563. orgId := info.CurrentOrgId
  2564. bed, err := service.ChangeBed(id, orgId)
  2565. if err != nil {
  2566. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2567. return
  2568. }
  2569. this.ServeSuccessJSON(map[string]interface{}{
  2570. "bed": bed,
  2571. })
  2572. }
  2573. func (this *MachineApiController) GetPatientDetail() {
  2574. id, _ := this.GetInt64("id")
  2575. fmt.Print("id", id)
  2576. info := this.GetAdminUserInfo()
  2577. orgid := info.CurrentOrgId
  2578. patient, err := service.GetPatientDetail(id, orgid)
  2579. if err != nil {
  2580. this.ServeFailJsonSend(enums.ErrorCodeDataException, "添加设备失败")
  2581. return
  2582. }
  2583. this.ServeSuccessJSON(map[string]interface{}{
  2584. "patient": patient,
  2585. })
  2586. }
  2587. func (this *MachineApiController) SaveReminder() {
  2588. id, _ := this.GetInt64("id")
  2589. fmt.Print("码字", id)
  2590. info := this.GetAdminUserInfo()
  2591. orgId := info.CurrentOrgId
  2592. remander := models.DeviceRemander{
  2593. IsRun: id,
  2594. Status: 1,
  2595. UserOrgId: orgId,
  2596. Ctime: time.Now().Unix(),
  2597. }
  2598. data, errs := service.GetRemanderData(orgId)
  2599. if errs == gorm.ErrRecordNotFound {
  2600. err := service.CreateRemander(&remander).Error()
  2601. fmt.Print(err)
  2602. } else if errs == nil {
  2603. deviceRemander := models.DeviceRemander{
  2604. ID: data.ID,
  2605. IsRun: id,
  2606. Status: 1,
  2607. UserOrgId: orgId,
  2608. Mtime: time.Now().Unix(),
  2609. }
  2610. err := service.UpdateRemander(&deviceRemander)
  2611. if err != nil {
  2612. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2613. return
  2614. }
  2615. }
  2616. this.ServeSuccessJSON(map[string]interface{}{
  2617. "id": id,
  2618. })
  2619. return
  2620. }
  2621. func (this *MachineApiController) GetRemanderData() {
  2622. info := this.GetAdminUserInfo()
  2623. orgid := info.CurrentOrgId
  2624. data, err := service.GetRemanderData(orgid)
  2625. if err != nil {
  2626. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2627. return
  2628. }
  2629. this.ServeSuccessJSON(map[string]interface{}{
  2630. "remander": data,
  2631. })
  2632. }
  2633. func (this *MachineApiController) OpenDelete() {
  2634. id, _ := this.GetInt64("id")
  2635. err := service.DeletePlan(id)
  2636. if err != nil {
  2637. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2638. return
  2639. }
  2640. returnData := make(map[string]interface{}, 0)
  2641. returnData["msg"] = "ok"
  2642. this.ServeSuccessJSON(returnData)
  2643. return
  2644. }
  2645. func (this *MachineApiController) DeleteUserLogin() {
  2646. id, _ := this.GetInt64("id")
  2647. err := service.DeleteUserLogin(id)
  2648. if err != nil {
  2649. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2650. return
  2651. }
  2652. returnData := make(map[string]interface{}, 0)
  2653. returnData["msg"] = "ok"
  2654. this.ServeSuccessJSON(returnData)
  2655. return
  2656. }
  2657. func (this *MachineApiController) DeleteCultrues() {
  2658. id, _ := this.GetInt64("id")
  2659. err := service.DeleteCultrues(id)
  2660. if err != nil {
  2661. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2662. return
  2663. }
  2664. returnData := make(map[string]interface{}, 0)
  2665. returnData["msg"] = "ok"
  2666. this.ServeSuccessJSON(returnData)
  2667. return
  2668. }
  2669. func (this *MachineApiController) DeleteDialystates() {
  2670. id, _ := this.GetInt64("id")
  2671. err := service.DeleteDialystates(id)
  2672. if err != nil {
  2673. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2674. return
  2675. }
  2676. returnData := make(map[string]interface{}, 0)
  2677. returnData["msg"] = "ok"
  2678. this.ServeSuccessJSON(returnData)
  2679. return
  2680. }
  2681. func (this *MachineApiController) Deleteions() {
  2682. id, _ := this.GetInt64("id")
  2683. err := service.DeleteIons(id)
  2684. if err != nil {
  2685. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2686. return
  2687. }
  2688. returnData := make(map[string]interface{}, 0)
  2689. returnData["msg"] = "ok"
  2690. this.ServeSuccessJSON(returnData)
  2691. return
  2692. }
  2693. func (this *MachineApiController) DeleteRepairs() {
  2694. id, _ := this.GetInt64("id")
  2695. err := service.DeleteRepairs(id)
  2696. if err != nil {
  2697. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2698. return
  2699. }
  2700. returnData := make(map[string]interface{}, 0)
  2701. returnData["msg"] = "ok"
  2702. this.ServeSuccessJSON(returnData)
  2703. return
  2704. }
  2705. func (this *MachineApiController) SaveMode() {
  2706. adminUserInfo := this.GetAdminUserInfo()
  2707. orgid := adminUserInfo.CurrentOrgId
  2708. fmt.Println("机构id", orgid)
  2709. dataBody := make(map[string]interface{}, 0)
  2710. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2711. fmt.Println("err", err)
  2712. device_mode := dataBody["device_mode"].(string)
  2713. mode := models.DeviceMode{
  2714. DeviceMode: device_mode,
  2715. UserOrgId: orgid,
  2716. Status: 1,
  2717. Ctime: time.Now().Unix(),
  2718. }
  2719. _, errcode := service.GetMode(device_mode, orgid)
  2720. if errcode == gorm.ErrRecordNotFound {
  2721. err = service.SaveMode(&mode)
  2722. } else if errcode == nil {
  2723. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2724. return
  2725. } else {
  2726. }
  2727. if err != nil {
  2728. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2729. return
  2730. }
  2731. this.ServeSuccessJSON(map[string]interface{}{
  2732. "mode": mode,
  2733. })
  2734. }
  2735. func (this *MachineApiController) GetAllMode() {
  2736. fmt.Println("进来了没哟")
  2737. adminUserInfo := this.GetAdminUserInfo()
  2738. orgid := adminUserInfo.CurrentOrgId
  2739. mode, err := service.GetAllMode(orgid)
  2740. if err != nil {
  2741. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2742. return
  2743. }
  2744. this.ServeSuccessJSON(map[string]interface{}{
  2745. "mode": mode,
  2746. })
  2747. }
  2748. func (this *MachineApiController) EditMode() {
  2749. id, _ := this.GetInt64("id")
  2750. mode, err := service.GetModeById(id)
  2751. if err != nil {
  2752. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2753. return
  2754. }
  2755. this.ServeSuccessJSON(map[string]interface{}{
  2756. "mode": mode,
  2757. })
  2758. }
  2759. func (this *MachineApiController) UpdateMode() {
  2760. id, _ := this.GetInt64("id")
  2761. dataBody := make(map[string]interface{}, 0)
  2762. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2763. fmt.Println("err", err)
  2764. device_mode := dataBody["device_mode"].(string)
  2765. mode := models.DeviceMode{DeviceMode: device_mode}
  2766. err = service.UpdateMode(id, mode)
  2767. if err != nil {
  2768. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2769. return
  2770. }
  2771. this.ServeSuccessJSON(map[string]interface{}{
  2772. "mode": mode,
  2773. })
  2774. }
  2775. func (this *MachineApiController) DeleteMode() {
  2776. id, _ := this.GetInt64("id")
  2777. adminUserInfo := this.GetAdminUserInfo()
  2778. orgid := adminUserInfo.CurrentOrgId
  2779. _, errcode := service.QueryDeviceMode(id, orgid)
  2780. if errcode == gorm.ErrRecordNotFound {
  2781. service.DeleteMode(id)
  2782. returnData := make(map[string]interface{}, 0)
  2783. returnData["msg"] = "ok"
  2784. this.ServeSuccessJSON(returnData)
  2785. return
  2786. } else if errcode == nil {
  2787. return
  2788. } else {
  2789. fmt.Print("设备型号已存在")
  2790. }
  2791. }
  2792. func (this *MachineApiController) SelectChange() {
  2793. id, _ := this.GetInt64("id")
  2794. adminUserInfo := this.GetAdminUserInfo()
  2795. orgid := adminUserInfo.CurrentOrgId
  2796. change, err := service.SelectChange(id, orgid)
  2797. //fmt.Print("---------------------------", err)
  2798. if err != nil {
  2799. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2800. return
  2801. }
  2802. this.ServeSuccessJSON(map[string]interface{}{
  2803. "change": change,
  2804. })
  2805. }
  2806. func (this *MachineApiController) SelectBed() {
  2807. id, _ := this.GetInt64("id")
  2808. adminUserInfo := this.GetAdminUserInfo()
  2809. orgid := adminUserInfo.CurrentOrgId
  2810. bed, err := service.SelectBed(id, orgid)
  2811. if err != nil {
  2812. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2813. return
  2814. }
  2815. this.ServeSuccessJSON(map[string]interface{}{
  2816. "zone": bed,
  2817. })
  2818. }
  2819. func (this *MachineApiController) GetTimeData() {
  2820. equitid, _ := this.GetInt64("equitid")
  2821. fmt.Print("equitid", equitid)
  2822. timeLayout := "2006-01-02 15:04:05"
  2823. todaytime := this.GetString("todaytime")
  2824. theTime, _ := utils.ParseTimeStringToTime(timeLayout, todaytime+" 00:00:00")
  2825. fmt.Print("时间", theTime.Unix())
  2826. adminUserInfo := this.GetAdminUserInfo()
  2827. orgid := adminUserInfo.CurrentOrgId
  2828. timeData, err := service.GetTimeData(equitid, orgid, theTime.Unix())
  2829. fmt.Print("报错", err)
  2830. timeDataTwo, err := service.GetTimeTwo(equitid, orgid, theTime.Unix())
  2831. timeDataThree, err := service.GetTimeThree(equitid, orgid, theTime.Unix())
  2832. fmt.Print("err报错了没有", err)
  2833. if err != nil {
  2834. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2835. return
  2836. }
  2837. this.ServeSuccessJSON(map[string]interface{}{
  2838. "timeData": timeData,
  2839. "timeDataTwo": timeDataTwo,
  2840. "timeDataThree": timeDataThree,
  2841. })
  2842. }
  2843. func (this *MachineApiController) DeleteImages() {
  2844. id, _ := this.GetInt64("id")
  2845. err := service.DeleteImages(id)
  2846. fmt.Print("err", err)
  2847. if err != nil {
  2848. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2849. return
  2850. }
  2851. returnData := make(map[string]interface{}, 0)
  2852. returnData["msg"] = "ok"
  2853. this.ServeSuccessJSON(returnData)
  2854. return
  2855. }
  2856. func (this *MachineApiController) GetUserMachTotalCount() {
  2857. adminUserInfo := this.GetAdminUserInfo()
  2858. orgid := adminUserInfo.CurrentOrgId
  2859. count, err := service.GetUserMachTotalCount(orgid)
  2860. if err != nil {
  2861. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2862. return
  2863. }
  2864. this.ServeSuccessJSON(map[string]interface{}{
  2865. "count": count,
  2866. })
  2867. }
  2868. func (this *MachineApiController) GetUserTotalCount() {
  2869. adminUserInfo := this.GetAdminUserInfo()
  2870. orgid := adminUserInfo.CurrentOrgId
  2871. id, _ := this.GetInt64("id")
  2872. count, err := service.GetUserTotalCount(orgid, id)
  2873. addmacher, err := service.GetUserTotal(orgid, id)
  2874. if err != nil {
  2875. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2876. return
  2877. }
  2878. this.ServeSuccessJSON(map[string]interface{}{
  2879. "count": count,
  2880. "addmacher": addmacher,
  2881. })
  2882. }
  2883. func (this *MachineApiController) DeleteManagement() {
  2884. id, _ := this.GetInt64("id")
  2885. _, err := service.DeleteEquit(id)
  2886. if err != nil {
  2887. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2888. return
  2889. }
  2890. returnData := make(map[string]interface{}, 0)
  2891. returnData["msg"] = "ok"
  2892. this.ServeSuccessJSON(returnData)
  2893. return
  2894. }
  2895. func (this *MachineApiController) SaveOxygenates() {
  2896. timeLayout := "2006-01-02"
  2897. loc, _ := time.LoadLocation("Local")
  2898. id, _ := this.GetInt64("id")
  2899. addmacher, _ := service.GetBedId(id)
  2900. adminUserInfo := this.GetAdminUserInfo()
  2901. orgid := adminUserInfo.CurrentOrgId
  2902. dataBody := make(map[string]interface{}, 0)
  2903. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2904. date := dataBody["sampling_date"].(string)
  2905. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  2906. samp_date := theTime.Unix()
  2907. specimen := int64(dataBody["specimenb"].(float64))
  2908. cona := dataBody["concentrate_noc"].(string)
  2909. conb := dataBody["concentrateb_nod"].(string)
  2910. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  2911. detectionUnit := dataBody["detection_unit"].(string)
  2912. samplerb := int64(dataBody["samplerb"].(float64))
  2913. reportDate := dataBody["reporting_dateb"].(string)
  2914. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  2915. repDate := reportTime.Unix()
  2916. detectionResult := dataBody["detection_resultb"].(string)
  2917. sort := dataBody["sort"].(string)
  2918. modifications := int64(dataBody["modifications"].(float64))
  2919. examination := dataBody["pass_examination"].(string)
  2920. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  2921. oxygenates := models.XtDeviceOxygenates{
  2922. SamplingDate: samp_date,
  2923. Specimenb: specimen,
  2924. ConcentrateNoc: cona,
  2925. ConcentratebNod: conb,
  2926. SamplingLocationb: samplinglocationb,
  2927. DetectionUnit: detectionUnit,
  2928. Samplerb: samplerb,
  2929. ReportingDateb: repDate,
  2930. DetectionResultb: detectionResult,
  2931. Ctime: time.Now().Unix(),
  2932. Status: 1,
  2933. UserOrgId: orgid,
  2934. BedId: addmacher.BedId,
  2935. EquitmentId: id,
  2936. Bed: addmacher.BedNumber,
  2937. Sort: sort,
  2938. PassExamination: pass_examination,
  2939. Modifications: modifications,
  2940. }
  2941. err = service.CreateOxygenates(&oxygenates)
  2942. if err != nil {
  2943. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2944. return
  2945. }
  2946. this.ServeSuccessJSON(map[string]interface{}{
  2947. "oxygenates": oxygenates,
  2948. })
  2949. }
  2950. func (this *MachineApiController) SaveHardWater() {
  2951. timeLayout := "2006-01-02"
  2952. loc, _ := time.LoadLocation("Local")
  2953. id, _ := this.GetInt64("id")
  2954. addmacher, _ := service.GetBedId(id)
  2955. adminUserInfo := this.GetAdminUserInfo()
  2956. orgid := adminUserInfo.CurrentOrgId
  2957. dataBody := make(map[string]interface{}, 0)
  2958. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2959. date := dataBody["sampling_date"].(string)
  2960. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  2961. samp_date := theTime.Unix()
  2962. specimen := int64(dataBody["specimenb"].(float64))
  2963. cona := dataBody["concentrate_noc"].(string)
  2964. conb := dataBody["concentrateb_nod"].(string)
  2965. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  2966. detectionUnit := dataBody["detection_unit"].(string)
  2967. samplerb := int64(dataBody["samplerb"].(float64))
  2968. reportDate := dataBody["reporting_dateb"].(string)
  2969. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  2970. repDate := reportTime.Unix()
  2971. detectionResult := dataBody["detection_resultb"].(string)
  2972. sort := dataBody["sort"].(string)
  2973. modifications := int64(dataBody["modifications"].(float64))
  2974. examination := dataBody["pass_examination"].(string)
  2975. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  2976. hadwater := models.XtDeviceHadwater{
  2977. SamplingDate: samp_date,
  2978. Specimenb: specimen,
  2979. ConcentrateNoc: cona,
  2980. ConcentratebNod: conb,
  2981. SamplingLocationb: samplinglocationb,
  2982. DetectionUnit: detectionUnit,
  2983. Samplerb: samplerb,
  2984. ReportingDateb: repDate,
  2985. DetectionResultb: detectionResult,
  2986. Ctime: time.Now().Unix(),
  2987. Status: 1,
  2988. UserOrgId: orgid,
  2989. BedId: addmacher.BedId,
  2990. EquitmentId: id,
  2991. Bed: addmacher.BedNumber,
  2992. Sort: sort,
  2993. PassExamination: pass_examination,
  2994. Modifications: modifications,
  2995. }
  2996. err = service.CreateHadWater(&hadwater)
  2997. if err != nil {
  2998. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2999. return
  3000. }
  3001. this.ServeSuccessJSON(map[string]interface{}{
  3002. "hadwater": hadwater,
  3003. })
  3004. }
  3005. func (this *MachineApiController) SaveWater() {
  3006. timeLayout := "2006-01-02"
  3007. loc, _ := time.LoadLocation("Local")
  3008. id, _ := this.GetInt64("id")
  3009. addmacher, _ := service.GetBedId(id)
  3010. adminUserInfo := this.GetAdminUserInfo()
  3011. orgid := adminUserInfo.CurrentOrgId
  3012. dataBody := make(map[string]interface{}, 0)
  3013. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3014. date := dataBody["sampling_date"].(string)
  3015. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  3016. samp_date := theTime.Unix()
  3017. specimen := int64(dataBody["specimenb"].(float64))
  3018. cona := dataBody["concentrate_noc"].(string)
  3019. conb := dataBody["concentrateb_nod"].(string)
  3020. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3021. detectionUnit := dataBody["detection_unit"].(string)
  3022. samplerb := int64(dataBody["samplerb"].(float64))
  3023. reportDate := dataBody["reporting_dateb"].(string)
  3024. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  3025. repDate := reportTime.Unix()
  3026. detectionResult := dataBody["detection_resultb"].(string)
  3027. sort := dataBody["sort"].(string)
  3028. modifications := int64(dataBody["modifications"].(float64))
  3029. examination := dataBody["pass_examination"].(string)
  3030. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  3031. deviceWater := models.XtDeviceWater{
  3032. SamplingDate: samp_date,
  3033. Specimenb: specimen,
  3034. ConcentrateNoc: cona,
  3035. ConcentratebNod: conb,
  3036. SamplingLocationb: samplinglocationb,
  3037. DetectionUnit: detectionUnit,
  3038. Samplerb: samplerb,
  3039. ReportingDateb: repDate,
  3040. DetectionResultb: detectionResult,
  3041. Ctime: time.Now().Unix(),
  3042. Status: 1,
  3043. UserOrgId: orgid,
  3044. BedId: addmacher.BedId,
  3045. EquitmentId: id,
  3046. Bed: addmacher.BedNumber,
  3047. Sort: sort,
  3048. PassExamination: pass_examination,
  3049. Modifications: modifications,
  3050. }
  3051. err = service.CreateWater(&deviceWater)
  3052. if err != nil {
  3053. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3054. return
  3055. }
  3056. this.ServeSuccessJSON(map[string]interface{}{
  3057. "deviceWater": deviceWater,
  3058. })
  3059. }
  3060. func (this *MachineApiController) SaveDevicePH() {
  3061. timeLayout := "2006-01-02"
  3062. loc, _ := time.LoadLocation("Local")
  3063. id, _ := this.GetInt64("id")
  3064. addmacher, _ := service.GetBedId(id)
  3065. adminUserInfo := this.GetAdminUserInfo()
  3066. orgid := adminUserInfo.CurrentOrgId
  3067. dataBody := make(map[string]interface{}, 0)
  3068. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3069. date := dataBody["sampling_date"].(string)
  3070. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  3071. samp_date := theTime.Unix()
  3072. specimen := int64(dataBody["specimenb"].(float64))
  3073. cona := dataBody["concentrate_noc"].(string)
  3074. conb := dataBody["concentrateb_nod"].(string)
  3075. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3076. detectionUnit := dataBody["detection_unit"].(string)
  3077. samplerb := int64(dataBody["samplerb"].(float64))
  3078. reportDate := dataBody["reporting_dateb"].(string)
  3079. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  3080. repDate := reportTime.Unix()
  3081. detectionResult := dataBody["detection_resultb"].(string)
  3082. sort := dataBody["sort"].(string)
  3083. modifications := int64(dataBody["modifications"].(float64))
  3084. examination := dataBody["pass_examination"].(string)
  3085. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  3086. devicePh := models.XtDevicePh{
  3087. SamplingDate: samp_date,
  3088. Specimenb: specimen,
  3089. ConcentrateNoc: cona,
  3090. ConcentratebNod: conb,
  3091. SamplingLocationb: samplinglocationb,
  3092. DetectionUnit: detectionUnit,
  3093. Samplerb: samplerb,
  3094. ReportingDateb: repDate,
  3095. DetectionResultb: detectionResult,
  3096. Ctime: time.Now().Unix(),
  3097. Status: 1,
  3098. UserOrgId: orgid,
  3099. BedId: addmacher.BedId,
  3100. EquitmentId: id,
  3101. Bed: addmacher.BedNumber,
  3102. Sort: sort,
  3103. PassExamination: pass_examination,
  3104. Modifications: modifications,
  3105. }
  3106. err = service.CreateDevicePh(&devicePh)
  3107. if err != nil {
  3108. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3109. return
  3110. }
  3111. this.ServeSuccessJSON(map[string]interface{}{
  3112. "devicePh": devicePh,
  3113. })
  3114. }
  3115. func (this *MachineApiController) EditOxygenates() {
  3116. id, _ := this.GetInt64("id")
  3117. oxygenates, err := service.GetOxygenatesById(id)
  3118. if err != nil {
  3119. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3120. return
  3121. }
  3122. this.ServeSuccessJSON(map[string]interface{}{
  3123. "oxygenates": oxygenates,
  3124. })
  3125. }
  3126. func (this *MachineApiController) UpdateOxygenates() {
  3127. timeLayout := "2006-01-02"
  3128. loc, _ := time.LoadLocation("Local")
  3129. dataBody := make(map[string]interface{}, 0)
  3130. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3131. fmt.Println("err", err)
  3132. id := int64(dataBody["id"].(float64))
  3133. fmt.Println("id", id)
  3134. samplingDate := dataBody["sampling_date"].(string)
  3135. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3136. samp_date := sampdate.Unix()
  3137. specimentb := int64(dataBody["specimenb"].(float64))
  3138. concentratec := dataBody["concentrate_noc"].(string)
  3139. concentraeb := dataBody["concentrateb_nod"].(string)
  3140. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3141. samplerb := int64(dataBody["samplerb"].(float64))
  3142. reportDateb := dataBody["reporting_dateb"].(string)
  3143. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3144. report_date := location.Unix()
  3145. detectionResultb := dataBody["detection_resultb"].(string)
  3146. detectionUnit := dataBody["detection_unit"].(string)
  3147. sort := dataBody["sort"].(string)
  3148. pass_examination := int64(dataBody["pass_examination"].(float64))
  3149. modifications := int64(dataBody["modifications"].(float64))
  3150. adminUserInfo := this.GetAdminUserInfo()
  3151. orgId := adminUserInfo.CurrentOrgId
  3152. oxygenates := models.XtDeviceOxygenates{
  3153. SamplingDate: samp_date,
  3154. Specimenb: specimentb,
  3155. ConcentrateNoc: concentratec,
  3156. ConcentratebNod: concentraeb,
  3157. SamplingLocationb: samplinglocationb,
  3158. DetectionUnit: detectionUnit,
  3159. Samplerb: samplerb,
  3160. ReportingDateb: report_date,
  3161. DetectionResultb: detectionResultb,
  3162. Sort: sort,
  3163. PassExamination: pass_examination,
  3164. Modifications: modifications,
  3165. }
  3166. err = service.UpdateOxygenates(id, orgId, &oxygenates)
  3167. if err != nil {
  3168. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3169. return
  3170. }
  3171. this.ServeSuccessJSON(map[string]interface{}{
  3172. "oxygenates": oxygenates,
  3173. })
  3174. }
  3175. func (this *MachineApiController) EditHardWater() {
  3176. id, _ := this.GetInt64("id")
  3177. hardWater, err := service.GetHardWaterById(id)
  3178. if err != nil {
  3179. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3180. return
  3181. }
  3182. this.ServeSuccessJSON(map[string]interface{}{
  3183. "hardWater": hardWater,
  3184. })
  3185. }
  3186. func (this *MachineApiController) EditWater() {
  3187. id, _ := this.GetInt64("id")
  3188. water, err := service.GetWaterById(id)
  3189. if err != nil {
  3190. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3191. return
  3192. }
  3193. this.ServeSuccessJSON(map[string]interface{}{
  3194. "water": water,
  3195. })
  3196. }
  3197. func (this *MachineApiController) EditDevicePh() {
  3198. id, _ := this.GetInt64("id")
  3199. deviceph, err := service.GetDevicePhById(id)
  3200. if err != nil {
  3201. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3202. return
  3203. }
  3204. this.ServeSuccessJSON(map[string]interface{}{
  3205. "deviceph": deviceph,
  3206. })
  3207. }
  3208. func (this *MachineApiController) GetAllDoctorList() {
  3209. adminUserInfo := this.GetAdminUserInfo()
  3210. orgId := adminUserInfo.CurrentOrgId
  3211. appId := this.GetAdminUserInfo().CurrentAppId
  3212. list, err := service.GetAllDoctorTwo(orgId, appId)
  3213. operators, err := service.GetAdminUserEsOne(orgId)
  3214. if err != nil {
  3215. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3216. return
  3217. }
  3218. this.ServeSuccessJSON(map[string]interface{}{
  3219. "list": list,
  3220. "operators": operators,
  3221. })
  3222. }
  3223. func (this *MachineApiController) SaveAirDisinfect() {
  3224. timeLayout := "2006-01-02"
  3225. loc, _ := time.LoadLocation("Local")
  3226. check_out, err := this.GetInt64("check_out")
  3227. class, err := this.GetInt64("class")
  3228. create_time := this.GetString("created_time")
  3229. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3230. creator, err := this.GetInt64("creator")
  3231. detection_result := this.GetString("detection_result")
  3232. detection_time := this.GetString("detection_time")
  3233. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3234. disinfection_fluid := this.GetString("disinfection_fluid")
  3235. disinfection_methods := this.GetString("disinfection_methods")
  3236. modifications, _ := this.GetInt64("modifications")
  3237. sort := this.GetString("sort")
  3238. upload_time := this.GetString("upload_time")
  3239. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3240. start_time := this.GetString("start_time")
  3241. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3242. adminUserInfo := this.GetAdminUserInfo()
  3243. orgId := adminUserInfo.CurrentOrgId
  3244. detection := models.XtAerialDetection{
  3245. CheckOut: check_out,
  3246. Class: class,
  3247. CreatedTime: createTime.Unix(),
  3248. Creator: creator,
  3249. DetectionResult: detection_result,
  3250. DetectionTime: detectionTime.Unix(),
  3251. DisinfectionFluid: disinfection_fluid,
  3252. DisinfectionMethods: disinfection_methods,
  3253. Modifications: modifications,
  3254. Sort: sort,
  3255. UploadTime: uploadTime.Unix(),
  3256. StartTime: startTime.Unix(),
  3257. UserOrgId: orgId,
  3258. Ctime: time.Now().Unix(),
  3259. Status: 1,
  3260. }
  3261. err = service.CreateAerialDetection(&detection)
  3262. if err != nil {
  3263. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3264. return
  3265. }
  3266. this.ServeSuccessJSON(map[string]interface{}{
  3267. "list": detection,
  3268. })
  3269. }
  3270. func (this *MachineApiController) GetAirList() {
  3271. limit, _ := this.GetInt64("limit")
  3272. page, _ := this.GetInt64("page")
  3273. adminUserInfo := this.GetAdminUserInfo()
  3274. orgId := adminUserInfo.CurrentOrgId
  3275. list, total, err := service.GetAirList(limit, page, orgId)
  3276. if err != nil {
  3277. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3278. return
  3279. }
  3280. this.ServeSuccessJSON(map[string]interface{}{
  3281. "list": list,
  3282. "total": total,
  3283. })
  3284. }
  3285. func (this *MachineApiController) GetAirDisinfetDetail() {
  3286. id, _ := this.GetInt64("id")
  3287. detail, err := service.GetAirDisinfectDetail(id)
  3288. if err != nil {
  3289. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3290. return
  3291. }
  3292. this.ServeSuccessJSON(map[string]interface{}{
  3293. "detail": detail,
  3294. })
  3295. }
  3296. func (this *MachineApiController) UpdateAirDisinfect() {
  3297. timeLayout := "2006-01-02"
  3298. loc, _ := time.LoadLocation("Local")
  3299. check_out, err := this.GetInt64("check_out")
  3300. class, err := this.GetInt64("class")
  3301. create_time := this.GetString("created_time")
  3302. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3303. creator, err := this.GetInt64("creator")
  3304. detection_result := this.GetString("detection_result")
  3305. detection_time := this.GetString("detection_time")
  3306. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3307. disinfection_fluid := this.GetString("disinfection_fluid")
  3308. disinfection_methods := this.GetString("disinfection_methods")
  3309. modifications, _ := this.GetInt64("modifications")
  3310. sort := this.GetString("sort")
  3311. upload_time := this.GetString("upload_time")
  3312. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3313. start_time := this.GetString("start_time")
  3314. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3315. id, _ := this.GetInt64("id")
  3316. adminUserInfo := this.GetAdminUserInfo()
  3317. orgId := adminUserInfo.CurrentOrgId
  3318. detection := models.XtAerialDetection{
  3319. CheckOut: check_out,
  3320. Class: class,
  3321. CreatedTime: createTime.Unix(),
  3322. Creator: creator,
  3323. DetectionResult: detection_result,
  3324. DetectionTime: detectionTime.Unix(),
  3325. DisinfectionFluid: disinfection_fluid,
  3326. DisinfectionMethods: disinfection_methods,
  3327. Modifications: modifications,
  3328. Sort: sort,
  3329. UploadTime: uploadTime.Unix(),
  3330. StartTime: startTime.Unix(),
  3331. UserOrgId: orgId,
  3332. Ctime: time.Now().Unix(),
  3333. Status: 1,
  3334. }
  3335. err = service.UpdateAeriaDetection(&detection, id)
  3336. if err != nil {
  3337. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3338. return
  3339. }
  3340. this.ServeSuccessJSON(map[string]interface{}{
  3341. "detection": detection,
  3342. })
  3343. }
  3344. func (this *MachineApiController) DeleteAirDisinfect() {
  3345. id, _ := this.GetInt64("id")
  3346. err := service.DeleteAirDisinfect(id)
  3347. fmt.Println(err)
  3348. returnData := make(map[string]interface{}, 0)
  3349. returnData["msg"] = "ok"
  3350. this.ServeSuccessJSON(returnData)
  3351. return
  3352. }
  3353. func (this *MachineApiController) SaveBodyDisinfect() {
  3354. timeLayout := "2006-01-02"
  3355. loc, _ := time.LoadLocation("Local")
  3356. check_out, err := this.GetInt64("check_out")
  3357. class, err := this.GetInt64("class")
  3358. create_time := this.GetString("created_time")
  3359. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3360. creator, err := this.GetInt64("creator")
  3361. detection_result := this.GetString("detection_result")
  3362. detection_time := this.GetString("detection_time")
  3363. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3364. disinfection_fluid := this.GetString("disinfection_fluid")
  3365. disinfection_methods := this.GetString("disinfection_methods")
  3366. modifications, _ := this.GetInt64("modifications")
  3367. sort := this.GetString("sort")
  3368. upload_time := this.GetString("upload_time")
  3369. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3370. start_time := this.GetString("start_time")
  3371. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3372. adminUserInfo := this.GetAdminUserInfo()
  3373. orgId := adminUserInfo.CurrentOrgId
  3374. detection := models.XtBodyDetection{
  3375. CheckOut: check_out,
  3376. Class: class,
  3377. CreatedTime: createTime.Unix(),
  3378. Creator: creator,
  3379. DetectionResult: detection_result,
  3380. DetectionTime: detectionTime.Unix(),
  3381. DisinfectionFluid: disinfection_fluid,
  3382. DisinfectionMethods: disinfection_methods,
  3383. Modifications: modifications,
  3384. Sort: sort,
  3385. UploadTime: uploadTime.Unix(),
  3386. StartTime: startTime.Unix(),
  3387. UserOrgId: orgId,
  3388. Ctime: time.Now().Unix(),
  3389. Status: 1,
  3390. }
  3391. err = service.SaveBodyDetection(&detection)
  3392. if err != nil {
  3393. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3394. return
  3395. }
  3396. this.ServeSuccessJSON(map[string]interface{}{
  3397. "detection": detection,
  3398. })
  3399. }
  3400. func (this *MachineApiController) GetBodyList() {
  3401. limit, _ := this.GetInt64("limit")
  3402. page, _ := this.GetInt64("page")
  3403. adminUserInfo := this.GetAdminUserInfo()
  3404. orgId := adminUserInfo.CurrentOrgId
  3405. list, total, err := service.GetBodyList(limit, page, orgId)
  3406. if err != nil {
  3407. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3408. return
  3409. }
  3410. this.ServeSuccessJSON(map[string]interface{}{
  3411. "list": list,
  3412. "total": total,
  3413. })
  3414. }
  3415. func (this *MachineApiController) GetBodyDisinfetDetail() {
  3416. id, _ := this.GetInt64("id")
  3417. detail, err := service.GetBodyDisinfectDetail(id)
  3418. if err != nil {
  3419. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3420. return
  3421. }
  3422. this.ServeSuccessJSON(map[string]interface{}{
  3423. "detail": detail,
  3424. })
  3425. }
  3426. func (this *MachineApiController) UpdateBodyDisinfect() {
  3427. timeLayout := "2006-01-02"
  3428. loc, _ := time.LoadLocation("Local")
  3429. check_out, _ := this.GetInt64("check_out")
  3430. class, _ := this.GetInt64("class")
  3431. create_time := this.GetString("created_time")
  3432. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3433. creator, err := this.GetInt64("creator")
  3434. detection_result := this.GetString("detection_result")
  3435. detection_time := this.GetString("detection_time")
  3436. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3437. disinfection_fluid := this.GetString("disinfection_fluid")
  3438. disinfection_methods := this.GetString("disinfection_methods")
  3439. modifications, _ := this.GetInt64("modifications")
  3440. sort := this.GetString("sort")
  3441. upload_time := this.GetString("upload_time")
  3442. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3443. start_time := this.GetString("start_time")
  3444. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3445. id, _ := this.GetInt64("id")
  3446. adminUserInfo := this.GetAdminUserInfo()
  3447. orgId := adminUserInfo.CurrentOrgId
  3448. detection := models.XtBodyDetection{
  3449. CheckOut: check_out,
  3450. Class: class,
  3451. CreatedTime: createTime.Unix(),
  3452. Creator: creator,
  3453. DetectionResult: detection_result,
  3454. DetectionTime: detectionTime.Unix(),
  3455. DisinfectionFluid: disinfection_fluid,
  3456. DisinfectionMethods: disinfection_methods,
  3457. Modifications: modifications,
  3458. Sort: sort,
  3459. UploadTime: uploadTime.Unix(),
  3460. StartTime: startTime.Unix(),
  3461. UserOrgId: orgId,
  3462. Ctime: time.Now().Unix(),
  3463. Status: 1,
  3464. }
  3465. err = service.UpdateBodyDetection(&detection, id)
  3466. if err != nil {
  3467. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3468. return
  3469. }
  3470. this.ServeSuccessJSON(map[string]interface{}{
  3471. "detection": detection,
  3472. })
  3473. }
  3474. func (this *MachineApiController) DeleteBodyDisInfect() {
  3475. id, _ := this.GetInt64("id")
  3476. err := service.DeleteBodyDisInfect(id)
  3477. fmt.Println(err)
  3478. returnData := make(map[string]interface{}, 0)
  3479. returnData["msg"] = "ok"
  3480. this.ServeSuccessJSON(returnData)
  3481. return
  3482. }
  3483. func (this *MachineApiController) UpdateHadWater() {
  3484. timeLayout := "2006-01-02"
  3485. loc, _ := time.LoadLocation("Local")
  3486. dataBody := make(map[string]interface{}, 0)
  3487. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3488. fmt.Println("err", err)
  3489. id := int64(dataBody["id"].(float64))
  3490. fmt.Println("id", id)
  3491. samplingDate := dataBody["sampling_date"].(string)
  3492. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3493. samp_date := sampdate.Unix()
  3494. specimentb := int64(dataBody["specimenb"].(float64))
  3495. concentratec := dataBody["concentrate_noc"].(string)
  3496. concentraeb := dataBody["concentrateb_nod"].(string)
  3497. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3498. samplerb := int64(dataBody["samplerb"].(float64))
  3499. reportDateb := dataBody["reporting_dateb"].(string)
  3500. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3501. report_date := location.Unix()
  3502. detectionResultb := dataBody["detection_resultb"].(string)
  3503. detectionUnit := dataBody["detection_unit"].(string)
  3504. sort := dataBody["sort"].(string)
  3505. pass_examination := int64(dataBody["pass_examination"].(float64))
  3506. modifications := int64(dataBody["modifications"].(float64))
  3507. adminUserInfo := this.GetAdminUserInfo()
  3508. orgId := adminUserInfo.CurrentOrgId
  3509. hadWater := models.XtDeviceHadwater{
  3510. SamplingDate: samp_date,
  3511. Specimenb: specimentb,
  3512. ConcentrateNoc: concentratec,
  3513. ConcentratebNod: concentraeb,
  3514. SamplingLocationb: samplinglocationb,
  3515. DetectionUnit: detectionUnit,
  3516. Samplerb: samplerb,
  3517. ReportingDateb: report_date,
  3518. DetectionResultb: detectionResultb,
  3519. Sort: sort,
  3520. PassExamination: pass_examination,
  3521. Modifications: modifications,
  3522. }
  3523. err = service.UpdateHadWater(id, orgId, &hadWater)
  3524. if err != nil {
  3525. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3526. return
  3527. }
  3528. this.ServeSuccessJSON(map[string]interface{}{
  3529. "hadWater": hadWater,
  3530. })
  3531. }
  3532. func (this *MachineApiController) UpdateWater() {
  3533. timeLayout := "2006-01-02"
  3534. loc, _ := time.LoadLocation("Local")
  3535. dataBody := make(map[string]interface{}, 0)
  3536. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3537. fmt.Println("err", err)
  3538. id := int64(dataBody["id"].(float64))
  3539. fmt.Println("id", id)
  3540. samplingDate := dataBody["sampling_date"].(string)
  3541. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3542. samp_date := sampdate.Unix()
  3543. specimentb := int64(dataBody["specimenb"].(float64))
  3544. concentratec := dataBody["concentrate_noc"].(string)
  3545. concentraeb := dataBody["concentrateb_nod"].(string)
  3546. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3547. samplerb := int64(dataBody["samplerb"].(float64))
  3548. reportDateb := dataBody["reporting_dateb"].(string)
  3549. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3550. report_date := location.Unix()
  3551. detectionResultb := dataBody["detection_resultb"].(string)
  3552. detectionUnit := dataBody["detection_unit"].(string)
  3553. sort := dataBody["sort"].(string)
  3554. pass_examination := int64(dataBody["pass_examination"].(float64))
  3555. modifications := int64(dataBody["modifications"].(float64))
  3556. adminUserInfo := this.GetAdminUserInfo()
  3557. orgId := adminUserInfo.CurrentOrgId
  3558. hadWater := models.XtDeviceWater{
  3559. SamplingDate: samp_date,
  3560. Specimenb: specimentb,
  3561. ConcentrateNoc: concentratec,
  3562. ConcentratebNod: concentraeb,
  3563. SamplingLocationb: samplinglocationb,
  3564. DetectionUnit: detectionUnit,
  3565. Samplerb: samplerb,
  3566. ReportingDateb: report_date,
  3567. DetectionResultb: detectionResultb,
  3568. Sort: sort,
  3569. PassExamination: pass_examination,
  3570. Modifications: modifications,
  3571. }
  3572. err = service.UpdateDeviceWater(id, orgId, &hadWater)
  3573. if err != nil {
  3574. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3575. return
  3576. }
  3577. this.ServeSuccessJSON(map[string]interface{}{
  3578. "hadWater": hadWater,
  3579. })
  3580. }
  3581. func (this *MachineApiController) UpdateDevicePh() {
  3582. timeLayout := "2006-01-02"
  3583. loc, _ := time.LoadLocation("Local")
  3584. dataBody := make(map[string]interface{}, 0)
  3585. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3586. fmt.Println("err", err)
  3587. id := int64(dataBody["id"].(float64))
  3588. fmt.Println("id", id)
  3589. samplingDate := dataBody["sampling_date"].(string)
  3590. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3591. samp_date := sampdate.Unix()
  3592. specimentb := int64(dataBody["specimenb"].(float64))
  3593. concentratec := dataBody["concentrate_noc"].(string)
  3594. concentraeb := dataBody["concentrateb_nod"].(string)
  3595. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3596. samplerb := int64(dataBody["samplerb"].(float64))
  3597. reportDateb := dataBody["reporting_dateb"].(string)
  3598. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3599. report_date := location.Unix()
  3600. detectionResultb := dataBody["detection_resultb"].(string)
  3601. detectionUnit := dataBody["detection_unit"].(string)
  3602. sort := dataBody["sort"].(string)
  3603. pass_examination := int64(dataBody["pass_examination"].(float64))
  3604. modifications := int64(dataBody["modifications"].(float64))
  3605. adminUserInfo := this.GetAdminUserInfo()
  3606. orgId := adminUserInfo.CurrentOrgId
  3607. hadWater := models.XtDevicePh{
  3608. SamplingDate: samp_date,
  3609. Specimenb: specimentb,
  3610. ConcentrateNoc: concentratec,
  3611. ConcentratebNod: concentraeb,
  3612. SamplingLocationb: samplinglocationb,
  3613. DetectionUnit: detectionUnit,
  3614. Samplerb: samplerb,
  3615. ReportingDateb: report_date,
  3616. DetectionResultb: detectionResultb,
  3617. Sort: sort,
  3618. PassExamination: pass_examination,
  3619. Modifications: modifications,
  3620. }
  3621. err = service.UpdateDivicePh(id, orgId, &hadWater)
  3622. if err != nil {
  3623. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3624. return
  3625. }
  3626. this.ServeSuccessJSON(map[string]interface{}{
  3627. "hadWater": hadWater,
  3628. })
  3629. }
  3630. func (this *MachineApiController) DeleteOxygenates() {
  3631. id, _ := this.GetInt64("id")
  3632. err := service.DeleteOxygenates(id)
  3633. fmt.Println(err)
  3634. returnData := make(map[string]interface{}, 0)
  3635. returnData["msg"] = "ok"
  3636. this.ServeSuccessJSON(returnData)
  3637. return
  3638. }
  3639. func (this *MachineApiController) DeleteHadWater() {
  3640. id, _ := this.GetInt64("id")
  3641. err := service.DeleteHadWater(id)
  3642. fmt.Println(err)
  3643. returnData := make(map[string]interface{}, 0)
  3644. returnData["msg"] = "ok"
  3645. this.ServeSuccessJSON(returnData)
  3646. return
  3647. }
  3648. func (this *MachineApiController) DeleteWater() {
  3649. id, _ := this.GetInt64("id")
  3650. err := service.DeleteWater(id)
  3651. fmt.Println(err)
  3652. returnData := make(map[string]interface{}, 0)
  3653. returnData["msg"] = "ok"
  3654. this.ServeSuccessJSON(returnData)
  3655. return
  3656. }
  3657. func (this *MachineApiController) DeleteDevicePh() {
  3658. id, _ := this.GetInt64("id")
  3659. err := service.DeleteDevicePh(id)
  3660. fmt.Println(err)
  3661. returnData := make(map[string]interface{}, 0)
  3662. returnData["msg"] = "ok"
  3663. this.ServeSuccessJSON(returnData)
  3664. return
  3665. }
  3666. func (this *MachineApiController) SaveWaterList() {
  3667. equitment_id, _ := this.GetInt64("equitment_id")
  3668. timeLayout := "2006-01-02"
  3669. loc, _ := time.LoadLocation("Local")
  3670. dataBody := make(map[string]interface{}, 0)
  3671. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3672. fmt.Println("err", err)
  3673. record_date := dataBody["record_date"].(string)
  3674. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  3675. recorddateunix := sampdate.Unix()
  3676. fmt.Println("日期", recorddateunix)
  3677. machine_status := int64(dataBody["machine_status"].(float64))
  3678. fmt.Println("machine_status", machine_status)
  3679. fault_description := dataBody["fault_description"].(string)
  3680. water_conductivity := dataBody["water_conductivity"].(float64)
  3681. water_pressure := dataBody["water_pressure"].(float64)
  3682. temperature := dataBody["temperature"].(float64)
  3683. force_pump_status := int64(dataBody["force_pump_status"].(float64))
  3684. first_ro_membrane_water := dataBody["first_ro_membrane_water"].(float64)
  3685. first_ro_film_thick_water := dataBody["first_ro_film_thick_water"].(float64)
  3686. first_ro_membrane_effluent := dataBody["first_ro_membrane_effluent"].(float64)
  3687. first_production_of_water_conductivity := dataBody["first_production_of_water_conductivity"].(float64)
  3688. first_water_yield := dataBody["first_water_yield"].(float64)
  3689. last_ro_membrane_water := dataBody["last_ro_membrane_water"].(float64)
  3690. last_ro_membrane_effluent := dataBody["last_ro_membrane_effluent"].(float64)
  3691. last_ro_film_thick_water := dataBody["last_ro_film_thick_water"].(float64)
  3692. last_production_of_water_conductivity := dataBody["last_production_of_water_conductivity"].(float64)
  3693. last_water_yield := dataBody["last_water_yield"].(float64)
  3694. carbon_tank := dataBody["carbon_tank"].(float64)
  3695. snd_tank := dataBody["snd_tank"].(float64)
  3696. resin_tank := dataBody["resin_tank"].(float64)
  3697. ultrafilter := dataBody["ultrafilter"].(float64)
  3698. hardness_monitoring := dataBody["hardness_monitoring"].(float64)
  3699. total_chlorine_detection := dataBody["total_chlorine_detection"].(float64)
  3700. ph_detection := dataBody["ph_detection"].(float64)
  3701. concentration_of_peroxyacetic_acid := dataBody["concentration_of_peroxyacetic_acid"].(float64)
  3702. reverse_osmosis_membrane_disinfection := int64(dataBody["reverse_osmosis_membrane_disinfection"].(float64))
  3703. first_disinfection_method := int64(dataBody["first_disinfection_method"].(float64))
  3704. last_disinfection_method := int64(dataBody["last_disinfection_method"].(float64))
  3705. first_disinfection_time := dataBody["first_disinfection_time"].(float64)
  3706. last_disinfection_time := dataBody["last_disinfection_time"].(float64)
  3707. remark := dataBody["remark"].(string)
  3708. filter_replacement := int64(dataBody["filter_replacement"].(float64))
  3709. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  3710. disinfection_of_water_pipeline := int64(dataBody["disinfection_of_water_pipeline"].(float64))
  3711. orgId := this.GetAdminUserInfo().CurrentOrgId
  3712. deviceWater := models.XtDialysisDeviceWater{
  3713. UserOrgId: orgId,
  3714. EquimentId: equitment_id,
  3715. RecordDate: recorddateunix,
  3716. MachineStatus: machine_status,
  3717. FaultDescription: fault_description,
  3718. WaterConductivity: water_conductivity,
  3719. WaterPressure: water_pressure,
  3720. Temperature: temperature,
  3721. ForcePumpStatus: force_pump_status,
  3722. FirstRoMembraneWater: first_ro_membrane_water,
  3723. FirstRoFilmThickWater: first_ro_film_thick_water,
  3724. FirstRoMembraneEffluent: first_ro_membrane_effluent,
  3725. FirstProductionOfWaterConductivity: first_production_of_water_conductivity,
  3726. FirstWaterYield: first_water_yield,
  3727. LastRoMembraneWater: last_ro_membrane_water,
  3728. LastRoFilmThickWater: last_ro_film_thick_water,
  3729. LastRoMembraneEffluent: last_ro_membrane_effluent,
  3730. LastProductionOfWaterConductivity: last_production_of_water_conductivity,
  3731. LastWaterYield: last_water_yield,
  3732. CarbonTank: carbon_tank,
  3733. SndTank: snd_tank,
  3734. ResinTank: resin_tank,
  3735. Ultrafilter: ultrafilter,
  3736. HardnessMonitoring: hardness_monitoring,
  3737. TotalChlorineDetection: total_chlorine_detection,
  3738. ConcentrationOfPeroxyaceticAcid: concentration_of_peroxyacetic_acid,
  3739. ReverseOsmosisMembraneDisinfection: reverse_osmosis_membrane_disinfection,
  3740. FirstDisinfectionMethod: first_disinfection_method,
  3741. LastDisinfectionMethod: last_disinfection_method,
  3742. FirstDisinfectionTime: first_disinfection_time,
  3743. LastDisinfectionTime: last_disinfection_time,
  3744. Remark: remark,
  3745. FilterReplacement: filter_replacement,
  3746. AdminUserId: admin_user_id,
  3747. Ctime: time.Now().Unix(),
  3748. Mtime: time.Now().Unix(),
  3749. Status: 1,
  3750. PhDetection: ph_detection,
  3751. DisinfectionOfWaterPipeline: disinfection_of_water_pipeline,
  3752. }
  3753. err = service.CretaDeviceWater(deviceWater)
  3754. if err != nil {
  3755. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3756. return
  3757. }
  3758. this.ServeSuccessJSON(map[string]interface{}{
  3759. "deviceWater": deviceWater,
  3760. })
  3761. }
  3762. func (this *MachineApiController) GetWaterFormList() {
  3763. equitment_id, _ := this.GetInt64("equitment_id")
  3764. timeLayout := "2006-01-02"
  3765. loc, _ := time.LoadLocation("Local")
  3766. start_time := this.GetString("start_time")
  3767. var theStartTIme int64
  3768. if len(start_time) > 0 {
  3769. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3770. if err != nil {
  3771. utils.ErrorLog(err.Error())
  3772. }
  3773. theStartTIme = theTime.Unix()
  3774. }
  3775. end_time := this.GetString("end_time")
  3776. var theEndTime int64
  3777. if len(end_time) > 0 {
  3778. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  3779. if err != nil {
  3780. utils.ErrorLog(err.Error())
  3781. }
  3782. theEndTime = theTime.Unix()
  3783. }
  3784. limit, _ := this.GetInt64("limit")
  3785. page, _ := this.GetInt64("page")
  3786. orgId := this.GetAdminUserInfo().CurrentOrgId
  3787. list, total, err := service.GetWaterFormList(equitment_id, theStartTIme, theEndTime, limit, page, orgId)
  3788. appId := this.GetAdminUserInfo().CurrentAppId
  3789. adminRole, err := service.GetAllDoctorTwo(orgId, appId)
  3790. operators, err := service.GetAdminUserEsOne(orgId)
  3791. if err != nil {
  3792. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3793. return
  3794. }
  3795. this.ServeSuccessJSON(map[string]interface{}{
  3796. "list": list,
  3797. "total": total,
  3798. "adminRole": adminRole,
  3799. "operators": operators,
  3800. })
  3801. }
  3802. func (this *MachineApiController) DeleteDialysisWater() {
  3803. id, _ := this.GetInt64("id")
  3804. err := service.DelelteDialysisWater(id)
  3805. fmt.Println(err)
  3806. returnData := make(map[string]interface{}, 0)
  3807. returnData["msg"] = "ok"
  3808. this.ServeSuccessJSON(returnData)
  3809. return
  3810. }
  3811. func (this *MachineApiController) GetDialysisWaterDetail() {
  3812. id, _ := this.GetInt64("id")
  3813. detail, err := service.GetDialysisWaterDetail(id)
  3814. appId := this.GetAdminUserInfo().CurrentAppId
  3815. orgId := this.GetAdminUserInfo().CurrentOrgId
  3816. adminRole, err := service.GetAllDoctorTwo(orgId, appId)
  3817. if err != nil {
  3818. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3819. return
  3820. }
  3821. this.ServeSuccessJSON(map[string]interface{}{
  3822. "detail": detail,
  3823. "adminRole": adminRole,
  3824. })
  3825. }
  3826. func (this *MachineApiController) UpdateDialysisWater() {
  3827. equitment_id, _ := this.GetInt64("equitment_id")
  3828. timeLayout := "2006-01-02"
  3829. loc, _ := time.LoadLocation("Local")
  3830. dataBody := make(map[string]interface{}, 0)
  3831. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3832. fmt.Println("err", err)
  3833. id := int64(dataBody["id"].(float64))
  3834. record_date := dataBody["record_date"].(string)
  3835. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  3836. recorddateunix := sampdate.Unix()
  3837. fmt.Println("日期", recorddateunix)
  3838. machine_status := int64(dataBody["machine_status"].(float64))
  3839. fmt.Println("machine_status", machine_status)
  3840. fault_description := dataBody["fault_description"].(string)
  3841. water_conductivity := dataBody["water_conductivity"].(float64)
  3842. water_pressure := dataBody["water_pressure"].(float64)
  3843. temperature := dataBody["temperature"].(float64)
  3844. force_pump_status := int64(dataBody["force_pump_status"].(float64))
  3845. first_ro_membrane_water := dataBody["first_ro_membrane_water"].(float64)
  3846. first_ro_film_thick_water := dataBody["first_ro_film_thick_water"].(float64)
  3847. first_ro_membrane_effluent := dataBody["first_ro_membrane_effluent"].(float64)
  3848. first_production_of_water_conductivity := dataBody["first_production_of_water_conductivity"].(float64)
  3849. first_water_yield := dataBody["first_water_yield"].(float64)
  3850. last_ro_membrane_water := dataBody["last_ro_membrane_water"].(float64)
  3851. last_ro_membrane_effluent := dataBody["last_ro_membrane_effluent"].(float64)
  3852. last_ro_film_thick_water := dataBody["last_ro_film_thick_water"].(float64)
  3853. last_production_of_water_conductivity := dataBody["last_production_of_water_conductivity"].(float64)
  3854. last_water_yield := dataBody["last_water_yield"].(float64)
  3855. carbon_tank := dataBody["carbon_tank"].(float64)
  3856. snd_tank := dataBody["snd_tank"].(float64)
  3857. resin_tank := dataBody["resin_tank"].(float64)
  3858. ultrafilter := dataBody["ultrafilter"].(float64)
  3859. hardness_monitoring := dataBody["hardness_monitoring"].(float64)
  3860. total_chlorine_detection := dataBody["total_chlorine_detection"].(float64)
  3861. ph_detection := dataBody["ph_detection"].(float64)
  3862. concentration_of_peroxyacetic_acid := dataBody["concentration_of_peroxyacetic_acid"].(float64)
  3863. reverse_osmosis_membrane_disinfection := int64(dataBody["reverse_osmosis_membrane_disinfection"].(float64))
  3864. first_disinfection_method := int64(dataBody["first_disinfection_method"].(float64))
  3865. last_disinfection_method := int64(dataBody["last_disinfection_method"].(float64))
  3866. first_disinfection_time := dataBody["first_disinfection_time"].(float64)
  3867. last_disinfection_time := dataBody["last_disinfection_time"].(float64)
  3868. remark := dataBody["remark"].(string)
  3869. filter_replacement := int64(dataBody["filter_replacement"].(float64))
  3870. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  3871. disinfection_of_water_pipeline := int64(dataBody["disinfection_of_water_pipeline"].(float64))
  3872. orgId := this.GetAdminUserInfo().CurrentOrgId
  3873. deviceWater := models.XtDialysisDeviceWater{
  3874. ID: id,
  3875. UserOrgId: orgId,
  3876. EquimentId: equitment_id,
  3877. RecordDate: recorddateunix,
  3878. MachineStatus: machine_status,
  3879. FaultDescription: fault_description,
  3880. WaterConductivity: water_conductivity,
  3881. WaterPressure: water_pressure,
  3882. Temperature: temperature,
  3883. ForcePumpStatus: force_pump_status,
  3884. FirstRoMembraneWater: first_ro_membrane_water,
  3885. FirstRoFilmThickWater: first_ro_film_thick_water,
  3886. FirstRoMembraneEffluent: first_ro_membrane_effluent,
  3887. FirstProductionOfWaterConductivity: first_production_of_water_conductivity,
  3888. FirstWaterYield: first_water_yield,
  3889. LastRoMembraneWater: last_ro_membrane_water,
  3890. LastRoFilmThickWater: last_ro_film_thick_water,
  3891. LastRoMembraneEffluent: last_ro_membrane_effluent,
  3892. LastProductionOfWaterConductivity: last_production_of_water_conductivity,
  3893. LastWaterYield: last_water_yield,
  3894. CarbonTank: carbon_tank,
  3895. SndTank: snd_tank,
  3896. ResinTank: resin_tank,
  3897. Ultrafilter: ultrafilter,
  3898. HardnessMonitoring: hardness_monitoring,
  3899. TotalChlorineDetection: total_chlorine_detection,
  3900. ConcentrationOfPeroxyaceticAcid: concentration_of_peroxyacetic_acid,
  3901. ReverseOsmosisMembraneDisinfection: reverse_osmosis_membrane_disinfection,
  3902. FirstDisinfectionMethod: first_disinfection_method,
  3903. LastDisinfectionMethod: last_disinfection_method,
  3904. FirstDisinfectionTime: first_disinfection_time,
  3905. LastDisinfectionTime: last_disinfection_time,
  3906. Remark: remark,
  3907. FilterReplacement: filter_replacement,
  3908. AdminUserId: admin_user_id,
  3909. Ctime: time.Now().Unix(),
  3910. Mtime: time.Now().Unix(),
  3911. Status: 1,
  3912. PhDetection: ph_detection,
  3913. DisinfectionOfWaterPipeline: disinfection_of_water_pipeline,
  3914. }
  3915. err = service.SaveDeviceWater(deviceWater)
  3916. if err != nil {
  3917. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3918. return
  3919. }
  3920. this.ServeSuccessJSON(map[string]interface{}{
  3921. "deviceWater": deviceWater,
  3922. })
  3923. }
  3924. func (this *MachineApiController) DeleteBatchDialysisWater() {
  3925. adminUserInfo := this.GetAdminUserInfo()
  3926. OrgID := adminUserInfo.CurrentOrgId
  3927. dataBody := make(map[string]interface{}, 0)
  3928. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3929. if err != nil {
  3930. utils.ErrorLog(err.Error())
  3931. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  3932. return
  3933. }
  3934. idsInters := dataBody["ids"].([]interface{})
  3935. if len(idsInters) == 0 {
  3936. if err != nil {
  3937. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  3938. return
  3939. }
  3940. }
  3941. ids := make([]int64, 0)
  3942. for _, idsInter := range idsInters {
  3943. id := int64(idsInter.(float64))
  3944. ids = append(ids, id)
  3945. }
  3946. fmt.Println("ids", ids)
  3947. err = service.DeleteBatchDialysisWater(OrgID, ids)
  3948. if err != nil {
  3949. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3950. return
  3951. }
  3952. returnData := make(map[string]interface{}, 0)
  3953. returnData["msg"] = "ok"
  3954. this.ServeSuccessJSON(returnData)
  3955. return
  3956. }
  3957. func (this *MachineApiController) SaveNewAirDisInfect() {
  3958. timeLayout := "2006-01-02"
  3959. loc, _ := time.LoadLocation("Local")
  3960. dataBody := make(map[string]interface{}, 0)
  3961. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3962. fmt.Println("err", err)
  3963. record_date := dataBody["record_date"].(string)
  3964. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  3965. recorddateunix := recorddate.Unix()
  3966. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  3967. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  3968. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  3969. first_start_time := dataBody["first_start_time"].(string)
  3970. if len(first_start_time) == 0 {
  3971. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3972. return
  3973. }
  3974. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  3975. first_end_time := dataBody["first_end_time"].(string)
  3976. if len(first_end_time) == 0 {
  3977. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3978. return
  3979. }
  3980. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  3981. first_total_time := dataBody["first_total_time"].(string)
  3982. first_is_check := int64(dataBody["first_is_check"].(float64))
  3983. first_modifications := int64(dataBody["first_modifications"].(float64))
  3984. first_creator := int64(dataBody["first_creator"].(float64))
  3985. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  3986. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  3987. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  3988. sencond_start_time := dataBody["sencond_start_time"].(string)
  3989. if len(sencond_start_time) == 0 {
  3990. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3991. return
  3992. }
  3993. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  3994. sencond_end_time := dataBody["sencond_end_time"].(string)
  3995. if len(sencond_end_time) == 0 {
  3996. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3997. return
  3998. }
  3999. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  4000. sencond_total_time := dataBody["sencond_total_time"].(string)
  4001. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  4002. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  4003. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  4004. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4005. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4006. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4007. third_start_time := dataBody["third_start_time"].(string)
  4008. if len(third_start_time) == 0 {
  4009. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4010. return
  4011. }
  4012. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4013. third_end_time := dataBody["third_end_time"].(string)
  4014. if len(third_end_time) == 0 {
  4015. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4016. return
  4017. }
  4018. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4019. third_total_time := dataBody["third_total_time"].(string)
  4020. third_is_check := int64(dataBody["third_is_check"].(float64))
  4021. third_modifications := int64(dataBody["third_modifications"].(float64))
  4022. third_creator := int64(dataBody["third_creator"].(float64))
  4023. last_start_time := dataBody["last_start_time"].(string)
  4024. if len(last_start_time) == 0 {
  4025. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4026. return
  4027. }
  4028. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4029. last_end_time := dataBody["last_end_time"].(string)
  4030. if len(last_end_time) == 0 {
  4031. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4032. return
  4033. }
  4034. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4035. last_total_time := dataBody["last_total_time"].(string)
  4036. last_is_check := int64(dataBody["last_is_check"].(float64))
  4037. last_modifications := int64(dataBody["last_modifications"].(float64))
  4038. last_creator := int64(dataBody["last_creator"].(float64))
  4039. storey := dataBody["storey"].(string)
  4040. orgId := this.GetAdminUserInfo().CurrentOrgId
  4041. disinfect := models.XtNewAriDisinfect{
  4042. UserOrgId: orgId,
  4043. RecordDate: recorddateunix,
  4044. FirstDisinfectionWater: first_disinfection_water,
  4045. FirstDisinfectionMethods: first_disinfection_methods,
  4046. FirstDisinfectionTime: first_disinfection_time,
  4047. FirstStartTime: firstStartTime.Unix(),
  4048. FirstEndTime: firstEndTime.Unix(),
  4049. FirstTotalTime: first_total_time,
  4050. FirstIsCheck: first_is_check,
  4051. FirstModifications: first_modifications,
  4052. FirstCreator: first_creator,
  4053. SencondDisinfectionWater: sencond_disinfection_water,
  4054. SencondDisinfectionMethods: sencond_disinfection_methods,
  4055. SencondDisinfectionTime: sencond_disinfection_time,
  4056. SencondStartTime: sencondStartTime.Unix(),
  4057. SencondEndTime: sencondEndTime.Unix(),
  4058. SencondTotalTime: sencond_total_time,
  4059. SencondIsCheck: sencond_is_check,
  4060. SencondModifications: sencond_modifications,
  4061. SencondCreator: sencond_creator,
  4062. ThirdDisinfectionWater: third_disinfection_water,
  4063. ThirdDisinfectionMethods: third_disinfection_methods,
  4064. ThirdDisinfectionTime: third_disinfection_time,
  4065. ThirdStartTime: thirdStartTime.Unix(),
  4066. ThirdEndTime: thirdEndTime.Unix(),
  4067. ThirdTotalTime: third_total_time,
  4068. ThirdIsCheck: third_is_check,
  4069. ThirdModifications: third_modifications,
  4070. ThirdCreator: third_creator,
  4071. LastStartTime: lastStartTime.Unix(),
  4072. LastEndTime: lastEndTime.Unix(),
  4073. LastTotalTime: last_total_time,
  4074. LastIsCheck: last_is_check,
  4075. LastModifications: last_modifications,
  4076. LastCreator: last_creator,
  4077. Ctime: time.Now().Unix(),
  4078. Mtime: time.Now().Unix(),
  4079. Status: 1,
  4080. Storey: storey,
  4081. }
  4082. err = service.CreateNewAirDisinfect(disinfect)
  4083. if err != nil {
  4084. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4085. return
  4086. }
  4087. this.ServeSuccessJSON(map[string]interface{}{
  4088. "disinfect": disinfect,
  4089. })
  4090. }
  4091. func (this *MachineApiController) GetNewAirDisinfectList() {
  4092. timeLayout := "2006-01-02"
  4093. loc, _ := time.LoadLocation("Local")
  4094. start_time := this.GetString("start_time")
  4095. end_time := this.GetString("end_time")
  4096. limit, _ := this.GetInt64("limit")
  4097. page, _ := this.GetInt64("page")
  4098. storey := this.GetString("storey")
  4099. var startTime int64
  4100. if len(start_time) > 0 {
  4101. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4102. if err != nil {
  4103. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4104. return
  4105. }
  4106. startTime = theTime.Unix()
  4107. }
  4108. var endTime int64
  4109. if len(end_time) > 0 {
  4110. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4111. if err != nil {
  4112. utils.ErrorLog(err.Error())
  4113. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4114. return
  4115. }
  4116. endTime = theTime.Unix()
  4117. }
  4118. orgId := this.GetAdminUserInfo().CurrentOrgId
  4119. list, total, err := service.GetNewAirDisinfectList(limit, page, startTime, endTime, orgId, storey)
  4120. if err != nil {
  4121. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4122. return
  4123. }
  4124. this.ServeSuccessJSON(map[string]interface{}{
  4125. "list": list,
  4126. "total": total,
  4127. })
  4128. }
  4129. func (this *MachineApiController) GetNewAirDisinfectByIdList() {
  4130. id, _ := this.GetInt64("id")
  4131. list, err := service.GetNewAirDisinfectByIdList(id)
  4132. if err != nil {
  4133. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4134. return
  4135. }
  4136. this.ServeSuccessJSON(map[string]interface{}{
  4137. "list": list,
  4138. })
  4139. }
  4140. func (this *MachineApiController) UpdateNewAirDisInfect() {
  4141. timeLayout := "2006-01-02"
  4142. loc, _ := time.LoadLocation("Local")
  4143. dataBody := make(map[string]interface{}, 0)
  4144. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4145. fmt.Println("err", err)
  4146. id := int64(dataBody["id"].(float64))
  4147. record_date := dataBody["record_date"].(string)
  4148. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4149. recorddateunix := recorddate.Unix()
  4150. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  4151. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  4152. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  4153. first_start_time := dataBody["first_start_time"].(string)
  4154. if len(first_start_time) == 0 {
  4155. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4156. return
  4157. }
  4158. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  4159. first_end_time := dataBody["first_end_time"].(string)
  4160. if len(first_end_time) == 0 {
  4161. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4162. return
  4163. }
  4164. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  4165. first_total_time := dataBody["first_total_time"].(string)
  4166. first_is_check := int64(dataBody["first_is_check"].(float64))
  4167. first_modifications := int64(dataBody["first_modifications"].(float64))
  4168. first_creator := int64(dataBody["first_creator"].(float64))
  4169. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  4170. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  4171. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  4172. sencond_start_time := dataBody["sencond_start_time"].(string)
  4173. if len(sencond_start_time) == 0 {
  4174. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4175. return
  4176. }
  4177. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  4178. sencond_end_time := dataBody["sencond_end_time"].(string)
  4179. if len(sencond_end_time) == 0 {
  4180. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4181. return
  4182. }
  4183. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  4184. sencond_total_time := dataBody["sencond_total_time"].(string)
  4185. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  4186. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  4187. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  4188. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4189. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4190. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4191. third_start_time := dataBody["third_start_time"].(string)
  4192. if len(third_start_time) == 0 {
  4193. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4194. return
  4195. }
  4196. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4197. third_end_time := dataBody["third_end_time"].(string)
  4198. if len(third_end_time) == 0 {
  4199. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4200. return
  4201. }
  4202. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4203. third_total_time := dataBody["third_total_time"].(string)
  4204. third_is_check := int64(dataBody["third_is_check"].(float64))
  4205. third_modifications := int64(dataBody["third_modifications"].(float64))
  4206. third_creator := int64(dataBody["third_creator"].(float64))
  4207. last_start_time := dataBody["last_start_time"].(string)
  4208. if len(last_start_time) == 0 {
  4209. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4210. return
  4211. }
  4212. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4213. last_end_time := dataBody["last_end_time"].(string)
  4214. if len(last_end_time) == 0 {
  4215. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4216. return
  4217. }
  4218. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4219. last_total_time := dataBody["last_total_time"].(string)
  4220. last_is_check := int64(dataBody["last_is_check"].(float64))
  4221. last_modifications := int64(dataBody["last_modifications"].(float64))
  4222. last_creator := int64(dataBody["last_creator"].(float64))
  4223. storey := dataBody["storey"].(string)
  4224. orgId := this.GetAdminUserInfo().CurrentOrgId
  4225. disinfect := models.XtNewAriDisinfect{
  4226. ID: id,
  4227. UserOrgId: orgId,
  4228. RecordDate: recorddateunix,
  4229. FirstDisinfectionWater: first_disinfection_water,
  4230. FirstDisinfectionMethods: first_disinfection_methods,
  4231. FirstDisinfectionTime: first_disinfection_time,
  4232. FirstStartTime: firstStartTime.Unix(),
  4233. FirstEndTime: firstEndTime.Unix(),
  4234. FirstTotalTime: first_total_time,
  4235. FirstIsCheck: first_is_check,
  4236. FirstModifications: first_modifications,
  4237. FirstCreator: first_creator,
  4238. SencondDisinfectionWater: sencond_disinfection_water,
  4239. SencondDisinfectionMethods: sencond_disinfection_methods,
  4240. SencondDisinfectionTime: sencond_disinfection_time,
  4241. SencondStartTime: sencondStartTime.Unix(),
  4242. SencondEndTime: sencondEndTime.Unix(),
  4243. SencondTotalTime: sencond_total_time,
  4244. SencondIsCheck: sencond_is_check,
  4245. SencondModifications: sencond_modifications,
  4246. SencondCreator: sencond_creator,
  4247. ThirdDisinfectionWater: third_disinfection_water,
  4248. ThirdDisinfectionMethods: third_disinfection_methods,
  4249. ThirdDisinfectionTime: third_disinfection_time,
  4250. ThirdStartTime: thirdStartTime.Unix(),
  4251. ThirdEndTime: thirdEndTime.Unix(),
  4252. ThirdTotalTime: third_total_time,
  4253. ThirdIsCheck: third_is_check,
  4254. ThirdModifications: third_modifications,
  4255. ThirdCreator: third_creator,
  4256. LastStartTime: lastStartTime.Unix(),
  4257. LastEndTime: lastEndTime.Unix(),
  4258. LastTotalTime: last_total_time,
  4259. LastIsCheck: last_is_check,
  4260. LastModifications: last_modifications,
  4261. LastCreator: last_creator,
  4262. Ctime: time.Now().Unix(),
  4263. Mtime: time.Now().Unix(),
  4264. Status: 1,
  4265. Storey: storey,
  4266. }
  4267. err = service.SaveNewAriDisinfect(disinfect)
  4268. if err != nil {
  4269. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4270. return
  4271. }
  4272. this.ServeSuccessJSON(map[string]interface{}{
  4273. "disinfect": disinfect,
  4274. })
  4275. }
  4276. func (this *MachineApiController) DeleteNewAirDisinfect() {
  4277. id, _ := this.GetInt64("id")
  4278. err := service.DeleteNewAirDisInfect(id)
  4279. if err != nil {
  4280. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4281. return
  4282. }
  4283. returnData := make(map[string]interface{}, 0)
  4284. returnData["msg"] = "ok"
  4285. this.ServeSuccessJSON(returnData)
  4286. return
  4287. }
  4288. func (this *MachineApiController) SaveObjTableDisInfect() {
  4289. timeLayout := "2006-01-02"
  4290. loc, _ := time.LoadLocation("Local")
  4291. dataBody := make(map[string]interface{}, 0)
  4292. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4293. fmt.Println("err", err)
  4294. record_date := dataBody["record_date"].(string)
  4295. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4296. recorddateunix := recorddate.Unix()
  4297. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  4298. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  4299. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  4300. first_start_time := dataBody["first_start_time"].(string)
  4301. var firstStartTimeUnix int64
  4302. if len(first_start_time) > 0 {
  4303. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  4304. firstStartTimeUnix = firstStartTime.Unix()
  4305. }
  4306. var firstEndTimeUnix int64
  4307. first_end_time := dataBody["first_end_time"].(string)
  4308. if len(first_end_time) > 0 {
  4309. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  4310. firstEndTimeUnix = firstEndTime.Unix()
  4311. }
  4312. first_total_time := dataBody["first_total_time"].(string)
  4313. first_is_check := int64(dataBody["first_is_check"].(float64))
  4314. first_modifications := int64(dataBody["first_modifications"].(float64))
  4315. first_creator := int64(dataBody["first_creator"].(float64))
  4316. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  4317. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  4318. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  4319. sencond_start_time := dataBody["sencond_start_time"].(string)
  4320. var sencondStartTimeUnixt int64
  4321. if len(sencond_start_time) > 0 {
  4322. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  4323. sencondStartTimeUnixt = sencondStartTime.Unix()
  4324. }
  4325. sencond_end_time := dataBody["sencond_end_time"].(string)
  4326. var sencondEndTimeUnixt int64
  4327. if len(sencond_end_time) > 0 {
  4328. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  4329. sencondEndTimeUnixt = sencondEndTime.Unix()
  4330. }
  4331. sencond_total_time := dataBody["sencond_total_time"].(string)
  4332. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  4333. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  4334. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  4335. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4336. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4337. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4338. third_start_time := dataBody["third_start_time"].(string)
  4339. var thirdStartTimeUnix int64
  4340. if len(third_start_time) > 0 {
  4341. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4342. thirdStartTimeUnix = thirdStartTime.Unix()
  4343. }
  4344. third_end_time := dataBody["third_end_time"].(string)
  4345. var thirdEndTimeUnix int64
  4346. if len(third_end_time) > 0 {
  4347. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4348. thirdEndTimeUnix = thirdEndTime.Unix()
  4349. }
  4350. third_total_time := dataBody["third_total_time"].(string)
  4351. third_is_check := int64(dataBody["third_is_check"].(float64))
  4352. third_modifications := int64(dataBody["third_modifications"].(float64))
  4353. third_creator := int64(dataBody["third_creator"].(float64))
  4354. fourth_disinfection_water := dataBody["fourth_disinfection_water"].(string)
  4355. fourth_disinfection_methods := dataBody["fourth_disinfection_methods"].(string)
  4356. fourth_disinfection_time := dataBody["fourth_disinfection_time"].(string)
  4357. fourth_start_time := dataBody["fourth_start_time"].(string)
  4358. var fourthiStartTimeUnitx int64
  4359. if len(fourth_start_time) > 0 {
  4360. fourthStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_start_time)
  4361. fourthiStartTimeUnitx = fourthStartTime.Unix()
  4362. }
  4363. fourth_end_time := dataBody["fourth_end_time"].(string)
  4364. var fourthEndTimeUnix int64
  4365. if len(fourth_end_time) > 0 {
  4366. fourthEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_end_time)
  4367. fourthEndTimeUnix = fourthEndTime.Unix()
  4368. }
  4369. fourth_total_time := dataBody["fourth_total_time"].(string)
  4370. fourth_is_check := int64(dataBody["fourth_is_check"].(float64))
  4371. fourth_modifications := int64(dataBody["fourth_modifications"].(float64))
  4372. fourth_creator := int64(dataBody["fourth_creator"].(float64))
  4373. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  4374. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  4375. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  4376. last_start_time := dataBody["last_start_time"].(string)
  4377. var lastStartTimeUnix int64
  4378. if len(last_start_time) > 0 {
  4379. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4380. lastStartTimeUnix = lastStartTime.Unix()
  4381. }
  4382. last_end_time := dataBody["last_end_time"].(string)
  4383. var lastEndTimeUnix int64
  4384. if len(last_end_time) > 0 {
  4385. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4386. lastEndTimeUnix = lastEndTime.Unix()
  4387. }
  4388. last_total_time := dataBody["last_total_time"].(string)
  4389. last_is_check := int64(dataBody["last_is_check"].(float64))
  4390. last_modifications := int64(dataBody["last_modifications"].(float64))
  4391. last_creator := int64(dataBody["last_creator"].(float64))
  4392. storey := dataBody["storey"].(string)
  4393. orgId := this.GetAdminUserInfo().CurrentOrgId
  4394. objectDisinfect := models.XtNewObjectDisinfect{
  4395. UserOrgId: orgId,
  4396. RecordDate: recorddateunix,
  4397. FirstDisinfectionWater: first_disinfection_water,
  4398. FirstDisinfectionMethods: first_disinfection_methods,
  4399. FirstDisinfectionTime: first_disinfection_time,
  4400. FirstStartTime: firstStartTimeUnix,
  4401. FirstEndTime: firstEndTimeUnix,
  4402. FirstTotalTime: first_total_time,
  4403. FirstIsCheck: first_is_check,
  4404. FirstModifications: first_modifications,
  4405. FirstCreator: first_creator,
  4406. SencondDisinfectionWater: sencond_disinfection_water,
  4407. SencondDisinfectionMethods: sencond_disinfection_methods,
  4408. SencondDisinfectionTime: sencond_disinfection_time,
  4409. SencondStartTime: sencondStartTimeUnixt,
  4410. SencondEndTime: sencondEndTimeUnixt,
  4411. SencondTotalTime: sencond_total_time,
  4412. SencondIsCheck: sencond_is_check,
  4413. SencondModifications: sencond_modifications,
  4414. SencondCreator: sencond_creator,
  4415. ThirdDisinfectionWater: third_disinfection_water,
  4416. ThirdDisinfectionMethods: third_disinfection_methods,
  4417. ThirdDisinfectionTime: third_disinfection_time,
  4418. ThirdStartTime: thirdStartTimeUnix,
  4419. ThirdEndTime: thirdEndTimeUnix,
  4420. ThirdTotalTime: third_total_time,
  4421. ThirdIsCheck: third_is_check,
  4422. ThirdModifications: third_modifications,
  4423. ThirdCreator: third_creator,
  4424. LastStartTime: lastStartTimeUnix,
  4425. LastEndTime: lastEndTimeUnix,
  4426. LastTotalTime: last_total_time,
  4427. LastIsCheck: last_is_check,
  4428. LastModifications: last_modifications,
  4429. LastCreator: last_creator,
  4430. Ctime: time.Now().Unix(),
  4431. Mtime: 0,
  4432. Status: 1,
  4433. FourthDisinfectionWater: fourth_disinfection_water,
  4434. FourthDisinfectionMethods: fourth_disinfection_methods,
  4435. FourthDisinfectionTime: fourth_disinfection_time,
  4436. FourthStartTime: fourthiStartTimeUnitx,
  4437. FourthEndTime: fourthEndTimeUnix,
  4438. FourthTotalTime: fourth_total_time,
  4439. FourthIsCheck: fourth_is_check,
  4440. FourthModifications: fourth_modifications,
  4441. FourthCreator: fourth_creator,
  4442. LastDisinfectionWater: last_disinfection_water,
  4443. LastDisinfectionMethods: last_disinfection_methods,
  4444. LastDisinfectionTime: last_disinfection_time,
  4445. Storey: storey,
  4446. }
  4447. err = service.CreateObjectDisInfect(objectDisinfect)
  4448. if err != nil {
  4449. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4450. return
  4451. }
  4452. this.ServeSuccessJSON(map[string]interface{}{
  4453. "objectDisinfect": objectDisinfect,
  4454. })
  4455. }
  4456. func (this *MachineApiController) GetObjectTableDisinfectList() {
  4457. timeLayout := "2006-01-02"
  4458. loc, _ := time.LoadLocation("Local")
  4459. start_time := this.GetString("start_time")
  4460. end_time := this.GetString("end_time")
  4461. limit, _ := this.GetInt64("limit")
  4462. page, _ := this.GetInt64("page")
  4463. storey := this.GetString("storey")
  4464. var startTime int64
  4465. if len(start_time) > 0 {
  4466. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4467. if err != nil {
  4468. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4469. return
  4470. }
  4471. startTime = theTime.Unix()
  4472. }
  4473. var endTime int64
  4474. if len(end_time) > 0 {
  4475. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4476. if err != nil {
  4477. utils.ErrorLog(err.Error())
  4478. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4479. return
  4480. }
  4481. endTime = theTime.Unix()
  4482. }
  4483. orgId := this.GetAdminUserInfo().CurrentOrgId
  4484. list, total, err := service.GetObjectTableDisinfectList(limit, page, startTime, endTime, orgId, storey)
  4485. if err != nil {
  4486. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4487. return
  4488. }
  4489. this.ServeSuccessJSON(map[string]interface{}{
  4490. "list": list,
  4491. "total": total,
  4492. })
  4493. }
  4494. func (this *MachineApiController) GetObjectTableDisinfectByList() {
  4495. id, _ := this.GetInt64("id")
  4496. list, err := service.GetObjectTableDisinfectByList(id)
  4497. if err != nil {
  4498. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4499. return
  4500. }
  4501. this.ServeSuccessJSON(map[string]interface{}{
  4502. "list": list,
  4503. })
  4504. }
  4505. func (this *MachineApiController) UpdateObjectTableDisinfect() {
  4506. timeLayout := "2006-01-02"
  4507. loc, _ := time.LoadLocation("Local")
  4508. dataBody := make(map[string]interface{}, 0)
  4509. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4510. fmt.Println("err", err)
  4511. record_date := dataBody["record_date"].(string)
  4512. id := int64(dataBody["id"].(float64))
  4513. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4514. recorddateunix := recorddate.Unix()
  4515. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  4516. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  4517. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  4518. first_start_time := dataBody["first_start_time"].(string)
  4519. var firstStartTimeUnix int64
  4520. if len(first_start_time) > 0 {
  4521. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  4522. firstStartTimeUnix = firstStartTime.Unix()
  4523. }
  4524. var firstEndTimeUnix int64
  4525. first_end_time := dataBody["first_end_time"].(string)
  4526. if len(first_end_time) > 0 {
  4527. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  4528. firstEndTimeUnix = firstEndTime.Unix()
  4529. }
  4530. first_total_time := dataBody["first_total_time"].(string)
  4531. first_is_check := int64(dataBody["first_is_check"].(float64))
  4532. first_modifications := int64(dataBody["first_modifications"].(float64))
  4533. first_creator := int64(dataBody["first_creator"].(float64))
  4534. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  4535. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  4536. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  4537. sencond_start_time := dataBody["sencond_start_time"].(string)
  4538. var sencondStartTimeUnixt int64
  4539. if len(sencond_start_time) > 0 {
  4540. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  4541. sencondStartTimeUnixt = sencondStartTime.Unix()
  4542. }
  4543. sencond_end_time := dataBody["sencond_end_time"].(string)
  4544. var sencondEndTimeUnixt int64
  4545. if len(sencond_end_time) > 0 {
  4546. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  4547. sencondEndTimeUnixt = sencondEndTime.Unix()
  4548. }
  4549. sencond_total_time := dataBody["sencond_total_time"].(string)
  4550. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  4551. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  4552. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  4553. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4554. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4555. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4556. third_start_time := dataBody["third_start_time"].(string)
  4557. var thirdStartTimeUnix int64
  4558. if len(third_start_time) > 0 {
  4559. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4560. thirdStartTimeUnix = thirdStartTime.Unix()
  4561. }
  4562. third_end_time := dataBody["third_end_time"].(string)
  4563. var thirdEndTimeUnix int64
  4564. if len(third_end_time) > 0 {
  4565. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4566. thirdEndTimeUnix = thirdEndTime.Unix()
  4567. }
  4568. third_total_time := dataBody["third_total_time"].(string)
  4569. third_is_check := int64(dataBody["third_is_check"].(float64))
  4570. third_modifications := int64(dataBody["third_modifications"].(float64))
  4571. third_creator := int64(dataBody["third_creator"].(float64))
  4572. fourth_disinfection_water := dataBody["fourth_disinfection_water"].(string)
  4573. fourth_disinfection_methods := dataBody["fourth_disinfection_methods"].(string)
  4574. fourth_disinfection_time := dataBody["fourth_disinfection_time"].(string)
  4575. fourth_start_time := dataBody["fourth_start_time"].(string)
  4576. var fourthiStartTimeUnitx int64
  4577. if len(fourth_start_time) > 0 {
  4578. fourthStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_start_time)
  4579. fourthiStartTimeUnitx = fourthStartTime.Unix()
  4580. }
  4581. fourth_end_time := dataBody["fourth_end_time"].(string)
  4582. var fourthEndTimeUnix int64
  4583. if len(fourth_end_time) > 0 {
  4584. fourthEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_end_time)
  4585. fourthEndTimeUnix = fourthEndTime.Unix()
  4586. }
  4587. fourth_total_time := dataBody["fourth_total_time"].(string)
  4588. fourth_is_check := int64(dataBody["fourth_is_check"].(float64))
  4589. fourth_modifications := int64(dataBody["fourth_modifications"].(float64))
  4590. fourth_creator := int64(dataBody["fourth_creator"].(float64))
  4591. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  4592. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  4593. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  4594. last_start_time := dataBody["last_start_time"].(string)
  4595. var lastStartTimeUnix int64
  4596. if len(last_start_time) > 0 {
  4597. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4598. lastStartTimeUnix = lastStartTime.Unix()
  4599. }
  4600. last_end_time := dataBody["last_end_time"].(string)
  4601. var lastEndTimeUnix int64
  4602. if len(last_end_time) > 0 {
  4603. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4604. lastEndTimeUnix = lastEndTime.Unix()
  4605. }
  4606. last_total_time := dataBody["last_total_time"].(string)
  4607. last_is_check := int64(dataBody["last_is_check"].(float64))
  4608. last_modifications := int64(dataBody["last_modifications"].(float64))
  4609. last_creator := int64(dataBody["last_creator"].(float64))
  4610. storey := dataBody["storey"].(string)
  4611. orgId := this.GetAdminUserInfo().CurrentOrgId
  4612. objectDisinfect := models.XtNewObjectDisinfect{
  4613. ID: id,
  4614. UserOrgId: orgId,
  4615. RecordDate: recorddateunix,
  4616. FirstDisinfectionWater: first_disinfection_water,
  4617. FirstDisinfectionMethods: first_disinfection_methods,
  4618. FirstDisinfectionTime: first_disinfection_time,
  4619. FirstStartTime: firstStartTimeUnix,
  4620. FirstEndTime: firstEndTimeUnix,
  4621. FirstTotalTime: first_total_time,
  4622. FirstIsCheck: first_is_check,
  4623. FirstModifications: first_modifications,
  4624. FirstCreator: first_creator,
  4625. SencondDisinfectionWater: sencond_disinfection_water,
  4626. SencondDisinfectionMethods: sencond_disinfection_methods,
  4627. SencondDisinfectionTime: sencond_disinfection_time,
  4628. SencondStartTime: sencondStartTimeUnixt,
  4629. SencondEndTime: sencondEndTimeUnixt,
  4630. SencondTotalTime: sencond_total_time,
  4631. SencondIsCheck: sencond_is_check,
  4632. SencondModifications: sencond_modifications,
  4633. SencondCreator: sencond_creator,
  4634. ThirdDisinfectionWater: third_disinfection_water,
  4635. ThirdDisinfectionMethods: third_disinfection_methods,
  4636. ThirdDisinfectionTime: third_disinfection_time,
  4637. ThirdStartTime: thirdStartTimeUnix,
  4638. ThirdEndTime: thirdEndTimeUnix,
  4639. ThirdTotalTime: third_total_time,
  4640. ThirdIsCheck: third_is_check,
  4641. ThirdModifications: third_modifications,
  4642. ThirdCreator: third_creator,
  4643. LastStartTime: lastStartTimeUnix,
  4644. LastEndTime: lastEndTimeUnix,
  4645. LastTotalTime: last_total_time,
  4646. LastIsCheck: last_is_check,
  4647. LastModifications: last_modifications,
  4648. LastCreator: last_creator,
  4649. Ctime: time.Now().Unix(),
  4650. Mtime: 0,
  4651. Status: 1,
  4652. FourthDisinfectionWater: fourth_disinfection_water,
  4653. FourthDisinfectionMethods: fourth_disinfection_methods,
  4654. FourthDisinfectionTime: fourth_disinfection_time,
  4655. FourthStartTime: fourthiStartTimeUnitx,
  4656. FourthEndTime: fourthEndTimeUnix,
  4657. FourthTotalTime: fourth_total_time,
  4658. FourthIsCheck: fourth_is_check,
  4659. FourthModifications: fourth_modifications,
  4660. FourthCreator: fourth_creator,
  4661. LastDisinfectionWater: last_disinfection_water,
  4662. LastDisinfectionMethods: last_disinfection_methods,
  4663. LastDisinfectionTime: last_disinfection_time,
  4664. Storey: storey,
  4665. }
  4666. err = service.UpdateObjectTableDisinfect(objectDisinfect)
  4667. if err != nil {
  4668. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4669. return
  4670. }
  4671. this.ServeSuccessJSON(map[string]interface{}{
  4672. "objectDisinfect": objectDisinfect,
  4673. })
  4674. }
  4675. func (this *MachineApiController) DeleteObjectTableDisinfect() {
  4676. id, _ := this.GetInt64("id")
  4677. err := service.DeleteObjectTableDisinfect(id)
  4678. if err != nil {
  4679. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4680. return
  4681. }
  4682. returnData := make(map[string]interface{}, 0)
  4683. returnData["msg"] = "ok"
  4684. this.ServeSuccessJSON(returnData)
  4685. return
  4686. }
  4687. func (this *MachineApiController) GetAirDisinfectionLongTime() {
  4688. orgId := this.GetAdminUserInfo().CurrentOrgId
  4689. storey := this.GetString("storey")
  4690. list, err := service.GetAirDisInfectionLongTime(orgId, storey)
  4691. if err != nil {
  4692. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4693. return
  4694. }
  4695. this.ServeSuccessJSON(map[string]interface{}{
  4696. "list": list,
  4697. })
  4698. }
  4699. func (this *MachineApiController) GetObjectDisInfectionLongTime() {
  4700. orgId := this.GetAdminUserInfo().CurrentOrgId
  4701. list, err := service.GetObjectDisInfectionLongTime(orgId)
  4702. if err != nil {
  4703. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4704. return
  4705. }
  4706. this.ServeSuccessJSON(map[string]interface{}{
  4707. "list": list,
  4708. })
  4709. }
  4710. func (this *MachineApiController) GetInformationmanalist() {
  4711. //获取2022年8月1日到10月16日的上机患者
  4712. list, _ := service.GetDialysisOrderPatient(10101)
  4713. for _, dialysisOrder := range list {
  4714. //根据床位号获取设备型号
  4715. unitType, _ := service.GetUnitType(dialysisOrder.BedId, dialysisOrder.UserOrgId)
  4716. //查询使用消毒最后一条消毒记录
  4717. _, err := service.GetLaseDeviceInfomation(dialysisOrder.UserOrgId, dialysisOrder.BedId, dialysisOrder.DialysisDate, dialysisOrder.SchedualType)
  4718. fmt.Println("err", err)
  4719. if err == gorm.ErrRecordNotFound {
  4720. //查找排班
  4721. scheduleByPatient, _ := service.GetScheduleByPatient(dialysisOrder.PatientId, dialysisOrder.DialysisDate, dialysisOrder.UserOrgId)
  4722. //查询改设备是否有消毒计划
  4723. plan, errcode := service.GetDisInfectionTime(dialysisOrder.UserOrgId, unitType.UnitType, dialysisOrder.SchedualType, scheduleByPatient.ScheduleWeek)
  4724. //根据床位号获取设备id
  4725. addmacher, _ := service.GetEquimentIDTwo(dialysisOrder.BedId, dialysisOrder.UserOrgId)
  4726. //查询病人信息
  4727. patients, _ := service.GetPatientInfoMation(dialysisOrder.PatientId)
  4728. var con = ""
  4729. if patients.IsInfectious == 0 {
  4730. con = ""
  4731. }
  4732. if patients.IsInfectious == 1 {
  4733. con = "无"
  4734. }
  4735. if patients.IsInfectious == 2 {
  4736. con = "有"
  4737. }
  4738. if errcode == nil {
  4739. var end_time int64
  4740. end_time = dialysisOrder.EndTime + plan.DisinfecTime*60
  4741. //新增消毒
  4742. information := models.DeviceInformation{
  4743. Date: dialysisOrder.DialysisDate,
  4744. Zone: dialysisOrder.ZoneId,
  4745. Class: dialysisOrder.SchedualType,
  4746. BedNumber: dialysisOrder.BedId,
  4747. PatientId: dialysisOrder.PatientId,
  4748. DialysisMode: scheduleByPatient.ModeId,
  4749. LongTime: strconv.FormatInt(plan.DisinfecTime, 10),
  4750. Disinfection: 1,
  4751. DialysisConcentration: 1,
  4752. DisinfectionStatus: 1,
  4753. Move: 1,
  4754. UserOrgId: dialysisOrder.UserOrgId,
  4755. DisinfectType: plan.Way,
  4756. DisinfectantType: plan.MachineDisinfectant,
  4757. FluidPath: plan.DisinfectanWay, //液路消毒方式
  4758. Disinfectant: plan.Disinfectant,
  4759. Ctime: time.Now().Unix(),
  4760. Status: 1,
  4761. SignName: dialysisOrder.FinishNurse,
  4762. EquimentId: addmacher.ID,
  4763. DisinfectionResidue: 2,
  4764. Bed: addmacher.BedNumber,
  4765. StartTime: dialysisOrder.StartTime,
  4766. EndTime: dialysisOrder.EndTime,
  4767. Contagion: con,
  4768. WeightLoss: 0,
  4769. Hyperfiltratio: 0,
  4770. DialysisHour: "",
  4771. MachineRun: 1,
  4772. DisinfecStartime: dialysisOrder.EndTime,
  4773. DisinfecEndtime: end_time,
  4774. }
  4775. err := service.CreateInformationTwo(&information)
  4776. fmt.Println("报错", err)
  4777. }
  4778. }
  4779. }
  4780. this.ServeSuccessJSON(map[string]interface{}{
  4781. "list": list,
  4782. })
  4783. }
  4784. func (this *MachineApiController) SaveObjectRegistration() {
  4785. timeLayout := "2006-01-02"
  4786. loc, _ := time.LoadLocation("Local")
  4787. dataBody := make(map[string]interface{}, 0)
  4788. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4789. fmt.Println(err)
  4790. record_date := dataBody["record_date"].(string)
  4791. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4792. recorddateunix := recorddate.Unix()
  4793. model_number := dataBody["model_number"].(string)
  4794. user_count := dataBody["user_count"].(string)
  4795. product_date := dataBody["product_date"].(string)
  4796. productdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
  4797. productdateunix := productdate.Unix()
  4798. expiry_date := dataBody["expiry_date"].(string)
  4799. expirydate, _ := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
  4800. expirydateunix := expirydate.Unix()
  4801. packaging_identification := int64(dataBody["packaging_identification"].(float64))
  4802. destroy_people := int64(dataBody["destroy_people"].(float64))
  4803. destroy_nubmer := dataBody["destroy_nubmer"].(string)
  4804. destroy_way := int64(dataBody["destroy_way"].(float64))
  4805. leader := int64(dataBody["leader"].(float64))
  4806. orgId := this.GetAdminUserInfo().CurrentOrgId
  4807. registration := models.XtDialysisRegistration{
  4808. RecordDate: recorddateunix,
  4809. ModelNumber: model_number,
  4810. UserCount: user_count,
  4811. ProductDate: productdateunix,
  4812. ExpiryDate: expirydateunix,
  4813. PackagingIdentification: packaging_identification,
  4814. DestroyPeople: destroy_people,
  4815. DestroyNubmer: destroy_nubmer,
  4816. DestroyWay: destroy_way,
  4817. Leader: leader,
  4818. UserOrgId: orgId,
  4819. Status: 1,
  4820. Ctime: time.Now().Unix(),
  4821. Mtime: 0,
  4822. }
  4823. err = service.CreateObjectRegistration(registration)
  4824. this.ServeSuccessJSON(map[string]interface{}{
  4825. "registration": registration,
  4826. })
  4827. }
  4828. func (this *MachineApiController) GetRegistrationDisinfectList() {
  4829. timeLayout := "2006-01-02"
  4830. loc, _ := time.LoadLocation("Local")
  4831. start_time := this.GetString("start_time")
  4832. end_time := this.GetString("end_time")
  4833. limit, _ := this.GetInt64("limit")
  4834. page, _ := this.GetInt64("page")
  4835. var startTime int64
  4836. if len(start_time) > 0 {
  4837. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4838. if err != nil {
  4839. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4840. return
  4841. }
  4842. startTime = theTime.Unix()
  4843. }
  4844. var endTime int64
  4845. if len(end_time) > 0 {
  4846. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4847. if err != nil {
  4848. utils.ErrorLog(err.Error())
  4849. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4850. return
  4851. }
  4852. endTime = theTime.Unix()
  4853. }
  4854. orgId := this.GetAdminUserInfo().CurrentOrgId
  4855. list, total, err := service.GetRegistrationDisinfectList(limit, page, startTime, endTime, orgId)
  4856. if err != nil {
  4857. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4858. return
  4859. }
  4860. this.ServeSuccessJSON(map[string]interface{}{
  4861. "list": list,
  4862. "total": total,
  4863. })
  4864. }
  4865. func (this *MachineApiController) GetObjectRegistrationByIdList() {
  4866. id, _ := this.GetInt64("id")
  4867. list, err := service.GetObjectRegistrationByIdList(id)
  4868. if err != nil {
  4869. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4870. return
  4871. }
  4872. this.ServeSuccessJSON(map[string]interface{}{
  4873. "list": list,
  4874. })
  4875. }
  4876. func (this *MachineApiController) UpdateObjectRegistration() {
  4877. timeLayout := "2006-01-02"
  4878. loc, _ := time.LoadLocation("Local")
  4879. dataBody := make(map[string]interface{}, 0)
  4880. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4881. fmt.Println(err)
  4882. record_date := dataBody["record_date"].(string)
  4883. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4884. recorddateunix := recorddate.Unix()
  4885. model_number := dataBody["model_number"].(string)
  4886. user_count := dataBody["user_count"].(string)
  4887. product_date := dataBody["product_date"].(string)
  4888. productdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
  4889. productdateunix := productdate.Unix()
  4890. expiry_date := dataBody["expiry_date"].(string)
  4891. expirydate, _ := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
  4892. expirydateunix := expirydate.Unix()
  4893. packaging_identification := int64(dataBody["packaging_identification"].(float64))
  4894. destroy_people := int64(dataBody["destroy_people"].(float64))
  4895. destroy_nubmer := dataBody["destroy_nubmer"].(string)
  4896. destroy_way := int64(dataBody["destroy_way"].(float64))
  4897. leader := int64(dataBody["leader"].(float64))
  4898. id := int64(dataBody["id"].(float64))
  4899. orgId := this.GetAdminUserInfo().CurrentOrgId
  4900. registration := models.XtDialysisRegistration{
  4901. ID: id,
  4902. RecordDate: recorddateunix,
  4903. ModelNumber: model_number,
  4904. UserCount: user_count,
  4905. ProductDate: productdateunix,
  4906. ExpiryDate: expirydateunix,
  4907. PackagingIdentification: packaging_identification,
  4908. DestroyPeople: destroy_people,
  4909. DestroyNubmer: destroy_nubmer,
  4910. DestroyWay: destroy_way,
  4911. Leader: leader,
  4912. UserOrgId: orgId,
  4913. Status: 1,
  4914. Ctime: time.Now().Unix(),
  4915. Mtime: 0,
  4916. }
  4917. service.UpdateObjectRegistration(registration)
  4918. this.ServeSuccessJSON(map[string]interface{}{
  4919. "registration": registration,
  4920. })
  4921. }
  4922. func (this *MachineApiController) DeleteObjectTregistration() {
  4923. id, _ := this.GetInt64("id")
  4924. err := service.DeleteObjectTregistration(id)
  4925. if err != nil {
  4926. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4927. return
  4928. }
  4929. this.ServeSuccessJSON(map[string]interface{}{
  4930. "msg": "ok",
  4931. })
  4932. return
  4933. }
  4934. func (this *MachineApiController) GetRegistGoodInforList() {
  4935. orgId := this.GetAdminUserInfo().CurrentOrgId
  4936. list, err := service.GetRegistGoodInforList(orgId)
  4937. if err != nil {
  4938. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4939. return
  4940. }
  4941. this.ServeSuccessJSON(map[string]interface{}{
  4942. "list": list,
  4943. })
  4944. return
  4945. }
  4946. func (this *MachineApiController) GetRegistNumber() {
  4947. id, _ := this.GetInt64("id")
  4948. record_date := this.GetString("record_date")
  4949. timeLayout := "2006-01-02"
  4950. loc, _ := time.LoadLocation("Local")
  4951. dataBody := make(map[string]interface{}, 0)
  4952. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4953. fmt.Println(err)
  4954. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4955. recorddateunix := recorddate.Unix()
  4956. orgId := this.GetAdminUserInfo().CurrentOrgId
  4957. infor, err := service.GetRegistNumber(recorddateunix, id, orgId)
  4958. if err != nil {
  4959. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4960. return
  4961. }
  4962. this.ServeSuccessJSON(map[string]interface{}{
  4963. "list": infor,
  4964. })
  4965. return
  4966. }
  4967. func (this *MachineApiController) SaveSetAirDisInfect() {
  4968. air_way, _ := this.GetInt64("air_way")
  4969. orgId := this.GetAdminUserInfo().CurrentOrgId
  4970. airdisinfect, _ := service.GetAirDisInfectSetting(orgId)
  4971. airSetting := models.XtDeviceAirSetting{
  4972. ID: airdisinfect.ID,
  4973. AirWay: air_way,
  4974. UserOrgId: orgId,
  4975. Ctime: time.Now().Unix(),
  4976. Status: 1,
  4977. Mtime: time.Now().Unix(),
  4978. }
  4979. err := service.SaveSetAirDisInfect(airSetting)
  4980. if err != nil {
  4981. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4982. return
  4983. }
  4984. this.ServeSuccessJSON(map[string]interface{}{
  4985. "airSetting": airSetting,
  4986. })
  4987. return
  4988. }
  4989. func (this *MachineApiController) GetSetAirInfectById() {
  4990. orgId := this.GetAdminUserInfo().CurrentOrgId
  4991. airset, _ := service.GetAirDisInfectSetting(orgId)
  4992. this.ServeSuccessJSON(map[string]interface{}{
  4993. "airset": airset,
  4994. })
  4995. return
  4996. }
  4997. func (this *MachineApiController) SaveNewAirWayDisinfect() {
  4998. timeLayout := "2006-01-02"
  4999. loc, _ := time.LoadLocation("Local")
  5000. dataBody := make(map[string]interface{}, 0)
  5001. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  5002. fmt.Println("err", err)
  5003. record_date := dataBody["record_date"].(string)
  5004. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5005. recorddateunix := recorddate.Unix()
  5006. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5007. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5008. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5009. first_start_time := dataBody["first_start_time"].(string)
  5010. if len(first_start_time) == 0 {
  5011. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5012. return
  5013. }
  5014. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5015. first_end_time := dataBody["first_end_time"].(string)
  5016. if len(first_end_time) == 0 {
  5017. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5018. return
  5019. }
  5020. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5021. first_total_time := dataBody["first_total_time"].(string)
  5022. first_is_check := int64(dataBody["first_is_check"].(float64))
  5023. first_modifications := int64(dataBody["first_modifications"].(float64))
  5024. first_creator := int64(dataBody["first_creator"].(float64))
  5025. last_start_time := dataBody["last_start_time"].(string)
  5026. if len(last_start_time) == 0 {
  5027. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5028. return
  5029. }
  5030. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5031. last_end_time := dataBody["last_end_time"].(string)
  5032. if len(last_end_time) == 0 {
  5033. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5034. return
  5035. }
  5036. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5037. last_total_time := dataBody["last_total_time"].(string)
  5038. last_is_check := int64(dataBody["last_is_check"].(float64))
  5039. last_modifications := int64(dataBody["last_modifications"].(float64))
  5040. last_creator := int64(dataBody["last_creator"].(float64))
  5041. department := dataBody["department"].(string)
  5042. orgId := this.GetAdminUserInfo().CurrentOrgId
  5043. disinfect := models.XtNewAriDisinfectWay{
  5044. UserOrgId: orgId,
  5045. RecordDate: recorddateunix,
  5046. FirstDisinfectionWater: first_disinfection_water,
  5047. FirstDisinfectionMethods: first_disinfection_methods,
  5048. FirstDisinfectionTime: first_disinfection_time,
  5049. FirstStartTime: firstStartTime.Unix(),
  5050. FirstEndTime: firstEndTime.Unix(),
  5051. FirstTotalTime: first_total_time,
  5052. FirstIsCheck: first_is_check,
  5053. FirstModifications: first_modifications,
  5054. FirstCreator: first_creator,
  5055. LastStartTime: lastStartTime.Unix(),
  5056. LastEndTime: lastEndTime.Unix(),
  5057. LastTotalTime: last_total_time,
  5058. LastIsCheck: last_is_check,
  5059. LastModifications: last_modifications,
  5060. LastCreator: last_creator,
  5061. Ctime: time.Now().Unix(),
  5062. Mtime: time.Now().Unix(),
  5063. Status: 1,
  5064. Department: department,
  5065. }
  5066. err = service.CreateNewAirWayDisinfectOne(disinfect)
  5067. if err != nil {
  5068. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5069. return
  5070. }
  5071. this.ServeSuccessJSON(map[string]interface{}{
  5072. "disinfect": disinfect,
  5073. })
  5074. }
  5075. func (this *MachineApiController) GetNewAirWayDisinfectList() {
  5076. timeLayout := "2006-01-02"
  5077. loc, _ := time.LoadLocation("Local")
  5078. start_time := this.GetString("start_time")
  5079. end_time := this.GetString("end_time")
  5080. limit, _ := this.GetInt64("limit")
  5081. page, _ := this.GetInt64("page")
  5082. var startTime int64
  5083. if len(start_time) > 0 {
  5084. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5085. if err != nil {
  5086. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5087. return
  5088. }
  5089. startTime = theTime.Unix()
  5090. }
  5091. var endTime int64
  5092. if len(end_time) > 0 {
  5093. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5094. if err != nil {
  5095. utils.ErrorLog(err.Error())
  5096. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5097. return
  5098. }
  5099. endTime = theTime.Unix()
  5100. }
  5101. orgId := this.GetAdminUserInfo().CurrentOrgId
  5102. list, total, err := service.GetNewAirWayDisinfectList(limit, page, startTime, endTime, orgId)
  5103. fmt.Println("lisitwoowowow", list)
  5104. if err != nil {
  5105. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5106. return
  5107. }
  5108. this.ServeSuccessJSON(map[string]interface{}{
  5109. "list": list,
  5110. "total": total,
  5111. })
  5112. }
  5113. func (this *MachineApiController) GetAirDisinfectWayLongTime() {
  5114. orgId := this.GetAdminUserInfo().CurrentOrgId
  5115. department := this.GetString("department")
  5116. list, err := service.GetAirDisinfectWayLongTime(orgId, department)
  5117. if err != nil {
  5118. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5119. return
  5120. }
  5121. this.ServeSuccessJSON(map[string]interface{}{
  5122. "list": list,
  5123. })
  5124. }
  5125. func (this *MachineApiController) GetNewAirWayDisinfectByIdList() {
  5126. id, _ := this.GetInt64("id")
  5127. list, err := service.GetNewAirWayDisinfectByIdList(id)
  5128. if err != nil {
  5129. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5130. return
  5131. }
  5132. this.ServeSuccessJSON(map[string]interface{}{
  5133. "list": list,
  5134. })
  5135. }
  5136. func (this *MachineApiController) UpdateNewAirWayDisInfect() {
  5137. timeLayout := "2006-01-02"
  5138. loc, _ := time.LoadLocation("Local")
  5139. dataBody := make(map[string]interface{}, 0)
  5140. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  5141. fmt.Println("err", err)
  5142. id := int64(dataBody["id"].(float64))
  5143. record_date := dataBody["record_date"].(string)
  5144. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5145. recorddateunix := recorddate.Unix()
  5146. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5147. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5148. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5149. first_start_time := dataBody["first_start_time"].(string)
  5150. if len(first_start_time) == 0 {
  5151. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5152. return
  5153. }
  5154. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5155. first_end_time := dataBody["first_end_time"].(string)
  5156. if len(first_end_time) == 0 {
  5157. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5158. return
  5159. }
  5160. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5161. first_total_time := dataBody["first_total_time"].(string)
  5162. first_is_check := int64(dataBody["first_is_check"].(float64))
  5163. first_modifications := int64(dataBody["first_modifications"].(float64))
  5164. first_creator := int64(dataBody["first_creator"].(float64))
  5165. last_start_time := dataBody["last_start_time"].(string)
  5166. if len(last_start_time) == 0 {
  5167. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5168. return
  5169. }
  5170. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5171. last_end_time := dataBody["last_end_time"].(string)
  5172. if len(last_end_time) == 0 {
  5173. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5174. return
  5175. }
  5176. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5177. last_total_time := dataBody["last_total_time"].(string)
  5178. last_is_check := int64(dataBody["last_is_check"].(float64))
  5179. last_modifications := int64(dataBody["last_modifications"].(float64))
  5180. last_creator := int64(dataBody["last_creator"].(float64))
  5181. department := dataBody["department"].(string)
  5182. orgId := this.GetAdminUserInfo().CurrentOrgId
  5183. disinfect := models.XtNewAriDisinfectWay{
  5184. ID: id,
  5185. UserOrgId: orgId,
  5186. RecordDate: recorddateunix,
  5187. FirstDisinfectionWater: first_disinfection_water,
  5188. FirstDisinfectionMethods: first_disinfection_methods,
  5189. FirstDisinfectionTime: first_disinfection_time,
  5190. FirstStartTime: firstStartTime.Unix(),
  5191. FirstEndTime: firstEndTime.Unix(),
  5192. FirstTotalTime: first_total_time,
  5193. FirstIsCheck: first_is_check,
  5194. FirstModifications: first_modifications,
  5195. FirstCreator: first_creator,
  5196. LastStartTime: lastStartTime.Unix(),
  5197. LastEndTime: lastEndTime.Unix(),
  5198. LastTotalTime: last_total_time,
  5199. LastIsCheck: last_is_check,
  5200. LastModifications: last_modifications,
  5201. LastCreator: last_creator,
  5202. Ctime: time.Now().Unix(),
  5203. Mtime: time.Now().Unix(),
  5204. Status: 1,
  5205. Department: department,
  5206. }
  5207. err = service.CreateNewAirWayDisinfect(disinfect)
  5208. if err != nil {
  5209. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5210. return
  5211. }
  5212. this.ServeSuccessJSON(map[string]interface{}{
  5213. "disinfect": disinfect,
  5214. })
  5215. }
  5216. func (this *MachineApiController) DeleteNewAirWayDisinfect() {
  5217. id, _ := this.GetInt64("id")
  5218. err := service.DeleteNewAirWayDisinfect(id)
  5219. if err != nil {
  5220. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5221. return
  5222. }
  5223. this.ServeSuccessJSON(map[string]interface{}{
  5224. "msg": "ok",
  5225. })
  5226. return
  5227. }
  5228. func (this *MachineApiController) SaveSetObjectDisinfect() {
  5229. air_way, _ := this.GetInt64("air_way")
  5230. orgId := this.GetAdminUserInfo().CurrentOrgId
  5231. disinfect, _ := service.GetObjectTableDisinfect(orgId)
  5232. objctSet := models.XtDeviceObjctSet{
  5233. ID: disinfect.ID,
  5234. UserOrgId: orgId,
  5235. Status: 1,
  5236. AirWay: air_way,
  5237. Ctime: time.Now().Unix(),
  5238. Mtime: time.Now().Unix(),
  5239. }
  5240. err := service.SaveSetObjectDisinfect(objctSet)
  5241. if err != nil {
  5242. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5243. return
  5244. }
  5245. this.ServeSuccessJSON(map[string]interface{}{
  5246. "objctSet": objctSet,
  5247. })
  5248. return
  5249. }
  5250. func (this *MachineApiController) GetObjectWayDisinect() {
  5251. orgId := this.GetAdminUserInfo().CurrentOrgId
  5252. disinfect, _ := service.GetObjectTableDisinfect(orgId)
  5253. this.ServeSuccessJSON(map[string]interface{}{
  5254. "disinfect": disinfect,
  5255. })
  5256. return
  5257. }
  5258. func (this *MachineApiController) SaveObjectWayTableDisinfect() {
  5259. timeLayout := "2006-01-02"
  5260. loc, _ := time.LoadLocation("Local")
  5261. dataBody := make(map[string]interface{}, 0)
  5262. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  5263. fmt.Println("err", err)
  5264. record_date := dataBody["record_date"].(string)
  5265. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5266. recorddateunix := recorddate.Unix()
  5267. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5268. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5269. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5270. first_start_time := dataBody["first_start_time"].(string)
  5271. var firstStartTimeUnix int64
  5272. if len(first_start_time) > 0 {
  5273. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5274. firstStartTimeUnix = firstStartTime.Unix()
  5275. }
  5276. var firstEndTimeUnix int64
  5277. first_end_time := dataBody["first_end_time"].(string)
  5278. if len(first_end_time) > 0 {
  5279. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5280. firstEndTimeUnix = firstEndTime.Unix()
  5281. }
  5282. first_total_time := dataBody["first_total_time"].(string)
  5283. first_is_check := int64(dataBody["first_is_check"].(float64))
  5284. first_modifications := int64(dataBody["first_modifications"].(float64))
  5285. first_creator := int64(dataBody["first_creator"].(float64))
  5286. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  5287. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  5288. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  5289. last_start_time := dataBody["last_start_time"].(string)
  5290. var lastStartTimeUnix int64
  5291. if len(last_start_time) > 0 {
  5292. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5293. lastStartTimeUnix = lastStartTime.Unix()
  5294. }
  5295. last_end_time := dataBody["last_end_time"].(string)
  5296. var lastEndTimeUnix int64
  5297. if len(last_end_time) > 0 {
  5298. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5299. lastEndTimeUnix = lastEndTime.Unix()
  5300. }
  5301. last_total_time := dataBody["last_total_time"].(string)
  5302. last_is_check := int64(dataBody["last_is_check"].(float64))
  5303. last_modifications := int64(dataBody["last_modifications"].(float64))
  5304. last_creator := int64(dataBody["last_creator"].(float64))
  5305. orgId := this.GetAdminUserInfo().CurrentOrgId
  5306. department := dataBody["department"].(string)
  5307. objectDisinfect := models.XtNewObjectDisinfectWay{
  5308. UserOrgId: orgId,
  5309. RecordDate: recorddateunix,
  5310. FirstDisinfectionWater: first_disinfection_water,
  5311. FirstDisinfectionMethods: first_disinfection_methods,
  5312. FirstDisinfectionTime: first_disinfection_time,
  5313. FirstStartTime: firstStartTimeUnix,
  5314. FirstEndTime: firstEndTimeUnix,
  5315. FirstTotalTime: first_total_time,
  5316. FirstIsCheck: first_is_check,
  5317. FirstModifications: first_modifications,
  5318. FirstCreator: first_creator,
  5319. LastStartTime: lastStartTimeUnix,
  5320. LastEndTime: lastEndTimeUnix,
  5321. LastTotalTime: last_total_time,
  5322. LastIsCheck: last_is_check,
  5323. LastModifications: last_modifications,
  5324. LastCreator: last_creator,
  5325. Ctime: time.Now().Unix(),
  5326. Mtime: 0,
  5327. Status: 1,
  5328. LastDisinfectionWater: last_disinfection_water,
  5329. LastDisinfectionMethods: last_disinfection_methods,
  5330. LastDisinfectionTime: last_disinfection_time,
  5331. Department: department,
  5332. }
  5333. err = service.CreateNewObjectWayDisInfect(objectDisinfect)
  5334. if err != nil {
  5335. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5336. return
  5337. }
  5338. this.ServeSuccessJSON(map[string]interface{}{
  5339. "objectDisinfect": objectDisinfect,
  5340. })
  5341. }
  5342. func (this *MachineApiController) GetObjectAbleDisInfectWayList() {
  5343. timeLayout := "2006-01-02"
  5344. loc, _ := time.LoadLocation("Local")
  5345. start_time := this.GetString("start_time")
  5346. end_time := this.GetString("end_time")
  5347. limit, _ := this.GetInt64("limit")
  5348. page, _ := this.GetInt64("page")
  5349. var startTime int64
  5350. if len(start_time) > 0 {
  5351. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5352. if err != nil {
  5353. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5354. return
  5355. }
  5356. startTime = theTime.Unix()
  5357. }
  5358. var endTime int64
  5359. if len(end_time) > 0 {
  5360. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5361. if err != nil {
  5362. utils.ErrorLog(err.Error())
  5363. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5364. return
  5365. }
  5366. endTime = theTime.Unix()
  5367. }
  5368. orgId := this.GetAdminUserInfo().CurrentOrgId
  5369. list, total, err := service.GetObjectAbleDisInfectWayList(limit, page, startTime, endTime, orgId)
  5370. if err != nil {
  5371. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5372. return
  5373. }
  5374. this.ServeSuccessJSON(map[string]interface{}{
  5375. "list": list,
  5376. "total": total,
  5377. })
  5378. }
  5379. func (this *MachineApiController) GetObjectAbledDisInfectWayById() {
  5380. id, _ := this.GetInt64("id")
  5381. list, err := service.GetObjectAbledDisInfectWayById(id)
  5382. if err != nil {
  5383. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5384. return
  5385. }
  5386. this.ServeSuccessJSON(map[string]interface{}{
  5387. "list": list,
  5388. })
  5389. }
  5390. func (this *MachineApiController) UpdateObjectWayAbleDisinfect() {
  5391. timeLayout := "2006-01-02"
  5392. loc, _ := time.LoadLocation("Local")
  5393. dataBody := make(map[string]interface{}, 0)
  5394. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  5395. fmt.Println("err", err)
  5396. record_date := dataBody["record_date"].(string)
  5397. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5398. recorddateunix := recorddate.Unix()
  5399. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5400. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5401. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5402. first_start_time := dataBody["first_start_time"].(string)
  5403. var firstStartTimeUnix int64
  5404. if len(first_start_time) > 0 {
  5405. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5406. firstStartTimeUnix = firstStartTime.Unix()
  5407. }
  5408. var firstEndTimeUnix int64
  5409. first_end_time := dataBody["first_end_time"].(string)
  5410. if len(first_end_time) > 0 {
  5411. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5412. firstEndTimeUnix = firstEndTime.Unix()
  5413. }
  5414. first_total_time := dataBody["first_total_time"].(string)
  5415. first_is_check := int64(dataBody["first_is_check"].(float64))
  5416. first_modifications := int64(dataBody["first_modifications"].(float64))
  5417. first_creator := int64(dataBody["first_creator"].(float64))
  5418. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  5419. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  5420. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  5421. last_start_time := dataBody["last_start_time"].(string)
  5422. var lastStartTimeUnix int64
  5423. if len(last_start_time) > 0 {
  5424. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5425. lastStartTimeUnix = lastStartTime.Unix()
  5426. }
  5427. last_end_time := dataBody["last_end_time"].(string)
  5428. var lastEndTimeUnix int64
  5429. if len(last_end_time) > 0 {
  5430. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5431. lastEndTimeUnix = lastEndTime.Unix()
  5432. }
  5433. last_total_time := dataBody["last_total_time"].(string)
  5434. last_is_check := int64(dataBody["last_is_check"].(float64))
  5435. last_modifications := int64(dataBody["last_modifications"].(float64))
  5436. last_creator := int64(dataBody["last_creator"].(float64))
  5437. id := int64(dataBody["id"].(float64))
  5438. orgId := this.GetAdminUserInfo().CurrentOrgId
  5439. department := dataBody["department"].(string)
  5440. objectDisinfect := models.XtNewObjectDisinfectWay{
  5441. ID: id,
  5442. UserOrgId: orgId,
  5443. RecordDate: recorddateunix,
  5444. FirstDisinfectionWater: first_disinfection_water,
  5445. FirstDisinfectionMethods: first_disinfection_methods,
  5446. FirstDisinfectionTime: first_disinfection_time,
  5447. FirstStartTime: firstStartTimeUnix,
  5448. FirstEndTime: firstEndTimeUnix,
  5449. FirstTotalTime: first_total_time,
  5450. FirstIsCheck: first_is_check,
  5451. FirstModifications: first_modifications,
  5452. FirstCreator: first_creator,
  5453. LastStartTime: lastStartTimeUnix,
  5454. LastEndTime: lastEndTimeUnix,
  5455. LastTotalTime: last_total_time,
  5456. LastIsCheck: last_is_check,
  5457. LastModifications: last_modifications,
  5458. LastCreator: last_creator,
  5459. Ctime: time.Now().Unix(),
  5460. Mtime: 0,
  5461. Status: 1,
  5462. LastDisinfectionWater: last_disinfection_water,
  5463. LastDisinfectionMethods: last_disinfection_methods,
  5464. LastDisinfectionTime: last_disinfection_time,
  5465. Department: department,
  5466. }
  5467. err = service.SaveobjectDisinfect(objectDisinfect)
  5468. if err != nil {
  5469. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5470. return
  5471. }
  5472. this.ServeSuccessJSON(map[string]interface{}{
  5473. "objectDisinfect": objectDisinfect,
  5474. })
  5475. }
  5476. func (this *MachineApiController) DeleteObjectAbleWayDisinfect() {
  5477. id, _ := this.GetInt64("id")
  5478. err := service.DeleteObjectAbleWayDisinfect(id)
  5479. if err != nil {
  5480. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5481. return
  5482. }
  5483. this.ServeSuccessJSON(map[string]interface{}{
  5484. "msg": "ok",
  5485. })
  5486. return
  5487. }