微调
This commit is contained in:
@@ -16,13 +16,12 @@ import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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;
|
||||
@@ -33,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -114,7 +114,7 @@ public class PqDevController extends BaseController {
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入被检设备数据")
|
||||
@ApiImplicitParam(name = "ids", value = "被检设备id", required = true)
|
||||
@ApiImplicitParam(name = "file", value = "被检设备数据文件", required = true)
|
||||
public HttpResult<String> importPqDevData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importPqDevData");
|
||||
ImportParams params = new ImportParams();
|
||||
@@ -135,7 +135,7 @@ public class PqDevController extends BaseController {
|
||||
pqDevService.importPqDevData(list);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DeviceResponseEnum.IMPORT_DATA_FAIL);
|
||||
throw new BusinessException(DevResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
@@ -152,40 +152,23 @@ public class PqDevController extends BaseController {
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listUnbound")
|
||||
@ApiOperation("查询出所有未绑定的设备")
|
||||
public HttpResult<List<PqDev>> listUnbound() {
|
||||
@ApiOperation("获取指定模式下所有未绑定的设备")
|
||||
@ApiImplicitParam(name = "pattern", value = "模式id", required = true)
|
||||
public HttpResult<List<Map<String, Object>>> listUnbound(@RequestParam("pattern") String pattern) {
|
||||
String methodDescribe = getMethodDescribe("listUnbound");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, null);
|
||||
List<PqDev> result = pqDevService.listUnbound();
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, pattern);
|
||||
List<Map<String, Object>> result = pqDevService.listUnbound(pattern);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listBoundByPlanId")
|
||||
@ApiOperation("根据计划id查询出所有已绑定的设备")
|
||||
@PostMapping("/listBoundByPlanId")
|
||||
@ApiOperation("根据检测计划id查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqDev>> listBoundByPlanId(@RequestParam("planId") String planId) {
|
||||
public HttpResult<List<PqDev>> listBoundByPlanId(@RequestBody @Validated PqDevParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("listBoundByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
List<PqDev> result = pqDevService.listBoundByPlanId(planId);
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
List<PqDev> result = pqDevService.listBoundByPlanId(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/bindPlan")
|
||||
@ApiOperation("设备绑定计划")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true),
|
||||
@ApiImplicitParam(name = "pqDevId", value = "被检设备id", required = true)
|
||||
})
|
||||
public HttpResult<Object> bindPlan(@RequestBody @Validated PqDevParam.BindPlanParam bindPlanParam) {
|
||||
String methodDescribe = getMethodDescribe("bindPlan");
|
||||
LogUtil.njcnDebug(log, "{},绑定计划数据为:planId={}, pqDevId={}", methodDescribe, bindPlanParam.getPlanId(), String.join(StrUtil.COMMA, bindPlanParam.getPqDevIds()));
|
||||
boolean result = pqDevService.bindPlan(bindPlanParam.getPlanId(), bindPlanParam.getPqDevIds());
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,8 @@
|
||||
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.device.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -9,6 +10,7 @@ import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
@@ -20,74 +22,74 @@ import java.util.List;
|
||||
public class PqDevParam {
|
||||
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.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)
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.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)
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
@Min(value = 1, message = DevValidMessage.DEV_CHNS_RANGE_ERROR)
|
||||
private Integer devChns;
|
||||
|
||||
@ApiModelProperty(value = "额定电压(V)", required = true)
|
||||
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@ApiModelProperty(value = "额定电流(A)", required = true)
|
||||
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@ApiModelProperty(value = "设备厂家,字典表", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.MANUFACTURER_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.MANUFACTURER_FORMAT_ERROR)
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(value = "出厂日期", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(format = "yyyy-MM-dd", message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@ApiModelProperty(value = "设备序列号", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@ApiModelProperty(value = "固件版本", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@ApiModelProperty(value = "软件版本", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@ApiModelProperty(value = "通讯协议", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PROTOCOL_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PROTOCOL_FORMAT_ERROR)
|
||||
private String protocol;
|
||||
|
||||
@ApiModelProperty(value = "IP地址", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DevValidMessage.IP_FORMAT_ERROR)
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty(value = "端口号", required = true)
|
||||
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR)
|
||||
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.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)
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
@Min(value = 0, message = DevValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DevValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@ApiModelProperty("装置识别码(3ds加密)")
|
||||
@@ -100,7 +102,7 @@ public class PqDevParam {
|
||||
private String sampleId;
|
||||
|
||||
@ApiModelProperty(value = "送样日期")
|
||||
@DateTimeStrValid(message = DeviceValidMessage.ARRIVE_DATE_FORMAT_ERROR)
|
||||
@DateTimeStrValid(message = DevValidMessage.ARRIVE_DATE_FORMAT_ERROR)
|
||||
private String arrivedDate;
|
||||
|
||||
@ApiModelProperty("所属地市名称")
|
||||
@@ -112,17 +114,17 @@ public class PqDevParam {
|
||||
@ApiModelProperty("所属电站名称")
|
||||
private String subName;
|
||||
|
||||
@ApiModelProperty("检测状态")
|
||||
private Integer checkState;
|
||||
// @ApiModelProperty("检测状态")
|
||||
// private Integer checkState;
|
||||
|
||||
@ApiModelProperty("检测结果(1:合格/0:不合格)")
|
||||
private Integer checkResult;
|
||||
// @ApiModelProperty("检测结果")
|
||||
// private Integer checkResult;
|
||||
|
||||
@ApiModelProperty("报告状态(1:生成/0:未生成)")
|
||||
private Integer reportState;
|
||||
// @ApiModelProperty("报告状态")
|
||||
// private Integer reportState;
|
||||
|
||||
@ApiModelProperty("归档状态(1:归档/0:未归档)")
|
||||
private Integer documentState;
|
||||
// @ApiModelProperty("归档状态")
|
||||
// private Integer documentState;
|
||||
|
||||
@ApiModelProperty("报告路径")
|
||||
private String reportPath;
|
||||
@@ -131,10 +133,13 @@ public class PqDevParam {
|
||||
private String qrCode;
|
||||
|
||||
@ApiModelProperty(value = "复检次数,默认为0", required = true)
|
||||
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
@Min(value = 0, message = DeviceValidMessage.RECHECK_NUM_FORMAT_ERROR)
|
||||
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
@Min(value = 0, message = DevValidMessage.RECHECK_NUM_FORMAT_ERROR)
|
||||
private Integer reCheckNum;
|
||||
|
||||
@ApiModelProperty("监测点台账列表")
|
||||
@Valid
|
||||
private List<PqMonitorParam> pqMonitorList;
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
@@ -144,10 +149,29 @@ public class PqDevParam {
|
||||
public static class UpdateParam extends PqDevParam {
|
||||
|
||||
@ApiModelProperty(value = "id", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
|
||||
@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 = 2, 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 = 1, 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;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,27 +181,29 @@ public class PqDevParam {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
// @NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty("设备厂家")
|
||||
private String manufacturer;
|
||||
}
|
||||
|
||||
@Data
|
||||
public static class BindPlanParam {
|
||||
@ApiModelProperty("planId")
|
||||
@NotNull(message = DeviceValidMessage.PLAN_ID_NOT_NULL)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
@ApiModelProperty("检测计划ID")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("pqDevIds")
|
||||
@NotNull(message = DeviceValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> pqDevIds;
|
||||
}
|
||||
@ApiModelProperty("检测状态")
|
||||
@Min(value = 0, message = DevValidMessage.CHECK_STATE_FORMAT_ERROR)
|
||||
@Max(value = 2, 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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,7 @@ package com.njcn.gather.device.device.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
@@ -24,62 +24,62 @@ public class PqDevExcel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Excel(name = "名称", width = 20)
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||
@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 = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "设备类型", width = 20, orderNum = "2")
|
||||
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备通道数", width = 20, orderNum = "3")
|
||||
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@Excel(name = "额定电压(V)", width = 15, orderNum = "4")
|
||||
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@Excel(name = "额定电流(A)", width = 15, orderNum = "5")
|
||||
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@Excel(name = "设备厂家", width = 20, orderNum = "6")
|
||||
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "设备序列号", width = 40, orderNum = "8")
|
||||
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "固件版本", width = 15, orderNum = "9")
|
||||
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15, orderNum = "10")
|
||||
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议", width = 15, orderNum = "11")
|
||||
@NotBlank(message = DeviceValidMessage.PROTOCOL_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.PROTOCOL_NOT_BLANK)
|
||||
private String protocol;
|
||||
|
||||
@Excel(name = "IP地址", width = 20, orderNum = "12")
|
||||
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.IP_FORMAT_ERROR)
|
||||
@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 = DeviceValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR)
|
||||
@NotNull(message = DevValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DevValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否为加密版本(0:否/1:是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14")
|
||||
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
|
||||
@Excel(name = "是否为加密版本(0:否、1:是)", width = 20, replace = {"否_0", "是_1"}, orderNum = "14")
|
||||
@NotNull(message = DevValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码", width = 30, orderNum = "15")
|
||||
@@ -104,7 +104,7 @@ public class PqDevExcel implements Serializable {
|
||||
private String qrCode;
|
||||
|
||||
@Excel(name = "复检次数", width = 15, orderNum = "28")
|
||||
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
private Integer reCheckNum;
|
||||
|
||||
/**
|
||||
@@ -115,7 +115,7 @@ public class PqDevExcel implements Serializable {
|
||||
public static class SimulateAndDigitalExportData extends PqDevExcel {
|
||||
|
||||
@Excel(name = "出厂日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "7")
|
||||
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "样品编号", width = 40, orderNum = "17")
|
||||
@@ -124,16 +124,16 @@ public class PqDevExcel implements Serializable {
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd", orderNum = "18")
|
||||
private LocalDate arrivedDate;
|
||||
|
||||
@Excel(name = "检测状态(0:未检/1:检测中/2:检测完成/3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3", "_null"}, orderNum = "22")
|
||||
@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")
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1","/_2", "_null"}, orderNum = "23")
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成/1:生成)", width = 15, replace = {"未生成_0", "生成_1", "_null"}, orderNum = "24")
|
||||
@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")
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1", "_null"}, orderNum = "25")
|
||||
private Integer documentState;
|
||||
}
|
||||
|
||||
@@ -144,19 +144,19 @@ public class PqDevExcel implements Serializable {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
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)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "检测状态(0:未检/1:检测中/2:检测完成/3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3", "_null"}, orderNum = "22")
|
||||
@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")
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1","/_2", "_null"}, orderNum = "23")
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成/1:生成)", width = 15, replace = {"未生成_0", "生成_1", "_null"}, orderNum = "24")
|
||||
@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")
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1", "_null"}, orderNum = "25")
|
||||
private Integer documentState;
|
||||
}
|
||||
|
||||
@@ -168,20 +168,20 @@ public class PqDevExcel implements Serializable {
|
||||
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)
|
||||
@DateTimeStrValid(message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
@NotNull(message = DevValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(message = DevValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@Excel(name = "检测状态(0:未检/1:检测中/2:检测完成/3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22")
|
||||
@Excel(name = "检测状态(0:未检、1:检测中、2:检测完成、3:归档)", width = 15, replace = {"未检_0", "检测中_1", "检测完成_2", "归档_3"}, orderNum = "22")
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "检测结果(0:不合格/1:合格)", width = 15, replace = {"不合格_0", "合格_1"}, orderNum = "23")
|
||||
@Excel(name = "检测结果(0:不符合、1:符合、2:/)", width = 15, replace = {"不符合_0", "符合_1","/_2"}, orderNum = "23")
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(0:未生成/1:生成)", width = 15, replace = {"未生成_0", "生成_1"}, orderNum = "24")
|
||||
@Excel(name = "报告状态(0:未生成、1:已生成)", width = 15, replace = {"未生成_0", "已生成_1"}, orderNum = "24")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(0:未归档/1:归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "25")
|
||||
@Excel(name = "归档状态(0:未归档、1:归档)", width = 15, replace = {"未归档_0", "归档_1"}, orderNum = "25")
|
||||
private Integer documentState;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,8 +5,10 @@ import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -65,28 +67,35 @@ public interface IPqDevService extends IService<PqDev> {
|
||||
*/
|
||||
void exportPqDevData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有未绑定的设备
|
||||
*
|
||||
* @param pattern 模式Id
|
||||
* @return 未绑定的设备列表
|
||||
*/
|
||||
List<PqDev> listUnbound();
|
||||
List<Map<String, Object>> listUnbound(String pattern);
|
||||
|
||||
/**
|
||||
* 根据计划id获取绑定的设备
|
||||
*
|
||||
* @param planId 计划id
|
||||
* @param param 计划id
|
||||
* @return 绑定的设备列表
|
||||
*/
|
||||
List<PqDev> listBoundByPlanId(String planId);
|
||||
List<PqDev> listBoundByPlanId(PqDevParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 绑定计划
|
||||
*
|
||||
* @param planId 计划id
|
||||
* @param pqDevIds 被检设备id列表
|
||||
* @param bindPlanParam 检测计划绑定被检设备参数
|
||||
* @return 绑定成功返回true,否则返回false
|
||||
*/
|
||||
boolean bindPlan(String planId, List<String> pqDevIds);
|
||||
boolean bind(AdPlanParam.BindPlanParam bindPlanParam);
|
||||
|
||||
/**
|
||||
* 获取饼图数据
|
||||
*
|
||||
* @param planId 检测计划id
|
||||
* @return 饼图数据
|
||||
*/
|
||||
List<List<Map<String, Object>>> getPieData(String planId);
|
||||
}
|
||||
|
||||
@@ -15,19 +15,20 @@ import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.device.device.pojo.vo.PqDevExcel;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.device.util.DeviceUtil;
|
||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.pojo.constant.DevConst;
|
||||
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.*;
|
||||
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.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@@ -40,6 +41,7 @@ import java.util.stream.Collectors;
|
||||
public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements IPqDevService {
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
|
||||
@Override
|
||||
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
@@ -77,19 +79,25 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
public boolean addPqDev(PqDevParam pqDevParam) {
|
||||
PqDev pqDev = new 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 (StrUtil.isNotBlank(pqDevParam.getSeries()) && StrUtil.isNotBlank(pqDevParam.getDevKey())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
} else {
|
||||
throw new BusinessException(DeviceResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
throw new BusinessException(DevResponseEnum.SERIES_AND_DEVKEY_NOT_BLANK);
|
||||
}
|
||||
}
|
||||
//todo 比对式设备处理
|
||||
// 新增时默认设置为未检验、未生成报告、未归档、未出检测结果
|
||||
pqDev.setCheckState(CheckStateEnum.UNCHECKED.getValue());
|
||||
pqDev.setReportState(DevReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
pqDev.setDocumentState(DevDocumentStateEnum.UNDOCUMENTED.getValue());
|
||||
pqDev.setCheckResult(CheckResultEnum.UNKNOWN.getValue());
|
||||
String id = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
pqDev.setId(id);
|
||||
// 比对式设备添加监测点
|
||||
if (DevConst.PATTERN_CONTRAST.equals(dictDataService.getDictDataById(pqDevParam.getPattern()).getCode())) {
|
||||
pqMonitorService.addPqMonitorByDevId(id, pqDevParam.getPqMonitorList());
|
||||
}
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqDev);
|
||||
}
|
||||
@@ -105,6 +113,9 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
//todo 比对式设备处理
|
||||
if (DevConst.PATTERN_CONTRAST.equals(dictDataService.getDictDataById(updateParam.getPattern()).getCode())) {
|
||||
pqMonitorService.addPqMonitorByDevId(updateParam.getId(), updateParam.getPqMonitorList());
|
||||
}
|
||||
return this.updateById(pqDev);
|
||||
}
|
||||
|
||||
@@ -161,31 +172,128 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listUnbound() {
|
||||
return this.lambdaQuery().eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).isNull(PqDev::getPlanId).list();
|
||||
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();
|
||||
List<Map<String, Object>> result = pqDevList.stream().map(pqDev -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqDev.getId());
|
||||
map.put("name", pqDev.getName());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listBoundByPlanId(String planId) {
|
||||
return this.lambdaQuery().eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).eq(PqDev::getPlanId, planId).list();
|
||||
public List<PqDev> listBoundByPlanId(PqDevParam.QueryParam param) {
|
||||
List<PqDev> pqDevList = this.lambdaQuery()
|
||||
.eq(StrUtil.isNotBlank(param.getPlanId()), PqDev::getPlanId, param.getPlanId())
|
||||
.eq(StrUtil.isNotBlank(param.getName()), PqDev::getName, param.getName())
|
||||
.eq(ObjectUtil.isNotNull(param.getCheckState()), PqDev::getCheckState, param.getCheckState())
|
||||
.eq(ObjectUtil.isNotNull(param.getCheckResult()), PqDev::getCheckResult, param.getCheckResult())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
// List<Map<String, Object>> result = pqDevList.stream().map(pqDev -> {
|
||||
// Map<String, Object> map = new HashMap<>();
|
||||
// map.put("id", pqDev.getId());
|
||||
// map.put("name", pqDev.getName());
|
||||
// return map;
|
||||
// }).collect(Collectors.toList());
|
||||
return pqDevList;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bindPlan(String planId, List<String> pqDevIds) {
|
||||
List<String> existedBoundPqDevIds = this.listBoundByPlanId(planId).stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
public boolean bind(AdPlanParam.BindPlanParam bindPlanParam) {
|
||||
String planId = bindPlanParam.getPlanId();
|
||||
List<String> pqDevIds = bindPlanParam.getPqDevIds();
|
||||
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
queryParam.setPlanId(planId);
|
||||
List<String> existedBoundPqDevIds = this.listBoundByPlanId(queryParam).stream().map(PqDev::getId).collect(Collectors.toList());
|
||||
|
||||
//共有的(交集)
|
||||
List<String> intersection = existedBoundPqDevIds.stream().filter(pqDevIds::contains).collect(Collectors.toList());
|
||||
|
||||
//移除 已有的历史绑定而此次不绑定的
|
||||
existedBoundPqDevIds.removeAll(intersection);
|
||||
boolean result1 = this.lambdaUpdate().set(PqDev::getPlanId, null).in(PqDev::getId, existedBoundPqDevIds).update();
|
||||
if (ObjectUtils.isNotEmpty(existedBoundPqDevIds)) {
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, null).in(PqDev::getId, existedBoundPqDevIds).update();
|
||||
}
|
||||
|
||||
//绑定 没有的历史绑定而此次绑定的
|
||||
pqDevIds.removeAll(existedBoundPqDevIds);
|
||||
boolean result2 = this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, pqDevIds).update();
|
||||
if (ObjectUtils.isNotEmpty(pqDevIds)) {
|
||||
this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, pqDevIds).update();
|
||||
}
|
||||
|
||||
return result1 && result2;
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List getPieData(String planId) {
|
||||
List<PqDev> pqDevList = this.lambdaQuery().eq(PqDev::getPlanId, planId).eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
Map<Integer, Long> checkStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckState, Collectors.counting()));
|
||||
Map<Integer, Long> checkResultMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getCheckResult, Collectors.counting()));
|
||||
Map<Integer, Long> reportStateMap = pqDevList.stream().collect(Collectors.groupingBy(PqDev::getReportState, Collectors.counting()));
|
||||
|
||||
List<Map<String, Object>> checkStateData = getCheckStatePieData(checkStateMap);
|
||||
List<Map<String, Object>> checkResultData = getCheckResultPieData(checkResultMap);
|
||||
List<Map<String, Object>> reportStateData = getReportStatePieData(reportStateMap);
|
||||
|
||||
List<List<Map<String, Object>>> result = new ArrayList<>();
|
||||
result.add(checkStateData);
|
||||
result.add(checkResultData);
|
||||
result.add(reportStateData);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测状态饼状图数据
|
||||
*
|
||||
* @param map 检测状态分组map
|
||||
* @return 检测状态饼状图数据
|
||||
*/
|
||||
private List<Map<String, Object>> getCheckStatePieData(Map<Integer, Long> map) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (CheckStateEnum e : CheckStateEnum.values()) {
|
||||
Map<String, Object> temp = new HashMap<>();
|
||||
temp.put("name", e.getMessage());
|
||||
temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
result.add(temp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取检测结果饼状图数据
|
||||
*
|
||||
* @param map 检测结果分组map
|
||||
* @return 检测结果饼状图数据
|
||||
*/
|
||||
private List<Map<String, Object>> getCheckResultPieData(Map<Integer, Long> map) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (CheckResultEnum e : CheckResultEnum.values()) {
|
||||
Map<String, Object> temp = new HashMap<>();
|
||||
temp.put("name", e.getMessage());
|
||||
temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
result.add(temp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取报告状态饼状图数据
|
||||
*
|
||||
* @param map 报告状态分组map
|
||||
* @return 报告状态饼状图数据
|
||||
*/
|
||||
private List<Map<String, Object>> getReportStatePieData(Map<Integer, Long> map) {
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
for (DevReportStateEnum e : DevReportStateEnum.values()) {
|
||||
Map<String, Object> temp = new HashMap<>();
|
||||
temp.put("name", e.getMessage());
|
||||
temp.put("value", map.getOrDefault(e.getValue(), 0L));
|
||||
result.add(temp);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
//可视化,各种id回显字典值,解码等操作
|
||||
|
||||
@@ -7,9 +7,9 @@ import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
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.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
@@ -22,6 +22,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -114,6 +115,16 @@ public class PqErrSysController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation("获取所有误差体系")
|
||||
public HttpResult<List<Map<String, Object>>> getAllPqErrSys() {
|
||||
String methodDescribe = getMethodDescribe("getAllPqErrSys");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
List<Map<String, Object>> result = pqErrSysService.listAllPqErrSys();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
// @OperateInfo(operateType = OperateType.ADD)
|
||||
// @GetMapping("/copy")
|
||||
// @ApiOperation("复制误差体系")
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.err.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -17,24 +17,24 @@ import javax.validation.constraints.Pattern;
|
||||
public class PqErrSysDtlsParam {
|
||||
|
||||
@ApiModelProperty(value = "电能质量指标类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.ERR_SYS_DTLS_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ERR_SYS_DTLS_TYPE_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.ERR_SYS_DTLS_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERR_SYS_DTLS_TYPE_FORMAT_ERROR)
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "误差判断起始值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.START_VALUE_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.START_VALUE_NOT_NULL)
|
||||
private Float startValue;
|
||||
|
||||
@ApiModelProperty(value = "是否包含起始值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.START_FLAG_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.START_FLAG_NOT_NULL)
|
||||
private Integer startFlag;
|
||||
|
||||
@ApiModelProperty(value = "误差判断结束值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.END_VALUE_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.END_VALUE_NOT_NULL)
|
||||
private Float endValue;
|
||||
|
||||
@ApiModelProperty(value = "是否包含结束值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.END_FLAG_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.END_FLAG_NOT_NULL)
|
||||
private Integer endFlag;
|
||||
|
||||
// @ApiModelProperty(value = "单位", required = true)
|
||||
@@ -43,17 +43,17 @@ public class PqErrSysDtlsParam {
|
||||
// private String unit;
|
||||
|
||||
@ApiModelProperty(value = "判断条件值类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.CONDITION_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ERROR_VALUE_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.CONDITION_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERROR_VALUE_FORMAT_ERROR)
|
||||
private String conditionType;
|
||||
|
||||
@ApiModelProperty(value = "最大值误差", required = true)
|
||||
@NotNull(message = DeviceValidMessage.MAX_ERROR_VALUE_NOT_NULL)
|
||||
@NotNull(message = DevValidMessage.MAX_ERROR_VALUE_NOT_NULL)
|
||||
private Float maxErrorValue;
|
||||
|
||||
@ApiModelProperty(value = "误差值类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ERROR_VALUE_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.ERROR_VALUE_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERROR_VALUE_FORMAT_ERROR)
|
||||
private String errorValueType;
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.err.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
@@ -20,29 +20,29 @@ import java.util.List;
|
||||
public class PqErrSysParam {
|
||||
|
||||
@ApiModelProperty(value = "误差体系名称", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "参照标准名称", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DeviceValidMessage.STANDARD_NAME_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.STANDARD_NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.STANDARD_NAME_FORMAT_ERROR)
|
||||
private String standardName;
|
||||
|
||||
@ApiModelProperty(value = "标准实施年份", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_TIME_NOT_BLANK)
|
||||
@DateTimeStrValid(format = "yyyy", message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.STANDARD_TIME_NOT_BLANK)
|
||||
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
private String standardTime;
|
||||
|
||||
@ApiModelProperty(value = "设备等级", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.DEV_LEVEL_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_LEVEL_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.DEV_LEVEL_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_LEVEL_FORMAT_ERROR)
|
||||
private String devLevel;
|
||||
|
||||
@ApiModelProperty("状态")
|
||||
@NotNull(message = DeviceValidMessage.ENABLE_NOT_NULL)
|
||||
@Min(value = 0, message = DeviceValidMessage.ENABLE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DeviceValidMessage.ENABLE_FORMAT_ERROR)
|
||||
@NotNull(message = DevValidMessage.ENABLE_NOT_NULL)
|
||||
@Min(value = 0, message = DevValidMessage.ENABLE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DevValidMessage.ENABLE_FORMAT_ERROR)
|
||||
private Integer enable;
|
||||
|
||||
@ApiModelProperty(value = "误差详情列表", required = true)
|
||||
@@ -53,11 +53,11 @@ public class PqErrSysParam {
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("标准实施年份")
|
||||
@DateTimeStrValid(format = "yyyy", message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
private String standardTime;
|
||||
|
||||
@ApiModelProperty("设备等级")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_LEVEL_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_LEVEL_FORMAT_ERROR)
|
||||
private String devLevel;
|
||||
}
|
||||
|
||||
@@ -65,8 +65,8 @@ public class PqErrSysParam {
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public static class UpdateParam extends PqErrSysParam {
|
||||
@ApiModelProperty("id")
|
||||
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,11 +2,12 @@ package com.njcn.gather.device.err.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
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.vo.PqErrSysDtlsVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -56,6 +57,13 @@ public interface IPqErrSysService extends IService<PqErrSys> {
|
||||
|
||||
List<PqErrSysDtlsVO> getDetail(String id);
|
||||
|
||||
/**
|
||||
* 获取所有误差体系
|
||||
*
|
||||
* @return 误差体系列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllPqErrSys();
|
||||
|
||||
/**
|
||||
* 复制误差体系
|
||||
*
|
||||
|
||||
@@ -14,7 +14,7 @@ import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.device.err.pojo.vo.PqErrSysDtlsVO;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
|
||||
import com.njcn.gather.device.pojo.enums.DevResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
@@ -110,6 +110,18 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listAllPqErrSys() {
|
||||
List<PqErrSys> pqErrSysList = this.lambdaQuery().eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqErrSysList.stream().map(pqErrSys -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqErrSys.getId());
|
||||
map.put("name", pqErrSys.getName());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* 将检测项可视化
|
||||
*
|
||||
@@ -159,7 +171,7 @@ public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> i
|
||||
if (ObjectUtil.isNotNull(devLevelDictData)) {
|
||||
return param.getStandardName() + "-" + param.getStandardTime() + "-" + devLevelDictData.getName();
|
||||
}
|
||||
throw new BusinessException(DeviceResponseEnum.PQ_ERRSYS_GEN_NAME_ERROR);
|
||||
throw new BusinessException(DevResponseEnum.PQ_ERRSYS_GEN_NAME_ERROR);
|
||||
}
|
||||
|
||||
// @Override
|
||||
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.njcn.gather.device.monitor.controller;
|
||||
|
||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import io.swagger.annotations.Api;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-12
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "监测点管理")
|
||||
@RestController
|
||||
@RequestMapping("/pqMonitor")
|
||||
@RequiredArgsConstructor
|
||||
public class PqMonitorController extends BaseController {
|
||||
private final IPqMonitorService pqMonitorService;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.monitor.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-12
|
||||
*/
|
||||
public interface PqMonitorMapper extends MPJBaseMapper<PqMonitor> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.monitor.mapper.PqMonitorMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.njcn.gather.device.monitor.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-12
|
||||
*/
|
||||
@Data
|
||||
public class PqMonitorParam {
|
||||
|
||||
@ApiModelProperty(value = "谐波系统监测点ID")
|
||||
private String code;
|
||||
|
||||
@ApiModelProperty(value = "所属设备ID")
|
||||
@NotBlank(message = DevValidMessage.DEVICE_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEVICE_ID_FORMAT_ERROR)
|
||||
private String devId;
|
||||
|
||||
@ApiModelProperty(value = "所属母线")
|
||||
@NotBlank(message = DevValidMessage.BELONG_LINE_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 监测点序号
|
||||
*/
|
||||
// private Integer num;
|
||||
|
||||
@ApiModelProperty(value = "PT变比")
|
||||
@NotNull(message = DevValidMessage.PT_NOT_NULL)
|
||||
private Float pt;
|
||||
|
||||
@ApiModelProperty(value = "CT变比")
|
||||
@NotNull(message = DevValidMessage.CT_NOT_NULL)
|
||||
private Float ct;
|
||||
|
||||
/**
|
||||
* 接线方式,字典表
|
||||
*/
|
||||
@ApiModelProperty(value = "接线方式")
|
||||
@NotBlank(message = DevValidMessage.WIRING_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.WIRING_TYPE_FORMAT_ERROR)
|
||||
private String ptType;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends PqMonitorParam {
|
||||
@ApiModelProperty(value = "监测点ID")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.gather.device.monitor.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-12
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_monitor")
|
||||
public class PqMonitor extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -97606920356561872L;
|
||||
/**
|
||||
* 监测点ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 默认与谐波系统监测点ID相同
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 所属设备ID
|
||||
*/
|
||||
private String devId;
|
||||
|
||||
/**
|
||||
* 所属母线
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 监测点序号
|
||||
*/
|
||||
private Integer num;
|
||||
|
||||
/**
|
||||
* PT变比
|
||||
*/
|
||||
private Float pt;
|
||||
|
||||
/**
|
||||
* CT变比
|
||||
*/
|
||||
private Float ct;
|
||||
|
||||
/**
|
||||
* 接线方式,字典表
|
||||
*/
|
||||
private String ptType;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,48 @@
|
||||
package com.njcn.gather.device.monitor.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-12
|
||||
*/
|
||||
public interface IPqMonitorService extends IService<PqMonitor> {
|
||||
|
||||
/**
|
||||
* 根据设备id获取所有监测点信息
|
||||
*
|
||||
* @param devId 被检设备id
|
||||
* @return 监测点信息列表
|
||||
*/
|
||||
List<PqMonitor> listPqMonitorByDevId(String devId);
|
||||
|
||||
/**
|
||||
* 批量新增监测点信息
|
||||
*
|
||||
* @param devId 被检设备id
|
||||
* @param pqMonitorParamList 监测点信息列表
|
||||
* @return 新增成功返回true,否则返回false
|
||||
*/
|
||||
boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList);
|
||||
|
||||
/**
|
||||
* 批量删除监测点信息
|
||||
*
|
||||
* @param devId 被检设备id
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
boolean deletePqMonitorByDevId(String devId);
|
||||
|
||||
/**
|
||||
* 修改监测点信息
|
||||
*
|
||||
* @param devId 被检设备id
|
||||
* @param paramList 监测点信息
|
||||
* @return 修改成功返回true,否则返回false
|
||||
*/
|
||||
boolean updatePqMonitor(String devId, List<PqMonitorParam.UpdateParam> paramList);
|
||||
}
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.gather.device.monitor.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.monitor.mapper.PqMonitorMapper;
|
||||
import com.njcn.gather.device.monitor.pojo.param.PqMonitorParam;
|
||||
import com.njcn.gather.device.monitor.pojo.po.PqMonitor;
|
||||
import com.njcn.gather.device.monitor.service.IPqMonitorService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-12
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqMonitorServiceImpl extends ServiceImpl<PqMonitorMapper, PqMonitor> implements IPqMonitorService {
|
||||
|
||||
@Override
|
||||
public List<PqMonitor> listPqMonitorByDevId(String devId) {
|
||||
return this.lambdaQuery().eq(PqMonitor::getDevId, devId).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqMonitorByDevId(String devId, List<PqMonitorParam> pqMonitorParamList) {
|
||||
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(pqMonitorParamList, PqMonitor.class);
|
||||
pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId));
|
||||
return this.saveBatch(pqMonitorList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqMonitorByDevId(String devId) {
|
||||
QueryWrapper<PqMonitor> wrapper = new QueryWrapper<>();
|
||||
wrapper.eq("pq_monitor.Dev_Id", devId);
|
||||
return this.remove(wrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqMonitor(String devId, List<PqMonitorParam.UpdateParam> paramList) {
|
||||
// 先删除原有数据
|
||||
this.deletePqMonitorByDevId(devId);
|
||||
// 再添加新数据
|
||||
List<PqMonitor> pqMonitorList = BeanUtil.copyToList(paramList, PqMonitor.class);
|
||||
pqMonitorList.forEach(pqMonitor -> pqMonitor.setDevId(devId));
|
||||
return this.saveBatch(pqMonitorList);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,135 @@
|
||||
package com.njcn.gather.device.plan.controller;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "检测计划管理")
|
||||
@RestController
|
||||
@RequestMapping("/adPlan")
|
||||
@RequiredArgsConstructor
|
||||
public class AdPlanController extends BaseController {
|
||||
|
||||
private final IAdPlanService adPlanService;
|
||||
private final IPqDevService pqDevService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询检测计划")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<AdPlanVO>> list(@RequestBody @Validated AdPlanParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<AdPlanVO> result = adPlanService.listAdPlan(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测计划")
|
||||
@ApiImplicitParam(name = "pqDevParam", value = "检测计划", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated AdPlanParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
boolean result = adPlanService.addAdPlan(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改检测计划")
|
||||
@ApiImplicitParam(name = "updateParam", value = "检测计划", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated AdPlanParam.UpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = adPlanService.updateAdPlan(updateParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除检测计划")
|
||||
@ApiImplicitParam(name = "ids", value = "检测计划id", required = true)
|
||||
public HttpResult<Object> delete(@RequestBody List<String> ids) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除ID数据为:{}", methodDescribe, String.join(StrUtil.COMMA, ids));
|
||||
boolean result = adPlanService.deleteAdPlan(ids);
|
||||
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 AdPlanParam.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);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/listByPattern")
|
||||
@ApiOperation("按照模式查询检测计划")
|
||||
@ApiImplicitParam(name = "pattern", value = "模式Id", required = true)
|
||||
public HttpResult<List<Map<String, Object>>> listByPattern(@RequestParam("pattern") String pattern) {
|
||||
String methodDescribe = getMethodDescribe("listByPattern");
|
||||
LogUtil.njcnDebug(log, "{},模式Id为:{}", methodDescribe, pattern);
|
||||
List<Map<String, Object>> result = adPlanService.listByPattern(pattern);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getPieData")
|
||||
@ApiOperation("获取饼状图数据")
|
||||
@ApiImplicitParam(name = "id", value = "检测计划id", required = true)
|
||||
public HttpResult<List<List<Map<String, Object>>>> getPieData(@RequestParam("planId") String planId) {
|
||||
String methodDescribe = getMethodDescribe("getPieData");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
List<List<Map<String, Object>>> result = pqDevService.getPieData(planId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.plan.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface AdPlanMapper extends MPJBaseMapper<AdPlan> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.njcn.gather.device.plan.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface AdPlanSourceMapper extends MPJBaseMapper<AdPlanSource> {
|
||||
|
||||
/**
|
||||
* 根据检测计划id获取检测源
|
||||
*
|
||||
* @param planId 检测计划id
|
||||
* @return 检测源列表
|
||||
*/
|
||||
List<PqSource> selectPqSourceByPlanId(String planId);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.plan.mapper.AdPlanMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.device.plan.mapper.AdPlanSourceMapper">
|
||||
|
||||
|
||||
<select id="selectPqSourceByPlanId" resultType="com.njcn.gather.device.source.pojo.po.PqSource">
|
||||
SELECT pq_source.*
|
||||
FROM pq_source,
|
||||
ad_plan_source
|
||||
WHERE pq_source.id = ad_plan_source.Source_Id
|
||||
AND ad_plan_source.Plan_Id = #{planId}
|
||||
</select>
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,142 @@
|
||||
package com.njcn.gather.device.plan.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-09
|
||||
*/
|
||||
@Data
|
||||
public class AdPlanParam {
|
||||
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.PLAN_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "模式", required = true)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
// @ApiModelProperty(value = "父计划ID")
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
// private String fatherPlanId;
|
||||
|
||||
@ApiModelProperty(value = "检测源ID列表",required = true)
|
||||
@NotEmpty(message = DevValidMessage.SOURCE_IDS_NOT_EMPTY)
|
||||
private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.SOURCE_ID_FORMAT_ERROR)String> sourceIds;
|
||||
|
||||
@ApiModelProperty(value = "数据源ID列表", required = true)
|
||||
@NotEmpty(message = DevValidMessage.DATASOURCE_ID_NOT_EMPTY)
|
||||
private List<@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DATASOURCE_ID_FORMAT_ERROR)String> datasourceIds;
|
||||
|
||||
@ApiModelProperty(value = "检测脚本ID", required = true)
|
||||
@NotBlank(message = DevValidMessage.SCRIPT_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.SCRIPT_ID_FORMAT_ERROR)
|
||||
private String scriptId;
|
||||
|
||||
@ApiModelProperty(value = "误差体系ID", required = true)
|
||||
@NotBlank(message = DevValidMessage.ERROR_SYS_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ERROR_SYS_ID_FORMAT_ERROR)
|
||||
private String errorSysId;
|
||||
|
||||
@ApiModelProperty(value = "守时检测")
|
||||
@NotNull(message = DevValidMessage.TIME_CHECK_NOT_NULL)
|
||||
@Min(value = 0, message = DevValidMessage.TIME_CHECK_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DevValidMessage.TIME_CHECK_FORMAT_ERROR)
|
||||
private Integer timeCheck;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotNull(message = DevValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> devIds;
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DevValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "模式,字典表(数字、模拟、比对)")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty(value = "检测状态")
|
||||
@Min(value = 0, message = DevValidMessage.TEST_STATE_FORMAT_ERROR)
|
||||
@Max(value = 2, message = DevValidMessage.TEST_STATE_FORMAT_ERROR)
|
||||
private Integer testState;
|
||||
|
||||
@ApiModelProperty(value = "报告生成状态")
|
||||
@Min(value = 0, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
@Max(value = 2, message = DevValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
private Integer reportState;
|
||||
|
||||
@ApiModelProperty(value = "检测结果")
|
||||
@Min(value = 0, message = DevValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
|
||||
@Max(value = 2, message = DevValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
|
||||
private Integer result;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends AdPlanParam {
|
||||
@ApiModelProperty(value = "id", required = true)
|
||||
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测状态,字典表(未检、检测中、检测完成)
|
||||
*/
|
||||
// @ApiModelProperty(value = "检测状态")
|
||||
// @NotNull(message = DeviceValidMessage.TEST_STATE_NOT_NULL)
|
||||
// @Min(value = 0, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR)
|
||||
// @Max(value = 2, message = DeviceValidMessage.TEST_STATE_FORMAT_ERROR)
|
||||
// private Integer testState;
|
||||
|
||||
/**
|
||||
* 报告生成状态,字典表(未生成、部分生成、全部生成)
|
||||
*/
|
||||
// @ApiModelProperty(value = "报告生成状态")
|
||||
// @NotNull(message = DeviceValidMessage.REPORT_STATE_NOT_NULL)
|
||||
// @Min(value = 0, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
// @Max(value = 2, message = DeviceValidMessage.REPORT_STATE_FORMAT_ERROR)
|
||||
// private Integer reportState;
|
||||
|
||||
/**
|
||||
* 检测结果,字典表(符合、不符合、/)
|
||||
*/
|
||||
// @ApiModelProperty(value = "检测结果")
|
||||
// @NotNull(message = DeviceValidMessage.CHECK_RESULT_STATE_NOT_NULL)
|
||||
// @Min(value = 0, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
|
||||
// @Max(value = 2, message = DeviceValidMessage.CHECK_RESULT_STATE_FORMAT_ERROR)
|
||||
// private Integer result;
|
||||
}
|
||||
|
||||
@Data
|
||||
@AllArgsConstructor
|
||||
public static class BindPlanParam {
|
||||
@ApiModelProperty("检测计划ID")
|
||||
@NotNull(message = DevValidMessage.PLAN_ID_NOT_NULL)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PLAN_ID_FORMAT_ERROR)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("被检设备ID列表")
|
||||
@NotNull(message = DevValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> pqDevIds;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package com.njcn.gather.device.plan.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import io.swagger.models.auth.In;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("ad_plan")
|
||||
public class AdPlan extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 923200973006628094L;
|
||||
|
||||
/**
|
||||
* 检测计划ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测计划名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 模式,字典表(数字、模拟、比对)
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 父计划ID
|
||||
*/
|
||||
private String fatherPlanId;
|
||||
|
||||
/**
|
||||
* 数据源ID,字典表
|
||||
*/
|
||||
private String datasourceId;
|
||||
|
||||
/**
|
||||
* 检测脚本ID,关联PQ_Script表
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
/**
|
||||
* 误差体系ID,关联PQ_Error_Sys表
|
||||
*/
|
||||
private String errorSysId;
|
||||
|
||||
/**
|
||||
* 守时检测
|
||||
*/
|
||||
private Integer timeCheck;
|
||||
|
||||
/**
|
||||
* 检测状态,字典表(未检、检测中、检测完成)
|
||||
*/
|
||||
private Integer testState;
|
||||
|
||||
/**
|
||||
* 报告生成状态,字典表(未生成、部分生成、全部生成)
|
||||
*/
|
||||
private Integer reportState;
|
||||
|
||||
/**
|
||||
* 检测结果,字典表(符合、不符合)
|
||||
*/
|
||||
private Integer result;
|
||||
|
||||
/**
|
||||
* 自动生成,用于生成数据表后缀
|
||||
*/
|
||||
private Integer code;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.gather.device.plan.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Data
|
||||
@TableName("ad_plan_source")
|
||||
@AllArgsConstructor
|
||||
public class AdPlanSource implements Serializable {
|
||||
private static final long serialVersionUID = -76292730578149530L;
|
||||
/**
|
||||
* 检测计划表Id
|
||||
*/
|
||||
private String planId;
|
||||
|
||||
/**
|
||||
* 检测源表Id
|
||||
*/
|
||||
private String sourceId;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.njcn.gather.device.plan.pojo.vo;
|
||||
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-09
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public class AdPlanVO extends AdPlan {
|
||||
|
||||
/**
|
||||
* 检测脚本名称
|
||||
*/
|
||||
private String scriptName;
|
||||
|
||||
/**
|
||||
* 误差体系名称
|
||||
*/
|
||||
private String errorSysName;
|
||||
|
||||
/**
|
||||
* 检测源名称
|
||||
*/
|
||||
private String SourceName;
|
||||
|
||||
/**
|
||||
* 数据源名称
|
||||
*/
|
||||
private String datasourceName;
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.njcn.gather.device.plan.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.device.plan.pojo.vo.AdPlanVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface IAdPlanService extends IService<AdPlan> {
|
||||
|
||||
/**
|
||||
* 分页查询检测计划
|
||||
*
|
||||
* @param queryParam 分页查询参数
|
||||
* @return 分页查询结果
|
||||
*/
|
||||
Page<AdPlanVO> listAdPlan(AdPlanParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增检测计划
|
||||
*
|
||||
* @param param 检测计划参数
|
||||
* @return 新增成功则返回true,否则返回false
|
||||
*/
|
||||
boolean addAdPlan(AdPlanParam param);
|
||||
|
||||
/**
|
||||
* 更新检测计划
|
||||
*
|
||||
* @param param 更新参数
|
||||
* @return 更新成功则返回true,否则返回false
|
||||
*/
|
||||
boolean updateAdPlan(AdPlanParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 删除检测计划
|
||||
*
|
||||
* @param ids 检测计划id列表
|
||||
* @return 删除成功则返回true,否则返回false
|
||||
*/
|
||||
boolean deleteAdPlan(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据模式查询检测计划
|
||||
*
|
||||
* @param pattern 模式Id
|
||||
* @return 检测计划列表
|
||||
*/
|
||||
List<Map<String, Object>> listByPattern(String pattern);
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.gather.device.plan.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
public interface IAdPlanSourceService extends IService<AdPlanSource> {
|
||||
/**
|
||||
* 根据检测计划id获取检测源
|
||||
*
|
||||
* @param planId 检测计划id
|
||||
* @return 检测源列表
|
||||
*/
|
||||
List<PqSource> listPqSourceByPlanId(String planId);
|
||||
|
||||
/**
|
||||
* 新增检测计划关联检测源数据
|
||||
*
|
||||
* @param planId 检测计划id
|
||||
* @param sourceIds 检测源id列表
|
||||
* @return 新增成功返回true,否则返回false
|
||||
*/
|
||||
boolean addAdPlanSource(String planId, List<String> sourceIds);
|
||||
|
||||
/**
|
||||
* 根据检测计划id删除关联的检测源数据
|
||||
*
|
||||
* @param planIds 检测计划id列表
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
boolean deleteAdPlanSourceByPlanIds(List<String> planIds);
|
||||
|
||||
/**
|
||||
* 更新检测计划关联的检测源数据
|
||||
*
|
||||
* @param planId 检测计划id
|
||||
* @param sourceIds 检测源id列表
|
||||
* @return 更新成功返回true,否则返回false
|
||||
*/
|
||||
boolean updateAdPlanSource(String planId, List<String> sourceIds);
|
||||
}
|
||||
@@ -0,0 +1,179 @@
|
||||
package com.njcn.gather.device.plan.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.device.device.service.IPqDevService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
import com.njcn.gather.device.plan.mapper.AdPlanMapper;
|
||||
import com.njcn.gather.device.plan.pojo.param.AdPlanParam;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlan;
|
||||
import com.njcn.gather.device.plan.pojo.vo.AdPlanVO;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanService;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanSourceService;
|
||||
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.script.service.IPqScriptService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.lang3.ObjectUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdPlanServiceImpl extends ServiceImpl<AdPlanMapper, AdPlan> implements IAdPlanService {
|
||||
|
||||
private final IPqScriptService pqScriptService;
|
||||
private final IPqErrSysService pqErrSysService;
|
||||
private final IAdPlanSourceService adPlanSourceService;
|
||||
private final IDictDataService dictDataService;
|
||||
private final IPqDevService pqDevService;
|
||||
|
||||
@Override
|
||||
public Page<AdPlanVO> listAdPlan(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());
|
||||
Page<AdPlan> page1 = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
List<AdPlan> adPlans = page1.getRecords();
|
||||
List<AdPlanVO> adPlanVOList = BeanUtil.copyToList(adPlans, AdPlanVO.class);
|
||||
adPlanVOList.forEach(adPlanVO -> {
|
||||
adPlanVO.setScriptName(pqScriptService.getPqScriptById(adPlanVO.getScriptId()).getName());
|
||||
adPlanVO.setErrorSysName(pqErrSysService.getPqErrSysById(adPlanVO.getErrorSysId()).getName());
|
||||
|
||||
List<PqSource> pqSourceList = adPlanSourceService.listPqSourceByPlanId(adPlanVO.getId());
|
||||
StringBuilder sb = new StringBuilder();
|
||||
pqSourceList.forEach(pqSource -> {
|
||||
sb.append(pqSource.getName()).append(StrUtil.COMMA);
|
||||
});
|
||||
adPlanVO.setSourceName(sb.toString().substring(0, sb.length() - 1));
|
||||
|
||||
sb.delete(0, sb.length());
|
||||
|
||||
String[] dataSourceIds = adPlanVO.getDatasourceId().split(StrUtil.COMMA);
|
||||
for (String dataSourceId : dataSourceIds) {
|
||||
sb.append(dictDataService.getDictDataById(dataSourceId).getName()).append(StrUtil.COMMA);
|
||||
}
|
||||
adPlanVO.setDatasourceName(sb.toString().substring(0, sb.length() - 1));
|
||||
});
|
||||
|
||||
Page<AdPlanVO> page2 = new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam));
|
||||
page2.setTotal(page1.getTotal());
|
||||
page2.setOrders(page1.orders());
|
||||
page2.setPages(page1.getPages());
|
||||
page2.setRecords(adPlanVOList);
|
||||
return page2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAdPlan(AdPlanParam param) {
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
|
||||
String planId = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
adPlan.setId(planId);
|
||||
adPlan.setState(DataStateEnum.ENABLE.getCode());
|
||||
adPlan.setFatherPlanId(DevConst.FATHER_ID);
|
||||
adPlan.setDatasourceId(String.join(StrUtil.COMMA, param.getDatasourceIds()));
|
||||
adPlan.setTestState(CheckStateEnum.UNCHECKED.getValue());
|
||||
adPlan.setReportState(PlanReportStateEnum.REPORT_STATE_NOT_GENERATED.getValue());
|
||||
adPlan.setResult(CheckResultEnum.UNKNOWN.getValue());
|
||||
// todo code 生成
|
||||
// 日期生成 MMdd
|
||||
//String dateStr = DateFormatUtils.format(new Date(), "MMdd");
|
||||
adPlan.setCode(this.count() + 1);
|
||||
|
||||
// 新增检测计划、检测源关联
|
||||
adPlanSourceService.addAdPlanSource(planId, param.getSourceIds());
|
||||
|
||||
// 新增时,绑定设备
|
||||
pqDevService.bind(new AdPlanParam.BindPlanParam(planId, param.getDevIds()));
|
||||
|
||||
return this.save(adPlan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateAdPlan(AdPlanParam.UpdateParam param) {
|
||||
AdPlan adPlan = new AdPlan();
|
||||
BeanUtil.copyProperties(param, adPlan);
|
||||
|
||||
adPlan.setDatasourceId(String.join(StrUtil.COMMA, param.getDatasourceIds()));
|
||||
|
||||
// 修改检测计划、检测源关联
|
||||
adPlanSourceService.updateAdPlanSource(param.getId(), param.getSourceIds());
|
||||
|
||||
return this.updateById(adPlan);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAdPlan(List<String> ids) {
|
||||
for (String id : ids) {
|
||||
PqDevParam.QueryParam queryParam = new PqDevParam.QueryParam();
|
||||
queryParam.setPlanId(id);
|
||||
if (ObjectUtils.isNotEmpty(pqDevService.listBoundByPlanId(queryParam))) {
|
||||
throw new BusinessException(DevResponseEnum.PLAN_HAS_DEVICE_BIND);
|
||||
}
|
||||
}
|
||||
// 删除检测计划、检测源关联
|
||||
adPlanSourceService.deleteAdPlanSourceByPlanIds(ids);
|
||||
|
||||
return this.lambdaUpdate().in(AdPlan::getId, ids).set(AdPlan::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listByPattern(String pattern) {
|
||||
List<AdPlan> adPlanList = this.lambdaQuery().eq(AdPlan::getPattern, pattern).eq(AdPlan::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
Map<Integer, List<AdPlan>> map1 = adPlanList.stream().collect(Collectors.groupingBy(AdPlan::getTestState));
|
||||
|
||||
List<Map<String, Object>> result = new ArrayList<>();
|
||||
|
||||
for (CheckStateEnum checkStateEnum : CheckStateEnum.values()) {
|
||||
// 检测计划的检测状态中没有 归档 状态
|
||||
if (checkStateEnum.getValue() == CheckStateEnum.DOCUMENTED.getValue()) {
|
||||
continue;
|
||||
}
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", checkStateEnum.getMessage());
|
||||
List<Map<String, Object>> children = new ArrayList<>();
|
||||
if (map1.containsKey(checkStateEnum.getValue())) {
|
||||
map1.get(checkStateEnum.getValue()).forEach(adPlan -> {
|
||||
Map<String, Object> child = new HashMap<>();
|
||||
child.put("id", adPlan.getId());
|
||||
child.put("pid", adPlan.getFatherPlanId());
|
||||
child.put("name", adPlan.getName());
|
||||
children.add(child);
|
||||
});
|
||||
}
|
||||
map.put("children", children);
|
||||
result.add(map);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.gather.device.plan.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.plan.mapper.AdPlanSourceMapper;
|
||||
import com.njcn.gather.device.plan.pojo.po.AdPlanSource;
|
||||
import com.njcn.gather.device.plan.service.IAdPlanSourceService;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-12-09
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class AdPlanSourceServiceImpl extends ServiceImpl<AdPlanSourceMapper, AdPlanSource> implements IAdPlanSourceService {
|
||||
|
||||
private final AdPlanSourceMapper adPlanSourceMapper;
|
||||
|
||||
@Override
|
||||
public List<PqSource> listPqSourceByPlanId(String planId) {
|
||||
return adPlanSourceMapper.selectPqSourceByPlanId(planId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addAdPlanSource(String planId, List<String> sourceIds) {
|
||||
List<AdPlanSource> adPlanSourceList = new ArrayList<>();
|
||||
for (String sourceId : sourceIds) {
|
||||
adPlanSourceList.add(new AdPlanSource(planId, sourceId));
|
||||
}
|
||||
return this.saveBatch(adPlanSourceList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteAdPlanSourceByPlanIds(List<String> planIds) {
|
||||
QueryWrapper<AdPlanSource> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("ad_plan_source.Plan_Id", planIds);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateAdPlanSource(String planId, List<String> sourceIds) {
|
||||
this.deleteAdPlanSourceByPlanIds(Collections.singletonList(planId));
|
||||
this.addAdPlanSource(planId, sourceIds);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@@ -5,59 +5,23 @@ package com.njcn.gather.device.pojo.constant;
|
||||
* @data 2024-12-04
|
||||
*/
|
||||
public interface DevConst {
|
||||
/**
|
||||
* 顶层父节点ID
|
||||
*/
|
||||
String FATHER_ID = "0";
|
||||
|
||||
/**
|
||||
* 模拟式
|
||||
*/
|
||||
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;
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ package com.njcn.gather.device.pojo.constant;
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
public interface DeviceValidMessage {
|
||||
public interface DevValidMessage {
|
||||
|
||||
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||
|
||||
@@ -62,6 +62,10 @@ public interface DeviceValidMessage {
|
||||
|
||||
String PATTERN_FORMAT_ERROR = "模式格式错误,请检查pattern参数";
|
||||
|
||||
String SOURCE_IDS_NOT_EMPTY = "检测源ID不能为空,请检查sourceIds参数";
|
||||
|
||||
String SOURCE_ID_FORMAT_ERROR = "检测源ID格式错误,请检查sourceIds参数";
|
||||
|
||||
String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误,请检查devType参数";
|
||||
|
||||
String DEV_CHNS_RANGE_ERROR = "设备通道系数错误,请检查devChns参数";
|
||||
@@ -130,7 +134,51 @@ public interface DeviceValidMessage {
|
||||
|
||||
String PQ_SOURCE_PARAMETER_VALUE_NOT_BLANK = "参数值不能为空,请检查pqSourceParameterValue参数";
|
||||
|
||||
// String UNIT_NOT_BLANK = "单位不能为空,请检查unit参数";
|
||||
//
|
||||
// String UNIT_FORMAT_ERROR = "单位格式错误,请检查unit参数";
|
||||
String DEVICE_ID_NOT_BLANK = "所属设备ID不能为空,请检查deviceId参数";
|
||||
|
||||
String DEVICE_ID_FORMAT_ERROR = "所属设备ID格式错误,请检查deviceId参数";
|
||||
|
||||
String BELONG_LINE_NOT_BLANK = "所属母线不能为空";
|
||||
|
||||
String PT_NOT_NULL = "PT变比不能为空";
|
||||
|
||||
String CT_NOT_NULL = "CT变比不能为空";
|
||||
|
||||
String WIRING_TYPE_NOT_BLANK = "接线方式不能为空";
|
||||
|
||||
String WIRING_TYPE_FORMAT_ERROR = "接线方式格式错误";
|
||||
|
||||
String DATASOURCE_ID_NOT_EMPTY = "数据源ID不能为空";
|
||||
|
||||
String DATASOURCE_ID_FORMAT_ERROR = "数据源ID格式错误";
|
||||
|
||||
String SCRIPT_ID_NOT_BLANK = "检测脚本ID不能为空";
|
||||
|
||||
String SCRIPT_ID_FORMAT_ERROR = "检测脚本ID格式错误";
|
||||
|
||||
String ERROR_SYS_ID_NOT_BLANK = "误差体系ID不能为空";
|
||||
|
||||
String ERROR_SYS_ID_FORMAT_ERROR = "误差体系ID格式错误";
|
||||
|
||||
String TIME_CHECK_NOT_NULL = "守时检测不能为空";
|
||||
|
||||
String TIME_CHECK_FORMAT_ERROR = "守时检测格式错误";
|
||||
|
||||
String TEST_STATE_NOT_NULL = "检测状态不能为空";
|
||||
|
||||
String TEST_STATE_FORMAT_ERROR = "检测状态格式错误";
|
||||
|
||||
String REPORT_STATE_NOT_NULL = "报告生成状态不能为空";
|
||||
|
||||
String REPORT_STATE_FORMAT_ERROR = "报告生成状态格式错误";
|
||||
|
||||
String CHECK_RESULT_STATE_NOT_NULL = "检测结果不能为空";
|
||||
|
||||
String CHECK_RESULT_STATE_FORMAT_ERROR = "检测结果格式错误";
|
||||
|
||||
String CHECK_STATE_FORMAT_ERROR = "检测状态格式错误";
|
||||
|
||||
String CHECK_RESULT_FORMAT_ERROR = "检测结果格式错误";
|
||||
|
||||
String DOCUMENT_STATE_FORMAT_ERROR = "归档状态格式错误";
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-12
|
||||
*/
|
||||
@Getter
|
||||
public enum CheckResultEnum {
|
||||
NOT_ACCORD("不符合", 0),
|
||||
ACCORD("符合", 1),
|
||||
UNKNOWN("/", 2);
|
||||
|
||||
private final String message;
|
||||
private final Integer value;
|
||||
|
||||
CheckResultEnum(String message, Integer value) {
|
||||
this.message = message;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static String getMsgByValue(Integer value) {
|
||||
for (CheckStateEnum state : CheckStateEnum.values()) {
|
||||
if (state.getValue().equals(value)) {
|
||||
return state.getMessage();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-12
|
||||
*/
|
||||
@Getter
|
||||
public enum CheckStateEnum {
|
||||
UNCHECKED("未检", 0),
|
||||
CHECKING("检测中", 1),
|
||||
CHECKED("检测完成", 2),
|
||||
/**
|
||||
* 检测计划没有该状态,只有未检、检测中、检测完成三种状态。被检设备有这种状态
|
||||
*/
|
||||
DOCUMENTED("归档", 3);
|
||||
|
||||
private final String message;
|
||||
private final Integer value;
|
||||
|
||||
CheckStateEnum(String message, Integer value) {
|
||||
this.message = message;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static String getMsgByValue(Integer value) {
|
||||
for (CheckStateEnum state : CheckStateEnum.values()) {
|
||||
if (state.getValue().equals(value)) {
|
||||
return state.getMessage();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-12
|
||||
*/
|
||||
@Getter
|
||||
public enum DevDocumentStateEnum {
|
||||
UNDOCUMENTED("未归档", 0),
|
||||
DOCUMENTED("归档", 1);
|
||||
|
||||
private final String message;
|
||||
private final Integer value;
|
||||
|
||||
DevDocumentStateEnum(String message, Integer value) {
|
||||
this.message = message;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-12
|
||||
*/
|
||||
@Getter
|
||||
public enum DevReportStateEnum {
|
||||
REPORT_STATE_NOT_GENERATED("未生成", 0),
|
||||
REPORT_STATE_GENERATED("已生成", 1);
|
||||
|
||||
private final String message;
|
||||
private final Integer value;
|
||||
|
||||
DevReportStateEnum(String message, Integer value) {
|
||||
this.message = message;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static String getMsgByValue(Integer value) {
|
||||
for (CheckStateEnum state : CheckStateEnum.values()) {
|
||||
if (state.getValue().equals(value)) {
|
||||
return state.getMessage();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -3,19 +3,20 @@ package com.njcn.gather.device.pojo.enums;
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum DeviceResponseEnum {
|
||||
public enum DevResponseEnum {
|
||||
//NAME_REPEAT("A001001", "名称重复"),
|
||||
|
||||
IMPORT_DATA_FAIL("A001002", "导入数据失败"),
|
||||
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "加密设备的序列号和设备密钥不能为空"),
|
||||
PQ_SOURCE_GEN_NAME_ERROR("A001004", "检测源生成名称出错"),
|
||||
PQ_ERRSYS_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),;
|
||||
PQ_ERRSYS_GEN_NAME_ERROR("A001005", "误差体系生成名称出错"),
|
||||
PLAN_HAS_DEVICE_BIND("A001006", "检测计划下已绑定设备,请先解绑设备");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
DeviceResponseEnum(String code, String message) {
|
||||
DevResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-12
|
||||
*/
|
||||
@Getter
|
||||
public enum PlanReportStateEnum {
|
||||
REPORT_STATE_NOT_GENERATED("未生成", 0),
|
||||
REPORT_STATE_PARTIALLY_GENERATED("部分生成", 1),
|
||||
REPORT_STATE_ALL_GENERATED("全部生成", 2);
|
||||
|
||||
private final String message;
|
||||
private final Integer value;
|
||||
|
||||
PlanReportStateEnum(String message, Integer value) {
|
||||
this.message = message;
|
||||
this.value = value;
|
||||
}
|
||||
}
|
||||
@@ -24,6 +24,7 @@ import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -120,5 +121,16 @@ public class PqScriptController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation("获取指定模式下的所有检测脚本")
|
||||
@ApiImplicitParam(name = "patternId", value = "模式Id", required = true)
|
||||
public HttpResult<List<Map<String, Object>>> getAllPqScript(@RequestParam("patternId") String patternId) {
|
||||
String methodDescribe = getMethodDescribe("getAllPqScript");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId);
|
||||
List<Map<String, Object>> result = pqScriptService.listAllPqScript(patternId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.script.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
@@ -19,21 +19,21 @@ import javax.validation.constraints.*;
|
||||
public class PqScriptParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
@NotNull(message = DeviceValidMessage.SCRIPT_TYPE_NOT_BLANK)
|
||||
@Min(value = 0, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DeviceValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||
@NotNull(message = DevValidMessage.SCRIPT_TYPE_NOT_BLANK)
|
||||
@Min(value = 0, message = DevValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DevValidMessage.SCRIPT_TYPE_FORMAT_ERROR)
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 检测脚本模式,字典表(数字、模拟、比对)
|
||||
*/
|
||||
@ApiModelProperty("模式")
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
@@ -43,14 +43,14 @@ public class PqScriptParam {
|
||||
private String valueType;
|
||||
|
||||
@ApiModelProperty("参照标准名称")
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DeviceValidMessage.STANDARD_NAME_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.STANDARD_NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DevValidMessage.STANDARD_NAME_FORMAT_ERROR)
|
||||
private String standardName;
|
||||
|
||||
|
||||
@ApiModelProperty("标准推行时间")
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_TIME_NOT_BLANK)
|
||||
@DateTimeStrValid(format = "yyyy", message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.STANDARD_TIME_NOT_BLANK)
|
||||
@DateTimeStrValid(format = "yyyy", message = DevValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
private String standardTime;
|
||||
|
||||
@Data
|
||||
@@ -66,8 +66,8 @@ public class PqScriptParam {
|
||||
private String valueType;
|
||||
|
||||
@ApiModelProperty("模式")
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
}
|
||||
|
||||
@@ -75,7 +75,7 @@ public class PqScriptParam {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends PqScriptParam {
|
||||
@ApiModelProperty("检测脚本ID")
|
||||
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
|
||||
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
|
||||
@@ -7,6 +7,8 @@ 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
|
||||
@@ -22,6 +24,14 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
*/
|
||||
Page<PqScript> listPqScript(PqScriptParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 根据检测脚本id获取检测脚本
|
||||
*
|
||||
* @param id 检测脚本id
|
||||
* @return 检测脚本
|
||||
*/
|
||||
PqScript getPqScriptById(String id);
|
||||
|
||||
/**
|
||||
* 新增检测脚本
|
||||
*
|
||||
@@ -52,4 +62,12 @@ public interface IPqScriptService extends IService<PqScript> {
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean upgradeToTemplate(String id);
|
||||
|
||||
/**
|
||||
* 获取指定模式下所有检测脚本
|
||||
*
|
||||
* @param patternId 模式id
|
||||
* @return 检测脚本列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllPqScript(String patternId);
|
||||
}
|
||||
|
||||
@@ -19,7 +19,10 @@ import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -45,6 +48,11 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqScript getPqScriptById(String id) {
|
||||
return this.lambdaQuery().eq(PqScript::getId, id).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqScript(PqScriptParam param) {
|
||||
PqScript pqScript = new PqScript();
|
||||
@@ -81,4 +89,16 @@ public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> i
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listAllPqScript(String patternId) {
|
||||
List<PqScript> pqScriptList = this.lambdaQuery().eq(PqScript::getPattern, patternId).eq(PqScript::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqScriptList.stream().map(pqScript -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqScript.getId());
|
||||
map.put("name", pqScript.getName());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,11 +9,13 @@ import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
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.SourceParam;
|
||||
import com.njcn.gather.device.source.service.IPqSourceService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
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;
|
||||
@@ -21,6 +23,7 @@ import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
@@ -101,5 +104,30 @@ public class PqSourceController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getAll")
|
||||
@ApiOperation("获取指定模式下的所有检测源")
|
||||
@ApiImplicitParam(name = "patternId", value = "模式Id", required = true)
|
||||
public HttpResult<List<Map<String, Object>>> getAllPqSource(@RequestParam("patternId") String patternId) {
|
||||
String methodDescribe = getMethodDescribe("getAllPqSource");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, patternId);
|
||||
List<Map<String, Object>> result = pqSourceService.listAllPqSource(patternId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getSourceParam")
|
||||
@ApiOperation("按照检测源ID、源参数Type、获取源参数")
|
||||
@ApiImplicitParams({
|
||||
@ApiImplicitParam(name = "pqSourceId", value = "检测源ID", required = true),
|
||||
@ApiImplicitParam(name = "paramType", value = "源参数Type", required = true)
|
||||
})
|
||||
public HttpResult<List<SourceParam>> getSourceParam(@RequestParam("pqSourceId") String pqSourceId, @RequestParam("paramType") String paramType) {
|
||||
String methodDescribe = getMethodDescribe("getParam");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, pqSourceId + " " + paramType);
|
||||
List<SourceParam> result = pqSourceService.getSourceParam(pqSourceId, paramType);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package com.njcn.gather.device.source.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||
import com.njcn.gather.device.pojo.constant.DevValidMessage;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
@@ -28,24 +28,24 @@ public class PqSourceParam {
|
||||
/**
|
||||
* 检测模式,字典表
|
||||
*/
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 检测源类型,字典表
|
||||
*/
|
||||
@ApiModelProperty(value = "检测源类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.PQ_SOURCE_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PQ_SOURCE_TYPE_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PQ_SOURCE_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PQ_SOURCE_TYPE_FORMAT_ERROR)
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 设备类型,字典表
|
||||
*/
|
||||
@ApiModelProperty(value = "设备类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty("源参数")
|
||||
@@ -60,16 +60,16 @@ public class PqSourceParam {
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("模式")
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty(value = "检测源类型")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PQ_SOURCE_TYPE_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.PQ_SOURCE_TYPE_FORMAT_ERROR)
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "设备类型")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
private String devType;
|
||||
}
|
||||
|
||||
@@ -77,8 +77,8 @@ public class PqSourceParam {
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends PqSourceParam {
|
||||
@ApiModelProperty(value = "检测源ID", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||
@NotBlank(message = DevValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DevValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.njcn.gather.device.source.pojo.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-09
|
||||
*/
|
||||
@Data
|
||||
public class SourceParam {
|
||||
private String id;
|
||||
|
||||
private String pId;
|
||||
|
||||
private String sourceParamType;
|
||||
|
||||
private String sourceParamDesc;
|
||||
|
||||
private String sourceParamValue;
|
||||
|
||||
private Integer sort;
|
||||
|
||||
private List<SourceParam> children;
|
||||
}
|
||||
@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
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.SourceParam;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -52,4 +54,21 @@ public interface IPqSourceService extends IService<PqSource> {
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqSource(List<String> ids);
|
||||
|
||||
/**
|
||||
* 获取指定模式下的所有检测源
|
||||
*
|
||||
* @param patternId 模式Id
|
||||
* @return 检测源列表
|
||||
*/
|
||||
List<Map<String, Object>> listAllPqSource(String patternId);
|
||||
|
||||
/**
|
||||
* 获取指定检测源的指定参数
|
||||
*
|
||||
* @param pqSourceId 检测源Id
|
||||
* @param paramType 参数类型
|
||||
* @return 源参数
|
||||
*/
|
||||
List<SourceParam> getSourceParam(String pqSourceId, String paramType);
|
||||
}
|
||||
|
||||
@@ -3,15 +3,18 @@ package com.njcn.gather.device.source.service.impl;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONArray;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.enums.DeviceResponseEnum;
|
||||
import com.njcn.gather.device.pojo.constant.DevConst;
|
||||
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;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
import com.njcn.gather.device.source.pojo.po.SourceParam;
|
||||
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;
|
||||
@@ -19,8 +22,13 @@ import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.Comparator;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
@@ -75,6 +83,72 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Map<String, Object>> listAllPqSource(String patternId) {
|
||||
List<PqSource> pqSourceList = this.lambdaQuery().eq(PqSource::getPattern, patternId).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).list();
|
||||
List<Map<String, Object>> result = pqSourceList.stream().map(pqSource -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("id", pqSource.getId());
|
||||
map.put("name", pqSource.getName());
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<SourceParam> getSourceParam(String pqSourceId, String paramType) {
|
||||
PqSource pqSource = this.lambdaQuery().eq(PqSource::getId, pqSourceId).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (ObjectUtil.isNotNull(pqSource)) {
|
||||
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))
|
||||
.peek(p -> p.setChildren(getChildren(p, list)))
|
||||
.sorted(Comparator.comparingInt(SourceParam::getSort))
|
||||
.collect(Collectors.toList());
|
||||
return filterTree(sourceParams, paramType);
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private List<SourceParam> getChildren(SourceParam current, List<SourceParam> list) {
|
||||
return list.stream()
|
||||
.filter(p -> p.getPId().equals(current.getId()))
|
||||
.peek(p -> p.setChildren(getChildren(p, list)))
|
||||
.sorted(Comparator.comparingInt(SourceParam::getSort))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
private List<SourceParam> filterTree(List<SourceParam> tree, String keyword) {
|
||||
if (CollectionUtils.isEmpty(tree) || StrUtil.isBlank(keyword)) {
|
||||
return tree;
|
||||
}
|
||||
filter(tree, keyword);
|
||||
return tree;
|
||||
}
|
||||
|
||||
private void filter(List<SourceParam> list, String keyword) {
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
SourceParam sourceParam = list.get(i);
|
||||
List<SourceParam> children = sourceParam.getChildren();
|
||||
if (!keyword.equals(sourceParam.getSourceParamType())) {
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
filter(children, keyword);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(sourceParam.getChildren())) {
|
||||
list.remove(i);
|
||||
}
|
||||
}
|
||||
// else {
|
||||
// if (!CollectionUtils.isEmpty(children)) {
|
||||
// filter(children, keyword);
|
||||
// }
|
||||
// }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 生成检测源名称(检测源类型+设备类型+数字)
|
||||
*
|
||||
@@ -99,6 +173,6 @@ public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> i
|
||||
}
|
||||
}
|
||||
}
|
||||
throw new BusinessException(DeviceResponseEnum.PQ_SOURCE_GEN_NAME_ERROR);
|
||||
throw new BusinessException(DevResponseEnum.PQ_SOURCE_GEN_NAME_ERROR);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,6 +33,12 @@
|
||||
<artifactId>user</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.aspectj</groupId>
|
||||
<artifactId>aspectjweaver</artifactId>
|
||||
<version>1.9.6</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||
import com.njcn.gather.system.dictionary.mapper.DictPqMapper;
|
||||
import com.njcn.gather.system.dictionary.pojo.param.DictPqParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictPq;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictPqService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
@@ -28,6 +29,8 @@ import java.util.List;
|
||||
@RequiredArgsConstructor
|
||||
public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> implements IDictPqService {
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@Override
|
||||
public Page<DictPq> listDictPqs(DictPqParam.QueryParam queryParam) {
|
||||
QueryWrapper<DictPq> queryWrapper = new QueryWrapper<>();
|
||||
@@ -71,6 +74,7 @@ public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> impleme
|
||||
|
||||
@Override
|
||||
public boolean deleteDictPq(List<String> ids) {
|
||||
dictDataService.deleteDictDataByDictTypeId(ids);
|
||||
return this.lambdaUpdate()
|
||||
.set(DictPq::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(DictPq::getId, ids)
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
package com.njcn.gather.system.log.aop;
|
||||
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.google.common.util.concurrent.ThreadFactoryBuilder;
|
||||
import com.njcn.common.bean.CustomCacheUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.db.mybatisplus.constant.UserConstant;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
import com.njcn.gather.system.log.service.ISysLogAuditService;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.aspectj.lang.ProceedingJoinPoint;
|
||||
import org.aspectj.lang.annotation.Around;
|
||||
import org.aspectj.lang.annotation.Aspect;
|
||||
import org.aspectj.lang.annotation.Pointcut;
|
||||
import org.aspectj.lang.reflect.MethodSignature;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-2
|
||||
*/
|
||||
|
||||
@Aspect
|
||||
@Component
|
||||
@Slf4j
|
||||
@RequiredArgsConstructor
|
||||
public class LogAdvice implements ApplicationListener<ContextRefreshedEvent> {
|
||||
|
||||
private final ISysLogAuditService sysLogAuditService;
|
||||
|
||||
private BlockingQueue<SysLogAudit> logQueue = new LinkedBlockingDeque<>();
|
||||
|
||||
@Pointcut(value = "execution(* com.njcn.gather..controller.*(..))")
|
||||
public void logPointcut() {
|
||||
}
|
||||
|
||||
@Around("logPointcut()")
|
||||
public Object around(ProceedingJoinPoint joinPoint) throws Throwable {
|
||||
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
|
||||
String username = customCacheUtil.get(UserConstant.USER_NAME, false);
|
||||
// String operationType = "";
|
||||
// String operateResult = "成功";
|
||||
// Integer level = 0;
|
||||
// Integer warn = 0;
|
||||
|
||||
Object result = null;
|
||||
try {
|
||||
result = joinPoint.proceed();
|
||||
addLogToQueue(joinPoint, username, "操作日志", "成功", 0, 0);
|
||||
} catch (Throwable e) {
|
||||
addLogToQueue(joinPoint, username, "告警日志", "失败", 1, 1);
|
||||
throw e;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
private void addLogToQueue(ProceedingJoinPoint joinPoint, String username, String operationType, String result, Integer level, Integer warn) {
|
||||
SysLogAudit sysLogAudit = new SysLogAudit();
|
||||
sysLogAudit.setCreateBy(username);
|
||||
sysLogAudit.setOperateType(operationType);
|
||||
sysLogAudit.setLevel(level);
|
||||
sysLogAudit.setWarn(warn);
|
||||
|
||||
HttpServletRequest request = HttpServletUtil.getRequest();
|
||||
sysLogAudit.setIp(request.getRemoteAddr());
|
||||
|
||||
MethodSignature signature = (MethodSignature) joinPoint.getSignature();
|
||||
Method method = signature.getMethod();
|
||||
ApiOperation apiOperation = method.getAnnotation(ApiOperation.class);
|
||||
OperateInfo operateInfo = method.getAnnotation(OperateInfo.class);
|
||||
if (operateInfo != null) {
|
||||
//注解上的操作类型
|
||||
sysLogAudit.setResult(operateInfo.operateType() + result);
|
||||
}
|
||||
if (apiOperation != null) {
|
||||
//注解上的描述
|
||||
sysLogAudit.setRemark(apiOperation.value());
|
||||
}
|
||||
//Object[] args = joinPoint.getArgs();
|
||||
logQueue.add(sysLogAudit);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onApplicationEvent(ContextRefreshedEvent contextRefreshedEvent) {
|
||||
ExecutorService pool = new ThreadPoolExecutor(1, 1,
|
||||
0L, TimeUnit.SECONDS,
|
||||
new LinkedBlockingQueue<>(),
|
||||
new ThreadFactoryBuilder().setNameFormat("Save-Logs-%d").setDaemon(true).build());
|
||||
pool.submit(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
while (true) {
|
||||
try {
|
||||
SysLogAudit log = logQueue.poll(5, TimeUnit.MILLISECONDS);
|
||||
if (log != null) {
|
||||
sysLogAuditService.save(log);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("insert operation log to db error", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.njcn.gather.system.log.controller;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.enums.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.system.log.pojo.param.SysLogParam;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
import com.njcn.gather.system.log.service.ISysLogAuditService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "日志管理")
|
||||
@RestController
|
||||
@RequestMapping("/sysLog")
|
||||
@RequiredArgsConstructor
|
||||
public class SysLogController extends BaseController {
|
||||
private final ISysLogAuditService sysLogAuditService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation(value = "获取日志列表")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<SysLogAudit>> list(@RequestBody @Validated SysLogParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
Page<SysLogAudit> result = sysLogAuditService.listSysLogAudit(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出csv文件")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated SysLogParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
sysLogAuditService.exportSysLogAuditData(param);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.system.log.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
public interface SysLogAuditMapper extends MPJBaseMapper<SysLogAudit> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.system.log.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogRun;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
public interface SysLogRunMapper extends MPJBaseMapper<SysLogRun> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.system.log.mapper.SysLogAuditMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.njcn.gather.system.log.mapper.SysLogRunMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.njcn.gather.system.log.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-25
|
||||
*/
|
||||
@Data
|
||||
public class SysLogParam {
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("操作类型")
|
||||
private String operateType;
|
||||
|
||||
@ApiModelProperty("操作用户")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.USER_ID_FORMAT_ERROR)
|
||||
private String createBy;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.njcn.gather.system.log.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldFill;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_log_audit")
|
||||
public class SysLogAudit implements Serializable {
|
||||
private static final long serialVersionUID = -56962081010894238L;
|
||||
/**
|
||||
* 审计日志Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 操作类型
|
||||
*/
|
||||
private String operateType;
|
||||
|
||||
/**
|
||||
* IP
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 事件结果
|
||||
*/
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* 事件描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 事件严重度(0.普通 1.中等 2.严重)
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 告警标志(0:未告警;1:已告警),默认未告警
|
||||
*/
|
||||
private Integer warn;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
@TableField(fill = FieldFill.INSERT)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
@JsonDeserialize(using = LocalDateTimeDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateTimeSerializer.class)
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.njcn.gather.system.log.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
@Data
|
||||
@TableName("sys_log_run")
|
||||
public class SysLogRun implements Serializable {
|
||||
private static final long serialVersionUID = -37126398654461376L;
|
||||
/**
|
||||
* 运行日志Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 类型(数据源、被检设备)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* IP
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 事件结果
|
||||
*/
|
||||
private String result;
|
||||
|
||||
/**
|
||||
* 事件描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 告警标志(0:未告警;1:已告警),默认未告警
|
||||
*/
|
||||
private Integer warn;
|
||||
|
||||
/**
|
||||
* 创建用户
|
||||
*/
|
||||
private String createBy;
|
||||
|
||||
/**
|
||||
* 创建时间
|
||||
*/
|
||||
private LocalDateTime createTime;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,42 @@
|
||||
package com.njcn.gather.system.log.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-25
|
||||
*/
|
||||
@Data
|
||||
public class SysLogVO {
|
||||
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 操作类型,审计日志独有字段。
|
||||
*/
|
||||
private String operateType;
|
||||
|
||||
/**
|
||||
* 类型(数据源、被检设备),运行日志独有字段。
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private String ip;
|
||||
|
||||
private String result;
|
||||
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 事件严重度(0.普通 1.中等 2.严重),审计日志独有字段。
|
||||
*/
|
||||
private Integer level;
|
||||
|
||||
private Integer warn;
|
||||
|
||||
private String createBy;
|
||||
|
||||
private LocalDateTime createTime;
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.njcn.gather.system.log.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.log.pojo.param.SysLogParam;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
import com.njcn.gather.system.log.pojo.vo.SysLogVO;
|
||||
import org.aspectj.lang.JoinPoint;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
public interface ISysLogAuditService extends IService<SysLogAudit> {
|
||||
|
||||
/**
|
||||
* 分页查询审计日志
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 分页结果
|
||||
*/
|
||||
Page<SysLogAudit> listSysLogAudit(SysLogParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 导出审计日志数据
|
||||
* @param param 查询参数
|
||||
*/
|
||||
void exportSysLogAuditData(SysLogParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 添加审计日志
|
||||
*
|
||||
* @param sysLogParam
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
//boolean addSysLogAudit(SysLogParam sysLogParam);
|
||||
}
|
||||
@@ -0,0 +1,12 @@
|
||||
package com.njcn.gather.system.log.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogRun;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
public interface ISysLogRunService extends IService<SysLogRun> {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.njcn.gather.system.log.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.system.log.mapper.SysLogAuditMapper;
|
||||
import com.njcn.gather.system.log.pojo.param.SysLogParam;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogAudit;
|
||||
import com.njcn.gather.system.log.service.ISysLogAuditService;
|
||||
import com.njcn.gather.system.log.util.CSVUtil;
|
||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||
import com.njcn.gather.user.user.service.ISysUserService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysLogAuditServiceImpl extends ServiceImpl<SysLogAuditMapper, SysLogAudit> implements ISysLogAuditService {
|
||||
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
@Override
|
||||
public Page<SysLogAudit> listSysLogAudit(SysLogParam.QueryParam param) {
|
||||
QueryWrapper<SysLogAudit> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
queryWrapper.eq(StrUtil.isNotBlank(param.getOperateType()), "sys_log_audit.Operate_Type", param.getOperateType())
|
||||
.eq(StrUtil.isNotBlank(param.getCreateBy()), "sys_log_audit.Create_By", param.getCreateBy())
|
||||
.between(StrUtil.isAllNotBlank(param.getSearchBeginTime(), param.getSearchEndTime()), "sys_log_audit.Create_Time", param.getSearchBeginTime(), param.getSearchEndTime());
|
||||
}
|
||||
queryWrapper.orderByDesc("sys_log_audit.Create_Time");
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportSysLogAuditData(SysLogParam.QueryParam param) {
|
||||
String[] titles = {"日志类型", "IP", "事件结果", "描述", "日志等级", "告警标准", "操作用户", "记录时间"};
|
||||
String[] keys = {"operateType", "ip", "result", "remark", "level", "warn", "createBy", "createTime"};
|
||||
QueryWrapper<SysLogAudit> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
queryWrapper.eq(StrUtil.isNotBlank(param.getOperateType()), "sys_log_audit.Operate_Type", param.getOperateType()).eq(StrUtil.isNotBlank(param.getCreateBy()), "sys_log_audit.Create_By", param.getCreateBy()).between(StrUtil.isAllNotBlank(param.getSearchBeginTime(), param.getSearchEndTime()), "sys_log_audit.Create_Time", param.getSearchBeginTime(), param.getSearchEndTime());
|
||||
}
|
||||
queryWrapper.orderByDesc("sys_log_audit.Create_Time");
|
||||
List<SysLogAudit> list = this.list(queryWrapper);
|
||||
List<Map<String, Object>> data = list.stream().map(item -> {
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("operateType", item.getOperateType());
|
||||
map.put("ip", item.getIp());
|
||||
map.put("result", item.getResult());
|
||||
map.put("remark", item.getRemark());
|
||||
map.put("level", item.getLevel() == 0 ? "普通" : item.getLevel() == 1 ? "中等" : "严重");
|
||||
map.put("warn", item.getWarn() == 0 ? "未告警" : "告警");
|
||||
SysUser user = sysUserService.getById(item.getCreateBy());
|
||||
map.put("createBy", ObjectUtil.isNull(user) ? "" : user.getName());
|
||||
//将 createTime 转换为 yyyy-MM-dd HH:mm:ss 格式
|
||||
map.put("createTime", item.getCreateTime() == null ? "" : item.getCreateTime().toString().replace("T", " "));
|
||||
return map;
|
||||
}).collect(Collectors.toList());
|
||||
SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
CSVUtil.export("日志数据" + sdf.format(new Date()) + ".csv", titles, keys, data);
|
||||
}
|
||||
|
||||
// @Override
|
||||
// public boolean addSysLogAudit(SysLogParam sysLogParam) {
|
||||
// SysLogAudit sysLogAudit = new SysLogAudit();
|
||||
// BeanUtils.copyProperties(sysLogParam, sysLogAudit);
|
||||
// return this.save(sysLogAudit);
|
||||
// }
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.system.log.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.system.log.pojo.po.SysLogRun;
|
||||
import com.njcn.gather.system.log.mapper.SysLogRunMapper;
|
||||
import com.njcn.gather.system.log.service.ISysLogRunService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-29
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysLogRunServiceImpl extends ServiceImpl<SysLogRunMapper, SysLogRun> implements ISysLogRunService {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,125 @@
|
||||
package com.njcn.gather.system.log.util;
|
||||
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
||||
import com.njcn.web.utils.HttpServletUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import javax.servlet.ServletOutputStream;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-12-2
|
||||
*/
|
||||
@Slf4j
|
||||
public class CSVUtil {
|
||||
|
||||
/**
|
||||
* CSV文件列分隔符
|
||||
*/
|
||||
private static final String CSV_COLUMN_SEPARATOR = ",";
|
||||
|
||||
/**
|
||||
* CSV文件行分隔符
|
||||
*/
|
||||
private static final String CSV_ROW_SEPARATOR = System.lineSeparator();
|
||||
|
||||
/**
|
||||
* 导出CSV文件
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @param titles 表头
|
||||
* @param keys 字段名
|
||||
* @param dataList 数据集
|
||||
*/
|
||||
public static void export(String fileName, String[] titles, String[] keys, List<Map<String, Object>> dataList) {
|
||||
// 保证线程安全
|
||||
StringBuffer buf = new StringBuffer();
|
||||
|
||||
// 组装表头
|
||||
for (String title : titles) {
|
||||
buf.append(title).append(CSV_COLUMN_SEPARATOR);
|
||||
}
|
||||
buf.append(CSV_ROW_SEPARATOR);
|
||||
// 组装数据
|
||||
if (CollectionUtils.isNotEmpty(dataList)) {
|
||||
for (Map<String, Object> map : dataList) {
|
||||
for (String key : keys) {
|
||||
if (ObjectUtil.isEmpty(map.get(key))) {
|
||||
buf.append("").append(CSV_COLUMN_SEPARATOR);
|
||||
} else {
|
||||
// 如果数据内容中包含逗号,则进行使用!替换
|
||||
buf.append(map.get(key).toString().replaceAll(",", "!")).append(CSV_COLUMN_SEPARATOR);
|
||||
}
|
||||
}
|
||||
buf.deleteCharAt(buf.length() - 1).append(CSV_ROW_SEPARATOR);
|
||||
}
|
||||
}
|
||||
|
||||
HttpServletResponse response = HttpServletUtil.getResponse();
|
||||
|
||||
try {
|
||||
ServletOutputStream os = response.getOutputStream();
|
||||
Throwable var1 = null;
|
||||
|
||||
try {
|
||||
fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
response.reset();
|
||||
response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
// 写出响应
|
||||
os.write(buf.toString().getBytes("UTF-8"));
|
||||
os.flush();
|
||||
} catch (Throwable var2) {
|
||||
var1 = var2;
|
||||
throw var2;
|
||||
} finally {
|
||||
if (os != null) {
|
||||
if (var1 != null) {
|
||||
try {
|
||||
os.close();
|
||||
} catch (Throwable var3) {
|
||||
var1.addSuppressed(var3);
|
||||
}
|
||||
} else {
|
||||
os.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
} catch (IOException var4) {
|
||||
IOException e = var4;
|
||||
log.error(">>> 导出数据异常:{}", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置Header
|
||||
*
|
||||
* @param fileName 文件名
|
||||
* @throws
|
||||
*/
|
||||
// public static void responseSetProperties(String fileName) {
|
||||
// HttpServletResponse response = HttpServletUtil.getResponse();
|
||||
// // 设置文件后缀
|
||||
// SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
|
||||
// String fn = fileName + sdf.format(new Date()) + ".csv";
|
||||
//
|
||||
// fileName = URLEncoder.encode(fileName, "UTF-8");
|
||||
//
|
||||
// // 设置响应
|
||||
//// response.setContentType("application/ms-txt.numberformat:@");
|
||||
// response.setContentType("application/octet-stream;charset=UTF-8");
|
||||
// response.setHeader("Content-Disposition", "attachment; filename=\"" + fileName + "\"");
|
||||
//// response.setCharacterEncoding("UTF-8");
|
||||
//// response.setHeader("Pragma", "public");
|
||||
//// response.setHeader("Cache-Control", "max-age=30");
|
||||
// response.setHeader("Content-Disposition", "attachment; filename=" + URLEncoder.encode(fn, "UTF-8"));
|
||||
// }
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user