设备、计划状态修改

This commit is contained in:
caozehui
2025-10-16 15:40:20 +08:00
parent 15e93b6734
commit 66786200bd
5 changed files with 71 additions and 64 deletions

View File

@@ -5,9 +5,7 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
import com.njcn.gather.detection.util.socket.CnSocketUtil;
import com.njcn.gather.detection.util.socket.FormalTestManager;
import com.njcn.gather.detection.util.socket.SocketManager;
import com.njcn.gather.device.pojo.enums.PatternEnum;
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.CorruptedFrameException;
@@ -373,40 +371,43 @@ public class WebSocketHandler extends SimpleChannelInboundHandler<TextWebSocketF
// 使用该用户的检测参数关闭Socket连接
log.info("使用用户检测参数关闭Socket连接userId: {}", userId);
if (FormalTestManager.patternEnum.equals(PatternEnum.CONTRAST)) {
if (FormalTestManager.isRemoveSocket) {
boolean channelActive = SocketManager.isChannelActive(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
if (channelActive) {
SocketManager.removeUser(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
}
} else {
if (FormalTestManager.currentStep == SourceOperateCodeEnum.RECORD_WAVE_STEP1) {
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
} else if (FormalTestManager.currentStep != SourceOperateCodeEnum.QUITE) {
if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
if (FormalTestManager.nonWaveDataSourceEnum == DataSourceEnum.REAL_DATA) {
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
if (FormalTestManager.statisticsProtocol) {
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
}
} else {
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
}
if (FormalTestManager.isWaveCheck) {
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
}
} else {
if (FormalTestManager.statisticsProtocol) {
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
}
if (FormalTestManager.isWaveCheck) {
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
}
}
} else {
SocketManager.removeUser(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
}
}
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
// if (FormalTestManager.isRemoveSocket) {
// boolean channelActive = SocketManager.isChannelActive(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
// if (channelActive) {
// SocketManager.removeUser(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
// }
// } else {
// if (FormalTestManager.currentStep == SourceOperateCodeEnum.RECORD_WAVE_STEP1) {
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
// } else if (FormalTestManager.currentStep != SourceOperateCodeEnum.QUITE) {
// if (ObjectUtil.isNotNull(FormalTestManager.nonWaveDataSourceEnum)) {
// if (FormalTestManager.nonWaveDataSourceEnum == DataSourceEnum.REAL_DATA) {
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
// if (FormalTestManager.statisticsProtocol) {
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
// }
// } else {
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
// }
// if (FormalTestManager.isWaveCheck) {
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
// }
// } else {
// if (FormalTestManager.statisticsProtocol) {
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_01, false);
// }
// if (FormalTestManager.isWaveCheck) {
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_02, false);
// CnSocketUtil.contrastSendquit(preDetectionParam.getUserPageId(), SourceOperateCodeEnum.QUIT_INIT_03, false);
// }
// }
// } else {
// SocketManager.removeUser(preDetectionParam.getUserPageId() + CnSocketUtil.CONTRAST_DEV_TAG);
// }
// }
} else {
CnSocketUtil.quitSendSource(preDetectionParam);
CnSocketUtil.quitSend(preDetectionParam);

View File

@@ -35,6 +35,7 @@ import com.njcn.gather.monitor.pojo.po.PqMonitor;
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
import com.njcn.gather.monitor.service.IPqMonitorService;
import com.njcn.gather.pojo.enums.DetectionResponseEnum;
import com.njcn.gather.report.pojo.enums.ReportResponseEnum;
import com.njcn.gather.storage.service.DetectionDataDealService;
import com.njcn.gather.system.cfg.pojo.enums.SceneEnum;
import com.njcn.gather.system.cfg.pojo.po.SysTestConfig;
@@ -535,13 +536,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
LambdaUpdateChainWrapper<PqDevSub> w = pqDevSubService.lambdaUpdate()
.set(PqDevSub::getCheckState, checkState)
.set(PqDevSub::getCheckResult, checkResult)
.set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue())
.set(PqDevSub::getCheckTime, LocalDateTime.now())
.eq(PqDevSub::getDevId, devId);
if(ObjectUtil.isNotNull(user)){
if (ObjectUtil.isNotNull(user)) {
w.set(PqDevSub::getCheckBy, user.getName());
}
if(checkState.equals(CheckStateEnum.CHECKED.getValue())){
if (checkState.equals(CheckStateEnum.CHECKED.getValue())) {
w.set(PqDevSub::getReportState, DevReportStateEnum.NOT_GENERATED.getValue());
}
w.update();
@@ -552,15 +554,23 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
List<PqDevVO> pqDevVOList = this.baseMapper.selectByQueryParam(param);
if (CollUtil.isNotEmpty(pqDevVOList)) {
Set<Integer> set = pqDevVOList.stream().map(PqDevVO::getCheckResult).collect(Collectors.toSet());
if (set.contains(CheckResultEnum.NOT_ACCORD.getValue())) {
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.NOT_ACCORD.getValue());
} else if (set.contains(CheckResultEnum.UNCHECKED.getValue())) {
Set<Integer> set = pqDevVOList.stream().filter(obj -> CheckStateEnum.CHECKED.getValue().equals(obj.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(obj.getCheckState())).map(PqDevVO::getCheckResult).collect(Collectors.toSet());
if (checkState == CheckStateEnum.CHECKED.getValue()) {
set.add(checkResult);
}
if (CollUtil.isEmpty(set)) {
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.UNCHECKED.getValue());
} else {
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.ACCORD.getValue());
if (set.contains(CheckResultEnum.NOT_ACCORD.getValue())) {
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.NOT_ACCORD.getValue());
} else if (set.contains(CheckResultEnum.UNCHECKED.getValue())) {
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.UNCHECKED.getValue());
} else {
this.baseMapper.updatePlanCheckResult(planId, CheckResultEnum.ACCORD.getValue());
}
}
set = pqDevVOList.stream().map(PqDevVO::getCheckState).collect(Collectors.toSet());
if (set.contains(CheckStateEnum.UNCHECKED.getValue())) {
this.baseMapper.updatePlanTestState(planId, CheckStateEnum.CHECKING.getValue());

View File

@@ -207,7 +207,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
}
List<PqDevVO> pqDevVOList = pqDevMapper.selectByQueryParam(queryParam1);
if (CollUtil.isNotEmpty(pqDevVOList)) {
long count = pqDevVOList.stream().filter(pqDev -> CheckStateEnum.CHECKED.getValue().equals(pqDev.getCheckState())).count();
long count = pqDevVOList.stream().filter(pqDev -> CheckStateEnum.CHECKED.getValue().equals(pqDev.getCheckState()) || CheckStateEnum.DOCUMENTED.getValue().equals(pqDev.getCheckState())).count();
adPlanVO.setProgress((float) count / pqDevVOList.size());
} else {
adPlanVO.setProgress(0.0f);
@@ -531,7 +531,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
@Override
public List<Map<String, Object>> listByPattern(String pattern) {
List<AdPlan> adPlanList = this.lambdaQuery().eq(AdPlan::getPattern, pattern).eq(AdPlan::getState, DataStateEnum.ENABLE.getCode()).list();
List<AdPlan> adPlanList = this.lambdaQuery().eq(AdPlan::getPattern, pattern).eq(AdPlan::getState, DataStateEnum.ENABLE.getCode()).orderByDesc(AdPlan::getCreateTime).list();
Map<Integer, List<AdPlan>> map1 = adPlanList.stream().collect(Collectors.groupingBy(AdPlan::getTestState));
List<Map<String, Object>> result = new ArrayList<>();

View File

@@ -35,14 +35,14 @@ import java.util.List;
@RestController
@RequestMapping("/report")
@RequiredArgsConstructor
public class ReportController extends BaseController {
public class ReportController extends BaseController {
private final IPqReportService pqReportService;
/**
* 此方法临时的,给楼下使用,实际需要优化
* 1、不同的设备需要不同的模板
* 2、数据页的内容暂时是固定的后期可能是动态的
* 2、数据页的内容暂时是固定的后期可能是动态 的;
*/
@OperateInfo
@PostMapping("/generateReport")

View File

@@ -89,7 +89,6 @@ import org.docx4j.jaxb.Context;
import org.docx4j.openpackaging.packages.WordprocessingMLPackage;
import org.docx4j.openpackaging.parts.WordprocessingML.MainDocumentPart;
import org.docx4j.wml.*;
import org.docx4j.wml.Color;
import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.io.ClassPathResource;
@@ -571,7 +570,6 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
/**
*
* 根据设备类型生成报告
* 注:该方法目前仅支持楼下出厂检测场景,属于模板占位符替换方式,后期可能会有调整
*
@@ -809,10 +807,10 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
ensureDirectoryExists(dirPath);
// 构建文件名cityName_gdName_subName_name.docx
String fileName = String.format("%s_%s_%s_%s.docx",
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
Docx4jUtil.cleanBlankPagesAndRedundantPageBreaks(baseModelDocument);
baseModelDocument.save(new File(dirPath.concat(File.separator).concat(fileName)));
this.updateDevAndPlanState(devId, devReportParam.getPlanId());
@@ -1065,7 +1063,6 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
* 实时数据3秒数据150周波数据
* 录波:录波数据
* 分钟统计数据:分钟统计数据-最大值、分钟统计数据-最小值、分钟统计数据-平均值、分钟统计数据-CP95值
*
*/
private String getDataTypeFromParam(AdPlan adPlan) {
String dataSource = adPlan.getDatasourceId();
@@ -1088,11 +1085,11 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
AdPlanTestConfig adPlanTestConfig = adPlanTestConfigService.getByPlanId(adPlan.getId());
StringBuilder sampleCount = new StringBuilder();
for (String item : dataSourceArray) {
if(item.equalsIgnoreCase(DataSourceEnum.REAL_DATA.getValue())){
if (item.equalsIgnoreCase(DataSourceEnum.REAL_DATA.getValue())) {
sampleCount.append("实时数据采集").append(adPlanTestConfig.getRealTime()).append("组,");
}else if(item.equalsIgnoreCase(DataSourceEnum.WAVE_DATA.getValue())){
} else if (item.equalsIgnoreCase(DataSourceEnum.WAVE_DATA.getValue())) {
sampleCount.append("录波数据采集").append(adPlanTestConfig.getWaveRecord()).append("组,");
}else{
} else {
sampleCount.append("统计数据采集").append(adPlanTestConfig.getStatistics()).append("组,");
}
}
@@ -1805,10 +1802,10 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
if (dictDataById != null && "Contrast".equals(dictDataById.getCode())) {
// 比对模式:使用新的路径结构
String fileName = String.format("%s_%s_%s_%s.docx",
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
pqDevVO.getCityName() != null ? pqDevVO.getCityName() : "未知地市",
pqDevVO.getGdName() != null ? pqDevVO.getGdName() : "未知供电公司",
pqDevVO.getSubName() != null ? pqDevVO.getSubName() : "未知电站",
pqDevVO.getName() != null ? pqDevVO.getName() : "未知设备");
filePath = reportPath.concat(File.separator).concat(plan.getName()).concat(File.separator).concat(fileName);
downloadFileName = fileName;
} else {
@@ -1879,12 +1876,12 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
for (int i = 0; i < pqDevVOList.size(); i++) {
pqDevVO = pqDevVOList.get(i);
tempPqDevVO = pqDevVO;
if (!pqDevVO.getCheckState().equals(CheckStateEnum.CHECKED.getValue())) {
throw new BusinessException(DetectionResponseEnum.DEV_UN_CHECKED);
}
if (!pqDevVO.getReportState().equals(DevReportStateEnum.GENERATED.getValue())) {
devIds.add(pqDevVO.getId());
tempPqDevVO = pqDevVO;
}
}
@@ -1986,7 +1983,6 @@ public class PqReportServiceImpl extends ServiceImpl<PqReportMapper, PqReport> i
}
/**
*
* 比对模式下需要获取的数据
* 处理基础模版中的信息,非数据页报告
* 因为Docx4j工具包替换时会默认增加${}