YtiotVCompanyServiceImpl.java 42 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083
  1. package cn.com.usky.iot.company.service;
  2. import java.text.SimpleDateFormat;
  3. import java.util.ArrayList;
  4. import java.util.Date;
  5. import java.util.HashMap;
  6. import java.util.List;
  7. import java.util.Map;
  8. import java.util.Calendar;
  9. import java.text.NumberFormat;
  10. import cn.com.usky.iot.admin.dao.YtiotTAdminDao;
  11. import cn.com.usky.iot.admin.dao.YtiotVUserCompanyDao;
  12. import cn.com.usky.iot.company.dao.YtiotVCompanyDao;
  13. import cn.com.usky.iot.entity.YtiotTAdmin;
  14. import cn.com.usky.iot.entity.YtiotTInspectors;
  15. import cn.com.usky.iot.entity.YtiotVCompany;
  16. import cn.com.usky.iot.entity.YtiotVCompanyId;
  17. import cn.com.usky.iot.entity.YtiotVUsercompany;
  18. import cn.com.usky.iot.entity.YtiotVUsercompanyId;
  19. import cn.com.usky.iot.entity.YtiotTProjectDetails;
  20. import cn.com.usky.iot.entity.YtiotTProjectDevice;
  21. import cn.com.usky.iot.entity.YtiotTProjectMonitor;
  22. import cn.com.usky.iot.entity.YtiotVEfire;
  23. import cn.com.usky.iot.entity.YtiotVEfireId;
  24. import cn.com.usky.iot.entity.YtiotVHj;
  25. import cn.com.usky.iot.entity.YtiotVHjId;
  26. import cn.com.usky.iot.entity.YtiotVRtu;
  27. import cn.com.usky.iot.entity.YtiotVRtuId;
  28. import cn.com.usky.iot.entity.YtiotVSj;
  29. import cn.com.usky.iot.entity.YtiotVSjId;
  30. import cn.com.usky.iot.alarm.dao.YtiotVAlarmDao;
  31. import cn.com.usky.iot.data.dao.YtiotVDataDao;
  32. import cn.com.usky.iot.entity.YtiotVEfire;
  33. import cn.com.usky.iot.entity.YtiotVEfireId;
  34. import cn.com.usky.iot.entity.YtiotVHj;
  35. import cn.com.usky.iot.entity.YtiotVHjId;
  36. import cn.com.usky.iot.entity.YtiotVRtu;
  37. import cn.com.usky.iot.entity.YtiotVRtuId;
  38. import cn.com.usky.iot.entity.YtiotVSj;
  39. import cn.com.usky.iot.entity.YtiotVSjId;
  40. import cn.com.usky.utils.MD5Util;
  41. import net.sf.json.JSONArray;
  42. import net.sf.json.JSONObject;
  43. import java.math.BigDecimal;
  44. import java.text.DecimalFormat;
  45. import java.text.ParseException;
  46. import java.text.SimpleDateFormat;
  47. public class YtiotVCompanyServiceImpl implements YtiotVCompanyService {
  48. private YtiotVCompanyDao ytiotVCompanyDao;
  49. private YtiotTAdminDao ytiotTAdminDao;
  50. private YtiotVUserCompanyDao ytiotVUserCompanyDao;
  51. private YtiotVAlarmDao ytiotVAlarmDao;
  52. private YtiotVDataDao ytiotVDataDao;
  53. public YtiotVDataDao getYtiotVDataDao() {
  54. return ytiotVDataDao;
  55. }
  56. public void setYtiotVDataDao(YtiotVDataDao ytiotVDataDao) {
  57. this.ytiotVDataDao = ytiotVDataDao;
  58. }
  59. public YtiotVAlarmDao getYtiotVAlarmDao() {
  60. return ytiotVAlarmDao;
  61. }
  62. public void setYtiotVAlarmDao(YtiotVAlarmDao ytiotVAlarmDao) {
  63. this.ytiotVAlarmDao = ytiotVAlarmDao;
  64. }
  65. public YtiotVUserCompanyDao getYtiotVUserCompanyDao() {
  66. return ytiotVUserCompanyDao;
  67. }
  68. public void setYtiotVUserCompanyDao(YtiotVUserCompanyDao ytiotVUserCompanyDao) {
  69. this.ytiotVUserCompanyDao = ytiotVUserCompanyDao;
  70. }
  71. public YtiotVCompanyDao getYtiotVCompanyDao() {
  72. return ytiotVCompanyDao;
  73. }
  74. public void setYtiotVCompanyDao(YtiotVCompanyDao ytiotVCompanyDao) {
  75. this.ytiotVCompanyDao = ytiotVCompanyDao;
  76. }
  77. public YtiotTAdminDao getYtiotTAdminDao() {
  78. return ytiotTAdminDao;
  79. }
  80. public void setYtiotTAdminDao(YtiotTAdminDao ytiotTAdminDao) {
  81. this.ytiotTAdminDao = ytiotTAdminDao;
  82. }
  83. public boolean chk_string_param(String param) {
  84. if(param==null)
  85. return true;
  86. if(param.indexOf("=")>=0)
  87. return false;
  88. if(param.indexOf("\'")>=0)
  89. return false;
  90. if(param.indexOf("\"")>=0)
  91. return false;
  92. return true;
  93. }
  94. public String chkhw(String hqlwhere){
  95. if(hqlwhere==null)
  96. return " where ";
  97. else
  98. return hqlwhere+" and ";
  99. }
  100. public String fieldname(String field){
  101. if(field.equals("building_id"))
  102. return "buildingId";
  103. if(field.equals("building_name"))
  104. return "buildingName";
  105. if(field.equals("create_man"))
  106. return "createMan";
  107. if(field.equals("create_time"))
  108. return "createTime";
  109. if(field.equals("owner_address"))
  110. return "ownerAddress";
  111. if(field.equals("owner_id"))
  112. return "ownerId";
  113. if(field.equals("owner_man"))
  114. return "ownerMan";
  115. if(field.equals("owner_name"))
  116. return "ownerName";
  117. if(field.equals("owner_office"))
  118. return "ownerOffice";
  119. if(field.equals("company_code"))
  120. return "companyCode";
  121. return field;
  122. }
  123. @Override
  124. public String getVCompanyList(String queryJson, String page, String start, String limit, String sort)
  125. throws Exception {
  126. // TODO Auto-generated method stub
  127. String addr1=null, addr2=null, addr3=null;
  128. String addr1list=null, addr2list=null, addr3list=null;
  129. String address=null, building_id=null, building_name=null, create_man=null;
  130. String data1=null, data2=null, data3=null, fulladdress=null;
  131. String h5=null, hls=null, id=null, owner_address=null;
  132. String owner_id=null, owner_man=null, owner_name=null;
  133. String owner_id_list=null, building_id_list=null;
  134. String owner_office=null, rtmp=null, xmlx=null, xmlx_list=null;
  135. String hqlwhere = null;
  136. String order = null;
  137. String dir = null;
  138. String Start = null;
  139. String Limit = null;
  140. String Page = null;
  141. String order_str = null;
  142. JSONObject q_json = null;
  143. JSONArray Sort = null;
  144. JSONArray jSONArray = new JSONArray();
  145. JSONObject json = new JSONObject();
  146. json.put("action", "getVCompanyList");
  147. if(queryJson!=null) {
  148. q_json = JSONObject.fromObject(queryJson);
  149. if(q_json.has("addr1")) {
  150. if(((JSONObject) q_json.get("addr1")).isArray())
  151. {
  152. JSONArray j_tmp = q_json.getJSONArray("addr1");
  153. for(int i=0;i<j_tmp.size();i++)
  154. {
  155. String tmp = j_tmp.getString(i);
  156. if(i==0)
  157. addr1list = tmp;
  158. else
  159. addr1list += ","+tmp;
  160. }
  161. }else
  162. addr1 = q_json.getString("addr1");
  163. }
  164. if(q_json.has("addr2")) {
  165. if(((JSONObject) q_json.getJSONObject("addr2")).isArray())
  166. {
  167. JSONArray j_tmp = q_json.getJSONArray("addr2");
  168. for(int i=0;i<j_tmp.size();i++)
  169. {
  170. String tmp = j_tmp.getString(i);
  171. if(i==0)
  172. addr2list = tmp;
  173. else
  174. addr2list += ","+tmp;
  175. }
  176. }else
  177. addr2 = q_json.getString("addr2");
  178. }
  179. if(q_json.has("addr3")) {
  180. if(((JSONObject)q_json.getJSONObject("addr3")).isArray())
  181. {
  182. JSONArray j_tmp = q_json.getJSONArray("addr3");
  183. for(int i=0;i<j_tmp.size();i++)
  184. {
  185. String tmp = j_tmp.getString(i);
  186. if(i==0)
  187. addr3list = tmp;
  188. else
  189. addr3list += ","+tmp;
  190. }
  191. }else
  192. addr3 = q_json.getString("addr3");
  193. }
  194. address = q_json.has("address")?q_json.getString("address"):null;
  195. if(q_json.has("building_id")) {
  196. if(((JSONObject)q_json.getJSONObject("building_id")).isArray())
  197. {
  198. JSONArray j_tmp = q_json.getJSONArray("building_id");
  199. for(int i=0;i<j_tmp.size();i++)
  200. {
  201. String tmp = j_tmp.getString(i);
  202. if(i==0)
  203. building_id_list = tmp;
  204. else
  205. building_id_list += ","+tmp;
  206. }
  207. }else
  208. building_id = q_json.getString("building_id");
  209. }
  210. building_name = q_json.has("building_name")?q_json.getString("building_name"):null;
  211. create_man = q_json.has("create_man")?q_json.getString("create_man"):null;
  212. data1 = q_json.has("data1")?q_json.getString("data1"):null;
  213. data2 = q_json.has("data2")?q_json.getString("data2"):null;
  214. data3 = q_json.has("data3")?q_json.getString("data3"):null;
  215. fulladdress = q_json.has("fulladdress")?q_json.getString("fulladdress"):null;
  216. id = q_json.has("id")?q_json.getString("id"):null;
  217. if(q_json.has("owner_id"))
  218. {
  219. if(((JSONObject)q_json.getJSONObject("owner_id")).isArray())
  220. {
  221. JSONArray j_tmp = q_json.getJSONArray("owner_id");
  222. for(int i=0;i<j_tmp.size();i++)
  223. {
  224. String tmp = j_tmp.getString(i);
  225. if(i==0)
  226. owner_id_list = tmp;
  227. else
  228. owner_id_list += ","+tmp;
  229. }
  230. }else
  231. owner_id = q_json.getString("owner_id");
  232. }
  233. owner_address = q_json.has("owner_address")?q_json.getString("owner_address"):null;
  234. owner_office = q_json.has("owner_office")?q_json.getString("owner_office"):null;
  235. if(q_json.has("xmlx")) {
  236. if(((JSONObject)q_json.getJSONObject("xmlx")).isArray()) {
  237. JSONArray j_tmp = q_json.getJSONArray("xmlx");
  238. for(int i=0;i<j_tmp.size();i++) {
  239. String tmp = j_tmp.getString(i);
  240. if(i==0)
  241. xmlx_list = "'"+tmp+"'";
  242. else
  243. xmlx_list += ",'"+tmp+"'";
  244. }
  245. }else
  246. xmlx = q_json.getString("xmlx");
  247. }
  248. xmlx = q_json.has("xmlx")?q_json.getString("xmlx"):null;
  249. order = q_json.has("order")?q_json.getString("order"):null;
  250. dir = q_json.has("dir")?q_json.getString("dir"):null;
  251. Start = q_json.has("start")?q_json.getString("start"):(start!=null)?start:"0";
  252. Limit = q_json.has("limit")?q_json.getString("limit"):(limit!=null)?limit:null;
  253. Page = q_json.has("page")?q_json.getString("page"):(page!=null)?page:"0";
  254. json.put("query", queryJson);
  255. }
  256. if(sort!=null) {
  257. Sort = JSONArray.fromObject(sort);
  258. if((Sort.isArray())&&(Sort.size()>0)) {
  259. JSONObject s_json = Sort.getJSONObject(0);
  260. order = s_json.has("property")?s_json.getString("property"):order;
  261. dir = s_json.has("direction")?s_json.getString("direction"):dir;
  262. }
  263. json.put("sort", sort);
  264. }
  265. Start = start;
  266. Limit = limit;
  267. Page = page;
  268. if(addr1!=null)
  269. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" like '%"+addr1+"%' ";
  270. if(addr1list!=null)
  271. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" in ("+addr1list+") ";
  272. if(addr2!=null)
  273. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" like '%"+addr2+"%' ";
  274. if(addr2list!=null)
  275. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" in ("+addr2list+") ";
  276. if(addr3!=null)
  277. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" like '%"+addr3+"%' ";
  278. if(addr3list!=null)
  279. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" in ("+addr3list+") ";
  280. if(address!=null)
  281. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("address")+" like '%"+address+"%' ";
  282. if(building_id!=null)
  283. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" like '%"+building_id+"%' ";
  284. if(building_id_list!=null)
  285. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" in ("+building_id_list+") ";
  286. if(building_name!=null)
  287. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_name")+" like '%"+building_name+"%' ";
  288. if(create_man!=null)
  289. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("create_man")+" like '%"+create_man+"%' ";
  290. if(data1!=null)
  291. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data1")+" like '%"+data1+"%' ";
  292. if(data2!=null)
  293. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data2")+" like '%"+data2+"%' ";
  294. if(data3!=null)
  295. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data3")+" like '%"+data3+"%' ";
  296. if(fulladdress!=null)
  297. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("fulladdress")+" like '%"+fulladdress+"%' ";
  298. if(id!=null)
  299. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("id")+" = '"+id+"' ";
  300. if(owner_id!=null)
  301. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" = "+owner_id+" ";
  302. if(owner_id_list!=null)
  303. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_list+") ";
  304. if(owner_address!=null)
  305. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_address")+" like '%"+owner_address+"%' ";
  306. if(owner_office!=null)
  307. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_office")+" like '%"+owner_office+"%' ";
  308. if(xmlx!=null)
  309. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" like '%"+xmlx+"%' ";
  310. if(xmlx_list!=null)
  311. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" in ("+xmlx_list+") ";
  312. if(order!=null)
  313. order_str = " order by u.id."+fieldname(order);
  314. else
  315. order_str = " order by u.id."+fieldname("id");
  316. int totalCount = ytiotVCompanyDao.getCount(hqlwhere);
  317. json.put("totalCount", totalCount);
  318. if(Start!=null){
  319. if(Integer.parseInt(Start)>totalCount){
  320. Start = "0";
  321. Page = "0";
  322. }
  323. if(page==null)
  324. Page="0";
  325. }else{
  326. Start = "0";
  327. Page = "0";
  328. }
  329. json.put("page", Page);
  330. json.put("start", Start);
  331. json.put("limit", Limit);
  332. if(totalCount>0) {
  333. List list = ytiotVCompanyDao.query(hqlwhere, order_str, dir, Start, Limit);
  334. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  335. if(list.size()>0) {
  336. for(int i=0;i<list.size();i++) {
  337. YtiotVCompany o = (YtiotVCompany)list.get(i);
  338. YtiotVCompanyId Id = o.getId();
  339. Map map = new HashMap();
  340. map.put("addr1", Id.getAddr1());
  341. map.put("addr2", Id.getAddr2());
  342. map.put("addr3", Id.getAddr3());
  343. map.put("address", Id.getAddress());
  344. map.put("building_id", Id.getBuildingId());
  345. map.put("building_name", Id.getBuildingName());
  346. map.put("create_man", Id.getCreateMan());
  347. map.put("create_time", df.format(Id.getCreateTime()));
  348. map.put("data1", Id.getData1());
  349. map.put("data2", Id.getData2());
  350. map.put("data3", Id.getData3());
  351. map.put("fulladdress", Id.getFulladdress());
  352. map.put("h5", Id.getH5());
  353. map.put("hls", Id.getHls());
  354. map.put("id", Id.getId());
  355. map.put("owner_address", Id.getOwnerAddress());
  356. map.put("owner_id", Id.getOwnerId());
  357. map.put("owner_man", Id.getOwnerMan());
  358. map.put("owner_name", Id.getOwnerName());
  359. map.put("owner_office", Id.getOwnerOffice());
  360. map.put("position", Id.getPosition());
  361. map.put("rtmp", Id.getRtmp());
  362. map.put("xmlx", Id.getXmlx());
  363. JSONObject jSONObject = JSONObject.fromObject(map);
  364. jSONArray.add(jSONObject);
  365. }
  366. json.put("RESULT", jSONArray);
  367. }
  368. }
  369. return json.toString();
  370. }
  371. @Override
  372. public String getVCompanyNameList(String queryJson) throws Exception {
  373. // TODO Auto-generated method stub
  374. String addr1=null, addr2=null, addr3=null;
  375. String addr1list=null, addr2list=null, addr3list=null;
  376. String address=null, building_id=null, building_name=null, create_man=null;
  377. String data1=null, data2=null, data3=null, fulladdress=null;
  378. String h5=null, hls=null, id=null, owner_address=null;
  379. String owner_id=null, owner_man=null, owner_name=null;
  380. String owner_id_list=null, building_id_list=null;
  381. String owner_office=null, rtmp=null, xmlx=null, xmlx_list=null;
  382. String V_LOGINNAME = null;
  383. String V_PASSWORD = null;
  384. String owner_id_List = null;
  385. int E_STATUS=-1;
  386. String hqlwhere = null;
  387. JSONObject q_json = null;
  388. JSONArray Sort = null;
  389. JSONArray jSONArray = new JSONArray();
  390. JSONObject json = new JSONObject();
  391. json.put("action", "getVCompanyNameList");
  392. if(queryJson!=null) {
  393. q_json = JSONObject.fromObject(queryJson);
  394. if(q_json.has("addr1")) {
  395. if(((JSONObject) q_json.get("addr1")).isArray())
  396. {
  397. JSONArray j_tmp = q_json.getJSONArray("addr1");
  398. for(int i=0;i<j_tmp.size();i++)
  399. {
  400. String tmp = j_tmp.getString(i);
  401. if(i==0)
  402. addr1list = tmp;
  403. else
  404. addr1list += ","+tmp;
  405. }
  406. }else
  407. addr1 = q_json.getString("addr1");
  408. }
  409. if(q_json.has("addr2")) {
  410. if(((JSONObject) q_json.getJSONObject("addr2")).isArray())
  411. {
  412. JSONArray j_tmp = q_json.getJSONArray("addr2");
  413. for(int i=0;i<j_tmp.size();i++)
  414. {
  415. String tmp = j_tmp.getString(i);
  416. if(i==0)
  417. addr2list = tmp;
  418. else
  419. addr2list += ","+tmp;
  420. }
  421. }else
  422. addr2 = q_json.getString("addr2");
  423. }
  424. if(q_json.has("addr3")) {
  425. if(((JSONObject)q_json.getJSONObject("addr3")).isArray())
  426. {
  427. JSONArray j_tmp = q_json.getJSONArray("addr3");
  428. for(int i=0;i<j_tmp.size();i++)
  429. {
  430. String tmp = j_tmp.getString(i);
  431. if(i==0)
  432. addr3list = tmp;
  433. else
  434. addr3list += ","+tmp;
  435. }
  436. }else
  437. addr3 = q_json.getString("addr3");
  438. }
  439. address = q_json.has("address")?q_json.getString("address"):null;
  440. if(q_json.has("building_id")) {
  441. if(((JSONObject)q_json.getJSONObject("building_id")).isArray())
  442. {
  443. JSONArray j_tmp = q_json.getJSONArray("building_id");
  444. for(int i=0;i<j_tmp.size();i++)
  445. {
  446. String tmp = j_tmp.getString(i);
  447. if(i==0)
  448. building_id_list = tmp;
  449. else
  450. building_id_list += ","+tmp;
  451. }
  452. }else
  453. building_id = q_json.getString("building_id");
  454. }
  455. building_name = q_json.has("building_name")?q_json.getString("building_name"):null;
  456. create_man = q_json.has("create_man")?q_json.getString("create_man"):null;
  457. data1 = q_json.has("data1")?q_json.getString("data1"):null;
  458. data2 = q_json.has("data2")?q_json.getString("data2"):null;
  459. data3 = q_json.has("data3")?q_json.getString("data3"):null;
  460. fulladdress = q_json.has("fulladdress")?q_json.getString("fulladdress"):null;
  461. id = q_json.has("id")?q_json.getString("id"):null;
  462. if(q_json.has("owner_id"))
  463. {
  464. if(((JSONObject)q_json.getJSONObject("owner_id")).isArray())
  465. {
  466. JSONArray j_tmp = q_json.getJSONArray("owner_id");
  467. for(int i=0;i<j_tmp.size();i++)
  468. {
  469. String tmp = j_tmp.getString(i);
  470. if(i==0)
  471. owner_id_list = tmp;
  472. else
  473. owner_id_list += ","+tmp;
  474. }
  475. }else
  476. owner_id = q_json.getString("owner_id");
  477. }
  478. owner_address = q_json.has("owner_address")?q_json.getString("owner_address"):null;
  479. owner_office = q_json.has("owner_office")?q_json.getString("owner_office"):null;
  480. if(q_json.has("xmlx")) {
  481. if(((JSONObject)q_json.getJSONObject("xmlx")).isArray()) {
  482. JSONArray j_tmp = q_json.getJSONArray("xmlx");
  483. for(int i=0;i<j_tmp.size();i++) {
  484. String tmp = j_tmp.getString(i);
  485. if(i==0)
  486. xmlx_list = "'"+tmp+"'";
  487. else
  488. xmlx_list += ",'"+tmp+"'";
  489. }
  490. }else
  491. xmlx = q_json.getString("xmlx");
  492. }
  493. xmlx = q_json.has("xmlx")?q_json.getString("xmlx"):null;
  494. json.put("query", queryJson);
  495. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  496. V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  497. }
  498. if((V_LOGINNAME!=null)&&(V_PASSWORD!=null)) {
  499. List list = ytiotTAdminDao.query(" where u.VLoginname='"+V_LOGINNAME+"' and u.VPassword='"
  500. +MD5Util.EncoderByMd5(MD5Util.EncoderByMd5(V_PASSWORD))+"' ", null, null, null, null);
  501. if(list.size()>0) {
  502. YtiotTAdmin o = (YtiotTAdmin)list.get(0);
  503. E_STATUS = Integer.parseInt(o.getEStatus());
  504. }
  505. String where = " where u.id.agentid='"+V_LOGINNAME+"' ";
  506. List list1 = ytiotVUserCompanyDao.query(where, null, null, null, null);
  507. if(list1.size()>0) {
  508. for(int i=0;i<list1.size();i++) {
  509. YtiotVUsercompany o = (YtiotVUsercompany)list1.get(i);
  510. YtiotVUsercompanyId oid = o.getId();
  511. if(i==0)
  512. owner_id_List = oid.getOwnerCode();
  513. else
  514. owner_id_List += ","+oid.getOwnerCode();
  515. }
  516. }
  517. }
  518. if(addr1!=null)
  519. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" like '%"+addr1+"%' ";
  520. if(addr1list!=null)
  521. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr1")+" in ("+addr1list+") ";
  522. if(owner_id_List!=null)
  523. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_List+") ";
  524. if(addr2!=null)
  525. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" like '%"+addr2+"%' ";
  526. if(addr2list!=null)
  527. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr2")+" in ("+addr2list+") ";
  528. if(addr3!=null)
  529. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" like '%"+addr3+"%' ";
  530. if(addr3list!=null)
  531. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("addr3")+" in ("+addr3list+") ";
  532. if(address!=null)
  533. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("address")+" like '%"+address+"%' ";
  534. if(building_id!=null)
  535. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" like '%"+building_id+"%' ";
  536. if(building_id_list!=null)
  537. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_id")+" in ("+building_id_list+") ";
  538. if(building_name!=null)
  539. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("building_name")+" like '%"+building_name+"%' ";
  540. if(create_man!=null)
  541. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("create_man")+" like '%"+create_man+"%' ";
  542. if(data1!=null)
  543. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data1")+" like '%"+data1+"%' ";
  544. if(data2!=null)
  545. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data2")+" like '%"+data2+"%' ";
  546. if(data3!=null)
  547. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("data3")+" like '%"+data3+"%' ";
  548. if(fulladdress!=null)
  549. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("fulladdress")+" like '%"+fulladdress+"%' ";
  550. if(id!=null)
  551. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("id")+" = '"+id+"' ";
  552. if(owner_id!=null)
  553. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" = "+owner_id+" ";
  554. if(owner_id_list!=null)
  555. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_id")+" in ("+owner_id_list+") ";
  556. if(owner_address!=null)
  557. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_address")+" like '%"+owner_address+"%' ";
  558. if(owner_office!=null)
  559. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("owner_office")+" like '%"+owner_office+"%' ";
  560. if(xmlx!=null)
  561. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" like '%"+xmlx+"%' ";
  562. if(xmlx_list!=null)
  563. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("xmlx")+" in ("+xmlx_list+") ";
  564. int totalCount = ytiotVCompanyDao.getCount(hqlwhere);
  565. json.put("totalCount", totalCount);
  566. if(totalCount>0) {
  567. List list = ytiotVCompanyDao.query(hqlwhere, null, null, null, null);
  568. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
  569. if(list.size()>0) {
  570. for(int i=0;i<list.size();i++) {
  571. YtiotVCompany o = (YtiotVCompany)list.get(i);
  572. YtiotVCompanyId Id = o.getId();
  573. Map map = new HashMap();
  574. map.put("owner_id", Id.getOwnerId());
  575. map.put("owner_name", Id.getOwnerName());
  576. map.put("xmlx", Id.getXmlx());
  577. JSONObject jSONObject = JSONObject.fromObject(map);
  578. jSONArray.add(jSONObject);
  579. }
  580. json.put("RESULT", jSONArray);
  581. }
  582. }
  583. return json.toString();
  584. }
  585. @Override
  586. public String getVBuildingNameList(String queryJson) throws Exception {
  587. String V_LOGINNAME = null;
  588. String company_code_list = null;
  589. String hqlwhere = null;
  590. JSONObject q_json = null;
  591. JSONArray jSONArray = new JSONArray();
  592. JSONObject json = new JSONObject();
  593. // json.put("action", "getPatrolPointList");
  594. if(queryJson!=null) {
  595. q_json = JSONObject.fromObject(queryJson);
  596. V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  597. json.put("query", queryJson);
  598. }
  599. if(V_LOGINNAME!=null) {
  600. String where1 = " where u.id.agentid='"+V_LOGINNAME+"' ";
  601. List list1 = ytiotVUserCompanyDao.query(where1, null, null, null, null);
  602. if(list1.size()>0) {
  603. for(int i=0;i<list1.size();i++) {
  604. YtiotVUsercompany o = (YtiotVUsercompany)list1.get(i);
  605. YtiotVUsercompanyId oid = o.getId();
  606. if(i==0)
  607. company_code_list = "'"+oid.getOwnerCode()+"'";
  608. else
  609. company_code_list += ",'"+oid.getOwnerCode()+"'";
  610. }
  611. }
  612. }
  613. if(company_code_list!=null)
  614. hqlwhere = " where u.id.ownerId in ("+company_code_list+")";
  615. List list = ytiotVCompanyDao.query(hqlwhere, null, null, null, null);
  616. if(list.size()>0) {
  617. for(int i=0;i<list.size();i++) {
  618. YtiotVCompany o = (YtiotVCompany)list.get(i);
  619. YtiotVCompanyId Id = o.getId();
  620. Map map = new HashMap();
  621. map.put("building_id", Id.getBuildingId());
  622. map.put("building_name", Id.getBuildingName());
  623. JSONObject jSONObject = JSONObject.fromObject(map);
  624. jSONArray.add(jSONObject);
  625. }
  626. json.put("RESULT", jSONArray);
  627. }
  628. return json.toString();
  629. }
  630. public static int getDates(Date date1,Date date2) {
  631. Calendar cal=Calendar.getInstance();
  632. cal.setTime(date1);
  633. long time1 = cal.getTimeInMillis();
  634. cal.setTime(date2);
  635. long time2 = cal.getTimeInMillis();
  636. long between_days=(time2-time1)/(1000*3600*24);
  637. return Integer.parseInt(String.valueOf(between_days));
  638. }
  639. @Override
  640. public String getVProjectNameList(String queryJson) throws Exception {
  641. // TODO Auto-generated method stub
  642. String V_LOGINNAME = null;
  643. String V_PASSWORD = null;
  644. String start_data = null;
  645. String end_data = null;
  646. String company_code = null;
  647. String device_type = null;
  648. String video_type = null;
  649. int E_STATUS=-1;
  650. int m=0;
  651. int q=0;
  652. int x=0;
  653. long days2=0;
  654. long days5=0;
  655. long days8=0;
  656. String hqlwhere = null;
  657. String hhwhere = null;
  658. String hswhere = null;
  659. String hrwhere = null;
  660. String hewhere = null;
  661. String efwhere = null;
  662. String efrwhere = null;
  663. String videowhere = null;
  664. String videorwhere = null;
  665. String sjwhere = null;
  666. String sjrwhere = null;
  667. String rtuwhere = null;
  668. String rturwhere = null;
  669. String dwwhere = null;
  670. String dwsjwhere = null;
  671. String dwrtuwhere = null;
  672. String dwefwhere = null;
  673. String dwvideowhere = null;
  674. String hjresult = null;
  675. String lxhjresult = null;
  676. String sjresult = null;
  677. String lxsjresult = null;
  678. String rturesult = null;
  679. String lxrturesult = null;
  680. String efresult = null;
  681. String lxefresult = null;
  682. String videoresult = null;
  683. JSONObject q_json = null;
  684. JSONArray Sort = null;
  685. JSONArray jSONArray = new JSONArray();
  686. JSONArray jSONArray1 = new JSONArray();
  687. JSONArray jSONArray2 = new JSONArray();
  688. JSONArray jSONArray4 = new JSONArray();
  689. JSONObject json = new JSONObject();
  690. json.put("action", "getVProjectNameList");
  691. SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd");
  692. if(queryJson!=null) {
  693. q_json = JSONObject.fromObject(queryJson);
  694. // V_LOGINNAME = q_json.has("V_LOGINNAME")?q_json.getString("V_LOGINNAME"):null;
  695. // V_PASSWORD = q_json.has("V_PASSWORD")?q_json.getString("V_PASSWORD"):null;
  696. start_data = q_json.has("start_data")?q_json.getString("start_data"):null;
  697. end_data = q_json.has("end_data")?q_json.getString("end_data"):null;
  698. company_code = q_json.has("build_code")?q_json.getString("build_code"):null;
  699. json.put("query", queryJson);
  700. }
  701. Date startData = null;
  702. Date endData = null;
  703. startData=df.parse(start_data);
  704. endData=df.parse(end_data);
  705. int days= getDates(startData,endData)+1;
  706. hqlwhere = chkhw(hqlwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  707. hhwhere = chkhw(hhwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  708. hswhere = chkhw(hswhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  709. hrwhere = chkhw(hrwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  710. hewhere = chkhw(hewhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  711. efwhere = chkhw(efwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  712. efrwhere = chkhw(efrwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  713. sjwhere = chkhw(sjwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  714. sjrwhere = chkhw(sjrwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  715. rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  716. rturwhere = chkhw(rturwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  717. dwwhere = chkhw(dwwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  718. dwsjwhere = chkhw(dwsjwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  719. dwrtuwhere = chkhw(dwrtuwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  720. dwefwhere = chkhw(dwefwhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  721. dwvideowhere = chkhw(dwvideowhere)+"u.id."+fieldname("company_code")+" = "+company_code+" ";
  722. hswhere = chkhw(hswhere)+"u.id."+fieldname("clzt")+" = "+1+" ";
  723. hewhere = chkhw(hewhere)+"u.id."+fieldname("clzt")+" = "+1+" ";
  724. efwhere = chkhw(efwhere)+"u.id."+fieldname("clzt")+" = "+1+" ";
  725. sjwhere = chkhw(sjwhere)+"u.id."+fieldname("clzt")+" = "+1+" ";
  726. rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("clzt")+" = "+1+" ";
  727. dwwhere = chkhw(dwwhere)+"u.id."+fieldname("dwtype")+" = "+1+" ";
  728. dwsjwhere = chkhw(dwsjwhere)+"( u.id.dwtype = 2 or u.id.dwtype = 5 ) ";
  729. dwrtuwhere = chkhw(dwrtuwhere)+"u.id."+fieldname("dwtype")+" = "+6+" ";
  730. dwefwhere = chkhw(dwefwhere)+"u.id."+fieldname("dwtype")+" = "+7+" ";
  731. dwvideowhere = chkhw(dwvideowhere)+"u.id."+fieldname("dwtype")+" = "+16+" ";
  732. hrwhere = chkhw(hrwhere)+" u.id.data1 = 'U44' ";
  733. hewhere = chkhw(hewhere)+" u.id.data1 = 'U44' ";
  734. efwhere = chkhw(efwhere)+" u.id.data1 = 'EF9' ";
  735. efrwhere = chkhw(efrwhere)+" u.id.data1 = 'EF9' ";
  736. videorwhere = chkhw(videorwhere)+" u.id.data1 = 'EF9' ";
  737. sjwhere = chkhw(sjwhere)+"( u.id.data1 = 'WP4' or u.id.data1 = 'LL4' ) ";
  738. sjrwhere = chkhw(sjrwhere)+"( u.id.data1 = 'WP4' or u.id.data1 = 'LL4' ) ";
  739. rtuwhere = chkhw(rtuwhere)+" u.id.data1 = '44' ";
  740. rturwhere = chkhw(rturwhere)+" u.id.data1 = '44' ";
  741. if(start_data!=null)
  742. hhwhere = chkhw(hhwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  743. hswhere = chkhw(hswhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  744. hrwhere = chkhw(hrwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  745. hewhere = chkhw(hewhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  746. efwhere = chkhw(efwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  747. efrwhere = chkhw(efrwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  748. videorwhere = chkhw(videorwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  749. sjwhere = chkhw(sjwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  750. sjrwhere = chkhw(sjrwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  751. rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  752. rturwhere = chkhw(rturwhere)+"u.id."+fieldname("time")+" > '"+start_data+"' ";
  753. if(end_data!=null)
  754. hhwhere = chkhw(hhwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  755. hswhere = chkhw(hswhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  756. hrwhere = chkhw(hrwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  757. hewhere = chkhw(hewhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  758. efwhere = chkhw(efwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  759. efrwhere = chkhw(efrwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  760. videorwhere = chkhw(videorwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  761. sjwhere = chkhw(sjwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  762. sjrwhere = chkhw(sjrwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  763. rtuwhere = chkhw(rtuwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  764. rturwhere = chkhw(rturwhere)+"u.id."+fieldname("time")+" < '"+end_data+"' ";
  765. int hjtotalCount = ytiotVAlarmDao.getHJCount(hhwhere);
  766. int clhjtotalCount = ytiotVAlarmDao.getHJCount(hswhere);
  767. int lxhjtotalCount = ytiotVAlarmDao.getHJCount(hrwhere);
  768. int cllxhjtotalCount = ytiotVAlarmDao.getHJCount(hewhere);
  769. int eftotalCount = ytiotVAlarmDao.getEFireCount(hhwhere);
  770. int cleftotalCount = ytiotVAlarmDao.getEFireCount(hswhere);
  771. int lxeftotalCount = ytiotVAlarmDao.getEFireCount(efrwhere);
  772. int cllxeftotalCount = ytiotVAlarmDao.getEFireCount(efwhere);
  773. int sjtotalCount = ytiotVAlarmDao.getSJCount(hhwhere);
  774. int clsjtotalCount = ytiotVAlarmDao.getSJCount(hswhere);
  775. int lxsjtotalCount = ytiotVAlarmDao.getSJCount(sjrwhere);
  776. int cllxsjtotalCount = ytiotVAlarmDao.getSJCount(sjwhere);
  777. int rtutotalCount = ytiotVAlarmDao.getRTUCount(hhwhere);
  778. int clrtutotalCount = ytiotVAlarmDao.getRTUCount(hswhere);
  779. int lxrtutotalCount = ytiotVAlarmDao.getRTUCount(rturwhere);
  780. int cllxrtutotalCount = ytiotVAlarmDao.getRTUCount(rtuwhere);
  781. int dwhjtotalCount = ytiotVDataDao.getSyncStatusCount1(dwwhere);
  782. int dwsjtotalCount = ytiotVDataDao.getSyncStatusCount1(dwsjwhere);
  783. int dwrtutotalCount = ytiotVDataDao.getSyncStatusCount1(dwrtuwhere);
  784. int dweftotalCount = ytiotVDataDao.getSyncStatusCount1(dwefwhere);
  785. int dwvideototalCount = ytiotVDataDao.getSyncStatusCount1(dwvideowhere);
  786. int videototalCount = ytiotVAlarmDao.getCount("ytiot_v_video2017",hhwhere);
  787. int clvideototalCount = ytiotVAlarmDao.getCount("ytiot_v_video2017",hswhere);
  788. NumberFormat numberFormat = NumberFormat.getInstance();
  789. numberFormat.setMaximumFractionDigits(2);
  790. if(hjtotalCount==0) {
  791. String result = "100";
  792. json.put("hjbaifenbi", result);
  793. }else {
  794. String result = numberFormat.format((float)clhjtotalCount/(float)hjtotalCount*100);
  795. json.put("hjbaifenbi", result);
  796. // int clhjbaifenbi = Integer.parseInt( result );
  797. // json.put("clhjbaifenbi", clhjbaifenbi);
  798. }
  799. if(lxhjtotalCount==0) {
  800. String result = "100"+"%";
  801. json.put("lxhjbaifenbi", result);
  802. }else {
  803. String result = numberFormat.format((float)cllxhjtotalCount/(float)lxhjtotalCount*100);
  804. json.put("lxhjbaifenbi", result+"%");
  805. }
  806. if(eftotalCount==0) {
  807. String result = "100";
  808. json.put("efbaifenbi", result);
  809. }else {
  810. String result = numberFormat.format((float)cleftotalCount/(float)eftotalCount*100);
  811. json.put("efbaifenbi", result);
  812. }
  813. if(lxeftotalCount==0) {
  814. String result = "100"+"%";
  815. json.put("lxefbaifenbi", result);
  816. }else {
  817. String result = numberFormat.format((float)cllxeftotalCount/(float)lxeftotalCount*100);
  818. json.put("lxefbaifenbi", result+"%");
  819. }
  820. if(videototalCount==0) {
  821. String result = "100";
  822. json.put("videobaifenbi", result);
  823. }else {
  824. String result = numberFormat.format((float)clvideototalCount/(float)videototalCount*100);
  825. json.put("videobaifenbi", result);
  826. }
  827. if(sjtotalCount==0) {
  828. String result = "100";
  829. json.put("sjbaifenbi", result);
  830. }else {
  831. String result = numberFormat.format((float)clsjtotalCount/(float)sjtotalCount*100);
  832. json.put("sjbaifenbi", result);
  833. }
  834. if(lxsjtotalCount==0) {
  835. String result = "100"+"%";
  836. json.put("lxsjbaifenbi", result);
  837. }else {
  838. String result = numberFormat.format((float)cllxsjtotalCount/(float)lxsjtotalCount*100);
  839. json.put("lxsjbaifenbi", result+"%");
  840. }
  841. if(rtutotalCount==0) {
  842. String result = "100";
  843. json.put("rtubaifenbi", result);
  844. }else {
  845. String result = numberFormat.format((float)clrtutotalCount/(float)rtutotalCount*100);
  846. json.put("rtubaifenbi", result);
  847. }
  848. if(lxrtutotalCount==0) {
  849. String result = "100"+"%";
  850. json.put("lxrtubaifenbi", result);
  851. }else {
  852. String result = numberFormat.format((float)cllxrtutotalCount/(float)lxrtutotalCount*100);
  853. json.put("lxrtubaifenbi", result+"%");
  854. }
  855. if(dwhjtotalCount==0) {
  856. hjresult = "0";
  857. lxhjresult = "0";
  858. }else {
  859. hjresult = numberFormat.format((float)hjtotalCount/(float)days/(float)dwhjtotalCount);
  860. lxhjresult = numberFormat.format((float)lxhjtotalCount/(float)days/(float)dwhjtotalCount);
  861. }
  862. if(dwsjtotalCount==0) {
  863. sjresult = "0";
  864. lxsjresult = "0";
  865. }else {
  866. sjresult = numberFormat.format((float)sjtotalCount/(float)days/(float)dwsjtotalCount);
  867. lxsjresult = numberFormat.format((float)lxsjtotalCount/(float)days/(float)dwsjtotalCount);
  868. }
  869. if(dwrtutotalCount==0) {
  870. rturesult = "0";
  871. lxrturesult = "0";
  872. }else {
  873. rturesult = numberFormat.format((float)rtutotalCount/(float)days/(float)dwrtutotalCount);
  874. lxrturesult = numberFormat.format((float)lxrtutotalCount/(float)days/(float)dwrtutotalCount);
  875. }
  876. if(dweftotalCount==0) {
  877. efresult = "0";
  878. lxefresult = "0";
  879. }else {
  880. efresult = numberFormat.format((float)eftotalCount/(float)days/(float)dweftotalCount);
  881. lxefresult = numberFormat.format((float)lxeftotalCount/(float)days/(float)dweftotalCount);
  882. }
  883. if(dwvideototalCount==0) {
  884. videoresult = "0";
  885. }else {
  886. videoresult = numberFormat.format((float)videototalCount/(float)days/(float)dwvideototalCount);
  887. }
  888. int hjsjrtuCount = hjtotalCount+sjtotalCount+rtutotalCount+eftotalCount+videototalCount;
  889. String result1 = numberFormat.format((float)hjtotalCount/(float)hjsjrtuCount*100);
  890. String result2 = numberFormat.format((float)sjtotalCount/(float)hjsjrtuCount*100);
  891. String result3 = numberFormat.format((float)rtutotalCount/(float)hjsjrtuCount*100);
  892. String result4 = numberFormat.format((float)eftotalCount/(float)hjsjrtuCount*100);
  893. String result5 = numberFormat.format((float)videototalCount/(float)hjsjrtuCount*100);
  894. Map map4 = new HashMap();
  895. map4.put("lxhjresult", lxhjresult);
  896. map4.put("lxsjresult", lxsjresult);
  897. map4.put("lxrturesult", lxrturesult);
  898. map4.put("lxefresult", lxefresult);
  899. map4.put("efresult", efresult);
  900. map4.put("videoresult", videoresult);
  901. map4.put("dweftotalCount", dweftotalCount);
  902. map4.put("dwvideototalCount", dwvideototalCount);
  903. map4.put("eftotalCount", eftotalCount);
  904. map4.put("cleftotalCount", cleftotalCount);
  905. map4.put("lxeftotalCount", lxeftotalCount);
  906. map4.put("cllxeftotalCount", cllxeftotalCount);
  907. map4.put("videototalCount", videototalCount);
  908. map4.put("clvideototalCount", clvideototalCount);
  909. map4.put("result1", result1);
  910. map4.put("result2", result2);
  911. map4.put("result3", result3);
  912. map4.put("result4", result4);
  913. map4.put("result5", result5);
  914. // map.put("xmlx", g.getXmlx());
  915. JSONObject jSONObject4 = JSONObject.fromObject(map4);
  916. jSONArray4.add(jSONObject4);
  917. json.put("RESULT4", jSONArray4);
  918. json.put("hjtotalCount", hjtotalCount);
  919. json.put("clhjtotalCount", clhjtotalCount);
  920. json.put("lxhjtotalCount", lxhjtotalCount);
  921. json.put("cllxhjtotalCount", cllxhjtotalCount);
  922. json.put("sjtotalCount", sjtotalCount);
  923. json.put("clsjtotalCount", clsjtotalCount);
  924. json.put("lxsjtotalCount", lxsjtotalCount);
  925. json.put("cllxsjtotalCount", cllxsjtotalCount);
  926. json.put("rtutotalCount", rtutotalCount);
  927. json.put("clrtutotalCount", clrtutotalCount);
  928. json.put("lxrtutotalCount", lxrtutotalCount);
  929. json.put("cllxrtutotalCount", cllxrtutotalCount);
  930. json.put("dwhjtotalCount", dwhjtotalCount);
  931. json.put("dwsjtotalCount", dwsjtotalCount);
  932. json.put("dwrtutotalCount", dwrtutotalCount);
  933. json.put("days", days);
  934. json.put("hjresult", hjresult);
  935. json.put("sjresult", sjresult);
  936. json.put("rturesult", rturesult);
  937. List list = ytiotVCompanyDao.query1(hqlwhere, null, null, null, null);
  938. List list1 = ytiotVCompanyDao.query2(hqlwhere, null, null, null, null);
  939. List list2 = ytiotVCompanyDao.query3(hqlwhere, null, null, null, null);
  940. List list3 = ytiotVAlarmDao.HJQuery(hswhere, null, null, null, null);
  941. List list4 = ytiotVAlarmDao.SJQuery(hswhere, null, null, null, null);
  942. List list5 = ytiotVAlarmDao.RTUQuery(hswhere, null, null, null, null);
  943. if(list.size()>0) {
  944. for(int i=0;i<list.size();i++) {
  945. YtiotTProjectDetails g = (YtiotTProjectDetails)list.get(0);
  946. // YtiotVCompanyId Id = o.getId();
  947. Map map = new HashMap();
  948. map.put("company_name", g.getCompanyName()==null?"":g.getCompanyName());
  949. map.put("approach_time",g.getApproachTime()==null?"":df.format(g.getApproachTime()));
  950. map.put("complete_time",g.getCompleteTime()==null?"":df.format(g.getCompleteTime()));
  951. map.put("check_time", g.getCheckTime()==null?"":df.format(g.getCheckTime()));
  952. // map.put("xmlx", g.getXmlx());
  953. JSONObject jSONObject = JSONObject.fromObject(map);
  954. jSONArray.add(jSONObject);
  955. json.put("RESULT", jSONArray);
  956. }
  957. }
  958. if(list1.size()>0) {
  959. int device_num=0;
  960. for(int i=0;i<list1.size();i++) {
  961. YtiotTProjectDevice o = (YtiotTProjectDevice)list1.get(i);
  962. device_num+=o.getDeviceNum();
  963. // YtiotVCompanyId Id = o.getId();
  964. Map map1 = new HashMap();
  965. map1.put("device_name", o.getDeviceName()==null?"":o.getDeviceName());
  966. map1.put("specifications", o.getSpecifications()==null?"":o.getSpecifications());
  967. map1.put("device_num", o.getDeviceNum()==0?"":o.getDeviceNum());
  968. map1.put("data_info", o.getDataInfo()==null?"":o.getDataInfo());
  969. JSONObject jSONObject1 = JSONObject.fromObject(map1);
  970. jSONArray1.add(jSONObject1);
  971. json.put("RESULT1", jSONArray1);
  972. if(o.getDataInfo()!=null && o.getDataInfo().equals("efire")) {
  973. device_type="efire";
  974. }else if(o.getDataInfo()!=null && o.getDataInfo().equals("video")) {
  975. video_type="video";
  976. }
  977. }
  978. json.put("device_type", device_type);
  979. json.put("device_num1", device_num);
  980. }
  981. // if(device_type.equals("efire")) {
  982. // List list6 = ytiotVAlarmDao.EFireQuery(hswhere, null, null, null, null);
  983. //
  984. // }
  985. if(list2.size()>0) {
  986. int device_num2=0;
  987. for(int i=0;i<list2.size();i++) {
  988. YtiotTProjectMonitor h = (YtiotTProjectMonitor)list2.get(i);
  989. device_num2+=h.getMonitorSum();
  990. // YtiotVCompanyId Id = o.getId();
  991. Map map2 = new HashMap();
  992. map2.put("monitor_son", h.getMonitorSon()==null?"":h.getMonitorSon());
  993. map2.put("monitor_type", h.getMonitorType()==null?"":h.getMonitorType());
  994. map2.put("monitor_sum", h.getMonitorSum()==0?"":h.getMonitorSum());
  995. map2.put("data_info", h.getDataInfo()==null?"":h.getDataInfo());
  996. JSONObject jSONObject2 = JSONObject.fromObject(map2);
  997. jSONArray2.add(jSONObject2);
  998. json.put("RESULT2", jSONArray2);
  999. }
  1000. json.put("device_num2", device_num2);
  1001. }
  1002. if(list3.size()>0) {
  1003. for(int i=0;i<list3.size();i++) {
  1004. YtiotVHj z = (YtiotVHj)list3.get(0);
  1005. YtiotVHjId id = z.getId();
  1006. Date d1=id.getTime();
  1007. Date d2=id.getClsj();
  1008. long diff = d2.getTime() - d1.getTime();
  1009. long days1 = diff / (1000 * 60 * 60 * 24);
  1010. days2 += days1;
  1011. m+=1;
  1012. }
  1013. String days3= numberFormat.format((float)days2/(float)m);
  1014. json.put("days3", days3);
  1015. }else {
  1016. json.put("days3", "0");
  1017. }
  1018. if(list4.size()>0) {
  1019. for(int i=0;i<list4.size();i++) {
  1020. YtiotVSj s = (YtiotVSj)list4.get(0);
  1021. YtiotVSjId id1 = s.getId();
  1022. Date d1=id1.getTime();
  1023. Date d2=id1.getClsj();
  1024. long diff = d2.getTime() - d1.getTime();
  1025. long days4 = diff / (1000 * 60 * 60 * 24);
  1026. days5 += days4;
  1027. q+=1;
  1028. }
  1029. String days6= numberFormat.format((float)days5/(float)q);
  1030. json.put("days6", days6);
  1031. }else {
  1032. json.put("days6", "0");
  1033. }
  1034. if(list5.size()>0) {
  1035. for(int i=0;i<list5.size();i++) {
  1036. YtiotVRtu s = (YtiotVRtu)list5.get(0);
  1037. YtiotVRtuId id1 = s.getId();
  1038. Date d1=id1.getTime();
  1039. Date d2=id1.getClsj();
  1040. long diff = d2.getTime() - d1.getTime();
  1041. long days7 = diff / (1000 * 60 * 60 * 24);
  1042. days8 += days7;
  1043. x+=1;
  1044. }
  1045. String days9= numberFormat.format((float)days8/(float)x);
  1046. json.put("days9", days9);
  1047. }else {
  1048. json.put("days9", "0");
  1049. }
  1050. return json.toString();
  1051. }
  1052. }