代码合并

This commit is contained in:
2023-01-03 09:00:20 +08:00
parent 7c4cef74e7
commit cdc6255d22
81 changed files with 5415 additions and 63 deletions

View File

@@ -76,11 +76,11 @@ public class TerminalBaseController extends BaseController {
throw new BusinessException(DeviceResponseEnum.DEVICE_REPETITION);
}
//校验装置是否存在重复ip
List<String> devIp = listDev.stream().map(DeviceParam::getIp).collect(Collectors.toList());
/*List<String> devIp = listDev.stream().map(DeviceParam::getIp).collect(Collectors.toList());
long countIp = devIp.stream().distinct().count();
if (countIp != devIp.size()) {
throw new BusinessException(DeviceResponseEnum.DEVICE_IP_REPETITION);
}
}*/
//校验母线名称
for (DeviceParam deviceParam : listDev) {

View File

@@ -2,7 +2,6 @@ package com.njcn.device.pq.mapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.device.pq.pojo.po.Device;
import com.njcn.device.pq.pojo.vo.RunManageVO;
import com.njcn.device.pq.pojo.vo.RunTimeVO;
@@ -30,7 +29,8 @@ public interface DeviceMapper extends BaseMapper<Device> {
* @author cdf
* @date 2022/12/26
*/
List<Device> getDeviceBySubId(@Param("subId") String subId,@Param("ip") String ip,@Param("port") Integer port);
List<Device> getDeviceBySubId(@Param("subId") String subId,@Param("ip") String ip,@Param("port") Integer port,@Param("devId")String devId);
/**
* 获取监测点台账信息

View File

@@ -3,13 +3,16 @@
<mapper namespace="com.njcn.device.pq.mapper.DeviceMapper">
<select id="getDeviceBySubId" resultType="Device">
<select id="getDeviceBySubId" resultType="com.njcn.device.pq.pojo.po.Device">
select * from pq_line a
inner join pq_device b on a.id=b.id
where a.pid = #{subId}
and a.state = 1
and b.ip = #{ip}
and b.port = #{port}
<if test="devId !=null and devId !=''">
and a.id != #{devId}
</if>
</select>

View File

@@ -20,6 +20,7 @@ import com.njcn.common.utils.LogUtil;
import com.njcn.common.utils.PubUtils;
import com.njcn.device.pq.enums.DeviceResponseEnum;
import com.njcn.device.pq.enums.LineBaseEnum;
import com.njcn.device.pq.mapper.*;
import com.njcn.device.pq.pojo.bo.BaseLineInfo;
import com.njcn.device.pq.pojo.bo.DeviceType;
import com.njcn.device.pq.pojo.bo.excel.NodeExcel;
@@ -29,7 +30,6 @@ import com.njcn.device.pq.pojo.bo.excel.TerminalBaseExcel;
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.mapper.*;
import com.njcn.device.pq.service.DeviceBakService;
import com.njcn.device.pq.service.INodeService;
import com.njcn.device.pq.service.LineBakService;
@@ -55,9 +55,7 @@ import org.springframework.web.multipart.MultipartFile;
import javax.servlet.http.HttpServletResponse;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
@@ -201,13 +199,13 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
//用于记录装置id
String devIdIndex;
//监测点序号
List<Integer> listLineNum = Stream.of(1, 2, 3, 4, 5, 6).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).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;
//校验监测点总数不超过6
//校验监测点总数不超过10
if (CollectionUtil.isNotEmpty(deviceParam.getSubVoltageParam())) {
for (SubVoltageParam subVoltage : deviceParam.getSubVoltageParam()) {
if (CollectionUtil.isNotEmpty(subVoltage.getLineParam())) {
@@ -218,7 +216,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
}
//一台装置母线最多6
//一台装置母线最多10
if (StrUtil.isBlank(subVoltage.getSubvIndex())) {
voltageNum++;
}
@@ -282,10 +280,10 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
}
if (lineNum > 6) {
if (lineNum > 10) {
throw new BusinessException(DeviceResponseEnum.DEVICE_LINE_BIG);
}
if (voltageNum > 6) {
if (voltageNum > 10) {
throw new BusinessException(DeviceResponseEnum.DEVICE_VOLTAGE_BIG);
}
@@ -443,14 +441,20 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_NAME, String.join(";", stringList));
}
}
List<String> devIpList = addTerminalParam.getDeviceParam().stream().filter((dev -> dev.getDevIndex() == null)).map(DeviceParam::getIp).collect(Collectors.toList());
List<DeviceParam> devIpList = addTerminalParam.getDeviceParam().stream().filter((dev -> dev.getDevIndex() == null)).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(devIpList)) {
List<Device> deviceListIpRes = lineMapper.getDeviceBySubId(subIndex, 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());
}
}
//校验当前变电站下的装置是否有相同ip
if (CollectionUtil.isNotEmpty(deviceListIpRes)) {
/* if (CollectionUtil.isNotEmpty(deviceListIpRes)) {
List<String> stringList = deviceListIpRes.stream().map(Device::getIp).collect(Collectors.toList());
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP, String.join(";", stringList));
}
}*/
}
}
@@ -531,12 +535,12 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
//IP校验
List<String> devIpList = devList.stream()
.filter(item -> item.getUpdateFlag() == 1)
.map(DeviceParam::getIp).collect(Collectors.toList());
List<DeviceParam> devIpList = devList.stream()
.filter(item -> item.getUpdateFlag() == 1).collect(Collectors.toList());
if (CollectionUtil.isNotEmpty(devIpList)) {
long ipCount = devIpList.stream().distinct().count();
if (ipCount != devIpList.size()) {
Set<String> set = new HashSet<>();
devIpList.forEach(item-> set.add(item.getIp()+item.getPort()));
if(devIpList.size()!=set.size()){
throw new BusinessException(DeviceResponseEnum.DEVICE_IP_REPETITION);
}
}
@@ -558,11 +562,13 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_NAME, "重复装置:" + String.join(";", repeatDevNames));
}
//校验装置ip
List<Device> deviceIpList = lineMapper.getDeviceBySubIdForUpdate(deviceValid.getPid(), devIpList, devIndexList);
if (CollectionUtil.isNotEmpty(deviceIpList)) {
List<String> repeatDevIps = deviceIpList.stream().map(Device::getIp).collect(Collectors.toList());
throw new BusinessException(DeviceResponseEnum.DEVICE_SAME_IP, "重复IP:" + String.join(";", repeatDevIps));
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());
}
}
}
for (DeviceParam updateDeviceParam : devList) {
@@ -1546,7 +1552,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());
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())) {