微调
This commit is contained in:
@@ -15,40 +15,40 @@ import java.util.List;
|
||||
*/
|
||||
@Data
|
||||
public class AdPlanExcel {
|
||||
@Excel(name = "名称", width = 40)
|
||||
@Excel(name = "名称", width = 40, needMerge = true)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "模式", width = 20)
|
||||
@Excel(name = "模式", width = 20, needMerge = true)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "父计划id", width = 25)
|
||||
@Excel(name = "父计划id", width = 25, needMerge = true)
|
||||
private String fatherPlanId;
|
||||
|
||||
@Excel(name = "数据源", width = 20)
|
||||
private String datasource;
|
||||
@Excel(name = "数据源", width = 20, needMerge = true)
|
||||
private String datasourceId;
|
||||
|
||||
@Excel(name = "脚本", width = 50)
|
||||
private String script;
|
||||
@Excel(name = "脚本", width = 50, needMerge = true)
|
||||
private String scriptId;
|
||||
|
||||
@Excel(name = "误差体系", width = 30)
|
||||
private String errorSys;
|
||||
@Excel(name = "误差体系", width = 30, needMerge = true)
|
||||
private String errorSysId;
|
||||
|
||||
@Excel(name = "是否做守时检测", width = 15, replace = {"否_0", "是_1"})
|
||||
@Excel(name = "是否做守时检测", width = 15, replace = {"否_0", "是_1"}, needMerge = true)
|
||||
private Integer timeCheck;
|
||||
|
||||
@Excel(name = "检测状态", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"})
|
||||
@Excel(name = "检测状态", width = 10, replace = {"未检_0", "检测中_1", "检测完成_2"}, needMerge = true)
|
||||
private Integer testState;
|
||||
|
||||
@Excel(name = "报告生成状态", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"})
|
||||
@Excel(name = "报告生成状态", width = 15, replace = {"未生成_0", "部分生成_1", "全部生成_2"}, needMerge = true)
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "检测结果", width = 10, replace = {"不符合_0", "符合_1", "未检_2"})
|
||||
@Excel(name = "检测结果", width = 10, replace = {"不符合_0", "符合_1", "未检_2"}, needMerge = true)
|
||||
private Integer result;
|
||||
|
||||
@Excel(name = "数据表后缀", width = 20)
|
||||
@Excel(name = "数据表后缀", width = 20, needMerge = true)
|
||||
private Integer code;
|
||||
|
||||
@ExcelCollection(name = "绑定的设备")
|
||||
private List<PqDevExcel> devices;
|
||||
private List<PqDevExcel.PlanBindDevice> devices;
|
||||
}
|
||||
|
||||
@@ -14,11 +14,7 @@ import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.device.pojo.constant.DevConst;
|
||||
import com.njcn.gather.device.pojo.enums.CheckResultEnum;
|
||||
import com.njcn.gather.device.pojo.enums.CheckStateEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.PlanReportStateEnum;
|
||||
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.plan.mapper.AdPlanMapper;
|
||||
@@ -90,7 +86,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
adPlan.setId(planId);
|
||||
adPlan.setState(DataStateEnum.ENABLE.getCode());
|
||||
// 默认为顶级检测计划
|
||||
adPlan.setFatherPlanId(DevConst.FATHER_ID);
|
||||
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());
|
||||
@@ -122,17 +118,13 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
|
||||
// 修改检测计划、检测源关联
|
||||
adPlanSourceService.updateAdPlanSource(param.getId(), param.getSourceIds());
|
||||
if (ObjectUtil.isNotEmpty(param.getDevIds())) {
|
||||
// 修改时,只有未检测过的设备才可以修改绑定设备
|
||||
List<String> notUnCheckedIds = pqDevService.listNotUnchecked().stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
List<String> intersection = new ArrayList<>(notUnCheckedIds);
|
||||
intersection.retainAll(param.getDevIds());
|
||||
if (ObjectUtil.isEmpty(intersection)) {
|
||||
List<String> unCheckedIds = pqDevService.listUnchecked().stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
if (unCheckedIds.containsAll(param.getDevIds())) {
|
||||
pqDevService.bind(param.getId(), param.getDevIds());
|
||||
} else {
|
||||
throw new BusinessException(DevResponseEnum.HAS_NOT_UNCHECKED_DEVICE);
|
||||
}
|
||||
}
|
||||
|
||||
return this.updateById(adPlan);
|
||||
}
|
||||
@@ -214,6 +206,11 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
List<AdPlan> planList = this.list(this.getQueryWrapper(queryParam));
|
||||
this.visualize(planList);
|
||||
List<AdPlanExcel> planExcelList = BeanUtil.copyToList(planList, AdPlanExcel.class);
|
||||
for (int i = 0; i < planList.size(); i++) {
|
||||
PqDevParam.QueryParam queryParam1 = new PqDevParam.QueryParam();
|
||||
queryParam1.setPlanId(planList.get(i).getId());
|
||||
// planExcelList.get(i).setDevices(BeanUtil.copyToList(pqDevService.listByPlanId(queryParam1), PqDevExcel.ExportData.class));
|
||||
}
|
||||
return planExcelList;
|
||||
}
|
||||
|
||||
@@ -236,8 +233,8 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
if (StrUtil.isNotBlank(adPlan.getPattern())) {
|
||||
adPlan.setPattern(dictDataService.getDictDataById(adPlan.getPattern()).getName());
|
||||
}
|
||||
if (DevConst.FATHER_ID.equals(adPlan.getFatherPlanId())) {
|
||||
adPlan.setFatherPlanId("");
|
||||
if (CommonEnum.FATHER_ID.getValue().equals(adPlan.getFatherPlanId())) {
|
||||
adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getMsg());
|
||||
} else {
|
||||
adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getName());
|
||||
}
|
||||
@@ -266,7 +263,7 @@ public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> impleme
|
||||
adPlan.setPattern(dictDataService.getDictDataByName(adPlan.getPattern()).getId());
|
||||
}
|
||||
// if (DevConst.FATHER_ID.equals(adPlan.getFatherPlanId())) {
|
||||
// adPlan.setFatherPlanId("");
|
||||
// adPlan.setFatherPlanId(CommonEnum.FATHER_ID.getValue());
|
||||
// } else {
|
||||
// adPlan.setFatherPlanId(this.getById(adPlan.getFatherPlanId()).getId());
|
||||
// }
|
||||
|
||||
@@ -214,20 +214,20 @@ public class PqDevController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/bindDev")
|
||||
@ApiOperation("检测计划绑定设备")
|
||||
@ApiImplicitParam(name = "bindPlanParam", value = "绑定参数", required = true)
|
||||
public HttpResult<Object> bindDev(@RequestBody @Validated PqDevParam.BindPlanParam bindPlanParam) {
|
||||
String methodDescribe = getMethodDescribe("bindDev");
|
||||
LogUtil.njcnDebug(log, "{},绑定计划数据为:planId={}, pqDevIds={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
|
||||
boolean result = pqDevService.bind(bindPlanParam.getPlanId(), bindPlanParam.getPqDevIds());
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
// @OperateInfo(operateType = OperateType.UPDATE)
|
||||
// @PostMapping("/bindDev")
|
||||
// @ApiOperation("检测计划绑定设备")
|
||||
// @ApiImplicitParam(name = "bindPlanParam", value = "绑定参数", required = true)
|
||||
// public HttpResult<Object> bindDev(@RequestBody @Validated PqDevParam.BindPlanParam bindPlanParam) {
|
||||
// String methodDescribe = getMethodDescribe("bindDev");
|
||||
// LogUtil.njcnDebug(log, "{},绑定计划数据为:planId={}, pqDevIds={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
|
||||
// boolean result = pqDevService.bind(bindPlanParam.getPlanId(), bindPlanParam.getPqDevIds());
|
||||
// if (result) {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
// } else {
|
||||
// return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
// }
|
||||
// }
|
||||
|
||||
// @OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
// @PostMapping("/listUnDocumentByPlanId")
|
||||
|
||||
@@ -178,7 +178,6 @@ public class PqDevParam {
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty("设备厂家")
|
||||
|
||||
@@ -81,7 +81,7 @@ public class PqDevExcel implements Serializable {
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否为加密版本(0:否、1:是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14", needMerge = true)
|
||||
@Excel(name = "是否为加密版本(否\\是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14", needMerge = true)
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@@ -100,16 +100,16 @@ public class PqDevExcel implements Serializable {
|
||||
@Excel(name = "所属电站名称", width = 20, orderNum = "21", needMerge = true)
|
||||
private String subName;
|
||||
|
||||
@Excel(name = "检测状态(0:未检、1:检测中、2:检测完成、3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22", needMerge = true)
|
||||
@Excel(name = "检测状态(未检\\检测中\\检测完成\\归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22", needMerge = true)
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1", "/_2"}, orderNum = "23", needMerge = true)
|
||||
@Excel(name = "检测结果(不符合\\符合\\未检)", width = 15, replace = {"不符合_0", "符合_1", "未检_2"}, orderNum = "23", needMerge = true)
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成、1:已生成、2:未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "24", needMerge = true)
|
||||
@Excel(name = "报告状态(未生成\\已生成\\未检)", width = 15, replace = {"未生成_0", "已生成_1", "未检_2"}, orderNum = "24", needMerge = true)
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "25", needMerge = true)
|
||||
@Excel(name = "归档状态(未归档\\归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "25", needMerge = true)
|
||||
private Integer documentState;
|
||||
|
||||
@Excel(name = "报告路径", width = 20, orderNum = "26", needMerge = true)
|
||||
@@ -195,4 +195,72 @@ public class PqDevExcel implements Serializable {
|
||||
@ExcelCollection(name = "检测点台账", orderNum = "29")
|
||||
List<PqMonitorExcel.ExportData> 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -165,7 +165,7 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*
|
||||
* @return 所有非未检测状态的设备列表
|
||||
*/
|
||||
List<PqDev> listNotUnchecked();
|
||||
List<PqDev> listUnchecked();
|
||||
|
||||
/**
|
||||
* 获取装置信息和装置下监测点信息
|
||||
|
||||
@@ -270,22 +270,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
|
||||
@Override
|
||||
public boolean bind(String planId, List<String> devIds) {
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
queryParam.setPlanId(planId);
|
||||
List<String> existedBoundPqDevIds = this.listByPlanId(queryParam).stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, null).eq(PqDev::getPlanId, planId).update();
|
||||
|
||||
//共有的(交集)
|
||||
List<String> intersection = existedBoundPqDevIds.stream().filter(devIds::contains).collect(Collectors.toList());
|
||||
|
||||
//移除 已有的历史绑定而此次不绑定的
|
||||
existedBoundPqDevIds.removeAll(intersection);
|
||||
if (ObjectUtils.isNotEmpty(existedBoundPqDevIds)) {
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, null).in(PqDev::getId, existedBoundPqDevIds).update();
|
||||
}
|
||||
|
||||
//绑定 没有的历史绑定而此次绑定的
|
||||
devIds.removeAll(existedBoundPqDevIds);
|
||||
if (ObjectUtils.isNotEmpty(devIds)) {
|
||||
if (ObjectUtil.isNotEmpty(devIds)) {
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, devIds).update();
|
||||
}
|
||||
|
||||
@@ -323,8 +310,8 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listNotUnchecked() {
|
||||
return this.lambdaQuery().ne(PqDev::getCheckState, CheckStateEnum.UNCHECKED.getValue()).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
public List<PqDev> listUnchecked() {
|
||||
return this.lambdaQuery().eq(PqDev::getCheckState, CheckStateEnum.UNCHECKED.getValue()).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.njcn.gather.device.pojo.constant;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-04
|
||||
*/
|
||||
public interface DevConst {
|
||||
/**
|
||||
* 顶层父节点ID
|
||||
*/
|
||||
String FATHER_ID = "0";
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-13
|
||||
*/
|
||||
@Getter
|
||||
public enum CommonEnum {
|
||||
FATHER_ID("0", "无"),
|
||||
;
|
||||
|
||||
private String value;
|
||||
private String msg;
|
||||
|
||||
CommonEnum(String value, String msg) {
|
||||
this.value = value;
|
||||
this.msg = msg;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.gather.device.pojo.constant.DevConst;
|
||||
import com.njcn.gather.device.pojo.enums.CommonEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.device.source.mapper.PqSourceMapper;
|
||||
import com.njcn.gather.device.source.pojo.param.PqSourceParam;
|
||||
@@ -101,7 +101,7 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
String parameter = pqSource.getParameter();
|
||||
if (StrUtil.isNotBlank(parameter)) {
|
||||
List<SourceParam> list = new JSONArray(parameter).toList(SourceParam.class);
|
||||
List<SourceParam> sourceParams = list.stream().filter(p -> p.getPId().equals(DevConst.FATHER_ID))
|
||||
List<SourceParam> sourceParams = list.stream().filter(p -> p.getPId().equals(CommonEnum.FATHER_ID.getValue()))
|
||||
.peek(p -> p.setChildren(getChildren(p, list)))
|
||||
.sorted(Comparator.comparingInt(SourceParam::getSort))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
Reference in New Issue
Block a user