YtiotVAlarmServiceImpl.java 188 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797
  1. package cn.com.usky.iot.alarm.service;
  2. import java.io.BufferedReader;
  3. import java.sql.SQLException;
  4. import java.text.NumberFormat;
  5. import java.text.SimpleDateFormat;
  6. import java.util.ArrayList;
  7. import java.util.Date;
  8. import java.util.HashMap;
  9. import java.util.Iterator;
  10. import java.util.List;
  11. import java.util.Map;
  12. import cn.com.usky.iot.admin.dao.YtiotTAdminDao;
  13. import cn.com.usky.iot.admin.dao.YtiotVUserCompanyDao;
  14. import cn.com.usky.iot.admin.dao.YtiotVUserphoneDao;
  15. import cn.com.usky.iot.alarm.dao.YtiotVAlarmDao;
  16. import cn.com.usky.iot.entity.*;
  17. import cn.com.usky.utils.DaoQuery;
  18. import cn.com.usky.utils.HttpClientUtils;
  19. import cn.com.usky.utils.MD5Util;
  20. import net.sf.json.JSONArray;
  21. import net.sf.json.JSONObject;
  22. import org.apache.commons.lang3.StringUtils;
  23. import org.apache.http.HttpEntity;
  24. import org.apache.http.HttpResponse;
  25. import org.apache.http.client.entity.UrlEncodedFormEntity;
  26. import org.apache.http.client.methods.HttpPost;
  27. import org.apache.http.impl.client.CloseableHttpClient;
  28. import org.apache.http.impl.client.DefaultHttpClient;
  29. import org.hibernate.HibernateException;
  30. import org.hibernate.Query;
  31. import org.hibernate.Session;
  32. import org.springframework.beans.factory.annotation.Autowired;
  33. import org.springframework.orm.hibernate3.HibernateCallback;
  34. import org.springframework.orm.hibernate3.HibernateTemplate;
  35. import org.apache.http.message.BasicNameValuePair;
  36. import org.apache.http.protocol.HTTP;
  37. public class YtiotVAlarmServiceImpl implements YtiotVAlarmService {
  38. private HibernateTemplate hibernateTemplate;
  39. public void setHibernateTemplate(HibernateTemplate hibernateTemplate) {
  40. this.hibernateTemplate = hibernateTemplate;
  41. }
  42. private YtiotVAlarmDao ytiotVAlarmDao;
  43. private YtiotVUserphoneDao ytiotVUserphoneDao;
  44. private YtiotTAdminDao ytiotTAdminDao;
  45. private YtiotVUserCompanyDao ytiotVUserCompanyDao;
  46. public YtiotVAlarmDao getYtiotVAlarmDao() {
  47. return ytiotVAlarmDao;
  48. }
  49. public void setYtiotVAlarmDao(YtiotVAlarmDao ytiotVAlarmDao) {
  50. this.ytiotVAlarmDao = ytiotVAlarmDao;
  51. }
  52. public YtiotVUserCompanyDao getYtiotVUserCompanyDao() {
  53. return ytiotVUserCompanyDao;
  54. }
  55. public void setYtiotVUserCompanyDao(YtiotVUserCompanyDao ytiotVUserCompanyDao) {
  56. this.ytiotVUserCompanyDao = ytiotVUserCompanyDao;
  57. }
  58. public YtiotVUserphoneDao getYtiotVUserphoneDao() {
  59. return ytiotVUserphoneDao;
  60. }
  61. public void setYtiotVUserphoneDao(YtiotVUserphoneDao ytiotVUserphoneDao) {
  62. this.ytiotVUserphoneDao = ytiotVUserphoneDao;
  63. }
  64. public YtiotTAdminDao getYtiotTAdminDao() {
  65. return ytiotTAdminDao;
  66. }
  67. public void setYtiotTAdminDao(YtiotTAdminDao ytiotTAdminDao) {
  68. this.ytiotTAdminDao = ytiotTAdminDao;
  69. }
  70. public boolean chk_string_param(String param) {
  71. if(param==null)
  72. return true;
  73. if(param.indexOf("=")>=0)
  74. return false;
  75. if(param.indexOf("\'")>=0)
  76. return false;
  77. if(param.indexOf("\"")>=0)
  78. return false;
  79. return true;
  80. }
  81. public String chkhw(String hqlwhere){
  82. if(hqlwhere==null)
  83. return " where ";
  84. else
  85. return hqlwhere+" and ";
  86. }
  87. public String fieldname(String name) {
  88. if(name.equals("company_code"))
  89. return "companyCode";
  90. if(name.equals("company_name"))
  91. return "companyName";
  92. if(name.equals("device_code"))
  93. return "deviuceCode";
  94. return name;
  95. }
  96. @Override
  97. public String getEFireVList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  98. // TODO Auto-generated method stub
  99. String address = null;
  100. String clzt = null;
  101. String company_code = null;
  102. String company_code_list = null;
  103. String Company_Code_List = null;
  104. String company_name = null;
  105. String device_code = null;
  106. String device_code_list = null;
  107. String time_start = null;
  108. String time_end = null;
  109. String status = null;
  110. String COMMSTATUS = null;
  111. String V_LOGINNAME = null;
  112. String hqlwhere = null, hhwhere = null;
  113. String order = null;
  114. String dir = null;
  115. String Start = null;
  116. String Limit = null;
  117. String Page = null;
  118. String order_str = null;
  119. JSONObject q_json = null;
  120. JSONArray Sort = null;
  121. JSONArray jSONArray = new JSONArray();
  122. JSONObject json = new JSONObject();
  123. json.put("action", "getEFireVList");
  124. if(queryJson!=null) {
  125. q_json = JSONObject.fromObject(queryJson);
  126. address = q_json.has("address")?q_json.getString("address"):null;
  127. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  128. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  129. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  130. if(q_json.has("company_code")) {
  131. if((q_json.optJSONObject("company_code")!=null)
  132. &&(q_json.optJSONObject("company_code").isArray())) {
  133. JSONArray j_tmp = q_json.getJSONArray("company_code");
  134. for(int i=0;i<j_tmp.size();i++) {
  135. String tmp = j_tmp.getString(i);
  136. if(i==0)
  137. company_code_list = tmp;
  138. else
  139. company_code_list += ","+tmp;
  140. }
  141. }else
  142. company_code = q_json.getString("company_code");
  143. }
  144. // company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  145. if(q_json.has("device_code")) {
  146. if((q_json.optJSONObject("device_code")!=null)
  147. &&(q_json.optJSONObject("device_code").isArray())){
  148. JSONArray j_tmp = q_json.getJSONArray("device_code");
  149. for(int i=0;i<j_tmp.size();i++) {
  150. String tmp = j_tmp.getString(i);
  151. if(i==0)
  152. device_code_list = tmp;
  153. else
  154. device_code_list += ","+tmp;
  155. }
  156. }else
  157. device_code = q_json.getString("device_code");
  158. }
  159. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  160. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  161. }
  162. if(V_LOGINNAME.equals("ypsgec")) {
  163. return json.toString();
  164. }else {
  165. if(sort!=null) {
  166. Sort = JSONArray.fromObject(sort);
  167. if((Sort.isArray())&&(Sort.size()>0)) {
  168. JSONObject s_json = Sort.getJSONObject(0);
  169. order = s_json.has("property")?s_json.getString("property"):order;
  170. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  171. }
  172. json.put("sort", sort);
  173. }
  174. Start = start;
  175. Limit = limit;
  176. Page = page;
  177. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  178. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  179. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  180. if(list.size()>0) {
  181. for(int i=0;i<list.size();i++) {
  182. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  183. YtiotVUsercompanyId oid = o.getId();
  184. if(i==0)
  185. Company_Code_List = oid.getOwnerCode();
  186. else
  187. Company_Code_List += ","+oid.getOwnerCode();
  188. }
  189. }
  190. }
  191. if(address!=null) {
  192. hqlwhere = chkhw(hqlwhere) + " address like '%"+address+"%' ";
  193. hhwhere = chkhw(hhwhere) + " u.id.address like '%"+address+"%' ";
  194. }
  195. if((clzt!=null)&&(clzt.length()>0)) {
  196. hqlwhere = chkhw(hqlwhere) + " clzt = "+clzt+" ";
  197. hhwhere = chkhw(hhwhere) + " u.id.clzt = "+clzt+" ";
  198. }
  199. if(Company_Code_List!=null) {
  200. hqlwhere = chkhw(hqlwhere) + " company_code in ("+Company_Code_List+") ";
  201. hhwhere = chkhw(hhwhere) + " u.id.companyCode in ("+Company_Code_List+") ";
  202. }else {
  203. if(company_code!=null) {
  204. hqlwhere = chkhw(hqlwhere) + " company_code = "+company_code+" ";
  205. hhwhere = chkhw(hhwhere) + " u.id.companyCode = "+company_code+" ";
  206. }
  207. if(company_code_list!=null) {
  208. hqlwhere = chkhw(hqlwhere) + " company_code in ("+company_code_list+") ";
  209. hhwhere = chkhw(hhwhere) + " u.id.companyCode in ("+company_code_list+") ";
  210. }
  211. }
  212. if(device_code!=null) {
  213. hqlwhere = chkhw(hqlwhere) + " device_code = "+device_code+" ";
  214. hhwhere = chkhw(hhwhere) + " u.id.deviceCode = "+device_code+" ";
  215. }
  216. if(device_code_list!=null) {
  217. hqlwhere = chkhw(hqlwhere) + " device_code in ("+device_code_list+") ";
  218. hhwhere = chkhw(hhwhere) + " u.id.deviceCode in ("+device_code_list+") ";
  219. }
  220. if(time_start!=null) {
  221. hqlwhere = chkhw(hqlwhere) + " time >= '"+time_start+"' ";
  222. hhwhere = chkhw(hhwhere) + " u.id.time >= '"+time_start+"' ";
  223. }
  224. if(time_end!=null) {
  225. hqlwhere = chkhw(hqlwhere) + " time <= '"+time_end+"' ";
  226. hhwhere = chkhw(hhwhere) + " u.id.time <= '"+time_end+"' ";
  227. }
  228. if(COMMSTATUS!=null) {
  229. if(COMMSTATUS.equals("NO")) {
  230. hqlwhere = chkhw(hqlwhere)+" data1 <> 'EF9' ";
  231. hhwhere = chkhw(hhwhere)+" u.id.data1 <> 'EF9' ";
  232. }
  233. else if(COMMSTATUS.equals("ONLY")) {
  234. hqlwhere = chkhw(hqlwhere)+" data1 = 'EF9' ";
  235. hhwhere = chkhw(hhwhere)+" u.id.data1 = 'EF9' ";
  236. }
  237. }
  238. if(order!=null)
  239. order_str = " order by "+order;
  240. else
  241. order_str = " order by id ";
  242. int totalCount = ytiotVAlarmDao.getEFireCount(hhwhere);
  243. // System.out.print("shazi");
  244. // System.out.println(totalCount);
  245. json.put("totalCount", totalCount);
  246. if(Start!=null){
  247. if(Integer.parseInt(Start)>totalCount){
  248. Start = "0";
  249. Page = "0";
  250. }else if(page==null)
  251. Page="0";
  252. }else{
  253. Start = "0";
  254. Page = "0";
  255. }
  256. json.put("page", Page);
  257. json.put("start", Start);
  258. json.put("limit", Limit);
  259. if(totalCount>0) {
  260. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  261. List<?> list1 = ytiotVAlarmDao.EFireQuery(hhwhere, order_str, dir, Start, Limit);
  262. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  263. if(list1.size()>0) {
  264. for(int i=0;i<list1.size();i++) {
  265. YtiotVEfire o = (YtiotVEfire)list1.get(i);
  266. YtiotVEfireId oid = o.getId();
  267. String cl_name = "";
  268. Map<String, Comparable> map = new HashMap<String, Comparable>();
  269. if((company_code!=null)&&(i==0))
  270. json.put("company_name", oid.getCompanyName());
  271. map.put("orderIdx", Integer.parseInt(Start)+i+1);
  272. map.put("address", oid.getAddress());
  273. map.put("cldh", oid.getCldh());
  274. map.put("cllx", oid.getCllx());
  275. map.put("cllxr", oid.getCllxr());
  276. map.put("clnr", oid.getClnr());
  277. map.put("clr", oid.getClr());
  278. map.put("clwb", oid.getClwb());
  279. map.put("clzt", oid.getClzt()==0?"未处理":"已处理");
  280. map.put("company_code", oid.getCompanyCode());
  281. map.put("company_name", oid.getCompanyName());
  282. map.put("compartment", "");
  283. map.put("data1", oid.getData1());
  284. map.put("data2", oid.getData2());
  285. map.put("data3", oid.getData3());
  286. map.put("data4", oid.getData4());
  287. map.put("data5", oid.getData5());
  288. String dv = "";
  289. if(oid.getData1().equals("EF0"))
  290. dv = "正常/报警撤销";
  291. else if(oid.getData1().equals("EF1"))
  292. dv = "欠压报警";
  293. else if(oid.getData1().equals("EF2"))
  294. dv = "过压报警";
  295. else if(oid.getData1().equals("EF3"))
  296. dv = "过流报警";
  297. else if(oid.getData1().equals("EF4"))
  298. dv = "漏电报警";
  299. else if(oid.getData1().equals("EF5"))
  300. dv = "温度1超高报警";
  301. else if(oid.getData1().equals("EF6"))
  302. dv = "温度2超高报警";
  303. else if(oid.getData1().equals("EF7"))
  304. dv = "温度3超高报警";
  305. else if(oid.getData1().equals("EF8"))
  306. dv = "温度4超高报警";
  307. else if(oid.getData1().equals("EF9"))
  308. dv = "离线";
  309. String dw = "";
  310. if(oid.getData1().equals("EF0"))
  311. dw = "";
  312. else if(oid.getData1().equals("EF1"))
  313. dw = "V";
  314. else if(oid.getData1().equals("EF2"))
  315. dw = "V";
  316. else if(oid.getData1().equals("EF3"))
  317. dw = "mA";
  318. else if(oid.getData1().equals("EF4"))
  319. dw = "mA";
  320. else if(oid.getData1().equals("EF5"))
  321. dw = "℃";
  322. else if(oid.getData1().equals("EF6"))
  323. dw = "℃";
  324. else if(oid.getData1().equals("EF7"))
  325. dw = "℃";
  326. else if(oid.getData1().equals("EF8"))
  327. dw = "℃";
  328. else if(oid.getData1().equals("EF9"))
  329. dw = "";
  330. map.put("fullname", oid.getName()+","+dv+","+"告警值:"+oid.getData2()+dw);
  331. map.put("data", oid.getData1());
  332. if(oid.getClzt()==1)
  333. map.put("clsj", df.format(oid.getClsj()));
  334. else
  335. map.put("clsj", "");
  336. map.put("device_code", oid.getDeviceCode());
  337. map.put("fireprocess", "");
  338. map.put("id", oid.getId());
  339. map.put("name", oid.getName());
  340. map.put("ncmd", oid.getNcmd());
  341. map.put("port", oid.getPort());
  342. map.put("position", oid.getPosition());
  343. map.put("status", dv);
  344. map.put("time", df.format(oid.getTime()));
  345. map.put("vidoe", oid.getVideo());
  346. if((oid.getClr().length()>0)
  347. &&(ulist.size()>0)){
  348. for(int j=0;j<ulist.size();j++) {
  349. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  350. YtiotVUserphoneId poid = po.getId();
  351. if(oid.getCldh().equals(poid.getPhone())) {
  352. cl_name = poid.getUsername();
  353. break;
  354. }
  355. }
  356. }
  357. map.put("clr_name", cl_name.length()>0?cl_name:oid.getClr());
  358. JSONObject jSONObject = JSONObject.fromObject(map);
  359. jSONArray.add(jSONObject);
  360. }
  361. json.put("RESULT", jSONArray);
  362. }
  363. }
  364. return json.toString();
  365. }
  366. }
  367. @Override
  368. public String getHjVList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  369. // TODO Auto-generated method stub
  370. String address = null;
  371. String clzt = null;
  372. String company_code = null;
  373. String company_code_list = null;
  374. String Company_Code_List = null;
  375. String company_name = null;
  376. String device_code = null;
  377. String device_code_list = null;
  378. String time_start = null;
  379. String time_end = null;
  380. String status = null;
  381. String COMMSTATUS = null;
  382. String V_LOGINNAME = null;
  383. String hqlwhere = null;
  384. String order = null;
  385. String dir = null;
  386. String Start = null;
  387. String Limit = null;
  388. String Page = null;
  389. String order_str = null;
  390. JSONObject q_json = null;
  391. JSONArray Sort = null;
  392. JSONArray jSONArray = new JSONArray();
  393. JSONObject json = new JSONObject();
  394. json.put("action", "getHjVList");
  395. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  396. if(queryJson!=null) {
  397. q_json = JSONObject.fromObject(queryJson);
  398. address = q_json.has("address")?q_json.getString("address"):null;
  399. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  400. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  401. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  402. if(q_json.has("company_code")) {
  403. if((q_json.optJSONObject("company_code")!=null)
  404. &&(q_json.optJSONObject("company_code").isArray())) {
  405. JSONArray j_tmp = q_json.getJSONArray("company_code");
  406. for(int i=0;i<j_tmp.size();i++) {
  407. String tmp = j_tmp.getString(i);
  408. if(i==0)
  409. company_code_list = "'"+tmp+"'";
  410. else
  411. company_code_list += ","+"'"+tmp+"'";
  412. }
  413. }else
  414. company_code = q_json.getString("company_code");
  415. }
  416. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  417. if(q_json.has("device_code")) {
  418. if((q_json.optJSONObject("device_code")!=null)
  419. &&(q_json.optJSONObject("device_code").isArray())){
  420. JSONArray j_tmp = q_json.getJSONArray("device_code");
  421. for(int i=0;i<j_tmp.size();i++) {
  422. String tmp = j_tmp.getString(i);
  423. if(i==0)
  424. device_code_list = tmp;
  425. else
  426. device_code_list += ","+tmp;
  427. }
  428. }else
  429. device_code = q_json.getString("device_code");
  430. }
  431. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  432. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  433. }
  434. if(V_LOGINNAME.equals("ypsgec")) {
  435. return json.toString();
  436. }else {
  437. if(sort!=null) {
  438. Sort = JSONArray.fromObject(sort);
  439. if((Sort.isArray())&&(Sort.size()>0)) {
  440. JSONObject s_json = Sort.getJSONObject(0);
  441. order = s_json.has("property")?s_json.getString("property"):order;
  442. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  443. }
  444. json.put("sort", sort);
  445. }
  446. Start = start;
  447. Limit = limit;
  448. Page = page;
  449. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  450. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  451. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  452. if(list.size()>0) {
  453. for(int i=0;i<list.size();i++) {
  454. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  455. YtiotVUsercompanyId oid = o.getId();
  456. if(i==0)
  457. Company_Code_List = "'"+oid.getOwnerCode()+"'";
  458. else
  459. Company_Code_List += ","+"'"+oid.getOwnerCode()+"'";
  460. }
  461. }
  462. }
  463. System.out.print("hanzhengyi"+df.format(new Date()));
  464. if(address!=null)
  465. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"%' ";
  466. if((clzt!=null)&&(clzt.length()>0))
  467. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  468. if(Company_Code_List!=null) {
  469. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  470. }else {
  471. if(company_code!=null)
  472. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  473. if(company_code_list!=null)
  474. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  475. }
  476. if(company_name!=null)
  477. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" = '%"+company_name+"%' ";
  478. if(device_code!=null)
  479. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" = "+device_code+" ";
  480. if(device_code_list!=null)
  481. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  482. if((time_start!=null)&&(time_start.length()>0))
  483. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  484. if((time_end!=null)&&(time_end.length()>0))
  485. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  486. System.out.print("hanzhengyi"+hqlwhere);
  487. if(COMMSTATUS!=null) {
  488. if(COMMSTATUS.equals("NO"))
  489. hqlwhere = chkhw(hqlwhere)+" u.id.data1 <> 'U44' ";
  490. else if(COMMSTATUS.equals("ONLY"))
  491. hqlwhere = chkhw(hqlwhere)+" u.id.data1 = 'U44' ";
  492. }
  493. if(order!=null)
  494. order_str = " order by u.id."+fieldname(order);
  495. else
  496. order_str = " order by u.id.id ";
  497. int totalCount = ytiotVAlarmDao.getHJCount(hqlwhere);
  498. json.put("totalCount", totalCount);
  499. if(Start!=null){
  500. if(Integer.parseInt(Start)>totalCount){
  501. Start = "0";
  502. Page = "0";
  503. }else if(page==null)
  504. Page="0";
  505. }else{
  506. Start = "0";
  507. Page = "0";
  508. }
  509. json.put("page", Page);
  510. json.put("start", Start);
  511. json.put("limit", Limit);
  512. if(totalCount>0) {
  513. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  514. List<?> list = ytiotVAlarmDao.HJQuery(hqlwhere, order_str, dir, Start, Limit);
  515. if(list.size()>0) {
  516. for(int i=0;i<list.size();i++) {
  517. YtiotVHj hj = (YtiotVHj)list.get(i);
  518. YtiotVHjId id = hj.getId();
  519. String cl_name = "";
  520. Map<String, Comparable> map = new HashMap<String, Comparable>();
  521. if((company_code!=null)&&(i==0))
  522. json.put("company_name", id.getCompanyName());
  523. map.put("orderIdx", Integer.parseInt(Start)+i+1);
  524. map.put("address", id.getAddress());
  525. map.put("cldh", id.getCldh());
  526. map.put("cllx", id.getCllx());
  527. map.put("cllxr", id.getCllxr());
  528. map.put("clnr", id.getClnr());
  529. map.put("clr", id.getClr());
  530. map.put("clwb", id.getClwb());
  531. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  532. map.put("company_code", id.getCompanyCode());
  533. map.put("company_name", id.getCompanyName());
  534. map.put("compartment", id.getCompartment());
  535. map.put("data1", id.getData1());
  536. map.put("data2", id.getData2());
  537. map.put("data3", id.getData3());
  538. map.put("data4", id.getData4());
  539. map.put("data5", id.getData5());
  540. map.put("fullname", id.getName()+((id.getData4().length()>0) ?(","+id.getData4()):""));
  541. map.put("data", id.getData2());
  542. if(id.getClzt()==1)
  543. map.put("clsj", df.format(id.getClsj()));
  544. else
  545. map.put("clsj", "");
  546. map.put("device_code", id.getDeviceCode());
  547. map.put("fireprocess", id.getFireprocess());
  548. map.put("id", id.getId());
  549. map.put("name", id.getName());
  550. map.put("ncmd", id.getNcmd());
  551. map.put("port", id.getPort());
  552. map.put("position", id.getPosition());
  553. map.put("status", id.getStatus());
  554. map.put("time", df.format(id.getTime()));
  555. map.put("vidoe", id.getVideo());
  556. System.out.print("循环前"+i);
  557. if((id.getClr().length()>0)
  558. &&(ulist.size()>0)){
  559. for(int j=0;j<ulist.size();j++) {
  560. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  561. YtiotVUserphoneId poid = po.getId();
  562. if(id.getClr().equals(poid.getPhone())) {
  563. cl_name = poid.getUsername();
  564. break;
  565. }
  566. }
  567. }
  568. System.out.print("循环后"+i);
  569. map.put("clr_name", cl_name.length()>0?cl_name:id.getClr());
  570. JSONObject jSONObject = JSONObject.fromObject(map);
  571. jSONArray.add(jSONObject);
  572. }
  573. json.put("RESULT", jSONArray);
  574. // System.out.print("RESULT"+jSONArray);
  575. }
  576. }
  577. return json.toString();
  578. }
  579. }
  580. @Override
  581. public String getSyncfireAlarmFexcelList(String queryJson) throws Exception {
  582. // TODO Auto-generated method stub
  583. String address = null;
  584. String clzt = null;
  585. String company_code = null;
  586. String company_code_list = null;
  587. String Company_Code_List = null;
  588. String company_name = null;
  589. String device_code = null;
  590. String device_code_list = null;
  591. String time_start = null;
  592. String time_end = null;
  593. String status = null;
  594. String COMMSTATUS = null;
  595. String V_LOGINNAME = null;
  596. String hqlwhere = null;
  597. String order = null;
  598. String dir = null;
  599. String Start = null;
  600. String Limit = null;
  601. String Page = null;
  602. String order_str = null;
  603. JSONObject q_json = null;
  604. JSONArray Sort = null;
  605. JSONArray jSONArray = new JSONArray();
  606. JSONObject json = new JSONObject();
  607. json.put("action", "getHjVList");
  608. SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  609. if(queryJson!=null) {
  610. q_json = JSONObject.fromObject(queryJson);
  611. address = q_json.has("address")?q_json.getString("address"):null;
  612. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  613. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  614. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  615. if(q_json.has("company_code")) {
  616. if((q_json.optJSONObject("company_code")!=null)
  617. &&(q_json.optJSONObject("company_code").isArray())) {
  618. JSONArray j_tmp = q_json.getJSONArray("company_code");
  619. for(int i=0;i<j_tmp.size();i++) {
  620. String tmp = j_tmp.getString(i);
  621. if(i==0)
  622. company_code_list = tmp;
  623. else
  624. company_code_list += ","+tmp;
  625. }
  626. }else if((q_json.getString("company_code").length()>0)) {
  627. company_code = q_json.getString("company_code");
  628. }
  629. }
  630. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  631. if(q_json.has("device_code")) {
  632. if((q_json.optJSONObject("device_code")!=null)
  633. &&(q_json.optJSONObject("device_code").isArray())){
  634. JSONArray j_tmp = q_json.getJSONArray("device_code");
  635. for(int i=0;i<j_tmp.size();i++) {
  636. String tmp = j_tmp.getString(i);
  637. if(i==0)
  638. device_code_list = tmp;
  639. else
  640. device_code_list += ","+tmp;
  641. }
  642. }else
  643. device_code = q_json.getString("device_code");
  644. }
  645. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  646. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  647. }
  648. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  649. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  650. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  651. if(list.size()>0) {
  652. for(int i=0;i<list.size();i++) {
  653. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  654. YtiotVUsercompanyId oid = o.getId();
  655. if(i==0)
  656. Company_Code_List = oid.getOwnerCode();
  657. else
  658. Company_Code_List += ","+oid.getOwnerCode();
  659. }
  660. }
  661. }
  662. if(address!=null)
  663. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"%' ";
  664. if((clzt!=null)&&(clzt.length()>0))
  665. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  666. if(Company_Code_List!=null) {
  667. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  668. }else {
  669. if(company_code!=null)
  670. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  671. if(company_code_list!=null)
  672. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  673. }
  674. if(company_name!=null)
  675. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" = '%"+company_name+"%' ";
  676. if(device_code!=null)
  677. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" = "+device_code+" ";
  678. if(device_code_list!=null)
  679. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  680. if((time_start!=null)&&(time_start.length()>0))
  681. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  682. if((time_end!=null)&&(time_end.length()>0))
  683. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  684. System.out.print("hanzhengyi"+hqlwhere);
  685. if(COMMSTATUS!=null) {
  686. if(COMMSTATUS.equals("NO"))
  687. hqlwhere = chkhw(hqlwhere)+" u.id.data1 <> 'U44' ";
  688. else if(COMMSTATUS.equals("ONLY"))
  689. hqlwhere = chkhw(hqlwhere)+" u.id.data1 = 'U44' ";
  690. }
  691. if(order!=null)
  692. order_str = " order by u.id."+fieldname(order);
  693. else
  694. order_str = " order by u.id.id ";
  695. int totalCount = ytiotVAlarmDao.getHJCount(hqlwhere);
  696. json.put("totalCount", totalCount);
  697. if(totalCount>0) {
  698. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  699. List<?> list = ytiotVAlarmDao.HJQuery(hqlwhere, order_str, dir, Start, Limit);
  700. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  701. if(list.size()>0) {
  702. for(int i=0;i<list.size();i++) {
  703. YtiotVHj hj = (YtiotVHj)list.get(i);
  704. YtiotVHjId id = hj.getId();
  705. String cl_name = "";
  706. Map<String, Comparable> map = new HashMap<String, Comparable>();
  707. if((company_code!=null)&&(i==0))
  708. json.put("company_name", id.getCompanyName());
  709. map.put("address", id.getAddress());
  710. map.put("cldh", id.getCldh());
  711. map.put("cllx", id.getCllx());
  712. map.put("cllxr", id.getCllxr());
  713. map.put("clnr", id.getClnr());
  714. map.put("clr", id.getClr());
  715. if(id.getClwb().equals("0"))
  716. map.put("clwb", "未误报");
  717. else if(id.getClwb().equals("1"))
  718. map.put("clwb", "误报");
  719. else
  720. map.put("clwb", "");
  721. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  722. map.put("company_code", id.getCompanyCode());
  723. map.put("company_name", id.getCompanyName());
  724. map.put("compartment", id.getCompartment());
  725. map.put("data1", id.getData1());
  726. map.put("data2", id.getData2());
  727. map.put("data3", id.getData3());
  728. map.put("data4", id.getData4());
  729. map.put("data5", id.getData5());
  730. map.put("data", id.getData2());
  731. if(id.getClzt()==1)
  732. map.put("clsj", df.format(id.getClsj()));
  733. else
  734. map.put("clsj", "");
  735. map.put("device_code", id.getDeviceCode());
  736. map.put("fireprocess", id.getFireprocess());
  737. map.put("id", id.getId());
  738. map.put("name", id.getName());
  739. map.put("ncmd", id.getNcmd());
  740. map.put("port", id.getPort());
  741. map.put("position", id.getPosition());
  742. map.put("status", id.getStatus());
  743. map.put("time", df.format(id.getTime()));
  744. map.put("vidoe", id.getVideo());
  745. JSONObject jSONObject = JSONObject.fromObject(map);
  746. jSONArray.add(jSONObject);
  747. }
  748. json.put("result", jSONArray);
  749. }
  750. }
  751. return json.toString();
  752. }
  753. @Override
  754. public String getSyncEfireAlarmFexcelList(String queryJson) throws Exception {
  755. // TODO Auto-generated method stub
  756. String address = null;
  757. String clzt = null;
  758. String company_code = null;
  759. String company_code_list = null;
  760. String Company_Code_List = null;
  761. String company_name = null;
  762. String device_code = null;
  763. String device_code_list = null;
  764. String time_start = null;
  765. String time_end = null;
  766. String status = null;
  767. String COMMSTATUS = null;
  768. String V_LOGINNAME = null;
  769. String hqlwhere = null, hhwhere = null;
  770. String order = null;
  771. String dir = null;
  772. String Start = null;
  773. String Limit = null;
  774. String Page = null;
  775. String order_str = null;
  776. JSONObject q_json = null;
  777. JSONArray Sort = null;
  778. JSONArray jSONArray = new JSONArray();
  779. JSONObject json = new JSONObject();
  780. json.put("action", "getEFireVList");
  781. if(queryJson!=null) {
  782. q_json = JSONObject.fromObject(queryJson);
  783. address = q_json.has("address")?q_json.getString("address"):null;
  784. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  785. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  786. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  787. if(q_json.has("company_code")) {
  788. if((q_json.optJSONObject("company_code")!=null)
  789. &&(q_json.optJSONObject("company_code").isArray())) {
  790. JSONArray j_tmp = q_json.getJSONArray("company_code");
  791. for(int i=0;i<j_tmp.size();i++) {
  792. String tmp = j_tmp.getString(i);
  793. if(i==0)
  794. company_code_list = tmp;
  795. else
  796. company_code_list += ","+tmp;
  797. }
  798. }else if((q_json.getString("company_code").length()>0)) {
  799. company_code = q_json.getString("company_code");
  800. }
  801. }
  802. // company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  803. if(q_json.has("device_code")) {
  804. if((q_json.optJSONObject("device_code")!=null)
  805. &&(q_json.optJSONObject("device_code").isArray())){
  806. JSONArray j_tmp = q_json.getJSONArray("device_code");
  807. for(int i=0;i<j_tmp.size();i++) {
  808. String tmp = j_tmp.getString(i);
  809. if(i==0)
  810. device_code_list = tmp;
  811. else
  812. device_code_list += ","+tmp;
  813. }
  814. }else
  815. device_code = q_json.getString("device_code");
  816. }
  817. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  818. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  819. }
  820. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  821. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  822. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  823. if(list.size()>0) {
  824. for(int i=0;i<list.size();i++) {
  825. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  826. YtiotVUsercompanyId oid = o.getId();
  827. if(i==0)
  828. Company_Code_List = oid.getOwnerCode();
  829. else
  830. Company_Code_List += ","+oid.getOwnerCode();
  831. }
  832. }
  833. }
  834. if(address!=null) {
  835. hqlwhere = chkhw(hqlwhere) + " address like '%"+address+"%' ";
  836. hhwhere = chkhw(hhwhere) + " u.id.address like '%"+address+"%' ";
  837. }
  838. if((clzt!=null)&&(clzt.length()>0)) {
  839. hqlwhere = chkhw(hqlwhere) + " clzt = "+clzt+" ";
  840. hhwhere = chkhw(hhwhere) + " u.id.clzt = "+clzt+" ";
  841. }
  842. if(Company_Code_List!=null) {
  843. hqlwhere = chkhw(hqlwhere) + " company_code in ("+Company_Code_List+") ";
  844. hhwhere = chkhw(hhwhere) + " u.id.companyCode in ("+Company_Code_List+") ";
  845. }else {
  846. if(company_code!=null) {
  847. hqlwhere = chkhw(hqlwhere) + " company_code = "+company_code+" ";
  848. hhwhere = chkhw(hhwhere) + " u.id.companyCode = "+company_code+" ";
  849. }
  850. if(company_code_list!=null) {
  851. hqlwhere = chkhw(hqlwhere) + " company_code in ("+company_code_list+") ";
  852. hhwhere = chkhw(hhwhere) + " u.id.companyCode in ("+company_code_list+") ";
  853. }
  854. }
  855. if(device_code!=null) {
  856. hqlwhere = chkhw(hqlwhere) + " device_code = "+device_code+" ";
  857. hhwhere = chkhw(hhwhere) + " u.id.deviceCode = "+device_code+" ";
  858. }
  859. if(device_code_list!=null) {
  860. hqlwhere = chkhw(hqlwhere) + " device_code in ("+device_code_list+") ";
  861. hhwhere = chkhw(hhwhere) + " u.id.deviceCode in ("+device_code_list+") ";
  862. }
  863. if((time_start!=null)&&(time_start.length()>0)) {
  864. hqlwhere = chkhw(hqlwhere) + " time >= '"+time_start+"' ";
  865. hhwhere = chkhw(hhwhere) + " u.id.time >= '"+time_start+"' ";
  866. }
  867. if((time_end!=null)&&(time_start.length()>0)) {
  868. hqlwhere = chkhw(hqlwhere) + " time <= '"+time_end+"' ";
  869. hhwhere = chkhw(hhwhere) + " u.id.time <= '"+time_end+"' ";
  870. }
  871. if(COMMSTATUS!=null) {
  872. if(COMMSTATUS.equals("NO")) {
  873. hqlwhere = chkhw(hqlwhere)+" data1 <> 'EF9' ";
  874. hhwhere = chkhw(hhwhere)+" u.id.data1 <> 'EF9' ";
  875. }
  876. else if(COMMSTATUS.equals("ONLY")) {
  877. hqlwhere = chkhw(hqlwhere)+" data1 = 'EF9' ";
  878. hhwhere = chkhw(hhwhere)+" u.id.data1 = 'EF9' ";
  879. }
  880. }
  881. System.out.print("shazi"+hhwhere);
  882. if(order!=null)
  883. order_str = " order by "+order;
  884. else
  885. order_str = " order by id ";
  886. int totalCount = ytiotVAlarmDao.getEFireCount(hhwhere);
  887. // System.out.println(totalCount);
  888. json.put("totalCount", totalCount);
  889. if(totalCount>0) {
  890. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  891. List<?> list1 = ytiotVAlarmDao.EFireQuery(hhwhere, order_str, dir, Start, Limit);
  892. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  893. if(list1.size()>0) {
  894. for(int i=0;i<list1.size();i++) {
  895. YtiotVEfire o = (YtiotVEfire)list1.get(i);
  896. YtiotVEfireId oid = o.getId();
  897. String cl_name = "";
  898. Map<String, Comparable> map = new HashMap<String, Comparable>();
  899. if((company_code!=null)&&(i==0))
  900. json.put("company_name", oid.getCompanyName());
  901. map.put("address", oid.getAddress());
  902. map.put("cldh", oid.getCldh());
  903. map.put("cllx", oid.getCllx());
  904. map.put("cllxr", oid.getCllxr());
  905. map.put("clnr", oid.getClnr());
  906. map.put("clr", oid.getClr());
  907. if(oid.getClwb().equals("0"))
  908. map.put("clwb", "未误报");
  909. else if(oid.getClwb().equals("1"))
  910. map.put("clwb", "误报");
  911. else
  912. map.put("clwb", "");
  913. map.put("clzt", oid.getClzt()==0?"未处理":"已处理");
  914. map.put("company_code", oid.getCompanyCode());
  915. map.put("company_name", oid.getCompanyName());
  916. map.put("data2", oid.getData2());
  917. map.put("data3", oid.getData3());
  918. map.put("data4", oid.getData4());
  919. map.put("data5", oid.getData5());
  920. if(oid.getData1().equals("EF0"))
  921. map.put("data1", "正常/报警撤销");
  922. else if(oid.getData1().equals("EF1"))
  923. map.put("data1", "欠压报警");
  924. else if(oid.getData1().equals("EF2"))
  925. map.put("data1","过压报警");
  926. else if(oid.getData1().equals("EF3"))
  927. map.put("data1","过流报警");
  928. else if(oid.getData1().equals("EF4"))
  929. map.put("data1","漏电报警");
  930. else if(oid.getData1().equals("EF5"))
  931. map.put("data1","温度1超高报警");
  932. else if(oid.getData1().equals("EF6"))
  933. map.put("data1","温度2超高报警");
  934. else if(oid.getData1().equals("EF7"))
  935. map.put("data1","温度3超高报警");
  936. else if(oid.getData1().equals("EF8"))
  937. map.put("data1","温度4超高报警");
  938. else if(oid.getData1().equals("EF9"))
  939. map.put("data1","离线");
  940. // String dw = "";
  941. // if(oid.getData1().equals("EF0"))
  942. // dw = "";
  943. // else if(oid.getData1().equals("EF1"))
  944. // dw = "V";
  945. // else if(oid.getData1().equals("EF2"))
  946. // dw = "V";
  947. // else if(oid.getData1().equals("EF3"))
  948. // dw = "mA";
  949. // else if(oid.getData1().equals("EF4"))
  950. // dw = "mA";
  951. // else if(oid.getData1().equals("EF5"))
  952. // dw = "℃";
  953. // else if(oid.getData1().equals("EF6"))
  954. // dw = "℃";
  955. // else if(oid.getData1().equals("EF7"))
  956. // dw = "℃";
  957. // else if(oid.getData1().equals("EF8"))
  958. // dw = "℃";
  959. // else if(oid.getData1().equals("EF9"))
  960. // dw = "";
  961. map.put("data", oid.getData1());
  962. if(oid.getClzt()==1)
  963. map.put("clsj", df.format(oid.getClsj()));
  964. else
  965. map.put("clsj", "");
  966. map.put("device_code", oid.getDeviceCode());
  967. map.put("id", oid.getId());
  968. map.put("name", oid.getName());
  969. map.put("ncmd", oid.getNcmd());
  970. map.put("port", oid.getPort());
  971. map.put("position", oid.getPosition());
  972. map.put("time", df.format(oid.getTime()));
  973. map.put("vidoe", oid.getVideo());
  974. if((oid.getClr().length()>0)
  975. &&(ulist.size()>0)){
  976. for(int j=0;j<ulist.size();j++) {
  977. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  978. YtiotVUserphoneId poid = po.getId();
  979. if(oid.getCldh().equals(poid.getPhone())) {
  980. cl_name = poid.getUsername();
  981. break;
  982. }
  983. }
  984. }
  985. map.put("clr_name", cl_name.length()>0?cl_name:oid.getClr());
  986. JSONObject jSONObject = JSONObject.fromObject(map);
  987. jSONArray.add(jSONObject);
  988. }
  989. json.put("result", jSONArray);
  990. }
  991. }
  992. return json.toString();
  993. }
  994. @Override
  995. public String getSyncWaterAlarmFexcelList(String queryJson) throws Exception {
  996. // TODO Auto-generated method stub
  997. String address = null;
  998. String clzt = null;
  999. String company_code = null;
  1000. String company_code_list = null;
  1001. String Company_Code_List = null;
  1002. String company_name = null;
  1003. String device_code = null;
  1004. String device_code_list = null;
  1005. String time_start = null;
  1006. String time_end = null;
  1007. String COMMSTATUS = null;
  1008. String V_LOGINNAME = null;
  1009. String hqlwhere = null;
  1010. String order = null;
  1011. String dir = null;
  1012. String Start = null;
  1013. String Limit = null;
  1014. String Page = null;
  1015. String order_str = null;
  1016. JSONObject q_json = null;
  1017. JSONArray Sort = null;
  1018. JSONArray jSONArray = new JSONArray();
  1019. JSONObject json = new JSONObject();
  1020. json.put("action", "getSjVList");
  1021. if(queryJson!=null) {
  1022. q_json = JSONObject.fromObject(queryJson);
  1023. address = q_json.has("address")?q_json.getString("address"):null;
  1024. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  1025. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  1026. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  1027. if(q_json.has("company_code")) {
  1028. if((q_json.optJSONObject("company_code")!=null)
  1029. &&(q_json.optJSONObject("company_code").isArray())) {
  1030. JSONArray j_tmp = q_json.getJSONArray("company_code");
  1031. for(int i=0;i<j_tmp.size();i++) {
  1032. String tmp = j_tmp.getString(i);
  1033. if(i==0)
  1034. company_code_list = tmp;
  1035. else
  1036. company_code_list += ","+tmp;
  1037. }
  1038. }else if((q_json.getString("company_code").length()>0)) {
  1039. company_code = q_json.getString("company_code");
  1040. }
  1041. }
  1042. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  1043. if(q_json.has("device_code")) {
  1044. if((q_json.optJSONObject("device_code")!=null)
  1045. &&(q_json.optJSONObject("device_code").isArray())){
  1046. JSONArray j_tmp = q_json.getJSONArray("device_code");
  1047. for(int i=0;i<j_tmp.size();i++) {
  1048. String tmp = j_tmp.getString(i);
  1049. if(i==0)
  1050. device_code_list = tmp;
  1051. else
  1052. device_code_list += ","+tmp;
  1053. }
  1054. }else
  1055. device_code = q_json.getString("device_code");
  1056. }
  1057. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  1058. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  1059. }
  1060. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  1061. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  1062. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  1063. if(list.size()>0) {
  1064. for(int i=0;i<list.size();i++) {
  1065. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  1066. YtiotVUsercompanyId oid = o.getId();
  1067. if(i==0)
  1068. Company_Code_List = oid.getOwnerCode();
  1069. else
  1070. Company_Code_List += ","+oid.getOwnerCode();
  1071. }
  1072. }
  1073. }
  1074. if(address!=null)
  1075. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"' ";
  1076. if((clzt!=null)&&(clzt.length()>0))
  1077. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  1078. if(Company_Code_List!=null)
  1079. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  1080. else {
  1081. if(company_code!=null)
  1082. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  1083. if(company_code_list!=null)
  1084. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1085. }
  1086. // if(company_code!=null)
  1087. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = '"+company_code+"' ";
  1088. // if(company_code_list!=null)
  1089. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1090. if(company_name!=null)
  1091. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
  1092. if(device_code!=null)
  1093. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" = '"+device_code+"' ";
  1094. if(device_code_list!=null)
  1095. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  1096. if((time_start!=null)&&(time_start.length()>0))
  1097. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  1098. if((time_end!=null)&&(time_end.length()>0))
  1099. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  1100. if(COMMSTATUS!=null) {
  1101. if(COMMSTATUS.equals("NO"))
  1102. hqlwhere = chkhw(hqlwhere)+"( u.id.data1 <> 'WP4' and u.id.data1 <> 'LL4' ) ";
  1103. else if(COMMSTATUS.equals("ONLY"))
  1104. hqlwhere = chkhw(hqlwhere)+" ( u.id.data1 = 'WP4' or u.id.data1 = 'LL4' ) ";
  1105. }
  1106. if(order!=null)
  1107. order_str = " order by u.id."+fieldname(order);
  1108. else
  1109. order_str = " order by u.id.id ";
  1110. int totalCount = ytiotVAlarmDao.getSJCount(hqlwhere);
  1111. json.put("totalCount", totalCount);
  1112. if(totalCount>0) {
  1113. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  1114. List<?> list = ytiotVAlarmDao.SJQuery(hqlwhere, order_str, dir, Start, Limit);
  1115. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1116. if(list.size()>0) {
  1117. for(int i=0;i<list.size();i++) {
  1118. YtiotVSj hj = (YtiotVSj)list.get(i);
  1119. YtiotVSjId id = hj.getId();
  1120. String cl_name = "";
  1121. if((company_code!=null)&&(i==0))
  1122. json.put("company_name", id.getCompanyName());
  1123. Map<String, Comparable> map = new HashMap<String, Comparable>();
  1124. map.put("address", id.getAddress());
  1125. map.put("cldh", id.getCldh());
  1126. map.put("cllx", id.getCllx());
  1127. map.put("cllxr", id.getCllxr());
  1128. map.put("clnr", id.getClnr());
  1129. map.put("clr", id.getClr());
  1130. if(id.getClwb().equals("0"))
  1131. map.put("clwb", "未误报");
  1132. else if(id.getClwb().equals("1"))
  1133. map.put("clwb", "误报");
  1134. else
  1135. map.put("clwb", "");
  1136. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  1137. map.put("clsj", df.format(id.getClsj()));
  1138. map.put("company_code", id.getCompanyCode());
  1139. map.put("company_name", id.getCompanyName());
  1140. map.put("data2", id.getData2());
  1141. map.put("data3", id.getData3());
  1142. map.put("data4", id.getData4()+(id.getData1().equals("WP1")?"MPa"
  1143. :(id.getData1().equals("WP2")?"MPa"
  1144. :(id.getData1().equals("WP3")?"MPa"
  1145. :(id.getData1().equals("WP4")?"MPa"
  1146. :(id.getData1().equals("WP0")?"MPa"
  1147. :(id.getData1().equals("LL1")?"m"
  1148. :(id.getData1().equals("LL2")?"m"
  1149. :(id.getData1().equals("LL3")?"m"
  1150. :(id.getData1().equals("LL0")?"m":""))))))))));
  1151. map.put("data5", id.getData5());
  1152. if(id.getClzt()==1)
  1153. map.put("clsj", df.format(id.getClsj()));
  1154. else
  1155. map.put("clsj", "");
  1156. map.put("device_code", id.getDeviceCode());
  1157. map.put("id", id.getId());
  1158. map.put("name", id.getName());
  1159. map.put("ncmd", id.getNcmd());
  1160. map.put("port", id.getPort());
  1161. map.put("position", id.getPosition());
  1162. map.put("status", id.getStatus());
  1163. map.put("time", df.format(id.getTime()));
  1164. map.put("vidoe", id.getVideo());
  1165. map.put("data1", id.getData1().equals("WP1")?"低压"
  1166. :(id.getData1().equals("WP2")?"高压"
  1167. :(id.getData1().equals("WP3")?"故障"
  1168. :(id.getData1().equals("WP4")?"离线"
  1169. :(id.getData1().equals("WP0")?"正常"
  1170. :(id.getData1().equals("LL1")?"低水位"
  1171. :(id.getData1().equals("LL2")?"高水位"
  1172. :(id.getData1().equals("LL3")?"故障"
  1173. :(id.getData1().equals("LL0")?"正常":id.getData1())))))))));
  1174. if((id.getClr().length()>0)
  1175. &&(ulist.size()>0)){
  1176. for(int j=0;j<ulist.size();j++) {
  1177. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  1178. YtiotVUserphoneId poid = po.getId();
  1179. if(id.getClr().equals(poid.getPhone())) {
  1180. cl_name = poid.getUsername();
  1181. break;
  1182. }
  1183. }
  1184. }
  1185. map.put("clr_name", cl_name.length()>0?cl_name:id.getClr());
  1186. JSONObject jSONObject = JSONObject.fromObject(map);
  1187. jSONArray.add(jSONObject);
  1188. }
  1189. json.put("result", jSONArray);
  1190. }
  1191. }
  1192. return json.toString();
  1193. }
  1194. @Override
  1195. public String getSyncRTUAlarmFexcelList(String queryJson) throws Exception {
  1196. // TODO Auto-generated method stub
  1197. String address = null;
  1198. String clzt = null;
  1199. String company_code = null;
  1200. String company_code_list = null;
  1201. String Company_Code_List = null;
  1202. String company_name = null;
  1203. String device_code = null;
  1204. String device_code_list = null;
  1205. String time_start = null;
  1206. String time_end = null;
  1207. String status = null;
  1208. String COMMSTATUS = null;
  1209. String V_LOGINNAME = null;
  1210. String hqlwhere = null;
  1211. String order = null;
  1212. String dir = null;
  1213. String Start = null;
  1214. String Limit = null;
  1215. String Page = null;
  1216. String order_str = null;
  1217. JSONObject q_json = null;
  1218. JSONArray Sort = null;
  1219. JSONArray jSONArray = new JSONArray();
  1220. JSONObject json = new JSONObject();
  1221. json.put("action", "getRTUVList");
  1222. if(queryJson!=null) {
  1223. q_json = JSONObject.fromObject(queryJson);
  1224. address = q_json.has("address")?q_json.getString("address"):null;
  1225. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  1226. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  1227. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  1228. if(q_json.has("company_code")) {
  1229. if((q_json.optJSONObject("company_code")!=null)
  1230. &&(q_json.optJSONObject("company_code").isArray())) {
  1231. JSONArray j_tmp = q_json.getJSONArray("company_code");
  1232. for(int i=0;i<j_tmp.size();i++) {
  1233. String tmp = j_tmp.getString(i);
  1234. if(i==0)
  1235. company_code_list = tmp;
  1236. else
  1237. company_code_list += ","+tmp;
  1238. }
  1239. }else if((q_json.getString("company_code").length()>0)) {
  1240. company_code = q_json.getString("company_code");
  1241. }
  1242. }
  1243. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  1244. if(q_json.has("device_code")) {
  1245. if((q_json.optJSONObject("device_code")!=null)
  1246. &&(q_json.optJSONObject("device_code").isArray())){
  1247. JSONArray j_tmp = q_json.getJSONArray("device_code");
  1248. for(int i=0;i<j_tmp.size();i++) {
  1249. String tmp = j_tmp.getString(i);
  1250. if(i==0)
  1251. device_code_list = tmp;
  1252. else
  1253. device_code_list += ","+tmp;
  1254. }
  1255. }else
  1256. device_code = q_json.getString("device_code");
  1257. }
  1258. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  1259. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  1260. }
  1261. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  1262. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  1263. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  1264. if(list.size()>0) {
  1265. for(int i=0;i<list.size();i++) {
  1266. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  1267. YtiotVUsercompanyId oid = o.getId();
  1268. if(i==0)
  1269. Company_Code_List = oid.getOwnerCode();
  1270. else
  1271. Company_Code_List += ","+oid.getOwnerCode();
  1272. }
  1273. }
  1274. }
  1275. if(address!=null)
  1276. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"%' ";
  1277. if((clzt!=null)&&(clzt.length()>0))
  1278. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  1279. if(Company_Code_List!=null) {
  1280. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  1281. }else {
  1282. if((company_code!=null))
  1283. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  1284. if(company_code_list!=null)
  1285. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1286. }
  1287. if(company_name!=null)
  1288. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" = '%"+company_name+"%' ";
  1289. if(device_code!=null)
  1290. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" = "+device_code+" ";
  1291. if(device_code_list!=null)
  1292. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  1293. if((time_start!=null)&&(time_start.length()>0))
  1294. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  1295. if((time_end!=null)&&(time_end.length()>0))
  1296. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  1297. // System.out.print("hanzhengyi"+COMMSTATUS);
  1298. if(COMMSTATUS!=null) {
  1299. if(COMMSTATUS.equals("NO"))
  1300. hqlwhere = chkhw(hqlwhere)+" u.id.status <> '44' ";
  1301. else if(COMMSTATUS.equals("ONLY"))
  1302. hqlwhere = chkhw(hqlwhere)+" u.id.status = '44' ";
  1303. }
  1304. System.out.print("han"+hqlwhere);
  1305. if(order!=null)
  1306. order_str = " order by u.id."+fieldname(order);
  1307. else
  1308. order_str = " order by u.id.id ";
  1309. int totalCount = ytiotVAlarmDao.getRTUCount(hqlwhere);
  1310. json.put("totalCount", totalCount);
  1311. if(totalCount>0) {
  1312. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  1313. List<?> list = ytiotVAlarmDao.RTUQuery(hqlwhere, order_str, dir, Start, Limit);
  1314. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1315. if(list.size()>0) {
  1316. for(int i=0;i<list.size();i++) {
  1317. YtiotVRtu hj = (YtiotVRtu)list.get(i);
  1318. YtiotVRtuId id = hj.getId();
  1319. String cl_name = "";
  1320. Map<String, Comparable> map = new HashMap<String, Comparable>();
  1321. if((company_code!=null)&&(i==0))
  1322. json.put("company_name", id.getCompanyName());
  1323. map.put("address", id.getAddress());
  1324. map.put("cldh", id.getCldh());
  1325. map.put("cllx", id.getCllx());
  1326. map.put("cllxr", id.getCllxr());
  1327. map.put("clnr", id.getClnr());
  1328. map.put("clr", id.getClr());
  1329. if(id.getClwb().equals("0"))
  1330. map.put("clwb", "未误报");
  1331. else if(id.getClwb().equals("1"))
  1332. map.put("clwb", "误报");
  1333. else
  1334. map.put("clwb", "");
  1335. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  1336. map.put("company_code", id.getCompanyCode());
  1337. map.put("company_name", id.getCompanyName());
  1338. map.put("data1", id.getData1());
  1339. map.put("data2", id.getData2());
  1340. map.put("data3", id.getData3());
  1341. map.put("data4", id.getData4());
  1342. map.put("data5", id.getData5());
  1343. map.put("data", id.getData2());
  1344. if(id.getClzt()==1)
  1345. map.put("clsj", df.format(id.getClsj()));
  1346. else
  1347. map.put("clsj", "");
  1348. map.put("device_code", id.getDeviceCode());
  1349. map.put("id", id.getId());
  1350. map.put("name", id.getName());
  1351. map.put("ncmd", id.getNcmd());
  1352. map.put("port", id.getPort());
  1353. map.put("position", id.getPosition());
  1354. map.put("status", id.getStatus());
  1355. map.put("time", df.format(id.getTime()));
  1356. map.put("vidoe", id.getVideo());
  1357. JSONObject jSONObject = JSONObject.fromObject(map);
  1358. jSONArray.add(jSONObject);
  1359. }
  1360. json.put("result", jSONArray);
  1361. }
  1362. }
  1363. return json.toString();
  1364. }
  1365. /**
  1366. * 获取监控视频告警信息
  1367. * @param queryJson
  1368. * @param page
  1369. * @param start
  1370. * @param limit
  1371. * @param sort
  1372. * @return
  1373. */
  1374. @Override
  1375. public String getVideoLists(String queryJson, String page, String start, String limit, String sort) {
  1376. {
  1377. String address = null;//地址
  1378. String clzt = null;//处理状态
  1379. String company_code = null;//公司编号
  1380. String company_code_list = null;//
  1381. String Company_Code_List = null;
  1382. String company_name = null;//公司名
  1383. String device_code = null;//设备代码
  1384. String device_code_list = null;
  1385. String time_start = null;//告警开始时间
  1386. String time_end = null;//告警结束时间
  1387. String COMMSTATUS = null;
  1388. String V_LOGINNAME = null;//用户名
  1389. String hqlwhere = null;
  1390. String order = null;
  1391. String dir = null;
  1392. String Start = null;
  1393. String Limit = null;
  1394. String Page = null;
  1395. String order_str = null;
  1396. JSONObject q_json = null;
  1397. JSONArray Sort = null;
  1398. JSONArray jSONArray = new JSONArray();
  1399. JSONObject json = new JSONObject();
  1400. json.put("action", "getVideoLists");
  1401. if(StringUtils.isNotBlank(queryJson)) {
  1402. q_json = JSONObject.fromObject(queryJson);
  1403. address = q_json.has("address")?q_json.getString("address"):null;
  1404. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  1405. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  1406. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  1407. if(q_json.has("company_code")) {
  1408. if((q_json.optJSONObject("company_code")!=null)
  1409. &&(q_json.optJSONObject("company_code").isArray())) {
  1410. JSONArray j_tmp = q_json.getJSONArray("company_code");
  1411. for(int i=0;i<j_tmp.size();i++) {
  1412. String tmp = j_tmp.getString(i);
  1413. if(i==0)
  1414. company_code_list = tmp;
  1415. else
  1416. company_code_list += ","+tmp;
  1417. }
  1418. }else
  1419. company_code = q_json.getString("company_code");
  1420. }
  1421. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  1422. if(q_json.has("device_code")) {
  1423. if((q_json.optJSONObject("device_code")!=null)
  1424. &&(q_json.optJSONObject("device_code").isArray())){
  1425. JSONArray j_tmp = q_json.getJSONArray("device_code");
  1426. for(int i=0;i<j_tmp.size();i++) {
  1427. String tmp = j_tmp.getString(i);
  1428. if(i==0)
  1429. device_code_list = tmp;
  1430. else
  1431. device_code_list += ","+tmp;
  1432. }
  1433. }else
  1434. device_code = q_json.getString("device_code");
  1435. }
  1436. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  1437. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  1438. }
  1439. if(sort!=null) {
  1440. Sort = JSONArray.fromObject(sort);
  1441. if((Sort.isArray())&&(Sort.size()>0)) {
  1442. JSONObject s_json = Sort.getJSONObject(0);
  1443. order = s_json.has("property")?s_json.getString("property"):order;
  1444. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  1445. }
  1446. json.put("sort", sort);
  1447. }
  1448. Start = start;
  1449. Limit = limit;
  1450. Page = page;
  1451. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  1452. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  1453. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  1454. if(list!=null && list.size()>=0) {
  1455. for(int i=0;i<list.size();i++) {
  1456. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  1457. YtiotVUsercompanyId oid = o.getId();
  1458. if(i==0)
  1459. Company_Code_List = oid.getOwnerCode();
  1460. else
  1461. Company_Code_List += ","+oid.getOwnerCode();
  1462. }
  1463. }
  1464. }
  1465. if(address!=null)
  1466. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"' ";
  1467. if((clzt!=null)&&(clzt.length()>0))
  1468. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  1469. if(Company_Code_List!=null)
  1470. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  1471. else {
  1472. if(company_code!=null)
  1473. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  1474. if(company_code_list!=null)
  1475. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1476. }
  1477. // if(company_code!=null)
  1478. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" like '%"+company_code+"%' ";
  1479. // if(company_code_list!=null)
  1480. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1481. if(company_name!=null)
  1482. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
  1483. if(device_code!=null)
  1484. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" like '%"+device_code+"%' ";
  1485. if(device_code_list!=null)
  1486. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  1487. if(time_start!=null)
  1488. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  1489. if(time_end!=null)
  1490. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  1491. if(COMMSTATUS!=null) {
  1492. if(COMMSTATUS.equals("NO"))
  1493. hqlwhere = chkhw(hqlwhere)+" u.id.status <> '44' ";
  1494. else if(COMMSTATUS.equals("ONLY"))
  1495. hqlwhere = chkhw(hqlwhere)+" u.id.data = '44' ";
  1496. }
  1497. if(order!=null)
  1498. order_str = " order by u.id."+fieldname(order);
  1499. else
  1500. order_str = " order by u.id.id ";
  1501. System.out.println(hqlwhere);
  1502. //int totalCount = ytiotVAlarmDao.getRTUCount(hqlwhere);
  1503. int totalCount = ytiotVAlarmDao.getVideoCount(hqlwhere);
  1504. json.put("totalCount", totalCount);
  1505. if(Start!=null){
  1506. if(Integer.parseInt(Start)>totalCount){
  1507. Start = "0";
  1508. Page = "0";
  1509. }else if(page==null)
  1510. Page="0";
  1511. }else{
  1512. Start = "0";
  1513. Page = "0";
  1514. }
  1515. json.put("page", Page);
  1516. json.put("start", Start);
  1517. json.put("limit", Limit);
  1518. if(totalCount>0) {
  1519. //获取用户手机号码
  1520. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  1521. //获取告警信息
  1522. List<?> list = ytiotVAlarmDao.VideoAlarmQuery(hqlwhere, order_str, dir, Start, Limit);
  1523. //ytiotVAlarmDao.RTUQuery(hqlwhere, order_str, dir, Start, Limit);
  1524. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1525. if(list.size()>0) {
  1526. for(int i=0;i<list.size();i++) {
  1527. YtiotVideoAlarm hj = (YtiotVideoAlarm)list.get(i);
  1528. YtiotVideoAlarmId id = hj.getId();
  1529. String cl_name = "";
  1530. if((company_code!=null)&&(i==0))
  1531. json.put("company_name", id.getCompanyName());
  1532. Map<String, Comparable> map = new HashMap<String, Comparable>();
  1533. map.put("orderIdx", Integer.parseInt(Start)+i+1);
  1534. map.put("address", id.getAddress());
  1535. map.put("cldh", id.getCldh());
  1536. map.put("cllx", id.getCllx());
  1537. map.put("cllxr", id.getCllxr());
  1538. map.put("clnr", id.getClnr());
  1539. map.put("clr", id.getClr());
  1540. map.put("clwb", id.getClwb());
  1541. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  1542. if(id.getClzt()==1)
  1543. map.put("clsj", df.format(id.getClsj()));
  1544. else
  1545. map.put("clsj", "");
  1546. map.put("company_code", id.getCompanyCode());
  1547. map.put("company_name", id.getCompanyName());
  1548. map.put("data1", id.getData1());
  1549. map.put("data2", id.getData2());
  1550. map.put("data3", id.getData3());
  1551. map.put("data4", id.getData4());
  1552. map.put("data5", id.getData5());
  1553. map.put("device_code", id.getDeviceCode());
  1554. map.put("id", id.getId());
  1555. map.put("name", id.getName());
  1556. map.put("ncmd", id.getNcmd());
  1557. map.put("port", id.getPort());
  1558. map.put("position", id.getPosition());
  1559. map.put("status", id.getStatus());
  1560. map.put("time", df.format(id.getTime()));
  1561. map.put("vidoe", id.getVideo());
  1562. map.put("fullname", id.getName()+","+((id.getPort().equals("E6")) ?"模拟量":"开关量")+","+((id.getNcmd().length()>0) ?("端口号:"+id.getNcmd()):"")
  1563. +((id.getPort().equals("E3")) ?"":(id.getData2().equals("高压")?(","+"告警值:"+id.getData1()+"MPa")
  1564. :(id.getData2().equals("低压")?(","+"告警值:"+id.getData1()+"MPa")
  1565. :(id.getData2().equals("高温")?(","+"告警值:"+id.getData1()+"℃")
  1566. :(id.getData2().equals("低温")?(","+"告警值:"+id.getData1()+"℃")
  1567. :(id.getData2().equals("高水位")?(","+"告警值:"+id.getData1()+"m")
  1568. :(id.getData2().equals("低水位")?(","+"告警值:"+id.getData1()+"m")
  1569. :(id.getData2().equals("高湿度")?(","+"告警值:"+id.getData1()+"%")
  1570. :(id.getData2().equals("低湿度")?(","+"告警值:"+id.getData1()+"%")
  1571. :""))))))))));
  1572. map.put("data", id.getData2());
  1573. if((id.getClr().length()>0)
  1574. &&(ulist.size()>0)){
  1575. for(int j=0;j<ulist.size();j++) {
  1576. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  1577. YtiotVUserphoneId poid = po.getId();
  1578. if(id.getClr().equals(poid.getPhone())) {
  1579. cl_name = poid.getUsername();
  1580. break;
  1581. }
  1582. }
  1583. }
  1584. map.put("clr_name", cl_name.length()>0?cl_name:id.getClr());
  1585. JSONObject jSONObject = JSONObject.fromObject(map);
  1586. jSONArray.add(jSONObject);
  1587. }
  1588. json.put("RESULT", jSONArray);
  1589. }
  1590. }
  1591. return json.toString();
  1592. }
  1593. }
  1594. /**
  1595. * 获取监控视频告警信息
  1596. * @param queryJson
  1597. * @param page
  1598. * @param start
  1599. * @param limit
  1600. * @param sort
  1601. * @return
  1602. */
  1603. @Override
  1604. public String getVideoOfflineList(String queryJson, String page, String start, String limit, String sort) {
  1605. {
  1606. String address = null;//地址
  1607. String clzt = null;//处理状态
  1608. String company_code = null;//公司编号
  1609. String company_code_list = null;//
  1610. String Company_Code_List = null;
  1611. String company_name = null;//公司名
  1612. String device_code = null;//设备代码
  1613. String device_code_list = null;
  1614. String time_start = null;//告警开始时间
  1615. String time_end = null;//告警结束时间
  1616. String COMMSTATUS = null;
  1617. String V_LOGINNAME = null;//用户名
  1618. String hqlwhere = null;
  1619. String order = null;
  1620. String dir = null;
  1621. String Start = null;
  1622. String Limit = null;
  1623. String Page = null;
  1624. String order_str = null;
  1625. JSONObject q_json = null;
  1626. JSONArray Sort = null;
  1627. JSONArray jSONArray = new JSONArray();
  1628. JSONObject json = new JSONObject();
  1629. json.put("action", "getVideoLists");
  1630. if(StringUtils.isNotBlank(queryJson)) {
  1631. q_json = JSONObject.fromObject(queryJson);
  1632. address = q_json.has("address")?q_json.getString("address"):null;
  1633. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  1634. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  1635. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  1636. if(q_json.has("company_code")) {
  1637. if((q_json.optJSONObject("company_code")!=null)
  1638. &&(q_json.optJSONObject("company_code").isArray())) {
  1639. JSONArray j_tmp = q_json.getJSONArray("company_code");
  1640. for(int i=0;i<j_tmp.size();i++) {
  1641. String tmp = j_tmp.getString(i);
  1642. if(i==0)
  1643. company_code_list = tmp;
  1644. else
  1645. company_code_list += ","+tmp;
  1646. }
  1647. }else
  1648. company_code = q_json.getString("company_code");
  1649. }
  1650. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  1651. if(q_json.has("device_code")) {
  1652. if((q_json.optJSONObject("device_code")!=null)
  1653. &&(q_json.optJSONObject("device_code").isArray())){
  1654. JSONArray j_tmp = q_json.getJSONArray("device_code");
  1655. for(int i=0;i<j_tmp.size();i++) {
  1656. String tmp = j_tmp.getString(i);
  1657. if(i==0)
  1658. device_code_list = tmp;
  1659. else
  1660. device_code_list += ","+tmp;
  1661. }
  1662. }else
  1663. device_code = q_json.getString("device_code");
  1664. }
  1665. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  1666. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  1667. }
  1668. if(sort!=null) {
  1669. Sort = JSONArray.fromObject(sort);
  1670. if((Sort.isArray())&&(Sort.size()>0)) {
  1671. JSONObject s_json = Sort.getJSONObject(0);
  1672. order = s_json.has("property")?s_json.getString("property"):order;
  1673. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  1674. }
  1675. json.put("sort", sort);
  1676. }
  1677. Start = start;
  1678. Limit = limit;
  1679. Page = page;
  1680. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  1681. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  1682. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  1683. if(list!=null && list.size()>=0) {
  1684. for(int i=0;i<list.size();i++) {
  1685. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  1686. YtiotVUsercompanyId oid = o.getId();
  1687. if(i==0)
  1688. Company_Code_List = oid.getOwnerCode();
  1689. else
  1690. Company_Code_List += ","+oid.getOwnerCode();
  1691. }
  1692. }
  1693. }
  1694. if(address!=null)
  1695. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"' ";
  1696. if((clzt!=null)&&(clzt.length()>0))
  1697. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  1698. if(Company_Code_List!=null)
  1699. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  1700. else {
  1701. if(company_code!=null)
  1702. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  1703. if(company_code_list!=null)
  1704. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1705. }
  1706. // if(company_code!=null)
  1707. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" like '%"+company_code+"%' ";
  1708. // if(company_code_list!=null)
  1709. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1710. if(company_name!=null)
  1711. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
  1712. if(device_code!=null)
  1713. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" like '%"+device_code+"%' ";
  1714. if(device_code_list!=null)
  1715. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  1716. if(time_start!=null)
  1717. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  1718. if(time_end!=null)
  1719. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  1720. if(COMMSTATUS!=null) {
  1721. if(COMMSTATUS.equals("NO"))
  1722. hqlwhere = chkhw(hqlwhere)+" u.id.status <> '上线' ";
  1723. else if(COMMSTATUS.equals("ONLY"))
  1724. hqlwhere = chkhw(hqlwhere)+" u.id.status = '离线' ";
  1725. }
  1726. if(order!=null)
  1727. order_str = " order by u.id."+fieldname(order);
  1728. else
  1729. order_str = " order by u.id.id ";
  1730. System.out.println(hqlwhere);
  1731. //int totalCount = ytiotVAlarmDao.getRTUCount(hqlwhere);
  1732. int totalCount = ytiotVAlarmDao.getVideoCount(hqlwhere);
  1733. json.put("totalCount", totalCount);
  1734. if(Start!=null){
  1735. if(Integer.parseInt(Start)>totalCount){
  1736. Start = "0";
  1737. Page = "0";
  1738. }else if(page==null)
  1739. Page="0";
  1740. }else{
  1741. Start = "0";
  1742. Page = "0";
  1743. }
  1744. json.put("page", Page);
  1745. json.put("start", Start);
  1746. json.put("limit", Limit);
  1747. if(totalCount>0) {
  1748. //获取用户手机号码
  1749. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  1750. //获取告警信息
  1751. List<?> list = ytiotVAlarmDao.videoOfflienQuery(hqlwhere, order_str, dir, Start, Limit);
  1752. //ytiotVAlarmDao.RTUQuery(hqlwhere, order_str, dir, Start, Limit);
  1753. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1754. if(list.size()>0) {
  1755. for(int i=0;i<list.size();i++) {
  1756. YtiotVideoOffline hj = (YtiotVideoOffline)list.get(i);
  1757. YtiotVideoOfflineId id = hj.getId();
  1758. String cl_name = "";
  1759. if((company_code!=null)&&(i==0))
  1760. json.put("company_name", id.getCompanyName());
  1761. Map<String, Comparable> map = new HashMap<String, Comparable>();
  1762. map.put("orderIdx", Integer.parseInt(Start)+i+1);
  1763. map.put("cllxr", id.getCllxr());
  1764. map.put("clnr", id.getClnr());
  1765. map.put("clr", id.getClr());
  1766. map.put("clwb", id.getClwb());
  1767. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  1768. if(id.getClzt()==1)
  1769. map.put("clsj", df.format(id.getClsj()));
  1770. else
  1771. map.put("clsj", "");
  1772. map.put("company_code", id.getCompanyCode());
  1773. map.put("company_name", id.getCompanyName());
  1774. map.put("device_code", id.getDeviceCode());
  1775. map.put("id", id.getId());
  1776. map.put("name", id.getName());
  1777. map.put("port", id.getPort());
  1778. map.put("position", id.getPosition());
  1779. map.put("status", id.getStatus());
  1780. map.put("time", df.format(id.getTime()));
  1781. /*map.put("fullname", id.getName()+","+((id.getPort().equals("E6")) ?"模拟量":"开关量")+","+((id.getNcmd().length()>0) ?("端口号:"+id.getNcmd()):"")
  1782. +((id.getPort().equals("E3")) ?"":(id.getData2().equals("高压")?(","+"告警值:"+id.getData1()+"MPa")
  1783. :(id.getData2().equals("低压")?(","+"告警值:"+id.getData1()+"MPa")
  1784. :(id.getData2().equals("高温")?(","+"告警值:"+id.getData1()+"℃")
  1785. :(id.getData2().equals("低温")?(","+"告警值:"+id.getData1()+"℃")
  1786. :(id.getData2().equals("高水位")?(","+"告警值:"+id.getData1()+"m")
  1787. :(id.getData2().equals("低水位")?(","+"告警值:"+id.getData1()+"m")
  1788. :(id.getData2().equals("高湿度")?(","+"告警值:"+id.getData1()+"%")
  1789. :(id.getData2().equals("低湿度")?(","+"告警值:"+id.getData1()+"%")
  1790. :""))))))))));*/
  1791. map.put("data", id.getData());
  1792. if((id.getClr().length()>0)
  1793. &&(ulist.size()>0)){
  1794. for(int j=0;j<ulist.size();j++) {
  1795. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  1796. YtiotVUserphoneId poid = po.getId();
  1797. if(id.getClr().equals(poid.getPhone())) {
  1798. cl_name = poid.getUsername();
  1799. break;
  1800. }
  1801. }
  1802. }
  1803. map.put("clr_name", cl_name.length()>0?cl_name:id.getClr());
  1804. JSONObject jSONObject = JSONObject.fromObject(map);
  1805. jSONArray.add(jSONObject);
  1806. }
  1807. json.put("RESULT", jSONArray);
  1808. }
  1809. }
  1810. return json.toString();
  1811. }
  1812. }
  1813. @Override
  1814. public String getSjVList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  1815. // TODO Auto-generated method stub
  1816. String address = null;
  1817. String clzt = null;
  1818. String company_code = null;
  1819. String company_code_list = null;
  1820. String Company_Code_List = null;
  1821. String company_name = null;
  1822. String device_code = null;
  1823. String device_code_list = null;
  1824. String time_start = null;
  1825. String time_end = null;
  1826. String COMMSTATUS = null;
  1827. String V_LOGINNAME = null;
  1828. String hqlwhere = null;
  1829. String order = null;
  1830. String dir = null;
  1831. String Start = null;
  1832. String Limit = null;
  1833. String Page = null;
  1834. String order_str = null;
  1835. JSONObject q_json = null;
  1836. JSONArray Sort = null;
  1837. JSONArray jSONArray = new JSONArray();
  1838. JSONObject json = new JSONObject();
  1839. json.put("action", "getSjVList");
  1840. if(queryJson!=null) {
  1841. q_json = JSONObject.fromObject(queryJson);
  1842. address = q_json.has("address")?q_json.getString("address"):null;
  1843. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  1844. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  1845. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  1846. if(q_json.has("company_code")) {
  1847. if((q_json.optJSONObject("company_code")!=null)
  1848. &&(q_json.optJSONObject("company_code").isArray())) {
  1849. JSONArray j_tmp = q_json.getJSONArray("company_code");
  1850. for(int i=0;i<j_tmp.size();i++) {
  1851. String tmp = j_tmp.getString(i);
  1852. if(i==0)
  1853. company_code_list = tmp;
  1854. else
  1855. company_code_list += ","+tmp;
  1856. }
  1857. }else
  1858. company_code = q_json.getString("company_code");
  1859. }
  1860. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  1861. if(q_json.has("device_code")) {
  1862. if((q_json.optJSONObject("device_code")!=null)
  1863. &&(q_json.optJSONObject("device_code").isArray())){
  1864. JSONArray j_tmp = q_json.getJSONArray("device_code");
  1865. for(int i=0;i<j_tmp.size();i++) {
  1866. String tmp = j_tmp.getString(i);
  1867. if(i==0)
  1868. device_code_list = tmp;
  1869. else
  1870. device_code_list += ","+tmp;
  1871. }
  1872. }else
  1873. device_code = q_json.getString("device_code");
  1874. }
  1875. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  1876. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  1877. }
  1878. if(V_LOGINNAME.equals("ypsgec")) {
  1879. return json.toString();
  1880. }else {
  1881. if(sort!=null) {
  1882. Sort = JSONArray.fromObject(sort);
  1883. if((Sort.isArray())&&(Sort.size()>0)) {
  1884. JSONObject s_json = Sort.getJSONObject(0);
  1885. order = s_json.has("property")?s_json.getString("property"):order;
  1886. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  1887. }
  1888. json.put("sort", sort);
  1889. }
  1890. Start = start;
  1891. Limit = limit;
  1892. Page = page;
  1893. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  1894. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  1895. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  1896. if(list.size()>0) {
  1897. for(int i=0;i<list.size();i++) {
  1898. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  1899. YtiotVUsercompanyId oid = o.getId();
  1900. if(i==0)
  1901. Company_Code_List = oid.getOwnerCode();
  1902. else
  1903. Company_Code_List += ","+oid.getOwnerCode();
  1904. }
  1905. }
  1906. }
  1907. if(address!=null)
  1908. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"' ";
  1909. if((clzt!=null)&&(clzt.length()>0))
  1910. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  1911. if(Company_Code_List!=null)
  1912. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  1913. else {
  1914. if(company_code!=null)
  1915. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  1916. if(company_code_list!=null)
  1917. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1918. }
  1919. // if(company_code!=null)
  1920. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = '"+company_code+"' ";
  1921. // if(company_code_list!=null)
  1922. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  1923. if(company_name!=null)
  1924. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
  1925. if(device_code!=null)
  1926. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" = '"+device_code+"' ";
  1927. if(device_code_list!=null)
  1928. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  1929. if(time_start!=null)
  1930. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  1931. if(time_end!=null)
  1932. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  1933. if(COMMSTATUS!=null) {
  1934. if(COMMSTATUS.equals("NO"))
  1935. hqlwhere = chkhw(hqlwhere)+"( u.id.data1 <> 'WP4' and u.id.data1 <> 'LL4' ) ";
  1936. else if(COMMSTATUS.equals("ONLY"))
  1937. hqlwhere = chkhw(hqlwhere)+" ( u.id.data1 = 'WP4' or u.id.data1 = 'LL4' ) ";
  1938. }
  1939. if(order!=null)
  1940. order_str = " order by u.id."+fieldname(order);
  1941. else
  1942. order_str = " order by u.id.id ";
  1943. int totalCount = ytiotVAlarmDao.getSJCount(hqlwhere);
  1944. json.put("totalCount", totalCount);
  1945. if(Start!=null){
  1946. if(Integer.parseInt(Start)>totalCount){
  1947. Start = "0";
  1948. Page = "0";
  1949. }else if(page==null)
  1950. Page="0";
  1951. }else{
  1952. Start = "0";
  1953. Page = "0";
  1954. }
  1955. json.put("page", Page);
  1956. json.put("start", Start);
  1957. json.put("limit", Limit);
  1958. if(totalCount>0) {
  1959. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  1960. List<?> list = ytiotVAlarmDao.SJQuery(hqlwhere, order_str, dir, Start, Limit);
  1961. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  1962. if(list.size()>0) {
  1963. for(int i=0;i<list.size();i++) {
  1964. YtiotVSj hj = (YtiotVSj)list.get(i);
  1965. YtiotVSjId id = hj.getId();
  1966. String cl_name = "";
  1967. if((company_code!=null)&&(i==0))
  1968. json.put("company_name", id.getCompanyName());
  1969. Map<String, Comparable> map = new HashMap<String, Comparable>();
  1970. map.put("orderIdx", Integer.parseInt(Start)+i+1);
  1971. map.put("address", id.getAddress());
  1972. map.put("cldh", id.getCldh());
  1973. map.put("cllx", id.getCllx());
  1974. map.put("cllxr", id.getCllxr());
  1975. map.put("clnr", id.getClnr());
  1976. map.put("clr", id.getClr());
  1977. map.put("clwb", id.getClwb());
  1978. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  1979. map.put("clsj", df.format(id.getClsj()));
  1980. map.put("company_code", id.getCompanyCode());
  1981. map.put("company_name", id.getCompanyName());
  1982. map.put("data1", id.getData1());
  1983. map.put("data2", id.getData2());
  1984. map.put("data3", id.getData3());
  1985. map.put("data4", id.getData4()+(id.getData1().equals("WP1")?"MPa"
  1986. :(id.getData1().equals("WP2")?"MPa"
  1987. :(id.getData1().equals("WP3")?"MPa"
  1988. :(id.getData1().equals("WP4")?"MPa"
  1989. :(id.getData1().equals("WP0")?"MPa"
  1990. :(id.getData1().equals("LL1")?"m"
  1991. :(id.getData1().equals("LL2")?"m"
  1992. :(id.getData1().equals("LL3")?"m"
  1993. :(id.getData1().equals("LL0")?"m":""))))))))));
  1994. map.put("data5", id.getData5());
  1995. if(id.getClzt()==1)
  1996. map.put("clsj", df.format(id.getClsj()));
  1997. else
  1998. map.put("clsj", "");
  1999. map.put("device_code", id.getDeviceCode());
  2000. map.put("id", id.getId());
  2001. map.put("name", id.getName());
  2002. map.put("ncmd", id.getNcmd());
  2003. map.put("port", id.getPort());
  2004. map.put("position", id.getPosition());
  2005. map.put("status", id.getStatus());
  2006. map.put("time", df.format(id.getTime()));
  2007. map.put("vidoe", id.getVideo());
  2008. map.put("fullname", id.getName());
  2009. map.put("data", id.getData1().equals("WP1")?"低压"
  2010. :(id.getData1().equals("WP2")?"高压"
  2011. :(id.getData1().equals("WP3")?"故障"
  2012. :(id.getData1().equals("WP4")?"离线"
  2013. :(id.getData1().equals("WP0")?"正常"
  2014. :(id.getData1().equals("LL1")?"低压"
  2015. :(id.getData1().equals("LL2")?"高压"
  2016. :(id.getData1().equals("LL3")?"故障"
  2017. :(id.getData1().equals("LL0")?"正常":id.getData1())))))))));
  2018. if((id.getClr().length()>0)
  2019. &&(ulist.size()>0)){
  2020. for(int j=0;j<ulist.size();j++) {
  2021. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  2022. YtiotVUserphoneId poid = po.getId();
  2023. if(id.getClr().equals(poid.getPhone())) {
  2024. cl_name = poid.getUsername();
  2025. break;
  2026. }
  2027. }
  2028. }
  2029. map.put("clr_name", cl_name.length()>0?cl_name:id.getClr());
  2030. JSONObject jSONObject = JSONObject.fromObject(map);
  2031. jSONArray.add(jSONObject);
  2032. }
  2033. json.put("RESULT", jSONArray);
  2034. }
  2035. }
  2036. return json.toString();
  2037. }
  2038. }
  2039. @Override
  2040. public String getRtuVList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  2041. // TODO Auto-generated method stub
  2042. String address = null;
  2043. String clzt = null;
  2044. String company_code = null;
  2045. String company_code_list = null;
  2046. String Company_Code_List = null;
  2047. String company_name = null;
  2048. String device_code = null;
  2049. String device_code_list = null;
  2050. String time_start = null;
  2051. String time_end = null;
  2052. String COMMSTATUS = null;
  2053. String V_LOGINNAME = null;
  2054. String hqlwhere = null;
  2055. String order = null;
  2056. String dir = null;
  2057. String Start = null;
  2058. String Limit = null;
  2059. String Page = null;
  2060. String order_str = null;
  2061. JSONObject q_json = null;
  2062. JSONArray Sort = null;
  2063. JSONArray jSONArray = new JSONArray();
  2064. JSONObject json = new JSONObject();
  2065. json.put("action", "getRtuVList");
  2066. if(queryJson!=null) {
  2067. q_json = JSONObject.fromObject(queryJson);
  2068. address = q_json.has("address")?q_json.getString("address"):null;
  2069. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  2070. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  2071. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  2072. if(q_json.has("company_code")) {
  2073. if((q_json.optJSONObject("company_code")!=null)
  2074. &&(q_json.optJSONObject("company_code").isArray())) {
  2075. JSONArray j_tmp = q_json.getJSONArray("company_code");
  2076. for(int i=0;i<j_tmp.size();i++) {
  2077. String tmp = j_tmp.getString(i);
  2078. if(i==0)
  2079. company_code_list = tmp;
  2080. else
  2081. company_code_list += ","+tmp;
  2082. }
  2083. }else
  2084. company_code = q_json.getString("company_code");
  2085. }
  2086. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  2087. if(q_json.has("device_code")) {
  2088. if((q_json.optJSONObject("device_code")!=null)
  2089. &&(q_json.optJSONObject("device_code").isArray())){
  2090. JSONArray j_tmp = q_json.getJSONArray("device_code");
  2091. for(int i=0;i<j_tmp.size();i++) {
  2092. String tmp = j_tmp.getString(i);
  2093. if(i==0)
  2094. device_code_list = tmp;
  2095. else
  2096. device_code_list += ","+tmp;
  2097. }
  2098. }else
  2099. device_code = q_json.getString("device_code");
  2100. }
  2101. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  2102. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  2103. }
  2104. if(V_LOGINNAME.equals("ypsgec")) {
  2105. return json.toString();
  2106. }else {
  2107. if(sort!=null) {
  2108. Sort = JSONArray.fromObject(sort);
  2109. if((Sort.isArray())&&(Sort.size()>0)) {
  2110. JSONObject s_json = Sort.getJSONObject(0);
  2111. order = s_json.has("property")?s_json.getString("property"):order;
  2112. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  2113. }
  2114. json.put("sort", sort);
  2115. }
  2116. Start = start;
  2117. Limit = limit;
  2118. Page = page;
  2119. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  2120. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  2121. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  2122. if(list.size()>0) {
  2123. for(int i=0;i<list.size();i++) {
  2124. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  2125. YtiotVUsercompanyId oid = o.getId();
  2126. if(i==0)
  2127. Company_Code_List = oid.getOwnerCode();
  2128. else
  2129. Company_Code_List += ","+oid.getOwnerCode();
  2130. }
  2131. }
  2132. }
  2133. if(address!=null)
  2134. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"' ";
  2135. if((clzt!=null)&&(clzt.length()>0))
  2136. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  2137. if(Company_Code_List!=null)
  2138. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  2139. else {
  2140. if(company_code!=null)
  2141. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  2142. if(company_code_list!=null)
  2143. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  2144. }
  2145. // if(company_code!=null)
  2146. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" like '%"+company_code+"%' ";
  2147. // if(company_code_list!=null)
  2148. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  2149. if(company_name!=null)
  2150. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
  2151. if(device_code!=null)
  2152. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" like '%"+device_code+"%' ";
  2153. if(device_code_list!=null)
  2154. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  2155. if(time_start!=null)
  2156. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  2157. if(time_end!=null)
  2158. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  2159. if(COMMSTATUS!=null) {
  2160. if(COMMSTATUS.equals("NO"))
  2161. hqlwhere = chkhw(hqlwhere)+" u.id.status <> '44' ";
  2162. else if(COMMSTATUS.equals("ONLY"))
  2163. hqlwhere = chkhw(hqlwhere)+" u.id.status = '44' ";
  2164. }
  2165. if(order!=null)
  2166. order_str = " order by u.id."+fieldname(order);
  2167. else
  2168. order_str = " order by u.id.id ";
  2169. System.out.println(hqlwhere);
  2170. int totalCount = ytiotVAlarmDao.getRTUCount(hqlwhere);
  2171. json.put("totalCount", totalCount);
  2172. if(Start!=null){
  2173. if(Integer.parseInt(Start)>totalCount){
  2174. Start = "0";
  2175. Page = "0";
  2176. }else if(page==null)
  2177. Page="0";
  2178. }else{
  2179. Start = "0";
  2180. Page = "0";
  2181. }
  2182. json.put("page", Page);
  2183. json.put("start", Start);
  2184. json.put("limit", Limit);
  2185. if(totalCount>0) {
  2186. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  2187. List<?> list = ytiotVAlarmDao.RTUQuery(hqlwhere, order_str, dir, Start, Limit);
  2188. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2189. if(list.size()>0) {
  2190. for(int i=0;i<list.size();i++) {
  2191. YtiotVRtu hj = (YtiotVRtu)list.get(i);
  2192. YtiotVRtuId id = hj.getId();
  2193. String cl_name = "";
  2194. if((company_code!=null)&&(i==0))
  2195. json.put("company_name", id.getCompanyName());
  2196. Map<String, Comparable> map = new HashMap<String, Comparable>();
  2197. map.put("orderIdx", Integer.parseInt(Start)+i+1);
  2198. map.put("address", id.getAddress());
  2199. map.put("cldh", id.getCldh());
  2200. map.put("cllx", id.getCllx());
  2201. map.put("cllxr", id.getCllxr());
  2202. map.put("clnr", id.getClnr());
  2203. map.put("clr", id.getClr());
  2204. map.put("clwb", id.getClwb());
  2205. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  2206. if(id.getClzt()==1)
  2207. map.put("clsj", df.format(id.getClsj()));
  2208. else
  2209. map.put("clsj", "");
  2210. map.put("company_code", id.getCompanyCode());
  2211. map.put("company_name", id.getCompanyName());
  2212. map.put("data1", id.getData1());
  2213. map.put("data2", id.getData2());
  2214. map.put("data3", id.getData3());
  2215. map.put("data4", id.getData4());
  2216. map.put("data5", id.getData5());
  2217. map.put("device_code", id.getDeviceCode());
  2218. map.put("id", id.getId());
  2219. map.put("name", id.getName());
  2220. map.put("ncmd", id.getNcmd());
  2221. map.put("port", id.getPort());
  2222. map.put("position", id.getPosition());
  2223. map.put("status", id.getStatus());
  2224. map.put("time", df.format(id.getTime()));
  2225. map.put("vidoe", id.getVideo());
  2226. map.put("fullname", id.getName()+","+((id.getPort().equals("E6")) ?"模拟量":"开关量")+","+((id.getNcmd().length()>0) ?("端口号:"+id.getNcmd()):"")
  2227. +((id.getPort().equals("E3")) ?"":(id.getData2().equals("高压")?(","+"告警值:"+id.getData1()+"MPa")
  2228. :(id.getData2().equals("低压")?(","+"告警值:"+id.getData1()+"MPa")
  2229. :(id.getData2().equals("高温")?(","+"告警值:"+id.getData1()+"℃")
  2230. :(id.getData2().equals("低温")?(","+"告警值:"+id.getData1()+"℃")
  2231. :(id.getData2().equals("高水位")?(","+"告警值:"+id.getData1()+"m")
  2232. :(id.getData2().equals("低水位")?(","+"告警值:"+id.getData1()+"m")
  2233. :(id.getData2().equals("高湿度")?(","+"告警值:"+id.getData1()+"%")
  2234. :(id.getData2().equals("低湿度")?(","+"告警值:"+id.getData1()+"%")
  2235. :""))))))))));
  2236. map.put("data", id.getData2());
  2237. if((id.getClr().length()>0)
  2238. &&(ulist.size()>0)){
  2239. for(int j=0;j<ulist.size();j++) {
  2240. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  2241. YtiotVUserphoneId poid = po.getId();
  2242. if(id.getClr().equals(poid.getPhone())) {
  2243. cl_name = poid.getUsername();
  2244. break;
  2245. }
  2246. }
  2247. }
  2248. map.put("clr_name", cl_name.length()>0?cl_name:id.getClr());
  2249. JSONObject jSONObject = JSONObject.fromObject(map);
  2250. jSONArray.add(jSONObject);
  2251. }
  2252. json.put("RESULT", jSONArray);
  2253. }
  2254. }
  2255. return json.toString();
  2256. }
  2257. }
  2258. @Override
  2259. public String getConfirmStatus(String queryJson) throws Exception {
  2260. // TODO Auto-generated method stub
  2261. String company_code = null;
  2262. String company_code_list = null;
  2263. String company_name = null;
  2264. String device_code = null;
  2265. String device_code_list = null;
  2266. String time_start = null;
  2267. String time_end = null;
  2268. String clzt = null;
  2269. String COMMSTATUS = null;
  2270. String V_LOGINNAME = null;
  2271. String V_PASSWORD = null;
  2272. String hqlwhere = null;
  2273. String sqlwhere = null;
  2274. int E_STATUS=-1;
  2275. JSONObject q_json = null;
  2276. JSONArray jSONArray = new JSONArray();
  2277. JSONArray jSONArray2 = new JSONArray();
  2278. JSONObject json = new JSONObject();
  2279. List list2 = null,list3 = null,list4 = null;
  2280. json.put("action", "getConfirmStatus");
  2281. if(queryJson!=null) {
  2282. q_json = JSONObject.fromObject(queryJson);
  2283. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  2284. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  2285. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  2286. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  2287. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  2288. if(q_json.has("company_code")) {
  2289. if((q_json.optJSONObject("company_code")!=null)&&(q_json.optJSONObject("company_code").isArray())) {
  2290. JSONArray j_tmp = q_json.getJSONArray("company_code");
  2291. for(int i=0;i<j_tmp.size();i++) {
  2292. if(i==0)
  2293. company_code_list = j_tmp.getString(i);
  2294. else
  2295. company_code_list += ","+j_tmp.getString(i);
  2296. }
  2297. }else
  2298. company_code = q_json.getString("company_code");
  2299. }
  2300. if(q_json.has("device_code")) {
  2301. if(q_json.getJSONObject("device_code").isArray()) {
  2302. JSONArray j_tmp = q_json.getJSONArray("device_code");
  2303. for(int i=0;i<j_tmp.size();i++) {
  2304. if(i==0)
  2305. device_code_list = j_tmp.getString(i);
  2306. else
  2307. device_code_list += ","+j_tmp.getString(i);
  2308. }
  2309. }else
  2310. device_code = q_json.getString("device_code");
  2311. }
  2312. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  2313. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  2314. }
  2315. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  2316. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  2317. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  2318. if(list.size()>0) {
  2319. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  2320. E_STATUS = Integer.parseInt(o.getEStatus());
  2321. }
  2322. }
  2323. if(E_STATUS==1) {
  2324. if(company_name!=null) {
  2325. sqlwhere = chkhw(sqlwhere)+" company_name like '%"+company_name+"%' ";
  2326. hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
  2327. }
  2328. if(time_start!=null) {
  2329. sqlwhere = chkhw(sqlwhere)+" time >= '"+time_start+"' ";
  2330. hqlwhere = chkhw(hqlwhere)+" u.id."+" time >= '"+time_start+"' ";
  2331. }
  2332. if(time_end!=null) {
  2333. sqlwhere = chkhw(sqlwhere)+" time <= '"+time_end+"' ";
  2334. hqlwhere = chkhw(hqlwhere)+" u.id."+" time <= '"+time_end+"' ";
  2335. }
  2336. if(company_code!=null) {
  2337. sqlwhere = chkhw(sqlwhere)+" company_code like '%"+company_code+"%' ";
  2338. hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("company_code")+" like '%"+company_code+"%' ";
  2339. }
  2340. if(company_code_list!=null) {
  2341. sqlwhere = chkhw(sqlwhere)+" company_code in ("+company_code_list+") ";
  2342. hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  2343. }
  2344. if(device_code!=null) {
  2345. sqlwhere = chkhw(sqlwhere)+" device_code like '%"+device_code+"%' ";
  2346. hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("device_code")+" like '%"+device_code+"%' ";
  2347. }
  2348. if(device_code_list!=null) {
  2349. sqlwhere = chkhw(sqlwhere)+" device_code in ("+device_code_list+") ";
  2350. hqlwhere = chkhw(hqlwhere)+" u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  2351. }
  2352. if(clzt!=null) {
  2353. sqlwhere = chkhw(sqlwhere)+" clzt="+clzt+" ";
  2354. hqlwhere = chkhw(hqlwhere)+" u.id.clzt = "+clzt+" ";
  2355. }
  2356. String wheresql = null;
  2357. if(COMMSTATUS!=null) {
  2358. if(COMMSTATUS.equals("NO"))
  2359. wheresql = chkhw(sqlwhere)+" data1<>'U44' ";
  2360. else if(COMMSTATUS.equals("ONLY"))
  2361. wheresql = chkhw(sqlwhere)+" data1='U44' ";
  2362. else
  2363. wheresql = sqlwhere;
  2364. }else
  2365. wheresql = sqlwhere;
  2366. List list = ytiotVAlarmDao.queryBySQL(" select count(*) as count, sum(clzt) as sum from ytiot_v_hj "+((wheresql!=null)?wheresql:""));
  2367. if(list.size()>0) {
  2368. int NCount = 0;
  2369. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2370. if(NCount==0) {
  2371. Object[] objects = (Object[]) iterator.next();
  2372. Map map = new HashMap();
  2373. map.put("count", objects[0].toString());
  2374. map.put("sum", objects[1]==null?"0":objects[1].toString());
  2375. map.put("id", "fire_alarm");
  2376. list2 = ytiotVAlarmDao.HJQuery(hqlwhere, "order by u.id.id", "desc", "0", "1");
  2377. JSONObject jSONObject = JSONObject.fromObject(map);
  2378. jSONArray.add(jSONObject);
  2379. break;
  2380. }
  2381. NCount++;
  2382. }
  2383. }
  2384. wheresql = null;
  2385. if(COMMSTATUS!=null) {
  2386. if(COMMSTATUS.equals("NO"))
  2387. wheresql = chkhw(sqlwhere)+" ( data1<>'WP4' and data1<>'LL4' ) ";
  2388. else if(COMMSTATUS.equals("ONLY"))
  2389. wheresql = chkhw(sqlwhere)+" (data1='WP4' or data1='LL4' ) ";
  2390. else
  2391. wheresql = sqlwhere;
  2392. }else
  2393. wheresql = sqlwhere;
  2394. // System.out.println(" select count(*) as count, sum(clzt) as sum from ytiot_v_sj "+((wheresql!=null)?wheresql:""));
  2395. list = ytiotVAlarmDao.queryBySQL(" select count(*) as count, sum(clzt) as sum from ytiot_v_sj "+((wheresql!=null)?wheresql:""));
  2396. if(list.size()>0) {
  2397. int NCount = 0;
  2398. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2399. if(NCount==0) {
  2400. Object[] objects = (Object[]) iterator.next();
  2401. Map map = new HashMap();
  2402. map.put("count", objects[0].toString());
  2403. map.put("sum", objects[1]==null?"0":objects[1].toString());
  2404. map.put("id", "water_alarm");
  2405. list3 = ytiotVAlarmDao.SJQuery(hqlwhere, "order by u.id.id", "desc", "0", "1");
  2406. JSONObject jSONObject = JSONObject.fromObject(map);
  2407. jSONArray.add(jSONObject);
  2408. break;
  2409. }
  2410. NCount++;
  2411. }
  2412. }
  2413. wheresql = null;
  2414. if(COMMSTATUS!=null) {
  2415. if(COMMSTATUS.equals("NO"))
  2416. wheresql = chkhw(sqlwhere)+" status<>'44' ";
  2417. else if(COMMSTATUS.equals("ONLY"))
  2418. wheresql = chkhw(sqlwhere)+" status='44' ";
  2419. else
  2420. wheresql = sqlwhere;
  2421. }else
  2422. wheresql = sqlwhere;
  2423. list = ytiotVAlarmDao.queryBySQL(" select count(*) as count, sum(clzt) as sum from ytiot_v_rtu "+((wheresql!=null)?wheresql:""));
  2424. if(list.size()>0) {
  2425. int NCount = 0;
  2426. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2427. if(NCount==0) {
  2428. Object[] objects = (Object[]) iterator.next();
  2429. Map map = new HashMap();
  2430. map.put("count", objects[0].toString());
  2431. map.put("sum", objects[1]==null?"0":objects[1].toString());
  2432. map.put("id", "rtu_alarm");
  2433. list4 = ytiotVAlarmDao.RTUQuery(hqlwhere, "order by u.id.id", "desc", "0", "1");
  2434. JSONObject jSONObject = JSONObject.fromObject(map);
  2435. jSONArray.add(jSONObject);
  2436. break;
  2437. }
  2438. NCount++;
  2439. }
  2440. }
  2441. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  2442. for(int i=0;i<1;i++) {
  2443. YtiotVHjId HJid = new YtiotVHjId();
  2444. HJid.setTime(df.parse("1970-01-01 00:00:00"));
  2445. if(list2.size()>0) {
  2446. YtiotVHj hj = (YtiotVHj)list2.get(0);
  2447. HJid = hj.getId();
  2448. }
  2449. YtiotVSjId SJid = new YtiotVSjId();
  2450. SJid.setTime(df.parse("1970-01-01 00:00:00"));
  2451. if(list3.size()>0) {
  2452. YtiotVSj sj = (YtiotVSj)list3.get(0);
  2453. SJid = sj.getId();
  2454. }
  2455. YtiotVRtuId RTUid = new YtiotVRtuId();
  2456. RTUid.setTime(df.parse("1970-01-01 00:00:00"));
  2457. if(list4.size()>0) {
  2458. YtiotVRtu rtu = (YtiotVRtu)list4.get(0);
  2459. RTUid = rtu.getId();
  2460. }
  2461. if(HJid.getTime().getTime()>=SJid.getTime().getTime()) {
  2462. if(HJid.getTime().getTime()>=RTUid.getTime().getTime()) {
  2463. if(HJid.getTime().getTime()>0) {
  2464. Map map = new HashMap();
  2465. map.put("id", i+1);
  2466. map.put("company", HJid.getCompanyName());
  2467. map.put("name", HJid.getName()+((HJid.getData4().length()>0) ?(","+HJid.getData4()):""));
  2468. map.put("data", HJid.getData2());
  2469. map.put("time", df.format(HJid.getTime()));
  2470. map.put("clzt", HJid.getClzt()==1?"已处理":"未处理");
  2471. JSONObject jSONObject = JSONObject.fromObject(map);
  2472. jSONArray2.add(jSONObject);
  2473. }
  2474. // list2.remove(0);
  2475. }else {
  2476. if(RTUid.getTime().getTime()>0) {
  2477. Map map = new HashMap();
  2478. map.put("id", i+1);
  2479. map.put("company", RTUid.getCompanyName());
  2480. map.put("name", RTUid.getName());
  2481. map.put("data", RTUid.getData2());
  2482. map.put("time", df.format(RTUid.getTime()));
  2483. map.put("clzt", RTUid.getClzt()==1?"已处理":"未处理");
  2484. JSONObject jSONObject = JSONObject.fromObject(map);
  2485. jSONArray2.add(jSONObject);
  2486. }
  2487. // list4.remove(0);
  2488. }
  2489. }else {
  2490. if(SJid.getTime().getTime()>=RTUid.getTime().getTime()) {
  2491. if(SJid.getTime().getTime()>0) {
  2492. Map map = new HashMap();
  2493. map.put("id", i+1);
  2494. map.put("company", SJid.getCompanyName());
  2495. map.put("name", SJid.getName());
  2496. map.put("data", SJid.getData1().equals("WP1")?"低压"
  2497. :(SJid.getData1().equals("WP2")?"高压"
  2498. :(SJid.getData1().equals("WP3")?"故障"
  2499. :(SJid.getData1().equals("WP4")?"离线"
  2500. :(SJid.getData1().equals("WP0")?"正常"
  2501. :(SJid.getData1().equals("LL1")?"低压"
  2502. :(SJid.getData1().equals("LL2")?"高压"
  2503. :(SJid.getData1().equals("LL3")?"故障"
  2504. :(SJid.getData1().equals("LL0")?"正常":SJid.getData1())))))))));
  2505. map.put("time", df.format(SJid.getTime()));
  2506. map.put("clzt", SJid.getClzt()==1?"已处理":"未处理");
  2507. JSONObject jSONObject = JSONObject.fromObject(map);
  2508. jSONArray2.add(jSONObject);
  2509. }
  2510. // list3.remove(0);
  2511. }else {
  2512. if(RTUid.getTime().getTime()>0) {
  2513. Map map = new HashMap();
  2514. map.put("id", i+1);
  2515. map.put("company", RTUid.getCompanyName());
  2516. map.put("name", RTUid.getName());
  2517. map.put("data", RTUid.getData2());
  2518. map.put("time", df.format(RTUid.getTime()));
  2519. map.put("clzt", RTUid.getClzt()==1?"已处理":"未处理");
  2520. JSONObject jSONObject = JSONObject.fromObject(map);
  2521. jSONArray2.add(jSONObject);
  2522. }
  2523. // list4.remove(0);
  2524. }
  2525. }
  2526. }
  2527. json.put("ALARM_LIST", jSONArray2);
  2528. json.put("RESULT", jSONArray);
  2529. json.put("check", "true");
  2530. }else
  2531. json.put("check", "false");
  2532. return json.toString();
  2533. }
  2534. @Override
  2535. public String getConfirmStatusByDays(String queryJson) throws Exception {
  2536. // TODO Auto-generated method stub
  2537. String company_code = null;
  2538. String company_code_list = null;
  2539. String company_name = null;
  2540. String device_code = null;
  2541. String dwtype = null;
  2542. String device_code_list = null;
  2543. String time_start = null;
  2544. String time_end = null;
  2545. String COMMSTATUS = null;
  2546. String V_LOGINNAME = null;
  2547. String V_PASSWORD = null;
  2548. int E_STATUS=-1;
  2549. String sqlwhere = null;
  2550. JSONObject q_json = null;
  2551. JSONArray jSONArray = new JSONArray();
  2552. JSONObject json = new JSONObject();
  2553. List list2 = null,list3 = null,list4 = null;
  2554. json.put("action", "getConfirmStatusByDays");
  2555. if(queryJson!=null) {
  2556. q_json = JSONObject.fromObject(queryJson);
  2557. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  2558. dwtype = q_json.has("dwtype")?q_json.getString("dwtype"):null;
  2559. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  2560. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  2561. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  2562. if(q_json.has("company_code")) {
  2563. if((q_json.optJSONObject("company_code")!=null)&&(q_json.optJSONObject("company_code").isArray())) {
  2564. JSONArray j_tmp = q_json.getJSONArray("company_code");
  2565. for(int i=0;i<j_tmp.size();i++) {
  2566. if(i==0)
  2567. company_code_list = j_tmp.getString(i);
  2568. else
  2569. company_code_list += ","+j_tmp.getString(i);
  2570. }
  2571. }else
  2572. company_code = q_json.getString("company_code");
  2573. }
  2574. if(q_json.has("device_code")) {
  2575. if(q_json.getJSONObject("device_code").isArray()) {
  2576. JSONArray j_tmp = q_json.getJSONArray("device_code");
  2577. for(int i=0;i<j_tmp.size();i++) {
  2578. if(i==0)
  2579. device_code_list = j_tmp.getString(i);
  2580. else
  2581. device_code_list += ","+j_tmp.getString(i);
  2582. }
  2583. }else
  2584. device_code = q_json.getString("device_code");
  2585. }
  2586. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  2587. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  2588. }
  2589. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  2590. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  2591. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  2592. if(list.size()>0) {
  2593. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  2594. E_STATUS = Integer.parseInt(o.getEStatus());
  2595. }
  2596. }
  2597. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  2598. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  2599. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  2600. if(list.size()>0) {
  2601. for(int i=0;i<list.size();i++) {
  2602. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  2603. YtiotVUsercompanyId oid = o.getId();
  2604. if(i==0)
  2605. company_code_list = oid.getOwnerCode();
  2606. else
  2607. company_code_list += ","+oid.getOwnerCode();
  2608. }
  2609. }
  2610. }
  2611. if(E_STATUS==1) {
  2612. if(company_name!=null) {
  2613. sqlwhere = chkhw(sqlwhere)+" company_name like '%"+company_name+"%' ";
  2614. }
  2615. if(time_start!=null) {
  2616. sqlwhere = chkhw(sqlwhere)+" time >= '"+time_start+"' ";
  2617. }
  2618. if(time_end!=null) {
  2619. sqlwhere = chkhw(sqlwhere)+" time <= '"+time_end+"' ";
  2620. }
  2621. if(company_code!=null) {
  2622. sqlwhere = chkhw(sqlwhere)+" company_code like '%"+company_code+"%' ";
  2623. }
  2624. if(company_code_list!=null) {
  2625. sqlwhere = chkhw(sqlwhere)+" company_code in ("+company_code_list+") ";
  2626. }
  2627. if(device_code!=null) {
  2628. sqlwhere = chkhw(sqlwhere)+" device_code like '%"+device_code+"%' ";
  2629. }
  2630. if(device_code_list!=null) {
  2631. sqlwhere = chkhw(sqlwhere)+" device_code in ("+device_code_list+") ";
  2632. }
  2633. String wheresql = null;
  2634. JSONArray daylist = new JSONArray();
  2635. JSONArray countlist = new JSONArray();
  2636. JSONArray sumlist = new JSONArray();
  2637. JSONObject jSONObject2;
  2638. List list;
  2639. Map map2;
  2640. int count=0,sum=0;
  2641. if((dwtype==null)||(dwtype.equals("1"))) {
  2642. wheresql = null;
  2643. if(COMMSTATUS!=null) {
  2644. if(COMMSTATUS.equals("NO"))
  2645. wheresql = chkhw(sqlwhere)+" data1 <> 'U44' ";
  2646. else if(COMMSTATUS.equals("ONLY"))
  2647. wheresql = chkhw(sqlwhere)+" data1 = 'U44' ";
  2648. }
  2649. list = ytiotVAlarmDao.queryBySQL(" select DATE_FORMAT(ytiot_v_hj.time, \"%Y-%m-%d\") as days, count(*) as count, sum(clzt) as sum, company_name from ytiot_v_hj "+((wheresql!=null)?wheresql:"")+" group by days order by days desc");
  2650. if(list.size()>0) {
  2651. int Nrow = 0;
  2652. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2653. Object[] objects = (Object[]) iterator.next();
  2654. daylist.add(objects[0].toString());
  2655. String s_count = objects[1]==null?"0":objects[1].toString();
  2656. String s_sum = objects[2]==null?"0":objects[2].toString();
  2657. countlist.add(Integer.parseInt(s_count));
  2658. sumlist.add(Integer.parseInt(s_sum));
  2659. count += Integer.parseInt(s_count);
  2660. sum += Integer.parseInt(s_sum);
  2661. if((company_code!=null)&&(Nrow==0))
  2662. json.put("company_name", objects[3].toString());
  2663. Nrow++;
  2664. }
  2665. }
  2666. map2 = new HashMap();
  2667. map2.put("day_list", daylist);
  2668. map2.put("count_list", countlist);
  2669. map2.put("sum_list", sumlist);
  2670. map2.put("count", count);
  2671. map2.put("sum", sum);
  2672. map2.put("id", "fire_alarm");
  2673. jSONObject2 = JSONObject.fromObject(map2);
  2674. jSONArray.add(jSONObject2);
  2675. }
  2676. if((dwtype==null)||(dwtype.equals("2"))) {
  2677. wheresql = null;
  2678. if(COMMSTATUS!=null) {
  2679. if(COMMSTATUS.equals("NO"))
  2680. wheresql = chkhw(sqlwhere)+" ( data1<>'WP4' and data1<>'LL4' ) ";
  2681. else if(COMMSTATUS.equals("ONLY"))
  2682. wheresql = chkhw(sqlwhere)+" ( data1='WP4' or data1='LL4') ";
  2683. else
  2684. wheresql = sqlwhere;
  2685. }
  2686. list = ytiotVAlarmDao.queryBySQL(" select DATE_FORMAT(ytiot_v_sj.time, \"%Y-%m-%d\") as days, count(*) as count, sum(clzt) as sum, company_name from ytiot_v_sj "+((wheresql!=null)?wheresql:"")+" group by days order by days desc");
  2687. count=0;
  2688. sum=0;
  2689. daylist = new JSONArray();
  2690. countlist = new JSONArray();
  2691. sumlist = new JSONArray();
  2692. if(list.size()>0) {
  2693. int Nrow = 0;
  2694. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2695. Object[] objects = (Object[]) iterator.next();
  2696. daylist.add(objects[0].toString());
  2697. String s_count = objects[1]==null?"0":objects[1].toString();
  2698. String s_sum = objects[2]==null?"0":objects[2].toString();
  2699. countlist.add(Integer.parseInt(s_count));
  2700. sumlist.add(Integer.parseInt(s_sum));
  2701. count += Integer.parseInt(s_count);
  2702. sum += Integer.parseInt(s_sum);
  2703. if((company_code!=null)&&(Nrow==0))
  2704. json.put("company_name", objects[3].toString());
  2705. Nrow++;
  2706. }
  2707. }
  2708. map2 = new HashMap();
  2709. map2.put("day_list", daylist);
  2710. map2.put("count_list", countlist);
  2711. map2.put("sum_list", sumlist);
  2712. map2.put("count", count);
  2713. map2.put("sum", sum);
  2714. map2.put("id", "water_alarm");
  2715. jSONObject2 = JSONObject.fromObject(map2);
  2716. jSONArray.add(jSONObject2);
  2717. }
  2718. if((dwtype==null)||(dwtype.equals("6"))) {
  2719. wheresql = null;
  2720. if(COMMSTATUS!=null) {
  2721. if(COMMSTATUS.equals("NO"))
  2722. wheresql = chkhw(sqlwhere)+" status<>'44' ";
  2723. else if(COMMSTATUS.equals("ONLY"))
  2724. wheresql = chkhw(sqlwhere)+" status='44' ";
  2725. else
  2726. wheresql = sqlwhere;
  2727. }
  2728. list = ytiotVAlarmDao.queryBySQL(" select DATE_FORMAT(ytiot_v_rtu.time, \"%Y-%m-%d\") as days, count(*) as count, sum(clzt) as sum, company_name from ytiot_v_rtu "+((wheresql!=null)?wheresql:"")+" group by days order by days desc");
  2729. count=0;
  2730. sum=0;
  2731. daylist = new JSONArray();
  2732. countlist = new JSONArray();
  2733. sumlist = new JSONArray();
  2734. if(list.size()>0) {
  2735. int Nrow = 0;
  2736. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2737. Object[] objects = (Object[]) iterator.next();
  2738. daylist.add(objects[0].toString());
  2739. String s_count = objects[1]==null?"0":objects[1].toString();
  2740. String s_sum = objects[2]==null?"0":objects[2].toString();
  2741. countlist.add(Integer.parseInt(s_count));
  2742. sumlist.add(Integer.parseInt(s_sum));
  2743. count += Integer.parseInt(s_count);
  2744. sum += Integer.parseInt(s_sum);
  2745. if((company_code!=null)&&(Nrow==0))
  2746. json.put("company_name", objects[3].toString());
  2747. Nrow++;
  2748. }
  2749. }
  2750. map2 = new HashMap();
  2751. map2.put("day_list", daylist);
  2752. map2.put("count_list", countlist);
  2753. map2.put("sum_list", sumlist);
  2754. map2.put("count", count);
  2755. map2.put("sum", sum);
  2756. map2.put("id", "rtu_alarm");
  2757. jSONObject2 = JSONObject.fromObject(map2);
  2758. jSONArray.add(jSONObject2);
  2759. }
  2760. //视频监控统计数据
  2761. if((dwtype==null)||(dwtype.equals("16"))) {
  2762. wheresql = null;
  2763. if(COMMSTATUS!=null) {
  2764. if(COMMSTATUS.equals("NO"))
  2765. wheresql = chkhw(sqlwhere)+" status<>'44' ";
  2766. else if(COMMSTATUS.equals("ONLY"))
  2767. wheresql = chkhw(sqlwhere)+" status='44' ";
  2768. else
  2769. wheresql = sqlwhere;
  2770. }
  2771. list = ytiotVAlarmDao.queryBySQL(" select DATE_FORMAT(ytiot_v_video2017.time, \"%Y-%m-%d\") as days, count(*) as count, sum(clzt) as sum, company_name from ytiot_v_video2017 "+((wheresql!=null)?wheresql:"")+" group by days order by days desc");
  2772. count=0;
  2773. sum=0;
  2774. daylist = new JSONArray();
  2775. countlist = new JSONArray();
  2776. sumlist = new JSONArray();
  2777. if(list.size()>0) {
  2778. int Nrow = 0;
  2779. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2780. Object[] objects = (Object[]) iterator.next();
  2781. daylist.add(objects[0].toString());
  2782. String s_count = objects[1]==null?"0":objects[1].toString();
  2783. String s_sum = objects[2]==null?"0":objects[2].toString();
  2784. countlist.add(Integer.parseInt(s_count));
  2785. sumlist.add(Integer.parseInt(s_sum));
  2786. count += Integer.parseInt(s_count);
  2787. sum += Integer.parseInt(s_sum);
  2788. if((company_code!=null)&&(Nrow==0))
  2789. json.put("company_name", objects[3].toString());
  2790. Nrow++;
  2791. }
  2792. }
  2793. map2 = new HashMap();
  2794. map2.put("day_list", daylist);
  2795. map2.put("count_list", countlist);
  2796. map2.put("sum_list", sumlist);
  2797. map2.put("count", count);
  2798. map2.put("sum", sum);
  2799. map2.put("id", "rtu_alarm");
  2800. jSONObject2 = JSONObject.fromObject(map2);
  2801. jSONArray.add(jSONObject2);
  2802. }
  2803. //视频设备离线统计
  2804. if((dwtype==null)||(dwtype.equals("18"))) {
  2805. wheresql = null;
  2806. if(COMMSTATUS!=null) {
  2807. if(COMMSTATUS.equals("NO"))
  2808. wheresql = chkhw(sqlwhere)+" status<>'上线' ";
  2809. else if(COMMSTATUS.equals("ONLY"))
  2810. wheresql = chkhw(sqlwhere)+" status='离线' ";
  2811. else
  2812. wheresql = sqlwhere;
  2813. }
  2814. list = ytiotVAlarmDao.queryBySQL(" select DATE_FORMAT(ytiot_v_video2017s.time, \"%Y-%m-%d\") as days, count(*) as count, sum(clzt=1) as sum, company_name from ytiot_v_video2017s "+((wheresql!=null)?wheresql:"")+" group by days order by device_code desc");
  2815. count=0;
  2816. sum=0;
  2817. daylist = new JSONArray();
  2818. countlist = new JSONArray();
  2819. sumlist = new JSONArray();
  2820. if(list.size()>0) {
  2821. int Nrow = 0;
  2822. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2823. Object[] objects = (Object[]) iterator.next();
  2824. daylist.add(objects[0].toString());
  2825. String s_count = objects[1]==null?"0":objects[1].toString();
  2826. String s_sum = objects[2]==null?"0":objects[2].toString();
  2827. countlist.add(Integer.parseInt(s_count));
  2828. sumlist.add(Integer.parseInt(s_sum));
  2829. count += Integer.parseInt(s_count);
  2830. sum += Integer.parseInt(s_sum);
  2831. if((company_code!=null)&&(Nrow==0))
  2832. json.put("company_name", objects[3].toString());
  2833. Nrow++;
  2834. }
  2835. }
  2836. map2 = new HashMap();
  2837. map2.put("day_list", daylist);
  2838. map2.put("count_list", countlist);
  2839. map2.put("sum_list", sumlist);
  2840. map2.put("count", count);
  2841. map2.put("sum", sum);
  2842. map2.put("id", "rtu_alarm");
  2843. jSONObject2 = JSONObject.fromObject(map2);
  2844. jSONArray.add(jSONObject2);
  2845. }
  2846. //电梯监控统计数据
  2847. if((dwtype==null)||(dwtype.equals("17"))) {
  2848. wheresql = null;
  2849. if(COMMSTATUS!=null) {
  2850. if(COMMSTATUS.equals("NO"))
  2851. wheresql = chkhw(sqlwhere)+" ncmd<>'0' ";
  2852. else if(COMMSTATUS.equals("ONLY"))
  2853. wheresql = chkhw(sqlwhere)+" ncmd='0' ";
  2854. else
  2855. wheresql = sqlwhere;
  2856. }
  2857. list = ytiotVAlarmDao.queryBySQL(" select DATE_FORMAT(ytiot_v_lift.time, \"%Y-%m-%d\") as days, count(*) as count, sum(clzt) as sum, company_name from ytiot_v_lift "+((wheresql!=null)?wheresql:"")+" group by days order by days desc");
  2858. count=0;
  2859. sum=0;
  2860. daylist = new JSONArray();
  2861. countlist = new JSONArray();
  2862. sumlist = new JSONArray();
  2863. if(list.size()>0) {
  2864. int Nrow = 0;
  2865. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2866. Object[] objects = (Object[]) iterator.next();
  2867. daylist.add(objects[0].toString());
  2868. String s_count = objects[1]==null?"0":objects[1].toString();
  2869. String s_sum = objects[2]==null?"0":objects[2].toString();
  2870. countlist.add(Integer.parseInt(s_count));
  2871. sumlist.add(Integer.parseInt(s_sum));
  2872. count += Integer.parseInt(s_count);
  2873. sum += Integer.parseInt(s_sum);
  2874. if((company_code!=null)&&(Nrow==0))
  2875. json.put("company_name", objects[3].toString());
  2876. Nrow++;
  2877. }
  2878. }
  2879. map2 = new HashMap();
  2880. map2.put("day_list", daylist);
  2881. map2.put("count_list", countlist);
  2882. map2.put("sum_list", sumlist);
  2883. map2.put("count", count);
  2884. map2.put("sum", sum);
  2885. map2.put("id", "lift_alarm");
  2886. jSONObject2 = JSONObject.fromObject(map2);
  2887. jSONArray.add(jSONObject2);
  2888. }
  2889. if((dwtype==null)||(dwtype.equals("7"))) {
  2890. wheresql = null;
  2891. if(COMMSTATUS!=null) {
  2892. if(COMMSTATUS.equals("NO"))
  2893. wheresql = chkhw(sqlwhere)+" data1<>'EF9' ";
  2894. else if(COMMSTATUS.equals("ONLY"))
  2895. wheresql = chkhw(sqlwhere)+" data1='EF9' ";
  2896. else
  2897. wheresql = sqlwhere;
  2898. }
  2899. list = ytiotVAlarmDao.queryBySQL(" select DATE_FORMAT(ytiot_v_efire.time, \"%Y-%m-%d\") as days, count(*) as count, sum(clzt) as sum, company_name from ytiot_v_efire "+((wheresql!=null)?wheresql:"")+" group by days order by days desc");
  2900. count=0;
  2901. sum=0;
  2902. daylist = new JSONArray();
  2903. countlist = new JSONArray();
  2904. sumlist = new JSONArray();
  2905. if(list.size()>0) {
  2906. int Nrow = 0;
  2907. for(Iterator iterator = list.iterator();iterator.hasNext();){
  2908. Object[] objects = (Object[]) iterator.next();
  2909. daylist.add(objects[0].toString());
  2910. String s_count = objects[1]==null?"0":objects[1].toString();
  2911. String s_sum = objects[2]==null?"0":objects[2].toString();
  2912. countlist.add(Integer.parseInt(s_count));
  2913. sumlist.add(Integer.parseInt(s_sum));
  2914. count += Integer.parseInt(s_count);
  2915. sum += Integer.parseInt(s_sum);
  2916. if((company_code!=null)&&(Nrow==0))
  2917. json.put("company_name", objects[3].toString());
  2918. Nrow++;
  2919. }
  2920. }
  2921. map2 = new HashMap();
  2922. map2.put("day_list", daylist);
  2923. map2.put("count_list", countlist);
  2924. map2.put("sum_list", sumlist);
  2925. map2.put("count", count);
  2926. map2.put("sum", sum);
  2927. map2.put("id", "efire_alarm");
  2928. jSONObject2 = JSONObject.fromObject(map2);
  2929. jSONArray.add(jSONObject2);
  2930. }
  2931. json.put("RESULT", jSONArray);
  2932. json.put("check", "true");
  2933. }else {
  2934. json.put("check", "false");
  2935. }
  2936. return json.toString();
  2937. }
  2938. @Override
  2939. public String updateHj(String queryJson) throws Exception {
  2940. // TODO Auto-generated method stub
  2941. String V_LOGINNAME = null;
  2942. String V_PASSWORD = null;
  2943. int E_STATUS=-1;
  2944. String clwb = null;
  2945. String clnr = null;
  2946. String id = null;
  2947. String status = null;
  2948. String device_code = null;
  2949. String name = null;
  2950. String confirmAll = null;
  2951. String data4 = null;
  2952. String data2 = null;
  2953. String sql = null;
  2954. List list1 = null;
  2955. JSONObject q_json = null;
  2956. JSONObject json = new JSONObject();
  2957. json.put("action", "updateHj");
  2958. if(queryJson!=null) {
  2959. q_json = JSONObject.fromObject(queryJson);
  2960. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  2961. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  2962. id = q_json.has("id")?q_json.getString("id"):null;
  2963. status = q_json.has("status")?q_json.getString("status"):null;
  2964. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  2965. name = q_json.has("name")?q_json.getString("name"):null;
  2966. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  2967. data4 = q_json.has("data4")?q_json.getString("data4"):null;
  2968. data2 = q_json.has("data2")?q_json.getString("data2"):null;
  2969. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  2970. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  2971. }
  2972. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  2973. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  2974. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  2975. if(list.size()>0) {
  2976. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  2977. E_STATUS = Integer.parseInt(o.getEStatus());
  2978. }
  2979. }
  2980. System.out.println("用户测试"+V_LOGINNAME+V_PASSWORD);
  2981. System.out.println("接口火警测试"+E_STATUS);
  2982. if(E_STATUS==1) {
  2983. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(status!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  2984. String sqlwhere=null;
  2985. String hqlwhere=null;
  2986. if(Integer.parseInt(confirmAll)==1) {
  2987. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.status='"+status+"' and u.id.data4='"+data4+"' and u.id.data2='"+data2+"' and u.id.clzt=0";
  2988. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and status='"+status+"' and data4='"+data4+"' and data2='"+data2+"' and clzt=0";
  2989. }else {
  2990. hqlwhere = " where u.id.id="+id+" ";
  2991. sqlwhere = " where id="+id+" ";
  2992. }
  2993. int RowCount = ytiotVAlarmDao.getHJCount(hqlwhere);
  2994. System.out.println("火警测试1"+hqlwhere);
  2995. // System.out.println("火警测试2"+sqlwhere);
  2996. if(RowCount>0) {
  2997. ytiotVAlarmDao.execSQL(" update ytiot_v_hj2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  2998. if (Integer.parseInt(confirmAll)==0){
  2999. HashMap<String, Object> map = new HashMap<>();
  3000. if(V_LOGINNAME.equals("ypxy")) {
  3001. map.put("SubType",3);
  3002. }else {
  3003. map.put("SubType",1);
  3004. }
  3005. map.put("DeviceId",device_code);
  3006. map.put("InsertId",id);
  3007. map.put("Confirmed",true);
  3008. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3009. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3010. // System.out.println("jsonObject = " + jsonObject);
  3011. }else {
  3012. sql = "select id,company_code from ytiot_v_hj where device_code='"+device_code+"' and name='"+name+"' and status='"+status+"' and data4='"+data4+"' and data2='"+data2+"' and clzt=1 order by time desc LIMIT 1";
  3013. list1 = ytiotVAlarmDao.queryBySQL(sql);
  3014. System.out.println("ceshi19950802"+sql);
  3015. if(list1.size()>0) {
  3016. System.out.println("ceshi1995");
  3017. for(int i=0;i<list1.size();i++) {
  3018. Object [] row = (Object [])list1.get(i);
  3019. HashMap<String, Object> map = new HashMap<>();
  3020. if(V_LOGINNAME.equals("ypxy")) {
  3021. map.put("SubType",3);
  3022. }else {
  3023. map.put("SubType",1);
  3024. }
  3025. map.put("DeviceId",device_code);
  3026. map.put("InsertId",row[0].toString());
  3027. map.put("Confirmed",true);
  3028. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3029. System.out.println("ceshi19950802"+row[0].toString());
  3030. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3031. }
  3032. }
  3033. }
  3034. json.put("activerow", RowCount);
  3035. json.put("success", "true");
  3036. // DefaultHttpClient httpclient = new DefaultHttpClient();
  3037. // HttpPost httppost = new HttpPost("http://localhost:8011/testServlet");
  3038. // List<BasicNameValuePair> nvps = new ArrayList<BasicNameValuePair>();
  3039. // nvps.add(new BasicNameValuePair("content", "11111111")); // 参数
  3040. // nvps.add(new BasicNameValuePair("path", "D:/file")); // 参数
  3041. // nvps.add(new BasicNameValuePair("name", "8")); // 参数
  3042. // nvps.add(new BasicNameValuePair("age", "9")); // 参数
  3043. // nvps.add(new BasicNameValuePair("username", "wzt")); // 参数
  3044. //
  3045. // httppost.setEntity((HttpEntity) new UrlEncodedFormEntity(nvps, HTTP.UTF_8)); // 设置参数给Post
  3046. // HttpResponse response = httpclient.execute(httppost);
  3047. // HttpEntity entity = response.getEntity();
  3048. // System.out.println(response.getStatusLine());
  3049. // if (entity != null) {
  3050. // System.out.println("Response content length: "
  3051. // + entity.getContentLength());
  3052. // }
  3053. //
  3054. // BufferedReader reader = new BufferedReader(new InputStreamReader(
  3055. // entity.getContent(), "UTF-8"));
  3056. //
  3057. // String line = null;
  3058. // while ((line = reader.readLine()) != null) {
  3059. // System.out.println(line);
  3060. // }
  3061. // if (entity != null) {
  3062. // entity.consumeContent();
  3063. // }
  3064. }else {
  3065. json.put("success", "false");
  3066. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3067. }
  3068. }else {
  3069. json.put("success", "false");
  3070. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3071. }
  3072. }else {
  3073. json.put("success", "false");
  3074. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3075. }
  3076. return json.toString();
  3077. }
  3078. @Override
  3079. public String updateEf(String queryJson) throws Exception {
  3080. // TODO Auto-generated method stub
  3081. String V_LOGINNAME = null;
  3082. String V_PASSWORD = null;
  3083. int E_STATUS=-1;
  3084. String clwb = null;
  3085. String clnr = null;
  3086. String id = null;
  3087. String status = null;
  3088. String device_code = null;
  3089. String name = null;
  3090. String confirmAll = null;
  3091. String data4 = null;
  3092. String data2 = null;
  3093. JSONObject q_json = null;
  3094. JSONObject json = new JSONObject();
  3095. json.put("action", "updateEf");
  3096. if(queryJson!=null) {
  3097. q_json = JSONObject.fromObject(queryJson);
  3098. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  3099. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  3100. id = q_json.has("id")?q_json.getString("id"):null;
  3101. status = q_json.has("status")?q_json.getString("status"):null;
  3102. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  3103. name = q_json.has("name")?q_json.getString("name"):null;
  3104. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  3105. data4 = q_json.has("data4")?q_json.getString("data4"):null;
  3106. data2 = q_json.has("data2")?q_json.getString("data2"):null;
  3107. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3108. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  3109. }
  3110. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  3111. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  3112. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  3113. if(list.size()>0) {
  3114. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  3115. E_STATUS = Integer.parseInt(o.getEStatus());
  3116. }
  3117. }
  3118. if(E_STATUS==1) {
  3119. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(status!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  3120. String sqlwhere=null;
  3121. String hqlwhere=null;
  3122. if(Integer.parseInt(confirmAll)==1) {
  3123. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.clzt=0";
  3124. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and clzt=0";
  3125. }else {
  3126. hqlwhere = " where u.id.id="+id+" ";
  3127. sqlwhere = " where id="+id+" ";
  3128. }
  3129. int RowCount = ytiotVAlarmDao.getEFireCount(hqlwhere);
  3130. // System.out.println(sqlwhere);
  3131. if(RowCount>0) {
  3132. ytiotVAlarmDao.execSQL(" update ytiot_v_efire2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3133. if (Integer.parseInt(confirmAll)==0){
  3134. HashMap<String, Object> map = new HashMap<>();
  3135. map.put("SubType",7);
  3136. map.put("DeviceId",device_code);
  3137. map.put("InsertId",id);
  3138. map.put("Confirmed",true);
  3139. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3140. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3141. // System.out.println("jsonObject = " + jsonObject);
  3142. }else {
  3143. String sql = "select id,company_code from ytiot_v_efire where device_code='"+device_code+"' and name='"+name+"' and clzt=1 order by time desc LIMIT 1";
  3144. List list1 = ytiotVAlarmDao.queryBySQL(sql);
  3145. if(list1.size()>0) {
  3146. for(int i=0;i<list1.size();i++) {
  3147. Object [] row = (Object [])list1.get(i);
  3148. HashMap<String, Object> map = new HashMap<>();
  3149. map.put("SubType",7);
  3150. map.put("DeviceId",device_code);
  3151. map.put("InsertId",row[0].toString());
  3152. map.put("Confirmed",true);
  3153. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3154. System.out.println("ceshi19950802"+row[0].toString());
  3155. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3156. }
  3157. }
  3158. }
  3159. json.put("activerow", RowCount);
  3160. json.put("success", "true");
  3161. }else {
  3162. json.put("success", "false");
  3163. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3164. }
  3165. }else {
  3166. json.put("success", "false");
  3167. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3168. }
  3169. }else {
  3170. json.put("success", "false");
  3171. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3172. }
  3173. return json.toString();
  3174. }
  3175. @Override
  3176. public String updateSj(String queryJson) throws Exception {
  3177. // TODO Auto-generated method stub
  3178. String V_LOGINNAME = null;
  3179. String V_PASSWORD = null;
  3180. int E_STATUS=-1;
  3181. String clwb = null;
  3182. String clnr = null;
  3183. String id = null;
  3184. String status = null;
  3185. String device_code = null;
  3186. String name = null;
  3187. String confirmAll = null;
  3188. JSONObject q_json = null;
  3189. JSONObject json = new JSONObject();
  3190. json.put("action", "updateSj");
  3191. if(queryJson!=null) {
  3192. q_json = JSONObject.fromObject(queryJson);
  3193. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  3194. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  3195. id = q_json.has("id")?q_json.getString("id"):null;
  3196. status = q_json.has("status")?q_json.getString("status"):null;
  3197. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  3198. name = q_json.has("name")?q_json.getString("name"):null;
  3199. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  3200. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3201. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  3202. }
  3203. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  3204. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  3205. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  3206. if(list.size()>0) {
  3207. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  3208. E_STATUS = Integer.parseInt(o.getEStatus());
  3209. }
  3210. }
  3211. if(E_STATUS==1) {
  3212. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(status!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  3213. String sqlwhere=null;
  3214. String hqlwhere=null;
  3215. if(Integer.parseInt(confirmAll)==1) {
  3216. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.status='"+status+"' and u.id.clzt=0";
  3217. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and status='"+status+"' and clzt=0";
  3218. }else {
  3219. hqlwhere = " where u.id.id="+id+" ";
  3220. sqlwhere = " where id="+id+" ";
  3221. }
  3222. int RowCount = ytiotVAlarmDao.getSJCount(hqlwhere);
  3223. // System.out.println(sqlwhere);
  3224. if(RowCount>0) {
  3225. ytiotVAlarmDao.execSQL(" update ytiot_v_sj2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3226. if (Integer.parseInt(confirmAll)==0){
  3227. HashMap<String, Object> map = new HashMap<>();
  3228. map.put("SubType",2);
  3229. map.put("DeviceId",device_code);
  3230. map.put("InsertId",id);
  3231. map.put("Confirmed",true);
  3232. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3233. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3234. // System.out.println("jsonObject = " + jsonObject);
  3235. }else {
  3236. String sql = "select id,company_code from ytiot_v_sj where device_code='"+device_code+"' and name='"+name+"' and status='"+status+"' and clzt=1 order by time desc LIMIT 1";
  3237. List list1 = ytiotVAlarmDao.queryBySQL(sql);
  3238. if(list1.size()>0) {
  3239. for(int i=0;i<list1.size();i++) {
  3240. Object [] row = (Object [])list1.get(i);
  3241. HashMap<String, Object> map = new HashMap<>();
  3242. map.put("SubType",2);
  3243. map.put("DeviceId",device_code);
  3244. map.put("InsertId",row[0].toString());
  3245. map.put("Confirmed",true);
  3246. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3247. System.out.println("ceshi19950802"+row[0].toString());
  3248. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3249. }
  3250. }
  3251. }
  3252. json.put("activerow", RowCount);
  3253. json.put("success", "true");
  3254. }else {
  3255. json.put("success", "false");
  3256. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3257. }
  3258. }else {
  3259. json.put("success", "false");
  3260. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3261. }
  3262. }else {
  3263. json.put("success", "false");
  3264. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3265. }
  3266. return json.toString();
  3267. }
  3268. @Override
  3269. public String updateRtu(String queryJson) throws Exception {
  3270. // TODO Auto-generated method stub
  3271. String V_LOGINNAME = null;
  3272. String V_PASSWORD = null;
  3273. int E_STATUS=-1;
  3274. String clwb = null;
  3275. String clnr = null;
  3276. String id = null;
  3277. String status = null;
  3278. String device_code = null;
  3279. String name = null;
  3280. String confirmAll = null;
  3281. JSONObject q_json = null;
  3282. JSONObject json = new JSONObject();
  3283. json.put("action", "updateSj");
  3284. if(queryJson!=null) {
  3285. q_json = JSONObject.fromObject(queryJson);
  3286. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  3287. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  3288. id = q_json.has("id")?q_json.getString("id"):null;
  3289. status = q_json.has("status")?q_json.getString("status"):null;
  3290. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  3291. name = q_json.has("name")?q_json.getString("name"):null;
  3292. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  3293. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3294. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  3295. }
  3296. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  3297. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  3298. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  3299. if(list.size()>0) {
  3300. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  3301. E_STATUS = Integer.parseInt(o.getEStatus());
  3302. }
  3303. }
  3304. if(E_STATUS==1) {
  3305. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(status!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  3306. String sqlwhere=null;
  3307. String hqlwhere=null;
  3308. if(Integer.parseInt(confirmAll)==1) {
  3309. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.status='"+status+"' and u.id.clzt=0";
  3310. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and status='"+status+"' and clzt=0";
  3311. }else {
  3312. hqlwhere = " where u.id.id="+id+" ";
  3313. sqlwhere = " where id="+id+" ";
  3314. }
  3315. int RowCount = ytiotVAlarmDao.getRTUCount(hqlwhere);
  3316. // System.out.println(sqlwhere);
  3317. if(RowCount>0) {
  3318. ytiotVAlarmDao.execSQL(" update ytiot_v_rtu2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3319. json.put("activerow", RowCount);
  3320. json.put("success", "true");
  3321. }else {
  3322. json.put("success", "false");
  3323. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3324. }
  3325. }else {
  3326. json.put("success", "false");
  3327. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3328. }
  3329. }else {
  3330. json.put("success", "false");
  3331. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3332. }
  3333. return json.toString();
  3334. }
  3335. @Override
  3336. public String getVideoList(String queryJson) throws Exception {
  3337. // TODO Auto-generated method stub
  3338. String company_code = null;
  3339. String sql = null;
  3340. JSONObject q_json = null;
  3341. JSONArray jSONArray = new JSONArray();
  3342. JSONObject json = new JSONObject();
  3343. List list = null;
  3344. json.put("action", "getVideoList");
  3345. if(queryJson!=null) {
  3346. q_json = JSONObject.fromObject(queryJson);
  3347. company_code = q_json.has("company_code")?q_json.getString("company_code"):null;
  3348. }
  3349. if(company_code!=null) {
  3350. sql = "select device_code, dev_name, company, rtsp_path, comm_type from ytiot_v_video where company_code='"+company_code+"'";
  3351. list = ytiotVAlarmDao.queryBySQL(sql);
  3352. if(list.size()>0) {
  3353. for(int i=0;i<list.size();i++) {
  3354. Object [] row = (Object [])list.get(i);
  3355. Map map = new HashMap();
  3356. if(i==0)
  3357. json.put("company", row[2].toString());
  3358. map.put("device_code", row[0].toString());
  3359. map.put("dev_name", row[1].toString());
  3360. map.put("rtsp_path", row[3].toString());
  3361. map.put("comm_type", row[4].toString());
  3362. JSONObject jSONObject = JSONObject.fromObject(map);
  3363. jSONArray.add(jSONObject);
  3364. }
  3365. }else
  3366. json.put("company", "");
  3367. json.put("RESULT", jSONArray);
  3368. }
  3369. return json.toString();
  3370. }
  3371. /**
  3372. * 视频状态修改
  3373. * @param queryJson
  3374. * @return
  3375. * @throws Exception
  3376. */
  3377. @Override
  3378. public String updateVideo(String queryJson) throws Exception {
  3379. String V_LOGINNAME = null;
  3380. String V_PASSWORD = null;
  3381. int E_STATUS=-1;
  3382. String clwb = null;
  3383. String clnr = null;
  3384. String id = null;
  3385. String status = null;
  3386. String device_code = null;
  3387. String name = null;
  3388. String confirmAll = null;
  3389. JSONObject q_json = null;
  3390. JSONObject json = new JSONObject();
  3391. json.put("action", "updateSj");
  3392. if(queryJson!=null) {
  3393. q_json = JSONObject.fromObject(queryJson);
  3394. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  3395. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  3396. id = q_json.has("id")?q_json.getString("id"):null;
  3397. status = q_json.has("status")?q_json.getString("status"):null;
  3398. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  3399. name = q_json.has("name")?q_json.getString("name"):null;
  3400. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  3401. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3402. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  3403. }
  3404. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  3405. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  3406. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  3407. if(list.size()>0) {
  3408. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  3409. E_STATUS = Integer.parseInt(o.getEStatus());
  3410. }
  3411. }
  3412. if(E_STATUS==1) {
  3413. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(status!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  3414. String sqlwhere=null;
  3415. String hqlwhere=null;
  3416. if(Integer.parseInt(confirmAll)==1) {
  3417. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.status='"+status+"' ";
  3418. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and status='"+status+"' ";
  3419. }else {
  3420. hqlwhere = " where u.id.id="+id+" ";
  3421. sqlwhere = " where id="+id+" ";
  3422. }
  3423. int RowCount = ytiotVAlarmDao.getVideoCount(hqlwhere);
  3424. // System.out.println(sqlwhere);
  3425. if(RowCount>0) {
  3426. ytiotVAlarmDao.execSQL(" update ytiot_v_video20172 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3427. json.put("activerow", RowCount);
  3428. json.put("success", "true");
  3429. }else {
  3430. json.put("success", "false");
  3431. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3432. }
  3433. }else {
  3434. json.put("success", "false");
  3435. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3436. }
  3437. }else {
  3438. json.put("success", "false");
  3439. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3440. }
  3441. return json.toString();
  3442. }
  3443. /**
  3444. * 视频设备状态处理
  3445. * @param queryJson
  3446. * @return
  3447. * @throws Exception
  3448. */
  3449. @Override
  3450. public String updateVideoOffline(String queryJson) throws Exception {
  3451. String V_LOGINNAME = null;
  3452. String V_PASSWORD = null;
  3453. int E_STATUS=-1;
  3454. String clwb = null;
  3455. String clnr = null;
  3456. String id = null;
  3457. String status = null;
  3458. String device_code = null;
  3459. String name = null;
  3460. String confirmAll = null;
  3461. JSONObject q_json = null;
  3462. JSONObject json = new JSONObject();
  3463. json.put("action", "updateSj");
  3464. if(queryJson!=null) {
  3465. q_json = JSONObject.fromObject(queryJson);
  3466. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  3467. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  3468. id = q_json.has("id")?q_json.getString("id"):null;
  3469. status = q_json.has("status")?q_json.getString("status"):null;
  3470. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  3471. name = q_json.has("name")?q_json.getString("name"):null;
  3472. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  3473. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3474. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  3475. }
  3476. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  3477. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  3478. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  3479. if(list.size()>0) {
  3480. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  3481. E_STATUS = Integer.parseInt(o.getEStatus());
  3482. }
  3483. }
  3484. if(E_STATUS==1) {
  3485. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(status!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  3486. String sqlwhere=null;
  3487. String hqlwhere=null;
  3488. if(Integer.parseInt(confirmAll)==1) {
  3489. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.status='"+status+"' ";
  3490. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and status='"+status+"' ";
  3491. }else {
  3492. hqlwhere = " where u.id.id="+id+" ";
  3493. sqlwhere = " where id="+id+" ";
  3494. }
  3495. int RowCount = ytiotVAlarmDao.getVideoCount(hqlwhere);
  3496. if(RowCount>0) {
  3497. ytiotVAlarmDao.execSQL(" update ytiot_v_video2017s2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3498. json.put("activerow", RowCount);
  3499. json.put("success", "true");
  3500. }else {
  3501. json.put("success", "false");
  3502. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3503. }
  3504. }else {
  3505. json.put("success", "false");
  3506. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3507. }
  3508. }else {
  3509. json.put("success", "false");
  3510. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3511. }
  3512. return json.toString();
  3513. }
  3514. /**
  3515. * 获取电梯信息
  3516. */
  3517. @Override
  3518. public String getLiftVList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  3519. // TODO Auto-generated method stub
  3520. String address = null;
  3521. String clzt = null;
  3522. String company_code = null;
  3523. String company_code_list = null;
  3524. String Company_Code_List = null;
  3525. String company_name = null;
  3526. String device_code = null;
  3527. String device_code_list = null;
  3528. String time_start = null;
  3529. String time_end = null;
  3530. String COMMSTATUS = null;
  3531. String V_LOGINNAME = null;
  3532. String hqlwhere = null;
  3533. String order = null;
  3534. String dir = null;
  3535. String Start = null;
  3536. String Limit = null;
  3537. String Page = null;
  3538. String order_str = null;
  3539. JSONObject q_json = null;
  3540. JSONArray Sort = null;
  3541. JSONArray jSONArray = new JSONArray();
  3542. JSONObject json = new JSONObject();
  3543. json.put("action", "getLiftVList");
  3544. if(queryJson!=null) {
  3545. q_json = JSONObject.fromObject(queryJson);
  3546. address = q_json.has("address")?q_json.getString("address"):null;
  3547. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3548. clzt = q_json.has("clzt")?q_json.getString("clzt"):null;
  3549. COMMSTATUS = q_json.has("COMMSTATUS")?q_json.getString("COMMSTATUS"):null;
  3550. if(q_json.has("company_code")) {
  3551. if((q_json.optJSONObject("company_code")!=null)
  3552. &&(q_json.optJSONObject("company_code").isArray())) {
  3553. JSONArray j_tmp = q_json.getJSONArray("company_code");
  3554. for(int i=0;i<j_tmp.size();i++) {
  3555. String tmp = j_tmp.getString(i);
  3556. if(i==0)
  3557. company_code_list = tmp;
  3558. else
  3559. company_code_list += ","+tmp;
  3560. }
  3561. }else
  3562. company_code = q_json.getString("company_code");
  3563. }
  3564. company_name = q_json.has("company_name")?q_json.getString("company_name"):null;
  3565. if(q_json.has("device_code")) {
  3566. if((q_json.optJSONObject("device_code")!=null)
  3567. &&(q_json.optJSONObject("device_code").isArray())){
  3568. JSONArray j_tmp = q_json.getJSONArray("device_code");
  3569. for(int i=0;i<j_tmp.size();i++) {
  3570. String tmp = j_tmp.getString(i);
  3571. if(i==0)
  3572. device_code_list = tmp;
  3573. else
  3574. device_code_list += ","+tmp;
  3575. }
  3576. }else
  3577. device_code = q_json.getString("device_code");
  3578. }
  3579. time_start = q_json.has("time_start")?q_json.getString("time_start"):null;
  3580. time_end = q_json.has("time_end")?q_json.getString("time_end"):null;
  3581. }
  3582. if(sort!=null) {
  3583. Sort = JSONArray.fromObject(sort);
  3584. if((Sort.isArray())&&(Sort.size()>0)) {
  3585. JSONObject s_json = Sort.getJSONObject(0);
  3586. order = s_json.has("property")?s_json.getString("property"):order;
  3587. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  3588. }
  3589. json.put("sort", sort);
  3590. }
  3591. Start = start;
  3592. Limit = limit;
  3593. Page = page;
  3594. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  3595. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  3596. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  3597. if(list.size()>0) {
  3598. for(int i=0;i<list.size();i++) {
  3599. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  3600. YtiotVUsercompanyId oid = o.getId();
  3601. if(i==0)
  3602. Company_Code_List = oid.getOwnerCode();
  3603. else
  3604. Company_Code_List += ","+oid.getOwnerCode();
  3605. }
  3606. }
  3607. }
  3608. if(address!=null)
  3609. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("address")+" like '%"+address+"' ";
  3610. if((clzt!=null)&&(clzt.length()>0))
  3611. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("clzt")+" = "+clzt+" ";
  3612. if(Company_Code_List!=null)
  3613. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+Company_Code_List+") ";
  3614. else {
  3615. if(company_code!=null)
  3616. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = "+company_code+" ";
  3617. if(company_code_list!=null)
  3618. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  3619. }
  3620. // if(company_code!=null)
  3621. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" = '"+company_code+"' ";
  3622. // if(company_code_list!=null)
  3623. // hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_code")+" in ("+company_code_list+") ";
  3624. if(company_name!=null)
  3625. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("company_name")+" like '%"+company_name+"%' ";
  3626. if(device_code!=null)
  3627. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" = '"+device_code+"' ";
  3628. if(device_code_list!=null)
  3629. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("device_code")+" in ("+device_code_list+") ";
  3630. if(time_start!=null)
  3631. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" >= '"+time_start+"' ";
  3632. if(time_end!=null)
  3633. hqlwhere = chkhw(hqlwhere) + " u.id."+fieldname("time")+" <= '"+time_end+"' ";
  3634. if(COMMSTATUS!=null) {
  3635. if(COMMSTATUS.equals("NO"))
  3636. hqlwhere = chkhw(hqlwhere)+"( u.id.ncmd <> '0' ) ";
  3637. else if(COMMSTATUS.equals("ONLY"))
  3638. hqlwhere = chkhw(hqlwhere)+" ( u.id.ncmd = '0' ) ";
  3639. }
  3640. if(order!=null)
  3641. order_str = " order by u.id."+fieldname(order);
  3642. else
  3643. order_str = " order by u.id.id ";
  3644. int totalCount = ytiotVAlarmDao.getLiftCount(hqlwhere);
  3645. json.put("totalCount", totalCount);
  3646. if(Start!=null){
  3647. if(Integer.parseInt(Start)>totalCount){
  3648. Start = "0";
  3649. Page = "0";
  3650. }else if(page==null)
  3651. Page="0";
  3652. }else{
  3653. Start = "0";
  3654. Page = "0";
  3655. }
  3656. json.put("page", Page);
  3657. json.put("start", Start);
  3658. json.put("limit", Limit);
  3659. if(totalCount>0) {
  3660. List<?> ulist = ytiotVUserphoneDao.query(null, null, null, null, null);
  3661. List<?> list = ytiotVAlarmDao.LiftQuery(hqlwhere, order_str, dir, Start, Limit);
  3662. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  3663. if(list.size()>0) {
  3664. for(int i=0;i<list.size();i++) {
  3665. YtiotVLift hj = (YtiotVLift)list.get(i);
  3666. YtiotVLiftId id = hj.getId();
  3667. String cl_name = "";
  3668. if((company_code!=null)&&(i==0))
  3669. json.put("company_name", id.getCompanyName());
  3670. Map<String, Comparable> map = new HashMap<String, Comparable>();
  3671. map.put("orderIdx", Integer.parseInt(Start)+i+1);
  3672. map.put("address", id.getAddress());
  3673. map.put("cldh", id.getCldh());
  3674. map.put("cllx", id.getCllx());
  3675. map.put("cllxr", id.getCllxr());
  3676. map.put("clnr", id.getClnr());
  3677. map.put("clr", id.getClr());
  3678. map.put("clwb", id.getClwb());
  3679. map.put("clzt", id.getClzt()==0?"未处理":"已处理");
  3680. map.put("clsj", df.format(id.getClsj()));
  3681. map.put("company_code", id.getCompanyCode());
  3682. map.put("company_name", id.getCompanyName());
  3683. map.put("data1", id.getData1());
  3684. map.put("data2", id.getData2());
  3685. map.put("data3", id.getData3());
  3686. map.put("data4", id.getData4());
  3687. map.put("data5", id.getData5());
  3688. if(id.getClzt()==1)
  3689. map.put("clsj", df.format(id.getClsj()));
  3690. else
  3691. map.put("clsj", "");
  3692. map.put("device_code", id.getDeviceCode());
  3693. map.put("id", id.getId());
  3694. map.put("name", id.getName());
  3695. map.put("ncmd", id.getNcmd());
  3696. map.put("port", id.getPort());
  3697. map.put("position", id.getPosition());
  3698. map.put("status", id.getStatus());
  3699. map.put("time", df.format(id.getTime()));
  3700. map.put("vidoe", id.getVideo());
  3701. //报告内容
  3702. map.put("fullname", id.getName()+","+id.getData4());
  3703. map.put("data", id.getNcmd().equals("0")?"离线":"在线" );
  3704. if((id.getClr().length()>0)
  3705. &&(ulist.size()>0)){
  3706. for(int j=0;j<ulist.size();j++) {
  3707. YtiotVUserphone po = (YtiotVUserphone)ulist.get(j);
  3708. YtiotVUserphoneId poid = po.getId();
  3709. if(id.getClr().equals(poid.getPhone())) {
  3710. cl_name = poid.getUsername();
  3711. break;
  3712. }
  3713. }
  3714. }
  3715. map.put("clr_name", cl_name.length()>0?cl_name:id.getClr());
  3716. JSONObject jSONObject = JSONObject.fromObject(map);
  3717. jSONArray.add(jSONObject);
  3718. }
  3719. json.put("RESULT", jSONArray);
  3720. }
  3721. }
  3722. return json.toString();
  3723. }
  3724. /**
  3725. * 处理电梯
  3726. */
  3727. @Override
  3728. public String updateLift(String queryJson) throws Exception {
  3729. // TODO Auto-generated method stub
  3730. String V_LOGINNAME = null;
  3731. String V_PASSWORD = null;
  3732. int E_STATUS=-1;
  3733. String clwb = null;
  3734. String clnr = null;
  3735. String id = null;
  3736. String status = null;
  3737. String ncmd = null;
  3738. String device_code = null;
  3739. String name = null;
  3740. String confirmAll = null;
  3741. JSONObject q_json = null;
  3742. JSONObject json = new JSONObject();
  3743. json.put("action", "updateSj");
  3744. if(queryJson!=null) {
  3745. q_json = JSONObject.fromObject(queryJson);
  3746. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  3747. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  3748. id = q_json.has("id")?q_json.getString("id"):null;
  3749. status = q_json.has("status")?q_json.getString("status"):null;
  3750. ncmd = q_json.has("ncmd")?q_json.getString("ncmd"):null;
  3751. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  3752. name = q_json.has("name")?q_json.getString("name"):null;
  3753. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  3754. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3755. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  3756. System.out.println("ncmb+++"+ncmd);
  3757. }
  3758. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  3759. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  3760. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  3761. if(list.size()>0) {
  3762. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  3763. E_STATUS = Integer.parseInt(o.getEStatus());
  3764. }
  3765. }
  3766. if(E_STATUS==1) {
  3767. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(ncmd!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  3768. String sqlwhere=null;
  3769. String hqlwhere=null;
  3770. //是否离线状态 and 批量
  3771. if(Integer.parseInt(confirmAll)==1) {
  3772. if (Integer.parseInt(ncmd) == 0) {
  3773. //离线
  3774. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.ncmd='"+ncmd+"' and clzt='0' ";
  3775. //根据设备编号 状态 名称 进行批量修改
  3776. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and ncmd='"+ncmd+"' and clzt='0' ";
  3777. System.out.println("hqlwhere==="+hqlwhere);
  3778. System.out.println("sqlwhere===="+sqlwhere);
  3779. }else {
  3780. //在线
  3781. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.ncmd<>'0' and clzt='0' ";
  3782. //根据设备编号 状态 名称 进行批量修改
  3783. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and ncmd<> '0' and clzt='0' ";
  3784. System.out.println("hqlwhere222==="+hqlwhere);
  3785. System.out.println("sqlwhere222===="+sqlwhere);
  3786. }
  3787. }else {
  3788. hqlwhere = " where u.id.id="+id+" ";
  3789. sqlwhere = " where id="+id+" ";
  3790. }
  3791. int RowCount = ytiotVAlarmDao.getLiftCount(hqlwhere);
  3792. // System.out.println(sqlwhere);
  3793. if(RowCount>0) {
  3794. ytiotVAlarmDao.execSQL(" update ytiot_v_lift2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3795. json.put("activerow", RowCount);
  3796. json.put("success", "true");
  3797. }else {
  3798. json.put("success", "false");
  3799. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3800. }
  3801. }else {
  3802. json.put("success", "false");
  3803. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3804. }
  3805. }else {
  3806. json.put("success", "false");
  3807. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3808. }
  3809. return json.toString();
  3810. }
  3811. @Override
  3812. public String updateIndexAlarm(String queryJson) throws Exception {
  3813. // TODO Auto-generated method stub
  3814. String V_LOGINNAME = null;
  3815. String V_PASSWORD = null;
  3816. int E_STATUS=-1;
  3817. String clwb = null;
  3818. String clnr = null;
  3819. String id = null;
  3820. String data5 = null;
  3821. String dwtype = null;
  3822. String device_code = null;
  3823. String name = null;
  3824. String confirmAll = null;
  3825. String data4 = null;
  3826. String data2 = null;
  3827. String sql = null;
  3828. List list1 = null;
  3829. JSONObject q_json = null;
  3830. JSONObject json = new JSONObject();
  3831. json.put("action", "updateHj");
  3832. if(queryJson!=null) {
  3833. q_json = JSONObject.fromObject(queryJson);
  3834. clwb = q_json.has("clwb")?q_json.getString("clwb"):null;
  3835. clnr = q_json.has("clnr")?q_json.getString("clnr"):null;
  3836. id = q_json.has("id")?q_json.getString("id"):null;
  3837. data5 = q_json.has("data5")?q_json.getString("data5"):null;
  3838. dwtype = q_json.has("dwtype")?q_json.getString("dwtype"):null;
  3839. device_code = q_json.has("device_code")?q_json.getString("device_code"):null;
  3840. name = q_json.has("name")?q_json.getString("name"):null;
  3841. confirmAll = q_json.has("confirmAll")?q_json.getString("confirmAll"):null;
  3842. data4 = q_json.has("data4")?q_json.getString("data4"):null;
  3843. data2 = q_json.has("data2")?q_json.getString("data2"):null;
  3844. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3845. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  3846. }
  3847. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  3848. List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  3849. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  3850. if(list.size()>0) {
  3851. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  3852. E_STATUS = Integer.parseInt(o.getEStatus());
  3853. }
  3854. }
  3855. if(E_STATUS==1) {
  3856. if((clwb!=null)&&(clnr!=null)&&(id!=null)&&(data5!=null)&&(device_code!=null)&&(name!=null)&&(confirmAll!=null)) {
  3857. String sqlwhere=null;
  3858. String hqlwhere=null;
  3859. if(Integer.parseInt(confirmAll)==1) {
  3860. if(Integer.parseInt(dwtype)==1||Integer.parseInt(dwtype)==3) {
  3861. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.data5='"+data5+"' and u.id.data4='"+data4+"' and u.id.data2='"+data2+"' and u.id.clzt=0";
  3862. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and status='"+data5+"' and data4='"+data4+"' and data2='"+data2+"' and clzt=0";
  3863. }else if(Integer.parseInt(dwtype)==2||Integer.parseInt(dwtype)==5) {
  3864. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.clzt=0";
  3865. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and clzt=0";
  3866. }else if(Integer.parseInt(dwtype)==6) {
  3867. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.clzt=0";
  3868. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and clzt=0";
  3869. }else if(Integer.parseInt(dwtype)==7) {
  3870. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' and u.id.clzt=0";
  3871. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' and clzt=0";
  3872. }else if(Integer.parseInt(dwtype)==16) {
  3873. hqlwhere = " where u.id.deviceCode='"+device_code+"' and u.id.name='"+name+"' ";
  3874. sqlwhere = " where device_code='"+device_code+"' and name='"+name+"' ";
  3875. }
  3876. }else {
  3877. hqlwhere = " where u.id.id="+id+" ";
  3878. sqlwhere = " where id="+id+" ";
  3879. }
  3880. int RowCount = 0;
  3881. if(Integer.parseInt(dwtype)==1||Integer.parseInt(dwtype)==3) {
  3882. RowCount = ytiotVAlarmDao.getHJCount(hqlwhere);
  3883. }else if(Integer.parseInt(dwtype)==2||Integer.parseInt(dwtype)==5) {
  3884. RowCount = ytiotVAlarmDao.getSJCount(hqlwhere);
  3885. }else if(Integer.parseInt(dwtype)==6) {
  3886. RowCount = ytiotVAlarmDao.getRTUCount(hqlwhere);
  3887. }else if(Integer.parseInt(dwtype)==7) {
  3888. RowCount = ytiotVAlarmDao.getEFireCount(hqlwhere);
  3889. }else if(Integer.parseInt(dwtype)==16) {
  3890. RowCount = ytiotVAlarmDao.getVideoCount(hqlwhere);
  3891. }
  3892. if(RowCount>0) {
  3893. if(Integer.parseInt(dwtype)==1||Integer.parseInt(dwtype)==3) {
  3894. ytiotVAlarmDao.execSQL(" update ytiot_v_hj2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3895. if (Integer.parseInt(confirmAll)==0){
  3896. HashMap<String, Object> map = new HashMap<>();
  3897. map.put("SubType",1);
  3898. map.put("DeviceId",device_code);
  3899. map.put("InsertId",id);
  3900. map.put("Confirmed",true);
  3901. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3902. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3903. // System.out.println("jsonObject = " + jsonObject);
  3904. }else {
  3905. sql = "select id,company_code from ytiot_v_hj where device_code='"+device_code+"' and name='"+name+"' and data5='"+data5+"' and data4='"+data4+"' and data2='"+data2+"' and clzt=1 order by time desc LIMIT 1";
  3906. list1 = ytiotVAlarmDao.queryBySQL(sql);
  3907. System.out.println("ceshi19950802"+sql);
  3908. if(list1.size()>0) {
  3909. System.out.println("ceshi1995");
  3910. for(int i=0;i<list1.size();i++) {
  3911. Object [] row = (Object [])list1.get(i);
  3912. HashMap<String, Object> map = new HashMap<>();
  3913. map.put("SubType",1);
  3914. map.put("DeviceId",device_code);
  3915. map.put("InsertId",row[0].toString());
  3916. map.put("Confirmed",true);
  3917. com.alibaba.fastjson.JSONObject json1 = new com.alibaba.fastjson.JSONObject(map);
  3918. System.out.println("ceshi19950802"+row[0].toString());
  3919. com.alibaba.fastjson.JSONObject jsonObject = HttpClientUtils.doPost("http://47.98.201.187:55335/report", null,json1);
  3920. }
  3921. }
  3922. }
  3923. }else if(Integer.parseInt(dwtype)==2||Integer.parseInt(dwtype)==5) {
  3924. ytiotVAlarmDao.execSQL(" update ytiot_v_sj2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3925. }else if(Integer.parseInt(dwtype)==6) {
  3926. ytiotVAlarmDao.execSQL(" update ytiot_v_rtu2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3927. }else if(Integer.parseInt(dwtype)==7) {
  3928. ytiotVAlarmDao.execSQL(" update ytiot_v_efire2 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3929. }else if(Integer.parseInt(dwtype)==16) {
  3930. ytiotVAlarmDao.execSQL(" update ytiot_v_video20172 set clwb='"+clwb+"', clnr='"+clnr+"', clzt=1 , clsj=now(), clr='"+V_LOGINNAME+"' "+sqlwhere);
  3931. }
  3932. json.put("activerow", RowCount);
  3933. json.put("success", "true");
  3934. }else {
  3935. json.put("success", "false");
  3936. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3937. }
  3938. }else {
  3939. json.put("success", "false");
  3940. json.put("MSG", "参数传递错误,请联系系统管理员。");
  3941. }
  3942. }else {
  3943. json.put("success", "false");
  3944. json.put("MSG", "用户权限错误,请重新登录后再试。");
  3945. }
  3946. return json.toString();
  3947. }
  3948. @Override
  3949. public String getHjOfflineList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  3950. // TODO Auto-generated method stub
  3951. String company_code = null;
  3952. String company_code_list = null;
  3953. String Company_Code_List = null;
  3954. int dwtype = 0;
  3955. String status = "在线";
  3956. String V_LOGINNAME = null;
  3957. String hql = null;
  3958. String hjhql = null;
  3959. String sonhql = null;
  3960. String order = null;
  3961. String dir = null;
  3962. String Start = null;
  3963. String Limit = null;
  3964. String Page = null;
  3965. String order_str = null;
  3966. JSONObject q_json = null;
  3967. JSONArray Sort = null;
  3968. JSONArray jSONArray = new JSONArray();
  3969. JSONObject json = new JSONObject();
  3970. json.put("action", "getHjOfflineList");
  3971. if(queryJson!=null) {
  3972. q_json = JSONObject.fromObject(queryJson);
  3973. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  3974. dwtype = q_json.has("dwtype")?q_json.getInt("dwtype"):0;
  3975. if(q_json.has("company_code")) {
  3976. if((q_json.optJSONObject("company_code")!=null)
  3977. &&(q_json.optJSONObject("company_code").isArray())) {
  3978. JSONArray j_tmp = q_json.getJSONArray("company_code");
  3979. for(int i=0;i<j_tmp.size();i++) {
  3980. String tmp = j_tmp.getString(i);
  3981. if(i==0)
  3982. company_code_list = tmp;
  3983. else
  3984. company_code_list += ","+tmp;
  3985. }
  3986. }else {
  3987. company_code = q_json.getString("company_code");
  3988. }
  3989. }
  3990. if((V_LOGINNAME!=null)&&(company_code==null)&&(company_code_list==null)) {
  3991. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  3992. List list = ytiotVUserCompanyDao.query(where, null, null, null, null);
  3993. if(list.size()>0) {
  3994. for(int i=0;i<list.size();i++) {
  3995. YtiotVUsercompany o = (YtiotVUsercompany)list.get(i);
  3996. YtiotVUsercompanyId oid = o.getId();
  3997. if(i==0)
  3998. Company_Code_List = oid.getOwnerCode();
  3999. else
  4000. Company_Code_List += ","+oid.getOwnerCode();
  4001. }
  4002. }
  4003. }
  4004. if(dwtype==1) {
  4005. if(Company_Code_List!=null) {
  4006. hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype !='火系统' AND `status`>24";
  4007. hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND `status` ='离线'";
  4008. }else {
  4009. if(company_code!=null) {
  4010. hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype !='火系统' AND `status`>24";
  4011. hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" = '"+company_code+ "' AND `status` ='离线'";
  4012. }
  4013. if(company_code_list!=null) {
  4014. hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype !='火系统' AND `status`>24";
  4015. hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" in ("+company_code_list+") "+ "AND `status` ='离线'";
  4016. }
  4017. }
  4018. }else {
  4019. if(Company_Code_List!=null) {
  4020. hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND `status` ='离线'";
  4021. hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype !='火系统' AND `status`>24";
  4022. if(dwtype==6) {
  4023. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='rtu' AND `status`>24";
  4024. }else if(dwtype==2) {
  4025. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype IN ('液位','水系统') AND `status`>24";
  4026. }else if(dwtype==7) {
  4027. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='电气火灾' AND `status`>24";
  4028. }else if(dwtype==16) {
  4029. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='视频监测' AND `status`>24";
  4030. }else if(dwtype==128) {
  4031. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='井盖监测' AND `status`>24";
  4032. }else if(dwtype==17) {
  4033. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+Company_Code_List+") "+ "AND dwtype ='电梯监测' AND `status`>24";
  4034. }
  4035. }else {
  4036. if(company_code!=null) {
  4037. hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" = '"+company_code+ "' AND `status` ='离线'";
  4038. hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype !='火系统' AND `status`>24";
  4039. if(dwtype==6) {
  4040. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype ='rtu' AND `status`>24";
  4041. }else if(dwtype==2) {
  4042. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype IN ('液位','水系统') AND `status`>24";
  4043. }else if(dwtype==7) {
  4044. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype ='电气火灾' AND `status`>24";
  4045. }else if(dwtype==16) {
  4046. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype ='视频监测' AND `status`>24";
  4047. }else if(dwtype==128) {
  4048. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype ='井盖监测' AND `status`>24";
  4049. }else if(dwtype==17) {
  4050. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" = '"+company_code+ "' AND dwtype ='电梯监测' AND `status`>24";
  4051. }
  4052. }
  4053. if(company_code_list!=null) {
  4054. hjhql = "SELECT COUNT(*) FROM ytiot_v_userinfocondition WHERE company_code" +" in ("+company_code_list+") "+ "AND `status` ='离线'";
  4055. hql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype !='火系统' AND `status`>24";
  4056. if(dwtype==6) {
  4057. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='rtu' AND `status`>24";
  4058. }else if(dwtype==2) {
  4059. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype IN ('液位','水系统') AND `status`>24";
  4060. }else if(dwtype==7) {
  4061. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='电气火灾' AND `status`>24";
  4062. }else if(dwtype==16) {
  4063. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='视频监测' AND `status`>24";
  4064. }else if(dwtype==128) {
  4065. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='井盖监测' AND `status`>24";
  4066. }else if(dwtype==17) {
  4067. sonhql = "SELECT COUNT(*) FROM ytiot_v_device_condition WHERE company_code" +" in ("+company_code_list+") "+ "AND dwtype ='电梯监测' AND `status`>24";
  4068. }
  4069. }
  4070. }
  4071. }
  4072. System.out.println("hjhql = " + hjhql);
  4073. String hjsql = hjhql;
  4074. Integer hjtotalCount = 0;
  4075. hjtotalCount = (Integer) hibernateTemplate.execute(new HibernateCallback() {
  4076. @Override
  4077. public Object doInHibernate(Session session) throws HibernateException, SQLException {
  4078. return Integer.valueOf(session.createSQLQuery(hjsql).uniqueResult().toString());
  4079. }
  4080. });
  4081. String sonsql = sonhql;
  4082. Integer sontotalCount =0;
  4083. Integer totalCount = 0;
  4084. if(dwtype!=1) {
  4085. sontotalCount = (Integer) hibernateTemplate.execute(new HibernateCallback() {
  4086. @Override
  4087. public Object doInHibernate(Session session) throws HibernateException, SQLException {
  4088. return Integer.valueOf(session.createSQLQuery(sonsql).uniqueResult().toString());
  4089. }
  4090. });
  4091. json.put("sontotalCount", sontotalCount);
  4092. }
  4093. String sql = hql;
  4094. totalCount = (Integer) hibernateTemplate.execute(new HibernateCallback() {
  4095. @Override
  4096. public Object doInHibernate(Session session) throws HibernateException, SQLException {
  4097. return Integer.valueOf(session.createSQLQuery(sql).uniqueResult().toString());
  4098. }
  4099. });
  4100. NumberFormat numberFormat = NumberFormat.getInstance();
  4101. String hjresult = numberFormat.format((float)hjtotalCount/(float)(totalCount+hjtotalCount)*100);
  4102. if(dwtype!=1) {
  4103. String sonresult = numberFormat.format((float)sontotalCount/(float)(totalCount+hjtotalCount)*100);
  4104. json.put("sonresult", sonresult);
  4105. }
  4106. // int totalCount = ytiotVAlarmDao.getHjOfflineCount(hqlwhere);
  4107. json.put("hjtotalCount", hjtotalCount);
  4108. json.put("hjresult", hjresult);
  4109. json.put("limit", Limit);
  4110. }
  4111. return json.toString();
  4112. }
  4113. /**
  4114. * 伍继告警信息
  4115. */
  4116. @Override
  4117. public String getWjAlarmList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  4118. // TODO Auto-generated method stub
  4119. String address = null;
  4120. String clzt = null;
  4121. String company_code = null;
  4122. String company_code_list = null;
  4123. String Company_Code_List = null;
  4124. String company_name = null;
  4125. String digitalValue = null;
  4126. String device_code_list = null;
  4127. String time_start = null;
  4128. String time_end = null;
  4129. String COMMSTATUS = null;
  4130. String V_LOGINNAME = null;
  4131. String hqlwhere = null;
  4132. String order = " order by id";
  4133. String dir = " desc";
  4134. String Start = null;
  4135. String Limit = null;
  4136. String Page = null;
  4137. String order_str = " order by id";
  4138. JSONObject q_json = null;
  4139. JSONArray Sort = null;
  4140. JSONArray jSONArray = new JSONArray();
  4141. JSONObject json = new JSONObject();
  4142. json.put("action", "getLiftVList");
  4143. NumberFormat numberFormat = NumberFormat.getInstance();
  4144. if(queryJson!=null) {
  4145. q_json = JSONObject.fromObject(queryJson);
  4146. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  4147. digitalValue = q_json.has("digitalValue")?q_json.getString("digitalValue"):null;
  4148. time_start = q_json.has("startTime")?q_json.getString("startTime"):null;
  4149. time_end = q_json.has("endTime")?q_json.getString("endTime"):null;
  4150. if(digitalValue!=null) {
  4151. if(digitalValue.equals("复归")) {
  4152. hqlwhere = chkhw(hqlwhere) + " u.digitalValue"+" = "+0+"";
  4153. }else if(digitalValue.equals("动作")) {
  4154. hqlwhere = chkhw(hqlwhere) + " u.digitalValue"+" = "+1+"";
  4155. }
  4156. }
  4157. if((time_start!=null)&&(time_start.length()>0)) {
  4158. hqlwhere = chkhw(hqlwhere) + " u.sendingTime >= '"+time_start+"' ";
  4159. }
  4160. if((time_end!=null)&&(time_start.length()>0)) {
  4161. hqlwhere = chkhw(hqlwhere) + " u.sendingTime <= '"+time_end+"' ";
  4162. }
  4163. int totalCount = ytiotVAlarmDao.getWjAlarmCount(hqlwhere);
  4164. json.put("totalCount", totalCount);
  4165. if(Start!=null){
  4166. if(Integer.parseInt(Start)>totalCount){
  4167. Start = "0";
  4168. Page = "0";
  4169. }else if(page==null)
  4170. Page="0";
  4171. }else{
  4172. Start = "0";
  4173. Page = "0";
  4174. }
  4175. json.put("page", Page);
  4176. json.put("start", Start);
  4177. json.put("limit", Limit);
  4178. if(totalCount>0) {
  4179. json.put("code", 200);
  4180. List<?> list = ytiotVAlarmDao.wjAlarmQuery(hqlwhere, order_str, dir, Start, Limit);
  4181. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  4182. if(list.size()>0) {
  4183. for(int i=0;i<list.size();i++) {
  4184. WjPowerMonitoringAlarm o = (WjPowerMonitoringAlarm)list.get(i);
  4185. Map map = new HashMap();
  4186. String deviceName=o.getDeviceName();
  4187. map.put("alarmId", o.getId());
  4188. if(deviceName.equals("DA00012784")) {
  4189. map.put("companyName", "宝辉冶金");
  4190. map.put("userName", "韩正义");
  4191. map.put("userPhone", "15122423833");
  4192. map.put("siteName", "测试站点一");
  4193. map.put("companyAdress", "沪太路8786弄155号");
  4194. map.put("lineName", "进线一");
  4195. map.put("measDesc", "进线一,"+o.getMeasDesc());
  4196. }else if(deviceName.equals("DA00013596")) {
  4197. map.put("companyName", "永鑫汽车配件");
  4198. map.put("userName", "韩锐");
  4199. map.put("userPhone", "17630065224");
  4200. map.put("siteName", "测试站点二");
  4201. map.put("companyAdress", "上海市嘉定区宝安公路2442号");
  4202. map.put("lineName", "进线一");
  4203. map.put("measDesc", "进线一,"+o.getMeasDesc());
  4204. }else if(deviceName.equals("DA00013433")) {
  4205. map.put("companyName", "宝辉冶金");
  4206. map.put("userName", "韩正义");
  4207. map.put("userPhone", "15122423833");
  4208. map.put("siteName", "测试站点三");
  4209. map.put("companyAdress", "沪太路8786弄155号");
  4210. map.put("lineName", "进线二");
  4211. map.put("measDesc", "进线二,"+o.getMeasDesc());
  4212. }else if(deviceName.equals("DA00012827")) {
  4213. map.put("companyName", "永鑫汽车配件");
  4214. map.put("userName", "韩锐");
  4215. map.put("userPhone", "17630065224");
  4216. map.put("siteName", "测试站点四");
  4217. map.put("companyAdress", "上海市嘉定区宝安公路2442号");
  4218. map.put("lineName", "进线三");
  4219. map.put("measDesc", "进线三,"+o.getMeasDesc());
  4220. }else if(deviceName.equals("DA00013948")) {
  4221. map.put("companyName", "永鑫汽车配件");
  4222. map.put("userName", "韩锐");
  4223. map.put("userPhone", "17630065224");
  4224. map.put("siteName", "测试站点五");
  4225. map.put("companyAdress", "上海市嘉定区宝安公路2442号");
  4226. map.put("lineName", "进线四");
  4227. map.put("measDesc", "进线四,"+o.getMeasDesc());
  4228. }
  4229. switch (o.getMeasName()) {
  4230. case "DI1":
  4231. map.put("measName", "开入1");
  4232. break;
  4233. case "DI2":
  4234. map.put("measName", "开入2");
  4235. break;
  4236. case "DI3":
  4237. map.put("measName", "开入3");
  4238. break;
  4239. case "FireAlarm":
  4240. map.put("measName", "火灾预警总");
  4241. break;
  4242. case "EleAlarm":
  4243. map.put("measName", "线路电气故障总");
  4244. break;
  4245. case "PhaseLoss":
  4246. map.put("measName", "缺相");
  4247. break;
  4248. case "LoadLive":
  4249. map.put("measName", "线路带电");
  4250. break;
  4251. case "LoadBrkState":
  4252. map.put("measName", "线路开关状态");
  4253. break;
  4254. case "OverV":
  4255. map.put("measName", "过压");
  4256. break;
  4257. case "UnderV":
  4258. map.put("measName", "低压");
  4259. break;
  4260. case "OverI":
  4261. map.put("measName", "电流越限");
  4262. break;
  4263. case "Trip":
  4264. map.put("measName", "过流跳闸");
  4265. break;
  4266. case "BusOutage":
  4267. map.put("measName", "母线停电");
  4268. break;
  4269. case "OverIr":
  4270. map.put("measName", "剩余电流越限");
  4271. break;
  4272. case "OverT1":
  4273. map.put("measName", "测温点1超温");
  4274. break;
  4275. case "OverT2":
  4276. map.put("measName", "测温点2超温");
  4277. break;
  4278. case "OverT3":
  4279. map.put("measName", "测温点3超温");
  4280. break;
  4281. case "OverT4":
  4282. map.put("measName", "测温点4超温");
  4283. break;
  4284. case "OverEvT":
  4285. map.put("measName", "环境温度越限");
  4286. break;
  4287. case "ArcA":
  4288. map.put("measName", "A相燃弧");
  4289. break;
  4290. case "ArcB":
  4291. map.put("measName", "B相燃弧");
  4292. break;
  4293. case "ArcC":
  4294. map.put("measName", "C相燃弧");
  4295. break;
  4296. case "OverUH":
  4297. map.put("measName", "电压谐波越限");
  4298. break;
  4299. case "OverIH":
  4300. map.put("measName", "电流谐波越限");
  4301. break;
  4302. case "OverDemandP":
  4303. map.put("measName", "有功需量超限");
  4304. break;
  4305. case "OverDemandS":
  4306. map.put("measName", "视在需量超限");
  4307. break;
  4308. case "MeasFailure":
  4309. map.put("measName", "测量通道故障");
  4310. break;
  4311. case "DevAbnormal":
  4312. map.put("measName", "设备异常");
  4313. break;
  4314. case "Mute":
  4315. map.put("measName", "消音");
  4316. break;
  4317. case "DO1":
  4318. map.put("measName", "开出1");
  4319. break;
  4320. case "DO2":
  4321. map.put("measName", "开出2");
  4322. break;
  4323. case "ResDI1":
  4324. map.put("measName", "备用遥信1");
  4325. break;
  4326. case "ResDI2":
  4327. map.put("measName", "备用遥信2");
  4328. break;
  4329. case "ResDI3":
  4330. map.put("measName", "备用遥信3");
  4331. break;
  4332. case "ResDI4":
  4333. map.put("measName", "备用遥信4");
  4334. break;
  4335. default:
  4336. map.put("measName", "未知");
  4337. break;
  4338. }
  4339. int alarmStatus=o.getDigitalValue();
  4340. if(alarmStatus==0) {
  4341. map.put("digitalValue", "复归");
  4342. }else if(alarmStatus==1) {
  4343. map.put("digitalValue", "动作");
  4344. }
  4345. map.put("deviceCode", o.getDeviceName());
  4346. map.put("handleContent", o.getHandleContent());
  4347. map.put("handleMisinformation", o.getHandleMisinformation());
  4348. map.put("sendingTime", df.format(o.getSendingTime()));
  4349. map.put("pictureUrl", o.getPictureUrl());
  4350. int handleState = o.getHandleState();
  4351. if(handleState==0) {
  4352. map.put("timeConsuming", "--");
  4353. map.put("handleState", "未处理");
  4354. }else if(handleState==1) {
  4355. String endTime = df.format(o.getHandleTime());
  4356. String startTime = df.format(o.getSendingTime());
  4357. long diff = df.parse(endTime).getTime() - df.parse(startTime).getTime();
  4358. long nh = 1000*60*60;
  4359. long nd = 1000*24*60*60;
  4360. long hour = diff/nh;
  4361. map.put("timeConsuming", hour);
  4362. map.put("handleState", "已处理");
  4363. }
  4364. JSONObject jSONObject = JSONObject.fromObject(map);
  4365. jSONArray.add(jSONObject);
  4366. }
  4367. json.put("RESULT", jSONArray);
  4368. }
  4369. }else {
  4370. json.put("code", 200);
  4371. json.put("data", jSONArray);
  4372. }
  4373. return json.toString();
  4374. }else {
  4375. json.put("code", 60001);
  4376. json.put("data", "缺少参数");
  4377. return json.toString();
  4378. }
  4379. }
  4380. @Override
  4381. public String getWjDeviceList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  4382. // TODO Auto-generated method stub
  4383. String address = null;
  4384. String clzt = null;
  4385. String company_code = null;
  4386. String company_code_list = null;
  4387. String Company_Code_List = null;
  4388. String company_name = null;
  4389. String device_code = null;
  4390. String deviceStatus = null;
  4391. String time_start = null;
  4392. String time_end = null;
  4393. String COMMSTATUS = null;
  4394. String V_LOGINNAME = null;
  4395. String hqlwhere = null;
  4396. String order = null;
  4397. String dir = null;
  4398. String Start = null;
  4399. String Limit = null;
  4400. String Page = null;
  4401. String order_str = null;
  4402. JSONObject q_json = null;
  4403. JSONArray Sort = null;
  4404. JSONArray jSONArray = new JSONArray();
  4405. JSONObject json = new JSONObject();
  4406. // json.put("action", "getLiftVList");
  4407. if(queryJson!=null) {
  4408. q_json = JSONObject.fromObject(queryJson);
  4409. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  4410. deviceStatus = q_json.has("deviceStatus")?q_json.getString("deviceStatus"):null;
  4411. if(deviceStatus!=null) {
  4412. if(deviceStatus.equals("离线")) {
  4413. hqlwhere = chkhw(hqlwhere) + " u.trueStatus"+" = '"+1+"'";
  4414. }else if(deviceStatus.equals("在线")){
  4415. hqlwhere = chkhw(hqlwhere) + " u.trueStatus"+" = '"+0+"'";
  4416. }
  4417. }
  4418. int totalCount = ytiotVAlarmDao.getWjDeviceCount(hqlwhere);
  4419. // json.put("totalCount", totalCount);
  4420. if(Start!=null){
  4421. if(Integer.parseInt(Start)>totalCount){
  4422. Start = "0";
  4423. Page = "0";
  4424. }else if(page==null)
  4425. Page="0";
  4426. }else{
  4427. Start = "0";
  4428. Page = "0";
  4429. }
  4430. if(totalCount>0) {
  4431. json.put("code", 200);
  4432. List<?> list = ytiotVAlarmDao.wjDeviceQuery(hqlwhere, order_str, dir, Start, Limit);
  4433. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  4434. if(list.size()>0) {
  4435. for(int i=0;i<list.size();i++) {
  4436. WjPowerMonitoringDevice o = (WjPowerMonitoringDevice)list.get(i);
  4437. String sql = "select siteName,siteAdress from wj_power_monitoring_site where id="+o.getSiteId()+"";
  4438. List<?>list1 = ytiotVAlarmDao.queryBySQL(sql);
  4439. Object [] row = (Object [])list1.get(0);
  4440. Map map = new HashMap();
  4441. if(o.getDeviceId().equals("DA00012784")) {
  4442. map.put("deviceName", "进线一");
  4443. }else if(o.getDeviceId().equals("DA00013596")) {
  4444. map.put("deviceName", "进线一");
  4445. }else if(o.getDeviceId().equals("DA00013433")) {
  4446. map.put("deviceName", "进线二");
  4447. }else if(o.getDeviceId().equals("DA00012827")) {
  4448. map.put("deviceName", "进线三");
  4449. }else if(o.getDeviceId().equals("DA00013948")) {
  4450. map.put("deviceName", "进线四");
  4451. }
  4452. if(o.getTrueStatus().equals("1")) {
  4453. map.put("deviceStatus", "离线");
  4454. System.out.println("deviceStatusli"+row[1].toString());
  4455. }else {
  4456. map.put("deviceStatus", "在线");
  4457. System.out.println("deviceStatuszai"+row[1].toString());
  4458. }
  4459. map.put("deviceAdress", row[1].toString()+row[0].toString());
  4460. map.put("deviceCode", o.getDeviceId());
  4461. JSONObject jSONObject = JSONObject.fromObject(map);
  4462. jSONArray.add(jSONObject);
  4463. }
  4464. json.put("data", jSONArray);
  4465. }
  4466. }else {
  4467. json.put("code", 200);
  4468. json.put("data", jSONArray);
  4469. }
  4470. return json.toString();
  4471. }else {
  4472. json.put("code", 60001);
  4473. json.put("data", "缺少参数");
  4474. return json.toString();
  4475. }
  4476. }
  4477. @Override
  4478. public String getWjDataStatisticsList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  4479. // TODO Auto-generated method stub
  4480. String address = null;
  4481. String clzt = null;
  4482. String company_code = null;
  4483. String company_code_list = null;
  4484. String Company_Code_List = null;
  4485. String company_name = null;
  4486. String device_code = null;
  4487. String device_code_list = null;
  4488. String time_start = null;
  4489. String time_end = null;
  4490. String COMMSTATUS = null;
  4491. String V_LOGINNAME = null;
  4492. String hqlwhere = null;
  4493. String order = null;
  4494. String dir = null;
  4495. String Start = null;
  4496. String Limit = null;
  4497. String Page = null;
  4498. String order_str = null;
  4499. JSONObject q_json = null;
  4500. JSONArray Sort = null;
  4501. JSONArray jSONArray = new JSONArray();
  4502. JSONObject json = new JSONObject();
  4503. NumberFormat numberFormat = NumberFormat.getInstance();
  4504. numberFormat.setMaximumFractionDigits(2);
  4505. // json.put("action", "getLiftVList");
  4506. json.put("code", 200);
  4507. Map map = new HashMap();
  4508. int totalCount = ytiotVAlarmDao.getWjDeviceCount(hqlwhere);
  4509. map.put("siteNumber", totalCount);
  4510. int alarmNumber = ytiotVAlarmDao.getWjAlarmCount(hqlwhere);
  4511. map.put("alarmNumber", alarmNumber);
  4512. String processedAlarmhqlwhere = " where u.id.handleState= 1";
  4513. int processedAlarmNumber = ytiotVAlarmDao.getWjAlarmCount(processedAlarmhqlwhere);
  4514. map.put("processedAlarmNumber", processedAlarmNumber);
  4515. String unprocessedAlarmhqlwhere = " where u.id.handleState= 0";
  4516. int unprocessedAlarmNumber = ytiotVAlarmDao.getWjAlarmCount(unprocessedAlarmhqlwhere);
  4517. map.put("unprocessedAlarmNumber", unprocessedAlarmNumber);
  4518. String powerLossAlarmhqlwhere = " where u.id.measName= 'BusOutage'";
  4519. int powerLossAlarmNumber = ytiotVAlarmDao.getWjAlarmCount(powerLossAlarmhqlwhere);
  4520. map.put("powerLossAlarmNumber", powerLossAlarmNumber);
  4521. String lowPressureAlarmhqlwhere = " where u.id.measName != 'BusOutage'";
  4522. int lowPressureAlarmNumber = ytiotVAlarmDao.getWjAlarmCount(lowPressureAlarmhqlwhere);
  4523. map.put("lowPressureAlarmNumber", lowPressureAlarmNumber);
  4524. String powerLossresult = numberFormat.format((float)powerLossAlarmNumber/(float)alarmNumber*100);
  4525. map.put("powerLossAlarmPercentage", powerLossresult);
  4526. String lowPressureresult = numberFormat.format((float)lowPressureAlarmNumber/(float)alarmNumber*100);
  4527. map.put("lowPressureAlarmPercentage", lowPressureresult);
  4528. JSONObject jSONObject = JSONObject.fromObject(map);
  4529. jSONArray.add(jSONObject);
  4530. json.put("data", jSONArray);
  4531. if(Start!=null){
  4532. if(Integer.parseInt(Start)>totalCount){
  4533. Start = "0";
  4534. Page = "0";
  4535. }else if(page==null)
  4536. Page="0";
  4537. }else{
  4538. Start = "0";
  4539. Page = "0";
  4540. }
  4541. return json.toString();
  4542. }
  4543. @Override
  4544. public String getWjDeviceInfoList(String queryJson, String page, String start, String limit, String sort) throws Exception {
  4545. // TODO Auto-generated method stub
  4546. String address = null;
  4547. String clzt = null;
  4548. String company_code = null;
  4549. String company_code_list = null;
  4550. String Company_Code_List = null;
  4551. String company_name = null;
  4552. String device_code = null;
  4553. String device_code_list = null;
  4554. String time_start = null;
  4555. String deviceName = null;
  4556. String COMMSTATUS = null;
  4557. String V_LOGINNAME = null;
  4558. String hqlwhere = null;
  4559. String order = null;
  4560. String dir = null;
  4561. String Start = null;
  4562. String Limit = null;
  4563. String Page = null;
  4564. String order_str = null;
  4565. JSONObject q_json = null;
  4566. JSONArray Sort = null;
  4567. JSONArray jSONArray = new JSONArray();
  4568. JSONObject json = new JSONObject();
  4569. // json.put("action", "getLiftVList");
  4570. if(queryJson!=null) {
  4571. q_json = JSONObject.fromObject(queryJson);
  4572. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  4573. deviceName = q_json.has("deviceCode")?q_json.getString("deviceCode"):null;
  4574. if(deviceName!=null)
  4575. hqlwhere = chkhw(hqlwhere) + " u.deviceName"+" = '"+deviceName+"'";
  4576. int totalCount = ytiotVAlarmDao.getWjAnalogCount(hqlwhere);
  4577. // json.put("totalCount", totalCount);
  4578. if(Start!=null){
  4579. if(Integer.parseInt(Start)>totalCount){
  4580. Start = "0";
  4581. Page = "0";
  4582. }else if(page==null)
  4583. Page="0";
  4584. }else{
  4585. Start = "0";
  4586. Page = "0";
  4587. }
  4588. order_str = " order by u.dataTime";
  4589. dir = " desc";
  4590. // json.put("page", Page);
  4591. // json.put("start", Start);
  4592. // json.put("limit", Limit);
  4593. if(totalCount>0) {
  4594. json.put("code", 200);
  4595. List<?> list = ytiotVAlarmDao.wjAnalogQuery(hqlwhere, order_str, dir, "0", "1");
  4596. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  4597. if(list.size()>0) {
  4598. for(int i=0;i<list.size();i++) {
  4599. WjPowerMonitoringAnalog o = (WjPowerMonitoringAnalog)list.get(i);
  4600. Map map = new HashMap();
  4601. map.put("Uab", o.getUab());
  4602. map.put("Ubc", o.getUbc());
  4603. map.put("Uca", o.getUca());
  4604. map.put("Ia", o.getIa());
  4605. map.put("Ib", o.getIb());
  4606. map.put("Ic", o.getIc());
  4607. map.put("P", o.getP());
  4608. map.put("Q", o.getQ());
  4609. map.put("COS", o.getCos());
  4610. map.put("F", o.getF());
  4611. map.put("dataTime", df.format(o.getDataTime()));
  4612. map.put("totalCount", totalCount);
  4613. JSONObject jSONObject = JSONObject.fromObject(map);
  4614. jSONArray.add(jSONObject);
  4615. }
  4616. json.put("data", jSONArray);
  4617. }
  4618. }
  4619. return json.toString();
  4620. }else {
  4621. json.put("code", 60001);
  4622. json.put("data", "缺少参数");
  4623. return json.toString();
  4624. }
  4625. }
  4626. @Override
  4627. public String updateWjAlarm(String queryJson) throws Exception {
  4628. // TODO Auto-generated method stub
  4629. String V_LOGINNAME = null;
  4630. String V_PASSWORD = null;
  4631. int E_STATUS=-1;
  4632. String clwb = null;
  4633. String clnr = null;
  4634. String id = null;
  4635. String pictureUrl = null;
  4636. String device_code = null;
  4637. String name = null;
  4638. String confirmAll = null;
  4639. JSONObject q_json = null;
  4640. JSONObject json = new JSONObject();
  4641. // json.put("action", "updateSj");
  4642. if(queryJson!=null) {
  4643. q_json = JSONObject.fromObject(queryJson);
  4644. clwb = q_json.has("handleMisinformation")?q_json.getString("handleMisinformation"):null;
  4645. clnr = q_json.has("handleContent")?q_json.getString("handleContent"):null;
  4646. pictureUrl = q_json.has("pictureUrl")?q_json.getString("pictureUrl"):null;
  4647. id = q_json.has("alarmId")?q_json.getString("alarmId"):null;
  4648. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  4649. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  4650. }
  4651. // if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  4652. // List list = ytiotTAdminDao.query(" where MD5(u.VLoginname)='"+MD5Util.EncoderByMd5(V_LOGINNAME)+"' and u.VPassword='"
  4653. // +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  4654. // if(list.size()>0) {
  4655. // YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  4656. // E_STATUS = Integer.parseInt(o.getEStatus());
  4657. // }
  4658. // }
  4659. if((clwb!=null)&&(clnr!=null)&&(id!=null)) {
  4660. String sqlwhere=null;
  4661. String hqlwhere=null;
  4662. hqlwhere = " where u.id="+id+" ";
  4663. sqlwhere = " where id="+id+" ";
  4664. int RowCount = ytiotVAlarmDao.getWjAlarmCount(hqlwhere);
  4665. System.out.println("clwb"+clwb);
  4666. if(RowCount>0) {
  4667. ytiotVAlarmDao.execSQL(" update wj_power_monitoring_alarm set handleContent='"+clnr+"',pictureUrl='"+pictureUrl+"',handleMisinformation='"+clwb+"', handleState=1 , handleTime=now(), handlePerson='"+V_LOGINNAME+"' "+sqlwhere);
  4668. json.put("activerow", RowCount);
  4669. json.put("success", "true");
  4670. }else {
  4671. json.put("success", "false");
  4672. json.put("MSG", "参数传递错误,请联系系统管理员。");
  4673. }
  4674. }else {
  4675. json.put("success", "false");
  4676. json.put("MSG", "参数传递错误,请联系系统管理员。");
  4677. }
  4678. return json.toString();
  4679. }
  4680. }