AlarmWtService.java 9.8 KB

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