AlarmBtService.java 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623
  1. package com.gyee.alarm.service;
  2. import com.gyee.alarm.init.CacheContext;
  3. import com.gyee.alarm.model.auto.*;
  4. import com.gyee.alarm.model.vo.*;
  5. import com.gyee.alarm.service.auto.IAlarmTsService;
  6. import com.gyee.alarm.service.auto.IProEconAlarmInfoService;
  7. import com.gyee.alarm.util.DateUtils;
  8. import com.gyee.alarm.util.StringUtils;
  9. import com.gyee.alarm.util.realtimesource.IEdosUtil;
  10. import com.gyee.alarm.websocket.PushParams;
  11. import com.gyee.alarm.websocket.WebSocket;
  12. import com.gyee.common.model.PointData;
  13. import org.springframework.beans.factory.annotation.Value;
  14. import org.springframework.stereotype.Service;
  15. import org.springframework.web.socket.TextMessage;
  16. import javax.annotation.Resource;
  17. import javax.websocket.EncodeException;
  18. import java.io.IOException;
  19. import java.sql.SQLException;
  20. import java.sql.Timestamp;
  21. import java.util.*;
  22. import java.util.concurrent.ConcurrentHashMap;
  23. @Service
  24. public class AlarmBtService {
  25. @Resource
  26. private IAlarmTsService alarmTsService;
  27. @Resource
  28. private IProEconAlarmInfoService proEconAlarmInfoService;
  29. @Value("${initialcode}")
  30. private String initialcode;
  31. @Value("${pushinterval}")
  32. private Double pushinterval;
  33. @Resource
  34. private WebSocket webSocket;
  35. @Resource
  36. private PushDataSevice pushDataSevice;
  37. @Value("${read-rows}")
  38. private Integer readRows;
  39. @Resource
  40. private IEdosUtil edosUtil;
  41. public void dropSuperTable() {
  42. alarmTsService.dropSuperTable(AlarmSuperTalbeType.BT.getCode());
  43. }
  44. public void createSuperTable() {
  45. alarmTsService.createSuperTable(AlarmSuperTalbeType.BT.getCode());
  46. }
  47. public void initalBtAlarm() throws Exception {
  48. List<AlarmTag> alarmTags = new ArrayList<>();
  49. List<AlarmVo> alarmVoList = CacheContext.alarmBtList;
  50. if (!alarmVoList.isEmpty()) {
  51. for (AlarmVo vo : alarmVoList) {
  52. alarmTsService.createTable(vo.getTbName(), vo.getAlarmid(), vo.getAlarmtype(),
  53. vo.getCharacteristic(), vo.getComponents(),
  54. vo.getDescription(),
  55. vo.getDeviceid(), vo.getDevicename(),
  56. vo.getDevicetype(), vo.getEnabled(),
  57. vo.getLineid(), vo.getLinename(),
  58. vo.getModelId(), vo.getProjectid(),
  59. vo.getProjectname(), vo.getRank(),
  60. vo.getResettable(), vo.getStationid(),
  61. vo.getStationname(), vo.getSubcomponents(),
  62. vo.getSuffix(), vo.getTagid(),
  63. vo.getTriggertype(), vo.getUniformcode(), vo.getSuperTableName(),
  64. vo.getName(),
  65. vo.getNemCode(),vo.getFaultCause(),vo.getResolvent(),vo.getFaultType(),vo.getAname());
  66. alarmTsService.updateTable(vo.getTbName(), vo.getAlarmid(), vo.getAlarmtype(),
  67. vo.getCharacteristic(), vo.getComponents(),
  68. vo.getDescription(),
  69. vo.getDeviceid(), vo.getDevicename(),
  70. vo.getDevicetype(), vo.getEnabled(),
  71. vo.getLineid(), vo.getLinename(),
  72. vo.getModelId(), vo.getProjectid(),
  73. vo.getProjectname(), vo.getRank(),
  74. vo.getResettable(), vo.getStationid(),
  75. vo.getStationname(), vo.getSubcomponents(),
  76. vo.getSuffix(), vo.getTagid(),
  77. vo.getTriggertype(), vo.getUniformcode(), vo.getSuperTableName(),
  78. vo.getName(),
  79. vo.getNemCode(),vo.getFaultCause(),vo.getResolvent(),vo.getFaultType(),vo.getAname());
  80. }
  81. }
  82. // alarmTsService.insertList(alarmTags);
  83. }
  84. public List<AlarmVo> initalAlarmVo() throws Exception {
  85. List<ProEconAlarmConfiguration> btalarmls = CacheContext.btalarmls;
  86. List<AlarmVo> alarmVoList = new ArrayList<>();
  87. if (!btalarmls.isEmpty()) {
  88. for (ProEconAlarmConfiguration alarm : btalarmls) {
  89. if (StringUtils.notEmp(alarm.getTagId()) &&
  90. (alarm.getAlarmType().equals(AlarmTypeValue.BT.getCode()) || alarm.getAlarmType().equals(AlarmTypeValue.BTE.getCode()))) {
  91. AlarmVo vo = new AlarmVo();
  92. StringBuilder tbName = new StringBuilder();
  93. tbName.append(alarm.getStationId()).append("_").append(alarm.getId());
  94. vo.setTbName(String.valueOf(tbName));
  95. vo.setAlarmid(alarm.getId());
  96. vo.setTagid(alarm.getTagId());
  97. vo.setAlarmtype(alarm.getAlarmType());
  98. vo.setCharacteristic(alarm.getCharacteristic());
  99. vo.setComponents(alarm.getComponents());
  100. vo.setDescription(alarm.getDescription());
  101. vo.setDeviceid("");
  102. vo.setDevicename("");
  103. vo.setDevicetype(DeviceTypeValue.BT.getCode());
  104. vo.setEnabled(alarm.getEnable());
  105. vo.setLineid("");
  106. vo.setLinename("");
  107. vo.setModelId(alarm.getModelId());
  108. vo.setProjectid("");
  109. vo.setProjectname("");
  110. vo.setRank(alarm.getRank());
  111. vo.setResettable(alarm.getResetTable());
  112. vo.setStationid(alarm.getStationId());
  113. if (CacheContext.subwpmap.containsKey(alarm.getStationId())) {
  114. ProBasicSubStation wp = CacheContext.subwpmap.get(alarm.getStationId());
  115. vo.setStationname(wp.getName());
  116. }
  117. vo.setSubcomponents(alarm.getSubcomponents());
  118. vo.setSuffix(alarm.getSuffix());
  119. vo.setTriggertype(alarm.getTriggerType());
  120. vo.setUniformcode(alarm.getUniformCode());
  121. vo.setSuperTableName(AlarmSuperTalbeType.BT.getCode());
  122. // PointData temp=edosUtil.getRealData(equipmentPoint.getNemCode());
  123. // vo.setVal((int)temp.getPointValueInDouble());
  124. // vo.setOval((int)temp.getPointValueInDouble());
  125. vo.setVal(null);
  126. vo.setOval(null);
  127. vo.setFaultType(alarm.getDeviceId());
  128. vo.setAname(alarm.getSuffix());
  129. vo.setName(alarm.getName());
  130. vo.setNemCode(alarm.getNemCode());
  131. vo.setFaultCause(alarm.getFaultCause());
  132. vo.setResolvent(alarm.getResolvent());
  133. alarmVoList.add(vo);
  134. }
  135. }
  136. }
  137. return alarmVoList;
  138. }
  139. public List<AlarmTag> findTags(String stbaleName) {
  140. List<AlarmTag> ls = new ArrayList<>();
  141. if (StringUtils.notEmp(stbaleName)) {
  142. // List<AlarmVo> vos= alarmTsService.findTags(stbaleName);
  143. List<AlarmVo> vos = CacheContext.alarmBtList;
  144. if (!vos.isEmpty()) {
  145. for (AlarmVo vo : vos) {
  146. AlarmTag po=new AlarmTag();
  147. po.setId(vo.getTbName());
  148. po.setOval(null);
  149. po.setTriggerType(vo.getTriggertype());
  150. po.setTagId(vo.getTagid());
  151. po.setVal(null);
  152. po.setRank(vo.getRank());
  153. po.setAlarmType(vo.getAlarmtype());
  154. po.setWpId(vo.getStationid());
  155. ls.add(po);
  156. }
  157. }
  158. }
  159. return ls;
  160. }
  161. public synchronized void saveAlarms(List<AlarmTag> ls) throws EncodeException, IOException, InterruptedException {
  162. if (StringUtils.notEmp(ls) && !ls.isEmpty()) {
  163. alarmTsService.insertList(ls);
  164. Map<String,ProEconAlarmInfo> tempmap=new HashMap<>();
  165. if (StringUtils.notEmp(ls) && !ls.isEmpty()) {
  166. List<ProEconAlarmInfo> valuels = new ArrayList<>();
  167. for (AlarmTag alarm : ls) {
  168. if (CacheContext.alarmBtMap.containsKey(alarm.getId())) {
  169. AlarmVo vo = CacheContext.alarmBtMap.get(alarm.getId());
  170. ProEconAlarmInfo po = new ProEconAlarmInfo();
  171. po.setTbname(vo.getTbName());
  172. po.setUpdateTime(new Date(alarm.getTs()));
  173. po.setLastUpdateTime(new Date(alarm.getTs()));
  174. po.setTagId(alarm.getTagId());
  175. po.setTriggerType(alarm.getTriggerType());
  176. if(alarm.getTriggerType()==-1)
  177. {
  178. if(alarm.getOval()==0)
  179. {
  180. po.setDescription(vo.getDescription()+"_分位");
  181. }else if(alarm.getOval()==1)
  182. {
  183. po.setDescription(vo.getDescription()+"_合位");
  184. }
  185. }else
  186. {
  187. po.setDescription(vo.getDescription());
  188. }
  189. po.setAlarmId(vo.getAlarmid());
  190. po.setDeviceId(vo.getDeviceid());
  191. po.setSubcomponents(vo.getSuffix());
  192. po.setRank(vo.getRank());
  193. po.setConfirmed(false);
  194. po.setUniformCode(vo.getUniformcode());
  195. po.setAlarmType(vo.getAlarmtype());
  196. po.setDeviceType(vo.getDevicetype());
  197. po.setComponents(vo.getComponents());
  198. po.setSubcomponents(vo.getSubcomponents());
  199. po.setModelId(vo.getModelId());
  200. po.setResetTable(vo.getResettable());
  201. po.setEnable(vo.getEnabled());
  202. po.setCharacteristic(vo.getCharacteristic());
  203. po.setStationId(vo.getStationid());
  204. po.setProjectId(vo.getProjectid());
  205. po.setLineId(vo.getLineid());
  206. po.setStationName(vo.getStationname());
  207. po.setProjectiName(vo.getProjectname());
  208. po.setLineidName(vo.getLinename());
  209. po.setDeviceName(vo.getDevicename());
  210. po.setOval(alarm.getOval().intValue());
  211. po.setVal(alarm.getVal().intValue());
  212. po.setIsOpen(1);
  213. alarm.setRank(vo.getRank());
  214. alarm.setDescription(vo.getDescription());
  215. alarm.setAlarmType(vo.getAlarmtype());
  216. alarm.setDeviceType(vo.getDevicetype());
  217. alarm.setCharacteristic(vo.getCharacteristic());
  218. alarm.setFaultCause(vo.getFaultCause());
  219. alarm.setResolvent(vo.getResolvent());
  220. alarm.setIsClose(false);
  221. alarm.setDeviceId(vo.getDeviceid());
  222. alarm.setAlarmId(vo.getAlarmid());
  223. if(CacheContext.subwpmap.containsKey(vo.getStationid()))
  224. {
  225. alarm.setWpName(CacheContext.subwpmap.get(vo.getStationid()).getName());
  226. }
  227. alarm.setWpId(vo.getStationid());
  228. // try {
  229. // pushDataSevice.pushBtData(alarm);
  230. // }catch (Exception e)
  231. // {
  232. // System.out.println(e.getMessage());
  233. // }
  234. //
  235. //
  236. tempmap.put(po.getTbname(),po);
  237. }
  238. }
  239. for (Map.Entry<String, ProEconAlarmInfo> entry : tempmap.entrySet()) {
  240. valuels.add(entry.getValue());
  241. }
  242. List<String> idls = new ArrayList<>();
  243. for (ProEconAlarmInfo vo : valuels) {
  244. idls.add(vo.getTbname());
  245. }
  246. // Map<String,ProEconAlarmInfo> infoMap=new HashMap<>();
  247. if (!idls.isEmpty()) {
  248. // List<ProEconAlarmInfo> templs= proEconAlarmInfoService.listByIds(idls);
  249. // if(!templs.isEmpty())
  250. // {
  251. // for(ProEconAlarmInfo info:templs)
  252. // {
  253. // infoMap.put(info.getTbname().toLowerCase(),info);
  254. // }
  255. // }
  256. proEconAlarmInfoService.removeByIds(idls);
  257. }
  258. List<ProEconAlarmInfo> templs = new ArrayList<>();
  259. for (ProEconAlarmInfo vo : valuels) {
  260. // if(infoMap.containsKey(vo.getTbname().toLowerCase()))
  261. // {
  262. // ProEconAlarmInfo in=infoMap.get(vo.getTbname().toLowerCase());
  263. // vo.setUpdateTime(in.getLastUpdateTime());
  264. // }
  265. templs.add(vo);
  266. if (templs.size() == 900) {
  267. proEconAlarmInfoService.saveBatch(templs);
  268. templs = new ArrayList<>();
  269. }
  270. }
  271. if (!templs.isEmpty()) {
  272. proEconAlarmInfoService.saveBatch(templs);
  273. }
  274. }
  275. if (StringUtils.notEmp(ls) && !ls.isEmpty()) {
  276. for (AlarmTag alarm : ls) {
  277. if (CacheContext.alarmBtMap.containsKey(alarm.getId())) {
  278. AlarmVo vo = CacheContext.alarmBtMap.get(alarm.getId());
  279. alarm.setRank(vo.getRank());
  280. alarm.setDescription(vo.getDescription());
  281. alarm.setAlarmType(vo.getAlarmtype());
  282. alarm.setDeviceType(vo.getDevicetype());
  283. alarm.setCharacteristic(vo.getCharacteristic());
  284. alarm.setFaultCause(vo.getFaultCause());
  285. alarm.setResolvent(vo.getResolvent());
  286. alarm.setIsClose(false);
  287. alarm.setDeviceId(vo.getDeviceid());
  288. alarm.setAlarmId(vo.getAlarmid());
  289. if(CacheContext.subwpmap.containsKey(vo.getStationid()))
  290. {
  291. alarm.setWpName(CacheContext.subwpmap.get(vo.getStationid()).getName());
  292. }
  293. alarm.setWpId(vo.getStationid());
  294. pushDataSevice.pushBtData(alarm);
  295. }
  296. }
  297. Thread.sleep(pushinterval.intValue());
  298. }
  299. }
  300. }
  301. public synchronized void updateAlarms(List<AlarmTag> ls) throws EncodeException, IOException, InterruptedException {
  302. if (StringUtils.notEmp(ls) && !ls.isEmpty()) {
  303. StringBuilder sb=new StringBuilder();
  304. Map<String,AlarmSimpleVo> map=new HashMap<>();
  305. for (AlarmTag alarm : ls) {
  306. if (CacheContext.alarmBtMap.containsKey(alarm.getId())) {
  307. AlarmVo vo = CacheContext.alarmBtMap.get(alarm.getId());
  308. if(vo.getAlarmtype().equals(AlarmTypeValue.BT.getCode()) )
  309. {
  310. sb.append("'").append(alarm.getId().toLowerCase()).append("',");
  311. }
  312. }
  313. }
  314. String ids=null;
  315. if(sb.length()>0)
  316. {
  317. ids=sb.substring(0,sb.length()-1);
  318. }
  319. List<AlarmSimpleVo> alarmls=new ArrayList<>();
  320. if( null !=ids)
  321. {
  322. alarmls=alarmTsService.selectLastRowByTbname(AlarmSuperTalbeType.BT.getCode(),ids);
  323. }
  324. if(!alarmls.isEmpty())
  325. {
  326. for(AlarmSimpleVo vo:alarmls)
  327. {
  328. map.put(vo.getTbName().toLowerCase(),vo);
  329. }
  330. }
  331. List<AlarmTag> alarmTagls=new ArrayList<>();
  332. for (AlarmTag alarm : ls) {
  333. if(map.containsKey(alarm.getId().toLowerCase()))
  334. {
  335. AlarmSimpleVo tag=map.get(alarm.getId().toLowerCase());
  336. if(StringUtils.notEmp(tag.getTs()))
  337. {
  338. alarm.setTs(tag.getTs());
  339. Date begin = new Date(alarm.getEndts());
  340. Date end = new Date(alarm.getTs());
  341. double value= DateUtils.secondsDiff(begin,end);
  342. alarm.setTimeLong(value);
  343. alarm.setConfirmed(tag.getConfirmed());
  344. alarm.setSuperTalbe(AlarmSuperTalbeType.BT.getCode());
  345. alarmTagls.add(alarm);
  346. }
  347. }
  348. // else
  349. // {
  350. // alarm.setSuperTalbe(AlarmSuperTalbeType.BT.getCode());
  351. // alarmTagls.add(alarm);
  352. // }
  353. }
  354. if (StringUtils.notEmp(alarmTagls) && !alarmTagls.isEmpty()) {
  355. alarmTsService.insertList(alarmTagls);
  356. }
  357. Map<String,ProEconAlarmInfo> tempmap=new HashMap<>();
  358. if (StringUtils.notEmp(alarmTagls) && !alarmTagls.isEmpty()) {
  359. List<ProEconAlarmInfo> valuels = new ArrayList<>();
  360. for (AlarmTag alarm : alarmTagls) {
  361. if (CacheContext.alarmBtMap.containsKey(alarm.getId())) {
  362. AlarmVo vo = CacheContext.alarmBtMap.get(alarm.getId());
  363. ProEconAlarmInfo po = new ProEconAlarmInfo();
  364. po.setTbname(vo.getTbName());
  365. po.setUpdateTime(new Date(alarm.getTs()));
  366. po.setLastUpdateTime(new Date(alarm.getEndts()));
  367. po.setTagId(alarm.getTagId());
  368. po.setTriggerType(alarm.getTriggerType());
  369. po.setAlarmId(vo.getAlarmid());
  370. po.setDeviceId(vo.getDeviceid());
  371. po.setSubcomponents(vo.getSuffix());
  372. po.setRank(vo.getRank());
  373. po.setConfirmed(alarm.getConfirmed());
  374. po.setUniformCode(vo.getUniformcode());
  375. po.setAlarmType(vo.getAlarmtype());
  376. po.setDeviceType(vo.getDevicetype());
  377. po.setComponents(vo.getComponents());
  378. po.setSubcomponents(vo.getSubcomponents());
  379. po.setDescription(vo.getDescription());
  380. po.setModelId(vo.getModelId());
  381. po.setResetTable(vo.getResettable());
  382. po.setEnable(vo.getEnabled());
  383. po.setCharacteristic(vo.getCharacteristic());
  384. po.setStationId(vo.getStationid());
  385. po.setProjectId(vo.getProjectid());
  386. po.setLineId(vo.getLineid());
  387. po.setStationName(vo.getStationname());
  388. po.setProjectiName(vo.getProjectname());
  389. po.setLineidName(vo.getLinename());
  390. po.setDeviceName(vo.getDevicename());
  391. po.setOval(alarm.getOval().intValue());
  392. po.setVal(alarm.getVal().intValue());
  393. if(StringUtils.notEmp(alarm.getEndts()))
  394. {
  395. po.setCloseTime(new Date(alarm.getEndts()));
  396. }else
  397. {
  398. po.setCloseTime(new Date());
  399. }
  400. po.setIsOpen(0);
  401. alarm.setRank(vo.getRank());
  402. alarm.setDescription(vo.getDescription());
  403. alarm.setAlarmType(vo.getAlarmtype());
  404. alarm.setDeviceType(vo.getDevicetype());
  405. alarm.setCharacteristic(vo.getCharacteristic());
  406. alarm.setFaultCause(vo.getFaultCause());
  407. alarm.setResolvent(vo.getResolvent());
  408. alarm.setDeviceId(vo.getDeviceid());
  409. alarm.setAlarmId(vo.getAlarmid());
  410. alarm.setIsClose(true);
  411. if(CacheContext.subwpmap.containsKey(vo.getStationid()))
  412. {
  413. alarm.setWpName(CacheContext.subwpmap.get(vo.getStationid()).getName());
  414. }
  415. alarm.setWpId(vo.getStationid());
  416. // try {
  417. // pushDataSevice.pushBtData(alarm);
  418. // }catch (Exception e)
  419. // {
  420. // System.out.println(e.getMessage());
  421. // }
  422. tempmap.put(po.getTbname(),po);
  423. }
  424. }
  425. for (Map.Entry<String, ProEconAlarmInfo> entry : tempmap.entrySet()) {
  426. valuels.add(entry.getValue());
  427. }
  428. List<String> idls = new ArrayList<>();
  429. for (ProEconAlarmInfo vo : valuels) {
  430. idls.add(vo.getTbname());
  431. }
  432. // Map<String,ProEconAlarmInfo> infoMap=new HashMap<>();
  433. if (!idls.isEmpty()) {
  434. // List<ProEconAlarmInfo> templs= proEconAlarmInfoService.listByIds(idls);
  435. // if(!templs.isEmpty())
  436. // {
  437. // for(ProEconAlarmInfo info:templs)
  438. // {
  439. // infoMap.put(info.getTbname().toLowerCase(),info);
  440. // }
  441. // }
  442. proEconAlarmInfoService.removeByIds(idls);
  443. }
  444. List<ProEconAlarmInfo> templs = new ArrayList<>();
  445. for (ProEconAlarmInfo vo : valuels) {
  446. // if(infoMap.containsKey(vo.getTbname().toLowerCase()))
  447. // {
  448. // ProEconAlarmInfo in=infoMap.get(vo.getTbname().toLowerCase());
  449. // vo.setUpdateTime(in.getLastUpdateTime());
  450. // }
  451. templs.add(vo);
  452. if (templs.size() == 900) {
  453. proEconAlarmInfoService.saveBatch(templs);
  454. templs = new ArrayList<>();
  455. }
  456. }
  457. if (!templs.isEmpty()) {
  458. proEconAlarmInfoService.saveBatch(templs);
  459. }
  460. }
  461. if (StringUtils.notEmp(ls) && !ls.isEmpty()) {
  462. for (AlarmTag alarm : ls) {
  463. if (CacheContext.alarmBtMap.containsKey(alarm.getId())) {
  464. AlarmVo vo = CacheContext.alarmBtMap.get(alarm.getId());
  465. alarm.setRank(vo.getRank());
  466. alarm.setDescription(vo.getDescription());
  467. alarm.setAlarmType(vo.getAlarmtype());
  468. alarm.setDeviceType(vo.getDevicetype());
  469. alarm.setCharacteristic(vo.getCharacteristic());
  470. alarm.setFaultCause(vo.getFaultCause());
  471. alarm.setResolvent(vo.getResolvent());
  472. alarm.setIsClose(false);
  473. alarm.setDeviceId(vo.getDeviceid());
  474. alarm.setAlarmId(vo.getAlarmid());
  475. if(CacheContext.subwpmap.containsKey(vo.getStationid()))
  476. {
  477. alarm.setWpName(CacheContext.subwpmap.get(vo.getStationid()).getName());
  478. }
  479. alarm.setWpId(vo.getStationid());
  480. pushDataSevice.pushBtData(alarm);
  481. }
  482. }
  483. Thread.sleep(pushinterval.intValue());
  484. }
  485. }
  486. }
  487. // public synchronized void pushData(AlarmTag po) throws EncodeException, IOException {
  488. // ConcurrentHashMap<String, WebSocket> webSocketPushMap = WebSocket.webSocketMap;
  489. // ConcurrentHashMap<String, PushParams> webSocketPushParamsMap = WebSocket.webSocketParamsMap;
  490. // if(!webSocketPushMap.isEmpty()){
  491. // for(String key : webSocketPushMap.keySet()){
  492. // // 根据ws连接用户ID获取推送参数
  493. // PushParams pushParams = webSocketPushParamsMap.get(key);
  494. //
  495. // if(webSocketPushParamsMap.contains(po.getId()))
  496. // {
  497. // PushParams pp=webSocketPushParamsMap.get(po.getId());
  498. //
  499. // double hours=DateUtils.hoursDiff(pp.getStartTime(),new Date());
  500. // if(hours>pushinterval)
  501. // {
  502. //
  503. // webSocket.sendMessageByUserId(key,po);
  504. // pp.setStartTime(new Date(po.getTs()));
  505. //
  506. // }
  507. // }else
  508. // {
  509. // webSocket.sendMessageByUserId(key,po);
  510. // PushParams pp=new PushParams();
  511. // pp.setStartTime(new Date());
  512. // webSocketPushParamsMap.put(po.getId(),pp);
  513. //
  514. // }
  515. // }
  516. // }
  517. //
  518. // }
  519. }