|
|
|
|
@@ -27,28 +27,27 @@ import com.njcn.device.pq.pojo.bo.excel.NodeExcel;
|
|
|
|
|
import com.njcn.device.pq.pojo.bo.excel.OracleTerminalExcel;
|
|
|
|
|
import com.njcn.device.pq.pojo.bo.excel.OverLimitExcel;
|
|
|
|
|
import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
|
|
|
|
|
import com.njcn.device.pq.pojo.dto.GeneralDeviceDTO;
|
|
|
|
|
import com.njcn.device.pq.pojo.param.*;
|
|
|
|
|
import com.njcn.device.pq.pojo.po.*;
|
|
|
|
|
import com.njcn.device.pq.pojo.vo.*;
|
|
|
|
|
import com.njcn.device.pq.service.DeviceBakService;
|
|
|
|
|
import com.njcn.device.pq.service.INodeService;
|
|
|
|
|
import com.njcn.device.pq.service.LineBakService;
|
|
|
|
|
import com.njcn.device.pq.service.TerminalBaseService;
|
|
|
|
|
import com.njcn.device.pq.service.*;
|
|
|
|
|
import com.njcn.device.pq.utils.DeviceUtil;
|
|
|
|
|
import com.njcn.device.pq.utils.ExcelStyleUtil;
|
|
|
|
|
import com.njcn.poi.excel.ExcelUtil;
|
|
|
|
|
import com.njcn.poi.util.PoiUtil;
|
|
|
|
|
import com.njcn.system.api.AreaFeignClient;
|
|
|
|
|
import com.njcn.system.api.DicDataFeignClient;
|
|
|
|
|
import com.njcn.system.enums.DicDataEnum;
|
|
|
|
|
import com.njcn.system.enums.DicDataTypeEnum;
|
|
|
|
|
import com.njcn.system.pojo.po.Area;
|
|
|
|
|
import com.njcn.system.pojo.po.DictData;
|
|
|
|
|
import com.njcn.web.utils.RequestUtil;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.scheduling.annotation.Async;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
@@ -73,6 +72,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
|
|
|
|
|
private final DeviceMapper deviceMapper;
|
|
|
|
|
|
|
|
|
|
private final UserMapper userMapper;
|
|
|
|
|
|
|
|
|
|
private final IPqsTerminalLogsService iPqsTerminalLogsService;
|
|
|
|
|
|
|
|
|
|
private final LineMapper lineMapper;
|
|
|
|
|
|
|
|
|
|
private final DevFuctionMapper devFuctionMapper;
|
|
|
|
|
@@ -98,7 +101,6 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
private final DeviceBakService deviceBakService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 终端新增操作
|
|
|
|
|
*
|
|
|
|
|
@@ -202,9 +204,9 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
//用于记录装置id
|
|
|
|
|
String devIdIndex;
|
|
|
|
|
//监测点序号
|
|
|
|
|
List<Integer> listLineNum = Stream.of(1, 2, 3, 4, 5, 6,7,8,9,10).collect(Collectors.toList());
|
|
|
|
|
List<Integer> listLineNum = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).collect(Collectors.toList());
|
|
|
|
|
//母线序号
|
|
|
|
|
List<Integer> listVoltageNum = Stream.of(1, 2, 3, 4, 5, 6,7,8,9,10).collect(Collectors.toList());
|
|
|
|
|
List<Integer> listVoltageNum = Stream.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 10).collect(Collectors.toList());
|
|
|
|
|
//标识当前装置下的监测点数量
|
|
|
|
|
int lineNum = 0, voltageNum = 0;
|
|
|
|
|
|
|
|
|
|
@@ -446,10 +448,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
}
|
|
|
|
|
List<DeviceParam> devIpList = addTerminalParam.getDeviceParam().stream().filter((dev -> dev.getDevIndex() == null)).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtil.isNotEmpty(devIpList)) {
|
|
|
|
|
for(DeviceParam deviceParam : devIpList){
|
|
|
|
|
List<Device> deviceListIpRes = deviceMapper.getDeviceBySubId(subIndex, deviceParam.getIp(),deviceParam.getPort(),null);
|
|
|
|
|
if(CollectionUtil.isNotEmpty(deviceListIpRes)){
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP,deviceListIpRes.get(0).getIp());
|
|
|
|
|
for (DeviceParam deviceParam : devIpList) {
|
|
|
|
|
List<Device> deviceListIpRes = deviceMapper.getDeviceBySubId(subIndex, deviceParam.getIp(), deviceParam.getPort(), null);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(deviceListIpRes)) {
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP, deviceListIpRes.get(0).getIp());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
@@ -542,8 +544,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
.filter(item -> item.getUpdateFlag() == 1).collect(Collectors.toList());
|
|
|
|
|
if (CollectionUtil.isNotEmpty(devIpList)) {
|
|
|
|
|
Set<String> set = new HashSet<>();
|
|
|
|
|
devIpList.forEach(item-> set.add(item.getIp()+item.getPort()));
|
|
|
|
|
if(devIpList.size()!=set.size()){
|
|
|
|
|
devIpList.forEach(item -> set.add(item.getIp() + item.getPort()));
|
|
|
|
|
if (devIpList.size() != set.size()) {
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.DEVICE_IP_REPETITION);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -565,8 +567,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_NAME, "重复装置:" + String.join(";", repeatDevNames));
|
|
|
|
|
}
|
|
|
|
|
//校验装置ip
|
|
|
|
|
for(DeviceParam deviceParam:devIpList){
|
|
|
|
|
List<Device> deviceIpList = deviceMapper.getDeviceBySubId(deviceValid.getPid(), deviceParam.getIp(),deviceParam.getPort(),deviceParam.getDevIndex());
|
|
|
|
|
for (DeviceParam deviceParam : devIpList) {
|
|
|
|
|
List<Device> deviceIpList = deviceMapper.getDeviceBySubId(deviceValid.getPid(), deviceParam.getIp(), deviceParam.getPort(), deviceParam.getDevIndex());
|
|
|
|
|
if (CollectionUtil.isNotEmpty(deviceIpList)) {
|
|
|
|
|
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP, "重复IP:" + deviceIpList.get(0).getIp());
|
|
|
|
|
}
|
|
|
|
|
@@ -693,9 +695,17 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
if (Objects.isNull(scaleResult.getData())) {
|
|
|
|
|
throw new BusinessException(CommonResponseEnum.DIC_DATA);
|
|
|
|
|
}
|
|
|
|
|
Overlimit overlimit = new Overlimit(line.getId(),scaleResult.getData().getValue(), lineDetail.getShortCapacity(), lineDetail.getStandardCapacity(), lineDetail.getDealCapacity(), lineDetail.getDevCapacity());
|
|
|
|
|
Overlimit overlimit = new Overlimit(line.getId(), scaleResult.getData().getValue(), lineDetail.getShortCapacity(), lineDetail.getStandardCapacity(), lineDetail.getDealCapacity(), lineDetail.getDevCapacity());
|
|
|
|
|
overlimitMapper.insert(overlimit);
|
|
|
|
|
}
|
|
|
|
|
//todo 插入日志
|
|
|
|
|
String userId = RequestUtil.getUserIndex();
|
|
|
|
|
//String userId = "5dd232f9a70c49c58d2f9e7f69776394";
|
|
|
|
|
Map<String, Object> map = userMapper.getUser(userId);
|
|
|
|
|
String userName = map.get("name").toString();
|
|
|
|
|
String loginName = map.get("loginName").toString();
|
|
|
|
|
LineDetail lineDetailResOld = lineDetailMapper.selectById(lineId);
|
|
|
|
|
queryUpdateAndInsertLog(userName, loginName, lineDetailRes, lineDetailResOld);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@@ -705,6 +715,68 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 查询监测点信息修改处,并新增日志
|
|
|
|
|
*
|
|
|
|
|
* @param userName
|
|
|
|
|
* @param newLine
|
|
|
|
|
* @param oldLine
|
|
|
|
|
* @return
|
|
|
|
|
*/
|
|
|
|
|
@Async
|
|
|
|
|
public void queryUpdateAndInsertLog(String userName, String loginName, LineDetail newLine, LineDetail oldLine) {
|
|
|
|
|
Map<String, Object> map = userMapper.getPointSuper(newLine.getId());
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
sb.append(userName).append("修改了").append(map.get("urbanName")).append(" - ")
|
|
|
|
|
.append(map.get("subName")).append(" - ").append(map.get("devName")).append(" - ").append(map.get("pName"))
|
|
|
|
|
.append(" - ").append(map.get("mName")).append(" - 监测点的参数;");
|
|
|
|
|
StringBuilder sbNew = new StringBuilder();
|
|
|
|
|
StringBuilder sbOld = new StringBuilder();
|
|
|
|
|
sbNew.append("操作历史,");
|
|
|
|
|
sbOld.append("修改后参数,");
|
|
|
|
|
//pt变化
|
|
|
|
|
if (!Objects.equals(newLine.getPt1(), oldLine.getPt1()) || !Objects.equals(newLine.getPt2(), oldLine.getPt2())) {
|
|
|
|
|
sbNew.append("pt变比: ").append(newLine.getPt1()).append(" : ").append(newLine.getPt2()).append(";");
|
|
|
|
|
sbOld.append("pt变比: ").append(oldLine.getPt1()).append(" : ").append(oldLine.getPt2()).append(";");
|
|
|
|
|
}
|
|
|
|
|
//ct变化
|
|
|
|
|
if (!Objects.equals(newLine.getCt1(), oldLine.getCt1()) || !Objects.equals(newLine.getCt2(), oldLine.getCt2())) {
|
|
|
|
|
sbNew.append("ct变比: ").append(newLine.getCt1()).append(" : ").append(newLine.getCt2()).append(";");
|
|
|
|
|
sbOld.append("ct变比: ").append(oldLine.getCt1()).append(" : ").append(oldLine.getCt2()).append(";");
|
|
|
|
|
}
|
|
|
|
|
//设备容量
|
|
|
|
|
if (!Objects.equals(newLine.getDealCapacity(), oldLine.getDealCapacity())) {
|
|
|
|
|
sbNew.append("设备容量: ").append(newLine.getDealCapacity()).append(";");
|
|
|
|
|
sbOld.append("设备容量: ").append(oldLine.getDealCapacity()).append(";");
|
|
|
|
|
}
|
|
|
|
|
//短路容量
|
|
|
|
|
if (!Objects.equals(newLine.getShortCapacity(), oldLine.getShortCapacity())) {
|
|
|
|
|
sbNew.append("短路容量: ").append(newLine.getShortCapacity()).append(";");
|
|
|
|
|
sbOld.append("短路容量: ").append(oldLine.getShortCapacity()).append(";");
|
|
|
|
|
}
|
|
|
|
|
//基准容量
|
|
|
|
|
if (!Objects.equals(newLine.getStandardCapacity(), oldLine.getStandardCapacity())) {
|
|
|
|
|
sbNew.append("基准容量: ").append(newLine.getStandardCapacity()).append(";");
|
|
|
|
|
sbOld.append("基准容量: ").append(oldLine.getStandardCapacity()).append(";");
|
|
|
|
|
}
|
|
|
|
|
//协议容量
|
|
|
|
|
if (!Objects.equals(newLine.getDealCapacity(), oldLine.getDealCapacity())) {
|
|
|
|
|
sbNew.append("协议容量: ").append(newLine.getDealCapacity()).append(";");
|
|
|
|
|
sbOld.append("协议容量: ").append(oldLine.getDealCapacity()).append(";");
|
|
|
|
|
}
|
|
|
|
|
sb.append(sbNew).append(sbOld);
|
|
|
|
|
HttpResult<DictData> dicDataByCode = dicDataFeignClient.getDicDataByCode(DicDataEnum.LINE_PARAMETER.getCode());
|
|
|
|
|
DictData data = dicDataByCode.getData();
|
|
|
|
|
//创建对象
|
|
|
|
|
PqsTerminalLogs terminalLogsNew = new PqsTerminalLogs();
|
|
|
|
|
terminalLogsNew.setObjIndex(newLine.getId());
|
|
|
|
|
terminalLogsNew.setTerminalDescribe(sb.toString());
|
|
|
|
|
terminalLogsNew.setCreateBy(loginName);
|
|
|
|
|
terminalLogsNew.setCreateTime(LocalDateTime.now());
|
|
|
|
|
terminalLogsNew.setTerminalType(data.getId());
|
|
|
|
|
terminalLogsNew.setState(1);
|
|
|
|
|
iPqsTerminalLogsService.save(terminalLogsNew);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 终端查询操作
|
|
|
|
|
@@ -1556,7 +1628,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
if (Objects.isNull(temp)) {
|
|
|
|
|
temp = assembleLine(deviceName, LineBaseEnum.DEVICE_LEVEL.getCode(), pids.get(LineBaseEnum.SUB_LEVEL.getCode()), pids);
|
|
|
|
|
this.baseMapper.insert(temp);
|
|
|
|
|
List<Device> existIp = deviceMapper.getDeviceBySubId(pids.get(LineBaseEnum.SUB_LEVEL.getCode()),oracleTerminalExcel.getIp(),oracleTerminalExcel.getPort(),null);
|
|
|
|
|
List<Device> existIp = deviceMapper.getDeviceBySubId(pids.get(LineBaseEnum.SUB_LEVEL.getCode()), oracleTerminalExcel.getIp(), oracleTerminalExcel.getPort(), null);
|
|
|
|
|
if (CollectionUtil.isNotEmpty(existIp)) {
|
|
|
|
|
Device device = existIp.get(0);
|
|
|
|
|
if (!device.getId().equalsIgnoreCase(temp.getId())) {
|
|
|
|
|
@@ -1994,7 +2066,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
|
|
|
|
lineDetail.setCt1(Float.valueOf(ct[0]));
|
|
|
|
|
lineDetail.setCt2(Float.valueOf(ct[1]));
|
|
|
|
|
|
|
|
|
|
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(terminalBaseExcel.getSubvScale(),DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
|
|
|
|
|
DictData dictData = dicDataFeignClient.getDicDataByNameAndTypeName(terminalBaseExcel.getSubvScale(), DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
|
|
|
|
|
|
|
|
|
|
lineDetailMapper.insert(lineDetail);
|
|
|
|
|
Overlimit overlimit = new Overlimit(temp.getId(), dictData.getValue(), terminalBaseExcel.getShortCapacity(), terminalBaseExcel.getStandardCapacity(), terminalBaseExcel.getDealCapacity(), terminalBaseExcel.getDevCapacity());
|
|
|
|
|
|