manage_api_controller.go 218KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318231923202321232223232324232523262327232823292330233123322333233423352336233723382339234023412342234323442345234623472348234923502351235223532354235523562357235823592360236123622363236423652366236723682369237023712372237323742375237623772378237923802381238223832384238523862387238823892390239123922393239423952396239723982399240024012402240324042405240624072408240924102411241224132414241524162417241824192420242124222423242424252426242724282429243024312432243324342435243624372438243924402441244224432444244524462447244824492450245124522453245424552456245724582459246024612462246324642465246624672468246924702471247224732474247524762477247824792480248124822483248424852486248724882489249024912492249324942495249624972498249925002501250225032504250525062507250825092510251125122513251425152516251725182519252025212522252325242525252625272528252925302531253225332534253525362537253825392540254125422543254425452546254725482549255025512552255325542555255625572558255925602561256225632564256525662567256825692570257125722573257425752576257725782579258025812582258325842585258625872588258925902591259225932594259525962597259825992600260126022603260426052606260726082609261026112612261326142615261626172618261926202621262226232624262526262627262826292630263126322633263426352636263726382639264026412642264326442645264626472648264926502651265226532654265526562657265826592660266126622663266426652666266726682669267026712672267326742675267626772678267926802681268226832684268526862687268826892690269126922693269426952696269726982699270027012702270327042705270627072708270927102711271227132714271527162717271827192720272127222723272427252726272727282729273027312732273327342735273627372738273927402741274227432744274527462747274827492750275127522753275427552756275727582759276027612762276327642765276627672768276927702771277227732774277527762777277827792780278127822783278427852786278727882789279027912792279327942795279627972798279928002801280228032804280528062807280828092810281128122813281428152816281728182819282028212822282328242825282628272828282928302831283228332834283528362837283828392840284128422843284428452846284728482849285028512852285328542855285628572858285928602861286228632864286528662867286828692870287128722873287428752876287728782879288028812882288328842885288628872888288928902891289228932894289528962897289828992900290129022903290429052906290729082909291029112912291329142915291629172918291929202921292229232924292529262927292829292930293129322933293429352936293729382939294029412942294329442945294629472948294929502951295229532954295529562957295829592960296129622963296429652966296729682969297029712972297329742975297629772978297929802981298229832984298529862987298829892990299129922993299429952996299729982999300030013002300330043005300630073008300930103011301230133014301530163017301830193020302130223023302430253026302730283029303030313032303330343035303630373038303930403041304230433044304530463047304830493050305130523053305430553056305730583059306030613062306330643065306630673068306930703071307230733074307530763077307830793080308130823083308430853086308730883089309030913092309330943095309630973098309931003101310231033104310531063107310831093110311131123113311431153116311731183119312031213122312331243125312631273128312931303131313231333134313531363137313831393140314131423143314431453146314731483149315031513152315331543155315631573158315931603161316231633164316531663167316831693170317131723173317431753176317731783179318031813182318331843185318631873188318931903191319231933194319531963197319831993200320132023203320432053206320732083209321032113212321332143215321632173218321932203221322232233224322532263227322832293230323132323233323432353236323732383239324032413242324332443245324632473248324932503251325232533254325532563257325832593260326132623263326432653266326732683269327032713272327332743275327632773278327932803281328232833284328532863287328832893290329132923293329432953296329732983299330033013302330333043305330633073308330933103311331233133314331533163317331833193320332133223323332433253326332733283329333033313332333333343335333633373338333933403341334233433344334533463347334833493350335133523353335433553356335733583359336033613362336333643365336633673368336933703371337233733374337533763377337833793380338133823383338433853386338733883389339033913392339333943395339633973398339934003401340234033404340534063407340834093410341134123413341434153416341734183419342034213422342334243425342634273428342934303431343234333434343534363437343834393440344134423443344434453446344734483449345034513452345334543455345634573458345934603461346234633464346534663467346834693470347134723473347434753476347734783479348034813482348334843485348634873488348934903491349234933494349534963497349834993500350135023503350435053506350735083509351035113512351335143515351635173518351935203521352235233524352535263527352835293530353135323533353435353536353735383539354035413542354335443545354635473548354935503551355235533554355535563557355835593560356135623563356435653566356735683569357035713572357335743575357635773578357935803581358235833584358535863587358835893590359135923593359435953596359735983599360036013602360336043605360636073608360936103611361236133614361536163617361836193620362136223623362436253626362736283629363036313632363336343635363636373638363936403641364236433644364536463647364836493650365136523653365436553656365736583659366036613662366336643665366636673668366936703671367236733674367536763677367836793680368136823683368436853686368736883689369036913692369336943695369636973698369937003701370237033704370537063707370837093710371137123713371437153716371737183719372037213722372337243725372637273728372937303731373237333734373537363737373837393740374137423743374437453746374737483749375037513752375337543755375637573758375937603761376237633764376537663767376837693770377137723773377437753776377737783779378037813782378337843785378637873788378937903791379237933794379537963797379837993800380138023803380438053806380738083809381038113812381338143815381638173818381938203821382238233824382538263827382838293830383138323833383438353836383738383839384038413842384338443845384638473848384938503851385238533854385538563857385838593860386138623863386438653866386738683869387038713872387338743875387638773878387938803881388238833884388538863887388838893890389138923893389438953896389738983899390039013902390339043905390639073908390939103911391239133914391539163917391839193920392139223923392439253926392739283929393039313932393339343935393639373938393939403941394239433944394539463947394839493950395139523953395439553956395739583959396039613962396339643965396639673968396939703971397239733974397539763977397839793980398139823983398439853986398739883989399039913992399339943995399639973998399940004001400240034004400540064007400840094010401140124013401440154016401740184019402040214022402340244025402640274028402940304031403240334034403540364037403840394040404140424043404440454046404740484049405040514052405340544055405640574058405940604061406240634064406540664067406840694070407140724073407440754076407740784079408040814082408340844085408640874088408940904091409240934094409540964097409840994100410141024103410441054106410741084109411041114112411341144115411641174118411941204121412241234124412541264127412841294130413141324133413441354136413741384139414041414142414341444145414641474148414941504151415241534154415541564157415841594160416141624163416441654166416741684169417041714172417341744175417641774178417941804181418241834184418541864187418841894190419141924193419441954196419741984199420042014202420342044205420642074208420942104211421242134214421542164217421842194220422142224223422442254226422742284229423042314232423342344235423642374238423942404241424242434244424542464247424842494250425142524253425442554256425742584259426042614262426342644265426642674268426942704271427242734274427542764277427842794280428142824283428442854286428742884289429042914292429342944295429642974298429943004301430243034304430543064307430843094310431143124313431443154316431743184319432043214322432343244325432643274328432943304331433243334334433543364337433843394340434143424343434443454346434743484349435043514352435343544355435643574358435943604361436243634364436543664367436843694370437143724373437443754376437743784379438043814382438343844385438643874388438943904391439243934394439543964397439843994400440144024403440444054406440744084409441044114412441344144415441644174418441944204421442244234424442544264427442844294430443144324433443444354436443744384439444044414442444344444445444644474448444944504451445244534454445544564457445844594460446144624463446444654466446744684469447044714472447344744475447644774478447944804481448244834484448544864487448844894490449144924493449444954496449744984499450045014502450345044505450645074508450945104511451245134514451545164517451845194520452145224523452445254526452745284529453045314532453345344535453645374538453945404541454245434544454545464547454845494550455145524553455445554556455745584559456045614562456345644565456645674568456945704571457245734574457545764577457845794580458145824583458445854586458745884589459045914592459345944595459645974598459946004601460246034604460546064607460846094610461146124613461446154616461746184619462046214622462346244625462646274628462946304631463246334634463546364637463846394640464146424643464446454646464746484649465046514652465346544655465646574658465946604661466246634664466546664667466846694670467146724673467446754676467746784679468046814682468346844685468646874688468946904691469246934694469546964697469846994700470147024703470447054706470747084709471047114712471347144715471647174718471947204721472247234724472547264727472847294730473147324733473447354736473747384739474047414742474347444745474647474748474947504751475247534754475547564757475847594760476147624763476447654766476747684769477047714772477347744775477647774778477947804781478247834784478547864787478847894790479147924793479447954796479747984799480048014802480348044805480648074808480948104811481248134814481548164817481848194820482148224823482448254826482748284829483048314832483348344835483648374838483948404841484248434844484548464847484848494850485148524853485448554856485748584859486048614862486348644865486648674868486948704871487248734874487548764877487848794880488148824883488448854886488748884889489048914892489348944895489648974898489949004901490249034904490549064907490849094910491149124913491449154916491749184919492049214922492349244925492649274928492949304931493249334934493549364937493849394940494149424943494449454946494749484949495049514952495349544955495649574958495949604961496249634964496549664967496849694970497149724973497449754976497749784979498049814982498349844985498649874988498949904991499249934994499549964997499849995000500150025003500450055006500750085009501050115012501350145015501650175018501950205021502250235024502550265027502850295030503150325033503450355036503750385039504050415042504350445045504650475048504950505051505250535054505550565057505850595060506150625063506450655066506750685069507050715072507350745075507650775078507950805081508250835084508550865087508850895090509150925093509450955096509750985099510051015102510351045105510651075108510951105111511251135114511551165117511851195120512151225123512451255126512751285129513051315132513351345135513651375138513951405141514251435144514551465147514851495150515151525153515451555156515751585159516051615162516351645165516651675168516951705171517251735174517551765177517851795180518151825183518451855186518751885189519051915192519351945195519651975198519952005201520252035204520552065207520852095210521152125213521452155216521752185219522052215222522352245225522652275228522952305231523252335234523552365237523852395240524152425243524452455246524752485249525052515252525352545255525652575258525952605261526252635264526552665267526852695270527152725273527452755276527752785279528052815282528352845285528652875288528952905291529252935294529552965297529852995300530153025303530453055306530753085309531053115312531353145315531653175318531953205321532253235324532553265327532853295330533153325333533453355336533753385339534053415342534353445345534653475348534953505351535253535354535553565357535853595360536153625363536453655366536753685369537053715372537353745375537653775378537953805381538253835384538553865387538853895390539153925393539453955396539753985399540054015402540354045405540654075408540954105411541254135414541554165417541854195420542154225423542454255426542754285429543054315432543354345435543654375438543954405441544254435444544554465447544854495450545154525453545454555456545754585459546054615462546354645465546654675468546954705471547254735474547554765477547854795480548154825483548454855486548754885489549054915492549354945495549654975498549955005501550255035504550555065507550855095510551155125513551455155516551755185519552055215522552355245525552655275528552955305531553255335534553555365537553855395540554155425543554455455546554755485549555055515552555355545555555655575558555955605561556255635564556555665567556855695570557155725573557455755576557755785579558055815582558355845585558655875588558955905591559255935594559555965597559855995600560156025603560456055606560756085609561056115612561356145615561656175618561956205621562256235624562556265627562856295630563156325633563456355636563756385639564056415642564356445645564656475648564956505651565256535654565556565657565856595660566156625663566456655666566756685669567056715672567356745675567656775678567956805681568256835684568556865687568856895690569156925693569456955696569756985699570057015702570357045705570657075708570957105711571257135714571557165717571857195720572157225723572457255726572757285729573057315732573357345735573657375738573957405741574257435744574557465747574857495750575157525753575457555756575757585759576057615762576357645765576657675768576957705771577257735774577557765777577857795780578157825783578457855786578757885789579057915792579357945795579657975798579958005801580258035804580558065807580858095810581158125813581458155816581758185819582058215822582358245825582658275828582958305831583258335834583558365837583858395840584158425843584458455846584758485849585058515852585358545855585658575858585958605861586258635864586558665867586858695870587158725873587458755876587758785879588058815882588358845885588658875888588958905891589258935894589558965897589858995900590159025903590459055906590759085909591059115912591359145915591659175918591959205921592259235924592559265927592859295930593159325933593459355936593759385939594059415942594359445945594659475948594959505951595259535954595559565957595859595960596159625963596459655966596759685969597059715972597359745975597659775978597959805981598259835984598559865987598859895990599159925993599459955996599759985999600060016002600360046005600660076008600960106011601260136014601560166017601860196020602160226023602460256026602760286029603060316032603360346035603660376038603960406041604260436044604560466047604860496050605160526053605460556056605760586059606060616062606360646065606660676068606960706071607260736074607560766077607860796080608160826083608460856086608760886089609060916092609360946095609660976098609961006101610261036104610561066107610861096110611161126113611461156116611761186119612061216122612361246125612661276128612961306131613261336134613561366137613861396140614161426143614461456146614761486149615061516152615361546155615661576158615961606161616261636164616561666167616861696170617161726173617461756176617761786179618061816182618361846185618661876188618961906191619261936194619561966197619861996200620162026203620462056206620762086209621062116212621362146215621662176218621962206221622262236224622562266227622862296230623162326233623462356236623762386239624062416242624362446245624662476248624962506251625262536254625562566257625862596260626162626263626462656266626762686269627062716272627362746275627662776278627962806281628262836284628562866287628862896290629162926293629462956296629762986299630063016302630363046305630663076308630963106311631263136314631563166317631863196320632163226323632463256326632763286329633063316332633363346335633663376338633963406341634263436344634563466347634863496350635163526353635463556356635763586359636063616362
  1. package controllers
  2. import (
  3. "encoding/json"
  4. "fmt"
  5. "strconv"
  6. "time"
  7. "unsafe"
  8. "XT_New/enums"
  9. "XT_New/models"
  10. "XT_New/service"
  11. "XT_New/utils"
  12. "github.com/astaxie/beego"
  13. "github.com/jinzhu/gorm"
  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. info := this.GetAdminUserInfo()
  2590. orgId := info.CurrentOrgId
  2591. remander := models.DeviceRemander{
  2592. IsRun: id,
  2593. Status: 1,
  2594. UserOrgId: orgId,
  2595. Ctime: time.Now().Unix(),
  2596. }
  2597. RemanderData, _ := service.GetRemanderData(orgId)
  2598. if RemanderData.ID == 0 {
  2599. service.CreateRemander(&remander).Error()
  2600. }
  2601. if RemanderData.ID > 0 {
  2602. deviceRemander := models.DeviceRemander{
  2603. ID: RemanderData.ID,
  2604. IsRun: id,
  2605. Status: 1,
  2606. UserOrgId: orgId,
  2607. Mtime: time.Now().Unix(),
  2608. }
  2609. service.UpdateRemander(&deviceRemander)
  2610. }
  2611. this.ServeSuccessJSON(map[string]interface{}{
  2612. "id": id,
  2613. })
  2614. return
  2615. }
  2616. func (this *MachineApiController) GetRemanderData() {
  2617. info := this.GetAdminUserInfo()
  2618. orgid := info.CurrentOrgId
  2619. data, err := service.GetRemanderData(orgid)
  2620. if err != nil {
  2621. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2622. return
  2623. }
  2624. this.ServeSuccessJSON(map[string]interface{}{
  2625. "remander": data,
  2626. })
  2627. }
  2628. func (this *MachineApiController) OpenDelete() {
  2629. id, _ := this.GetInt64("id")
  2630. err := service.DeletePlan(id)
  2631. if err != nil {
  2632. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2633. return
  2634. }
  2635. returnData := make(map[string]interface{}, 0)
  2636. returnData["msg"] = "ok"
  2637. this.ServeSuccessJSON(returnData)
  2638. return
  2639. }
  2640. func (this *MachineApiController) DeleteUserLogin() {
  2641. id, _ := this.GetInt64("id")
  2642. err := service.DeleteUserLogin(id)
  2643. if err != nil {
  2644. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2645. return
  2646. }
  2647. returnData := make(map[string]interface{}, 0)
  2648. returnData["msg"] = "ok"
  2649. this.ServeSuccessJSON(returnData)
  2650. return
  2651. }
  2652. func (this *MachineApiController) DeleteCultrues() {
  2653. id, _ := this.GetInt64("id")
  2654. err := service.DeleteCultrues(id)
  2655. if err != nil {
  2656. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2657. return
  2658. }
  2659. returnData := make(map[string]interface{}, 0)
  2660. returnData["msg"] = "ok"
  2661. this.ServeSuccessJSON(returnData)
  2662. return
  2663. }
  2664. func (this *MachineApiController) DeleteDialystates() {
  2665. id, _ := this.GetInt64("id")
  2666. err := service.DeleteDialystates(id)
  2667. if err != nil {
  2668. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2669. return
  2670. }
  2671. returnData := make(map[string]interface{}, 0)
  2672. returnData["msg"] = "ok"
  2673. this.ServeSuccessJSON(returnData)
  2674. return
  2675. }
  2676. func (this *MachineApiController) Deleteions() {
  2677. id, _ := this.GetInt64("id")
  2678. err := service.DeleteIons(id)
  2679. if err != nil {
  2680. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2681. return
  2682. }
  2683. returnData := make(map[string]interface{}, 0)
  2684. returnData["msg"] = "ok"
  2685. this.ServeSuccessJSON(returnData)
  2686. return
  2687. }
  2688. func (this *MachineApiController) DeleteRepairs() {
  2689. id, _ := this.GetInt64("id")
  2690. err := service.DeleteRepairs(id)
  2691. if err != nil {
  2692. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2693. return
  2694. }
  2695. returnData := make(map[string]interface{}, 0)
  2696. returnData["msg"] = "ok"
  2697. this.ServeSuccessJSON(returnData)
  2698. return
  2699. }
  2700. func (this *MachineApiController) SaveMode() {
  2701. adminUserInfo := this.GetAdminUserInfo()
  2702. orgid := adminUserInfo.CurrentOrgId
  2703. fmt.Println("机构id", orgid)
  2704. dataBody := make(map[string]interface{}, 0)
  2705. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2706. fmt.Println("err", err)
  2707. device_mode := dataBody["device_mode"].(string)
  2708. mode := models.DeviceMode{
  2709. DeviceMode: device_mode,
  2710. UserOrgId: orgid,
  2711. Status: 1,
  2712. Ctime: time.Now().Unix(),
  2713. }
  2714. _, errcode := service.GetMode(device_mode, orgid)
  2715. if errcode == gorm.ErrRecordNotFound {
  2716. err = service.SaveMode(&mode)
  2717. } else if errcode == nil {
  2718. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2719. return
  2720. } else {
  2721. }
  2722. if err != nil {
  2723. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2724. return
  2725. }
  2726. this.ServeSuccessJSON(map[string]interface{}{
  2727. "mode": mode,
  2728. })
  2729. }
  2730. func (this *MachineApiController) GetAllMode() {
  2731. fmt.Println("进来了没哟")
  2732. adminUserInfo := this.GetAdminUserInfo()
  2733. orgid := adminUserInfo.CurrentOrgId
  2734. mode, err := service.GetAllMode(orgid)
  2735. if err != nil {
  2736. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2737. return
  2738. }
  2739. this.ServeSuccessJSON(map[string]interface{}{
  2740. "mode": mode,
  2741. })
  2742. }
  2743. func (this *MachineApiController) EditMode() {
  2744. id, _ := this.GetInt64("id")
  2745. mode, err := service.GetModeById(id)
  2746. if err != nil {
  2747. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2748. return
  2749. }
  2750. this.ServeSuccessJSON(map[string]interface{}{
  2751. "mode": mode,
  2752. })
  2753. }
  2754. func (this *MachineApiController) UpdateMode() {
  2755. id, _ := this.GetInt64("id")
  2756. dataBody := make(map[string]interface{}, 0)
  2757. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2758. fmt.Println("err", err)
  2759. device_mode := dataBody["device_mode"].(string)
  2760. mode := models.DeviceMode{DeviceMode: device_mode}
  2761. err = service.UpdateMode(id, mode)
  2762. if err != nil {
  2763. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2764. return
  2765. }
  2766. this.ServeSuccessJSON(map[string]interface{}{
  2767. "mode": mode,
  2768. })
  2769. }
  2770. func (this *MachineApiController) DeleteMode() {
  2771. id, _ := this.GetInt64("id")
  2772. adminUserInfo := this.GetAdminUserInfo()
  2773. orgid := adminUserInfo.CurrentOrgId
  2774. _, errcode := service.QueryDeviceMode(id, orgid)
  2775. if errcode == gorm.ErrRecordNotFound {
  2776. service.DeleteMode(id)
  2777. returnData := make(map[string]interface{}, 0)
  2778. returnData["msg"] = "ok"
  2779. this.ServeSuccessJSON(returnData)
  2780. return
  2781. } else if errcode == nil {
  2782. return
  2783. } else {
  2784. fmt.Print("设备型号已存在")
  2785. }
  2786. }
  2787. func (this *MachineApiController) SelectChange() {
  2788. id, _ := this.GetInt64("id")
  2789. adminUserInfo := this.GetAdminUserInfo()
  2790. orgid := adminUserInfo.CurrentOrgId
  2791. change, err := service.SelectChange(id, orgid)
  2792. //fmt.Print("---------------------------", err)
  2793. if err != nil {
  2794. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2795. return
  2796. }
  2797. this.ServeSuccessJSON(map[string]interface{}{
  2798. "change": change,
  2799. })
  2800. }
  2801. func (this *MachineApiController) SelectBed() {
  2802. id, _ := this.GetInt64("id")
  2803. adminUserInfo := this.GetAdminUserInfo()
  2804. orgid := adminUserInfo.CurrentOrgId
  2805. bed, err := service.SelectBed(id, orgid)
  2806. if err != nil {
  2807. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2808. return
  2809. }
  2810. this.ServeSuccessJSON(map[string]interface{}{
  2811. "zone": bed,
  2812. })
  2813. }
  2814. func (this *MachineApiController) GetTimeData() {
  2815. equitid, _ := this.GetInt64("equitid")
  2816. fmt.Print("equitid", equitid)
  2817. timeLayout := "2006-01-02 15:04:05"
  2818. todaytime := this.GetString("todaytime")
  2819. theTime, _ := utils.ParseTimeStringToTime(timeLayout, todaytime+" 00:00:00")
  2820. fmt.Print("时间", theTime.Unix())
  2821. adminUserInfo := this.GetAdminUserInfo()
  2822. orgid := adminUserInfo.CurrentOrgId
  2823. timeData, err := service.GetTimeData(equitid, orgid, theTime.Unix())
  2824. fmt.Print("报错", err)
  2825. timeDataTwo, err := service.GetTimeTwo(equitid, orgid, theTime.Unix())
  2826. timeDataThree, err := service.GetTimeThree(equitid, orgid, theTime.Unix())
  2827. fmt.Print("err报错了没有", err)
  2828. if err != nil {
  2829. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2830. return
  2831. }
  2832. this.ServeSuccessJSON(map[string]interface{}{
  2833. "timeData": timeData,
  2834. "timeDataTwo": timeDataTwo,
  2835. "timeDataThree": timeDataThree,
  2836. })
  2837. }
  2838. func (this *MachineApiController) DeleteImages() {
  2839. id, _ := this.GetInt64("id")
  2840. err := service.DeleteImages(id)
  2841. fmt.Print("err", err)
  2842. if err != nil {
  2843. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2844. return
  2845. }
  2846. returnData := make(map[string]interface{}, 0)
  2847. returnData["msg"] = "ok"
  2848. this.ServeSuccessJSON(returnData)
  2849. return
  2850. }
  2851. func (this *MachineApiController) GetUserMachTotalCount() {
  2852. adminUserInfo := this.GetAdminUserInfo()
  2853. orgid := adminUserInfo.CurrentOrgId
  2854. count, err := service.GetUserMachTotalCount(orgid)
  2855. if err != nil {
  2856. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2857. return
  2858. }
  2859. this.ServeSuccessJSON(map[string]interface{}{
  2860. "count": count,
  2861. })
  2862. }
  2863. func (this *MachineApiController) GetUserTotalCount() {
  2864. adminUserInfo := this.GetAdminUserInfo()
  2865. orgid := adminUserInfo.CurrentOrgId
  2866. id, _ := this.GetInt64("id")
  2867. count, err := service.GetUserTotalCount(orgid, id)
  2868. addmacher, err := service.GetUserTotal(orgid, id)
  2869. if err != nil {
  2870. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2871. return
  2872. }
  2873. this.ServeSuccessJSON(map[string]interface{}{
  2874. "count": count,
  2875. "addmacher": addmacher,
  2876. })
  2877. }
  2878. func (this *MachineApiController) DeleteManagement() {
  2879. id, _ := this.GetInt64("id")
  2880. _, err := service.DeleteEquit(id)
  2881. if err != nil {
  2882. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  2883. return
  2884. }
  2885. returnData := make(map[string]interface{}, 0)
  2886. returnData["msg"] = "ok"
  2887. this.ServeSuccessJSON(returnData)
  2888. return
  2889. }
  2890. func (this *MachineApiController) SaveOxygenates() {
  2891. timeLayout := "2006-01-02"
  2892. loc, _ := time.LoadLocation("Local")
  2893. id, _ := this.GetInt64("id")
  2894. addmacher, _ := service.GetBedId(id)
  2895. adminUserInfo := this.GetAdminUserInfo()
  2896. orgid := adminUserInfo.CurrentOrgId
  2897. dataBody := make(map[string]interface{}, 0)
  2898. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2899. date := dataBody["sampling_date"].(string)
  2900. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  2901. samp_date := theTime.Unix()
  2902. specimen := int64(dataBody["specimenb"].(float64))
  2903. cona := dataBody["concentrate_noc"].(string)
  2904. conb := dataBody["concentrateb_nod"].(string)
  2905. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  2906. detectionUnit := dataBody["detection_unit"].(string)
  2907. samplerb := int64(dataBody["samplerb"].(float64))
  2908. reportDate := dataBody["reporting_dateb"].(string)
  2909. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  2910. repDate := reportTime.Unix()
  2911. detectionResult := dataBody["detection_resultb"].(string)
  2912. sort := dataBody["sort"].(string)
  2913. modifications := int64(dataBody["modifications"].(float64))
  2914. examination := dataBody["pass_examination"].(string)
  2915. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  2916. oxygenates := models.XtDeviceOxygenates{
  2917. SamplingDate: samp_date,
  2918. Specimenb: specimen,
  2919. ConcentrateNoc: cona,
  2920. ConcentratebNod: conb,
  2921. SamplingLocationb: samplinglocationb,
  2922. DetectionUnit: detectionUnit,
  2923. Samplerb: samplerb,
  2924. ReportingDateb: repDate,
  2925. DetectionResultb: detectionResult,
  2926. Ctime: time.Now().Unix(),
  2927. Status: 1,
  2928. UserOrgId: orgid,
  2929. BedId: addmacher.BedId,
  2930. EquitmentId: id,
  2931. Bed: addmacher.BedNumber,
  2932. Sort: sort,
  2933. PassExamination: pass_examination,
  2934. Modifications: modifications,
  2935. }
  2936. err = service.CreateOxygenates(&oxygenates)
  2937. if err != nil {
  2938. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2939. return
  2940. }
  2941. this.ServeSuccessJSON(map[string]interface{}{
  2942. "oxygenates": oxygenates,
  2943. })
  2944. }
  2945. func (this *MachineApiController) SaveHardWater() {
  2946. timeLayout := "2006-01-02"
  2947. loc, _ := time.LoadLocation("Local")
  2948. id, _ := this.GetInt64("id")
  2949. addmacher, _ := service.GetBedId(id)
  2950. adminUserInfo := this.GetAdminUserInfo()
  2951. orgid := adminUserInfo.CurrentOrgId
  2952. dataBody := make(map[string]interface{}, 0)
  2953. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  2954. date := dataBody["sampling_date"].(string)
  2955. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  2956. samp_date := theTime.Unix()
  2957. specimen := int64(dataBody["specimenb"].(float64))
  2958. cona := dataBody["concentrate_noc"].(string)
  2959. conb := dataBody["concentrateb_nod"].(string)
  2960. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  2961. detectionUnit := dataBody["detection_unit"].(string)
  2962. samplerb := int64(dataBody["samplerb"].(float64))
  2963. reportDate := dataBody["reporting_dateb"].(string)
  2964. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  2965. repDate := reportTime.Unix()
  2966. detectionResult := dataBody["detection_resultb"].(string)
  2967. sort := dataBody["sort"].(string)
  2968. modifications := int64(dataBody["modifications"].(float64))
  2969. examination := dataBody["pass_examination"].(string)
  2970. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  2971. hadwater := models.XtDeviceHadwater{
  2972. SamplingDate: samp_date,
  2973. Specimenb: specimen,
  2974. ConcentrateNoc: cona,
  2975. ConcentratebNod: conb,
  2976. SamplingLocationb: samplinglocationb,
  2977. DetectionUnit: detectionUnit,
  2978. Samplerb: samplerb,
  2979. ReportingDateb: repDate,
  2980. DetectionResultb: detectionResult,
  2981. Ctime: time.Now().Unix(),
  2982. Status: 1,
  2983. UserOrgId: orgid,
  2984. BedId: addmacher.BedId,
  2985. EquitmentId: id,
  2986. Bed: addmacher.BedNumber,
  2987. Sort: sort,
  2988. PassExamination: pass_examination,
  2989. Modifications: modifications,
  2990. }
  2991. err = service.CreateHadWater(&hadwater)
  2992. if err != nil {
  2993. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  2994. return
  2995. }
  2996. this.ServeSuccessJSON(map[string]interface{}{
  2997. "hadwater": hadwater,
  2998. })
  2999. }
  3000. func (this *MachineApiController) SaveWater() {
  3001. timeLayout := "2006-01-02"
  3002. loc, _ := time.LoadLocation("Local")
  3003. id, _ := this.GetInt64("id")
  3004. addmacher, _ := service.GetBedId(id)
  3005. adminUserInfo := this.GetAdminUserInfo()
  3006. orgid := adminUserInfo.CurrentOrgId
  3007. dataBody := make(map[string]interface{}, 0)
  3008. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3009. date := dataBody["sampling_date"].(string)
  3010. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  3011. samp_date := theTime.Unix()
  3012. specimen := int64(dataBody["specimenb"].(float64))
  3013. cona := dataBody["concentrate_noc"].(string)
  3014. conb := dataBody["concentrateb_nod"].(string)
  3015. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3016. detectionUnit := dataBody["detection_unit"].(string)
  3017. samplerb := int64(dataBody["samplerb"].(float64))
  3018. reportDate := dataBody["reporting_dateb"].(string)
  3019. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  3020. repDate := reportTime.Unix()
  3021. detectionResult := dataBody["detection_resultb"].(string)
  3022. sort := dataBody["sort"].(string)
  3023. modifications := int64(dataBody["modifications"].(float64))
  3024. examination := dataBody["pass_examination"].(string)
  3025. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  3026. deviceWater := models.XtDeviceWater{
  3027. SamplingDate: samp_date,
  3028. Specimenb: specimen,
  3029. ConcentrateNoc: cona,
  3030. ConcentratebNod: conb,
  3031. SamplingLocationb: samplinglocationb,
  3032. DetectionUnit: detectionUnit,
  3033. Samplerb: samplerb,
  3034. ReportingDateb: repDate,
  3035. DetectionResultb: detectionResult,
  3036. Ctime: time.Now().Unix(),
  3037. Status: 1,
  3038. UserOrgId: orgid,
  3039. BedId: addmacher.BedId,
  3040. EquitmentId: id,
  3041. Bed: addmacher.BedNumber,
  3042. Sort: sort,
  3043. PassExamination: pass_examination,
  3044. Modifications: modifications,
  3045. }
  3046. err = service.CreateWater(&deviceWater)
  3047. if err != nil {
  3048. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3049. return
  3050. }
  3051. this.ServeSuccessJSON(map[string]interface{}{
  3052. "deviceWater": deviceWater,
  3053. })
  3054. }
  3055. func (this *MachineApiController) SaveDevicePH() {
  3056. timeLayout := "2006-01-02"
  3057. loc, _ := time.LoadLocation("Local")
  3058. id, _ := this.GetInt64("id")
  3059. addmacher, _ := service.GetBedId(id)
  3060. adminUserInfo := this.GetAdminUserInfo()
  3061. orgid := adminUserInfo.CurrentOrgId
  3062. dataBody := make(map[string]interface{}, 0)
  3063. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3064. date := dataBody["sampling_date"].(string)
  3065. theTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", date+" 00:00:00", loc)
  3066. samp_date := theTime.Unix()
  3067. specimen := int64(dataBody["specimenb"].(float64))
  3068. cona := dataBody["concentrate_noc"].(string)
  3069. conb := dataBody["concentrateb_nod"].(string)
  3070. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3071. detectionUnit := dataBody["detection_unit"].(string)
  3072. samplerb := int64(dataBody["samplerb"].(float64))
  3073. reportDate := dataBody["reporting_dateb"].(string)
  3074. reportTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDate+" 00:00:00", loc)
  3075. repDate := reportTime.Unix()
  3076. detectionResult := dataBody["detection_resultb"].(string)
  3077. sort := dataBody["sort"].(string)
  3078. modifications := int64(dataBody["modifications"].(float64))
  3079. examination := dataBody["pass_examination"].(string)
  3080. pass_examination, _ := strconv.ParseInt(examination, 10, 64)
  3081. devicePh := models.XtDevicePh{
  3082. SamplingDate: samp_date,
  3083. Specimenb: specimen,
  3084. ConcentrateNoc: cona,
  3085. ConcentratebNod: conb,
  3086. SamplingLocationb: samplinglocationb,
  3087. DetectionUnit: detectionUnit,
  3088. Samplerb: samplerb,
  3089. ReportingDateb: repDate,
  3090. DetectionResultb: detectionResult,
  3091. Ctime: time.Now().Unix(),
  3092. Status: 1,
  3093. UserOrgId: orgid,
  3094. BedId: addmacher.BedId,
  3095. EquitmentId: id,
  3096. Bed: addmacher.BedNumber,
  3097. Sort: sort,
  3098. PassExamination: pass_examination,
  3099. Modifications: modifications,
  3100. }
  3101. err = service.CreateDevicePh(&devicePh)
  3102. if err != nil {
  3103. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3104. return
  3105. }
  3106. this.ServeSuccessJSON(map[string]interface{}{
  3107. "devicePh": devicePh,
  3108. })
  3109. }
  3110. func (this *MachineApiController) EditOxygenates() {
  3111. id, _ := this.GetInt64("id")
  3112. oxygenates, err := service.GetOxygenatesById(id)
  3113. if err != nil {
  3114. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3115. return
  3116. }
  3117. this.ServeSuccessJSON(map[string]interface{}{
  3118. "oxygenates": oxygenates,
  3119. })
  3120. }
  3121. func (this *MachineApiController) UpdateOxygenates() {
  3122. timeLayout := "2006-01-02"
  3123. loc, _ := time.LoadLocation("Local")
  3124. dataBody := make(map[string]interface{}, 0)
  3125. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3126. fmt.Println("err", err)
  3127. id := int64(dataBody["id"].(float64))
  3128. fmt.Println("id", id)
  3129. samplingDate := dataBody["sampling_date"].(string)
  3130. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3131. samp_date := sampdate.Unix()
  3132. specimentb := int64(dataBody["specimenb"].(float64))
  3133. concentratec := dataBody["concentrate_noc"].(string)
  3134. concentraeb := dataBody["concentrateb_nod"].(string)
  3135. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3136. samplerb := int64(dataBody["samplerb"].(float64))
  3137. reportDateb := dataBody["reporting_dateb"].(string)
  3138. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3139. report_date := location.Unix()
  3140. detectionResultb := dataBody["detection_resultb"].(string)
  3141. detectionUnit := dataBody["detection_unit"].(string)
  3142. sort := dataBody["sort"].(string)
  3143. pass_examination := int64(dataBody["pass_examination"].(float64))
  3144. modifications := int64(dataBody["modifications"].(float64))
  3145. adminUserInfo := this.GetAdminUserInfo()
  3146. orgId := adminUserInfo.CurrentOrgId
  3147. oxygenates := models.XtDeviceOxygenates{
  3148. SamplingDate: samp_date,
  3149. Specimenb: specimentb,
  3150. ConcentrateNoc: concentratec,
  3151. ConcentratebNod: concentraeb,
  3152. SamplingLocationb: samplinglocationb,
  3153. DetectionUnit: detectionUnit,
  3154. Samplerb: samplerb,
  3155. ReportingDateb: report_date,
  3156. DetectionResultb: detectionResultb,
  3157. Sort: sort,
  3158. PassExamination: pass_examination,
  3159. Modifications: modifications,
  3160. }
  3161. err = service.UpdateOxygenates(id, orgId, &oxygenates)
  3162. if err != nil {
  3163. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3164. return
  3165. }
  3166. this.ServeSuccessJSON(map[string]interface{}{
  3167. "oxygenates": oxygenates,
  3168. })
  3169. }
  3170. func (this *MachineApiController) EditHardWater() {
  3171. id, _ := this.GetInt64("id")
  3172. hardWater, err := service.GetHardWaterById(id)
  3173. if err != nil {
  3174. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3175. return
  3176. }
  3177. this.ServeSuccessJSON(map[string]interface{}{
  3178. "hardWater": hardWater,
  3179. })
  3180. }
  3181. func (this *MachineApiController) EditWater() {
  3182. id, _ := this.GetInt64("id")
  3183. water, err := service.GetWaterById(id)
  3184. if err != nil {
  3185. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3186. return
  3187. }
  3188. this.ServeSuccessJSON(map[string]interface{}{
  3189. "water": water,
  3190. })
  3191. }
  3192. func (this *MachineApiController) EditDevicePh() {
  3193. id, _ := this.GetInt64("id")
  3194. deviceph, err := service.GetDevicePhById(id)
  3195. if err != nil {
  3196. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3197. return
  3198. }
  3199. this.ServeSuccessJSON(map[string]interface{}{
  3200. "deviceph": deviceph,
  3201. })
  3202. }
  3203. func (this *MachineApiController) GetAllDoctorList() {
  3204. adminUserInfo := this.GetAdminUserInfo()
  3205. orgId := adminUserInfo.CurrentOrgId
  3206. appId := this.GetAdminUserInfo().CurrentAppId
  3207. list, err := service.GetAllDoctorTwo(orgId, appId)
  3208. operators, err := service.GetAdminUserEsOne(orgId)
  3209. if err != nil {
  3210. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3211. return
  3212. }
  3213. this.ServeSuccessJSON(map[string]interface{}{
  3214. "list": list,
  3215. "operators": operators,
  3216. })
  3217. }
  3218. func (this *MachineApiController) SaveAirDisinfect() {
  3219. timeLayout := "2006-01-02"
  3220. loc, _ := time.LoadLocation("Local")
  3221. check_out, err := this.GetInt64("check_out")
  3222. class, err := this.GetInt64("class")
  3223. create_time := this.GetString("created_time")
  3224. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3225. creator, err := this.GetInt64("creator")
  3226. detection_result := this.GetString("detection_result")
  3227. detection_time := this.GetString("detection_time")
  3228. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3229. disinfection_fluid := this.GetString("disinfection_fluid")
  3230. disinfection_methods := this.GetString("disinfection_methods")
  3231. modifications, _ := this.GetInt64("modifications")
  3232. sort := this.GetString("sort")
  3233. upload_time := this.GetString("upload_time")
  3234. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3235. start_time := this.GetString("start_time")
  3236. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3237. adminUserInfo := this.GetAdminUserInfo()
  3238. orgId := adminUserInfo.CurrentOrgId
  3239. detection := models.XtAerialDetection{
  3240. CheckOut: check_out,
  3241. Class: class,
  3242. CreatedTime: createTime.Unix(),
  3243. Creator: creator,
  3244. DetectionResult: detection_result,
  3245. DetectionTime: detectionTime.Unix(),
  3246. DisinfectionFluid: disinfection_fluid,
  3247. DisinfectionMethods: disinfection_methods,
  3248. Modifications: modifications,
  3249. Sort: sort,
  3250. UploadTime: uploadTime.Unix(),
  3251. StartTime: startTime.Unix(),
  3252. UserOrgId: orgId,
  3253. Ctime: time.Now().Unix(),
  3254. Status: 1,
  3255. }
  3256. err = service.CreateAerialDetection(&detection)
  3257. if err != nil {
  3258. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3259. return
  3260. }
  3261. this.ServeSuccessJSON(map[string]interface{}{
  3262. "list": detection,
  3263. })
  3264. }
  3265. func (this *MachineApiController) GetAirList() {
  3266. limit, _ := this.GetInt64("limit")
  3267. page, _ := this.GetInt64("page")
  3268. adminUserInfo := this.GetAdminUserInfo()
  3269. orgId := adminUserInfo.CurrentOrgId
  3270. list, total, err := service.GetAirList(limit, page, orgId)
  3271. if err != nil {
  3272. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3273. return
  3274. }
  3275. this.ServeSuccessJSON(map[string]interface{}{
  3276. "list": list,
  3277. "total": total,
  3278. })
  3279. }
  3280. func (this *MachineApiController) GetAirDisinfetDetail() {
  3281. id, _ := this.GetInt64("id")
  3282. detail, err := service.GetAirDisinfectDetail(id)
  3283. if err != nil {
  3284. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3285. return
  3286. }
  3287. this.ServeSuccessJSON(map[string]interface{}{
  3288. "detail": detail,
  3289. })
  3290. }
  3291. func (this *MachineApiController) UpdateAirDisinfect() {
  3292. timeLayout := "2006-01-02"
  3293. loc, _ := time.LoadLocation("Local")
  3294. check_out, err := this.GetInt64("check_out")
  3295. class, err := this.GetInt64("class")
  3296. create_time := this.GetString("created_time")
  3297. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3298. creator, err := this.GetInt64("creator")
  3299. detection_result := this.GetString("detection_result")
  3300. detection_time := this.GetString("detection_time")
  3301. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3302. disinfection_fluid := this.GetString("disinfection_fluid")
  3303. disinfection_methods := this.GetString("disinfection_methods")
  3304. modifications, _ := this.GetInt64("modifications")
  3305. sort := this.GetString("sort")
  3306. upload_time := this.GetString("upload_time")
  3307. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3308. start_time := this.GetString("start_time")
  3309. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3310. id, _ := this.GetInt64("id")
  3311. adminUserInfo := this.GetAdminUserInfo()
  3312. orgId := adminUserInfo.CurrentOrgId
  3313. detection := models.XtAerialDetection{
  3314. CheckOut: check_out,
  3315. Class: class,
  3316. CreatedTime: createTime.Unix(),
  3317. Creator: creator,
  3318. DetectionResult: detection_result,
  3319. DetectionTime: detectionTime.Unix(),
  3320. DisinfectionFluid: disinfection_fluid,
  3321. DisinfectionMethods: disinfection_methods,
  3322. Modifications: modifications,
  3323. Sort: sort,
  3324. UploadTime: uploadTime.Unix(),
  3325. StartTime: startTime.Unix(),
  3326. UserOrgId: orgId,
  3327. Ctime: time.Now().Unix(),
  3328. Status: 1,
  3329. }
  3330. err = service.UpdateAeriaDetection(&detection, id)
  3331. if err != nil {
  3332. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3333. return
  3334. }
  3335. this.ServeSuccessJSON(map[string]interface{}{
  3336. "detection": detection,
  3337. })
  3338. }
  3339. func (this *MachineApiController) DeleteAirDisinfect() {
  3340. id, _ := this.GetInt64("id")
  3341. err := service.DeleteAirDisinfect(id)
  3342. fmt.Println(err)
  3343. returnData := make(map[string]interface{}, 0)
  3344. returnData["msg"] = "ok"
  3345. this.ServeSuccessJSON(returnData)
  3346. return
  3347. }
  3348. func (this *MachineApiController) SaveBodyDisinfect() {
  3349. timeLayout := "2006-01-02"
  3350. loc, _ := time.LoadLocation("Local")
  3351. check_out, err := this.GetInt64("check_out")
  3352. class, err := this.GetInt64("class")
  3353. create_time := this.GetString("created_time")
  3354. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3355. creator, err := this.GetInt64("creator")
  3356. detection_result := this.GetString("detection_result")
  3357. detection_time := this.GetString("detection_time")
  3358. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3359. disinfection_fluid := this.GetString("disinfection_fluid")
  3360. disinfection_methods := this.GetString("disinfection_methods")
  3361. modifications, _ := this.GetInt64("modifications")
  3362. sort := this.GetString("sort")
  3363. upload_time := this.GetString("upload_time")
  3364. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3365. start_time := this.GetString("start_time")
  3366. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3367. adminUserInfo := this.GetAdminUserInfo()
  3368. orgId := adminUserInfo.CurrentOrgId
  3369. detection := models.XtBodyDetection{
  3370. CheckOut: check_out,
  3371. Class: class,
  3372. CreatedTime: createTime.Unix(),
  3373. Creator: creator,
  3374. DetectionResult: detection_result,
  3375. DetectionTime: detectionTime.Unix(),
  3376. DisinfectionFluid: disinfection_fluid,
  3377. DisinfectionMethods: disinfection_methods,
  3378. Modifications: modifications,
  3379. Sort: sort,
  3380. UploadTime: uploadTime.Unix(),
  3381. StartTime: startTime.Unix(),
  3382. UserOrgId: orgId,
  3383. Ctime: time.Now().Unix(),
  3384. Status: 1,
  3385. }
  3386. err = service.SaveBodyDetection(&detection)
  3387. if err != nil {
  3388. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3389. return
  3390. }
  3391. this.ServeSuccessJSON(map[string]interface{}{
  3392. "detection": detection,
  3393. })
  3394. }
  3395. func (this *MachineApiController) GetBodyList() {
  3396. limit, _ := this.GetInt64("limit")
  3397. page, _ := this.GetInt64("page")
  3398. adminUserInfo := this.GetAdminUserInfo()
  3399. orgId := adminUserInfo.CurrentOrgId
  3400. list, total, err := service.GetBodyList(limit, page, orgId)
  3401. if err != nil {
  3402. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3403. return
  3404. }
  3405. this.ServeSuccessJSON(map[string]interface{}{
  3406. "list": list,
  3407. "total": total,
  3408. })
  3409. }
  3410. func (this *MachineApiController) GetBodyDisinfetDetail() {
  3411. id, _ := this.GetInt64("id")
  3412. detail, err := service.GetBodyDisinfectDetail(id)
  3413. if err != nil {
  3414. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3415. return
  3416. }
  3417. this.ServeSuccessJSON(map[string]interface{}{
  3418. "detail": detail,
  3419. })
  3420. }
  3421. func (this *MachineApiController) UpdateBodyDisinfect() {
  3422. timeLayout := "2006-01-02"
  3423. loc, _ := time.LoadLocation("Local")
  3424. check_out, _ := this.GetInt64("check_out")
  3425. class, _ := this.GetInt64("class")
  3426. create_time := this.GetString("created_time")
  3427. createTime, err := time.ParseInLocation(timeLayout+" 15:04:05", create_time+" 00:00:00", loc)
  3428. creator, err := this.GetInt64("creator")
  3429. detection_result := this.GetString("detection_result")
  3430. detection_time := this.GetString("detection_time")
  3431. detectionTime, err := time.ParseInLocation(timeLayout+" 15:04:05", detection_time+" 00:00:00", loc)
  3432. disinfection_fluid := this.GetString("disinfection_fluid")
  3433. disinfection_methods := this.GetString("disinfection_methods")
  3434. modifications, _ := this.GetInt64("modifications")
  3435. sort := this.GetString("sort")
  3436. upload_time := this.GetString("upload_time")
  3437. uploadTime, err := time.ParseInLocation(timeLayout+" 15:04:05", upload_time+" 00:00:00", loc)
  3438. start_time := this.GetString("start_time")
  3439. startTime, _ := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3440. id, _ := this.GetInt64("id")
  3441. adminUserInfo := this.GetAdminUserInfo()
  3442. orgId := adminUserInfo.CurrentOrgId
  3443. detection := models.XtBodyDetection{
  3444. CheckOut: check_out,
  3445. Class: class,
  3446. CreatedTime: createTime.Unix(),
  3447. Creator: creator,
  3448. DetectionResult: detection_result,
  3449. DetectionTime: detectionTime.Unix(),
  3450. DisinfectionFluid: disinfection_fluid,
  3451. DisinfectionMethods: disinfection_methods,
  3452. Modifications: modifications,
  3453. Sort: sort,
  3454. UploadTime: uploadTime.Unix(),
  3455. StartTime: startTime.Unix(),
  3456. UserOrgId: orgId,
  3457. Ctime: time.Now().Unix(),
  3458. Status: 1,
  3459. }
  3460. err = service.UpdateBodyDetection(&detection, id)
  3461. if err != nil {
  3462. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3463. return
  3464. }
  3465. this.ServeSuccessJSON(map[string]interface{}{
  3466. "detection": detection,
  3467. })
  3468. }
  3469. func (this *MachineApiController) DeleteBodyDisInfect() {
  3470. id, _ := this.GetInt64("id")
  3471. err := service.DeleteBodyDisInfect(id)
  3472. fmt.Println(err)
  3473. returnData := make(map[string]interface{}, 0)
  3474. returnData["msg"] = "ok"
  3475. this.ServeSuccessJSON(returnData)
  3476. return
  3477. }
  3478. func (this *MachineApiController) UpdateHadWater() {
  3479. timeLayout := "2006-01-02"
  3480. loc, _ := time.LoadLocation("Local")
  3481. dataBody := make(map[string]interface{}, 0)
  3482. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3483. fmt.Println("err", err)
  3484. id := int64(dataBody["id"].(float64))
  3485. fmt.Println("id", id)
  3486. samplingDate := dataBody["sampling_date"].(string)
  3487. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3488. samp_date := sampdate.Unix()
  3489. specimentb := int64(dataBody["specimenb"].(float64))
  3490. concentratec := dataBody["concentrate_noc"].(string)
  3491. concentraeb := dataBody["concentrateb_nod"].(string)
  3492. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3493. samplerb := int64(dataBody["samplerb"].(float64))
  3494. reportDateb := dataBody["reporting_dateb"].(string)
  3495. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3496. report_date := location.Unix()
  3497. detectionResultb := dataBody["detection_resultb"].(string)
  3498. detectionUnit := dataBody["detection_unit"].(string)
  3499. sort := dataBody["sort"].(string)
  3500. pass_examination := int64(dataBody["pass_examination"].(float64))
  3501. modifications := int64(dataBody["modifications"].(float64))
  3502. adminUserInfo := this.GetAdminUserInfo()
  3503. orgId := adminUserInfo.CurrentOrgId
  3504. hadWater := models.XtDeviceHadwater{
  3505. SamplingDate: samp_date,
  3506. Specimenb: specimentb,
  3507. ConcentrateNoc: concentratec,
  3508. ConcentratebNod: concentraeb,
  3509. SamplingLocationb: samplinglocationb,
  3510. DetectionUnit: detectionUnit,
  3511. Samplerb: samplerb,
  3512. ReportingDateb: report_date,
  3513. DetectionResultb: detectionResultb,
  3514. Sort: sort,
  3515. PassExamination: pass_examination,
  3516. Modifications: modifications,
  3517. }
  3518. err = service.UpdateHadWater(id, orgId, &hadWater)
  3519. if err != nil {
  3520. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3521. return
  3522. }
  3523. this.ServeSuccessJSON(map[string]interface{}{
  3524. "hadWater": hadWater,
  3525. })
  3526. }
  3527. func (this *MachineApiController) UpdateWater() {
  3528. timeLayout := "2006-01-02"
  3529. loc, _ := time.LoadLocation("Local")
  3530. dataBody := make(map[string]interface{}, 0)
  3531. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3532. fmt.Println("err", err)
  3533. id := int64(dataBody["id"].(float64))
  3534. fmt.Println("id", id)
  3535. samplingDate := dataBody["sampling_date"].(string)
  3536. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3537. samp_date := sampdate.Unix()
  3538. specimentb := int64(dataBody["specimenb"].(float64))
  3539. concentratec := dataBody["concentrate_noc"].(string)
  3540. concentraeb := dataBody["concentrateb_nod"].(string)
  3541. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3542. samplerb := int64(dataBody["samplerb"].(float64))
  3543. reportDateb := dataBody["reporting_dateb"].(string)
  3544. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3545. report_date := location.Unix()
  3546. detectionResultb := dataBody["detection_resultb"].(string)
  3547. detectionUnit := dataBody["detection_unit"].(string)
  3548. sort := dataBody["sort"].(string)
  3549. pass_examination := int64(dataBody["pass_examination"].(float64))
  3550. modifications := int64(dataBody["modifications"].(float64))
  3551. adminUserInfo := this.GetAdminUserInfo()
  3552. orgId := adminUserInfo.CurrentOrgId
  3553. hadWater := models.XtDeviceWater{
  3554. SamplingDate: samp_date,
  3555. Specimenb: specimentb,
  3556. ConcentrateNoc: concentratec,
  3557. ConcentratebNod: concentraeb,
  3558. SamplingLocationb: samplinglocationb,
  3559. DetectionUnit: detectionUnit,
  3560. Samplerb: samplerb,
  3561. ReportingDateb: report_date,
  3562. DetectionResultb: detectionResultb,
  3563. Sort: sort,
  3564. PassExamination: pass_examination,
  3565. Modifications: modifications,
  3566. }
  3567. err = service.UpdateDeviceWater(id, orgId, &hadWater)
  3568. if err != nil {
  3569. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3570. return
  3571. }
  3572. this.ServeSuccessJSON(map[string]interface{}{
  3573. "hadWater": hadWater,
  3574. })
  3575. }
  3576. func (this *MachineApiController) UpdateDevicePh() {
  3577. timeLayout := "2006-01-02"
  3578. loc, _ := time.LoadLocation("Local")
  3579. dataBody := make(map[string]interface{}, 0)
  3580. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3581. fmt.Println("err", err)
  3582. id := int64(dataBody["id"].(float64))
  3583. fmt.Println("id", id)
  3584. samplingDate := dataBody["sampling_date"].(string)
  3585. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", samplingDate+" 00:00:00", loc)
  3586. samp_date := sampdate.Unix()
  3587. specimentb := int64(dataBody["specimenb"].(float64))
  3588. concentratec := dataBody["concentrate_noc"].(string)
  3589. concentraeb := dataBody["concentrateb_nod"].(string)
  3590. samplinglocationb := int64(dataBody["sampling_locationb"].(float64))
  3591. samplerb := int64(dataBody["samplerb"].(float64))
  3592. reportDateb := dataBody["reporting_dateb"].(string)
  3593. location, _ := time.ParseInLocation(timeLayout+" 15:04:05", reportDateb+" 00:00:00", loc)
  3594. report_date := location.Unix()
  3595. detectionResultb := dataBody["detection_resultb"].(string)
  3596. detectionUnit := dataBody["detection_unit"].(string)
  3597. sort := dataBody["sort"].(string)
  3598. pass_examination := int64(dataBody["pass_examination"].(float64))
  3599. modifications := int64(dataBody["modifications"].(float64))
  3600. adminUserInfo := this.GetAdminUserInfo()
  3601. orgId := adminUserInfo.CurrentOrgId
  3602. hadWater := models.XtDevicePh{
  3603. SamplingDate: samp_date,
  3604. Specimenb: specimentb,
  3605. ConcentrateNoc: concentratec,
  3606. ConcentratebNod: concentraeb,
  3607. SamplingLocationb: samplinglocationb,
  3608. DetectionUnit: detectionUnit,
  3609. Samplerb: samplerb,
  3610. ReportingDateb: report_date,
  3611. DetectionResultb: detectionResultb,
  3612. Sort: sort,
  3613. PassExamination: pass_examination,
  3614. Modifications: modifications,
  3615. }
  3616. err = service.UpdateDivicePh(id, orgId, &hadWater)
  3617. if err != nil {
  3618. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3619. return
  3620. }
  3621. this.ServeSuccessJSON(map[string]interface{}{
  3622. "hadWater": hadWater,
  3623. })
  3624. }
  3625. func (this *MachineApiController) DeleteOxygenates() {
  3626. id, _ := this.GetInt64("id")
  3627. err := service.DeleteOxygenates(id)
  3628. fmt.Println(err)
  3629. returnData := make(map[string]interface{}, 0)
  3630. returnData["msg"] = "ok"
  3631. this.ServeSuccessJSON(returnData)
  3632. return
  3633. }
  3634. func (this *MachineApiController) DeleteHadWater() {
  3635. id, _ := this.GetInt64("id")
  3636. err := service.DeleteHadWater(id)
  3637. fmt.Println(err)
  3638. returnData := make(map[string]interface{}, 0)
  3639. returnData["msg"] = "ok"
  3640. this.ServeSuccessJSON(returnData)
  3641. return
  3642. }
  3643. func (this *MachineApiController) DeleteWater() {
  3644. id, _ := this.GetInt64("id")
  3645. err := service.DeleteWater(id)
  3646. fmt.Println(err)
  3647. returnData := make(map[string]interface{}, 0)
  3648. returnData["msg"] = "ok"
  3649. this.ServeSuccessJSON(returnData)
  3650. return
  3651. }
  3652. func (this *MachineApiController) DeleteDevicePh() {
  3653. id, _ := this.GetInt64("id")
  3654. err := service.DeleteDevicePh(id)
  3655. fmt.Println(err)
  3656. returnData := make(map[string]interface{}, 0)
  3657. returnData["msg"] = "ok"
  3658. this.ServeSuccessJSON(returnData)
  3659. return
  3660. }
  3661. func (this *MachineApiController) SaveWaterList() {
  3662. equitment_id, _ := this.GetInt64("equitment_id")
  3663. timeLayout := "2006-01-02"
  3664. loc, _ := time.LoadLocation("Local")
  3665. dataBody := make(map[string]interface{}, 0)
  3666. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3667. fmt.Println("err", err)
  3668. record_date := dataBody["record_date"].(string)
  3669. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  3670. recorddateunix := sampdate.Unix()
  3671. fmt.Println("日期", recorddateunix)
  3672. machine_status := int64(dataBody["machine_status"].(float64))
  3673. fmt.Println("machine_status", machine_status)
  3674. fault_description := dataBody["fault_description"].(string)
  3675. water_conductivity := dataBody["water_conductivity"].(float64)
  3676. water_pressure := dataBody["water_pressure"].(float64)
  3677. temperature := dataBody["temperature"].(float64)
  3678. force_pump_status := int64(dataBody["force_pump_status"].(float64))
  3679. first_ro_membrane_water := dataBody["first_ro_membrane_water"].(float64)
  3680. first_ro_film_thick_water := dataBody["first_ro_film_thick_water"].(float64)
  3681. first_ro_membrane_effluent := dataBody["first_ro_membrane_effluent"].(float64)
  3682. first_production_of_water_conductivity := dataBody["first_production_of_water_conductivity"].(float64)
  3683. first_water_yield := dataBody["first_water_yield"].(float64)
  3684. last_ro_membrane_water := dataBody["last_ro_membrane_water"].(float64)
  3685. last_ro_membrane_effluent := dataBody["last_ro_membrane_effluent"].(float64)
  3686. last_ro_film_thick_water := dataBody["last_ro_film_thick_water"].(float64)
  3687. last_production_of_water_conductivity := dataBody["last_production_of_water_conductivity"].(float64)
  3688. last_water_yield := dataBody["last_water_yield"].(float64)
  3689. carbon_tank := dataBody["carbon_tank"].(float64)
  3690. snd_tank := dataBody["snd_tank"].(float64)
  3691. resin_tank := dataBody["resin_tank"].(float64)
  3692. ultrafilter := dataBody["ultrafilter"].(float64)
  3693. hardness_monitoring := dataBody["hardness_monitoring"].(float64)
  3694. total_chlorine_detection := dataBody["total_chlorine_detection"].(float64)
  3695. ph_detection := dataBody["ph_detection"].(float64)
  3696. concentration_of_peroxyacetic_acid := dataBody["concentration_of_peroxyacetic_acid"].(float64)
  3697. reverse_osmosis_membrane_disinfection := int64(dataBody["reverse_osmosis_membrane_disinfection"].(float64))
  3698. first_disinfection_method := int64(dataBody["first_disinfection_method"].(float64))
  3699. last_disinfection_method := int64(dataBody["last_disinfection_method"].(float64))
  3700. first_disinfection_time := dataBody["first_disinfection_time"].(float64)
  3701. last_disinfection_time := dataBody["last_disinfection_time"].(float64)
  3702. remark := dataBody["remark"].(string)
  3703. filter_replacement := int64(dataBody["filter_replacement"].(float64))
  3704. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  3705. disinfection_of_water_pipeline := int64(dataBody["disinfection_of_water_pipeline"].(float64))
  3706. orgId := this.GetAdminUserInfo().CurrentOrgId
  3707. deviceWater := models.XtDialysisDeviceWater{
  3708. UserOrgId: orgId,
  3709. EquimentId: equitment_id,
  3710. RecordDate: recorddateunix,
  3711. MachineStatus: machine_status,
  3712. FaultDescription: fault_description,
  3713. WaterConductivity: water_conductivity,
  3714. WaterPressure: water_pressure,
  3715. Temperature: temperature,
  3716. ForcePumpStatus: force_pump_status,
  3717. FirstRoMembraneWater: first_ro_membrane_water,
  3718. FirstRoFilmThickWater: first_ro_film_thick_water,
  3719. FirstRoMembraneEffluent: first_ro_membrane_effluent,
  3720. FirstProductionOfWaterConductivity: first_production_of_water_conductivity,
  3721. FirstWaterYield: first_water_yield,
  3722. LastRoMembraneWater: last_ro_membrane_water,
  3723. LastRoFilmThickWater: last_ro_film_thick_water,
  3724. LastRoMembraneEffluent: last_ro_membrane_effluent,
  3725. LastProductionOfWaterConductivity: last_production_of_water_conductivity,
  3726. LastWaterYield: last_water_yield,
  3727. CarbonTank: carbon_tank,
  3728. SndTank: snd_tank,
  3729. ResinTank: resin_tank,
  3730. Ultrafilter: ultrafilter,
  3731. HardnessMonitoring: hardness_monitoring,
  3732. TotalChlorineDetection: total_chlorine_detection,
  3733. ConcentrationOfPeroxyaceticAcid: concentration_of_peroxyacetic_acid,
  3734. ReverseOsmosisMembraneDisinfection: reverse_osmosis_membrane_disinfection,
  3735. FirstDisinfectionMethod: first_disinfection_method,
  3736. LastDisinfectionMethod: last_disinfection_method,
  3737. FirstDisinfectionTime: first_disinfection_time,
  3738. LastDisinfectionTime: last_disinfection_time,
  3739. Remark: remark,
  3740. FilterReplacement: filter_replacement,
  3741. AdminUserId: admin_user_id,
  3742. Ctime: time.Now().Unix(),
  3743. Mtime: time.Now().Unix(),
  3744. Status: 1,
  3745. PhDetection: ph_detection,
  3746. DisinfectionOfWaterPipeline: disinfection_of_water_pipeline,
  3747. }
  3748. err = service.CretaDeviceWater(deviceWater)
  3749. if err != nil {
  3750. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3751. return
  3752. }
  3753. this.ServeSuccessJSON(map[string]interface{}{
  3754. "deviceWater": deviceWater,
  3755. })
  3756. }
  3757. func (this *MachineApiController) GetWaterFormList() {
  3758. equitment_id, _ := this.GetInt64("equitment_id")
  3759. timeLayout := "2006-01-02"
  3760. loc, _ := time.LoadLocation("Local")
  3761. start_time := this.GetString("start_time")
  3762. var theStartTIme int64
  3763. if len(start_time) > 0 {
  3764. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  3765. if err != nil {
  3766. utils.ErrorLog(err.Error())
  3767. }
  3768. theStartTIme = theTime.Unix()
  3769. }
  3770. end_time := this.GetString("end_time")
  3771. var theEndTime int64
  3772. if len(end_time) > 0 {
  3773. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 00:00:00", loc)
  3774. if err != nil {
  3775. utils.ErrorLog(err.Error())
  3776. }
  3777. theEndTime = theTime.Unix()
  3778. }
  3779. limit, _ := this.GetInt64("limit")
  3780. page, _ := this.GetInt64("page")
  3781. orgId := this.GetAdminUserInfo().CurrentOrgId
  3782. list, total, err := service.GetWaterFormList(equitment_id, theStartTIme, theEndTime, limit, page, orgId)
  3783. appId := this.GetAdminUserInfo().CurrentAppId
  3784. adminRole, err := service.GetAllDoctorTwo(orgId, appId)
  3785. operators, err := service.GetAdminUserEsOne(orgId)
  3786. if err != nil {
  3787. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3788. return
  3789. }
  3790. this.ServeSuccessJSON(map[string]interface{}{
  3791. "list": list,
  3792. "total": total,
  3793. "adminRole": adminRole,
  3794. "operators": operators,
  3795. })
  3796. }
  3797. func (this *MachineApiController) DeleteDialysisWater() {
  3798. id, _ := this.GetInt64("id")
  3799. err := service.DelelteDialysisWater(id)
  3800. fmt.Println(err)
  3801. returnData := make(map[string]interface{}, 0)
  3802. returnData["msg"] = "ok"
  3803. this.ServeSuccessJSON(returnData)
  3804. return
  3805. }
  3806. func (this *MachineApiController) GetDialysisWaterDetail() {
  3807. id, _ := this.GetInt64("id")
  3808. detail, err := service.GetDialysisWaterDetail(id)
  3809. appId := this.GetAdminUserInfo().CurrentAppId
  3810. orgId := this.GetAdminUserInfo().CurrentOrgId
  3811. adminRole, err := service.GetAllDoctorTwo(orgId, appId)
  3812. if err != nil {
  3813. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3814. return
  3815. }
  3816. this.ServeSuccessJSON(map[string]interface{}{
  3817. "detail": detail,
  3818. "adminRole": adminRole,
  3819. })
  3820. }
  3821. func (this *MachineApiController) UpdateDialysisWater() {
  3822. equitment_id, _ := this.GetInt64("equitment_id")
  3823. timeLayout := "2006-01-02"
  3824. loc, _ := time.LoadLocation("Local")
  3825. dataBody := make(map[string]interface{}, 0)
  3826. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3827. fmt.Println("err", err)
  3828. id := int64(dataBody["id"].(float64))
  3829. record_date := dataBody["record_date"].(string)
  3830. sampdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  3831. recorddateunix := sampdate.Unix()
  3832. fmt.Println("日期", recorddateunix)
  3833. machine_status := int64(dataBody["machine_status"].(float64))
  3834. fmt.Println("machine_status", machine_status)
  3835. fault_description := dataBody["fault_description"].(string)
  3836. water_conductivity := dataBody["water_conductivity"].(float64)
  3837. water_pressure := dataBody["water_pressure"].(float64)
  3838. temperature := dataBody["temperature"].(float64)
  3839. force_pump_status := int64(dataBody["force_pump_status"].(float64))
  3840. first_ro_membrane_water := dataBody["first_ro_membrane_water"].(float64)
  3841. first_ro_film_thick_water := dataBody["first_ro_film_thick_water"].(float64)
  3842. first_ro_membrane_effluent := dataBody["first_ro_membrane_effluent"].(float64)
  3843. first_production_of_water_conductivity := dataBody["first_production_of_water_conductivity"].(float64)
  3844. first_water_yield := dataBody["first_water_yield"].(float64)
  3845. last_ro_membrane_water := dataBody["last_ro_membrane_water"].(float64)
  3846. last_ro_membrane_effluent := dataBody["last_ro_membrane_effluent"].(float64)
  3847. last_ro_film_thick_water := dataBody["last_ro_film_thick_water"].(float64)
  3848. last_production_of_water_conductivity := dataBody["last_production_of_water_conductivity"].(float64)
  3849. last_water_yield := dataBody["last_water_yield"].(float64)
  3850. carbon_tank := dataBody["carbon_tank"].(float64)
  3851. snd_tank := dataBody["snd_tank"].(float64)
  3852. resin_tank := dataBody["resin_tank"].(float64)
  3853. ultrafilter := dataBody["ultrafilter"].(float64)
  3854. hardness_monitoring := dataBody["hardness_monitoring"].(float64)
  3855. total_chlorine_detection := dataBody["total_chlorine_detection"].(float64)
  3856. ph_detection := dataBody["ph_detection"].(float64)
  3857. concentration_of_peroxyacetic_acid := dataBody["concentration_of_peroxyacetic_acid"].(float64)
  3858. reverse_osmosis_membrane_disinfection := int64(dataBody["reverse_osmosis_membrane_disinfection"].(float64))
  3859. first_disinfection_method := int64(dataBody["first_disinfection_method"].(float64))
  3860. last_disinfection_method := int64(dataBody["last_disinfection_method"].(float64))
  3861. first_disinfection_time := dataBody["first_disinfection_time"].(float64)
  3862. last_disinfection_time := dataBody["last_disinfection_time"].(float64)
  3863. remark := dataBody["remark"].(string)
  3864. filter_replacement := int64(dataBody["filter_replacement"].(float64))
  3865. admin_user_id := int64(dataBody["admin_user_id"].(float64))
  3866. disinfection_of_water_pipeline := int64(dataBody["disinfection_of_water_pipeline"].(float64))
  3867. orgId := this.GetAdminUserInfo().CurrentOrgId
  3868. deviceWater := models.XtDialysisDeviceWater{
  3869. ID: id,
  3870. UserOrgId: orgId,
  3871. EquimentId: equitment_id,
  3872. RecordDate: recorddateunix,
  3873. MachineStatus: machine_status,
  3874. FaultDescription: fault_description,
  3875. WaterConductivity: water_conductivity,
  3876. WaterPressure: water_pressure,
  3877. Temperature: temperature,
  3878. ForcePumpStatus: force_pump_status,
  3879. FirstRoMembraneWater: first_ro_membrane_water,
  3880. FirstRoFilmThickWater: first_ro_film_thick_water,
  3881. FirstRoMembraneEffluent: first_ro_membrane_effluent,
  3882. FirstProductionOfWaterConductivity: first_production_of_water_conductivity,
  3883. FirstWaterYield: first_water_yield,
  3884. LastRoMembraneWater: last_ro_membrane_water,
  3885. LastRoFilmThickWater: last_ro_film_thick_water,
  3886. LastRoMembraneEffluent: last_ro_membrane_effluent,
  3887. LastProductionOfWaterConductivity: last_production_of_water_conductivity,
  3888. LastWaterYield: last_water_yield,
  3889. CarbonTank: carbon_tank,
  3890. SndTank: snd_tank,
  3891. ResinTank: resin_tank,
  3892. Ultrafilter: ultrafilter,
  3893. HardnessMonitoring: hardness_monitoring,
  3894. TotalChlorineDetection: total_chlorine_detection,
  3895. ConcentrationOfPeroxyaceticAcid: concentration_of_peroxyacetic_acid,
  3896. ReverseOsmosisMembraneDisinfection: reverse_osmosis_membrane_disinfection,
  3897. FirstDisinfectionMethod: first_disinfection_method,
  3898. LastDisinfectionMethod: last_disinfection_method,
  3899. FirstDisinfectionTime: first_disinfection_time,
  3900. LastDisinfectionTime: last_disinfection_time,
  3901. Remark: remark,
  3902. FilterReplacement: filter_replacement,
  3903. AdminUserId: admin_user_id,
  3904. Ctime: time.Now().Unix(),
  3905. Mtime: time.Now().Unix(),
  3906. Status: 1,
  3907. PhDetection: ph_detection,
  3908. DisinfectionOfWaterPipeline: disinfection_of_water_pipeline,
  3909. }
  3910. err = service.SaveDeviceWater(deviceWater)
  3911. if err != nil {
  3912. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3913. return
  3914. }
  3915. this.ServeSuccessJSON(map[string]interface{}{
  3916. "deviceWater": deviceWater,
  3917. })
  3918. }
  3919. func (this *MachineApiController) DeleteBatchDialysisWater() {
  3920. adminUserInfo := this.GetAdminUserInfo()
  3921. OrgID := adminUserInfo.CurrentOrgId
  3922. dataBody := make(map[string]interface{}, 0)
  3923. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3924. if err != nil {
  3925. utils.ErrorLog(err.Error())
  3926. this.ServeFailJsonSend(enums.ErrorCodeParamWrong, "参数错误")
  3927. return
  3928. }
  3929. idsInters := dataBody["ids"].([]interface{})
  3930. if len(idsInters) == 0 {
  3931. if err != nil {
  3932. this.ServeFailJsonSend(enums.ErrorCodeDBDelete, "删除失败")
  3933. return
  3934. }
  3935. }
  3936. ids := make([]int64, 0)
  3937. for _, idsInter := range idsInters {
  3938. id := int64(idsInter.(float64))
  3939. ids = append(ids, id)
  3940. }
  3941. fmt.Println("ids", ids)
  3942. err = service.DeleteBatchDialysisWater(OrgID, ids)
  3943. if err != nil {
  3944. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  3945. return
  3946. }
  3947. returnData := make(map[string]interface{}, 0)
  3948. returnData["msg"] = "ok"
  3949. this.ServeSuccessJSON(returnData)
  3950. return
  3951. }
  3952. func (this *MachineApiController) SaveNewAirDisInfect() {
  3953. timeLayout := "2006-01-02"
  3954. loc, _ := time.LoadLocation("Local")
  3955. dataBody := make(map[string]interface{}, 0)
  3956. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  3957. fmt.Println("err", err)
  3958. record_date := dataBody["record_date"].(string)
  3959. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  3960. recorddateunix := recorddate.Unix()
  3961. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  3962. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  3963. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  3964. first_start_time := dataBody["first_start_time"].(string)
  3965. if len(first_start_time) == 0 {
  3966. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3967. return
  3968. }
  3969. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  3970. first_end_time := dataBody["first_end_time"].(string)
  3971. if len(first_end_time) == 0 {
  3972. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3973. return
  3974. }
  3975. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  3976. first_total_time := dataBody["first_total_time"].(string)
  3977. first_is_check := int64(dataBody["first_is_check"].(float64))
  3978. first_modifications := int64(dataBody["first_modifications"].(float64))
  3979. first_creator := int64(dataBody["first_creator"].(float64))
  3980. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  3981. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  3982. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  3983. sencond_start_time := dataBody["sencond_start_time"].(string)
  3984. if len(sencond_start_time) == 0 {
  3985. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3986. return
  3987. }
  3988. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  3989. sencond_end_time := dataBody["sencond_end_time"].(string)
  3990. if len(sencond_end_time) == 0 {
  3991. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  3992. return
  3993. }
  3994. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  3995. sencond_total_time := dataBody["sencond_total_time"].(string)
  3996. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  3997. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  3998. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  3999. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4000. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4001. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4002. third_start_time := dataBody["third_start_time"].(string)
  4003. if len(third_start_time) == 0 {
  4004. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4005. return
  4006. }
  4007. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4008. third_end_time := dataBody["third_end_time"].(string)
  4009. if len(third_end_time) == 0 {
  4010. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4011. return
  4012. }
  4013. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4014. third_total_time := dataBody["third_total_time"].(string)
  4015. third_is_check := int64(dataBody["third_is_check"].(float64))
  4016. third_modifications := int64(dataBody["third_modifications"].(float64))
  4017. third_creator := int64(dataBody["third_creator"].(float64))
  4018. last_start_time := dataBody["last_start_time"].(string)
  4019. if len(last_start_time) == 0 {
  4020. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4021. return
  4022. }
  4023. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4024. last_end_time := dataBody["last_end_time"].(string)
  4025. if len(last_end_time) == 0 {
  4026. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4027. return
  4028. }
  4029. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4030. last_total_time := dataBody["last_total_time"].(string)
  4031. last_is_check := int64(dataBody["last_is_check"].(float64))
  4032. last_modifications := int64(dataBody["last_modifications"].(float64))
  4033. last_creator := int64(dataBody["last_creator"].(float64))
  4034. storey := dataBody["storey"].(string)
  4035. orgId := this.GetAdminUserInfo().CurrentOrgId
  4036. disinfect := models.XtNewAriDisinfect{
  4037. UserOrgId: orgId,
  4038. RecordDate: recorddateunix,
  4039. FirstDisinfectionWater: first_disinfection_water,
  4040. FirstDisinfectionMethods: first_disinfection_methods,
  4041. FirstDisinfectionTime: first_disinfection_time,
  4042. FirstStartTime: firstStartTime.Unix(),
  4043. FirstEndTime: firstEndTime.Unix(),
  4044. FirstTotalTime: first_total_time,
  4045. FirstIsCheck: first_is_check,
  4046. FirstModifications: first_modifications,
  4047. FirstCreator: first_creator,
  4048. SencondDisinfectionWater: sencond_disinfection_water,
  4049. SencondDisinfectionMethods: sencond_disinfection_methods,
  4050. SencondDisinfectionTime: sencond_disinfection_time,
  4051. SencondStartTime: sencondStartTime.Unix(),
  4052. SencondEndTime: sencondEndTime.Unix(),
  4053. SencondTotalTime: sencond_total_time,
  4054. SencondIsCheck: sencond_is_check,
  4055. SencondModifications: sencond_modifications,
  4056. SencondCreator: sencond_creator,
  4057. ThirdDisinfectionWater: third_disinfection_water,
  4058. ThirdDisinfectionMethods: third_disinfection_methods,
  4059. ThirdDisinfectionTime: third_disinfection_time,
  4060. ThirdStartTime: thirdStartTime.Unix(),
  4061. ThirdEndTime: thirdEndTime.Unix(),
  4062. ThirdTotalTime: third_total_time,
  4063. ThirdIsCheck: third_is_check,
  4064. ThirdModifications: third_modifications,
  4065. ThirdCreator: third_creator,
  4066. LastStartTime: lastStartTime.Unix(),
  4067. LastEndTime: lastEndTime.Unix(),
  4068. LastTotalTime: last_total_time,
  4069. LastIsCheck: last_is_check,
  4070. LastModifications: last_modifications,
  4071. LastCreator: last_creator,
  4072. Ctime: time.Now().Unix(),
  4073. Mtime: time.Now().Unix(),
  4074. Status: 1,
  4075. Storey: storey,
  4076. }
  4077. err = service.CreateNewAirDisinfect(disinfect)
  4078. if err != nil {
  4079. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4080. return
  4081. }
  4082. this.ServeSuccessJSON(map[string]interface{}{
  4083. "disinfect": disinfect,
  4084. })
  4085. }
  4086. func (this *MachineApiController) GetNewAirDisinfectList() {
  4087. timeLayout := "2006-01-02"
  4088. loc, _ := time.LoadLocation("Local")
  4089. start_time := this.GetString("start_time")
  4090. end_time := this.GetString("end_time")
  4091. limit, _ := this.GetInt64("limit")
  4092. page, _ := this.GetInt64("page")
  4093. storey := this.GetString("storey")
  4094. var startTime int64
  4095. if len(start_time) > 0 {
  4096. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4097. if err != nil {
  4098. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4099. return
  4100. }
  4101. startTime = theTime.Unix()
  4102. }
  4103. var endTime int64
  4104. if len(end_time) > 0 {
  4105. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4106. if err != nil {
  4107. utils.ErrorLog(err.Error())
  4108. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4109. return
  4110. }
  4111. endTime = theTime.Unix()
  4112. }
  4113. orgId := this.GetAdminUserInfo().CurrentOrgId
  4114. list, total, err := service.GetNewAirDisinfectList(limit, page, startTime, endTime, orgId, storey)
  4115. if err != nil {
  4116. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4117. return
  4118. }
  4119. this.ServeSuccessJSON(map[string]interface{}{
  4120. "list": list,
  4121. "total": total,
  4122. })
  4123. }
  4124. func (this *MachineApiController) GetNewAirDisinfectByIdList() {
  4125. id, _ := this.GetInt64("id")
  4126. list, err := service.GetNewAirDisinfectByIdList(id)
  4127. if err != nil {
  4128. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4129. return
  4130. }
  4131. this.ServeSuccessJSON(map[string]interface{}{
  4132. "list": list,
  4133. })
  4134. }
  4135. func (this *MachineApiController) UpdateNewAirDisInfect() {
  4136. timeLayout := "2006-01-02"
  4137. loc, _ := time.LoadLocation("Local")
  4138. dataBody := make(map[string]interface{}, 0)
  4139. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4140. fmt.Println("err", err)
  4141. id := int64(dataBody["id"].(float64))
  4142. record_date := dataBody["record_date"].(string)
  4143. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4144. recorddateunix := recorddate.Unix()
  4145. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  4146. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  4147. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  4148. first_start_time := dataBody["first_start_time"].(string)
  4149. if len(first_start_time) == 0 {
  4150. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4151. return
  4152. }
  4153. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  4154. first_end_time := dataBody["first_end_time"].(string)
  4155. if len(first_end_time) == 0 {
  4156. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4157. return
  4158. }
  4159. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  4160. first_total_time := dataBody["first_total_time"].(string)
  4161. first_is_check := int64(dataBody["first_is_check"].(float64))
  4162. first_modifications := int64(dataBody["first_modifications"].(float64))
  4163. first_creator := int64(dataBody["first_creator"].(float64))
  4164. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  4165. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  4166. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  4167. sencond_start_time := dataBody["sencond_start_time"].(string)
  4168. if len(sencond_start_time) == 0 {
  4169. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4170. return
  4171. }
  4172. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  4173. sencond_end_time := dataBody["sencond_end_time"].(string)
  4174. if len(sencond_end_time) == 0 {
  4175. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4176. return
  4177. }
  4178. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  4179. sencond_total_time := dataBody["sencond_total_time"].(string)
  4180. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  4181. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  4182. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  4183. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4184. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4185. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4186. third_start_time := dataBody["third_start_time"].(string)
  4187. if len(third_start_time) == 0 {
  4188. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4189. return
  4190. }
  4191. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4192. third_end_time := dataBody["third_end_time"].(string)
  4193. if len(third_end_time) == 0 {
  4194. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4195. return
  4196. }
  4197. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4198. third_total_time := dataBody["third_total_time"].(string)
  4199. third_is_check := int64(dataBody["third_is_check"].(float64))
  4200. third_modifications := int64(dataBody["third_modifications"].(float64))
  4201. third_creator := int64(dataBody["third_creator"].(float64))
  4202. last_start_time := dataBody["last_start_time"].(string)
  4203. if len(last_start_time) == 0 {
  4204. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4205. return
  4206. }
  4207. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4208. last_end_time := dataBody["last_end_time"].(string)
  4209. if len(last_end_time) == 0 {
  4210. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4211. return
  4212. }
  4213. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4214. last_total_time := dataBody["last_total_time"].(string)
  4215. last_is_check := int64(dataBody["last_is_check"].(float64))
  4216. last_modifications := int64(dataBody["last_modifications"].(float64))
  4217. last_creator := int64(dataBody["last_creator"].(float64))
  4218. storey := dataBody["storey"].(string)
  4219. orgId := this.GetAdminUserInfo().CurrentOrgId
  4220. disinfect := models.XtNewAriDisinfect{
  4221. ID: id,
  4222. UserOrgId: orgId,
  4223. RecordDate: recorddateunix,
  4224. FirstDisinfectionWater: first_disinfection_water,
  4225. FirstDisinfectionMethods: first_disinfection_methods,
  4226. FirstDisinfectionTime: first_disinfection_time,
  4227. FirstStartTime: firstStartTime.Unix(),
  4228. FirstEndTime: firstEndTime.Unix(),
  4229. FirstTotalTime: first_total_time,
  4230. FirstIsCheck: first_is_check,
  4231. FirstModifications: first_modifications,
  4232. FirstCreator: first_creator,
  4233. SencondDisinfectionWater: sencond_disinfection_water,
  4234. SencondDisinfectionMethods: sencond_disinfection_methods,
  4235. SencondDisinfectionTime: sencond_disinfection_time,
  4236. SencondStartTime: sencondStartTime.Unix(),
  4237. SencondEndTime: sencondEndTime.Unix(),
  4238. SencondTotalTime: sencond_total_time,
  4239. SencondIsCheck: sencond_is_check,
  4240. SencondModifications: sencond_modifications,
  4241. SencondCreator: sencond_creator,
  4242. ThirdDisinfectionWater: third_disinfection_water,
  4243. ThirdDisinfectionMethods: third_disinfection_methods,
  4244. ThirdDisinfectionTime: third_disinfection_time,
  4245. ThirdStartTime: thirdStartTime.Unix(),
  4246. ThirdEndTime: thirdEndTime.Unix(),
  4247. ThirdTotalTime: third_total_time,
  4248. ThirdIsCheck: third_is_check,
  4249. ThirdModifications: third_modifications,
  4250. ThirdCreator: third_creator,
  4251. LastStartTime: lastStartTime.Unix(),
  4252. LastEndTime: lastEndTime.Unix(),
  4253. LastTotalTime: last_total_time,
  4254. LastIsCheck: last_is_check,
  4255. LastModifications: last_modifications,
  4256. LastCreator: last_creator,
  4257. Ctime: time.Now().Unix(),
  4258. Mtime: time.Now().Unix(),
  4259. Status: 1,
  4260. Storey: storey,
  4261. }
  4262. err = service.SaveNewAriDisinfect(disinfect)
  4263. if err != nil {
  4264. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4265. return
  4266. }
  4267. this.ServeSuccessJSON(map[string]interface{}{
  4268. "disinfect": disinfect,
  4269. })
  4270. }
  4271. func (this *MachineApiController) DeleteNewAirDisinfect() {
  4272. id, _ := this.GetInt64("id")
  4273. err := service.DeleteNewAirDisInfect(id)
  4274. if err != nil {
  4275. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4276. return
  4277. }
  4278. returnData := make(map[string]interface{}, 0)
  4279. returnData["msg"] = "ok"
  4280. this.ServeSuccessJSON(returnData)
  4281. return
  4282. }
  4283. func (this *MachineApiController) SaveObjTableDisInfect() {
  4284. timeLayout := "2006-01-02"
  4285. loc, _ := time.LoadLocation("Local")
  4286. dataBody := make(map[string]interface{}, 0)
  4287. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4288. fmt.Println("err", err)
  4289. record_date := dataBody["record_date"].(string)
  4290. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4291. recorddateunix := recorddate.Unix()
  4292. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  4293. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  4294. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  4295. first_start_time := dataBody["first_start_time"].(string)
  4296. var firstStartTimeUnix int64
  4297. if len(first_start_time) > 0 {
  4298. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  4299. firstStartTimeUnix = firstStartTime.Unix()
  4300. }
  4301. var firstEndTimeUnix int64
  4302. first_end_time := dataBody["first_end_time"].(string)
  4303. if len(first_end_time) > 0 {
  4304. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  4305. firstEndTimeUnix = firstEndTime.Unix()
  4306. }
  4307. first_total_time := dataBody["first_total_time"].(string)
  4308. first_is_check := int64(dataBody["first_is_check"].(float64))
  4309. first_modifications := int64(dataBody["first_modifications"].(float64))
  4310. first_creator := int64(dataBody["first_creator"].(float64))
  4311. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  4312. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  4313. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  4314. sencond_start_time := dataBody["sencond_start_time"].(string)
  4315. var sencondStartTimeUnixt int64
  4316. if len(sencond_start_time) > 0 {
  4317. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  4318. sencondStartTimeUnixt = sencondStartTime.Unix()
  4319. }
  4320. sencond_end_time := dataBody["sencond_end_time"].(string)
  4321. var sencondEndTimeUnixt int64
  4322. if len(sencond_end_time) > 0 {
  4323. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  4324. sencondEndTimeUnixt = sencondEndTime.Unix()
  4325. }
  4326. sencond_total_time := dataBody["sencond_total_time"].(string)
  4327. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  4328. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  4329. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  4330. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4331. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4332. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4333. third_start_time := dataBody["third_start_time"].(string)
  4334. var thirdStartTimeUnix int64
  4335. if len(third_start_time) > 0 {
  4336. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4337. thirdStartTimeUnix = thirdStartTime.Unix()
  4338. }
  4339. third_end_time := dataBody["third_end_time"].(string)
  4340. var thirdEndTimeUnix int64
  4341. if len(third_end_time) > 0 {
  4342. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4343. thirdEndTimeUnix = thirdEndTime.Unix()
  4344. }
  4345. third_total_time := dataBody["third_total_time"].(string)
  4346. third_is_check := int64(dataBody["third_is_check"].(float64))
  4347. third_modifications := int64(dataBody["third_modifications"].(float64))
  4348. third_creator := int64(dataBody["third_creator"].(float64))
  4349. fourth_disinfection_water := dataBody["fourth_disinfection_water"].(string)
  4350. fourth_disinfection_methods := dataBody["fourth_disinfection_methods"].(string)
  4351. fourth_disinfection_time := dataBody["fourth_disinfection_time"].(string)
  4352. fourth_start_time := dataBody["fourth_start_time"].(string)
  4353. var fourthiStartTimeUnitx int64
  4354. if len(fourth_start_time) > 0 {
  4355. fourthStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_start_time)
  4356. fourthiStartTimeUnitx = fourthStartTime.Unix()
  4357. }
  4358. fourth_end_time := dataBody["fourth_end_time"].(string)
  4359. var fourthEndTimeUnix int64
  4360. if len(fourth_end_time) > 0 {
  4361. fourthEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_end_time)
  4362. fourthEndTimeUnix = fourthEndTime.Unix()
  4363. }
  4364. fourth_total_time := dataBody["fourth_total_time"].(string)
  4365. fourth_is_check := int64(dataBody["fourth_is_check"].(float64))
  4366. fourth_modifications := int64(dataBody["fourth_modifications"].(float64))
  4367. fourth_creator := int64(dataBody["fourth_creator"].(float64))
  4368. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  4369. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  4370. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  4371. last_start_time := dataBody["last_start_time"].(string)
  4372. var lastStartTimeUnix int64
  4373. if len(last_start_time) > 0 {
  4374. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4375. lastStartTimeUnix = lastStartTime.Unix()
  4376. }
  4377. last_end_time := dataBody["last_end_time"].(string)
  4378. var lastEndTimeUnix int64
  4379. if len(last_end_time) > 0 {
  4380. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4381. lastEndTimeUnix = lastEndTime.Unix()
  4382. }
  4383. last_total_time := dataBody["last_total_time"].(string)
  4384. last_is_check := int64(dataBody["last_is_check"].(float64))
  4385. last_modifications := int64(dataBody["last_modifications"].(float64))
  4386. last_creator := int64(dataBody["last_creator"].(float64))
  4387. storey := dataBody["storey"].(string)
  4388. orgId := this.GetAdminUserInfo().CurrentOrgId
  4389. objectDisinfect := models.XtNewObjectDisinfect{
  4390. UserOrgId: orgId,
  4391. RecordDate: recorddateunix,
  4392. FirstDisinfectionWater: first_disinfection_water,
  4393. FirstDisinfectionMethods: first_disinfection_methods,
  4394. FirstDisinfectionTime: first_disinfection_time,
  4395. FirstStartTime: firstStartTimeUnix,
  4396. FirstEndTime: firstEndTimeUnix,
  4397. FirstTotalTime: first_total_time,
  4398. FirstIsCheck: first_is_check,
  4399. FirstModifications: first_modifications,
  4400. FirstCreator: first_creator,
  4401. SencondDisinfectionWater: sencond_disinfection_water,
  4402. SencondDisinfectionMethods: sencond_disinfection_methods,
  4403. SencondDisinfectionTime: sencond_disinfection_time,
  4404. SencondStartTime: sencondStartTimeUnixt,
  4405. SencondEndTime: sencondEndTimeUnixt,
  4406. SencondTotalTime: sencond_total_time,
  4407. SencondIsCheck: sencond_is_check,
  4408. SencondModifications: sencond_modifications,
  4409. SencondCreator: sencond_creator,
  4410. ThirdDisinfectionWater: third_disinfection_water,
  4411. ThirdDisinfectionMethods: third_disinfection_methods,
  4412. ThirdDisinfectionTime: third_disinfection_time,
  4413. ThirdStartTime: thirdStartTimeUnix,
  4414. ThirdEndTime: thirdEndTimeUnix,
  4415. ThirdTotalTime: third_total_time,
  4416. ThirdIsCheck: third_is_check,
  4417. ThirdModifications: third_modifications,
  4418. ThirdCreator: third_creator,
  4419. LastStartTime: lastStartTimeUnix,
  4420. LastEndTime: lastEndTimeUnix,
  4421. LastTotalTime: last_total_time,
  4422. LastIsCheck: last_is_check,
  4423. LastModifications: last_modifications,
  4424. LastCreator: last_creator,
  4425. Ctime: time.Now().Unix(),
  4426. Mtime: 0,
  4427. Status: 1,
  4428. FourthDisinfectionWater: fourth_disinfection_water,
  4429. FourthDisinfectionMethods: fourth_disinfection_methods,
  4430. FourthDisinfectionTime: fourth_disinfection_time,
  4431. FourthStartTime: fourthiStartTimeUnitx,
  4432. FourthEndTime: fourthEndTimeUnix,
  4433. FourthTotalTime: fourth_total_time,
  4434. FourthIsCheck: fourth_is_check,
  4435. FourthModifications: fourth_modifications,
  4436. FourthCreator: fourth_creator,
  4437. LastDisinfectionWater: last_disinfection_water,
  4438. LastDisinfectionMethods: last_disinfection_methods,
  4439. LastDisinfectionTime: last_disinfection_time,
  4440. Storey: storey,
  4441. }
  4442. err = service.CreateObjectDisInfect(objectDisinfect)
  4443. if err != nil {
  4444. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4445. return
  4446. }
  4447. this.ServeSuccessJSON(map[string]interface{}{
  4448. "objectDisinfect": objectDisinfect,
  4449. })
  4450. }
  4451. func (this *MachineApiController) GetObjectTableDisinfectList() {
  4452. timeLayout := "2006-01-02"
  4453. loc, _ := time.LoadLocation("Local")
  4454. start_time := this.GetString("start_time")
  4455. end_time := this.GetString("end_time")
  4456. limit, _ := this.GetInt64("limit")
  4457. page, _ := this.GetInt64("page")
  4458. storey := this.GetString("storey")
  4459. var startTime int64
  4460. if len(start_time) > 0 {
  4461. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4462. if err != nil {
  4463. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4464. return
  4465. }
  4466. startTime = theTime.Unix()
  4467. }
  4468. var endTime int64
  4469. if len(end_time) > 0 {
  4470. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4471. if err != nil {
  4472. utils.ErrorLog(err.Error())
  4473. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4474. return
  4475. }
  4476. endTime = theTime.Unix()
  4477. }
  4478. orgId := this.GetAdminUserInfo().CurrentOrgId
  4479. list, total, err := service.GetObjectTableDisinfectList(limit, page, startTime, endTime, orgId, storey)
  4480. if err != nil {
  4481. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4482. return
  4483. }
  4484. this.ServeSuccessJSON(map[string]interface{}{
  4485. "list": list,
  4486. "total": total,
  4487. })
  4488. }
  4489. func (this *MachineApiController) GetObjectTableDisinfectByList() {
  4490. id, _ := this.GetInt64("id")
  4491. list, err := service.GetObjectTableDisinfectByList(id)
  4492. if err != nil {
  4493. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4494. return
  4495. }
  4496. this.ServeSuccessJSON(map[string]interface{}{
  4497. "list": list,
  4498. })
  4499. }
  4500. func (this *MachineApiController) UpdateObjectTableDisinfect() {
  4501. timeLayout := "2006-01-02"
  4502. loc, _ := time.LoadLocation("Local")
  4503. dataBody := make(map[string]interface{}, 0)
  4504. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4505. fmt.Println("err", err)
  4506. record_date := dataBody["record_date"].(string)
  4507. id := int64(dataBody["id"].(float64))
  4508. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4509. recorddateunix := recorddate.Unix()
  4510. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  4511. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  4512. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  4513. first_start_time := dataBody["first_start_time"].(string)
  4514. var firstStartTimeUnix int64
  4515. if len(first_start_time) > 0 {
  4516. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  4517. firstStartTimeUnix = firstStartTime.Unix()
  4518. }
  4519. var firstEndTimeUnix int64
  4520. first_end_time := dataBody["first_end_time"].(string)
  4521. if len(first_end_time) > 0 {
  4522. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  4523. firstEndTimeUnix = firstEndTime.Unix()
  4524. }
  4525. first_total_time := dataBody["first_total_time"].(string)
  4526. first_is_check := int64(dataBody["first_is_check"].(float64))
  4527. first_modifications := int64(dataBody["first_modifications"].(float64))
  4528. first_creator := int64(dataBody["first_creator"].(float64))
  4529. sencond_disinfection_water := dataBody["sencond_disinfection_water"].(string)
  4530. sencond_disinfection_methods := dataBody["sencond_disinfection_methods"].(string)
  4531. sencond_disinfection_time := dataBody["sencond_disinfection_time"].(string)
  4532. sencond_start_time := dataBody["sencond_start_time"].(string)
  4533. var sencondStartTimeUnixt int64
  4534. if len(sencond_start_time) > 0 {
  4535. sencondStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_start_time)
  4536. sencondStartTimeUnixt = sencondStartTime.Unix()
  4537. }
  4538. sencond_end_time := dataBody["sencond_end_time"].(string)
  4539. var sencondEndTimeUnixt int64
  4540. if len(sencond_end_time) > 0 {
  4541. sencondEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", sencond_end_time)
  4542. sencondEndTimeUnixt = sencondEndTime.Unix()
  4543. }
  4544. sencond_total_time := dataBody["sencond_total_time"].(string)
  4545. sencond_is_check := int64(dataBody["sencond_is_check"].(float64))
  4546. sencond_modifications := int64(dataBody["sencond_modifications"].(float64))
  4547. sencond_creator := int64(dataBody["sencond_creator"].(float64))
  4548. third_disinfection_water := dataBody["third_disinfection_water"].(string)
  4549. third_disinfection_methods := dataBody["third_disinfection_methods"].(string)
  4550. third_disinfection_time := dataBody["third_disinfection_time"].(string)
  4551. third_start_time := dataBody["third_start_time"].(string)
  4552. var thirdStartTimeUnix int64
  4553. if len(third_start_time) > 0 {
  4554. thirdStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_start_time)
  4555. thirdStartTimeUnix = thirdStartTime.Unix()
  4556. }
  4557. third_end_time := dataBody["third_end_time"].(string)
  4558. var thirdEndTimeUnix int64
  4559. if len(third_end_time) > 0 {
  4560. thirdEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", third_end_time)
  4561. thirdEndTimeUnix = thirdEndTime.Unix()
  4562. }
  4563. third_total_time := dataBody["third_total_time"].(string)
  4564. third_is_check := int64(dataBody["third_is_check"].(float64))
  4565. third_modifications := int64(dataBody["third_modifications"].(float64))
  4566. third_creator := int64(dataBody["third_creator"].(float64))
  4567. fourth_disinfection_water := dataBody["fourth_disinfection_water"].(string)
  4568. fourth_disinfection_methods := dataBody["fourth_disinfection_methods"].(string)
  4569. fourth_disinfection_time := dataBody["fourth_disinfection_time"].(string)
  4570. fourth_start_time := dataBody["fourth_start_time"].(string)
  4571. var fourthiStartTimeUnitx int64
  4572. if len(fourth_start_time) > 0 {
  4573. fourthStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_start_time)
  4574. fourthiStartTimeUnitx = fourthStartTime.Unix()
  4575. }
  4576. fourth_end_time := dataBody["fourth_end_time"].(string)
  4577. var fourthEndTimeUnix int64
  4578. if len(fourth_end_time) > 0 {
  4579. fourthEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", fourth_end_time)
  4580. fourthEndTimeUnix = fourthEndTime.Unix()
  4581. }
  4582. fourth_total_time := dataBody["fourth_total_time"].(string)
  4583. fourth_is_check := int64(dataBody["fourth_is_check"].(float64))
  4584. fourth_modifications := int64(dataBody["fourth_modifications"].(float64))
  4585. fourth_creator := int64(dataBody["fourth_creator"].(float64))
  4586. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  4587. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  4588. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  4589. last_start_time := dataBody["last_start_time"].(string)
  4590. var lastStartTimeUnix int64
  4591. if len(last_start_time) > 0 {
  4592. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  4593. lastStartTimeUnix = lastStartTime.Unix()
  4594. }
  4595. last_end_time := dataBody["last_end_time"].(string)
  4596. var lastEndTimeUnix int64
  4597. if len(last_end_time) > 0 {
  4598. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  4599. lastEndTimeUnix = lastEndTime.Unix()
  4600. }
  4601. last_total_time := dataBody["last_total_time"].(string)
  4602. last_is_check := int64(dataBody["last_is_check"].(float64))
  4603. last_modifications := int64(dataBody["last_modifications"].(float64))
  4604. last_creator := int64(dataBody["last_creator"].(float64))
  4605. storey := dataBody["storey"].(string)
  4606. orgId := this.GetAdminUserInfo().CurrentOrgId
  4607. objectDisinfect := models.XtNewObjectDisinfect{
  4608. ID: id,
  4609. UserOrgId: orgId,
  4610. RecordDate: recorddateunix,
  4611. FirstDisinfectionWater: first_disinfection_water,
  4612. FirstDisinfectionMethods: first_disinfection_methods,
  4613. FirstDisinfectionTime: first_disinfection_time,
  4614. FirstStartTime: firstStartTimeUnix,
  4615. FirstEndTime: firstEndTimeUnix,
  4616. FirstTotalTime: first_total_time,
  4617. FirstIsCheck: first_is_check,
  4618. FirstModifications: first_modifications,
  4619. FirstCreator: first_creator,
  4620. SencondDisinfectionWater: sencond_disinfection_water,
  4621. SencondDisinfectionMethods: sencond_disinfection_methods,
  4622. SencondDisinfectionTime: sencond_disinfection_time,
  4623. SencondStartTime: sencondStartTimeUnixt,
  4624. SencondEndTime: sencondEndTimeUnixt,
  4625. SencondTotalTime: sencond_total_time,
  4626. SencondIsCheck: sencond_is_check,
  4627. SencondModifications: sencond_modifications,
  4628. SencondCreator: sencond_creator,
  4629. ThirdDisinfectionWater: third_disinfection_water,
  4630. ThirdDisinfectionMethods: third_disinfection_methods,
  4631. ThirdDisinfectionTime: third_disinfection_time,
  4632. ThirdStartTime: thirdStartTimeUnix,
  4633. ThirdEndTime: thirdEndTimeUnix,
  4634. ThirdTotalTime: third_total_time,
  4635. ThirdIsCheck: third_is_check,
  4636. ThirdModifications: third_modifications,
  4637. ThirdCreator: third_creator,
  4638. LastStartTime: lastStartTimeUnix,
  4639. LastEndTime: lastEndTimeUnix,
  4640. LastTotalTime: last_total_time,
  4641. LastIsCheck: last_is_check,
  4642. LastModifications: last_modifications,
  4643. LastCreator: last_creator,
  4644. Ctime: time.Now().Unix(),
  4645. Mtime: 0,
  4646. Status: 1,
  4647. FourthDisinfectionWater: fourth_disinfection_water,
  4648. FourthDisinfectionMethods: fourth_disinfection_methods,
  4649. FourthDisinfectionTime: fourth_disinfection_time,
  4650. FourthStartTime: fourthiStartTimeUnitx,
  4651. FourthEndTime: fourthEndTimeUnix,
  4652. FourthTotalTime: fourth_total_time,
  4653. FourthIsCheck: fourth_is_check,
  4654. FourthModifications: fourth_modifications,
  4655. FourthCreator: fourth_creator,
  4656. LastDisinfectionWater: last_disinfection_water,
  4657. LastDisinfectionMethods: last_disinfection_methods,
  4658. LastDisinfectionTime: last_disinfection_time,
  4659. Storey: storey,
  4660. }
  4661. err = service.UpdateObjectTableDisinfect(objectDisinfect)
  4662. if err != nil {
  4663. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4664. return
  4665. }
  4666. this.ServeSuccessJSON(map[string]interface{}{
  4667. "objectDisinfect": objectDisinfect,
  4668. })
  4669. }
  4670. func (this *MachineApiController) DeleteObjectTableDisinfect() {
  4671. id, _ := this.GetInt64("id")
  4672. err := service.DeleteObjectTableDisinfect(id)
  4673. if err != nil {
  4674. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4675. return
  4676. }
  4677. returnData := make(map[string]interface{}, 0)
  4678. returnData["msg"] = "ok"
  4679. this.ServeSuccessJSON(returnData)
  4680. return
  4681. }
  4682. func (this *MachineApiController) GetAirDisinfectionLongTime() {
  4683. orgId := this.GetAdminUserInfo().CurrentOrgId
  4684. storey := this.GetString("storey")
  4685. list, err := service.GetAirDisInfectionLongTime(orgId, storey)
  4686. if err != nil {
  4687. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4688. return
  4689. }
  4690. this.ServeSuccessJSON(map[string]interface{}{
  4691. "list": list,
  4692. })
  4693. }
  4694. func (this *MachineApiController) GetObjectDisInfectionLongTime() {
  4695. orgId := this.GetAdminUserInfo().CurrentOrgId
  4696. list, err := service.GetObjectDisInfectionLongTime(orgId)
  4697. if err != nil {
  4698. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4699. return
  4700. }
  4701. this.ServeSuccessJSON(map[string]interface{}{
  4702. "list": list,
  4703. })
  4704. }
  4705. func (this *MachineApiController) GetInformationmanalist() {
  4706. //获取2022年8月1日到12日的上机患者
  4707. list, _ := service.GetDialysisOrderPatient(9538)
  4708. for _, dialysisOrder := range list {
  4709. //根据床位号获取设备型号
  4710. unitType, _ := service.GetUnitType(dialysisOrder.BedId, dialysisOrder.UserOrgId)
  4711. //查询使用消毒最后一条消毒记录
  4712. _, err := service.GetLaseDeviceInfomation(dialysisOrder.UserOrgId, dialysisOrder.BedId, dialysisOrder.DialysisDate, dialysisOrder.SchedualType)
  4713. fmt.Println("err", err)
  4714. if err == gorm.ErrRecordNotFound {
  4715. //查找排班
  4716. scheduleByPatient, _ := service.GetScheduleByPatient(dialysisOrder.PatientId, dialysisOrder.DialysisDate, dialysisOrder.UserOrgId)
  4717. //查询改设备是否有消毒计划
  4718. plan, errcode := service.GetDisInfectionTime(dialysisOrder.UserOrgId, unitType.UnitType, dialysisOrder.SchedualType, scheduleByPatient.ScheduleWeek)
  4719. //根据床位号获取设备id
  4720. addmacher, _ := service.GetEquimentIDTwo(dialysisOrder.BedId, dialysisOrder.UserOrgId)
  4721. //查询病人信息
  4722. patients, _ := service.GetPatientInfoMation(dialysisOrder.PatientId)
  4723. var con = ""
  4724. if patients.IsInfectious == 0 {
  4725. con = ""
  4726. }
  4727. if patients.IsInfectious == 1 {
  4728. con = "无"
  4729. }
  4730. if patients.IsInfectious == 2 {
  4731. con = "有"
  4732. }
  4733. if errcode == nil {
  4734. var end_time int64
  4735. end_time = dialysisOrder.EndTime + plan.DisinfecTime*60
  4736. //新增消毒
  4737. information := models.DeviceInformation{
  4738. Date: dialysisOrder.DialysisDate,
  4739. Zone: dialysisOrder.ZoneId,
  4740. Class: dialysisOrder.SchedualType,
  4741. BedNumber: dialysisOrder.BedId,
  4742. PatientId: dialysisOrder.PatientId,
  4743. DialysisMode: scheduleByPatient.ModeId,
  4744. LongTime: strconv.FormatInt(plan.DisinfecTime, 10),
  4745. Disinfection: 1,
  4746. DialysisConcentration: 1,
  4747. DisinfectionStatus: 1,
  4748. Move: 1,
  4749. UserOrgId: dialysisOrder.UserOrgId,
  4750. DisinfectType: plan.Way,
  4751. DisinfectantType: plan.MachineDisinfectant,
  4752. FluidPath: plan.DisinfectanWay, //液路消毒方式
  4753. Disinfectant: plan.Disinfectant,
  4754. Ctime: time.Now().Unix(),
  4755. Status: 1,
  4756. SignName: dialysisOrder.FinishNurse,
  4757. EquimentId: addmacher.ID,
  4758. DisinfectionResidue: 2,
  4759. Bed: addmacher.BedNumber,
  4760. StartTime: dialysisOrder.StartTime,
  4761. EndTime: dialysisOrder.EndTime,
  4762. Contagion: con,
  4763. WeightLoss: 0,
  4764. Hyperfiltratio: 0,
  4765. DialysisHour: "",
  4766. MachineRun: 1,
  4767. DisinfecStartime: dialysisOrder.EndTime,
  4768. DisinfecEndtime: end_time,
  4769. }
  4770. err := service.CreateInformationTwo(&information)
  4771. fmt.Println("报错", err)
  4772. }
  4773. }
  4774. }
  4775. this.ServeSuccessJSON(map[string]interface{}{
  4776. "list": list,
  4777. })
  4778. }
  4779. func (this *MachineApiController) SaveObjectRegistration() {
  4780. timeLayout := "2006-01-02"
  4781. loc, _ := time.LoadLocation("Local")
  4782. dataBody := make(map[string]interface{}, 0)
  4783. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4784. fmt.Println(err)
  4785. record_date := dataBody["record_date"].(string)
  4786. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4787. recorddateunix := recorddate.Unix()
  4788. model_number := dataBody["model_number"].(string)
  4789. user_count := dataBody["user_count"].(string)
  4790. product_date := dataBody["product_date"].(string)
  4791. productdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
  4792. productdateunix := productdate.Unix()
  4793. expiry_date := dataBody["expiry_date"].(string)
  4794. expirydate, _ := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
  4795. expirydateunix := expirydate.Unix()
  4796. packaging_identification := int64(dataBody["packaging_identification"].(float64))
  4797. destroy_people := int64(dataBody["destroy_people"].(float64))
  4798. destroy_nubmer := dataBody["destroy_nubmer"].(string)
  4799. destroy_way := int64(dataBody["destroy_way"].(float64))
  4800. leader := int64(dataBody["leader"].(float64))
  4801. orgId := this.GetAdminUserInfo().CurrentOrgId
  4802. registration := models.XtDialysisRegistration{
  4803. RecordDate: recorddateunix,
  4804. ModelNumber: model_number,
  4805. UserCount: user_count,
  4806. ProductDate: productdateunix,
  4807. ExpiryDate: expirydateunix,
  4808. PackagingIdentification: packaging_identification,
  4809. DestroyPeople: destroy_people,
  4810. DestroyNubmer: destroy_nubmer,
  4811. DestroyWay: destroy_way,
  4812. Leader: leader,
  4813. UserOrgId: orgId,
  4814. Status: 1,
  4815. Ctime: time.Now().Unix(),
  4816. Mtime: 0,
  4817. }
  4818. err = service.CreateObjectRegistration(registration)
  4819. this.ServeSuccessJSON(map[string]interface{}{
  4820. "registration": registration,
  4821. })
  4822. }
  4823. func (this *MachineApiController) GetRegistrationDisinfectList() {
  4824. timeLayout := "2006-01-02"
  4825. loc, _ := time.LoadLocation("Local")
  4826. start_time := this.GetString("start_time")
  4827. end_time := this.GetString("end_time")
  4828. limit, _ := this.GetInt64("limit")
  4829. page, _ := this.GetInt64("page")
  4830. var startTime int64
  4831. if len(start_time) > 0 {
  4832. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  4833. if err != nil {
  4834. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4835. return
  4836. }
  4837. startTime = theTime.Unix()
  4838. }
  4839. var endTime int64
  4840. if len(end_time) > 0 {
  4841. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  4842. if err != nil {
  4843. utils.ErrorLog(err.Error())
  4844. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  4845. return
  4846. }
  4847. endTime = theTime.Unix()
  4848. }
  4849. orgId := this.GetAdminUserInfo().CurrentOrgId
  4850. list, total, err := service.GetRegistrationDisinfectList(limit, page, startTime, endTime, orgId)
  4851. if err != nil {
  4852. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4853. return
  4854. }
  4855. this.ServeSuccessJSON(map[string]interface{}{
  4856. "list": list,
  4857. "total": total,
  4858. })
  4859. }
  4860. func (this *MachineApiController) GetObjectRegistrationByIdList() {
  4861. id, _ := this.GetInt64("id")
  4862. list, err := service.GetObjectRegistrationByIdList(id)
  4863. if err != nil {
  4864. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4865. return
  4866. }
  4867. this.ServeSuccessJSON(map[string]interface{}{
  4868. "list": list,
  4869. })
  4870. }
  4871. func (this *MachineApiController) UpdateObjectRegistration() {
  4872. timeLayout := "2006-01-02"
  4873. loc, _ := time.LoadLocation("Local")
  4874. dataBody := make(map[string]interface{}, 0)
  4875. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4876. fmt.Println(err)
  4877. record_date := dataBody["record_date"].(string)
  4878. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4879. recorddateunix := recorddate.Unix()
  4880. model_number := dataBody["model_number"].(string)
  4881. user_count := dataBody["user_count"].(string)
  4882. product_date := dataBody["product_date"].(string)
  4883. productdate, _ := time.ParseInLocation(timeLayout+" 15:04:05", product_date+" 00:00:00", loc)
  4884. productdateunix := productdate.Unix()
  4885. expiry_date := dataBody["expiry_date"].(string)
  4886. expirydate, _ := time.ParseInLocation(timeLayout+" 15:04:05", expiry_date+" 00:00:00", loc)
  4887. expirydateunix := expirydate.Unix()
  4888. packaging_identification := int64(dataBody["packaging_identification"].(float64))
  4889. destroy_people := int64(dataBody["destroy_people"].(float64))
  4890. destroy_nubmer := dataBody["destroy_nubmer"].(string)
  4891. destroy_way := int64(dataBody["destroy_way"].(float64))
  4892. leader := int64(dataBody["leader"].(float64))
  4893. id := int64(dataBody["id"].(float64))
  4894. orgId := this.GetAdminUserInfo().CurrentOrgId
  4895. registration := models.XtDialysisRegistration{
  4896. ID: id,
  4897. RecordDate: recorddateunix,
  4898. ModelNumber: model_number,
  4899. UserCount: user_count,
  4900. ProductDate: productdateunix,
  4901. ExpiryDate: expirydateunix,
  4902. PackagingIdentification: packaging_identification,
  4903. DestroyPeople: destroy_people,
  4904. DestroyNubmer: destroy_nubmer,
  4905. DestroyWay: destroy_way,
  4906. Leader: leader,
  4907. UserOrgId: orgId,
  4908. Status: 1,
  4909. Ctime: time.Now().Unix(),
  4910. Mtime: 0,
  4911. }
  4912. service.UpdateObjectRegistration(registration)
  4913. this.ServeSuccessJSON(map[string]interface{}{
  4914. "registration": registration,
  4915. })
  4916. }
  4917. func (this *MachineApiController) DeleteObjectTregistration() {
  4918. id, _ := this.GetInt64("id")
  4919. err := service.DeleteObjectTregistration(id)
  4920. if err != nil {
  4921. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4922. return
  4923. }
  4924. this.ServeSuccessJSON(map[string]interface{}{
  4925. "msg": "ok",
  4926. })
  4927. return
  4928. }
  4929. func (this *MachineApiController) GetRegistGoodInforList() {
  4930. orgId := this.GetAdminUserInfo().CurrentOrgId
  4931. list, err := service.GetRegistGoodInforList(orgId)
  4932. if err != nil {
  4933. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4934. return
  4935. }
  4936. this.ServeSuccessJSON(map[string]interface{}{
  4937. "list": list,
  4938. })
  4939. return
  4940. }
  4941. func (this *MachineApiController) GetRegistNumber() {
  4942. id, _ := this.GetInt64("id")
  4943. record_date := this.GetString("record_date")
  4944. timeLayout := "2006-01-02"
  4945. loc, _ := time.LoadLocation("Local")
  4946. dataBody := make(map[string]interface{}, 0)
  4947. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4948. fmt.Println(err)
  4949. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  4950. recorddateunix := recorddate.Unix()
  4951. orgId := this.GetAdminUserInfo().CurrentOrgId
  4952. infor, err := service.GetRegistNumber(recorddateunix, id, orgId)
  4953. if err != nil {
  4954. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4955. return
  4956. }
  4957. this.ServeSuccessJSON(map[string]interface{}{
  4958. "list": infor,
  4959. })
  4960. return
  4961. }
  4962. func (this *MachineApiController) SaveSetAirDisInfect() {
  4963. air_way, _ := this.GetInt64("air_way")
  4964. orgId := this.GetAdminUserInfo().CurrentOrgId
  4965. airdisinfect, _ := service.GetAirDisInfectSetting(orgId)
  4966. airSetting := models.XtDeviceAirSetting{
  4967. ID: airdisinfect.ID,
  4968. AirWay: air_way,
  4969. UserOrgId: orgId,
  4970. Ctime: time.Now().Unix(),
  4971. Status: 1,
  4972. Mtime: time.Now().Unix(),
  4973. }
  4974. err := service.SaveSetAirDisInfect(airSetting)
  4975. if err != nil {
  4976. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  4977. return
  4978. }
  4979. this.ServeSuccessJSON(map[string]interface{}{
  4980. "airSetting": airSetting,
  4981. })
  4982. return
  4983. }
  4984. func (this *MachineApiController) GetSetAirInfectById() {
  4985. orgId := this.GetAdminUserInfo().CurrentOrgId
  4986. airset, _ := service.GetAirDisInfectSetting(orgId)
  4987. this.ServeSuccessJSON(map[string]interface{}{
  4988. "airset": airset,
  4989. })
  4990. return
  4991. }
  4992. func (this *MachineApiController) SaveNewAirWayDisinfect() {
  4993. timeLayout := "2006-01-02"
  4994. loc, _ := time.LoadLocation("Local")
  4995. dataBody := make(map[string]interface{}, 0)
  4996. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  4997. fmt.Println("err", err)
  4998. record_date := dataBody["record_date"].(string)
  4999. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5000. recorddateunix := recorddate.Unix()
  5001. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5002. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5003. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5004. first_start_time := dataBody["first_start_time"].(string)
  5005. if len(first_start_time) == 0 {
  5006. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5007. return
  5008. }
  5009. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5010. first_end_time := dataBody["first_end_time"].(string)
  5011. if len(first_end_time) == 0 {
  5012. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5013. return
  5014. }
  5015. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5016. first_total_time := dataBody["first_total_time"].(string)
  5017. first_is_check := int64(dataBody["first_is_check"].(float64))
  5018. first_modifications := int64(dataBody["first_modifications"].(float64))
  5019. first_creator := int64(dataBody["first_creator"].(float64))
  5020. last_start_time := dataBody["last_start_time"].(string)
  5021. if len(last_start_time) == 0 {
  5022. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5023. return
  5024. }
  5025. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5026. last_end_time := dataBody["last_end_time"].(string)
  5027. if len(last_end_time) == 0 {
  5028. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5029. return
  5030. }
  5031. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5032. last_total_time := dataBody["last_total_time"].(string)
  5033. last_is_check := int64(dataBody["last_is_check"].(float64))
  5034. last_modifications := int64(dataBody["last_modifications"].(float64))
  5035. last_creator := int64(dataBody["last_creator"].(float64))
  5036. department := dataBody["department"].(string)
  5037. orgId := this.GetAdminUserInfo().CurrentOrgId
  5038. disinfect := models.XtNewAriDisinfectWay{
  5039. UserOrgId: orgId,
  5040. RecordDate: recorddateunix,
  5041. FirstDisinfectionWater: first_disinfection_water,
  5042. FirstDisinfectionMethods: first_disinfection_methods,
  5043. FirstDisinfectionTime: first_disinfection_time,
  5044. FirstStartTime: firstStartTime.Unix(),
  5045. FirstEndTime: firstEndTime.Unix(),
  5046. FirstTotalTime: first_total_time,
  5047. FirstIsCheck: first_is_check,
  5048. FirstModifications: first_modifications,
  5049. FirstCreator: first_creator,
  5050. LastStartTime: lastStartTime.Unix(),
  5051. LastEndTime: lastEndTime.Unix(),
  5052. LastTotalTime: last_total_time,
  5053. LastIsCheck: last_is_check,
  5054. LastModifications: last_modifications,
  5055. LastCreator: last_creator,
  5056. Ctime: time.Now().Unix(),
  5057. Mtime: time.Now().Unix(),
  5058. Status: 1,
  5059. Department: department,
  5060. }
  5061. err = service.CreateNewAirWayDisinfectOne(disinfect)
  5062. if err != nil {
  5063. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5064. return
  5065. }
  5066. this.ServeSuccessJSON(map[string]interface{}{
  5067. "disinfect": disinfect,
  5068. })
  5069. }
  5070. func (this *MachineApiController) GetNewAirWayDisinfectList() {
  5071. timeLayout := "2006-01-02"
  5072. loc, _ := time.LoadLocation("Local")
  5073. start_time := this.GetString("start_time")
  5074. end_time := this.GetString("end_time")
  5075. limit, _ := this.GetInt64("limit")
  5076. page, _ := this.GetInt64("page")
  5077. var startTime int64
  5078. if len(start_time) > 0 {
  5079. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5080. if err != nil {
  5081. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5082. return
  5083. }
  5084. startTime = theTime.Unix()
  5085. }
  5086. var endTime int64
  5087. if len(end_time) > 0 {
  5088. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5089. if err != nil {
  5090. utils.ErrorLog(err.Error())
  5091. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5092. return
  5093. }
  5094. endTime = theTime.Unix()
  5095. }
  5096. orgId := this.GetAdminUserInfo().CurrentOrgId
  5097. list, total, err := service.GetNewAirWayDisinfectList(limit, page, startTime, endTime, orgId)
  5098. if err != nil {
  5099. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5100. return
  5101. }
  5102. this.ServeSuccessJSON(map[string]interface{}{
  5103. "list": list,
  5104. "total": total,
  5105. })
  5106. }
  5107. func (this *MachineApiController) GetAirDisinfectWayLongTime() {
  5108. orgId := this.GetAdminUserInfo().CurrentOrgId
  5109. department := this.GetString("department")
  5110. list, err := service.GetAirDisinfectWayLongTime(orgId, department)
  5111. if err != nil {
  5112. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5113. return
  5114. }
  5115. this.ServeSuccessJSON(map[string]interface{}{
  5116. "list": list,
  5117. })
  5118. }
  5119. func (this *MachineApiController) GetNewAirWayDisinfectByIdList() {
  5120. id, _ := this.GetInt64("id")
  5121. list, err := service.GetNewAirWayDisinfectByIdList(id)
  5122. if err != nil {
  5123. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5124. return
  5125. }
  5126. this.ServeSuccessJSON(map[string]interface{}{
  5127. "list": list,
  5128. })
  5129. }
  5130. func (this *MachineApiController) UpdateNewAirWayDisInfect() {
  5131. timeLayout := "2006-01-02"
  5132. loc, _ := time.LoadLocation("Local")
  5133. dataBody := make(map[string]interface{}, 0)
  5134. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  5135. fmt.Println("err", err)
  5136. id := int64(dataBody["id"].(float64))
  5137. record_date := dataBody["record_date"].(string)
  5138. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5139. recorddateunix := recorddate.Unix()
  5140. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5141. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5142. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5143. first_start_time := dataBody["first_start_time"].(string)
  5144. if len(first_start_time) == 0 {
  5145. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5146. return
  5147. }
  5148. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5149. first_end_time := dataBody["first_end_time"].(string)
  5150. if len(first_end_time) == 0 {
  5151. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5152. return
  5153. }
  5154. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5155. first_total_time := dataBody["first_total_time"].(string)
  5156. first_is_check := int64(dataBody["first_is_check"].(float64))
  5157. first_modifications := int64(dataBody["first_modifications"].(float64))
  5158. first_creator := int64(dataBody["first_creator"].(float64))
  5159. last_start_time := dataBody["last_start_time"].(string)
  5160. if len(last_start_time) == 0 {
  5161. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5162. return
  5163. }
  5164. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5165. last_end_time := dataBody["last_end_time"].(string)
  5166. if len(last_end_time) == 0 {
  5167. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5168. return
  5169. }
  5170. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5171. last_total_time := dataBody["last_total_time"].(string)
  5172. last_is_check := int64(dataBody["last_is_check"].(float64))
  5173. last_modifications := int64(dataBody["last_modifications"].(float64))
  5174. last_creator := int64(dataBody["last_creator"].(float64))
  5175. department := dataBody["department"].(string)
  5176. orgId := this.GetAdminUserInfo().CurrentOrgId
  5177. disinfect := models.XtNewAriDisinfectWay{
  5178. ID: id,
  5179. UserOrgId: orgId,
  5180. RecordDate: recorddateunix,
  5181. FirstDisinfectionWater: first_disinfection_water,
  5182. FirstDisinfectionMethods: first_disinfection_methods,
  5183. FirstDisinfectionTime: first_disinfection_time,
  5184. FirstStartTime: firstStartTime.Unix(),
  5185. FirstEndTime: firstEndTime.Unix(),
  5186. FirstTotalTime: first_total_time,
  5187. FirstIsCheck: first_is_check,
  5188. FirstModifications: first_modifications,
  5189. FirstCreator: first_creator,
  5190. LastStartTime: lastStartTime.Unix(),
  5191. LastEndTime: lastEndTime.Unix(),
  5192. LastTotalTime: last_total_time,
  5193. LastIsCheck: last_is_check,
  5194. LastModifications: last_modifications,
  5195. LastCreator: last_creator,
  5196. Ctime: time.Now().Unix(),
  5197. Mtime: time.Now().Unix(),
  5198. Status: 1,
  5199. Department: department,
  5200. }
  5201. err = service.CreateNewAirWayDisinfect(disinfect)
  5202. if err != nil {
  5203. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5204. return
  5205. }
  5206. this.ServeSuccessJSON(map[string]interface{}{
  5207. "disinfect": disinfect,
  5208. })
  5209. }
  5210. func (this *MachineApiController) DeleteNewAirWayDisinfect() {
  5211. id, _ := this.GetInt64("id")
  5212. err := service.DeleteNewAirWayDisinfect(id)
  5213. if err != nil {
  5214. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5215. return
  5216. }
  5217. this.ServeSuccessJSON(map[string]interface{}{
  5218. "msg": "ok",
  5219. })
  5220. return
  5221. }
  5222. func (this *MachineApiController) SaveSetObjectDisinfect() {
  5223. air_way, _ := this.GetInt64("air_way")
  5224. orgId := this.GetAdminUserInfo().CurrentOrgId
  5225. disinfect, _ := service.GetObjectTableDisinfect(orgId)
  5226. objctSet := models.XtDeviceObjctSet{
  5227. ID: disinfect.ID,
  5228. UserOrgId: orgId,
  5229. Status: 1,
  5230. AirWay: air_way,
  5231. Ctime: time.Now().Unix(),
  5232. Mtime: time.Now().Unix(),
  5233. }
  5234. err := service.SaveSetObjectDisinfect(objctSet)
  5235. if err != nil {
  5236. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5237. return
  5238. }
  5239. this.ServeSuccessJSON(map[string]interface{}{
  5240. "objctSet": objctSet,
  5241. })
  5242. return
  5243. }
  5244. func (this *MachineApiController) GetObjectWayDisinect() {
  5245. orgId := this.GetAdminUserInfo().CurrentOrgId
  5246. disinfect, _ := service.GetObjectTableDisinfect(orgId)
  5247. this.ServeSuccessJSON(map[string]interface{}{
  5248. "disinfect": disinfect,
  5249. })
  5250. return
  5251. }
  5252. func (this *MachineApiController) SaveObjectWayTableDisinfect() {
  5253. timeLayout := "2006-01-02"
  5254. loc, _ := time.LoadLocation("Local")
  5255. dataBody := make(map[string]interface{}, 0)
  5256. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  5257. fmt.Println("err", err)
  5258. record_date := dataBody["record_date"].(string)
  5259. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5260. recorddateunix := recorddate.Unix()
  5261. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5262. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5263. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5264. first_start_time := dataBody["first_start_time"].(string)
  5265. var firstStartTimeUnix int64
  5266. if len(first_start_time) > 0 {
  5267. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5268. firstStartTimeUnix = firstStartTime.Unix()
  5269. }
  5270. var firstEndTimeUnix int64
  5271. first_end_time := dataBody["first_end_time"].(string)
  5272. if len(first_end_time) > 0 {
  5273. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5274. firstEndTimeUnix = firstEndTime.Unix()
  5275. }
  5276. first_total_time := dataBody["first_total_time"].(string)
  5277. first_is_check := int64(dataBody["first_is_check"].(float64))
  5278. first_modifications := int64(dataBody["first_modifications"].(float64))
  5279. first_creator := int64(dataBody["first_creator"].(float64))
  5280. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  5281. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  5282. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  5283. last_start_time := dataBody["last_start_time"].(string)
  5284. var lastStartTimeUnix int64
  5285. if len(last_start_time) > 0 {
  5286. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5287. lastStartTimeUnix = lastStartTime.Unix()
  5288. }
  5289. last_end_time := dataBody["last_end_time"].(string)
  5290. var lastEndTimeUnix int64
  5291. if len(last_end_time) > 0 {
  5292. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5293. lastEndTimeUnix = lastEndTime.Unix()
  5294. }
  5295. last_total_time := dataBody["last_total_time"].(string)
  5296. last_is_check := int64(dataBody["last_is_check"].(float64))
  5297. last_modifications := int64(dataBody["last_modifications"].(float64))
  5298. last_creator := int64(dataBody["last_creator"].(float64))
  5299. orgId := this.GetAdminUserInfo().CurrentOrgId
  5300. department := dataBody["department"].(string)
  5301. objectDisinfect := models.XtNewObjectDisinfectWay{
  5302. UserOrgId: orgId,
  5303. RecordDate: recorddateunix,
  5304. FirstDisinfectionWater: first_disinfection_water,
  5305. FirstDisinfectionMethods: first_disinfection_methods,
  5306. FirstDisinfectionTime: first_disinfection_time,
  5307. FirstStartTime: firstStartTimeUnix,
  5308. FirstEndTime: firstEndTimeUnix,
  5309. FirstTotalTime: first_total_time,
  5310. FirstIsCheck: first_is_check,
  5311. FirstModifications: first_modifications,
  5312. FirstCreator: first_creator,
  5313. LastStartTime: lastStartTimeUnix,
  5314. LastEndTime: lastEndTimeUnix,
  5315. LastTotalTime: last_total_time,
  5316. LastIsCheck: last_is_check,
  5317. LastModifications: last_modifications,
  5318. LastCreator: last_creator,
  5319. Ctime: time.Now().Unix(),
  5320. Mtime: 0,
  5321. Status: 1,
  5322. LastDisinfectionWater: last_disinfection_water,
  5323. LastDisinfectionMethods: last_disinfection_methods,
  5324. LastDisinfectionTime: last_disinfection_time,
  5325. Department: department,
  5326. }
  5327. err = service.CreateNewObjectWayDisInfect(objectDisinfect)
  5328. if err != nil {
  5329. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5330. return
  5331. }
  5332. this.ServeSuccessJSON(map[string]interface{}{
  5333. "objectDisinfect": objectDisinfect,
  5334. })
  5335. }
  5336. func (this *MachineApiController) GetObjectAbleDisInfectWayList() {
  5337. timeLayout := "2006-01-02"
  5338. loc, _ := time.LoadLocation("Local")
  5339. start_time := this.GetString("start_time")
  5340. end_time := this.GetString("end_time")
  5341. limit, _ := this.GetInt64("limit")
  5342. page, _ := this.GetInt64("page")
  5343. var startTime int64
  5344. if len(start_time) > 0 {
  5345. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", start_time+" 00:00:00", loc)
  5346. if err != nil {
  5347. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5348. return
  5349. }
  5350. startTime = theTime.Unix()
  5351. }
  5352. var endTime int64
  5353. if len(end_time) > 0 {
  5354. theTime, err := time.ParseInLocation(timeLayout+" 15:04:05", end_time+" 23:59:59", loc)
  5355. if err != nil {
  5356. utils.ErrorLog(err.Error())
  5357. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeParamWrong)
  5358. return
  5359. }
  5360. endTime = theTime.Unix()
  5361. }
  5362. orgId := this.GetAdminUserInfo().CurrentOrgId
  5363. list, total, err := service.GetObjectAbleDisInfectWayList(limit, page, startTime, endTime, orgId)
  5364. if err != nil {
  5365. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5366. return
  5367. }
  5368. this.ServeSuccessJSON(map[string]interface{}{
  5369. "list": list,
  5370. "total": total,
  5371. })
  5372. }
  5373. func (this *MachineApiController) GetObjectAbledDisInfectWayById() {
  5374. id, _ := this.GetInt64("id")
  5375. list, err := service.GetObjectAbledDisInfectWayById(id)
  5376. if err != nil {
  5377. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5378. return
  5379. }
  5380. this.ServeSuccessJSON(map[string]interface{}{
  5381. "list": list,
  5382. })
  5383. }
  5384. func (this *MachineApiController) UpdateObjectWayAbleDisinfect() {
  5385. timeLayout := "2006-01-02"
  5386. loc, _ := time.LoadLocation("Local")
  5387. dataBody := make(map[string]interface{}, 0)
  5388. err := json.Unmarshal(this.Ctx.Input.RequestBody, &dataBody)
  5389. fmt.Println("err", err)
  5390. record_date := dataBody["record_date"].(string)
  5391. recorddate, _ := time.ParseInLocation(timeLayout+" 15:04:05", record_date+" 00:00:00", loc)
  5392. recorddateunix := recorddate.Unix()
  5393. first_disinfection_water := dataBody["first_disinfection_water"].(string)
  5394. first_disinfection_methods := dataBody["first_disinfection_methods"].(string)
  5395. first_disinfection_time := dataBody["first_disinfection_time"].(string)
  5396. first_start_time := dataBody["first_start_time"].(string)
  5397. var firstStartTimeUnix int64
  5398. if len(first_start_time) > 0 {
  5399. firstStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_start_time)
  5400. firstStartTimeUnix = firstStartTime.Unix()
  5401. }
  5402. var firstEndTimeUnix int64
  5403. first_end_time := dataBody["first_end_time"].(string)
  5404. if len(first_end_time) > 0 {
  5405. firstEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", first_end_time)
  5406. firstEndTimeUnix = firstEndTime.Unix()
  5407. }
  5408. first_total_time := dataBody["first_total_time"].(string)
  5409. first_is_check := int64(dataBody["first_is_check"].(float64))
  5410. first_modifications := int64(dataBody["first_modifications"].(float64))
  5411. first_creator := int64(dataBody["first_creator"].(float64))
  5412. last_disinfection_water := dataBody["last_disinfection_water"].(string)
  5413. last_disinfection_methods := dataBody["last_disinfection_methods"].(string)
  5414. last_disinfection_time := dataBody["last_disinfection_time"].(string)
  5415. last_start_time := dataBody["last_start_time"].(string)
  5416. var lastStartTimeUnix int64
  5417. if len(last_start_time) > 0 {
  5418. lastStartTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_start_time)
  5419. lastStartTimeUnix = lastStartTime.Unix()
  5420. }
  5421. last_end_time := dataBody["last_end_time"].(string)
  5422. var lastEndTimeUnix int64
  5423. if len(last_end_time) > 0 {
  5424. lastEndTime, _ := utils.ParseTimeStringToTime("2006-01-02 15:04", last_end_time)
  5425. lastEndTimeUnix = lastEndTime.Unix()
  5426. }
  5427. last_total_time := dataBody["last_total_time"].(string)
  5428. last_is_check := int64(dataBody["last_is_check"].(float64))
  5429. last_modifications := int64(dataBody["last_modifications"].(float64))
  5430. last_creator := int64(dataBody["last_creator"].(float64))
  5431. id := int64(dataBody["id"].(float64))
  5432. orgId := this.GetAdminUserInfo().CurrentOrgId
  5433. department := dataBody["department"].(string)
  5434. objectDisinfect := models.XtNewObjectDisinfectWay{
  5435. ID: id,
  5436. UserOrgId: orgId,
  5437. RecordDate: recorddateunix,
  5438. FirstDisinfectionWater: first_disinfection_water,
  5439. FirstDisinfectionMethods: first_disinfection_methods,
  5440. FirstDisinfectionTime: first_disinfection_time,
  5441. FirstStartTime: firstStartTimeUnix,
  5442. FirstEndTime: firstEndTimeUnix,
  5443. FirstTotalTime: first_total_time,
  5444. FirstIsCheck: first_is_check,
  5445. FirstModifications: first_modifications,
  5446. FirstCreator: first_creator,
  5447. LastStartTime: lastStartTimeUnix,
  5448. LastEndTime: lastEndTimeUnix,
  5449. LastTotalTime: last_total_time,
  5450. LastIsCheck: last_is_check,
  5451. LastModifications: last_modifications,
  5452. LastCreator: last_creator,
  5453. Ctime: time.Now().Unix(),
  5454. Mtime: 0,
  5455. Status: 1,
  5456. LastDisinfectionWater: last_disinfection_water,
  5457. LastDisinfectionMethods: last_disinfection_methods,
  5458. LastDisinfectionTime: last_disinfection_time,
  5459. Department: department,
  5460. }
  5461. err = service.SaveobjectDisinfect(objectDisinfect)
  5462. if err != nil {
  5463. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5464. return
  5465. }
  5466. this.ServeSuccessJSON(map[string]interface{}{
  5467. "objectDisinfect": objectDisinfect,
  5468. })
  5469. }
  5470. func (this *MachineApiController) DeleteObjectAbleWayDisinfect() {
  5471. id, _ := this.GetInt64("id")
  5472. err := service.DeleteObjectAbleWayDisinfect(id)
  5473. if err != nil {
  5474. this.ServeFailJSONWithSGJErrorCode(enums.ErrorCodeCreateConfig)
  5475. return
  5476. }
  5477. this.ServeSuccessJSON(map[string]interface{}{
  5478. "msg": "ok",
  5479. })
  5480. return
  5481. }