|
@@ -0,0 +1,137 @@
|
|
|
+package com.usky.issue.service.impl;
|
|
|
+
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DS;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
+import com.usky.common.core.util.StringUtils;
|
|
|
+import com.usky.issue.domain.*;
|
|
|
+import com.usky.issue.mapper.SpDeviceAlarmMapper;
|
|
|
+import com.usky.issue.service.*;
|
|
|
+import com.usky.common.mybatis.core.AbstractCrudService;
|
|
|
+import org.apache.commons.lang.math.NumberUtils;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.stereotype.Service;
|
|
|
+
|
|
|
+import java.time.LocalDateTime;
|
|
|
+import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
+/**
|
|
|
+ * <p>
|
|
|
+ * 设备告警表 服务实现类
|
|
|
+ * </p>
|
|
|
+ *
|
|
|
+ * @author fu
|
|
|
+ * @since 2024-01-24
|
|
|
+ */
|
|
|
+@Service
|
|
|
+public class SpDeviceAlarmServiceImpl extends AbstractCrudService<SpDeviceAlarmMapper, SpDeviceAlarm> implements SpDeviceAlarmService {
|
|
|
+ @Autowired
|
|
|
+ private SpOwnerService spOwnerService;
|
|
|
+ @Autowired
|
|
|
+ private SpEf2017Service spEf2017Service;
|
|
|
+ @Autowired
|
|
|
+ private SpHj2017Service spHj2017Service;
|
|
|
+ @Autowired
|
|
|
+ private SpRtu2017Service spRtu2017Service;
|
|
|
+ @Autowired
|
|
|
+ private SpSj2017Service spSj2017Service;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 告警数据更新hj、sj、rtu、ef
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ @DS("usky-website")
|
|
|
+ public void updateAlarm() {
|
|
|
+ QueryWrapper<SpDeviceAlarm> queryWrapper = new QueryWrapper<>();
|
|
|
+ queryWrapper.orderByDesc("id").last("LIMIT 1");
|
|
|
+ SpDeviceAlarm lastAlarm = baseMapper.selectOne(queryWrapper);
|
|
|
+ List<SpEf2017> listEf;
|
|
|
+ List<SpHj2017> listHj;
|
|
|
+ List<SpRtu2017> listRtu;
|
|
|
+ List<SpSj2017> listSj;
|
|
|
+ if (lastAlarm == null) {
|
|
|
+ listEf = spEf2017Service.getOwners();
|
|
|
+ listHj = spHj2017Service.getOwners();
|
|
|
+ listRtu = spRtu2017Service.getOwners();
|
|
|
+ listSj = spSj2017Service.getOwners();
|
|
|
+ } else {
|
|
|
+ LocalDateTime time = lastAlarm.getAlarmTime();
|
|
|
+ listEf = spEf2017Service.getOwners().stream()
|
|
|
+ .filter(owner -> owner.getTime().isAfter(time))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ listHj = spHj2017Service.getOwners().stream()
|
|
|
+ .filter(owner -> owner.getTime().isAfter(time))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ listRtu = spRtu2017Service.getOwners().stream()
|
|
|
+ .filter(owner -> owner.getTime().isAfter(time))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ listSj = spSj2017Service.getOwners().stream()
|
|
|
+ .filter(owner -> owner.getTime().isAfter(time))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ for (SpEf2017 ef : listEf) {
|
|
|
+ SpDeviceAlarm newAlarm = new SpDeviceAlarm();
|
|
|
+ newAlarm.setDeviceCode(ef.getDeviceCode());
|
|
|
+ newAlarm.setAlarmTime(ef.getTime());
|
|
|
+ newAlarm.setDeviceType(spOwnerService.getType(ef.getDeviceCode()));
|
|
|
+ newAlarm.setAlarmType(ef.getData1());
|
|
|
+ newAlarm.setAlarmName(spEf2017Service.getAlarmName(ef.getData1()));
|
|
|
+ newAlarm.setAlarmAddress(null);
|
|
|
+ newAlarm.setHandler(ef.getClr());
|
|
|
+ newAlarm.setHandlingTime(ef.getClsj());
|
|
|
+ newAlarm.setHandlingContent(ef.getClnr());
|
|
|
+ newAlarm.setHandlingStatus(ef.getClzt());
|
|
|
+ Integer falseAlarmValue = StringUtils.isBlank(ef.getClwb()) ? null : NumberUtils.createInteger(ef.getClwb());
|
|
|
+ newAlarm.setFalseAlarm(falseAlarmValue);
|
|
|
+ baseMapper.insert(newAlarm);
|
|
|
+ }
|
|
|
+ for (SpHj2017 hj : listHj) {
|
|
|
+ SpDeviceAlarm newAlarm = new SpDeviceAlarm();
|
|
|
+ newAlarm.setDeviceCode(hj.getDeviceCode());
|
|
|
+ newAlarm.setAlarmTime(hj.getTime());
|
|
|
+ newAlarm.setDeviceType(spOwnerService.getType(hj.getDeviceCode()));
|
|
|
+ newAlarm.setAlarmType(hj.getData1());
|
|
|
+ newAlarm.setAlarmName(hj.getData2());
|
|
|
+ newAlarm.setAlarmAddress(hj.getData4());
|
|
|
+ newAlarm.setHandler(hj.getClr());
|
|
|
+ newAlarm.setHandlingTime(hj.getClsj());
|
|
|
+ newAlarm.setHandlingContent(hj.getClnr());
|
|
|
+ newAlarm.setHandlingStatus(hj.getClzt());
|
|
|
+ Integer falseAlarmValue = StringUtils.isBlank(hj.getClwb()) ? null : NumberUtils.createInteger(hj.getClwb());
|
|
|
+ newAlarm.setFalseAlarm(falseAlarmValue);
|
|
|
+ baseMapper.insert(newAlarm);
|
|
|
+ }
|
|
|
+ for (SpRtu2017 rtu : listRtu) {
|
|
|
+ SpDeviceAlarm newAlarm = new SpDeviceAlarm();
|
|
|
+ newAlarm.setDeviceCode(rtu.getDeviceCode());
|
|
|
+ newAlarm.setAlarmTime(rtu.getTime());
|
|
|
+ newAlarm.setDeviceType(spOwnerService.getType(rtu.getDeviceCode()));
|
|
|
+ newAlarm.setAlarmType(rtu.getPort());
|
|
|
+ newAlarm.setAlarmName(rtu.getData2());
|
|
|
+ newAlarm.setAlarmAddress(rtu.getData4());
|
|
|
+ newAlarm.setHandler(rtu.getClr());
|
|
|
+ newAlarm.setHandlingTime(rtu.getClsj());
|
|
|
+ newAlarm.setHandlingContent(rtu.getClnr());
|
|
|
+ newAlarm.setHandlingStatus(rtu.getClzt());
|
|
|
+ Integer falseAlarmValue = StringUtils.isBlank(rtu.getClwb()) ? null : NumberUtils.createInteger(rtu.getClwb());
|
|
|
+ newAlarm.setFalseAlarm(falseAlarmValue);
|
|
|
+ baseMapper.insert(newAlarm);
|
|
|
+ }
|
|
|
+ for (SpSj2017 sj : listSj) {
|
|
|
+ SpDeviceAlarm newAlarm = new SpDeviceAlarm();
|
|
|
+ newAlarm.setDeviceCode(sj.getDeviceCode());
|
|
|
+ newAlarm.setAlarmTime(sj.getTime());
|
|
|
+ newAlarm.setDeviceType(spOwnerService.getType(sj.getDeviceCode()));
|
|
|
+ newAlarm.setAlarmType(sj.getData1());
|
|
|
+ newAlarm.setAlarmName(spSj2017Service.getAlarmName(sj.getData1()));
|
|
|
+ newAlarm.setAlarmAddress(sj.getAddress());
|
|
|
+ newAlarm.setHandler(sj.getClr());
|
|
|
+ newAlarm.setHandlingTime(sj.getClsj());
|
|
|
+ newAlarm.setHandlingContent(sj.getClnr());
|
|
|
+ newAlarm.setHandlingStatus(sj.getClzt());
|
|
|
+ Integer falseAlarmValue = StringUtils.isBlank(sj.getClwb()) ? null : NumberUtils.createInteger(sj.getClwb());
|
|
|
+ newAlarm.setFalseAlarm(falseAlarmValue);
|
|
|
+ baseMapper.insert(newAlarm);
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|