123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176 |
- package com.gyee.alarm.service;
- import com.gyee.alarm.init.CacheContext;
- import com.gyee.alarm.model.auto.*;
- import com.gyee.alarm.model.vo.*;
- import com.gyee.alarm.service.auto.IAlarmTsService;
- import com.gyee.alarm.service.auto.IProEconAlarmInfoService;
- import com.gyee.alarm.util.DateUtils;
- import com.gyee.alarm.util.StringUtils;
- import org.springframework.beans.factory.annotation.Value;
- import org.springframework.stereotype.Service;
- import org.springframework.web.context.request.RequestContextHolder;
- import org.springframework.web.context.request.ServletRequestAttributes;
- import javax.annotation.Resource;
- import javax.servlet.http.HttpServletRequest;
- import javax.websocket.EncodeException;
- import java.io.IOException;
- import java.sql.SQLException;
- import java.util.*;
- import java.util.concurrent.ConcurrentHashMap;
- @Service
- public class AlarmInService {
- @Resource
- private IAlarmTsService alarmTsService;
- @Resource
- private IProEconAlarmInfoService proEconAlarmInfoService;
- @Value("${initialcode}")
- private String initialcode;
- @Resource
- private TokenService tokenService;
- public List<AlarmVo> initalAlarmVo() {
- List<AlarmVo> alarmVoList=new ArrayList<>();
- Map<String, List<ProEconAlarmConfiguration>> wtAlarmMap = CacheContext.wtAlarmMap;
- Map<String, Map<String, ProBasicEquipmentPoint>> wtpAimap = CacheContext.wtpAimap;
- // HttpServletRequest request = ((ServletRequestAttributes) (RequestContextHolder.currentRequestAttributes())).getRequest();
- // List<ProBasicEquipment> wtls = tokenService.getWtls(request);
- for (ProBasicEquipment wt : CacheContext.wtls) {
- if (wtpAimap.containsKey(wt.getId())) {
- Map<String, ProBasicEquipmentPoint> pointMap = wtpAimap.get(wt.getId());
- StringBuilder sb = new StringBuilder();
- sb.append(wt.getWindpowerstationId() + wt.getModelId());
- if (StringUtils.notEmp(pointMap) && wtAlarmMap.containsKey(String.valueOf(sb))) {
- List<ProEconAlarmConfiguration> alarmls = wtAlarmMap.get(String.valueOf(sb));
- if (!alarmls.isEmpty()) {
- for (ProEconAlarmConfiguration alarm : alarmls) {
- if (pointMap.containsKey(alarm.getUniformCode())) {
- ProBasicEquipmentPoint equipmentPoint = pointMap.get(alarm.getUniformCode());
- if(StringUtils.notEmp(initialcode) &&
- StringUtils.notEmp(equipmentPoint.getNemCode()) &&
- !equipmentPoint.getNemCode().equals(initialcode) &&
- alarm.getAlarmType().equals(AlarmTypeValue.IN.getCode())
- )
- {
- AlarmVo vo=new AlarmVo();
- StringBuilder tbName = new StringBuilder();
- tbName.append(wt.getId()).append("_").append(alarm.getId());
- vo.setTbName(String.valueOf(tbName));
- vo.setAlarmId(alarm.getId());
- vo.setTagid(equipmentPoint.getNemCode());
- vo.setAlarmType(alarm.getAlarmType());
- vo.setCharacteristic(alarm.getCharacteristic());
- vo.setComponents(alarm.getComponents());
- vo.setDescription(alarm.getDescription());
- vo.setDeviceId(wt.getId());
- vo.setDevicename(wt.getName());
- vo.setDeviceType(alarm.getDeviceType());
- vo.setEnabled(alarm.getEnable());
- vo.setLineid(wt.getLineId());
- if(CacheContext.lnmap.containsKey(wt.getLineId()))
- {
- ProBasicLine ln=CacheContext.lnmap.get(wt.getLineId());
- vo.setLinename(ln.getName());
- }
- vo.setModelId(wt.getModelId());
- vo.setProjectid(wt.getProjectId());
- if(CacheContext.pjmap.containsKey(wt.getProjectId()))
- {
- ProBasicProject pj=CacheContext.pjmap.get(wt.getProjectId());
- vo.setProjectname(pj.getName());
- }
- vo.setRank(alarm.getRank());
- vo.setResettable(alarm.getResetTable());
- vo.setStationid(wt.getWindpowerstationId());
- if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
- {
- ProBasicPowerstation wp=CacheContext.wpmap.get(wt.getWindpowerstationId());
- vo.setStationname(wp.getName());
- }
- vo.setSubcomponents(alarm.getSubcomponents());
- vo.setSuffix(alarm.getSuffix());
- vo.setTriggertype(alarm.getTriggerType());
- vo.setUniformcode(alarm.getUniformCode());
- vo.setSuperTableName(AlarmSuperTalbeType.WT.getCode());
- vo.setVal(0);
- vo.setName(alarm.getName());
- vo.setNemCode(alarm.getNemCode());
- vo.setFaultCause(alarm.getFaultCause());
- vo.setResolvent(alarm.getResolvent());
- alarmVoList.add(vo);
- }
- }
- // else {
- //
- // //临时创建表
- // AlarmVo vo=new AlarmVo();
- // StringBuilder tbName = new StringBuilder();
- // tbName.append(wt.getId()).append("_").append(alarm.getId());
- // vo.setTbName(String.valueOf(tbName));
- // vo.setAlarmid(alarm.getId());
- // vo.setTagid("GF-TZ-SYZ.038200G9911SYB99GI017DB0111PA99RAW01");
- // vo.setAlarmtype(alarm.getAlarmType());
- // vo.setCharacteristic(alarm.getCharacteristic());
- // vo.setComponents(alarm.getComponents());
- // vo.setDescription(alarm.getDescription());
- // vo.setDeviceid(wt.getId());
- // vo.setDevicename(wt.getName());
- // vo.setDevicetype(alarm.getDeviceType());
- // vo.setEnabled(alarm.getEnable());
- // vo.setLineid(wt.getLineId());
- // if(CacheContext.lnmap.containsKey(wt.getLineId()))
- // {
- // ProBasicLine ln=CacheContext.lnmap.get(wt.getLineId());
- // vo.setLinename(ln.getName());
- // }
- // vo.setModelId(wt.getModelId());
- // vo.setProjectid(wt.getProjectId());
- // if(CacheContext.pjmap.containsKey(wt.getProjectId()))
- // {
- // ProBasicProject pj=CacheContext.pjmap.get(wt.getProjectId());
- // vo.setProjectname(pj.getName());
- // }
- // vo.setRank(alarm.getRank());
- // vo.setResettable(alarm.getResetTable());
- // vo.setStationid(wt.getWindpowerstationId());
- // if(CacheContext.wpmap.containsKey(wt.getWindpowerstationId()))
- // {
- // ProBasicPowerstation wp=CacheContext.wpmap.get(wt.getWindpowerstationId());
- // vo.setStationname(wp.getName());
- // }
- // vo.setSubcomponents(alarm.getSubcomponents());
- // vo.setSuffix(alarm.getSuffix());
- // vo.setTriggertype(alarm.getTriggerType());
- // vo.setUniformcode(alarm.getUniformCode());
- // vo.setSuperTableName(AlarmSuperTalbeType.WT.getCode());
- // vo.setVal(0);
- // vo.setOval(0);
- // alarmVoList.add(vo);
- //
- // }
- }
- }
- }
- }
- }
- return alarmVoList;
- }
- }
|