代码调整
This commit is contained in:
@@ -15,13 +15,10 @@ import com.njcn.influx.pojo.po.PowerQualityData;
|
||||
import com.njcn.influx.service.HaronicRatioService;
|
||||
import com.njcn.influx.service.PowerQualityService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.SneakyThrows;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.Instant;
|
||||
import java.time.ZoneId;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
|
||||
@@ -415,16 +415,16 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
//监测点限值
|
||||
DictData scaleResult = dicDataFeignClient.getDicDataById(voltage.getScale()).getData();
|
||||
float scaTmp = Float.parseFloat(scaleResult.getValue());
|
||||
Overlimit overlimit = COverlimitUtil.globalAssemble(scaTmp,lineDetail.getDealCapacity(),lineDetail.getDevCapacity(),lineDetail.getShortCapacity(),1,1);
|
||||
Overlimit overlimit = COverlimitUtil.globalAssemble(scaTmp, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), 1, 1);
|
||||
|
||||
if(Objects.isNull(lineParam.getVoltageDev())){
|
||||
if (Objects.isNull(lineParam.getVoltageDev())) {
|
||||
overlimit.setVoltageDev(overlimit.getVoltageDev());
|
||||
}else {
|
||||
} else {
|
||||
overlimit.setVoltageDev(lineParam.getVoltageDev());
|
||||
}
|
||||
if(Objects.isNull(lineParam.getUvoltageDev())){
|
||||
if (Objects.isNull(lineParam.getUvoltageDev())) {
|
||||
overlimit.setUvoltageDev(overlimit.getUvoltageDev());
|
||||
}else {
|
||||
} else {
|
||||
overlimit.setUvoltageDev(lineParam.getUvoltageDev());
|
||||
}
|
||||
//Overlimit overlimit = new Overlimit(line.getId(), scaTmp, lineDetail.getShortCapacity(), lineDetail.getStandardCapacity(), lineDetail.getDealCapacity(), lineDetail.getDevCapacity());
|
||||
@@ -656,7 +656,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
voltageMapper.updateById(voltage);
|
||||
|
||||
//如果电压等级变化重新计算母线下面监测点的限值
|
||||
if(!voltageTem.getScale().equals(voltage.getScale())) {
|
||||
if (!voltageTem.getScale().equals(voltage.getScale())) {
|
||||
List<LineDetail> lineList = voltageMapper.getLineDetailByBusBarId(voltage.getId());
|
||||
DictData dictData = dicDataFeignClient.getDicDataById(voltage.getScale()).getData();
|
||||
float voltageLevel = Float.parseFloat(dictData.getValue());
|
||||
@@ -739,15 +739,15 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
float scaTmp = Float.parseFloat(scaleResult.getValue());
|
||||
|
||||
//监测点限值
|
||||
Overlimit overlimit = COverlimitUtil.globalAssemble(scaTmp,lineDetail.getDealCapacity(),lineDetail.getDevCapacity(),lineDetail.getShortCapacity(),1,1);
|
||||
if(Objects.isNull(updateLineBO.getVoltageDev())){
|
||||
Overlimit overlimit = COverlimitUtil.globalAssemble(scaTmp, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), 1, 1);
|
||||
if (Objects.isNull(updateLineBO.getVoltageDev())) {
|
||||
overlimit.setVoltageDev(overlimit.getVoltageDev());
|
||||
}else {
|
||||
} else {
|
||||
overlimit.setVoltageDev(updateLineBO.getVoltageDev());
|
||||
}
|
||||
if(Objects.isNull(updateLineBO.getUvoltageDev())){
|
||||
if (Objects.isNull(updateLineBO.getUvoltageDev())) {
|
||||
overlimit.setUvoltageDev(overlimit.getUvoltageDev());
|
||||
}else {
|
||||
} else {
|
||||
overlimit.setUvoltageDev(updateLineBO.getUvoltageDev());
|
||||
}
|
||||
overlimit.setId(line.getId());
|
||||
@@ -1735,6 +1735,12 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
substation.setLng(oracleTerminalExcel.getLng());
|
||||
substation.setLat(oracleTerminalExcel.getLat());
|
||||
substationMapper.insert(substation);
|
||||
} else {
|
||||
//避免漏掉oracle项目中变电站经纬度的更改
|
||||
Substation substation = substationMapper.selectById(temp.getId());
|
||||
substation.setLng(oracleTerminalExcel.getLng());
|
||||
substation.setLat(oracleTerminalExcel.getLat());
|
||||
substationMapper.updateById(substation);
|
||||
}
|
||||
//添加变电站索引
|
||||
pids.add(temp.getId());
|
||||
@@ -1749,6 +1755,17 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
String deviceName = oracleTerminalExcel.getDeviceName();
|
||||
temp = queryLine(lineLambdaQueryWrapper, deviceName, pids.get(LineBaseEnum.SUB_LEVEL.getCode()), LineBaseEnum.DEVICE_LEVEL.getCode(), DataStateEnum.ENABLE.getCode());
|
||||
if (Objects.isNull(temp)) {
|
||||
//判断是否因为改了终端名称导致没有查到数据
|
||||
LambdaQueryWrapper<DeviceBak> deviceBakLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
deviceBakLambdaQueryWrapper.eq(DeviceBak::getDevId, oracleTerminalExcel.getDeviceId());
|
||||
List<DeviceBak> deviceBaks = deviceBakService.list(deviceBakLambdaQueryWrapper);
|
||||
List<String> devIds = deviceBaks.stream().map(DeviceBak::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<Line> devLambda = new LambdaQueryWrapper<>();
|
||||
devLambda.in(Line::getId, devIds)
|
||||
.orderByAsc(Line::getCreateTime)
|
||||
.eq(Line::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<Line> devList = lineMapper.selectList(devLambda);
|
||||
if (CollectionUtil.isEmpty(deviceBaks) || CollectionUtil.isEmpty(devList)) {
|
||||
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);
|
||||
@@ -1809,8 +1826,24 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
DeviceBak deviceBak = new DeviceBak();
|
||||
deviceBak.setId(temp.getId());
|
||||
deviceBak.setDevId(oracleTerminalExcel.getDeviceId());
|
||||
deviceBakService.removeById(oracleTerminalExcel.getDeviceId());
|
||||
deviceBakService.saveOrUpdate(deviceBak);
|
||||
} else {
|
||||
if (CollectionUtil.isNotEmpty(devList)) {
|
||||
//仅保留最早创建的记录
|
||||
List<String> ids = new ArrayList<>();
|
||||
if (devList.size() > 2) {
|
||||
for (int i = 1; i < devList.size(); i++) {
|
||||
ids.add(devList.get(i).getId());
|
||||
}
|
||||
//删除错误关系和错误数据,避免丢失influx数据,保留最早的终端记录
|
||||
lineMapper.deleteBatchIds(ids);
|
||||
deviceMapper.deleteBatchIds(ids);
|
||||
LambdaQueryWrapper<DeviceBak> deviceBakLambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
||||
deviceBakLambdaQueryWrapper1.in(DeviceBak::getId, ids);
|
||||
deviceBakService.remove(deviceBakLambdaQueryWrapper1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
//添加终端索引
|
||||
pids.add(temp.getId());
|
||||
@@ -1865,6 +1898,17 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
if (Objects.nonNull(temp)) {
|
||||
oracleTerminalExcelMsg.add(assembleMsg(oracleTerminalExcel, "监测点名称重复,请联系管理员"));
|
||||
} else {
|
||||
//判断是否因为改了终端名称导致没有查到数据
|
||||
LambdaQueryWrapper<LineBak> lineBakLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lineBakLambdaQueryWrapper.eq(LineBak::getLineId, oracleTerminalExcel.getId());
|
||||
List<LineBak> lineBaks = lineBakService.list(lineBakLambdaQueryWrapper);
|
||||
List<String> lineIds = lineBaks.stream().map(LineBak::getId).collect(Collectors.toList());
|
||||
LambdaQueryWrapper<Line> devLambda = new LambdaQueryWrapper<>();
|
||||
devLambda.in(Line::getId, lineIds)
|
||||
.orderByAsc(Line::getCreateTime)
|
||||
.eq(Line::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<Line> lineList = lineMapper.selectList(devLambda);
|
||||
if (CollectionUtil.isEmpty(lineBaks) || CollectionUtil.isEmpty(lineList)) {
|
||||
temp = assembleLine(lineName, LineBaseEnum.LINE_LEVEL.getCode(), pids.get(LineBaseEnum.SUB_V_LEVEL.getCode()), pids);
|
||||
this.baseMapper.insert(temp);
|
||||
LineDetail lineDetail = new LineDetail();
|
||||
@@ -1925,13 +1969,29 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
|
||||
LineBak lineBak = new LineBak();
|
||||
lineBak.setId(temp.getId());
|
||||
lineBak.setLineId(oracleTerminalExcel.getId());
|
||||
lineBakService.removeById(oracleTerminalExcel.getId());
|
||||
lineBakService.save(lineBak);
|
||||
// OverLimitExcel overLimitExcel = overLimitList.get(0);
|
||||
// Overlimit overlimit = new Overlimit();
|
||||
// BeanUtils.copyProperties(overLimitExcel, overlimit);
|
||||
// overlimit.setId(temp.getId());
|
||||
// overlimitMapper.insert(overlimit);
|
||||
} else {
|
||||
if (CollectionUtil.isNotEmpty(lineList)) {
|
||||
//仅保留最早创建的记录
|
||||
List<String> ids = new ArrayList<>();
|
||||
if (lineList.size() > 2) {
|
||||
for (int i = 1; i < lineList.size(); i++) {
|
||||
ids.add(lineList.get(i).getId());
|
||||
}
|
||||
//删除错误关系和错误数据,避免丢失influx数据,保留最早的终端记录
|
||||
lineMapper.deleteBatchIds(ids);
|
||||
lineDetailMapper.deleteBatchIds(ids);
|
||||
LambdaQueryWrapper<LineBak> lineBakLambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
||||
lineBakLambdaQueryWrapper1.in(LineBak::getId, ids);
|
||||
lineBakService.remove(lineBakLambdaQueryWrapper1);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.njcn;
|
||||
|
||||
import com.njcn.prepare.harmonic.pojo.mysql.po.line.RMpPassRateDPO;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.DayDataService;
|
||||
import com.njcn.prepare.harmonic.service.mysql.line.RMpPassRateDService;
|
||||
import com.njcn.prepare.harmonic.service.mysql.process.PmsTerminalDetectionService;
|
||||
import com.njcn.process.pojo.po.PmsTerminalDetection;
|
||||
@@ -8,6 +9,7 @@ import lombok.SneakyThrows;
|
||||
import org.junit.Test;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -23,18 +25,14 @@ public class DemoTest extends BaseJunitTest {
|
||||
@Autowired
|
||||
private PmsTerminalDetectionService pmsTerminalDetectionService;
|
||||
|
||||
@Autowired
|
||||
private DayDataService dayDataService;
|
||||
|
||||
|
||||
@SneakyThrows
|
||||
@Test
|
||||
public void test() {
|
||||
//查询pms库
|
||||
List<RMpPassRateDPO> list1 = rMpPassRateDService.list();
|
||||
|
||||
//测试方法注解技术监督库
|
||||
List<RMpPassRateDPO> list2 = rMpPassRateDService.getAll();
|
||||
|
||||
//测试service类注解技术监督库
|
||||
List<PmsTerminalDetection> list = pmsTerminalDetectionService.list();
|
||||
dayDataService.dataToDayHandler(new ArrayList<>(),"2022-01-01 00:00:00","2022-01-01 00:00:00");
|
||||
System.out.println("hello");
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user