This commit is contained in:
caozehui
2024-12-05 16:11:49 +08:00
parent f287498659
commit 176a43d865
14 changed files with 232 additions and 71 deletions

View File

@@ -123,7 +123,7 @@ public class PqDevController extends BaseController {
params.setStartSheetIndex(0); params.setStartSheetIndex(0);
params.setSheetNum(1); params.setSheetNum(1);
try { try {
ExcelImportResult<PqDevExcel.ImportData> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ImportData.class, params); ExcelImportResult<PqDevExcel.ContrastImportData> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ContrastImportData.class, params);
//如果存在非法数据,将不合格的数据导出 //如果存在非法数据,将不合格的数据导出
if (excelImportResult.isVerifyFail()) { if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入 // 此处前端要做特殊处理,具体可以参考技术监督的数据导入
@@ -131,7 +131,7 @@ public class PqDevController extends BaseController {
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response); PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
} else { } else {
//批量录入数据 //批量录入数据
List<PqDevExcel.ImportData> list = excelImportResult.getList(); List<PqDevExcel.ContrastImportData> list = excelImportResult.getList();
pqDevService.importPqDevData(list); pqDevService.importPqDevData(list);
} }
} catch (Exception e) { } catch (Exception e) {

View File

@@ -47,17 +47,17 @@ public class PqDevParam {
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL) @NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr; private Float devCurr;
@ApiModelProperty(value = "生产厂家,字典表", required = true) @ApiModelProperty(value = "设备厂家,字典表", required = true)
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK) @NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.MANUFACTURER_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.MANUFACTURER_FORMAT_ERROR)
private String manufacturer; private String manufacturer;
@ApiModelProperty(value = "生产日期", required = true) @ApiModelProperty(value = "出厂日期", required = true)
@NotBlank(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL) @NotBlank(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR) @DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate; private String createDate;
@ApiModelProperty(value = "出厂编", required = true) @ApiModelProperty(value = "设备序列", required = true)
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK) @NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
private String createId; private String createId;
@@ -164,7 +164,7 @@ public class PqDevParam {
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR) @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
private String pattern; private String pattern;
@ApiModelProperty("生产厂家") @ApiModelProperty("设备厂家")
private String manufacturer; private String manufacturer;
} }

View File

@@ -61,12 +61,12 @@ public class PqDev extends BaseEntity implements Serializable {
private Float devCurr; private Float devCurr;
/** /**
* 生产厂家,字典表 * 设备厂家,字典表
*/ */
private String manufacturer; private String manufacturer;
/** /**
* 生产日期 * 出厂日期
*/ */
@JsonFormat(pattern = "yyyy-MM-dd") @JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class) @JsonDeserialize(using = LocalDateDeserializer.class)
@@ -74,7 +74,7 @@ public class PqDev extends BaseEntity implements Serializable {
private LocalDate createDate; private LocalDate createDate;
/** /**
* 出厂编 * 设备序列
*/ */
private String createId; private String createId;

View File

@@ -28,132 +28,160 @@ public class PqDevExcel implements Serializable {
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR) @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
private String name; private String name;
@Excel(name = "设备模式", width = 20,orderNum = "1") @Excel(name = "设备模式", width = 20, orderNum = "1")
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK) @NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
private String pattern; private String pattern;
@Excel(name = "设备类型", width = 20,orderNum = "2") @Excel(name = "设备类型", width = 20, orderNum = "2")
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK) @NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
private String devType; private String devType;
@Excel(name = "设备通道数", width = 20,orderNum = "3") @Excel(name = "设备通道数", width = 20, orderNum = "3")
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL) @NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
private Integer devChns; private Integer devChns;
@Excel(name = "额定电压V", width = 15,orderNum = "4") @Excel(name = "额定电压V", width = 15, orderNum = "4")
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL) @NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt; private Float devVolt;
@Excel(name = "额定电流A", width = 15,orderNum = "5") @Excel(name = "额定电流A", width = 15, orderNum = "5")
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL) @NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr; private Float devCurr;
@Excel(name = "生产厂家", width = 20,orderNum = "6") @Excel(name = "设备厂家", width = 20, orderNum = "6")
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK) @NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer; private String manufacturer;
@Excel(name = "出厂编", width = 40,orderNum = "8") @Excel(name = "设备序列", width = 40, orderNum = "8")
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK) @NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
private String createId; private String createId;
@Excel(name = "固件版本", width = 15,orderNum = "9") @Excel(name = "固件版本", width = 15, orderNum = "9")
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK) @NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion; private String hardwareVersion;
@Excel(name = "软件版本", width = 15,orderNum = "10") @Excel(name = "软件版本", width = 15, orderNum = "10")
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK) @NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion; private String softwareVersion;
@Excel(name = "通讯协议", width = 15,orderNum = "11") @Excel(name = "通讯协议", width = 15, orderNum = "11")
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK) @NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
private String protocol; private String protocol;
@Excel(name = "IP地址", width = 20,orderNum = "12") @Excel(name = "IP地址", width = 20, orderNum = "12")
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK) @NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR) @Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR)
private String ip; private String ip;
@Excel(name = "端口号",orderNum = "13") @Excel(name = "端口号", orderNum = "13")
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL) @NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR) @Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR)
private Integer port; private Integer port;
@Excel(name = "是否为加密版本(1是/0", width = 20, replace = {"是_1", "否_0"},orderNum = "14") @Excel(name = "是否为加密版本0/1", width = 20, replace = {"否_0", "是_1"}, orderNum = "14")
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL) @NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryptionFlag; private Integer encryptionFlag;
@Excel(name = "识别码(未加密)", width = 30,orderNum = "15") @Excel(name = "识别码", width = 30, orderNum = "15")
private String series; private String series;
@Excel(name = "秘钥(未加密)", width = 30,orderNum = "16") @Excel(name = "秘钥", width = 30, orderNum = "16")
private String devKey; private String devKey;
@Excel(name = "样品编号", width = 40,orderNum = "17") @Excel(name = "所属地市名称", width = 20, orderNum = "19")
private String sampleId;
@Excel(name = "所属地市名称", width = 20,orderNum = "19")
private String cityName; private String cityName;
@Excel(name = "所属供电公司名称", width = 20,orderNum = "20") @Excel(name = "所属供电公司名称", width = 20, orderNum = "20")
private String gdName; private String gdName;
@Excel(name = "所属电站名称", width = 20,orderNum = "21") @Excel(name = "所属电站名称", width = 20, orderNum = "21")
private String subName; private String subName;
@Excel(name = "检测状态", width = 15,orderNum = "22") @Excel(name = "报告路径", width = 20, orderNum = "26")
private Integer checkState;
@Excel(name = "报告路径", width = 20,orderNum = "26")
private String reportPath; private String reportPath;
@Excel(name = "关键信息二维码", width = 20,orderNum = "27") @Excel(name = "关键信息二维码", width = 20, orderNum = "27")
private String qrCode; private String qrCode;
@Excel(name = "复检次数", width = 15,orderNum = "28") @Excel(name = "复检次数", width = 15, orderNum = "28")
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL) @NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
private Integer reCheckNum; private Integer reCheckNum;
/**
* 模拟式和比对式设备数据
*/
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class ExportData extends PqDevExcel { public static class SimulateAndDigitalExportData extends PqDevExcel {
@Excel(name = "生产日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd",orderNum = "7") @Excel(name = "出厂日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "7")
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL) @NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
private LocalDate createDate; private LocalDate createDate;
@Excel(name = "送样日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd",orderNum = "18") @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; private LocalDate arrivedDate;
@Excel(name = "检测结果1:合格/0:不合格", width = 15, replace = {"合格_1", "不合格_0","_null"},orderNum = "23") @Excel(name = "检测状态0:未检/1:检测中/2:检测完成/3:归档", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3", "_null"}, orderNum = "22")
private Integer checkState;
@Excel(name = "检测结果0:不合格/1:合格)", width = 15, replace = {"不合格_0", "合格_1", "_null"}, orderNum = "23")
private Integer checkResult; private Integer checkResult;
@Excel(name = "报告状态(1生成/0:未生成)", width = 15, replace = {"生成_1", "生成_0","_null"},orderNum = "24") @Excel(name = "报告状态0:未生成/1生成)", width = 15, replace = {"生成_0", "生成_1", "_null"}, orderNum = "24")
private Integer reportState; private Integer reportState;
@Excel(name = "归档状态(1归档/0:未归档)", width = 15, replace = {"归档_1", "归档_0","_null"},orderNum = "25") @Excel(name = "归档状态0:未归档/1归档)", width = 15, replace = {"归档_0", "归档_1", "_null"}, orderNum = "25")
private Integer documentState; private Integer documentState;
} }
/**
* 比对式设备导出数据
*/
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
public static class ImportData extends PqDevExcel { public static class ContrastExportData extends PqDevExcel {
@Excel(name = "出厂日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "7")
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
private LocalDate createDate;
@Excel(name = "生产日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd",orderNum = "7") @Excel(name = "检测状态0:未检/1:检测中/2:检测完成/3:归档", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3", "_null"}, orderNum = "22")
private Integer checkState;
@Excel(name = "检测结果0:不合格/1:合格)", width = 15, replace = {"不合格_0", "合格_1", "_null"}, orderNum = "23")
private Integer checkResult;
@Excel(name = "报告状态0:未生成/1生成", width = 15, replace = {"未生成_0", "生成_1", "_null"}, orderNum = "24")
private Integer reportState;
@Excel(name = "归档状态0:未归档/1归档", width = 15, replace = {"未归档_0", "归档_1", "_null"}, orderNum = "25")
private Integer documentState;
}
/**
* 对比式设备导入数据
*/
@Data
@EqualsAndHashCode(callSuper = true)
public static class ContrastImportData extends PqDevExcel {
@Excel(name = "出厂日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd", orderNum = "7")
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL) @NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
@DateTimeStrValid(message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR) @DateTimeStrValid(message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate; private String createDate;
@Excel(name = "送样日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd",orderNum = "18") @Excel(name = "检测状态0:未检/1:检测中/2:检测完成/3:归档", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22")
@DateTimeStrValid(message = DeviceValidMessage.ARRIVE_DATE_FORMAT_ERROR) private Integer checkState;
private String arrivedDate;
@Excel(name = "检测结果(1:合格/0:不合格)", width = 15, replace = {"合格_1", "合格_0"},orderNum = "23") @Excel(name = "检测结果0:不合格/1:合格)", width = 15, replace = {"合格_0", "合格_1"}, orderNum = "23")
private Integer checkResult; private Integer checkResult;
@Excel(name = "报告状态(1生成/0:未生成)", width = 15, replace = {"生成_1", "生成_0"},orderNum = "24") @Excel(name = "报告状态0:未生成/1生成)", width = 15, replace = {"生成_0", "生成_1"}, orderNum = "24")
private Integer reportState; private Integer reportState;
@Excel(name = "归档状态(1归档/0:未归档)", width = 15, replace = {"归档_1", "归档_0"},orderNum = "25") @Excel(name = "归档状态0:未归档/1归档)", width = 15, replace = {"归档_0", "归档_1"}, orderNum = "25")
private Integer documentState; private Integer documentState;
} }
} }

View File

@@ -56,7 +56,7 @@ public interface IPqDevService extends IService<PqDev> {
* *
* @param sgEventExcels 批量导入的数据 * @param sgEventExcels 批量导入的数据
*/ */
void importPqDevData(List<PqDevExcel.ImportData> sgEventExcels); void importPqDevData(List<PqDevExcel.ContrastImportData> sgEventExcels);
/** /**
* 导出被检设备信息 * 导出被检设备信息

View File

@@ -15,6 +15,7 @@ import com.njcn.gather.device.device.pojo.po.PqDev;
import com.njcn.gather.device.device.pojo.vo.PqDevExcel; import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
import com.njcn.gather.device.device.service.IPqDevService; import com.njcn.gather.device.device.service.IPqDevService;
import com.njcn.gather.device.device.util.DeviceUtil; import com.njcn.gather.device.device.util.DeviceUtil;
import com.njcn.gather.device.pojo.constant.DevConst;
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum; import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService; import com.njcn.gather.system.dictionary.service.IDictDataService;
@@ -76,6 +77,10 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
public boolean addPqDev(PqDevParam pqDevParam) { public boolean addPqDev(PqDevParam pqDevParam) {
PqDev pqDev = new PqDev(); PqDev pqDev = new PqDev();
BeanUtil.copyProperties(pqDevParam, pqDev); BeanUtil.copyProperties(pqDevParam, pqDev);
// 新增时默认设置为未检验、未生成报告、未归档
pqDev.setCheckState(DevConst.CHECK_STATE_UNCHECKED);
pqDev.setReportState(DevConst.REPORT_STATE_UNREPORTED);
pqDev.setDocumentState(DevConst.DOCUMENT_STATE_UNDOCUMENTED);
if (pqDevParam.getEncryptionFlag() == 1) { if (pqDevParam.getEncryptionFlag() == 1) {
if (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) { if (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) {
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries())); pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
@@ -110,11 +115,11 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override @Override
public void downloadTemplate() { public void downloadTemplate() {
ExcelUtil.exportExcel("被检设备模板.xlsx", "被检设备", PqDevExcel.ExportData.class, new ArrayList<>()); ExcelUtil.exportExcel("比对式-被检设备模板.xlsx", "被检设备", PqDevExcel.ContrastImportData.class, new ArrayList<>());
} }
@Override @Override
public void importPqDevData(List<PqDevExcel.ImportData> pqDevExcelList) { public void importPqDevData(List<PqDevExcel.ContrastImportData> pqDevExcelList) {
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class); List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
//逆向可视化 //逆向可视化
this.reverseVisualize(pqDevList); this.reverseVisualize(pqDevList);
@@ -143,8 +148,16 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode()); queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
List<PqDev> pqDevs = this.list(queryWrapper); List<PqDev> pqDevs = this.list(queryWrapper);
this.visualize(pqDevs); this.visualize(pqDevs);
List<PqDevExcel.ExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ExportData.class); DictData dictData = dictDataService.getDictDataById(queryParam.getPattern());
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.ExportData.class, pqDevExcels); if (ObjectUtil.isNotNull(dictData)) {
if (DevConst.PATTERN_CONTRAST.equals(dictData.getCode())) {
List<PqDevExcel.ContrastExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ContrastExportData.class);
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.ContrastExportData.class, pqDevExcels);
} else {
List<PqDevExcel.SimulateAndDigitalExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.SimulateAndDigitalExportData.class);
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.SimulateAndDigitalExportData.class, pqDevExcels);
}
}
} }
@Override @Override

View File

@@ -6,6 +6,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.device.err.mapper.PqErrSysMapper; import com.njcn.gather.device.err.mapper.PqErrSysMapper;
import com.njcn.gather.device.err.pojo.param.PqErrSysParam; import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
import com.njcn.gather.device.err.pojo.po.PqErrSys; import com.njcn.gather.device.err.pojo.po.PqErrSys;
@@ -13,7 +14,10 @@ import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO; import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
import com.njcn.gather.device.err.service.IPqErrSysDtlsService; import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
import com.njcn.gather.device.err.service.IPqErrSysService; import com.njcn.gather.device.err.service.IPqErrSysService;
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictTree; import com.njcn.gather.system.dictionary.pojo.po.DictTree;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.dictionary.service.IDictTreeService; import com.njcn.gather.system.dictionary.service.IDictTreeService;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
@@ -36,6 +40,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
private final IPqErrSysDtlsService pqErrSysDtlsService; private final IPqErrSysDtlsService pqErrSysDtlsService;
private final IDictTreeService dictTreeService; private final IDictTreeService dictTreeService;
private final IDictDataService dictDataService;
@Override @Override
public Page<PqErrSys> listPqErrSys(PqErrSysParam.QueryParam param) { public Page<PqErrSys> listPqErrSys(PqErrSysParam.QueryParam param) {
@@ -62,6 +67,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
BeanUtils.copyProperties(param, pqErrSys); BeanUtils.copyProperties(param, pqErrSys);
String id = UUID.randomUUID().toString().replaceAll("-", ""); String id = UUID.randomUUID().toString().replaceAll("-", "");
pqErrSys.setId(id); pqErrSys.setId(id);
pqErrSys.setName(generateErrSysName(param));
pqErrSys.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1)); pqErrSys.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
pqErrSys.setState(DataStateEnum.ENABLE.getCode()); pqErrSys.setState(DataStateEnum.ENABLE.getCode());
boolean result1 = this.save(pqErrSys); boolean result1 = this.save(pqErrSys);
@@ -73,6 +79,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) { public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
PqErrSys pqErrSys = new PqErrSys(); PqErrSys pqErrSys = new PqErrSys();
BeanUtils.copyProperties(param, pqErrSys); BeanUtils.copyProperties(param, pqErrSys);
pqErrSys.setName(generateErrSysName(param));
pqErrSys.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1)); pqErrSys.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
boolean result1 = this.updateById(pqErrSys); boolean result1 = this.updateById(pqErrSys);
boolean result2 = pqErrSysDtlsService.updatePqErrSysDtls(param.getId(), param.getPqErrSysDtlsList()); boolean result2 = pqErrSysDtlsService.updatePqErrSysDtls(param.getId(), param.getPqErrSysDtlsList());
@@ -120,9 +127,9 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
if (pids.length == 3) { if (pids.length == 3) {
temp.setCol2(dictTreeService.queryById(pids[2]).getName()); temp.setCol2(dictTreeService.queryById(pids[2]).getName());
} }
if (pids.length == 2) { // if (pids.length == 2) {
temp.setCol2(dictTreeService.queryById(pids[1]).getName()); // temp.setCol2(dictTreeService.queryById(pids[1]).getName());
} // }
} }
list.forEach(pqErrSysDtls -> { list.forEach(pqErrSysDtls -> {
@@ -142,6 +149,19 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
} }
} }
/**
* 生成误差体系名称(标准号+年份+设备等级)
*
* @return 误差体系名称
*/
private String generateErrSysName(PqErrSysParam param) {
DictData devLevelDictData = dictDataService.getDictDataById(param.getDevLevel());
if (ObjectUtil.isNotNull(devLevelDictData)) {
return param.getStandardName() + "-" + param.getStandardTime() + "-" + devLevelDictData.getName();
}
throw new BusinessException(DeviceResponseEnum.PQ_ERRSYS_GEN_NAME_ERROR);
}
// @Override // @Override
// public boolean copyPqErrSys(String id) { // public boolean copyPqErrSys(String id) {
// PqErrSys pqErrSys = this.getPqErrSysById(id); // PqErrSys pqErrSys = this.getPqErrSysById(id);

View File

@@ -0,0 +1,63 @@
package com.njcn.gather.device.pojo.constant;
/**
* @author caozehui
* @data 2024-12-04
*/
public interface DevConst {
String PATTERN_SIMULATE = "Simulate";
String PATTERN_DIGITAL = "Digital";
String PATTERN_CONTRAST = "Contrast";
/**
* 未检测
*/
Integer CHECK_STATE_UNCHECKED = 0;
/**
* 检测中
*/
Integer CHECK_STATE_CHECKING = 1;
/**
* 检测完成
*/
Integer CHECK_STATE_CHECKED = 2;
/**
* 归档
*/
Integer CHECK_STATE_DOCUMENTED = 3;
/**
* 未生成报告
*/
Integer REPORT_STATE_UNREPORTED = 0;
/**
* 已生成报告
*/
Integer REPORT_STATE_CHECKING = 1;
/**
* 未归档
*/
Integer DOCUMENT_STATE_UNDOCUMENTED = 0;
/**
* 归档
*/
Integer DOCUMENT_STATE_DOCUMENTED = 1;
/**
* 不合格
*/
Integer CHECK_RESULT_NOT_PASS = 0;
/**
* 合格
*/
Integer CHECK_RESULT_PASS = 1;
}

View File

@@ -26,11 +26,11 @@ public interface DeviceValidMessage {
String DEV_CURR_NOT_NULL = "额定电流不能为空请检查devCurr参数"; String DEV_CURR_NOT_NULL = "额定电流不能为空请检查devCurr参数";
String MANUFACTURER_NOT_BLANK = "生产厂家不能为空请检查manufacturer参数"; String MANUFACTURER_NOT_BLANK = "设备厂家不能为空请检查manufacturer参数";
String CREATEDATETIME_NOT_NULL = "生产日期不能为空请检查producedDate参数"; String CREATEDATETIME_NOT_NULL = "出厂日期不能为空请检查producedDate参数";
String CREATEDATETIME_FORMAT_ERROR = "生产日期格式错误请检查createDateTime参数"; String CREATEDATETIME_FORMAT_ERROR = "出厂日期格式错误请检查createDateTime参数";
String FACTORYNO_NOT_BLANK = "出厂编号不能为空请检查factoryNo参数"; String FACTORYNO_NOT_BLANK = "出厂编号不能为空请检查factoryNo参数";
@@ -66,7 +66,7 @@ public interface DeviceValidMessage {
String DEV_CHNS_RANGE_ERROR = "设备通道系数错误请检查devChns参数"; String DEV_CHNS_RANGE_ERROR = "设备通道系数错误请检查devChns参数";
String MANUFACTURER_FORMAT_ERROR = "生产厂家格式错误请检查manufacturer参数"; String MANUFACTURER_FORMAT_ERROR = "设备厂家格式错误请检查manufacturer参数";
String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误请检查protocol参数"; String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误请检查protocol参数";

View File

@@ -7,7 +7,9 @@ public enum DeviceResponseEnum {
//NAME_REPEAT("A001001", "名称重复"), //NAME_REPEAT("A001001", "名称重复"),
IMPORT_DATA_FAIL("A001002", "导入数据失败"), IMPORT_DATA_FAIL("A001002", "导入数据失败"),
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "加密设备的序列号和设备密钥不能为空"); SERIES_AND_DEVKEY_NOT_BLANK("A001003", "加密设备的序列号和设备密钥不能为空"),
PQ_SOURCE_GEN_NAME_ERROR("A001004", "检测源生成名称出错"),
PQ_ERRSYS_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),;
private final String code; private final String code;

View File

@@ -20,10 +20,10 @@ public class PqSourceParam {
/** /**
* 检测源名称(检测源类型 + 设备类型 + 数字自动生成) * 检测源名称(检测源类型 + 设备类型 + 数字自动生成)
*/ */
@ApiModelProperty(value = "检测源名称", required = true) // @ApiModelProperty(value = "检测源名称", required = true)
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK) // @NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.PQ_SOURCE_NAME, message = DeviceValidMessage.PQ_SOURCE_NAME_FORMAT_ERROR) // @Pattern(regexp = PatternRegex.PQ_SOURCE_NAME, message = DeviceValidMessage.PQ_SOURCE_NAME_FORMAT_ERROR)
private String name; // private String name;
/** /**
* 检测模式,字典表 * 检测模式,字典表

View File

@@ -7,10 +7,14 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.enums.common.DataStateEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
import com.njcn.gather.device.source.mapper.PqSourceMapper; import com.njcn.gather.device.source.mapper.PqSourceMapper;
import com.njcn.gather.device.source.pojo.param.PqSourceParam; import com.njcn.gather.device.source.pojo.param.PqSourceParam;
import com.njcn.gather.device.source.pojo.po.PqSource; import com.njcn.gather.device.source.pojo.po.PqSource;
import com.njcn.gather.device.source.service.IPqSourceService; import com.njcn.gather.device.source.service.IPqSourceService;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@@ -27,6 +31,8 @@ import java.util.List;
@RequiredArgsConstructor @RequiredArgsConstructor
public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> implements IPqSourceService { public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> implements IPqSourceService {
private final IDictDataService dictDataService;
@Override @Override
public Page<PqSource> listPqSource(PqSourceParam.QueryParam param) { public Page<PqSource> listPqSource(PqSourceParam.QueryParam param) {
QueryWrapper<PqSource> queryWrapper = new QueryWrapper<>(); QueryWrapper<PqSource> queryWrapper = new QueryWrapper<>();
@@ -50,6 +56,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
public boolean addPqSource(PqSourceParam param) { public boolean addPqSource(PqSourceParam param) {
PqSource pqSource = new PqSource(); PqSource pqSource = new PqSource();
BeanUtil.copyProperties(param, pqSource); BeanUtil.copyProperties(param, pqSource);
pqSource.setName(this.generatePqSourceName(param, true));
pqSource.setParameter(StrUtil.isBlank(pqSource.getParameter()) ? null : pqSource.getParameter()); pqSource.setParameter(StrUtil.isBlank(pqSource.getParameter()) ? null : pqSource.getParameter());
pqSource.setState(DataStateEnum.ENABLE.getCode()); pqSource.setState(DataStateEnum.ENABLE.getCode());
return this.save(pqSource); return this.save(pqSource);
@@ -59,6 +66,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
public boolean updatePqSource(PqSourceParam.UpdateParam param) { public boolean updatePqSource(PqSourceParam.UpdateParam param) {
PqSource pqSource = new PqSource(); PqSource pqSource = new PqSource();
BeanUtil.copyProperties(param, pqSource); BeanUtil.copyProperties(param, pqSource);
pqSource.setName(this.generatePqSourceName(param, false));
return this.updateById(pqSource); return this.updateById(pqSource);
} }
@@ -66,4 +74,31 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
public boolean deletePqSource(List<String> ids) { public boolean deletePqSource(List<String> ids) {
return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update(); return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update();
} }
/**
* 生成检测源名称(检测源类型+设备类型+数字)
*
* @return 检测源名称
*/
private String generatePqSourceName(PqSourceParam param, boolean isAdd) {
DictData devTypeDictData = dictDataService.getDictDataById(param.getDevType());
DictData typeDictData = dictDataService.getDictDataById(param.getType());
if (ObjectUtil.isNotNull(devTypeDictData) && ObjectUtil.isNotNull(typeDictData)) {
if (isAdd) {
int count = this.lambdaQuery().eq(PqSource::getPattern, param.getPattern()).count();
return typeDictData.getName() + "-" + devTypeDictData.getName() + "-" + (count + 1);
} else {
PqSource pqSource = this.lambdaQuery().eq(PqSource::getId, ((PqSourceParam.UpdateParam) param).getId()).one();
if (ObjectUtil.isNotNull(pqSource)) {
String name = pqSource.getName();
if (StrUtil.isNotBlank(name)) {
int index = name.lastIndexOf("-");
return typeDictData.getName() + "-" + devTypeDictData.getName() + "-" + name.substring(index + 1);
}
}
}
}
throw new BusinessException(DeviceResponseEnum.PQ_SOURCE_GEN_NAME_ERROR);
}
} }

View File

@@ -50,10 +50,10 @@ public interface IDictDataService extends IService<DictData> {
/** /**
* 根据字典id获取字典数据 * 根据字典id获取字典数据
* @param dicIndex 查询参数 * @param id 查询参数
* @return 根据字典id查询字典数据 * @return 根据字典id查询字典数据
*/ */
DictData getDictDataById(String dicIndex); DictData getDictDataById(String id);
/** /**
* 根据字典名称获取字典数据 * 根据字典名称获取字典数据

View File

@@ -93,8 +93,8 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
@Override @Override
public DictData getDictDataById(String dicIndex) { public DictData getDictDataById(String id) {
return this.lambdaQuery().eq(DictData::getId, dicIndex).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).one(); return this.lambdaQuery().eq(DictData::getId, id).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).one();
} }
@Override @Override