1.台账增加默认排序

2.增加场站/用户监测规模接口
This commit is contained in:
2026-06-15 10:21:14 +08:00
parent 6e4a294b00
commit 0196277eb2
15 changed files with 328 additions and 335 deletions

View File

@@ -64,6 +64,7 @@ import com.njcn.device.subvoltage.mapper.VoltageMapper;
import com.njcn.device.terminal.mapper.PqsTerminalLogsMapper;
import com.njcn.device.userledger.service.UserLedgerService;
import com.njcn.device.utils.ExcelStyleUtil;
import com.njcn.device.utils.LineSortHelper;
import com.njcn.message.api.ProduceFeignClient;
import com.njcn.message.constant.DeviceRebootType;
import com.njcn.message.constant.RedisKeyPrefix;
@@ -144,6 +145,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
private final ProduceFeignClient produceFeignClient;
private final UserLedgerService userLedgerService;
private final PqDevTypeService pqDevTypeService;
private final LineSortHelper lineSortHelper;
@Value("${oracle.isSync}")
private Boolean isSync;
@@ -205,6 +207,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
if (StrUtil.isBlank(projectIndex)) {
checkName(addTerminalParam, PROJECT_LEVEL.getCode(), null);
Line line = assembleLine(addTerminalParam.getProjectParam().getName(), PROJECT_LEVEL.getCode(), "0", "0", addTerminalParam.getProjectParam().getSort());
lineSortHelper.handleSort(PROJECT_LEVEL.getCode(),addTerminalParam.getProjectParam().getSort(),line);
this.baseMapper.insert(line);
projectIndex = line.getId();
}
@@ -219,6 +222,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
LogUtil.njcnDebug(log, "获取区域信息:{}", result.toString());
checkName(addTerminalParam, PROVINCE_LEVEL.getCode(), projectIndex);
Line province = assembleLine(result.getId(), PROVINCE_LEVEL.getCode(), projectIndex, projectIndex, addTerminalParam.getProvinceParam().getSort());
lineSortHelper.handleSort(PROVINCE_LEVEL.getCode(),addTerminalParam.getProvinceParam().getSort(),province);
this.baseMapper.insert(province);
provinceIndex = province.getId();
}
@@ -229,6 +233,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
if (StrUtil.isBlank(gdIndex) && StrUtil.isNotBlank(provinceIndex)) {
checkName(addTerminalParam, GD_LEVEL.getCode(), provinceIndex);
Line gdInformation = assembleLine(addTerminalParam.getGdInformationParam().getName(), GD_LEVEL.getCode(), provinceIndex, projectIndex + StrUtil.COMMA + provinceIndex, addTerminalParam.getGdInformationParam().getSort());
lineSortHelper.handleSort(GD_LEVEL.getCode(),addTerminalParam.getGdInformationParam().getSort(),gdInformation);
this.baseMapper.insert(gdInformation);
gdIndex = gdInformation.getId();
}
@@ -239,6 +244,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
if (StrUtil.isBlank(subIndex) && StrUtil.isNotBlank(gdIndex)) {
checkName(addTerminalParam, LineBaseEnum.SUB_LEVEL.getCode(), gdIndex);
Line subStation = assembleLine(addTerminalParam.getSubStationParam().getName(), LineBaseEnum.SUB_LEVEL.getCode(), gdIndex, projectIndex + StrUtil.COMMA + provinceIndex + StrUtil.COMMA + gdIndex, addTerminalParam.getSubStationParam().getSort());
lineSortHelper.handleSort(SUB_LEVEL.getCode(),addTerminalParam.getSubStationParam().getSort(),subStation);
this.baseMapper.insert(subStation);
subIndex = subStation.getId();
@@ -259,6 +265,8 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
if (CollectionUtil.isNotEmpty(addTerminalParam.getDeviceParam()) && StrUtil.isNotBlank(subIndex)) {
//校验变电站下的装置名称ip是否重复
checkDevNameAndIp(addTerminalParam, subIndex, lineLambdaQueryWrapper);
Integer devSort = lineSortHelper.getNextSort(DEVICE_LEVEL.getCode());
for (DeviceParam deviceParam : addTerminalParam.getDeviceParam()) {
//用于记录装置id
String devIdIndex;
@@ -286,9 +294,16 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
}
if (StrUtil.isBlank(deviceParam.getDevIndex())) {
Line device = assembleLine(deviceParam.getName(), LineBaseEnum.DEVICE_LEVEL.getCode(), subIndex, projectIndex + StrUtil.COMMA + provinceIndex + StrUtil.COMMA + gdIndex + StrUtil.COMMA + subIndex, deviceParam.getSort());
if(Objects.isNull(deviceParam.getSort()) || deviceParam.getSort() == 0){
device.setSort(devSort);
}
this.baseMapper.insert(device);
if(Objects.isNull(deviceParam.getSort()) || deviceParam.getSort() == 0){
devSort++;
}
devIdIndex = device.getId();
//装置详情
@@ -393,7 +408,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
throw new BusinessException(DeviceResponseEnum.SUBV_NAME_SAME, voltageListBySubId.stream().map(Line::getName).collect(Collectors.joining(";")));
}
}
Integer subvSort = lineSortHelper.getNextSort(SUB_V_LEVEL.getCode());
for (SubVoltageParam subVoltageParam : deviceParam.getSubVoltageParam()) {
//母线id
String subvIndex;
@@ -413,7 +428,13 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
Line subVoltage = assembleLine(subVoltageParam.getName(), LineBaseEnum.SUB_V_LEVEL.getCode(), devIdIndex, projectIndex + StrUtil.COMMA + provinceIndex + StrUtil.COMMA + gdIndex + StrUtil.COMMA + subIndex + StrUtil.COMMA + devIdIndex, subVoltageParam.getSort());
if(Objects.isNull(subVoltageParam.getSort()) || subVoltageParam.getSort() == 0) {
subVoltage.setSort(subvSort);
}
this.baseMapper.insert(subVoltage);
if(Objects.isNull(subVoltageParam.getSort()) || subVoltageParam.getSort() == 0) {
subvSort++;
}
subvIndex = subVoltage.getId();
Voltage voltage = new Voltage();
voltage.setId(subVoltage.getId());
@@ -441,6 +462,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
}
//通用新增监测点
Integer lineSort = lineSortHelper.getNextSort(LineBaseEnum.LINE_LEVEL.getCode());
for (LineParam lineParam : subVoltageParam.getLineParam()) {
if (StrUtil.isBlank(lineParam.getLineIndex()) && StrUtil.isNotBlank(subvIndex)) {
//判断监测点序号是否重复
@@ -454,7 +476,13 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
//删除与当前线路号重复的项
listLineNum.removeIf(lineNo -> lineNo.equals(lineParam.getNum()));
Line line = assembleLine(lineParam.getName(), LineBaseEnum.LINE_LEVEL.getCode(), subvIndex, projectIndex + StrUtil.COMMA + provinceIndex + StrUtil.COMMA + gdIndex + StrUtil.COMMA + subIndex + StrUtil.COMMA + devIdIndex + StrUtil.COMMA + subvIndex, lineParam.getSort());
if(Objects.isNull(lineParam.getSort()) || lineParam.getSort() == 0) {
line.setSort(lineSort);
}
this.baseMapper.insert(line);
if(Objects.isNull(lineParam.getSort()) || lineParam.getSort() == 0) {
lineSort++;
}
LineDetail lineDetail = new LineDetail();
BeanUtils.copyProperties(lineParam, lineDetail);
lineDetail.setId(line.getId());
@@ -481,7 +509,7 @@ 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, 0);
Overlimit overlimit = COverlimitUtil.globalAssemble(scaTmp, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), lineDetail.getPowerFlag(), 0);
if (Objects.isNull(lineParam.getVoltageDev())) {
overlimit.setVoltageDev(overlimit.getVoltageDev());
@@ -752,7 +780,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
float voltageLevel = Float.parseFloat(dictData.getValue());
if (CollectionUtil.isNotEmpty(lineList)) {
for (LineDetail lineDetail : lineList) {
Overlimit overlimit = COverlimitUtil.globalAssemble(voltageLevel, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), 1, 0);
Overlimit overlimit = COverlimitUtil.globalAssemble(voltageLevel, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), lineDetail.getPowerFlag(), 0);
overlimit.setId(lineDetail.getId());
overlimitMapper.deleteById(lineDetail.getId());
overlimitMapper.insert(overlimit);
@@ -839,7 +867,7 @@ 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, 0);
Overlimit overlimit = COverlimitUtil.globalAssemble(scaTmp, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), lineDetail.getPowerFlag(), 0);
if (Objects.isNull(updateLineBO.getVoltageDev())) {
overlimit.setVoltageDev(overlimit.getVoltageDev());
} else {
@@ -1860,7 +1888,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
}
float voltageLevel = Float.parseFloat(scaleResult.getValue());
Overlimit overlimit = COverlimitUtil.globalAssemble(voltageLevel, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), 1, 0);
Overlimit overlimit = COverlimitUtil.globalAssemble(voltageLevel, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), lineDetail.getPowerFlag(), 0);
overlimit.setId(lineDetail.getId());
overlimitMapper.insert(overlimit);
count++;
@@ -2193,7 +2221,7 @@ 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, 0);
Overlimit overlimit = COverlimitUtil.globalAssemble(scaTmp, lineDetail.getDealCapacity(), lineDetail.getDevCapacity(), lineDetail.getShortCapacity(), lineDetail.getPowerFlag(), 0);
if (Objects.isNull(lineParam.getVoltageDev())) {
overlimit.setVoltageDev(overlimit.getVoltageDev());
@@ -2742,7 +2770,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
* @date 2022/5/18
*/
@Transactional(rollbackFor = Exception.class)
private void saveTerminalBase(List<TerminalBaseExcel> terminalBaseExcels) {
public void saveTerminalBase(List<TerminalBaseExcel> terminalBaseExcels) {
List<TerminalBaseExcel.TerminalBaseExcelMsg> terminalBaseExcelMsgs = new ArrayList<>();
//任意集合数据为空,不处理
if (CollectionUtil.isNotEmpty(terminalBaseExcels)) {
@@ -3006,7 +3034,7 @@ public class TerminalBaseServiceImpl extends ServiceImpl<LineMapper, Line> imple
DictData dictData = dicDataFeignClient.getDicDataByNameAndType(terminalBaseExcel.getSubvScale(), DicDataTypeEnum.DEV_VOLTAGE_STAND.getName()).getData();
lineDetailMapper.insert(lineDetail);
Overlimit overlimit = COverlimitUtil.globalAssemble(Float.parseFloat(dictData.getValue()), terminalBaseExcel.getDealCapacity(), terminalBaseExcel.getDevCapacity(), terminalBaseExcel.getShortCapacity(), null, null);
Overlimit overlimit = COverlimitUtil.globalAssemble(Float.parseFloat(dictData.getValue()), terminalBaseExcel.getDealCapacity(), terminalBaseExcel.getDevCapacity(), terminalBaseExcel.getShortCapacity(), terminalBaseExcel.getPowerFlag(), 0);
overlimit.setId(temp.getId());
overlimitMapper.insert(overlimit);
}

View File

@@ -27,6 +27,7 @@
supervision_user_report.status,
supervision_user_report.dev_id,
supervision_user_report.line_id,
supervision_user_report.station_id,
supervision_user_report.second_assessment_id secondAssessmentId
FROM supervision_user_report supervision_user_report
WHERE ${ew.sqlSegment}

View File

@@ -17,6 +17,9 @@ import com.njcn.bpm.enums.BpmTaskStatusEnum;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.pq.pojo.po.Line;
import com.njcn.device.substation.mapper.SubstationMapper;
import com.njcn.device.userledger.mapper.UserReportNormalMapper;
import com.njcn.device.userledger.mapper.UserReportPOMapper;
import com.njcn.device.userledger.service.UserLedgerService;
@@ -67,6 +70,7 @@ public class UserLedgerServiceImpl extends ServiceImpl<UserReportPOMapper, UserR
private final UserReportNormalMapper userReportNormalMapper;
private final UserReportSensitivePOService userReportSensitivePOService;
private final UserFeignClient userFeignClient;
private final LineMapper substationMapper;
@Override
public List<UserLedgerVO> selectUserList(UserReportParam userReportParam) {
@@ -171,7 +175,16 @@ public class UserLedgerServiceImpl extends ServiceImpl<UserReportPOMapper, UserR
userReportVOQueryWrapper.orderByDesc("supervision_user_report.create_time");
Page<UserReportVO> page;
page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(userReportQueryParam), PageFactory.getPageSize(userReportQueryParam)), userReportVOQueryWrapper);
Map<String,String> atationMap = new HashMap<>();
if(CollUtil.isNotEmpty(page.getRecords())){
List<String> stationIds = page.getRecords().stream().map(UserReportVO::getStationId).filter(StrUtil::isNotBlank).distinct().collect(Collectors.toList());
if(CollUtil.isNotEmpty(stationIds)){
List<Line> stationList = substationMapper.selectBatchIds(stationIds);
stationList.forEach(line -> atationMap.put(line.getId(), line.getName()));
}
}
page.getRecords().forEach(temp -> {
temp.setStationId(atationMap.getOrDefault(temp.getStationId(),"/"));
Integer needGovernance = 0;
if (
CollectionUtil.newArrayList(

View File

@@ -0,0 +1,59 @@
package com.njcn.device.utils;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.device.line.mapper.LineMapper;
import com.njcn.device.pq.pojo.po.Line;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Component;
import java.util.Objects;
/**
* @Author: cdf
* @CreateTime: 2026-06-13
* @Description:
*/
@Component
@RequiredArgsConstructor
public class LineSortHelper {
private final LineMapper lineMapper;
/**
* 获取同一父节点下的最大 sort 值 + 1
* @param level 层级
* @return 下一个可用的 sort 值
*/
public Integer getNextSort(Integer level) {
LambdaQueryWrapper<Line> wrapper = new LambdaQueryWrapper<>();
wrapper.eq(Line::getState, DataStateEnum.ENABLE.getCode())
.eq(Line::getLevel,level)
.orderByDesc(Line::getSort)
.last("limit 1");
Line maxSortLine = lineMapper.selectOne(wrapper);
if (Objects.nonNull(maxSortLine) && Objects.nonNull(maxSortLine.getSort())) {
return maxSortLine.getSort() + 1;
}
return 0;
}
public void handleSort(Integer level, Integer sort,Line line) {
int lastSort;
if (Objects.isNull(sort) || sort == 0) {
lastSort = getNextSort(level);
}else {
lastSort = sort;
}
line.setSort(lastSort);
}
public Integer handleSortBatch(Integer currentSort, Line line) {
line.setSort(currentSort);
return currentSort + 1;
}
}