This commit is contained in:
caozehui
2024-11-15 22:05:38 +08:00
parent 424b319c38
commit f284b7a325
9 changed files with 158 additions and 67 deletions

View File

@@ -1,5 +1,6 @@
#### 简介
设备模块主要包含以下功能:
* 被检设备管理
* 检测脚本管理

View File

@@ -2,6 +2,7 @@ package com.njcn.gather.device.device.pojo.param;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
@@ -9,9 +10,7 @@ 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 javax.validation.constraints.*;
import java.util.List;
/**
@@ -28,14 +27,17 @@ public class PqDevParam {
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
private String pattern;
@ApiModelProperty(value = "设备类型,字典表", required = true)
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_TYPE_FORMAT_ERROR)
private String devType;
@ApiModelProperty(value = "设备通道数", required = true)
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
@Min(value = 1, message = DeviceValidMessage.DEV_CHNS_RANGE_ERROR)
private Integer devChns;
@ApiModelProperty(value = "额定电压V", required = true)
@@ -48,6 +50,7 @@ public class PqDevParam {
@ApiModelProperty(value = "生产厂家,字典表", required = true)
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.MANUFACTURER_FORMAT_ERROR)
private String manufacturer;
@ApiModelProperty(value = "生产日期", required = true)
@@ -69,6 +72,7 @@ public class PqDevParam {
@ApiModelProperty(value = "通讯协议", required = true)
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PROTOCOL_FORMAT_ERROR)
private String protocol;
@ApiModelProperty(value = "IP地址", required = true)
@@ -77,12 +81,14 @@ public class PqDevParam {
private String ip;
@ApiModelProperty(value = "端口号", required = true)
@Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR)
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
@Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR)
private Integer port;
@ApiModelProperty(value = "装置是否为加密版本", required = true)
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
@Min(value = 0, message = DeviceValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
@Max(value = 1, message = DeviceValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
private Integer encryptionFlag;
@ApiModelProperty("装置识别码3ds加密")
@@ -127,6 +133,7 @@ public class PqDevParam {
@ApiModelProperty(value = "复检次数,默认为0", required = true)
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
@Min(value = 0, message = DeviceValidMessage.RECHECK_NUM_FORMAT_ERROR)
private Integer reCheckNum;
@@ -162,7 +169,7 @@ public class PqDevParam {
public static class BindPlanParam {
@ApiModelProperty("planId")
@NotNull(message = DeviceValidMessage.PLAN_ID_NOT_NULL)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PLAN_ID_FORMAT_ERROR)
private String planId;
@ApiModelProperty("pqDevIds")

View File

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

View File

@@ -106,21 +106,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override
public void downloadTemplate() {
ExcelUtil.exportExcel("被检设备模板.xlsx", "被检设备", PqDevExcel.class, new ArrayList<>());
ExcelUtil.exportExcel("被检设备模板.xlsx", "被检设备", PqDevExcel.ExportData.class, new ArrayList<>());
}
@Override
public void importPqDevData(List<PqDevExcel.ImportData> pqDevExcelList) {
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
pqDevList.forEach(pqDev -> {
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());
});
//逆向可视化
this.reverseVisualize(pqDevList);
this.saveBatch(pqDevList);
}
@@ -177,14 +170,30 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
//可视化各种id回显字典值解码等操作
private void visualize(List<PqDev> sourceList) {
sourceList.forEach(pqDev -> {
//todo
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.getDicDataById(pqDev.getDevType());
if(ObjectUtil.isNotNull(dictData)){
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()));
}
@@ -193,4 +202,41 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
}
});
}
//逆向可视化
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.getName());
}
}
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());
});
}
}

View File

@@ -50,9 +50,25 @@ public interface DeviceValidMessage {
String RECHECK_NUM_NOT_NULL = "复检次数不能为空请检查reCheckNum参数";
String PLAN_ID_NOT_NULL="检测计划ID不能为空请检查planId参数";
String PLAN_ID_NOT_NULL = "检测计划ID不能为空请检查planId参数";
String PQ_DEV_IDS_NOT_NULL="设备ID集合不能为null请检查pqDevIds参数";
String PQ_DEV_IDS_NOT_NULL = "设备ID集合不能为null请检查pqDevIds参数";
String ARRIVE_DATE_FORMAT_ERROR = "送样日期格式错误请检查arrivedDateTime参数";
String ENCRYPTION_FLAG_FORMAT_ERROR = "是否为加密版本格式错误请检查encryptionFlag参数";
String RECHECK_NUM_FORMAT_ERROR = "复检次数格式错误请检查recheckNum参数";
String PATTERN_FORMAT_ERROR = "设备模式格式错误请检查pattern参数";
String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误请检查devType参数";
String DEV_CHNS_RANGE_ERROR = "设备通道系数错误请检查devChns参数";
String MANUFACTURER_FORMAT_ERROR = "生产厂家格式错误请检查manufacturer参数";
String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误请检查protocol参数";
String PLAN_ID_FORMAT_ERROR = "检测计划ID格式错误请检查planId参数";
}

View File

@@ -117,7 +117,7 @@ public class DictDataController extends BaseController {
@ApiImplicitParam(name = "dicIndex", value = "查询参数", required = true)
public HttpResult<DictData> getDicDataById(@RequestParam("dicIndex") String dicIndex) {
String methodDescribe = getMethodDescribe("getDicDataById");
DictData result = dictDataService.getDicDataById(dicIndex);
DictData result = dictDataService.getDictDataById(dicIndex);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}
@@ -127,7 +127,7 @@ public class DictDataController extends BaseController {
@ApiImplicitParam(name = "code", value = "查询参数", required = true)
public HttpResult<DictData> getDicDataByCode(@RequestParam("code") String code) {
String methodDescribe = getMethodDescribe("getDicDataByCode");
DictData result = dictDataService.getDicDataByCode(code);
DictData result = dictDataService.getDictDataByCode(code);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
}

View File

@@ -49,8 +49,8 @@ public class DictDataParam {
@ApiModelProperty("与高级算法内部Id描述对应")
private Integer algoDescribe;
@ApiModelProperty("字典值,用于记录字典的计算值如10kV记录为 10")
//todo 待定
@ApiModelProperty("字典值")
private String value;

View File

@@ -53,15 +53,21 @@ public interface IDictDataService extends IService<DictData> {
* @param dicIndex 查询参数
* @return 根据字典id查询字典数据
*/
DictData getDicDataById(String dicIndex);
DictData getDictDataById(String dicIndex);
/**
* 根据字典名称获取字典数据
* @param name 字典名称
* @return 根据字典名称查询字典数据
*/
DictData getDictDataByName(String name);
/**
* 根据字典code获取字典数据
* @param code 字典code
* @return 根据字典code查询字典数据
*/
DictData getDicDataByCode(String code);
DictData getDictDataByCode(String code);
/**
* 获取所有字典数据基础信息

View File

@@ -13,12 +13,12 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.gather.system.dictionary.mapper.DictDataMapper;
import com.njcn.gather.system.dictionary.pojo.dto.DictDataCache;
import com.njcn.gather.system.dictionary.pojo.vo.DictDataExcel;
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
import com.njcn.gather.system.dictionary.pojo.param.DictDataParam;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.pojo.po.DictType;
import com.njcn.gather.system.dictionary.pojo.vo.DictDataExcel;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
import com.njcn.web.factory.PageFactory;
import com.njcn.web.pojo.dto.SimpleDTO;
import com.njcn.web.pojo.dto.SimpleTreeDTO;
@@ -93,13 +93,17 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
@Override
public DictData getDicDataById(String dicIndex) {
public DictData getDictDataById(String dicIndex) {
return this.lambdaQuery().eq(DictData::getId, dicIndex).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).one();
}
@Override
public DictData getDictDataByName(String name) {
return this.lambdaQuery().eq(DictData::getName, name).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).one();
}
@Override
public DictData getDicDataByCode(String code) {
public DictData getDictDataByCode(String code) {
LambdaQueryWrapper<DictData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DictData::getCode, code)
.eq(DictData::getState, DataStateEnum.ENABLE.getCode());