AlarmInService.java 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176
  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 org.springframework.beans.factory.annotation.Value;
  10. import org.springframework.stereotype.Service;
  11. import org.springframework.web.context.request.RequestContextHolder;
  12. import org.springframework.web.context.request.ServletRequestAttributes;
  13. import javax.annotation.Resource;
  14. import javax.servlet.http.HttpServletRequest;
  15. import javax.websocket.EncodeException;
  16. import java.io.IOException;
  17. import java.sql.SQLException;
  18. import java.util.*;
  19. import java.util.concurrent.ConcurrentHashMap;
  20. @Service
  21. public class AlarmInService {
  22. @Resource
  23. private IAlarmTsService alarmTsService;
  24. @Resource
  25. private IProEconAlarmInfoService proEconAlarmInfoService;
  26. @Value("${initialcode}")
  27. private String initialcode;
  28. @Resource
  29. private TokenService tokenService;
  30. public List<AlarmVo> initalAlarmVo() {
  31. List<AlarmVo> alarmVoList=new ArrayList<>();
  32. Map<String, List<ProEconAlarmConfiguration>> wtAlarmMap = CacheContext.wtAlarmMap;
  33. Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
  34. // HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
  35. // List<ProBasicEquipment> wtls = tokenService.getWtls(request);
  36. for (ProBasicEquipment wt : CacheContext.wtls) {
  37. if (wtpAimap.containsKey(wt.getId())) {
  38. Map<String, ProBasicEquipmentPoint> pointMap = wtpAimap.get(wt.getId());
  39. StringBuilder sb = new StringBuilder();
  40. sb.append(wt.getWindpowerstationId() + wt.getModelId());
  41. if (StringUtils.notEmp(pointMap) && wtAlarmMap.containsKey(String.valueOf(sb))) {
  42. List<ProEconAlarmConfiguration> alarmls = wtAlarmMap.get(String.valueOf(sb));
  43. if (!alarmls.isEmpty()) {
  44. for (ProEconAlarmConfiguration alarm : alarmls) {
  45. if (pointMap.containsKey(alarm.getUniformCode())) {
  46. ProBasicEquipmentPoint equipmentPoint = pointMap.get(alarm.getUniformCode());
  47. if(StringUtils.notEmp(initialcode) &&
  48. StringUtils.notEmp(equipmentPoint.getNemCode()) &&
  49. !equipmentPoint.getNemCode().equals(initialcode) &&
  50. alarm.getAlarmType().equals(AlarmTypeValue.IN.getCode())
  51. )
  52. {
  53. AlarmVo vo=new AlarmVo();
  54. StringBuilder tbName = new StringBuilder();
  55. tbName.append(wt.getId()).append("_").append(alarm.getId());
  56. vo.setTbName(String.valueOf(tbName));
  57. vo.setAlarmId(alarm.getId());
  58. vo.setTagid(equipmentPoint.getNemCode());
  59. vo.setAlarmType(alarm.getAlarmType());
  60. vo.setCharacteristic(alarm.getCharacteristic());
  61. vo.setComponents(alarm.getComponents());
  62. vo.setDescription(alarm.getDescription());
  63. vo.setDeviceId(wt.getId());
  64. vo.setDevicename(wt.getName());
  65. vo.setDeviceType(alarm.getDeviceType());
  66. vo.setEnabled(alarm.getEnable());
  67. vo.setLineid(wt.getLineId());
  68. if(CacheContext.lnmap.containsKey(wt.getLineId()))
  69. {
  70. ProBasicLine ln=CacheContext.lnmap.get(wt.getLineId());
  71. vo.setLinename(ln.getName());
  72. }
  73. vo.setModelId(wt.getModelId());
  74. vo.setProjectid(wt.getProjectId());
  75. if(CacheContext.pjmap.containsKey(wt.getProjectId()))
  76. {
  77. ProBasicProject pj=CacheContext.pjmap.get(wt.getProjectId());
  78. vo.setProjectname(pj.getName());
  79. }
  80. vo.setRank(alarm.getRank());
  81. vo.setResettable(alarm.getResetTable());
  82. vo.setStationid(wt.getWindpowerstationId());
  83. if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
  84. {
  85. ProBasicPowerstation wp=CacheContext.wpmap.get(wt.getWindpowerstationId());
  86. vo.setStationname(wp.getName());
  87. }
  88. vo.setSubcomponents(alarm.getSubcomponents());
  89. vo.setSuffix(alarm.getSuffix());
  90. vo.setTriggertype(alarm.getTriggerType());
  91. vo.setUniformcode(alarm.getUniformCode());
  92. vo.setSuperTableName(AlarmSuperTalbeType.WT.getCode());
  93. vo.setVal(0);
  94. vo.setName(alarm.getName());
  95. vo.setNemCode(alarm.getNemCode());
  96. vo.setFaultCause(alarm.getFaultCause());
  97. vo.setResolvent(alarm.getResolvent());
  98. alarmVoList.add(vo);
  99. }
  100. }
  101. // else {
  102. //
  103. // //临时创建表
  104. // AlarmVo vo=new AlarmVo();
  105. // StringBuilder tbName = new StringBuilder();
  106. // tbName.append(wt.getId()).append("_").append(alarm.getId());
  107. // vo.setTbName(String.valueOf(tbName));
  108. // vo.setAlarmid(alarm.getId());
  109. // vo.setTagid("GF-TZ-SYZ.038200G9911SYB99GI017DB0111PA99RAW01");
  110. // vo.setAlarmtype(alarm.getAlarmType());
  111. // vo.setCharacteristic(alarm.getCharacteristic());
  112. // vo.setComponents(alarm.getComponents());
  113. // vo.setDescription(alarm.getDescription());
  114. // vo.setDeviceid(wt.getId());
  115. // vo.setDevicename(wt.getName());
  116. // vo.setDevicetype(alarm.getDeviceType());
  117. // vo.setEnabled(alarm.getEnable());
  118. // vo.setLineid(wt.getLineId());
  119. // if(CacheContext.lnmap.containsKey(wt.getLineId()))
  120. // {
  121. // ProBasicLine ln=CacheContext.lnmap.get(wt.getLineId());
  122. // vo.setLinename(ln.getName());
  123. // }
  124. // vo.setModelId(wt.getModelId());
  125. // vo.setProjectid(wt.getProjectId());
  126. // if(CacheContext.pjmap.containsKey(wt.getProjectId()))
  127. // {
  128. // ProBasicProject pj=CacheContext.pjmap.get(wt.getProjectId());
  129. // vo.setProjectname(pj.getName());
  130. // }
  131. // vo.setRank(alarm.getRank());
  132. // vo.setResettable(alarm.getResetTable());
  133. // vo.setStationid(wt.getWindpowerstationId());
  134. // if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
  135. // {
  136. // ProBasicPowerstation wp=CacheContext.wpmap.get(wt.getWindpowerstationId());
  137. // vo.setStationname(wp.getName());
  138. // }
  139. // vo.setSubcomponents(alarm.getSubcomponents());
  140. // vo.setSuffix(alarm.getSuffix());
  141. // vo.setTriggertype(alarm.getTriggerType());
  142. // vo.setUniformcode(alarm.getUniformCode());
  143. // vo.setSuperTableName(AlarmSuperTalbeType.WT.getCode());
  144. // vo.setVal(0);
  145. // vo.setOval(0);
  146. // alarmVoList.add(vo);
  147. //
  148. // }
  149. }
  150. }
  151. }
  152. }
  153. }
  154. return alarmVoList;
  155. }
  156. }