| | |
| | | package com.whyc.service; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import com.github.pagehelper.PageHelper; |
| | | import com.github.pagehelper.PageInfo; |
| | | import com.whyc.constant.DevAlarmEnum; |
| | | import com.whyc.constant.PowerAlarmEnum; |
| | | import com.whyc.dto.AlarmDto; |
| | | import com.whyc.dto.Param.AlmAnalyseDto; |
| | | import com.whyc.dto.Real.AlmDto; |
| | | import com.whyc.dto.Real.RealDateDTO; |
| | | import com.whyc.dto.Response; |
| | | import com.whyc.factory.ThreadPoolExecutorFactory; |
| | | import com.whyc.mapper.PwrdevAlarmMapper; |
| | | import com.whyc.pojo.db_alarm.DevalarmData; |
| | | import com.whyc.pojo.db_data_history.BattRealdataId; |
| | | import com.whyc.pojo.db_data_history.PwrdevHistorydataId; |
| | | import com.whyc.pojo.db_param.AlmAnalysisParam; |
| | | import com.whyc.pojo.db_param.AppParam; |
| | | import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarm; |
| | | import com.whyc.pojo.db_pwrdev_alarm.PwrdevAlarmParam; |
| | | import com.whyc.pojo.web_site.AlarmInspection; |
| | | import com.whyc.util.ActionUtil; |
| | | import com.whyc.util.DateUtil; |
| | | import com.whyc.util.ThreadLocalUtil; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | |
| | | import java.text.ParseException; |
| | | import java.text.SimpleDateFormat; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.*; |
| | | import java.util.concurrent.CountDownLatch; |
| | | import java.util.concurrent.ThreadPoolExecutor; |
| | | import java.util.concurrent.TimeUnit; |
| | | import java.util.stream.Collectors; |
| | | |
| | | import static java.lang.Thread.sleep; |
| | | |
| | | @Service |
| | | public class PwrdevAlarmService { |
| | | @Autowired(required = false) |
| | | private PwrdevAlarmMapper mapper; |
| | | @Autowired |
| | | private AppParamService appParamService; |
| | | @Autowired |
| | | private AlmAnalysisParamService almAnalysisParamService; |
| | | @Autowired |
| | | private SubTablePageInfoService subTablePageInfoService; |
| | | @Autowired |
| | | private BattInfService battInfService; |
| | | //获取电源实时告警信息 |
| | | public Response getPwrAlmReal(AlmDto almDto) { |
| | | PageHelper.startPage(almDto.getPageNum(),almDto.getPageSize()); |
| | | List<PwrdevAlarm> list=mapper.getPwrAlmReal(almDto); |
| | | list.forEach(data->{ |
| | | data.setAlmName(PowerAlarmEnum.getValue(data.getAlmId())); |
| | | }); |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"获取电源实时告警信息"); |
| | | } |
| | |
| | | int flag=mapper.update((PwrdevAlarm) ActionUtil.objeNull,wrapper); |
| | | return new Response().set(1,flag>0,flag>0?"确认成功":"确认失败"); |
| | | } |
| | | //获取一级未处理实时告警数 |
| | | public Integer getPwrAlmNum(Integer powerId) { |
| | | QueryWrapper wrapper=new QueryWrapper(); |
| | | wrapper.eq("power_id",powerId); |
| | | wrapper.eq("alm_is_confirmed",0); |
| | | wrapper.eq("alm_level",1); |
| | | List<DevalarmData> list=mapper.selectList(wrapper); |
| | | return list!=null?list.size():0; |
| | | } |
| | | //获取电源告警类型(下拉) |
| | | public Response getPwrAlmIdType() { |
| | | Map<String,Map<Integer,String>> map= PowerAlarmEnum.getOpInfo(); |
| | | return new Response().setII(1,true,map,"获取电源告警类型(下拉)"); |
| | | } |
| | | |
| | | public List<AlarmInspection> getListGreatThan(Long id) { |
| | | List<AlarmInspection> listGreatThan = mapper.getListGreatThan(id); |
| | | Date now = new Date(); |
| | | listGreatThan.forEach(data->{ |
| | | data.setType(1); |
| | | data.setIsExist(1); |
| | | data.setCreateTime(now); |
| | | }); |
| | | return listGreatThan; |
| | | } |
| | | |
| | | public List<Long> getNumListInDB(List<Long> powerAlarmNumList) { |
| | | QueryWrapper<PwrdevAlarm> query = Wrappers.query(); |
| | | query.select("num"); |
| | | query.in("num",powerAlarmNumList); |
| | | return mapper.selectList(query).stream().map(PwrdevAlarm::getNum).collect(Collectors.toList()); |
| | | } |
| | | |
| | | public List<AlarmDto> getListByUserId(Integer userId,Integer alarmLevel) { |
| | | return mapper.getListByUserId(userId,alarmLevel); |
| | | } |
| | | |
| | | //预警分析管理-电源告警 |
| | | public Response getPwrtAlmAnalyse(AlmAnalyseDto dto) { |
| | | PageHelper .startPage(dto.getPageNum(),dto.getPageSize()); |
| | | List<PwrdevAlarm> list=mapper.getPwrtAlmAnalyse(dto); |
| | | for (PwrdevAlarm pwrAlm:list) { |
| | | pwrAlm.setAlmName(PowerAlarmEnum.getValue(pwrAlm.getAlmId())); |
| | | //查询电源下所有的电池组id |
| | | List<Integer> battgroupIdList = battInfService.getBattgroupIdList(pwrAlm.getPowerId()); |
| | | pwrAlm.setBattgroupIdList(battgroupIdList); |
| | | } |
| | | PageInfo pageInfo=new PageInfo(list); |
| | | return new Response().setII(1,list!=null,pageInfo,"电源告警分析"); |
| | | } |
| | | |
| | | } |