导出检测计划
This commit is contained in:
@@ -13,24 +13,24 @@ 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.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanExcel;
|
||||
import com.njcn.gather.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PatternEnum;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
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;
|
||||
@@ -53,6 +53,7 @@ public class AdPlanController extends BaseController {
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
private final IPqDevService pqDevService;
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@@ -122,61 +123,50 @@ public class AdPlanController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载监测计划导入文件模板")
|
||||
public void downloadTemplate() {
|
||||
adPlanService.downloadTemplate();
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出检测计划")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("download");
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
List<AdPlanExcel> data = adPlanService.getExportData(queryParam);
|
||||
ExcelUtil.exportExcel("检测计划导出数据.xlsx", AdPlanExcel.class, data);
|
||||
List<AdPlanExcel.ExportData> data = adPlanService.getExportData(queryParam);
|
||||
ExcelUtil.exportExcel("检测计划导出数据.xlsx", AdPlanExcel.ExportData.class, data);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入检测计划数据")
|
||||
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true)
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "file", value = "检测计划数据文件", required = true),
|
||||
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
|
||||
})
|
||||
public HttpResult<Object> importData(@RequestParam("file") MultipartFile file, @RequestParam("pattern") String pattern, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}, 模式Id为:{}", methodDescribe, file.getOriginalFilename(), pattern);
|
||||
|
||||
try {
|
||||
Workbook workBook = ExcelUtil.getWorkBook(file);
|
||||
int numberOfSheets = workBook.getNumberOfSheets();
|
||||
if (numberOfSheets == 2) {
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
params.setHeadRows(2);
|
||||
params.setNeedVerify(true);
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
|
||||
params.setStartSheetIndex(0);
|
||||
ExcelImportResult<AdPlanExcel> adPlanExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.class, params);
|
||||
try {
|
||||
ExcelImportResult<AdPlanExcel.ImportData> adPlanExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), AdPlanExcel.ImportData.class, params);
|
||||
if (adPlanExcelResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
PoiUtil.exportFileByWorkbook(adPlanExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
} else {
|
||||
List<AdPlanExcel> adPlanExcelList = adPlanExcelResult.getList();
|
||||
List<AdPlanExcel.ImportData> adPlanExcelList = adPlanExcelResult.getList();
|
||||
if (ObjectUtil.isNotEmpty(adPlanExcelList)) {
|
||||
params.setStartSheetIndex(1);
|
||||
String pattern = adPlanExcelList.get(0).getPattern();
|
||||
if (PatternEnum.CONTRAST.getValue().equals(pattern)) {
|
||||
ExcelImportResult<PqDevExcel.ContrastImportData> pqDevExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ContrastImportData.class, params);
|
||||
if (pqDevExcelResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
PoiUtil.exportFileByWorkbook(pqDevExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
} else {
|
||||
adPlanService.importData(adPlanExcelList);
|
||||
pqDevService.importContrastData(pqDevExcelResult.getList());
|
||||
}
|
||||
} else {
|
||||
ExcelImportResult<PqDevExcel.SimulateOrDigitalImportData> pqDevExcelResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.SimulateOrDigitalImportData.class, params);
|
||||
if (pqDevExcelResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
PoiUtil.exportFileByWorkbook(pqDevExcelResult.getFailWorkbook(), "非法检测计划数据.xlsx", response);
|
||||
}
|
||||
}
|
||||
}
|
||||
adPlanService.importData(pattern,adPlanExcelList);
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
|
||||
@@ -2,11 +2,17 @@ package com.njcn.gather.plan.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import cn.afterturn.easypoi.excel.annotation.ExcelCollection;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||
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 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.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -15,40 +21,152 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class AdPlanExcel {
|
||||
@Excel(name = "名称", width = 40, needMerge = true)
|
||||
@Excel(name = "名称", width = 40, needMerge = true, orderNum = "0")
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "模式", width = 20, needMerge = true)
|
||||
@Excel(name = "检测源", width = 40, needMerge = true, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.SOURC_NOT_BLANK)
|
||||
private String source;
|
||||
|
||||
@Excel(name = "数据源", width = 20, needMerge = true, orderNum = "4")
|
||||
@NotBlank(message = DevValidMessage.DATASOURCE_NOT_BLANK)
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "脚本", width = 50, needMerge = true, orderNum = "5")
|
||||
@NotBlank(message = DevValidMessage.SCRIPT_NOT_BLANK)
|
||||
private String scriptId;
|
||||
|
||||
@Excel(name = "误差体系", width = 30, needMerge = true, orderNum = "6")
|
||||
@NotBlank(message = DevValidMessage.ERRORSYS_NOT_BLANK)
|
||||
private String errorSysId;
|
||||
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportData extends AdPlanExcel {
|
||||
@Excel(name = "模式", width = 20, needMerge = true, orderNum = "1")
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "父计划id", width = 25, needMerge = true)
|
||||
@Excel(name = "父计划id", width = 25, needMerge = true, orderNum = "3")
|
||||
private String fatherPlanId;
|
||||
|
||||
@Excel(name = "数据源", width = 20, needMerge = true)
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "脚本", width = 50, needMerge = true)
|
||||
private String scriptId;
|
||||
|
||||
@Excel(name = "误差体系", width = 30, needMerge = true)
|
||||
private String errorSysId;
|
||||
|
||||
@Excel(name = "是否做守时检测", width = 15, replace = {"否_0", "是_1"}, needMerge = true)
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7")
|
||||
private Integer timeCheck;
|
||||
|
||||
@Excel(name = "检测状态", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true)
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成)", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true, orderNum = "8")
|
||||
private Integer testState;
|
||||
|
||||
@Excel(name = "报告生成状态", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true)
|
||||
@Excel(name = "报告生成状态(未生成\\部分生成\\全部生成)", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true, orderNum = "9")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "检测结果", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true)
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true, orderNum = "10")
|
||||
private Integer result;
|
||||
|
||||
@Excel(name = "数据表后缀", width = 20, needMerge = true)
|
||||
@Excel(name = "数据表后缀", width = 20, needMerge = true, orderNum = "11")
|
||||
private Integer code;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备")
|
||||
private List<PqDevExcel.PlanBindDevice> devices;
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "12")
|
||||
private List<AdPlanExcel.BoundExportData> devices;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends AdPlanExcel {
|
||||
@Excel(name = "是否做守时检测(否\\是)", width = 15, replace = {"否_0", "是_1"}, needMerge = true, orderNum = "7")
|
||||
@NotNull(message = DevValidMessage.TIMECHECK_NOT_BLANK)
|
||||
private String timeCheck;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备", orderNum = "13")
|
||||
private List<AdPlanExcel.BoundImportData> devices;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BoundData {
|
||||
@Excel(name = "名称", width = 20)
|
||||
@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")
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备通道数", width = 20, orderNum = "3")
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@Excel(name = "额定电压(V)", width = 15, orderNum = "4")
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@Excel(name = "额定电流(A)", width = 15, orderNum = "5")
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@Excel(name = "设备厂家", width = 20, orderNum = "6")
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "设备序列号", width = 40, orderNum = "8")
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9")
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10")
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
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 = "端口号", 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;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class BoundExportData extends BoundData {
|
||||
@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 = 20, replace = {"否_0", "是_1"}, orderNum = "17", needMerge = true)
|
||||
private Integer factorFlag;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class BoundImportData extends BoundData {
|
||||
@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 = 20, replace = {"否_0", "是_1"}, orderNum = "17", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.FACTOR_FLAG_NOT_BLANK)
|
||||
private String factorFlag;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,12 +57,9 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
List<Map<String, Object>> listByPattern(String pattern);
|
||||
|
||||
/**
|
||||
* 获取检测计划导出时所需的SheetList (包含与之关联的设备信息)
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return SheetList
|
||||
* 下载检测计划模板
|
||||
*/
|
||||
//List<Map<String, Object>> getAdPlanEexportSheetList(AdPlanParam.QueryParam queryParam);
|
||||
void downloadTemplate();
|
||||
|
||||
/**
|
||||
* 获取检测计划导出数据
|
||||
@@ -70,15 +67,14 @@ public interface IAdPlanService extends IService<AdPlan> {
|
||||
* @param queryParam 查询参数
|
||||
* @return 检测计划导出数据
|
||||
*/
|
||||
List<AdPlanExcel> getExportData(AdPlanParam.QueryParam queryParam);
|
||||
List<AdPlanExcel.ExportData> getExportData(AdPlanParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 导入检测计划
|
||||
*
|
||||
* @param patternId 模式Id
|
||||
* @param adPlanExcelList 检测计划Excel列表
|
||||
* @return 导入成功则返回true,否则返回false
|
||||
*/
|
||||
void importData(List<AdPlanExcel> adPlanExcelList);
|
||||
|
||||
void importData(String patternId, List<AdPlanExcel.ImportData> adPlanExcelList);
|
||||
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.device.pojo.enums.*;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.device.source.service.IPqSourceService;
|
||||
import com.njcn.gather.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.plan.pojo.enums.DataSourceEnum;
|
||||
import com.njcn.gather.plan.pojo.param.AdPlanParam;
|
||||
@@ -27,10 +28,12 @@ import com.njcn.gather.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@@ -49,6 +52,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
private final IAdPlanSourceService adPlanSourceService;
|
||||
private final IPqDevService pqDevService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqSourceService pqSourceService;
|
||||
|
||||
@Override
|
||||
public Page<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam) {
|
||||
@@ -84,17 +88,18 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
String planId = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
adPlan.setId(planId);
|
||||
adPlan.setDatasourceId(String.join(StrUtil.COMMA, param.getDatasourceIds()));
|
||||
|
||||
adPlan.setState(DataStateEnum.ENABLE.getCode());
|
||||
// 默认为顶级检测计划
|
||||
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
||||
adPlan.setDatasourceId(String.join(StrUtil.COMMA, param.getDatasourceIds()));
|
||||
adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||
adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
adPlan.setResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
// todo code 生成
|
||||
// 日期生成 MMdd
|
||||
//String dateStr = DateFormatUtils.format(new Date(), "MMdd");
|
||||
adPlan.setCode(this.count() + 1);
|
||||
adPlan.setCode(this.generateCode());
|
||||
|
||||
// 新增检测计划、检测源关联
|
||||
adPlanSourceService.addAdPlanSource(planId, param.getSourceIds());
|
||||
@@ -175,61 +180,100 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
return result;
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public List<Map<String, Object>> getAdPlanEexportSheetList(AdPlanParam.QueryParam queryParam) {
|
||||
// List<AdPlan> adPlans = this.list(this.getQueryWrapper(queryParam));
|
||||
//
|
||||
// List<AdPlanExcel> adPlanExcelList = this.getAdPlanExcelList(adPlans);
|
||||
// Map<String, Object> sheetMap1 = new HashMap<>();
|
||||
// ExportParams exportParams = new ExportParams();
|
||||
// exportParams.setSheetName("检测计划");
|
||||
// sheetMap1.put("title", exportParams);
|
||||
// sheetMap1.put("entity", AdPlanExcel.class);
|
||||
// sheetMap1.put("data", adPlanExcelList);
|
||||
//
|
||||
// List<Map<String, Object>> sheetList = new ArrayList<>();
|
||||
// sheetList.add(sheetMap1);
|
||||
// DictData dictData = dictDataService.getDictDataById(queryParam.getPattern());
|
||||
// if (ObjectUtil.isNotNull(dictData)) {
|
||||
// if (PatternEnum.CONTRAST.getValue().equals(dictData.getCode())) {
|
||||
// sheetList.add(pqDevService.getExportSheetMap(adPlans.stream().map(AdPlan::getId).collect(Collectors.toList()), PqDevExcel.ContrastExportData.class));
|
||||
// } else {
|
||||
// sheetList.add(pqDevService.getExportSheetMap(adPlans.stream().map(AdPlan::getId).collect(Collectors.toList()), PqDevExcel.SimulateOrDigitalExportData.class));
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return sheetList;
|
||||
// }
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
ExcelUtil.exportExcel("检测计划模板.xlsx", AdPlanExcel.ImportData.class, Collections.emptyList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<AdPlanExcel> getExportData(AdPlanParam.QueryParam queryParam) {
|
||||
public List<AdPlanExcel.ExportData> getExportData(AdPlanParam.QueryParam queryParam) {
|
||||
List<AdPlan> planList = this.list(this.getQueryWrapper(queryParam));
|
||||
this.visualize(planList);
|
||||
List<AdPlanExcel> planExcelList = BeanUtil.copyToList(planList, AdPlanExcel.class);
|
||||
List<AdPlanExcel.ExportData> planExcelList = BeanUtil.copyToList(planList, AdPlanExcel.ExportData.class);
|
||||
for (int i = 0; i < planList.size(); i++) {
|
||||
List<PqSource> pqSources = adPlanSourceService.listPqSourceByPlanId(planList.get(i).getId());
|
||||
planExcelList.get(i).setSource(pqSources.stream().map(PqSource::getName).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
|
||||
PqDevParam.QueryParam queryParam1 = new PqDevParam.QueryParam();
|
||||
queryParam1.setPlanId(planList.get(i).getId());
|
||||
// planExcelList.get(i).setDevices(BeanUtil.copyToList(pqDevService.listByPlanId(queryParam1), PqDevExcel.ExportData.class));
|
||||
List<PqDev> pqDevs = pqDevService.listByPlanId(queryParam1);
|
||||
pqDevService.visualize(pqDevs);
|
||||
planExcelList.get(i).setDevices(BeanUtil.copyToList(pqDevs, AdPlanExcel.BoundExportData.class));
|
||||
}
|
||||
return planExcelList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importData(List<AdPlanExcel> adPlanExcelList) {
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void importData(String patternId, List<AdPlanExcel.ImportData> adPlanExcelList) {
|
||||
List<AdPlan> adPlans = BeanUtil.copyToList(adPlanExcelList, AdPlan.class);
|
||||
List<PqDev> devList = new ArrayList<>();
|
||||
|
||||
String patternCode = dictDataService.getDictDataById(patternId).getCode();
|
||||
for (int i = 0; i < adPlans.size(); i++) {
|
||||
|
||||
AdPlanExcel.ImportData adPlanExcel = adPlanExcelList.get(i);
|
||||
String planId = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
adPlans.get(i).setId(planId);
|
||||
adPlans.get(i).setPattern(patternId);
|
||||
|
||||
String source = adPlanExcel.getSource();
|
||||
String[] sourceNames = source.split(StrUtil.COMMA);
|
||||
// 若非比对模式,检测源、数据源有2个以上时,不导入
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && sourceNames.length > 1) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_SOURCE_ERROR);
|
||||
}
|
||||
|
||||
String datasource = adPlanExcel.getDatasourceId();
|
||||
String[] datasourceIds = datasource.split(StrUtil.COMMA);
|
||||
// 若非比对模式,数据源有2个以上时,不导入
|
||||
if (!PatternEnum.CONTRAST.getValue().equals(patternCode) && datasourceIds.length > 1) {
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATASOURCE_ERROR);
|
||||
}
|
||||
|
||||
List<String> sourceIds = pqSourceService.listPqSourceIdByName(sourceNames);
|
||||
adPlanSourceService.addAdPlanSource(planId, sourceIds);
|
||||
|
||||
List<PqDev> pqDevs = adPlanExcel.getDevices().stream()
|
||||
.map(planExcel -> {
|
||||
PqDev dev = new PqDev();
|
||||
BeanUtil.copyProperties(planExcel, dev);
|
||||
dev.setPlanId(planId);
|
||||
dev.setPattern(patternId);
|
||||
return dev;
|
||||
}).collect(Collectors.toList());
|
||||
devList.addAll(pqDevs);
|
||||
}
|
||||
// 逆向可视化
|
||||
this.reverseVisualize(adPlans);
|
||||
this.saveBatch(adPlans);
|
||||
//todo 脚本、误差体系处理
|
||||
|
||||
pqDevService.reverseVisualize(devList);
|
||||
pqDevService.saveBatch(devList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询条件wrapper
|
||||
*
|
||||
* @param queryParam 查询条件
|
||||
* @return
|
||||
*/
|
||||
private Wrapper getQueryWrapper(AdPlanParam.QueryParam queryParam) {
|
||||
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPattern()), "ad_plan.pattern", queryParam.getPattern()).eq(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName()).eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState()).eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState()).eq(ObjectUtil.isNotNull(queryParam.getResult()), "ad_plan.result", queryParam.getResult());
|
||||
}
|
||||
queryWrapper.eq("ad_plan.state", DataStateEnum.ENABLE.getCode()).orderBy(true, true, "Create_Time");
|
||||
return queryWrapper;
|
||||
}
|
||||
|
||||
/**
|
||||
* 可视化
|
||||
*
|
||||
* @param adPlans 检测计划列表
|
||||
* @param planList 检测计划列表
|
||||
*/
|
||||
private void visualize(List<AdPlan> adPlans) {
|
||||
adPlans.forEach(adPlan -> {
|
||||
private void visualize(List<AdPlan> planList) {
|
||||
planList.forEach(adPlan -> {
|
||||
if (StrUtil.isNotBlank(adPlan.getPattern())) {
|
||||
adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName());
|
||||
}
|
||||
@@ -255,43 +299,34 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
/**
|
||||
* 逆向可视化
|
||||
*
|
||||
* @param adPlans 检测计划列表
|
||||
* @param planList 检测计划列表
|
||||
*/
|
||||
private void reverseVisualize(List<AdPlan> adPlans) {
|
||||
adPlans.forEach(adPlan -> {
|
||||
if (StrUtil.isNotBlank(adPlan.getPattern())) {
|
||||
adPlan.setPattern(dictDataService.getDictDataByName(adPlan.getPattern()).getId());
|
||||
}
|
||||
// if (DevConst.FATHER_ID.equals(adPlan.getFatherPlanId())) {
|
||||
// adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
||||
// } else {
|
||||
// adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getId());
|
||||
// }
|
||||
if (StrUtil.isNotBlank(adPlan.getDatasourceId())) {
|
||||
private void reverseVisualize(List<AdPlan> planList) {
|
||||
planList.forEach(adPlan -> {
|
||||
String[] datasourceIds = adPlan.getDatasourceId().split(StrUtil.COMMA);
|
||||
adPlan.setDatasourceId(Arrays.stream(datasourceIds).map(id -> DataSourceEnum.getValueByMsg(id)).collect(Collectors.joining(StrUtil.COMMA)));
|
||||
}
|
||||
// if (StrUtil.isNotBlank(adPlan.getScriptId())) {
|
||||
// adPlan.setScriptId(pqScriptService.getPqScriptById(adPlan.getScriptId()).getName());
|
||||
// }
|
||||
// if (StrUtil.isNotBlank(adPlan.getErrorSysId())) {
|
||||
// adPlan.setErrorSysId(pqErrSysService.getPqErrSysById(adPlan.getErrorSysId()).getName());
|
||||
// }
|
||||
|
||||
adPlan.setScriptId(pqScriptService.getPqScriptByName(adPlan.getScriptId()).getId());
|
||||
|
||||
adPlan.setErrorSysId(pqErrSysService.getPqErrSysByName(adPlan.getErrorSysId()).getId());
|
||||
adPlan.setCode(this.generateCode());
|
||||
|
||||
adPlan.setState(DataStateEnum.ENABLE.getCode());
|
||||
// 默认为顶级检测计划
|
||||
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
||||
adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||
adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
adPlan.setResult(CheckResultEnum.UNCHECKED.getValue());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取查询条件wrapper
|
||||
* 生成code
|
||||
*
|
||||
* @param queryParam 查询条件
|
||||
* @return
|
||||
*/
|
||||
private Wrapper getQueryWrapper(AdPlanParam.QueryParam queryParam) {
|
||||
QueryWrapper<AdPlan> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.eq(StrUtil.isNotBlank(queryParam.getPattern()), "ad_plan.pattern", queryParam.getPattern()).eq(StrUtil.isNotBlank(queryParam.getName()), "ad_plan.name", queryParam.getName()).eq(ObjectUtil.isNotNull(queryParam.getTestState()), "ad_plan.Test_State", queryParam.getTestState()).eq(ObjectUtil.isNotNull(queryParam.getReportState()), "ad_plan.Report_State", queryParam.getReportState()).eq(ObjectUtil.isNotNull(queryParam.getResult()), "ad_plan.result", queryParam.getResult());
|
||||
}
|
||||
queryWrapper.eq("ad_plan.state", DataStateEnum.ENABLE.getCode()).orderBy(true, true, "Create_Time");
|
||||
return queryWrapper;
|
||||
private Integer generateCode() {
|
||||
return this.count() + 1;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -39,6 +39,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -143,6 +144,25 @@ public class PqDevController extends BaseController {
|
||||
pqDevService.downloadTemplate();
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出被检设备数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入被检设备数据")
|
||||
@@ -151,7 +171,7 @@ public class PqDevController extends BaseController {
|
||||
String methodDescribe = getMethodDescribe("importData");
|
||||
LogUtil.njcnDebug(log, "{},上传文件为:{}", methodDescribe, file.getOriginalFilename());
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
params.setHeadRows(2);
|
||||
params.setNeedVerify(true);
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
@@ -173,25 +193,6 @@ public class PqDevController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出被检设备数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listUnbound")
|
||||
@ApiOperation("获取指定模式下所有未绑定的设备")
|
||||
@@ -205,7 +206,7 @@ public class PqDevController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@PostMapping("/listByPlanId")
|
||||
@ApiOperation("根据检测计划id查询出所有已绑定的设备")
|
||||
@ApiOperation("根据查询参数查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqDev>> listByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listByPlanId");
|
||||
|
||||
@@ -146,25 +146,25 @@ public class PqDevParam {
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("检测状态")
|
||||
@Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
|
||||
@Max(value = 3, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
|
||||
private Integer checkState;
|
||||
|
||||
@ApiModelProperty("检测结果")
|
||||
@Min(value = 0, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
|
||||
@Max(value = 2, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
|
||||
private Integer checkResult;
|
||||
|
||||
@ApiModelProperty("报告状态")
|
||||
@Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
@Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
private Integer reportState;
|
||||
|
||||
@ApiModelProperty("归档状态")
|
||||
@Min(value = 0, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
|
||||
private Integer documentState;
|
||||
// @ApiModelProperty("检测状态")
|
||||
// @Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
|
||||
// @Max(value = 3, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
|
||||
// private Integer checkState;
|
||||
//
|
||||
// @ApiModelProperty("检测结果")
|
||||
// @Min(value = 0, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
|
||||
// @Max(value = 2, message = DevValidMessage.CHECK_RESULT_FORMAT_ERROR)
|
||||
// private Integer checkResult;
|
||||
//
|
||||
// @ApiModelProperty("报告状态")
|
||||
// @Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
// @Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
// private Integer reportState;
|
||||
//
|
||||
// @ApiModelProperty("归档状态")
|
||||
// @Min(value = 0, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
|
||||
// @Max(value = 1, message = DevValidMessage.DOCUMENT_STATE_FORMAT_ERROR)
|
||||
// private Integer documentState;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,10 +31,6 @@ public class PqDevExcel implements Serializable {
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备模式", width = 20, orderNum = "1", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "设备类型", width = 20, orderNum = "2", needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
@@ -100,39 +96,50 @@ public class PqDevExcel implements Serializable {
|
||||
@Excel(name = "所属电站名称", width = 20, orderNum = "21", needMerge = true)
|
||||
private String subName;
|
||||
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成\\归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22", needMerge = true)
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 15, replace = {"不符合_0", "符合_1", "未检_2"}, orderNum = "23", needMerge = true)
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(未生成\\已生成\\未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "24", needMerge = true)
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(未归档\\归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "25", needMerge = true)
|
||||
private Integer documentState;
|
||||
|
||||
@Excel(name = "报告路径", width = 20, orderNum = "26", needMerge = true)
|
||||
private String reportPath;
|
||||
|
||||
@Excel(name = "关键信息二维码", width = 20, orderNum = "27", needMerge = true)
|
||||
@Excel(name = "关键信息二维码", width = 20, orderNum = "30", needMerge = true)
|
||||
private String qrCode;
|
||||
|
||||
@Excel(name = "检测次数", width = 15, orderNum = "28", needMerge = true)
|
||||
@Excel(name = "检测次数", width = 15, orderNum = "31", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
private Integer reCheckNum;
|
||||
|
||||
// @Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
// @NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
// private LocalDate createDate;
|
||||
|
||||
@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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,7 +161,7 @@ public class PqDevExcel implements Serializable {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ContrastExportData extends ExportData {
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "29")
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "32")
|
||||
List<PqMonitorExcel.ExportData> monitorList;
|
||||
}
|
||||
|
||||
@@ -170,6 +177,11 @@ public class PqDevExcel implements Serializable {
|
||||
@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;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -177,7 +189,7 @@ public class PqDevExcel implements Serializable {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public class SimulateOrDigitalImportData extends ImportData {
|
||||
public static class SimulateOrDigitalImportData extends ImportData {
|
||||
@Excel(name = "样品编号", width = 40, orderNum = "17", needMerge = true)
|
||||
private String sampleId;
|
||||
|
||||
@@ -192,75 +204,8 @@ public class PqDevExcel implements Serializable {
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ContrastImportData extends ImportData {
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "29")
|
||||
List<PqMonitorExcel.ExportData> monitorList;
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "32")
|
||||
List<PqMonitorExcel.ImportData> monitorList;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class PlanBindDevice {
|
||||
@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 = "1")
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "设备类型", width = 20, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备通道数", width = 20, orderNum = "3")
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@Excel(name = "额定电压(V)", width = 15, orderNum = "4")
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@Excel(name = "额定电流(A)", width = 15, orderNum = "5")
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@Excel(name = "设备厂家", width = 20, orderNum = "6")
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "设备序列号", width = 40, orderNum = "8")
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9")
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10")
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
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 = "端口号", 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", needMerge = true)
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥", width = 30, orderNum = "16", needMerge = true)
|
||||
private String devKey;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -43,6 +43,14 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
boolean updatePqDev(PqDevParam.UpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 删除被检设备信息
|
||||
*
|
||||
* @param param 被检设备信息
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
boolean deletePqDev(PqDevParam.DeleteParam param);
|
||||
|
||||
/**
|
||||
* 批量更新被检设备守时检测结果
|
||||
*
|
||||
@@ -52,14 +60,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
boolean updatePqDevTimeCheckResult(List<String> ids, TimeCheckResultEnum result);
|
||||
|
||||
/**
|
||||
* 删除被检设备信息
|
||||
*
|
||||
* @param param 被检设备信息
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
boolean deletePqDev(PqDevParam.DeleteParam param);
|
||||
|
||||
/**
|
||||
* 获取模拟式||数字式设备导出时所需的数据
|
||||
*
|
||||
@@ -95,30 +95,6 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
void importSimulateAndDigitalData(List<PqDevExcel.SimulateOrDigitalImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 根据检测计划planIds获取被检设备设备导出时所需的SheetMap
|
||||
*
|
||||
* @param planIds
|
||||
* @return SheetMap
|
||||
*/
|
||||
Map<String, Object> getExportSheetMap(List<String> planIds, Class clazz);
|
||||
|
||||
/**
|
||||
* 获取模拟式||数字式设备导出时所需的SheetList
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return SheetList
|
||||
*/
|
||||
List<Map<String, Object>> getSimOrDigitExportSheetList(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 获取比对式设备导出时所需的SheetList (包含与之关联的监控点信息)
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return SheetList
|
||||
*/
|
||||
List<Map<String, Object>> getContrastExportSheetList(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 获取所有未绑定的设备
|
||||
*
|
||||
@@ -167,6 +143,18 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
List<PqDev> listUnchecked();
|
||||
|
||||
/**
|
||||
* 可视化,各种id回显字典值,解码等操作
|
||||
*
|
||||
* @param sourceList
|
||||
*/
|
||||
void visualize(List<PqDev> sourceList);
|
||||
|
||||
/**
|
||||
* 逆向可视化
|
||||
*/
|
||||
void reverseVisualize(List<PqDev> sourceList);
|
||||
|
||||
/**
|
||||
* 获取装置信息和装置下监测点信息
|
||||
*
|
||||
@@ -176,4 +164,5 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
* @Date: 2024/12/12 15:50
|
||||
*/
|
||||
List<PreDetection> getDevInfo(@Param("devIds") List<String> devIds);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package com.njcn.gather.device.device.service.impl;
|
||||
|
||||
import cn.afterturn.easypoi.excel.entity.ExportParams;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
@@ -76,7 +75,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
// 新增时默认设置为未检验、未生成报告、未归档、未出检测结果
|
||||
// 新增时默认设置
|
||||
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());
|
||||
@@ -114,11 +115,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.updateById(pqDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqDevTimeCheckResult(List<String> ids, TimeCheckResultEnum result) {
|
||||
return this.lambdaUpdate().set(PqDev::getTimeCheckResult, result.getValue()).in(PqDev::getId, ids).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqDev(PqDevParam.DeleteParam param) {
|
||||
if (PatternEnum.CONTRAST.getValue().equals(dictDataService.getDictDataById(param.getPattern()).getCode())) {
|
||||
@@ -131,6 +127,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.lambdaUpdate().set(PqDev::getState, DataStateEnum.DELETED.getCode()).in(PqDev::getId, param.getIds()).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqDevTimeCheckResult(List<String> ids, TimeCheckResultEnum result) {
|
||||
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));
|
||||
@@ -169,10 +170,40 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
@Override
|
||||
public void importContrastData(List<PqDevExcel.ContrastImportData> pqDevExcelList) {
|
||||
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
|
||||
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(pqDevList);
|
||||
this.saveBatch(pqDevList);
|
||||
this.reverseVisualize(devList);
|
||||
this.saveBatch(devList);
|
||||
|
||||
pqMonitorService.saveBatch(monitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -183,62 +214,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
this.saveBatch(pqDevList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getExportSheetMap(List<String> planIds, Class clazz) {
|
||||
List<PqDev> devList = new ArrayList<>();
|
||||
if (ObjectUtil.isNotEmpty(planIds)) {
|
||||
devList.addAll(this.lambdaQuery().in(PqDev::getPlanId, planIds).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).orderBy(true, true, PqDev::getCreateTime).list());
|
||||
}
|
||||
this.visualize(devList);
|
||||
|
||||
List<Object> pqDevExcels = BeanUtil.copyToList(devList, clazz);
|
||||
Map<String, Object> sheetMap = new HashMap<>();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setSheetName("被检设备");
|
||||
sheetMap.put("title", exportParams);
|
||||
sheetMap.put("data", pqDevExcels);
|
||||
sheetMap.put("entity", clazz);
|
||||
|
||||
return sheetMap;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getSimOrDigitExportSheetList(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.SimulateOrDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
|
||||
Map<String, Object> sheetMap = new HashMap<>();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setSheetName("被检设备");
|
||||
sheetMap.put("title", exportParams);
|
||||
sheetMap.put("data", pqDevExcels);
|
||||
sheetMap.put("entity", PqDevExcel.SimulateOrDigitalExportData.class);
|
||||
return Collections.singletonList(sheetMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> getContrastExportSheetList(PqDevParam.QueryParam queryParam) {
|
||||
List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
this.visualize(pqDevs);
|
||||
|
||||
List<PqDevExcel.ContrastExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ContrastExportData.class);
|
||||
Map<String, Object> sheetMap1 = new HashMap<>();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setSheetName("被检设备");
|
||||
sheetMap1.put("title", exportParams);
|
||||
sheetMap1.put("data", pqDevExcels);
|
||||
sheetMap1.put("entity", PqDevExcel.ContrastExportData.class);
|
||||
|
||||
Map<String, Object> sheetMap2 = pqMonitorService.getExportSheetMap(pqDevs);
|
||||
|
||||
List<Map<String, Object>> sheetList = new ArrayList<>();
|
||||
sheetList.add(sheetMap1);
|
||||
sheetList.add(sheetMap2);
|
||||
|
||||
return sheetList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listUnbound(String pattern) {
|
||||
List<PqDev> pqDevList = this.lambdaQuery().eq(PqDev::getPattern, pattern).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).isNull(PqDev::getPlanId).list();
|
||||
@@ -314,6 +289,85 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.lambdaQuery().eq(PqDev::getCheckState, CheckStateEnum.UNCHECKED.getValue()).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).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())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setDevType(dictData.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(DeviceUtil.decoderString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.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())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setDevType(dictData.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(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (StrUtil.isNotBlank(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.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
|
||||
*
|
||||
@@ -342,15 +396,6 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return this.baseMapper.selectDevInfo(devIds);
|
||||
}
|
||||
|
||||
// private <T> List<T> getExportData(PqDevParam.QueryParam queryParam, Class<T> clazz) {
|
||||
// List<PqDev> pqDevs = this.list(this.getQueryWrapper(queryParam));
|
||||
// this.visualize(pqDevs);
|
||||
// List<T> pqDevExcels = BeanUtil.copyToList(pqDevs, clazz);
|
||||
//
|
||||
//
|
||||
// return pqDevExcels;
|
||||
// }
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
*
|
||||
@@ -402,79 +447,12 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
return result;
|
||||
}
|
||||
|
||||
//可视化,各种id回显字典值,解码等操作
|
||||
private void visualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
if (ObjectUtil.isNotNull(pqDev.getPattern())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setPattern(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getDevType())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setDevType(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getSeries())) {
|
||||
pqDev.setSeries(DeviceUtil.decoderString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.decoderString(1, pqDev.getDevKey()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//逆向可视化
|
||||
private void reverseVisualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
if (ObjectUtil.isNotNull(pqDev.getPattern())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setPattern(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getDevType())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setDevType(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getSeries())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查设备是否重复
|
||||
*
|
||||
* @param param 设备参数
|
||||
* @param isExcludeSelf 是否排除自己
|
||||
*/
|
||||
private void checkRepeat(PqDevParam param, boolean isExcludeSelf) {
|
||||
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package com.njcn.gather.device.err.service;
|
||||
|
||||
import cn.hutool.core.date.StopWatch;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
@@ -64,6 +65,14 @@ public interface IPqErrSysService extends IService<PqErrSys> {
|
||||
*/
|
||||
List<Map<String, Object>> listAllPqErrSys();
|
||||
|
||||
/**
|
||||
* 根据误差体系名称查询误差体系
|
||||
*
|
||||
* @param name 误差体系名称
|
||||
* @return 误差体系
|
||||
*/
|
||||
PqErrSys getPqErrSysByName(String name);
|
||||
|
||||
/**
|
||||
* 复制误差体系
|
||||
*
|
||||
|
||||
@@ -123,6 +123,11 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqErrSys getPqErrSysByName(String name) {
|
||||
return this.lambdaQuery().eq(PqErrSys::getName, name).eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
/**
|
||||
* 将检测项可视化
|
||||
*
|
||||
|
||||
@@ -17,34 +17,36 @@ import javax.validation.constraints.Pattern;
|
||||
@Data
|
||||
public class PqMonitorExcel {
|
||||
|
||||
@Excel(name = "所属母线", width = 20, orderNum = "3")
|
||||
@Excel(name = "监测点序号", width = 20, orderNum = "1")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MONITOR_NUM_FORMAT_ERROR)
|
||||
private Integer num;
|
||||
|
||||
@Excel(name = "所属母线", width = 20, orderNum = "2")
|
||||
@NotBlank(message = DevValidMessage.BELONG_LINE_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "PT变比", width = 20, orderNum = "4")
|
||||
@Excel(name = "PT变比", width = 20, orderNum = "3")
|
||||
@NotNull(message = DevValidMessage.PT_NOT_NULL)
|
||||
private Float pt;
|
||||
|
||||
@Excel(name = "CT变比", width = 20, orderNum = "5")
|
||||
@Excel(name = "CT变比", width = 20, orderNum = "4")
|
||||
@NotNull(message = DevValidMessage.CT_NOT_NULL)
|
||||
private Float ct;
|
||||
|
||||
@Excel(name = "接线方式", width = 20, orderNum = "6")
|
||||
@Excel(name = "接线方式", width = 20, orderNum = "5")
|
||||
@NotBlank(message = DevValidMessage.WIRING_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.WIRING_TYPE_FORMAT_ERROR)
|
||||
private String ptType;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ImportData extends PqMonitorExcel {
|
||||
@Excel(name = "监测点序号", width = 20)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MONITOR_NUM_FORMAT_ERROR)
|
||||
private Integer num;
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends PqMonitorExcel {
|
||||
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class ExportData extends PqMonitorExcel {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportData extends PqMonitorExcel {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,12 +47,4 @@ public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
* @return 修改成功返回true,否则返回false
|
||||
*/
|
||||
boolean updatePqMonitorByDevId(String devId, List<PqMonitorParam> paramList);
|
||||
|
||||
/**
|
||||
* 根据被检设备获取导出监测点数据时所需的SheetMap
|
||||
*
|
||||
* @param devList 被检设备列表
|
||||
* @return SheetMap
|
||||
*/
|
||||
Map<String, Object> getExportSheetMap(List<PqDev> devList);
|
||||
}
|
||||
|
||||
@@ -61,31 +61,4 @@ public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor
|
||||
return this.saveBatch(pqMonitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getExportSheetMap(List<PqDev> devList) {
|
||||
List<PqMonitorExcel.ExportData> pqMonitorExcels = new ArrayList<>();
|
||||
|
||||
for (int i = 0; i < devList.size(); i++) {
|
||||
List<PqMonitor> pqMonitors = this.listPqMonitorByDevId(devList.get(i).getId());
|
||||
if (ObjectUtil.isNotEmpty(pqMonitors)) {
|
||||
List<PqMonitorExcel.ExportData> exportData = BeanUtil.copyToList(pqMonitors, PqMonitorExcel.ExportData.class);
|
||||
int finalI = i;
|
||||
exportData.forEach(data -> {
|
||||
// 给监测点台账添加设备名称
|
||||
// data.setDevName(devList.get(finalI).getName());
|
||||
data.setPtType(dictDataService.getDictDataById(data.getPtType()).getName());
|
||||
});
|
||||
pqMonitorExcels.addAll(exportData);
|
||||
}
|
||||
}
|
||||
|
||||
Map<String, Object> sheetMap = new HashMap<>();
|
||||
ExportParams exportParams = new ExportParams();
|
||||
exportParams.setSheetName("监测点台账");
|
||||
sheetMap.put("title", exportParams);
|
||||
sheetMap.put("data", pqMonitorExcels);
|
||||
sheetMap.put("entity", PqMonitorExcel.ExportData.class);
|
||||
|
||||
return sheetMap;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -187,4 +187,16 @@ public interface DevValidMessage {
|
||||
String FACTOR_FLAG_FORMAT_ERROR = "是否支持系数校准格式错误";
|
||||
|
||||
String MONITOR_NUM_FORMAT_ERROR = "监测点序号格式错误";
|
||||
|
||||
String SOURC_NOT_BLANK = "检测源不能为空";
|
||||
|
||||
String DATASOURCE_NOT_BLANK = "数据源不能为空";
|
||||
|
||||
String SCRIPT_NOT_BLANK = "检测脚本不能为空";
|
||||
|
||||
String ERRORSYS_NOT_BLANK = "误差体系不能为空";
|
||||
|
||||
String TIMECHECK_NOT_BLANK = "守时检测不能为空";
|
||||
|
||||
String FACTOR_FLAG_NOT_BLANK = "是否支持系数校准不能为空";
|
||||
}
|
||||
|
||||
@@ -9,6 +9,9 @@ import lombok.Getter;
|
||||
@Getter
|
||||
public enum CommonEnum {
|
||||
FATHER_ID("0", "无"),
|
||||
|
||||
NO("0", "否"),
|
||||
YES("1", "是"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
|
||||
@@ -17,7 +17,8 @@ public enum DevResponseEnum {
|
||||
HAS_NOT_UNCHECKED_DEVICE("A001009", "设备在检测中或已被检测过,请勿解除绑定"),
|
||||
IMPORT_PLAN_DATA_FAIL("A001010", "导入的检测计划为空"),
|
||||
IMPORT_DATA_FORMAT_FAIL("A001011", "导入数据格式错误"),
|
||||
;
|
||||
IMPORT_SOURCE_ERROR("A001012","当前模式下一个检测计划只能有一个检测源" ),
|
||||
IMPORT_DATASOURCE_ERROR("A001013","当前模式下一个检测计划只能有一个数据源" );
|
||||
|
||||
private final String message;
|
||||
private final String code;
|
||||
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-14
|
||||
*/
|
||||
@Getter
|
||||
public enum FactorCheckResultEnum {
|
||||
NOT_QUALIFY(0, "不合格"),
|
||||
QUALIFY(1, "合格"),
|
||||
UNKNOWN(2, "/");
|
||||
|
||||
private final Integer value;
|
||||
private final String msg;
|
||||
|
||||
FactorCheckResultEnum(Integer value, String msg) {
|
||||
this.value = value;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static String getMsgByValue(Integer value) {
|
||||
for (FactorCheckResultEnum e : FactorCheckResultEnum.values()) {
|
||||
if (e.getValue().equals(value)) {
|
||||
return e.getMsg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-14
|
||||
*/
|
||||
@Getter
|
||||
public enum TimeCheckResultEnum {
|
||||
NOT_QUALIFY(0, "不合格"),
|
||||
QUALIFY(1, "合格"),
|
||||
UNKNOWN(2, "/");
|
||||
|
||||
private final Integer value;
|
||||
private final String msg;
|
||||
|
||||
TimeCheckResultEnum(Integer value, String msg) {
|
||||
this.value = value;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
public static String getMsgByValue(Integer value) {
|
||||
for (TimeCheckResultEnum e : TimeCheckResultEnum.values()) {
|
||||
if (e.getValue().equals(value)) {
|
||||
return e.getMsg();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -4,11 +4,9 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.zip.ZipFile;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -58,6 +56,7 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
|
||||
/**
|
||||
* 将脚本升级为模板
|
||||
*
|
||||
* @param id 脚本id
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
@@ -70,4 +69,12 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
* @return 检测脚本列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllPqScript(String patternId);
|
||||
|
||||
/**
|
||||
* 根据脚本名称查询脚本
|
||||
*
|
||||
* @param name 脚本名称
|
||||
* @return 脚本列表
|
||||
*/
|
||||
PqScript getPqScriptByName(String name);
|
||||
}
|
||||
|
||||
@@ -101,4 +101,9 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqScript getPqScriptByName(String name) {
|
||||
return this.lambdaQuery().eq(PqScript::getName, name).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,12 +117,12 @@ public class PqSourceController extends BaseController {
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getSourceParam")
|
||||
@ApiOperation("按照检测源ID、源参数Type、获取源参数")
|
||||
@ApiOperation("按照检测源ID获取源参数")
|
||||
@ApiImplicitParam(name = "pqSourceId", value = "检测源ID", required = true)
|
||||
public HttpResult<List<SourceParam>> getSourceParam(@RequestParam("pqSourceId") String pqSourceId) {
|
||||
public HttpResult<List<SourceParam>> getSourceParam(@RequestParam("sourceId") String sourceId) {
|
||||
String methodDescribe = getMethodDescribe("getParam");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, pqSourceId);
|
||||
List<SourceParam> result = pqSourceService.getSourceParam(pqSourceId);
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, sourceId);
|
||||
List<SourceParam> result = pqSourceService.getSourceParam(sourceId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,8 +66,16 @@ public interface IPqSourceService extends IService<PqSource> {
|
||||
/**
|
||||
* 获取指定检测源的指定参数
|
||||
*
|
||||
* @param pqSourceId 检测源Id
|
||||
* @param sourceId 检测源Id
|
||||
* @return 源参数
|
||||
*/
|
||||
List<SourceParam> getSourceParam(String pqSourceId);
|
||||
List<SourceParam> getSourceParam(String sourceId);
|
||||
|
||||
/**
|
||||
* 根据名称获取检测源Id列表
|
||||
*
|
||||
* @param sourceNames 检测源名称列表
|
||||
* @return
|
||||
*/
|
||||
List<String> listPqSourceIdByName(String[] sourceNames);
|
||||
}
|
||||
|
||||
@@ -95,8 +95,8 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SourceParam> getSourceParam(String pqSourceId) {
|
||||
PqSource pqSource = this.lambdaQuery().eq(PqSource::getId, pqSourceId).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
public List<SourceParam> getSourceParam(String sourceId) {
|
||||
PqSource pqSource = this.lambdaQuery().eq(PqSource::getId, sourceId).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (ObjectUtil.isNotNull(pqSource)) {
|
||||
String parameter = pqSource.getParameter();
|
||||
if (StrUtil.isNotBlank(parameter)) {
|
||||
@@ -111,6 +111,11 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> listPqSourceIdByName(String[] sourceNames) {
|
||||
return this.lambdaQuery().in(PqSource::getName, sourceNames).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).list().stream().map(PqSource::getId).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<SourceParam> getChildren(SourceParam current, List<SourceParam> list) {
|
||||
return list.stream()
|
||||
.filter(p -> p.getPId().equals(current.getId()))
|
||||
|
||||
Reference in New Issue
Block a user