微调
This commit is contained in:
@@ -5,7 +5,6 @@ import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.alibaba.fastjson.serializer.SerializerFeature;
|
||||
import com.njcn.gather.detection.pojo.enums.DetectionCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.pojo.vo.SocketDataMsg;
|
||||
import com.njcn.gather.storage.pojo.po.AdHarmonicResult;
|
||||
@@ -76,103 +75,4 @@ public class MsgUtil {
|
||||
}
|
||||
return JSON.toJSONString(socketDataMsg);
|
||||
}
|
||||
|
||||
public static List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm, boolean containBaseHarm) {
|
||||
List<DevData> info = new ArrayList<>();
|
||||
// if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
Map<String, List<AdNonHarmonicResult>> noHarmMap = nonHarm.stream()
|
||||
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)) + "_" + x.getSort()));
|
||||
noHarmMap.forEach((key, value) -> {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0] + "_" + split[1]);
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(result.getDataType());
|
||||
sqlDataDTO.setDesc(result.getAdType());
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(result.getAValue()) ? Double.valueOf(result.getAValue()) : null);
|
||||
listDTO.setB(StrUtil.isNotBlank(result.getBValue()) ? Double.valueOf(result.getBValue()) : null);
|
||||
listDTO.setC(StrUtil.isNotBlank(result.getCValue()) ? Double.valueOf(result.getCValue()) : null);
|
||||
listDTO.setT(StrUtil.isNotBlank(result.getTValue()) ? Double.valueOf(result.getTValue()) : null);
|
||||
sqlDataDTO.setList(listDTO);
|
||||
sqlDataDTOS.add(sqlDataDTO);
|
||||
}
|
||||
data.setSqlData(sqlDataDTOS);
|
||||
info.add(data);
|
||||
});
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harm)) {
|
||||
Map<String, List<AdHarmonicResult>> harmMap = harm.stream()
|
||||
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN))));
|
||||
harmMap.forEach((key, value) -> {
|
||||
List<DevData> collect = info.stream().filter(x -> key.equals(x.getId() + "_" + x.getTime())).collect(Collectors.toList());
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
List<DevData.SqlDataHarmDTO> sqlDataHarmDTOS = new ArrayList<>();
|
||||
DevData.SqlDataHarmDTO dataHarmDTO;
|
||||
for (AdHarmonicResult harmonicResult : value) {
|
||||
if (containBaseHarm) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(harmonicResult.getDataType());
|
||||
sqlDataDTO.setDesc(harmonicResult.getAdType());
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(harmonicResult.getAValue1()) ? Double.valueOf(harmonicResult.getAValue1()) : null);
|
||||
listDTO.setB(StrUtil.isNotBlank(harmonicResult.getBValue1()) ? Double.valueOf(harmonicResult.getBValue1()) : null);
|
||||
listDTO.setC(StrUtil.isNotBlank(harmonicResult.getCValue1()) ? Double.valueOf(harmonicResult.getCValue1()) : null);
|
||||
sqlDataDTO.setList(listDTO);
|
||||
sqlDataDTOS.add(sqlDataDTO);
|
||||
}
|
||||
|
||||
dataHarmDTO = new DevData.SqlDataHarmDTO();
|
||||
dataHarmDTO.setType(harmonicResult.getDataType());
|
||||
dataHarmDTO.setDesc(harmonicResult.getAdType());
|
||||
dataHarmDTO.setNum(containBaseHarm ? 49 : 50);
|
||||
DevData.SqlDataHarmDTO.ListDTO listHarmDTO = new DevData.SqlDataHarmDTO.ListDTO();
|
||||
listHarmDTO.setA(reflectHarmonicValue("a", harmonicResult, containBaseHarm));
|
||||
listHarmDTO.setB(reflectHarmonicValue("b", harmonicResult, containBaseHarm));
|
||||
listHarmDTO.setC(reflectHarmonicValue("c", harmonicResult, containBaseHarm));
|
||||
dataHarmDTO.setList(listHarmDTO);
|
||||
sqlDataHarmDTOS.add(dataHarmDTO);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
collect.get(0).setSqlDataHarm(sqlDataHarmDTOS);
|
||||
} else {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0] + "_" + split[1]);
|
||||
data.setSqlData(sqlDataDTOS);
|
||||
data.setSqlDataHarm(sqlDataHarmDTOS);
|
||||
info.add(data);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
// }
|
||||
return info;
|
||||
|
||||
}
|
||||
|
||||
private static List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult, boolean notContainBaseHarm) {
|
||||
List<String> info = new ArrayList<>();
|
||||
for (int i = notContainBaseHarm ? 2 : 1; i <= 50; i++) {
|
||||
String fieldName = phase + "Value" + i;
|
||||
try {
|
||||
Field idField = AdHarmonicResult.class.getDeclaredField(fieldName);
|
||||
idField.setAccessible(true);
|
||||
String value = idField.get(adHarmonicResult) + "";
|
||||
info.add(value);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package com.njcn.gather.device.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -15,31 +12,22 @@ import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import com.njcn.web.utils.FileUtil;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiImplicitParams;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
@@ -63,7 +51,6 @@ import java.util.Map;
|
||||
public class PqDevController extends BaseController {
|
||||
|
||||
private final IPqDevService pqDevService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IDevTypeService devTypeService;
|
||||
|
||||
|
||||
@@ -148,24 +135,14 @@ public class PqDevController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出被检设备数据")
|
||||
@ApiOperation("批量导出被检设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
public void exportDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("exportDev");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
DictData dictData = dictDataService.getDictDataById(queryParam.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
List<PqDevExcel.ContrastExportData> data = pqDevService.getContrastExportData(queryParam);
|
||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", PqDevExcel.ContrastExportData.class, data);
|
||||
} else {
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> data = pqDevService.getSimulateOrDigitExportData(queryParam);
|
||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", PqDevExcel.SimulateOrDigitalExportData.class, data);
|
||||
}
|
||||
}
|
||||
pqDevService.exportDev(queryParam);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@@ -176,108 +153,124 @@ public class PqDevController extends BaseController {
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/importContrast")
|
||||
@ApiOperation("批量导入被检设备数据")
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
|
||||
public HttpResult<Object> importContrastData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importContrastData");
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入被检设备")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult<String> importDev(@RequestParam("file") MultipartFile file, @RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importDev");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(2);
|
||||
params.setNeedVerify(true);
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
try {
|
||||
ExcelImportResult<PqDevExcel.ContrastImportData> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ContrastImportData.class, params);
|
||||
//如果存在非法数据,将不合格的数据导出
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
} else {
|
||||
//批量录入数据
|
||||
List<PqDevExcel.ContrastImportData> list = excelImportResult.getList();
|
||||
pqDevService.importContrastData(list);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
pqDevService.importDev(file, patternId, null, response);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
// @PostMapping(value = "/importContrast")
|
||||
// @ApiOperation("批量导入被检设备数据")
|
||||
// @ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
|
||||
// public HttpResult<Object> importContrastData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
// String methodDescribe = getMethodDescribe("importContrastData");
|
||||
// LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
// ImportParams params = new ImportParams();
|
||||
// params.setHeadRows(2);
|
||||
// params.setNeedVerify(true);
|
||||
// params.setStartSheetIndex(0);
|
||||
// params.setSheetNum(1);
|
||||
// try {
|
||||
// ExcelImportResult<PqDevExcel.ContrastImportData> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ContrastImportData.class, params);
|
||||
// //如果存在非法数据,将不合格的数据导出
|
||||
// if (excelImportResult.isVerifyFail()) {
|
||||
// // 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
// Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
// PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
// } else {
|
||||
// //批量录入数据
|
||||
// List<PqDevExcel.ContrastImportData> list = excelImportResult.getList();
|
||||
// pqDevService.importContrastData(list);
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
// }
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 导出灿能二楼设备
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/exportCNDev")
|
||||
@ApiOperation("导出被检设备数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void exportCNDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("exportCNDev");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
|
||||
pqDevService.exportCNDev(queryParam);
|
||||
}
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
// @PostMapping("/exportCNDev")
|
||||
// @ApiOperation("导出被检设备数据")
|
||||
// @ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
// public void exportCNDev(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
// String methodDescribe = getMethodDescribe("exportCNDev");
|
||||
// LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
//
|
||||
// pqDevService.exportCNDev(queryParam);
|
||||
// }
|
||||
|
||||
/**
|
||||
* 下载灿能二楼设备导入文件模板
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadCNDevTemplate")
|
||||
@ApiOperation("下载被检设备导入文件模板")
|
||||
public void downloadCNDevTemplate() {
|
||||
pqDevService.downloadCNDevTemplate();
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
// @PostMapping("/downloadCNDevTemplate")
|
||||
// @ApiOperation("下载被检设备导入文件模板")
|
||||
// public void downloadCNDevTemplate() {
|
||||
// pqDevService.downloadCNDevTemplate();
|
||||
// }
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/importCNDev")
|
||||
@ApiOperation("批量导入设备数据")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
@ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
})
|
||||
public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file,@RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importCNDev");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
|
||||
boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
if (!fileType) {
|
||||
throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
}
|
||||
|
||||
ImportParams params = new ImportParams();
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedVerify(true);
|
||||
|
||||
List<CNDevExcel> cnDevExcelList;
|
||||
try {
|
||||
ExcelImportResult<CNDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), CNDevExcel.class, params);
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
return null;
|
||||
} else {
|
||||
cnDevExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(cnDevExcelList)) {
|
||||
pqDevService.importCNDev(cnDevExcelList, patternId, null);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
// @PostMapping(value = "/importCNDev")
|
||||
// @ApiOperation("批量导入设备数据")
|
||||
// @ApiImplicitParams({
|
||||
// @ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true),
|
||||
// @ApiImplicitParam(name = "patternId", value = "模式id", required = true)
|
||||
// })
|
||||
// public HttpResult<String> importCNDev(@RequestParam("file") MultipartFile file,@RequestParam("patternId") String patternId, HttpServletResponse response) {
|
||||
// String methodDescribe = getMethodDescribe("importCNDev");
|
||||
// LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
//
|
||||
// boolean fileType = FileUtil.judgeFileIsExcel(file.getOriginalFilename());
|
||||
// if (!fileType) {
|
||||
// throw new BusinessException(CommonResponseEnum.FILE_XLSX_ERROR);
|
||||
// }
|
||||
//
|
||||
// ImportParams params = new ImportParams();
|
||||
// params.setStartSheetIndex(0);
|
||||
// params.setSheetNum(1);
|
||||
// params.setHeadRows(1);
|
||||
// params.setNeedVerify(true);
|
||||
//
|
||||
// List<CNDevExcel> cnDevExcelList;
|
||||
// try {
|
||||
// ExcelImportResult<CNDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), CNDevExcel.class, params);
|
||||
// if (excelImportResult.isVerifyFail()) {
|
||||
// // 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
// Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
// PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
//// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
// return null;
|
||||
// } else {
|
||||
// cnDevExcelList = excelImportResult.getList();
|
||||
// }
|
||||
// } catch (Exception e) {
|
||||
// throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
// }
|
||||
// if (ObjectUtil.isNotEmpty(cnDevExcelList)) {
|
||||
// pqDevService.importCNDev(cnDevExcelList, patternId, null);
|
||||
// }
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// }
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listUnbound")
|
||||
@ApiOperation("获取指定模式下所有未绑定的设备")
|
||||
@@ -324,19 +317,4 @@ public class PqDevController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
// @OperateInfo(operateType = OperateType.UPDATE)
|
||||
// @PostMapping("/bindDev")
|
||||
// @ApiOperation("检测计划绑定设备")
|
||||
// @ApiImplicitParam(name = "bindPlanParam", value = "绑定参数", required = true)
|
||||
// public HttpResult<Object> bindDev(@RequestBody @Validated PqDevParam.BindPlanParam bindPlanParam) {
|
||||
// String methodDescribe = getMethodDescribe("bindDev");
|
||||
// LogUtil.njcnDebug(log, "{},绑定计划数据为:planId={}, pqDevIds={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
|
||||
// boolean result = pqDevService.bind(bindPlanParam.getPlanId(), bindPlanParam.getPqDevIds());
|
||||
// if (result) {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
|
||||
@@ -30,7 +30,7 @@ public interface DevValidMessage {
|
||||
|
||||
String CREATEDATETIME_NOT_NULL = "出厂日期不能为空,请检查producedDate参数";
|
||||
|
||||
String CREATEDATETIME_FORMAT_ERROR = "出厂日期格式错误,请检查createDateTime参数";
|
||||
String CREATEDATETIME_FORMAT_ERROR = "出厂日期格式错误,请检查createDate参数";
|
||||
|
||||
String FACTORYNO_NOT_BLANK = "出厂编号不能为空,请检查factoryNo参数";
|
||||
|
||||
|
||||
@@ -39,16 +39,16 @@ public class CNDevExcel {
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码", width = 30, orderNum = "6")
|
||||
@Excel(name = "识别码(当加密时必填)", width = 30, orderNum = "6")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥", width = 30, orderNum = "7")
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "7")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "8")
|
||||
private Integer factorFlag;
|
||||
|
||||
@Excel(name = "IP地址*", width = 20, replace = {"否_0", "是_1"}, orderNum = "9")
|
||||
@Excel(name = "IP地址*", width = 20, orderNum = "9")
|
||||
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@@ -1,211 +0,0 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.monitor.pojo.vo.PqMonitorExcel;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/7
|
||||
*/
|
||||
@Data
|
||||
public class PqDevExcel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "名称", width = 20, needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备类型", width = 20, orderNum = "2", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备通道数", width = 20, orderNum = "3", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@Excel(name = "额定电压(V)", width = 15, orderNum = "4", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@Excel(name = "额定电流(A)", width = 15, orderNum = "5", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@Excel(name = "设备厂家", width = 20, orderNum = "6", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "设备序列号", width = 40, orderNum = "8", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议", width = 15, orderNum = "11", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "IP地址", width = 20, orderNum = "12", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号", orderNum = "13", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否为加密版本(否\\是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码(当为加密版本时必填)", width = 30, orderNum = "15", needMerge = true)
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥(当为加密版本时必填)", width = 30, orderNum = "16", needMerge = true)
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "所属地市名称", width = 20, orderNum = "19", needMerge = true)
|
||||
private String cityName;
|
||||
|
||||
@Excel(name = "所属供电公司名称", width = 20, orderNum = "20", needMerge = true)
|
||||
private String gdName;
|
||||
|
||||
@Excel(name = "所属电站名称", width = 20, orderNum = "21", needMerge = true)
|
||||
private String subName;
|
||||
|
||||
@Excel(name = "关键信息二维码", width = 20, orderNum = "30", needMerge = true)
|
||||
private String qrCode;
|
||||
|
||||
@Excel(name = "检测次数", width = 15, orderNum = "31", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
private Integer reCheckNum;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportData extends PqDevExcel {
|
||||
|
||||
@Excel(name = "设备模式", width = 20, orderNum = "1", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "是否支持系数校准(否\\是)", width = 15, replace = {"否_0", "是_1"}, orderNum = "22", needMerge = true)
|
||||
private Integer factorFlag;
|
||||
|
||||
@Excel(name = "守时检测结果(不合格\\合格\\/)", replace = {"不合格_0", "合格_1", "/_2"}, width = 15, orderNum = "23", needMerge = true)
|
||||
private Integer timeCheckResult;
|
||||
|
||||
@Excel(name = "系数校准结果(不合格\\合格\\/)", width = 15, replace = {"不合格_0", "合格_1", "/_2"}, orderNum = "24", needMerge = true)
|
||||
private Integer factorCheckResult;
|
||||
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成\\归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "25", needMerge = true)
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 15, replace = {"不符合_0", "符合_1", "未检_2"}, orderNum = "26", needMerge = true)
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(未生成\\已生成\\未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "27", needMerge = true)
|
||||
private Integer reportState;
|
||||
|
||||
// @Excel(name = "归档状态(未归档\\归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "28", needMerge = true)
|
||||
// private Integer documentState;
|
||||
|
||||
@Excel(name = "报告路径", width = 20, orderNum = "29", needMerge = true)
|
||||
private String reportPath;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟式和比对式设备导出数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SimulateOrDigitalExportData extends ExportData {
|
||||
@Excel(name = "样品编号", width = 40, orderNum = "17", needMerge = true)
|
||||
private String sampleId;
|
||||
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18", needMerge = true)
|
||||
private LocalDate arrivedDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 比对式设备导出数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ContrastExportData extends ExportData {
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "32")
|
||||
List<PqMonitorExcel.ExportData> monitorList;
|
||||
}
|
||||
|
||||
/**
|
||||
* 被检设备导入数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends PqDevExcel {
|
||||
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
|
||||
@Excel(name = "是否支持系数校准(否\\是)", width = 15, replace = {"否_0", "是_1"}, orderNum = "22", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.FACTOR_FLAG_NOT_BLANK)
|
||||
private String factorFlag;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 模拟式和比对式设备导入数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class SimulateOrDigitalImportData extends ImportData {
|
||||
@Excel(name = "样品编号", width = 40, orderNum = "17", needMerge = true)
|
||||
private String sampleId;
|
||||
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18", needMerge = true)
|
||||
@DateTimeStrValid(message = DevValidMessage.ARRIVE_DATE_FORMAT_ERROR)
|
||||
private String arrivedDate;
|
||||
}
|
||||
|
||||
/**
|
||||
* 对比式设备导入数据
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ContrastImportData extends ImportData {
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "32")
|
||||
List<PqMonitorExcel.ImportData> monitorList;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,213 @@
|
||||
package com.njcn.gather.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import lombok.Data;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/7
|
||||
* @description 省级平台设备Excel导入导出实体类
|
||||
*/
|
||||
@Data
|
||||
public class ProvinceDevExcel implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "装置编号*", width = 20)
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "设备名称*", width = 20, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备类型*", width = 20, orderNum = "3")
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
// @Excel(name = "设备通道数", width = 20, orderNum = "4")
|
||||
// @NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
// private Integer devChns;
|
||||
//
|
||||
// @Excel(name = "额定电压(V)", width = 15, orderNum = "5")
|
||||
// @NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
// private Float devVolt;
|
||||
//
|
||||
// @Excel(name = "额定电流(A)", width = 15, orderNum = "6")
|
||||
// @NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
// private Float devCurr;
|
||||
|
||||
@Excel(name = "设备厂家*", width = 20, orderNum = "7")
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "出厂日期*", width = 25, format = "yyyy-MM-dd", orderNum = "8")
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9")
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10")
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议*", width = 15, orderNum = "11")
|
||||
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "IP地址*", width = 20, orderNum = "12")
|
||||
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号*", width = 15, orderNum = "13")
|
||||
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否加密*", width = 20, replace = {"否_0", "是_1"}, orderNum = "14")
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码(当加密时必填)", width = 30, orderNum = "15")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥(当加密时必填)", width = 30, orderNum = "16")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "是否支持系数校准*", width = 25, replace = {"否_0", "是_1"}, orderNum = "17")
|
||||
private Integer factorFlag;
|
||||
|
||||
// @Excel(name = "所属地市名称", width = 20, orderNum = "19")
|
||||
// private String cityName;
|
||||
//
|
||||
// @Excel(name = "所属供电公司名称", width = 20, orderNum = "20")
|
||||
// private String gdName;
|
||||
//
|
||||
// @Excel(name = "所属电站名称", width = 20, orderNum = "21")
|
||||
// private String subName;
|
||||
//
|
||||
// @Excel(name = "关键信息二维码", width = 20, orderNum = "30")
|
||||
// private String qrCode;
|
||||
//
|
||||
// @Excel(name = "检测次数", width = 15, orderNum = "31")
|
||||
// @NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
// private Integer reCheckNum;
|
||||
|
||||
|
||||
// @Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
// public static class ExportData extends PqDevExcel {
|
||||
//
|
||||
// @Excel(name = "设备模式", width = 20, orderNum = "1")
|
||||
// @NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
// private String pattern;
|
||||
//
|
||||
// @Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
// @NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
// private LocalDate createDate;
|
||||
//
|
||||
// @Excel(name = "是否支持系数校准(否\\是)", width = 15, replace = {"否_0", "是_1"}, orderNum = "22")
|
||||
// private Integer factorFlag;
|
||||
//
|
||||
// @Excel(name = "守时检测结果(不合格\\合格\\/)", replace = {"不合格_0", "合格_1", "/_2"}, width = 15, orderNum = "23")
|
||||
// private Integer timeCheckResult;
|
||||
//
|
||||
// @Excel(name = "系数校准结果(不合格\\合格\\/)", width = 15, replace = {"不合格_0", "合格_1", "/_2"}, orderNum = "24")
|
||||
// private Integer factorCheckResult;
|
||||
//
|
||||
// @Excel(name = "检测状态(未检\\检测中\\检测完成\\归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "25")
|
||||
// private Integer checkState;
|
||||
//
|
||||
// @Excel(name = "检测结果(不符合\\符合\\未检)", width = 15, replace = {"不符合_0", "符合_1", "未检_2"}, orderNum = "26")
|
||||
// private Integer checkResult;
|
||||
//
|
||||
// @Excel(name = "报告状态(未生成\\已生成\\未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "27")
|
||||
// private Integer reportState;
|
||||
//
|
||||
//// @Excel(name = "归档状态(未归档\\归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "28")
|
||||
//// private Integer documentState;
|
||||
//
|
||||
// @Excel(name = "报告路径", width = 20, orderNum = "29")
|
||||
// private String reportPath;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 模拟式和比对式设备导出数据
|
||||
// */
|
||||
// @Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
// public static class SimulateOrDigitalExportData extends ExportData {
|
||||
// @Excel(name = "样品编号", width = 40, orderNum = "17")
|
||||
// private String sampleId;
|
||||
//
|
||||
// @Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18")
|
||||
// private LocalDate arrivedDate;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 比对式设备导出数据
|
||||
// */
|
||||
// @Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
// public static class ContrastExportData extends ExportData {
|
||||
// @ExcelCollection(name = "检测点台账", orderNum = "32")
|
||||
// List<PqMonitorExcel.ExportData> monitorList;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 被检设备导入数据
|
||||
// */
|
||||
// @Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
// public static class ImportData extends PqDevExcel {
|
||||
//
|
||||
// @Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
// @NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
// @DateTimeStrValid(message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
// private String createDate;
|
||||
//
|
||||
//
|
||||
// @Excel(name = "是否支持系数校准(否\\是)", width = 15, replace = {"否_0", "是_1"}, orderNum = "22")
|
||||
// @NotBlank(message = DevValidMessage.FACTOR_FLAG_NOT_BLANK)
|
||||
// private String factorFlag;
|
||||
//
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 模拟式和比对式设备导入数据
|
||||
// */
|
||||
// @Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
// public static class SimulateOrDigitalImportData extends ImportData {
|
||||
// @Excel(name = "样品编号", width = 40, orderNum = "17")
|
||||
// private String sampleId;
|
||||
//
|
||||
// @Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18")
|
||||
// @DateTimeStrValid(message = DevValidMessage.ARRIVE_DATE_FORMAT_ERROR)
|
||||
// private String arrivedDate;
|
||||
// }
|
||||
//
|
||||
// /**
|
||||
// * 对比式设备导入数据
|
||||
// */
|
||||
// @Data
|
||||
// @EqualsAndHashCode(callSuper = true)
|
||||
// public static class ContrastImportData extends ImportData {
|
||||
// @ExcelCollection(name = "检测点台账", orderNum = "32")
|
||||
// List<PqMonitorExcel.ImportData> monitorList;
|
||||
// }
|
||||
|
||||
}
|
||||
@@ -6,11 +6,13 @@ import com.njcn.gather.device.pojo.enums.TimeCheckResultEnum;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -67,7 +69,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param queryParam 查询参数
|
||||
* @return
|
||||
*/
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam);
|
||||
//List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出时所需的数据
|
||||
@@ -75,26 +77,21 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @param queryParam 查询参数
|
||||
* @return 比对式设备导出时所需的数据
|
||||
*/
|
||||
List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 下载模板文件
|
||||
*/
|
||||
void downloadTemplate();
|
||||
//List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 批量导入被检设备信息
|
||||
*
|
||||
* @param sgEventExcels 批量导入的数据
|
||||
*/
|
||||
void importContrastData(List<PqDevExcel.ContrastImportData> sgEventExcels);
|
||||
//void importContrastData(List<PqDevExcel.ContrastImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 批量导入被检设备信息
|
||||
*
|
||||
* @param sgEventExcels 批量导入的数据
|
||||
*/
|
||||
void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels);
|
||||
//void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 获取所有未绑定的设备
|
||||
@@ -121,14 +118,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
Integer bind(String planId, List<String> devIds);
|
||||
|
||||
/**
|
||||
* 获取饼图数据
|
||||
*
|
||||
* @param planId 检测计划id
|
||||
* @return 饼图数据
|
||||
*/
|
||||
//List<List<Map<String, Object>>> getPieData(String planId);
|
||||
|
||||
/**
|
||||
* 根据id获取被检设备信息
|
||||
*
|
||||
@@ -137,25 +126,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
PqDevVO getPqDevById(String id);
|
||||
|
||||
/**
|
||||
* 获取所有非未检测状态的设备
|
||||
*
|
||||
* @return 所有非未检测状态的设备列表
|
||||
*/
|
||||
List<PqDev> listUnchecked();
|
||||
|
||||
/**
|
||||
* 可视化,各种id回显字典值,解码等操作
|
||||
*
|
||||
* @param sourceList
|
||||
*/
|
||||
void visualize(List<PqDev> sourceList);
|
||||
|
||||
/**
|
||||
* 逆向可视化
|
||||
*/
|
||||
void reverseVisualize(List<PqDev> sourceList);
|
||||
|
||||
/**
|
||||
* 获取装置信息和装置下监测点信息
|
||||
*
|
||||
@@ -174,7 +144,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
boolean documented(List<String> id);
|
||||
|
||||
|
||||
/**
|
||||
* 正式监测完成,修改中断状态
|
||||
*
|
||||
@@ -189,27 +158,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
|
||||
int countUnReportDev(String planId);
|
||||
|
||||
/**
|
||||
* 导出灿能二楼设备数据
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
void exportCNDev(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 下载灿能二楼设备模板文件
|
||||
*/
|
||||
void downloadCNDevTemplate();
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备数据
|
||||
*
|
||||
* @param cnDevExcelList 灿能二楼设备数据列表
|
||||
* @param patternId 模式Id
|
||||
* @param planId 计划Id
|
||||
*/
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 根据计划id列表获取设备列表
|
||||
*
|
||||
@@ -218,6 +166,47 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
List<PqDev> listByPlanIds(List<String> planIds);
|
||||
|
||||
/**
|
||||
* 导出设备数据
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
void exportDev(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 下载模板文件
|
||||
*/
|
||||
void downloadTemplate();
|
||||
|
||||
/**
|
||||
* 导入设备数据
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @param patternId 模式Id
|
||||
* @param planId 计划Id
|
||||
* @param response 响应
|
||||
*/
|
||||
void importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备数据
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @param patternId 模式Id
|
||||
* @param planId 计划Id
|
||||
* @param response 响应
|
||||
*/
|
||||
void importCNDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导入灿能二楼设备数据
|
||||
*
|
||||
* @param cnDevExcelList
|
||||
* @param patternId
|
||||
* @param planId
|
||||
*/
|
||||
void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 可视化-灿能二楼设备
|
||||
*
|
||||
@@ -228,8 +217,42 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
/**
|
||||
* 逆向可视化-灿能二楼设备
|
||||
*
|
||||
* @param pqDevs 设备列表
|
||||
* @param pqDevs 设备列表
|
||||
* @param patternId 模式Id
|
||||
*/
|
||||
void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId);
|
||||
|
||||
/**
|
||||
* 导入省级平台设备数据
|
||||
*
|
||||
* @param file 上传的文件
|
||||
* @param patternId 模式Id
|
||||
* @param planId 计划Id
|
||||
* @param response 响应
|
||||
*/
|
||||
void importProvinceDev(MultipartFile file, String patternId, String planId, HttpServletResponse response);
|
||||
|
||||
/**
|
||||
* 导入省级平台设备数据
|
||||
*
|
||||
* @param proviceDevExcelList
|
||||
* @param patternId
|
||||
* @param planId
|
||||
*/
|
||||
void importProvinceDev(List<ProvinceDevExcel> proviceDevExcelList, String patternId, String planId);
|
||||
|
||||
/**
|
||||
* 可视化-省级平台设备
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
void visualizeProvinceDev(List<PqDev> pqDevs);
|
||||
|
||||
/**
|
||||
* 逆向可视化-省级平台设备
|
||||
*
|
||||
* @param pqDevs 设备列表
|
||||
* @param patternId 模式Id
|
||||
*/
|
||||
void reverseVisualizeProvinceDev(List<PqDev> pqDevs, String patternId);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,9 @@
|
||||
package com.njcn.gather.device.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
@@ -22,12 +25,11 @@ import com.njcn.gather.device.pojo.enums.*;
|
||||
import com.njcn.gather.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.pojo.vo.CNDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.pojo.vo.PqDevVO;
|
||||
import com.njcn.gather.device.pojo.vo.PreDetection;
|
||||
import com.njcn.gather.device.pojo.vo.ProvinceDevExcel;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
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.storage.service.DetectionDataDealService;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
@@ -40,12 +42,16 @@ import com.njcn.gather.type.pojo.po.DevType;
|
||||
import com.njcn.gather.type.service.IDevTypeService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import com.njcn.web.utils.PoiUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -66,7 +72,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
private final IDictTypeService dictTypeService;
|
||||
|
||||
|
||||
@Override
|
||||
public Page<PqDevVO> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
Page<PqDev> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), this.getQueryWrapper(queryParam));
|
||||
@@ -203,89 +208,84 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.lambdaUpdate().set(PqDev::getTimeCheckResult, result.getValue()).in(PqDev::getId, ids).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
if (ObjectUtil.isNotNull(pqDevs)) {
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
return pqDevExcels;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
if (ObjectUtil.isNotEmpty(pqDevs)) {
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.ContrastExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ContrastExportData.class);
|
||||
for (int i = 0; i < pqDevs.size(); i++) {
|
||||
List<PqMonitorExcel.ExportData> monitorExportList = BeanUtil.copyToList(pqMonitorService.listPqMonitorByDevId(pqDevs.get(i).getId()), PqMonitorExcel.ExportData.class);
|
||||
monitorExportList.forEach(monitor -> {
|
||||
monitor.setPtType(dictDataService.getDictDataById(monitor.getPtType()).getName());
|
||||
});
|
||||
pqDevExcels.get(i).setMonitorList(monitorExportList);
|
||||
}
|
||||
return pqDevExcels;
|
||||
} else {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
ExcelUtil.exportExcel("被检设备模板.xlsx", PqDevExcel.ContrastImportData.class, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void importContrastData(List<PqDevExcel.ContrastImportData> pqDevExcelList) {
|
||||
List<PqDev> devList = new ArrayList<>();
|
||||
List<PqMonitor> monitorList = new ArrayList<>();
|
||||
String patternId = dictDataService.getDictDataByName(PatternEnum.CONTRAST.getMsg()).getId();
|
||||
pqDevExcelList.forEach(pqDevExcel -> {
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDevExcel, pqDev);
|
||||
pqDev.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
pqDev.setPattern(patternId);
|
||||
// pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
// pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
// pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
// pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
// pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
// pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
devList.add(pqDev);
|
||||
|
||||
// 新增与被检设备绑定的监测点
|
||||
List<PqMonitor> monitors = pqDevExcel.getMonitorList().stream()
|
||||
.map(monitor -> {
|
||||
PqMonitor monitorPo = new PqMonitor();
|
||||
BeanUtil.copyProperties(monitor, monitorPo);
|
||||
monitorPo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
monitorPo.setDevId(pqDev.getId());
|
||||
monitorPo.setPtType(dictDataService.getDictDataByName(monitor.getPtType()).getId());
|
||||
return monitorPo;
|
||||
}).collect(Collectors.toList());
|
||||
monitorList.addAll(monitors);
|
||||
});
|
||||
|
||||
//逆向可视化
|
||||
this.reverseVisualize(devList);
|
||||
this.saveBatch(devList);
|
||||
|
||||
pqMonitorService.saveBatch(monitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> pqDevExcelList) {
|
||||
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualize(pqDevList);
|
||||
this.saveBatch(pqDevList);
|
||||
}
|
||||
// @Override
|
||||
// public List<PqDevExcel.SimulateOrDigitalExportData> getSimulateOrDigitExportData(PqDevParam.QueryParam queryParam) {
|
||||
// List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
// if (ObjectUtil.isNotNull(pqDevs)) {
|
||||
// this.visualize(pqDevs);
|
||||
// List<PqDevExcel.SimulateOrDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
// return pqDevExcels;
|
||||
// } else {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// public List<PqDevExcel.ContrastExportData> getContrastExportData(PqDevParam.QueryParam queryParam) {
|
||||
// List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
// if (ObjectUtil.isNotEmpty(pqDevs)) {
|
||||
// this.visualize(pqDevs);
|
||||
// List<PqDevExcel.ContrastExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ContrastExportData.class);
|
||||
// for (int i = 0; i < pqDevs.size(); i++) {
|
||||
// List<PqMonitorExcel.ExportData> monitorExportList = BeanUtil.copyToList(pqMonitorService.listPqMonitorByDevId(pqDevs.get(i).getId()), PqMonitorExcel.ExportData.class);
|
||||
// monitorExportList.forEach(monitor -> {
|
||||
// monitor.setPtType(dictDataService.getDictDataById(monitor.getPtType()).getName());
|
||||
// });
|
||||
// pqDevExcels.get(i).setMonitorList(monitorExportList);
|
||||
// }
|
||||
// return pqDevExcels;
|
||||
// } else {
|
||||
// return Collections.emptyList();
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = {Exception.class})
|
||||
// public void importContrastData(List<PqDevExcel.ContrastImportData> pqDevExcelList) {
|
||||
// List<PqDev> devList = new ArrayList<>();
|
||||
// List<PqMonitor> monitorList = new ArrayList<>();
|
||||
// String patternId = dictDataService.getDictDataByName(PatternEnum.CONTRAST.getMsg()).getId();
|
||||
// pqDevExcelList.forEach(pqDevExcel -> {
|
||||
// PqDev pqDev = new PqDev();
|
||||
// BeanUtil.copyProperties(pqDevExcel, pqDev);
|
||||
// pqDev.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
// pqDev.setPattern(patternId);
|
||||
//// pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
//// pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
//// pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
//// pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
//// pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
//// pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
// devList.add(pqDev);
|
||||
//
|
||||
// // 新增与被检设备绑定的监测点
|
||||
// List<PqMonitor> monitors = pqDevExcel.getMonitorList().stream()
|
||||
// .map(monitor -> {
|
||||
// PqMonitor monitorPo = new PqMonitor();
|
||||
// BeanUtil.copyProperties(monitor, monitorPo);
|
||||
// monitorPo.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
// monitorPo.setDevId(pqDev.getId());
|
||||
// monitorPo.setPtType(dictDataService.getDictDataByName(monitor.getPtType()).getId());
|
||||
// return monitorPo;
|
||||
// }).collect(Collectors.toList());
|
||||
// monitorList.addAll(monitors);
|
||||
// });
|
||||
//
|
||||
// //逆向可视化
|
||||
// this.reverseVisualize(devList);
|
||||
// this.saveBatch(devList);
|
||||
//
|
||||
// pqMonitorService.saveBatch(monitorList);
|
||||
// }
|
||||
//
|
||||
// @Override
|
||||
// @Transactional(rollbackFor = {Exception.class})
|
||||
// public void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> pqDevExcelList) {
|
||||
// List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
|
||||
// //逆向可视化
|
||||
// this.reverseVisualize(pqDevList);
|
||||
// this.saveBatch(pqDevList);
|
||||
// }
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listUnbound(String pattern) {
|
||||
@@ -398,92 +398,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return pqDevVO;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listUnchecked() {
|
||||
return this.lambdaQuery()
|
||||
.eq(PqDev::getCheckState, CheckStateEnum.UNCHECKED.getValue())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode())
|
||||
.orderByAsc(PqDev::getCreateTime).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
if (StrUtil.isNotBlank(pqDev.getPattern())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setPattern(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevType())) {
|
||||
DevType devType = devTypeService.getById(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDev.setDevType(devType.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries())) {
|
||||
pqDev.setSeries(EncryptionUtil.decoderString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(EncryptionUtil.decoderString(1, pqDev.getDevKey()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reverseVisualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
// if (StrUtil.isNotBlank(pqDev.getPattern())) {
|
||||
// DictData dictData = dictDataService.getDictDataByName(pqDev.getPattern());
|
||||
// if (ObjectUtil.isNotNull(dictData)) {
|
||||
// pqDev.setPattern(dictData.getId());
|
||||
// }
|
||||
// }
|
||||
if (StrUtil.isNotBlank(pqDev.getDevType())) {
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(devType)) {
|
||||
pqDev.setDevType(devType.getId());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
// pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询条件wrapper
|
||||
@@ -536,7 +450,7 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
// @Transactional(rollbackFor = {Exception.class})
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean documented(List<String> ids) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
for (String id : ids) {
|
||||
@@ -574,7 +488,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateResult(List<String> ids, List<String> valueType, String code) {
|
||||
if (CollUtil.isNotEmpty(ids)) {
|
||||
@@ -664,178 +577,156 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.count(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportCNDev(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
List<CNDevExcel> pqDevExcels = null;
|
||||
if (ObjectUtil.isNotEmpty(pqDevs)) {
|
||||
this.visualizeCNDev(pqDevs);
|
||||
pqDevExcels = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
|
||||
}
|
||||
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", 1, this.getCNDevPullDownList(), CNDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadCNDevTemplate() {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", 1, this.getCNDevPullDownList(), CNDevExcel.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId,String planId) {
|
||||
List<PqDev> oldDevList = BeanUtil.copyToList(cnDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualizeCNDev(oldDevList, patternId);
|
||||
|
||||
List<PqDev> newDevList = new ArrayList<>();
|
||||
PqDevParam param = new PqDevParam.UpdateParam();
|
||||
oldDevList.forEach(pqDev -> {
|
||||
pqDev.setPlanId(planId);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
|
||||
String name = pqDev.getName();
|
||||
if (name.contains("-")) {
|
||||
String[] split = name.split("-");
|
||||
if (split.length == 2) {
|
||||
long start = Long.parseLong(split[0]);
|
||||
long end = Long.parseLong(split[1]);
|
||||
// 避免起始大于结束
|
||||
if (start > end) {
|
||||
long temp = start;
|
||||
start = end;
|
||||
end = temp;
|
||||
}
|
||||
for (long i = start; i <= end; i++) {
|
||||
PqDev dev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDev, dev);
|
||||
dev.setName(String.valueOf(i));
|
||||
dev.setCreateId(String.valueOf(i));
|
||||
dev.setPlanId(planId);
|
||||
|
||||
param.setName(dev.getName());
|
||||
param.setCreateId(dev.getName());
|
||||
param.setDevType(dev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(d -> d.getName().equals(dev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(dev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
}
|
||||
} else {
|
||||
|
||||
param.setName(pqDev.getName());
|
||||
param.setCreateId(pqDev.getCreateId());
|
||||
param.setDevType(pqDev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(pqDev);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
this.saveBatch(newDevList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listByPlanIds(List<String> planIds) {
|
||||
return this.lambdaQuery().in(PqDev::getPlanId, planIds).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
public void visualizeCNDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataById(pqDev.getPreinvestmentPlan()).getName());
|
||||
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
|
||||
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
|
||||
});
|
||||
@Override
|
||||
public void exportDev(PqDevParam.QueryParam queryParam) {
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
switch (currrentScene) {
|
||||
case "0":
|
||||
this.exportProvinceDev(queryParam);
|
||||
break;
|
||||
case "1":
|
||||
this.exportCNDev(queryParam);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
// pqDev.setIcdId(devType.getIcd());
|
||||
// pqDev.setDevVolt(devType.getDevVolt());
|
||||
// pqDev.setDevCurr(devType.getDevCurr());
|
||||
// pqDev.setDevChns(devType.getDevChns());
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
pqDev.setCreateDate(LocalDateTime.now().toLocalDate());
|
||||
pqDev.setCreateId(pqDev.getName());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
switch (currrentScene) {
|
||||
case "0":
|
||||
this.downloadProvinceDevTemplate();
|
||||
break;
|
||||
case "1":
|
||||
this.downloadCNDevTemplate();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
*
|
||||
* @param map 检测状态分组map
|
||||
* @return 检测状态饼状图数据
|
||||
*/
|
||||
// private List<Map<String, Object>> getCheckStatePieData(Map<Integer, Long> map) {
|
||||
// List<Map<String, Object>> result = new ArrayList<>();
|
||||
// for (CheckStateEnum e : CheckStateEnum.values()) {
|
||||
// Map<String, Object> temp = new HashMap<>();
|
||||
// temp.put("name", e.getMsg());
|
||||
// temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
// result.add(temp);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
@Override
|
||||
public void importDev(MultipartFile file, String patternId, String planId, HttpServletResponse response) {
|
||||
String currrentScene = sysTestConfigService.getCurrrentScene();
|
||||
switch (currrentScene) {
|
||||
case "0":
|
||||
this.importProvinceDev(file, patternId, planId, response);
|
||||
break;
|
||||
case "1":
|
||||
this.importCNDev(file, patternId, planId, response);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测结果饼状图数据
|
||||
*
|
||||
* @param map 检测结果分组map
|
||||
* @return 检测结果饼状图数据
|
||||
*/
|
||||
// private List<Map<String, Object>> getCheckResultPieData(Map<Integer, Long> map) {
|
||||
// List<Map<String, Object>> result = new ArrayList<>();
|
||||
// for (CheckResultEnum e : CheckResultEnum.values()) {
|
||||
// Map<String, Object> temp = new HashMap<>();
|
||||
// temp.put("name", e.getMsg());
|
||||
// temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
// result.add(temp);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importCNDev(MultipartFile file, String patternId, String planId, HttpServletResponse response) {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedVerify(true);
|
||||
|
||||
/**
|
||||
* 获取报告状态饼状图数据
|
||||
*
|
||||
* @param map 报告状态分组map
|
||||
* @return 报告状态饼状图数据
|
||||
*/
|
||||
// private List<Map<String, Object>> getReportStatePieData(Map<Integer, Long> map) {
|
||||
// List<Map<String, Object>> result = new ArrayList<>();
|
||||
// for (DevReportStateEnum e : DevReportStateEnum.values()) {
|
||||
// Map<String, Object> temp = new HashMap<>();
|
||||
// temp.put("name", e.getMsg());
|
||||
// temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
// result.add(temp);
|
||||
// }
|
||||
// return result;
|
||||
// }
|
||||
List<CNDevExcel> cnDevExcelList = null;
|
||||
try {
|
||||
ExcelImportResult<CNDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), CNDevExcel.class, params);
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
} else {
|
||||
cnDevExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
this.importCNDev(cnDevExcelList, patternId, planId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importCNDev(List<CNDevExcel> cnDevExcelList, String patternId, String planId) {
|
||||
if (CollUtil.isNotEmpty(cnDevExcelList)) {
|
||||
|
||||
|
||||
List<PqDev> oldDevList = BeanUtil.copyToList(cnDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualizeCNDev(oldDevList, patternId);
|
||||
|
||||
List<PqDev> newDevList = new ArrayList<>();
|
||||
PqDevParam param = new PqDevParam.UpdateParam();
|
||||
oldDevList.forEach(pqDev -> {
|
||||
pqDev.setPlanId(planId);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
|
||||
String name = pqDev.getName();
|
||||
if (name.contains("-")) {
|
||||
String[] split = name.split("-");
|
||||
if (split.length == 2) {
|
||||
long start = Long.parseLong(split[0]);
|
||||
long end = Long.parseLong(split[1]);
|
||||
// 避免起始大于结束
|
||||
if (start > end) {
|
||||
long temp = start;
|
||||
start = end;
|
||||
end = temp;
|
||||
}
|
||||
for (long i = start; i <= end; i++) {
|
||||
PqDev dev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDev, dev);
|
||||
dev.setName(String.valueOf(i));
|
||||
dev.setCreateId(String.valueOf(i));
|
||||
dev.setPlanId(planId);
|
||||
dev.setManufacturer("8fa73802c9e1abab973adcbeb0d58567"); // 南京灿能字典项目对应的id
|
||||
|
||||
param.setName(dev.getName());
|
||||
param.setCreateId(dev.getName());
|
||||
param.setDevType(dev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(d -> d.getName().equals(dev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(dev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
}
|
||||
} else {
|
||||
param.setName(pqDev.getName());
|
||||
param.setCreateId(pqDev.getCreateId());
|
||||
param.setDevType(pqDev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
pqDev.setManufacturer("8fa73802c9e1abab973adcbeb0d58567"); // 南京灿能字典项目对应的id
|
||||
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(pqDev);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.saveBatch(newDevList);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查设备是否重复
|
||||
@@ -864,7 +755,34 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出灿能二楼设备数据
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
private void exportCNDev(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
List<CNDevExcel> pqDevExcels = null;
|
||||
if (ObjectUtil.isNotEmpty(pqDevs)) {
|
||||
this.visualizeCNDev(pqDevs);
|
||||
pqDevExcels = BeanUtil.copyToList(pqDevs, CNDevExcel.class);
|
||||
}
|
||||
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", 1, this.getCNDevPullDownList(), CNDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载灿能二楼设备模板文件
|
||||
*/
|
||||
private void downloadCNDevTemplate() {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", 1, this.getCNDevPullDownList(), CNDevExcel.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取灿能二楼设备导出、导出文件模板的下拉列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<PullDown> getCNDevPullDownList() {
|
||||
List<PullDown> pullDowns = new ArrayList<>();
|
||||
// 预投计划
|
||||
@@ -920,4 +838,246 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
|
||||
/**
|
||||
* 可视化灿能二楼设备数据
|
||||
*
|
||||
* @param pqDevs
|
||||
*/
|
||||
public void visualizeCNDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataById(pqDev.getPreinvestmentPlan()).getName());
|
||||
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
|
||||
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 逆向可视化灿能二楼设备数据
|
||||
*
|
||||
* @param pqDevs 设备列表
|
||||
* @param patternId 模式Id
|
||||
*/
|
||||
public void reverseVisualizeCNDev(List<PqDev> pqDevs, String patternId) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setPreinvestmentPlan(dictDataService.getDictDataByName(pqDev.getPreinvestmentPlan()).getId());
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
pqDev.setCreateDate(LocalDateTime.now().toLocalDate());
|
||||
pqDev.setCreateId(pqDev.getName());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 导出省级平台设备数据
|
||||
*
|
||||
* @param queryParam
|
||||
*/
|
||||
private void exportProvinceDev(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
List<ProvinceDevExcel> pqDevExcels = null;
|
||||
if (ObjectUtil.isNotEmpty(pqDevs)) {
|
||||
this.visualizeProvinceDev(pqDevs);
|
||||
pqDevExcels = BeanUtil.copyToList(pqDevs, ProvinceDevExcel.class);
|
||||
}
|
||||
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备导出数据.xlsx", 1, this.getProvinceDevPullDownList(), ProvinceDevExcel.class, ObjectUtil.isEmpty(pqDevExcels) ? new ArrayList<>() : pqDevExcels);
|
||||
}
|
||||
|
||||
/**
|
||||
* 下载省级平台设备模板文件
|
||||
*/
|
||||
private void downloadProvinceDevTemplate() {
|
||||
ExcelUtil.exportExcelPullDown(new ExportParams(), "被检设备模板.xlsx", 1, this.getProvinceDevPullDownList(), ProvinceDevExcel.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取省级平台设备导出、导出文件模板的下拉列表
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
private List<PullDown> getProvinceDevPullDownList() {
|
||||
List<PullDown> pullDowns = new ArrayList<>();
|
||||
List<DictData> dictDataList = null;
|
||||
PullDown pullDown = null;
|
||||
|
||||
// 设备类型
|
||||
List<DevType> devTypeList = devTypeService.listAll();
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(2);
|
||||
pullDown.setLastCol(2);
|
||||
pullDown.setStrings(devTypeList.stream().map(DevType::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 设备厂家
|
||||
DictType dictType = dictTypeService.getByCode("Dev_Manufacturers");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(3);
|
||||
pullDown.setLastCol(3);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
// 通讯协议
|
||||
dictType = dictTypeService.getByCode("Protocol");
|
||||
if (ObjectUtil.isNotNull(dictType)) {
|
||||
dictDataList = dictDataService.getDictDataByTypeId(dictType.getId());
|
||||
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(7);
|
||||
pullDown.setLastCol(7);
|
||||
pullDown.setStrings(dictDataList.stream().map(DictData::getName).collect(Collectors.toList()));
|
||||
pullDowns.add(pullDown);
|
||||
}
|
||||
|
||||
// 是否加密
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(10);
|
||||
pullDown.setLastCol(10);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
// 是否支持系数校准
|
||||
pullDown = new PullDown();
|
||||
pullDown.setFirstCol(13);
|
||||
pullDown.setLastCol(13);
|
||||
pullDown.setStrings(Arrays.asList("是", "否"));
|
||||
pullDowns.add(pullDown);
|
||||
|
||||
return pullDowns;
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importProvinceDev(MultipartFile file, String patternId, String planId, HttpServletResponse response) {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
params.setHeadRows(1);
|
||||
params.setNeedVerify(true);
|
||||
|
||||
List<ProvinceDevExcel> cnDevExcelList = null;
|
||||
try {
|
||||
ExcelImportResult<ProvinceDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), ProvinceDevExcel.class, params);
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
} else {
|
||||
cnDevExcelList = excelImportResult.getList();
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
this.importProvinceDev(cnDevExcelList, patternId, planId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importProvinceDev(List<ProvinceDevExcel> proviceDevExcelList, String patternId, String planId) {
|
||||
if (CollUtil.isNotEmpty(proviceDevExcelList)) {
|
||||
|
||||
List<PqDev> oldDevList = BeanUtil.copyToList(proviceDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualizeProvinceDev(oldDevList, patternId);
|
||||
|
||||
List<PqDev> newDevList = new ArrayList<>();
|
||||
PqDevParam param = new PqDevParam.UpdateParam();
|
||||
oldDevList.forEach(pqDev -> {
|
||||
pqDev.setPlanId(planId);
|
||||
if (pqDev.getEncryptionFlag() == 1) {
|
||||
if (StrUtil.isNotBlank(pqDev.getSeries()) && StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setSeries(EncryptionUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(EncryptionUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
|
||||
String name = pqDev.getName();
|
||||
if (name.contains("-")) {
|
||||
String[] split = name.split("-");
|
||||
if (split.length == 2) {
|
||||
long start = Long.parseLong(split[0]);
|
||||
long end = Long.parseLong(split[1]);
|
||||
// 避免起始大于结束
|
||||
if (start > end) {
|
||||
long temp = start;
|
||||
start = end;
|
||||
end = temp;
|
||||
}
|
||||
for (long i = start; i <= end; i++) {
|
||||
PqDev dev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDev, dev);
|
||||
dev.setName(String.valueOf(i));
|
||||
// todo 这里建议和实际情况结合
|
||||
dev.setCreateId(String.valueOf(i));
|
||||
dev.setPlanId(planId);
|
||||
|
||||
param.setName(dev.getName());
|
||||
//param.setCreateId(dev.getName());
|
||||
param.setDevType(dev.getDevType());
|
||||
//this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(d -> d.getName().equals(dev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(dev);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FORMAT_FAIL);
|
||||
}
|
||||
} else {
|
||||
param.setName(pqDev.getName());
|
||||
param.setCreateId(pqDev.getCreateId());
|
||||
param.setDevType(pqDev.getDevType());
|
||||
this.checkRepeat(param, false);
|
||||
|
||||
long count = newDevList.stream().filter(dev -> dev.getName().equals(pqDev.getName())).count();
|
||||
if (count == 0) {
|
||||
newDevList.add(pqDev);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
this.saveBatch(newDevList);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void visualizeProvinceDev(List<PqDev> pqDevs) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
pqDev.setDevType(devTypeService.getById(pqDev.getDevType()).getName());
|
||||
pqDev.setManufacturer(dictDataService.getDictDataById(pqDev.getManufacturer()).getName());
|
||||
pqDev.setProtocol(dictDataService.getDictDataById(pqDev.getProtocol()).getName());
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reverseVisualizeProvinceDev(List<PqDev> pqDevs, String patternId) {
|
||||
pqDevs.forEach(pqDev -> {
|
||||
DevType devType = devTypeService.getByName(pqDev.getDevType());
|
||||
pqDev.setDevType(devType.getId());
|
||||
pqDev.setPattern(patternId);
|
||||
pqDev.setManufacturer(dictDataService.getDictDataByName(pqDev.getManufacturer()).getId());
|
||||
pqDev.setProtocol(dictDataService.getDictDataByName(pqDev.getProtocol()).getId());
|
||||
pqDev.setTimeCheckResult(TimeCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setFactorCheckResult(FactorCheckResultEnum.UNKNOWN.getValue());
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,6 +83,19 @@ public class ResultController extends BaseController {
|
||||
resultService.exportRawData(queryParam);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/reCalculate")
|
||||
@ApiOperation("重新计算检测结果")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Object> reCalculate(@RequestBody ResultParam.ChangeErrorSystemParam param) {
|
||||
String methodDescribe = getMethodDescribe("reCalculate");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
|
||||
resultService.reCalculate(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/changeErrorSystem")
|
||||
@ApiOperation("更换误差体系")
|
||||
|
||||
@@ -59,4 +59,10 @@ public interface IResultService {
|
||||
* @param code
|
||||
*/
|
||||
void deleteTempTable(String code);
|
||||
|
||||
/**
|
||||
* 重新计算
|
||||
* @param param
|
||||
*/
|
||||
void reCalculate(ResultParam.ChangeErrorSystemParam param);
|
||||
}
|
||||
|
||||
@@ -3,6 +3,7 @@ package com.njcn.gather.result.service.impl;
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.date.DatePattern;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -13,7 +14,6 @@ import com.njcn.gather.detection.pojo.enums.SourceOperateCodeEnum;
|
||||
import com.njcn.gather.detection.pojo.param.PreDetectionParam;
|
||||
import com.njcn.gather.detection.pojo.po.DevData;
|
||||
import com.njcn.gather.detection.service.impl.DetectionServiceImpl;
|
||||
import com.njcn.gather.detection.util.socket.MsgUtil;
|
||||
import com.njcn.gather.device.service.IPqDevService;
|
||||
import com.njcn.gather.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
@@ -52,6 +52,8 @@ import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.lang.reflect.Field;
|
||||
import java.time.format.DateTimeFormatter;
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -862,15 +864,21 @@ public class ResultServiceImpl implements IResultService {
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void changeErrorSystem(ResultParam.ChangeErrorSystemParam param) {
|
||||
this.createTempResultTable(param.getCode() + "");
|
||||
this.insertTempResultTable(param.getPlanId(), param.getScriptId(), param.getCode() + "", param.getErrorSysId(), param.getDeviceId());
|
||||
this.createTempResultTable(param.getCode() + "_temp");
|
||||
this.calculateResult(param.getPlanId(), param.getScriptId(), param.getCode() + "_temp", param.getErrorSysId(), param.getDeviceId());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteTempTable(String code) {
|
||||
code = code + "_temp";
|
||||
this.dropTempResultTable(code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reCalculate(ResultParam.ChangeErrorSystemParam param) {
|
||||
this.calculateResult(param.getPlanId(), param.getScriptId(), param.getCode(), param.getErrorSysId(), param.getDeviceId());
|
||||
}
|
||||
|
||||
private Integer conform(Set<Integer> numbers) {
|
||||
if (CollUtil.isNotEmpty(numbers)) {
|
||||
if (numbers.size() > 1) {
|
||||
@@ -892,7 +900,6 @@ public class ResultServiceImpl implements IResultService {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 拷贝结果表
|
||||
*
|
||||
@@ -900,7 +907,8 @@ public class ResultServiceImpl implements IResultService {
|
||||
*/
|
||||
private void createTempResultTable(String code) {
|
||||
this.dropTempResultTable(code);
|
||||
tableGenMapper.genAdNonHarmonicResultTable(code + "_temp");
|
||||
String oldCode = code.replace("_temp", "");
|
||||
tableGenMapper.genAdNonHarmonicResultTable(code);
|
||||
StringBuilder A = new StringBuilder();
|
||||
StringBuilder B = new StringBuilder();
|
||||
StringBuilder C = new StringBuilder();
|
||||
@@ -915,7 +923,7 @@ public class ResultServiceImpl implements IResultService {
|
||||
C.append("C_Value_").append(i).append(" json NULL COMMENT '").append(i).append("次C相谐波',");
|
||||
}
|
||||
}
|
||||
String sql1 = "CREATE TABLE if not exists AD_Harmonic_Result_" + code + "_temp (\n" +
|
||||
String sql1 = "CREATE TABLE if not exists AD_Harmonic_Result_" + code + "(\n" +
|
||||
" Monitor_Id CHAR(60) NOT NULL COMMENT '监测点Id',\n" +
|
||||
" Time_Id DATETIME NULL COMMENT '时间',\n" +
|
||||
" Script_Id CHAR(32) NOT NULL COMMENT '检测脚本子表Id,字典表',\n" +
|
||||
@@ -928,34 +936,34 @@ public class ResultServiceImpl implements IResultService {
|
||||
") COMMENT='监测数据表';";
|
||||
tableGenMapper.genAdHarmonicTable(sql1);
|
||||
|
||||
sql1 = "CREATE TABLE ad_non_harmonic_" + code + "_temp " + "LIKE ad_non_harmonic_" + code;
|
||||
sql1 = "CREATE TABLE ad_non_harmonic_" + code + " LIKE ad_non_harmonic_" + oldCode;
|
||||
tableGenMapper.genAdHarmonicTable(sql1);
|
||||
sql1 = "INSERT INTO ad_non_harmonic_" + code + "_temp " + "SELECT * FROM ad_non_harmonic_" + code;
|
||||
sql1 = "INSERT INTO ad_non_harmonic_" + code + " SELECT * FROM ad_non_harmonic_" + oldCode;
|
||||
tableGenMapper.genAdHarmonicTable(sql1);
|
||||
sql1 = "CREATE TABLE ad_harmonic_" + code + "_temp " + "LIKE ad_harmonic_" + code;
|
||||
sql1 = "CREATE TABLE ad_harmonic_" + code + " LIKE ad_harmonic_" + oldCode;
|
||||
tableGenMapper.genAdHarmonicTable(sql1);
|
||||
sql1 = "INSERT INTO ad_harmonic_" + code + "_temp " + "SELECT * FROM ad_harmonic_" + code;
|
||||
sql1 = "INSERT INTO ad_harmonic_" + code + " SELECT * FROM ad_harmonic_" + oldCode;
|
||||
tableGenMapper.genAdHarmonicTable(sql1);
|
||||
}
|
||||
|
||||
private void dropTempResultTable(String code) {
|
||||
tableGenMapper.genAdHarmonicTable("drop table if exists AD_Non_Harmonic_Result_" + code + "_temp,AD_Harmonic_Result_" + code + "_temp," + "ad_non_harmonic_" + code + "_temp," + "ad_harmonic_" + code + "_temp");
|
||||
tableGenMapper.genAdHarmonicTable("drop table if exists AD_Non_Harmonic_Result_" + code + ",AD_Harmonic_Result_" + code + "," + "ad_non_harmonic_" + code + "," + "ad_harmonic_" + code);
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改拷贝后的结果表(根据误差体系修改)
|
||||
* 根据原始数据、误差体系id、计算检测结果
|
||||
*
|
||||
* @param planId
|
||||
* @param code
|
||||
* @param errorSysId
|
||||
* @param devId
|
||||
*/
|
||||
private void insertTempResultTable(String planId, String scriptId, String code, String errorSysId, String devId) {
|
||||
private void calculateResult(String planId, String scriptId, String code, String errorSysId, String devId) {
|
||||
String oldCode = code.replace("_temp", "");
|
||||
PreDetectionParam param = new PreDetectionParam();
|
||||
param.setCode(code);
|
||||
param.setErrorSysId(errorSysId);
|
||||
param.setDevIds(Arrays.asList(devId));
|
||||
param.setCode(code + "_temp");
|
||||
|
||||
Map<String, String> devIdMapComm = new HashMap<>();
|
||||
// PqDev dev = pqDevService.getById(devId);
|
||||
@@ -969,10 +977,10 @@ public class ResultServiceImpl implements IResultService {
|
||||
dataRule = DictDataEnum.AT_WILL_VALUE;
|
||||
}
|
||||
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAll(code, devId);
|
||||
List<AdNonHarmonicResult> allNonHarmonicRawData = adNonHarmonicService.listAll(oldCode, devId);
|
||||
LinkedHashMap<Integer, List<AdNonHarmonicResult>> nonHarmonicMap = allNonHarmonicRawData.stream().sorted(Comparator.comparing(AdNonHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdNonHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
List<AdHarmonicResult> allHarmonicRawData = adHarmonicService.lisAll(code, devId);
|
||||
List<AdHarmonicResult> allHarmonicRawData = adHarmonicService.lisAll(oldCode, devId);
|
||||
LinkedHashMap<Integer, List<AdHarmonicResult>> harmonicMap = allHarmonicRawData.stream().sorted(Comparator.comparing(AdHarmonicResult::getSort))
|
||||
.collect(Collectors.groupingBy(AdHarmonicResult::getSort, LinkedHashMap::new, Collectors.toList()));
|
||||
|
||||
@@ -992,74 +1000,125 @@ public class ResultServiceImpl implements IResultService {
|
||||
List<AdHarmonicResult> harmonicResults = harmonicMap.get(sourceIssue.getIndex());
|
||||
List<DevData> realDataXiList = new ArrayList<>();
|
||||
if (CollUtil.isNotEmpty(nonHarmonicResults)) {
|
||||
realDataXiList.addAll(MsgUtil.toList(nonHarmonicResults, null, true));
|
||||
realDataXiList.addAll(this.toList(nonHarmonicResults, null, true));
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harmonicResults)) {
|
||||
DictTree dictTree = dictTreeService.getById(harmonicResults.get(0).getAdType());
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode()) || DetectionCodeEnum.P2_50.getCode().equals(dictTree.getCode())) {
|
||||
realDataXiList.addAll(MsgUtil.toList(null, harmonicResults, true));
|
||||
realDataXiList.addAll(this.toList(null, harmonicResults, true));
|
||||
} else {
|
||||
realDataXiList.addAll(MsgUtil.toList(null, harmonicResults, false));
|
||||
realDataXiList.addAll(this.toList(null, harmonicResults, false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (int i = 0; i < realDataXiList.size(); i++) {
|
||||
DevData devData = realDataXiList.get(i);
|
||||
List<DevData.SqlDataHarmDTO> sqlDataHarm = devData.getSqlDataHarm();
|
||||
if (CollUtil.isNotEmpty(sqlDataHarm)) {
|
||||
for (int j = 0; j < sqlDataHarm.size(); j++) {
|
||||
DevData.SqlDataHarmDTO sqlDataDTO = sqlDataHarm.get(j);
|
||||
String desc = sqlDataDTO.getDesc();
|
||||
if (StrUtil.isNotBlank(desc)) {
|
||||
DictTree dictTree = dictTreeService.getById(desc);
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<DevData.SqlDataDTO> sqlData = devData.getSqlData();
|
||||
if (CollUtil.isNotEmpty(sqlData)) {
|
||||
for (int j = 0; j < sqlData.size(); j++) {
|
||||
DevData.SqlDataDTO sqlDataDTO = sqlData.get(j);
|
||||
String desc = sqlDataDTO.getDesc();
|
||||
if (StrUtil.isNotBlank(desc)) {
|
||||
DictTree dictTree = dictTreeService.getById(desc);
|
||||
if (ObjectUtil.isNotNull(dictTree)) {
|
||||
if (CollUtil.isNotEmpty(harmonicResults)) {
|
||||
// if (dictTree.getCode().contains("V")) {
|
||||
// sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode());
|
||||
// }
|
||||
// if (dictTree.getCode().contains("I")) {
|
||||
// sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode());
|
||||
// }
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode());
|
||||
}
|
||||
if (DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode());
|
||||
}
|
||||
// if (DetectionCodeEnum.SV_1_49.getCode().equals(dictTree.getCode())) {
|
||||
// devData.setSqlData(null);
|
||||
// }
|
||||
// if (DetectionCodeEnum.SI_1_49.getCode().equals(dictTree.getCode())) {
|
||||
// devData.setSqlData(null);
|
||||
// }
|
||||
// if (DetectionCodeEnum.P2_50.getCode().equals(dictTree.getCode())) {
|
||||
// devData.setSqlData(null);
|
||||
// }
|
||||
} else {
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
detectionServiceImpl.processing(realDataXiList, param, devIdMapComm, sourceIssue, dataRule);
|
||||
});
|
||||
}
|
||||
|
||||
private List<DevData> toList(List<AdNonHarmonicResult> nonHarm, List<AdHarmonicResult> harm, boolean containBaseHarm) {
|
||||
List<DevData> info = new ArrayList<>();
|
||||
// if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
if (CollUtil.isNotEmpty(nonHarm)) {
|
||||
Map<String, List<AdNonHarmonicResult>> noHarmMap = nonHarm.stream()
|
||||
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN)) + "_" + x.getSort()));
|
||||
noHarmMap.forEach((key, value) -> {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0] + "_" + split[1]);
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
for (AdNonHarmonicResult result : value) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(result.getDataType());
|
||||
DictTree dictTree = dictTreeService.getById(result.getAdType());
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(result.getAValue()) ? Double.valueOf(result.getAValue()) : null);
|
||||
listDTO.setB(StrUtil.isNotBlank(result.getBValue()) ? Double.valueOf(result.getBValue()) : null);
|
||||
listDTO.setC(StrUtil.isNotBlank(result.getCValue()) ? Double.valueOf(result.getCValue()) : null);
|
||||
listDTO.setT(StrUtil.isNotBlank(result.getTValue()) ? Double.valueOf(result.getTValue()) : null);
|
||||
sqlDataDTO.setList(listDTO);
|
||||
sqlDataDTOS.add(sqlDataDTO);
|
||||
}
|
||||
data.setSqlData(sqlDataDTOS);
|
||||
info.add(data);
|
||||
});
|
||||
}
|
||||
if (CollUtil.isNotEmpty(harm)) {
|
||||
Map<String, List<AdHarmonicResult>> harmMap = harm.stream()
|
||||
.collect(Collectors.groupingBy(x -> x.getMonitorId() + "_" + x.getTimeId().format(DateTimeFormatter.ofPattern(DatePattern.UTC_SIMPLE_MS_PATTERN))));
|
||||
harmMap.forEach((key, value) -> {
|
||||
List<DevData> collect = info.stream().filter(x -> key.equals(x.getId() + "_" + x.getTime())).collect(Collectors.toList());
|
||||
List<DevData.SqlDataDTO> sqlDataDTOS = new ArrayList<>();
|
||||
DevData.SqlDataDTO sqlDataDTO;
|
||||
List<DevData.SqlDataHarmDTO> sqlDataHarmDTOS = new ArrayList<>();
|
||||
DevData.SqlDataHarmDTO dataHarmDTO;
|
||||
for (AdHarmonicResult harmonicResult : value) {
|
||||
DictTree dictTree = dictTreeService.getById(harmonicResult.getAdType());
|
||||
if (containBaseHarm) {
|
||||
sqlDataDTO = new DevData.SqlDataDTO();
|
||||
sqlDataDTO.setType(harmonicResult.getDataType());
|
||||
if (DetectionCodeEnum.V2_50.getCode().equals(dictTree.getCode())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.U1.getCode());
|
||||
} else if (DetectionCodeEnum.I2_50.getCode().equals(dictTree.getCode())) {
|
||||
sqlDataDTO.setDesc(DetectionCodeEnum.I1.getCode());
|
||||
} else {
|
||||
sqlDataDTO.setDesc(dictTree.getCode());
|
||||
}
|
||||
DevData.SqlDataDTO.ListDTO listDTO = new DevData.SqlDataDTO.ListDTO();
|
||||
listDTO.setA(StrUtil.isNotBlank(harmonicResult.getAValue1()) ? Double.valueOf(harmonicResult.getAValue1()) : null);
|
||||
listDTO.setB(StrUtil.isNotBlank(harmonicResult.getBValue1()) ? Double.valueOf(harmonicResult.getBValue1()) : null);
|
||||
listDTO.setC(StrUtil.isNotBlank(harmonicResult.getCValue1()) ? Double.valueOf(harmonicResult.getCValue1()) : null);
|
||||
sqlDataDTO.setList(listDTO);
|
||||
sqlDataDTOS.add(sqlDataDTO);
|
||||
}
|
||||
|
||||
dataHarmDTO = new DevData.SqlDataHarmDTO();
|
||||
dataHarmDTO.setType(harmonicResult.getDataType());
|
||||
dataHarmDTO.setDesc(dictTree.getCode());
|
||||
dataHarmDTO.setNum(containBaseHarm ? 49 : 50);
|
||||
DevData.SqlDataHarmDTO.ListDTO listHarmDTO = new DevData.SqlDataHarmDTO.ListDTO();
|
||||
listHarmDTO.setA(reflectHarmonicValue("a", harmonicResult, containBaseHarm));
|
||||
listHarmDTO.setB(reflectHarmonicValue("b", harmonicResult, containBaseHarm));
|
||||
listHarmDTO.setC(reflectHarmonicValue("c", harmonicResult, containBaseHarm));
|
||||
dataHarmDTO.setList(listHarmDTO);
|
||||
sqlDataHarmDTOS.add(dataHarmDTO);
|
||||
}
|
||||
if (CollUtil.isNotEmpty(collect)) {
|
||||
collect.get(0).setSqlDataHarm(sqlDataHarmDTOS);
|
||||
} else {
|
||||
String[] split = key.split("_");
|
||||
DevData data = new DevData();
|
||||
data.setTime(split[2]);
|
||||
data.setId(split[0] + "_" + split[1]);
|
||||
data.setSqlData(sqlDataDTOS);
|
||||
data.setSqlDataHarm(sqlDataHarmDTOS);
|
||||
info.add(data);
|
||||
}
|
||||
});
|
||||
|
||||
}
|
||||
// }
|
||||
return info;
|
||||
|
||||
}
|
||||
|
||||
private List<String> reflectHarmonicValue(String phase, AdHarmonicResult adHarmonicResult, boolean notContainBaseHarm) {
|
||||
List<String> info = new ArrayList<>();
|
||||
for (int i = notContainBaseHarm ? 2 : 1; i <= 50; i++) {
|
||||
String fieldName = phase + "Value" + i;
|
||||
try {
|
||||
Field idField = AdHarmonicResult.class.getDeclaredField(fieldName);
|
||||
idField.setAccessible(true);
|
||||
String value = idField.get(adHarmonicResult) + "";
|
||||
info.add(value);
|
||||
} catch (NoSuchFieldException | IllegalAccessException e) {
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
}
|
||||
return info;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,6 +14,9 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.JwtUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.system.auth.pojo.Token;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.log.pojo.enums.LogOperationTypeEnum;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
import com.njcn.gather.system.log.service.ISysLogAuditService;
|
||||
@@ -48,6 +51,7 @@ public class AuthController extends BaseController {
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
private final ISysLogAuditService sysLogAuditService;
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
|
||||
// @RequestMapping("/login")
|
||||
// public HttpResult<Token> login() {
|
||||
@@ -146,4 +150,14 @@ public class AuthController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@ApiOperation("获取当前场景")
|
||||
@GetMapping("/getCurrentScene")
|
||||
public HttpResult<String> getCurrentScene() {
|
||||
String methodDescribe = getMethodDescribe("getCurrentScene");
|
||||
LogUtil.njcnDebug(log, "{},获取当前场景", methodDescribe);
|
||||
String currrentScene= sysTestConfigService.getCurrrentScene();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, currrentScene, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,4 +35,6 @@ public interface ISysTestConfigService extends IService<SysTestConfig> {
|
||||
* @return
|
||||
*/
|
||||
SysTestConfig getOneConfig();
|
||||
|
||||
String getCurrrentScene();
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.system.config.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
@@ -9,6 +10,7 @@ import com.njcn.gather.system.config.pojo.param.SysTestConfigParam;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
@@ -24,6 +26,8 @@ import org.springframework.transaction.annotation.Transactional;
|
||||
@RequiredArgsConstructor
|
||||
public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, SysTestConfig> implements ISysTestConfigService {
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@Override
|
||||
public SysTestConfig getConfig() {
|
||||
return this.getOne(new QueryWrapper<SysTestConfig>().last("LIMIT 1"));
|
||||
@@ -55,4 +59,14 @@ public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, S
|
||||
.eq(SysTestConfig::getState, DataStateEnum.ENABLE.getCode());
|
||||
return this.getBaseMapper().selectJoinOne(SysTestConfig.class, queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getCurrrentScene() {
|
||||
String scene = getOneConfig().getScene();
|
||||
DictData dictData = dictDataService.getDictDataById(scene);
|
||||
if(ObjectUtil.isNotNull(dictData)){
|
||||
return dictData.getValue();
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.gather.system.reg.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2025-03-13
|
||||
*/
|
||||
@Getter
|
||||
public enum RegStatusEnum {
|
||||
UNREGISTERED(0, "未激活"),
|
||||
REGISTERED(1, "已激活"),
|
||||
EXPIRED(2, "已过期");
|
||||
|
||||
private int code;
|
||||
private String message;
|
||||
RegStatusEnum(int code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -12,17 +12,37 @@ import java.util.List;
|
||||
@Data
|
||||
public class SysRegResVO {
|
||||
/**
|
||||
* 注册码
|
||||
* 注册码。如果未激活,则为null
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 注册的模式
|
||||
* 模拟式激活状态。0:未激活;1:已激活;2:已过期
|
||||
*/
|
||||
private List<String> typeList;
|
||||
private int simulateStatus;
|
||||
|
||||
/**
|
||||
* 到期时间
|
||||
* 模拟式激活到期日期。如果未激活,则为null
|
||||
*/
|
||||
private List<String> expireDateList;
|
||||
private String simulateExpireDate;
|
||||
|
||||
/**
|
||||
* 数字式激活状态。0:未激活;1:已激活;2:已过期
|
||||
*/
|
||||
private int digitalStatus;
|
||||
|
||||
/**
|
||||
* 数字式激活到期日期。如果未激活,则为null
|
||||
*/
|
||||
private String digitalExpireDate;
|
||||
|
||||
/**
|
||||
* 比对式激活状态。0:未激活;1:已激活;2:已过期
|
||||
*/
|
||||
private int contrastStatus;
|
||||
|
||||
/**
|
||||
* 比对式激活到期日期。如果未激活,则为null
|
||||
*/
|
||||
private String contrastExpireDate;
|
||||
}
|
||||
|
||||
@@ -8,14 +8,13 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.utils.EncryptionUtil;
|
||||
import com.njcn.common.utils.sm.Sm4Utils;
|
||||
import com.njcn.gather.system.dictionary.pojo.enums.DictDataEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||
import com.njcn.gather.system.reg.mapper.SysRegResMapper;
|
||||
import com.njcn.gather.system.reg.pojo.dto.RegInfoData;
|
||||
import com.njcn.gather.system.reg.pojo.enums.RegResponseEnum;
|
||||
import com.njcn.gather.system.reg.pojo.enums.RegStatusEnum;
|
||||
import com.njcn.gather.system.reg.pojo.param.SysRegResParam;
|
||||
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
|
||||
import com.njcn.gather.system.reg.pojo.vo.SysRegResVO;
|
||||
@@ -35,8 +34,12 @@ import java.security.PrivateKey;
|
||||
import java.security.PublicKey;
|
||||
import java.security.spec.PKCS8EncodedKeySpec;
|
||||
import java.security.spec.X509EncodedKeySpec;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.time.LocalDate;
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -97,23 +100,28 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
if (!mac.equals(regInfoData.getMacAddress())) {
|
||||
throw new BusinessException(RegResponseEnum.MAC_ADDRESS_NOT_MATCH);
|
||||
}
|
||||
|
||||
List<String> expireDateList = regInfoData.getExpireDateList();
|
||||
for (int i = 0; i < regInfoData.getTypeList().size(); i++) {
|
||||
expireDateList.set(i, formatDate(expireDateList.get(i)));
|
||||
}
|
||||
// 比对到期日期
|
||||
String maxExpireDate = regInfoData.getExpireDateList().stream().max((a, b) -> a.compareTo(b)).get();
|
||||
String maxExpireDate = expireDateList.stream().max((a, b) -> a.compareTo(b)).get();
|
||||
if (LocalDate.parse(maxExpireDate).isBefore(LocalDate.now())) {
|
||||
throw new BusinessException(RegResponseEnum.REGISTRATION_CODE_EXPIRED);
|
||||
}
|
||||
|
||||
for (int i = 0; i < regInfoData.getTypeList().size(); i++) {
|
||||
// 忽略过期的
|
||||
if(LocalDate.parse(regInfoData.getExpireDateList().get(i)).isBefore(LocalDate.now())){
|
||||
continue;
|
||||
}
|
||||
// if (isExpire(expireDateList.get(i))) {
|
||||
// continue;
|
||||
// }
|
||||
|
||||
SysRegRes sysRegRes = new SysRegRes();
|
||||
BeanUtil.copyProperties(sysRegResParam, sysRegRes);
|
||||
sysRegRes.setState(DataStateEnum.ENABLE.getCode());
|
||||
sysRegRes.setCode(sysRegResParam.getCode());
|
||||
sysRegRes.setExpireDate(EncryptionUtil.encodeString(1,regInfoData.getExpireDateList().get(i)));
|
||||
sysRegRes.setExpireDate(EncryptionUtil.encodeString(1, formatDate(regInfoData.getExpireDateList().get(i))));
|
||||
|
||||
DictData dictData = dictDataService.getDictDataByCode(regInfoData.getTypeList().get(i));
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
@@ -124,7 +132,7 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
sysRegRes.setStatistics(5);
|
||||
sysRegRes.setFlicker(1);
|
||||
|
||||
if(regInfoData.getTypeList().get(i).equals(DictDataEnum.CONTRAST.getCode())){
|
||||
if (regInfoData.getTypeList().get(i).equals(DictDataEnum.CONTRAST.getCode())) {
|
||||
sysRegRes.setWaveRecord(1);
|
||||
sysRegRes.setRealTime(200);
|
||||
sysRegRes.setStatistics(5);
|
||||
@@ -155,31 +163,87 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
public SysRegResVO listRegRes() {
|
||||
// todo 需要切面检测是否到期,到期则状态设为0
|
||||
SysRegResVO sysRegResVO = new SysRegResVO();
|
||||
List<String> typeList = new ArrayList<>();
|
||||
List<String> expireDateList = new ArrayList<>();
|
||||
List<SysRegRes> regResList = this.lambdaQuery().eq(SysRegRes::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
if(ObjectUtil.isNotEmpty(regResList)){
|
||||
if (ObjectUtil.isNotEmpty(regResList)) {
|
||||
sysRegResVO.setCode(regResList.get(0).getCode());
|
||||
}
|
||||
regResList.forEach(item -> {
|
||||
DictData dictData = dictDataService.getDictDataById(item.getType());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
typeList.add(dictData.getCode());
|
||||
sysRegResVO.setSimulateStatus(RegStatusEnum.UNREGISTERED.getCode());
|
||||
sysRegResVO.setDigitalStatus(RegStatusEnum.UNREGISTERED.getCode());
|
||||
sysRegResVO.setContrastStatus(RegStatusEnum.UNREGISTERED.getCode());
|
||||
for (SysRegRes regRes : regResList) {
|
||||
DictData dictData = dictDataService.getDictDataById(regRes.getType());
|
||||
String s = EncryptionUtil.decoderString(1, regRes.getExpireDate());
|
||||
boolean expire = isExpire(s);
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
if (dictData.getCode().equals(DictDataEnum.SIMULATE.getCode())) {
|
||||
if (expire) {
|
||||
sysRegResVO.setSimulateStatus(RegStatusEnum.EXPIRED.getCode());
|
||||
} else {
|
||||
sysRegResVO.setSimulateStatus(RegStatusEnum.REGISTERED.getCode());
|
||||
}
|
||||
sysRegResVO.setSimulateExpireDate(s);
|
||||
}
|
||||
if (dictData.getCode().equals(DictDataEnum.DIGITAL.getCode())) {
|
||||
if (expire) {
|
||||
sysRegResVO.setDigitalStatus(RegStatusEnum.EXPIRED.getCode());
|
||||
} else {
|
||||
sysRegResVO.setDigitalStatus(RegStatusEnum.REGISTERED.getCode());
|
||||
}
|
||||
sysRegResVO.setDigitalExpireDate(s);
|
||||
}
|
||||
if (dictData.getCode().equals(DictDataEnum.CONTRAST.getCode())) {
|
||||
if (expire) {
|
||||
sysRegResVO.setContrastStatus(RegStatusEnum.EXPIRED.getCode());
|
||||
} else {
|
||||
sysRegResVO.setContrastStatus(RegStatusEnum.REGISTERED.getCode());
|
||||
}
|
||||
sysRegResVO.setContrastExpireDate(s);
|
||||
}
|
||||
} else {
|
||||
throw new BusinessException("字典数据缺失,请联系管理员!");
|
||||
}
|
||||
}
|
||||
expireDateList.add(EncryptionUtil.decoderString(1, item.getExpireDate()));
|
||||
});
|
||||
sysRegResVO.setTypeList(typeList);
|
||||
sysRegResVO.setExpireDateList(expireDateList);
|
||||
}
|
||||
return sysRegResVO;
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化日期 (将日期格式化为yyyy-MM-dd)
|
||||
*
|
||||
* @param date
|
||||
* @return
|
||||
*/
|
||||
private String formatDate(String date) {
|
||||
String[] split = date.split("-");
|
||||
if (split[1].length() == 1) {
|
||||
split[1] = "0" + split[1];
|
||||
}
|
||||
if (split[2].length() == 1) {
|
||||
split[2] = "0" + split[2];
|
||||
}
|
||||
return split[0] + "-" + split[1] + "-" + split[2];
|
||||
}
|
||||
|
||||
/**
|
||||
* 判断是否到期
|
||||
*
|
||||
* @param expireDate 到期日期
|
||||
* @return
|
||||
*/
|
||||
private boolean isExpire(String expireDate) {
|
||||
expireDate = formatDate(expireDate);
|
||||
String today = new SimpleDateFormat("yyyy-MM-dd").format(new Date());
|
||||
if (today.compareTo(expireDate) >= 0) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用hutool工具获取本机mac地址
|
||||
*
|
||||
* @return mac地址
|
||||
*/
|
||||
private static String getMAC() {
|
||||
private String getMAC() {
|
||||
InetAddress inetAddress = null;
|
||||
try {
|
||||
inetAddress = InetAddress.getLocalHost();
|
||||
@@ -196,7 +260,7 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
* @return 密钥对象
|
||||
* @throws Exception
|
||||
*/
|
||||
private static Key parsePemKey(String pem) throws Exception {
|
||||
private Key parsePemKey(String pem) throws Exception {
|
||||
// 去掉 PEM 格式中的头部和尾部
|
||||
String cleanPem = pem
|
||||
.replaceAll("-----BEGIN (.*?)-----", "")
|
||||
@@ -225,7 +289,7 @@ public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes
|
||||
* @param encryptedCode 加密后的注册码
|
||||
* @return
|
||||
*/
|
||||
public static RegInfoData decodeRegistrationCode(String encryptedCode) {
|
||||
private RegInfoData decodeRegistrationCode(String encryptedCode) {
|
||||
try {
|
||||
byte[] encryptedData = Base64.getDecoder().decode(encryptedCode);
|
||||
Key privateKey = parsePemKey(fixedPrivateKeyStr);
|
||||
|
||||
Reference in New Issue
Block a user