Compare commits
48 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
37aba2181b | ||
|
|
7335ffe445 | ||
|
|
43c1d56db3 | ||
|
|
2cffee4287 | ||
|
|
c125f20de4 | ||
|
|
f7ea59ce1b | ||
|
|
614849de64 | ||
|
|
d94c03cba1 | ||
|
|
44311fc6ec | ||
|
|
e4fa161e5a | ||
|
|
332c8909ff | ||
|
|
4c2c4d4ede | ||
|
|
c104834ea1 | ||
|
|
aa11314a07 | ||
|
|
8206a51c6c | ||
|
|
f4109275d7 | ||
|
|
f41595b727 | ||
|
|
f284b7a325 | ||
|
|
424b319c38 | ||
|
|
355ba48418 | ||
| 61b6b61a46 | |||
|
|
ea21d631c9 | ||
| 8f4483bbef | |||
|
|
2701816ebe | ||
| 8e75433282 | |||
| 53a4816272 | |||
|
|
b0db65a5cb | ||
|
|
4e3452a63c | ||
|
|
b546128183 | ||
|
|
2075d90760 | ||
|
|
63ac668df9 | ||
|
|
03e74ecb52 | ||
|
|
efebbc5305 | ||
|
|
442b80e7d9 | ||
|
|
712ebfaf24 | ||
|
|
42472dd496 | ||
|
|
b605605c13 | ||
|
|
81357906ca | ||
|
|
74b3e6a993 | ||
|
|
f3b561f8e9 | ||
|
|
b1e881798b | ||
| f0e82c458c | |||
|
|
05cdb20594 | ||
|
|
e640bd4516 | ||
|
|
bb5e5dfec5 | ||
| da38577e70 | |||
|
|
8896360473 | ||
| d0d21e84b8 |
8
device/Readme.md
Normal file
8
device/Readme.md
Normal file
@@ -0,0 +1,8 @@
|
||||
#### 简介
|
||||
设备模块主要包含以下功能:
|
||||
* 被检设备管理
|
||||
* 检测脚本管理
|
||||
* 误差体系管理
|
||||
* 检测源管理
|
||||
|
||||
|
||||
40
device/pom.xml
Normal file
40
device/pom.xml
Normal file
@@ -0,0 +1,40 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>CN_Gather</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</parent>
|
||||
<artifactId>device</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>njcn-common</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>mybatis-plus</artifactId>
|
||||
<version>0.0.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn</groupId>
|
||||
<artifactId>spingboot2.3.12</artifactId>
|
||||
<version>2.3.12</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>system</artifactId>
|
||||
<version>1.0.0</version>
|
||||
<scope>compile</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,191 @@
|
||||
package com.njcn.gather.device.device.controller;
|
||||
|
||||
import cn.afterturn.easypoi.excel.ExcelImportUtil;
|
||||
import cn.afterturn.easypoi.excel.entity.ImportParams;
|
||||
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
|
||||
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.common.LogEnum;
|
||||
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.common.pojo.response.HttpResult;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.gather.device.device.pojo.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.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;
|
||||
import org.apache.poi.ss.usermodel.Workbook;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "被检设备")
|
||||
@RestController
|
||||
@RequestMapping("/pqDev")
|
||||
@RequiredArgsConstructor
|
||||
public class PqDevController extends BaseController {
|
||||
|
||||
private final IPqDevService pqDevService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询被检设备")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqDev>> list(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<PqDev> result = pqDevService.listPqDevs(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 PqDevParam pqDevParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, pqDevParam);
|
||||
boolean result = pqDevService.addPqDev(pqDevParam);
|
||||
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 PqDevParam.UpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = pqDevService.updatePqDev(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 = pqDevService.deletePqDev(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/downloadTemplate")
|
||||
@ApiOperation("下载被检设备导入文件模板")
|
||||
public void downloadTemplate() {
|
||||
pqDevService.downloadTemplate();
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.UPLOAD)
|
||||
@PostMapping(value = "/import")
|
||||
@ApiOperation("批量导入被检设备数据")
|
||||
@ApiImplicitParam(name = "ids", value = "被检设备id", required = true)
|
||||
public HttpResult<String> importPqDevData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
|
||||
String methodDescribe = getMethodDescribe("importPqDevData");
|
||||
ImportParams params = new ImportParams();
|
||||
params.setHeadRows(1);
|
||||
params.setNeedVerify(true);
|
||||
params.setStartSheetIndex(0);
|
||||
params.setSheetNum(1);
|
||||
try {
|
||||
ExcelImportResult<PqDevExcel.ImportData> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.ImportData.class, params);
|
||||
//如果存在非法数据,将不合格的数据导出
|
||||
if (excelImportResult.isVerifyFail()) {
|
||||
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
|
||||
Workbook failWorkbook = excelImportResult.getFailWorkbook();
|
||||
PoiUtil.exportFileByWorkbook(failWorkbook, "非法被检设备数据.xlsx", response);
|
||||
} else {
|
||||
//批量录入数据
|
||||
List<PqDevExcel.ImportData> list = excelImportResult.getList();
|
||||
pqDevService.importPqDevData(list);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
throw new BusinessException(DeviceResponseEnum.IMPORT_DATA_FAIL);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出被检设备数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated PqDevParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("export");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
pqDevService.exportPqDevData(queryParam);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listUnbound")
|
||||
@ApiOperation("查询出所有未绑定的设备")
|
||||
public HttpResult<List<PqDev>> listUnbound() {
|
||||
String methodDescribe = getMethodDescribe("listUnbound");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, null);
|
||||
List<PqDev> result = pqDevService.listUnbound();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
|
||||
@GetMapping("/listBoundByPlanId")
|
||||
@ApiOperation("根据计划id查询出所有已绑定的设备")
|
||||
@ApiImplicitParam(name = "planId", value = "计划id", required = true)
|
||||
public HttpResult<List<PqDev>> listBoundByPlanId(@RequestParam("planId") String planId) {
|
||||
String methodDescribe = getMethodDescribe("listBoundByPlanId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, planId);
|
||||
List<PqDev> result = pqDevService.listBoundByPlanId(planId);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.device.pojo.po.PqDev;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-06
|
||||
*/
|
||||
public interface PqDevMapper extends MPJBaseMapper<PqDev> {
|
||||
|
||||
}
|
||||
|
||||
@@ -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.device.mapper.PqDevMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,183 @@
|
||||
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.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
@Data
|
||||
public class PqDevParam {
|
||||
|
||||
@ApiModelProperty(value = "名称", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.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)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty(value = "设备类型,字典表", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty(value = "设备通道数", required = true)
|
||||
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
|
||||
@Min(value = 1, message = DeviceValidMessage.DEV_CHNS_RANGE_ERROR)
|
||||
private Integer devChns;
|
||||
|
||||
@ApiModelProperty(value = "额定电压(V)", required = true)
|
||||
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@ApiModelProperty(value = "额定电流(A)", required = true)
|
||||
@NotNull(message = DeviceValidMessage.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)
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty(value = "生产日期", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(format = "yyyy-MM-dd", message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@ApiModelProperty(value = "出厂编号", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@ApiModelProperty(value = "固件版本", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@ApiModelProperty(value = "软件版本", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.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)
|
||||
private String protocol;
|
||||
|
||||
@ApiModelProperty(value = "IP地址", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.IP_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.IP_REGEX, message = DeviceValidMessage.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)
|
||||
private Integer port;
|
||||
|
||||
@ApiModelProperty(value = "装置是否为加密版本", required = true)
|
||||
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
|
||||
@Min(value = 0, message = DeviceValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
|
||||
@Max(value = 1, message = DeviceValidMessage.ENCRYPTION_FLAG_FORMAT_ERROR)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@ApiModelProperty("装置识别码(3ds加密)")
|
||||
private String series;
|
||||
|
||||
@ApiModelProperty("装置秘钥(3ds加密)")
|
||||
private String devKey;
|
||||
|
||||
@ApiModelProperty("样品编号")
|
||||
private String sampleId;
|
||||
|
||||
@ApiModelProperty(value = "送样日期")
|
||||
@DateTimeStrValid(message = DeviceValidMessage.ARRIVE_DATE_FORMAT_ERROR)
|
||||
private String arrivedDate;
|
||||
|
||||
@ApiModelProperty("所属地市名称")
|
||||
private String cityName;
|
||||
|
||||
@ApiModelProperty("所属供电公司名称")
|
||||
private String gdName;
|
||||
|
||||
@ApiModelProperty("所属电站名称")
|
||||
private String subName;
|
||||
|
||||
@ApiModelProperty("检测状态")
|
||||
private Integer checkState;
|
||||
|
||||
@ApiModelProperty("检测结果(1:合格/0:不合格)")
|
||||
private Integer checkResult;
|
||||
|
||||
@ApiModelProperty("报告状态(1:生成/0:未生成)")
|
||||
private Integer reportState;
|
||||
|
||||
@ApiModelProperty("归档状态(1:归档/0:未归档)")
|
||||
private Integer documentState;
|
||||
|
||||
@ApiModelProperty("报告路径")
|
||||
private String reportPath;
|
||||
|
||||
@ApiModelProperty("设备关键信息二维码")
|
||||
private String qrCode;
|
||||
|
||||
@ApiModelProperty(value = "复检次数,默认为0", required = true)
|
||||
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
@Min(value = 0, message = DeviceValidMessage.RECHECK_NUM_FORMAT_ERROR)
|
||||
private Integer reCheckNum;
|
||||
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
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)
|
||||
private String id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = DeviceValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.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)
|
||||
private String planId;
|
||||
|
||||
@ApiModelProperty("pqDevIds")
|
||||
@NotNull(message = DeviceValidMessage.PQ_DEV_IDS_NOT_NULL)
|
||||
private List<String> pqDevIds;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,196 @@
|
||||
package com.njcn.gather.device.device.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.FieldStrategy;
|
||||
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.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_dev")
|
||||
public class PqDev extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -45763424394344208L;
|
||||
|
||||
/**
|
||||
* 主键装置序号ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 设备名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 设备模式,字典表(数字、模拟、比对)
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 设备类型,字典表
|
||||
*/
|
||||
private String devType;
|
||||
|
||||
/**
|
||||
* 设备通道数
|
||||
*/
|
||||
private Integer devChns;
|
||||
|
||||
/**
|
||||
* 额定电压(V)
|
||||
*/
|
||||
private Float devVolt;
|
||||
|
||||
/**
|
||||
* 额定电流(A)
|
||||
*/
|
||||
private Float devCurr;
|
||||
|
||||
/**
|
||||
* 生产厂家,字典表
|
||||
*/
|
||||
private String manufacturer;
|
||||
|
||||
/**
|
||||
* 生产日期
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
private LocalDate createDate;
|
||||
|
||||
/**
|
||||
* 出厂编号
|
||||
*/
|
||||
private String createId;
|
||||
|
||||
/**
|
||||
* 固件版本
|
||||
*/
|
||||
private String hardwareVersion;
|
||||
|
||||
/**
|
||||
* 软件版本
|
||||
*/
|
||||
private String softwareVersion;
|
||||
|
||||
/**
|
||||
* 通讯协议,字典表(MMS、PODIF)
|
||||
*/
|
||||
private String protocol;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* 装置是否为加密版本
|
||||
*/
|
||||
private Integer encryptionFlag;
|
||||
|
||||
/**
|
||||
* 装置识别码(3ds加密)
|
||||
*/
|
||||
private String series;
|
||||
|
||||
/**
|
||||
* 装置秘钥(3ds加密)
|
||||
*/
|
||||
private String devKey;
|
||||
|
||||
/**
|
||||
* 样品编号
|
||||
*/
|
||||
private String sampleId;
|
||||
|
||||
/**
|
||||
* 送样日期
|
||||
*/
|
||||
@TableField(updateStrategy = FieldStrategy.IGNORED)
|
||||
@JsonFormat(pattern = "yyyy-MM-dd")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
private LocalDate arrivedDate;
|
||||
|
||||
/**
|
||||
* 所属地市名称
|
||||
*/
|
||||
private String cityName;
|
||||
|
||||
/**
|
||||
* 所属供电公司名称
|
||||
*/
|
||||
private String gdName;
|
||||
|
||||
/**
|
||||
* 所属电站名称
|
||||
*/
|
||||
private String subName;
|
||||
|
||||
/**
|
||||
* 检测状态
|
||||
*/
|
||||
private Integer checkState;
|
||||
|
||||
/**
|
||||
* 检测结果(1:合格/0:不合格)
|
||||
*/
|
||||
private Integer checkResult;
|
||||
|
||||
/**
|
||||
* 报告状态(1:生成/0:未生成)
|
||||
*/
|
||||
private Integer reportState;
|
||||
|
||||
/**
|
||||
* 归档状态(1:归档/0:未归档)
|
||||
*/
|
||||
private Integer documentState;
|
||||
|
||||
/**
|
||||
* 报告路径
|
||||
*/
|
||||
private String reportPath;
|
||||
|
||||
/**
|
||||
* 设备关键信息二维码
|
||||
*/
|
||||
private String qrCode;
|
||||
|
||||
/**
|
||||
* 复检次数,默认为0
|
||||
*/
|
||||
@TableField(value = "ReCheck_Num")
|
||||
private Integer reCheckNum;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 检测计划id
|
||||
*/
|
||||
private String planId;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
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.web.pojo.annotation.DateTimeStrValid;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import org.hibernate.validator.constraints.Range;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/7
|
||||
*/
|
||||
@Data
|
||||
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)
|
||||
private String name;
|
||||
|
||||
@Excel(name = "设备模式", width = 20,orderNum = "1")
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@Excel(name = "设备类型", width = 20,orderNum = "2")
|
||||
@NotBlank(message = DeviceValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@Excel(name = "设备通道数", width = 20,orderNum = "3")
|
||||
@NotNull(message = DeviceValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@Excel(name = "额定电压(V)", width = 15,orderNum = "4")
|
||||
@NotNull(message = DeviceValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@Excel(name = "额定电流(A)", width = 15,orderNum = "5")
|
||||
@NotNull(message = DeviceValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@Excel(name = "生产厂家", width = 20,orderNum = "6")
|
||||
@NotBlank(message = DeviceValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@Excel(name = "出厂编号", width = 40,orderNum = "8")
|
||||
@NotBlank(message = DeviceValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createId;
|
||||
|
||||
@Excel(name = "固件版本", width = 15,orderNum = "9")
|
||||
@NotBlank(message = DeviceValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@Excel(name = "软件版本", width = 15,orderNum = "10")
|
||||
@NotBlank(message = DeviceValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@Excel(name = "通讯协议", width = 15,orderNum = "11")
|
||||
@NotBlank(message = DeviceValidMessage.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)
|
||||
private String ip;
|
||||
|
||||
@Excel(name = "端口号",orderNum = "13")
|
||||
@NotNull(message = DeviceValidMessage.PORT_NOT_NULL)
|
||||
@Range(min = 1, max = 65535, message = DeviceValidMessage.PORT_RANGE_ERROR)
|
||||
private Integer port;
|
||||
|
||||
@Excel(name = "是否为加密版本(1:是/0:否)", width = 20, replace = {"是_1", "否_0"},orderNum = "14")
|
||||
@NotNull(message = DeviceValidMessage.ENCRYPTION_NOT_NULL)
|
||||
private Integer encryptionFlag;
|
||||
|
||||
@Excel(name = "识别码(未加密)", width = 30,orderNum = "15")
|
||||
private String series;
|
||||
|
||||
@Excel(name = "秘钥(未加密)", width = 30,orderNum = "16")
|
||||
private String devKey;
|
||||
|
||||
@Excel(name = "样品编号", width = 40,orderNum = "17")
|
||||
private String sampleId;
|
||||
|
||||
@Excel(name = "所属地市名称", width = 20,orderNum = "19")
|
||||
private String cityName;
|
||||
|
||||
@Excel(name = "所属供电公司名称", width = 20,orderNum = "20")
|
||||
private String gdName;
|
||||
|
||||
@Excel(name = "所属电站名称", width = 20,orderNum = "21")
|
||||
private String subName;
|
||||
|
||||
@Excel(name = "检测状态", width = 15,orderNum = "22")
|
||||
private Integer checkState;
|
||||
|
||||
@Excel(name = "报告路径", width = 20,orderNum = "26")
|
||||
private String reportPath;
|
||||
|
||||
@Excel(name = "关键信息二维码", width = 20,orderNum = "27")
|
||||
private String qrCode;
|
||||
|
||||
@Excel(name = "复检次数", width = 15,orderNum = "28")
|
||||
@NotNull(message = DeviceValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
private Integer reCheckNum;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ExportData extends PqDevExcel {
|
||||
|
||||
@Excel(name = "生产日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd",orderNum = "7")
|
||||
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
private LocalDate createDate;
|
||||
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd",orderNum = "18")
|
||||
private LocalDate arrivedDate;
|
||||
|
||||
@Excel(name = "检测结果(1:合格/0:不合格)", width = 15, replace = {"合格_1", "不合格_0","_null"},orderNum = "23")
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(1:生成/0:未生成)", width = 15, replace = {"生成_1", "未生成_0","_null"},orderNum = "24")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(1:归档/0:未归档)", width = 15, replace = {"归档_1", "未归档_0","_null"},orderNum = "25")
|
||||
private Integer documentState;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class ImportData extends PqDevExcel {
|
||||
|
||||
@Excel(name = "生产日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd",orderNum = "7")
|
||||
@NotNull(message = DeviceValidMessage.CREATEDATETIME_NOT_NULL)
|
||||
@DateTimeStrValid(message = DeviceValidMessage.CREATEDATETIME_FORMAT_ERROR)
|
||||
private String createDate;
|
||||
|
||||
@Excel(name = "送样日期(yyyy-MM-dd)", width = 25, format = "yyyy-MM-dd",orderNum = "18")
|
||||
@DateTimeStrValid(message = DeviceValidMessage.ARRIVE_DATE_FORMAT_ERROR)
|
||||
private String arrivedDate;
|
||||
|
||||
@Excel(name = "检测结果(1:合格/0:不合格)", width = 15, replace = {"合格_1", "不合格_0"},orderNum = "23")
|
||||
private Integer checkResult;
|
||||
|
||||
@Excel(name = "报告状态(1:生成/0:未生成)", width = 15, replace = {"生成_1", "未生成_0"},orderNum = "24")
|
||||
private Integer reportState;
|
||||
|
||||
@Excel(name = "归档状态(1:归档/0:未归档)", width = 15, replace = {"归档_1", "未归档_0"},orderNum = "25")
|
||||
private Integer documentState;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.njcn.gather.device.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
public interface IPqDevService extends IService<PqDev> {
|
||||
|
||||
/**
|
||||
* 分页查询被检设备列表
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 分页数据,包含被检设备列表
|
||||
*/
|
||||
Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增被检设备信息
|
||||
*
|
||||
* @param pqDevParam 被检设备信息
|
||||
* @return 新增成功返回true,否则返回false
|
||||
*/
|
||||
boolean addPqDev(PqDevParam pqDevParam);
|
||||
|
||||
/**
|
||||
* 修改被检设备信息
|
||||
*
|
||||
* @param updateParam 被检设备信息
|
||||
* @return 修改成功返回true,否则返回false
|
||||
*/
|
||||
boolean updatePqDev(PqDevParam.UpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 删除被检设备信息
|
||||
*
|
||||
* @param ids 被检设备id列表
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
boolean deletePqDev(List<String> ids);
|
||||
|
||||
/**
|
||||
* 下载模板文件
|
||||
*/
|
||||
void downloadTemplate();
|
||||
|
||||
/**
|
||||
* 批量导入被检设备信息
|
||||
*
|
||||
* @param sgEventExcels 批量导入的数据
|
||||
*/
|
||||
void importPqDevData(List<PqDevExcel.ImportData> sgEventExcels);
|
||||
|
||||
/**
|
||||
* 导出被检设备信息
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
*/
|
||||
void exportPqDevData(PqDevParam.QueryParam queryParam);
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有未绑定的设备
|
||||
*
|
||||
* @return 未绑定的设备列表
|
||||
*/
|
||||
List<PqDev> listUnbound();
|
||||
|
||||
/**
|
||||
* 根据计划id获取绑定的设备
|
||||
*
|
||||
* @param planId 计划id
|
||||
* @return 绑定的设备列表
|
||||
*/
|
||||
List<PqDev> listBoundByPlanId(String planId);
|
||||
|
||||
/**
|
||||
* 绑定计划
|
||||
*
|
||||
* @param planId 计划id
|
||||
* @param pqDevIds 被检设备id列表
|
||||
* @return 绑定成功返回true,否则返回false
|
||||
*/
|
||||
boolean bindPlan(String planId, List<String> pqDevIds);
|
||||
}
|
||||
@@ -0,0 +1,250 @@
|
||||
package com.njcn.gather.device.device.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.db.mybatisplus.constant.DbConstant;
|
||||
import com.njcn.gather.device.device.mapper.PqDevMapper;
|
||||
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.device.util.DeviceUtil;
|
||||
import com.njcn.gather.device.pojo.enums.DeviceResponseEnum;
|
||||
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.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements IPqDevService {
|
||||
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@Override
|
||||
public Page<PqDev> listPqDevs(PqDevParam.QueryParam queryParam) {
|
||||
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper
|
||||
.like(StrUtil.isNotBlank(queryParam.getName()), "pq_dev.name", queryParam.getName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getPattern()), "pq_dev.pattern", queryParam.getPattern())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getManufacturer()), "pq_dev.manufacturer", queryParam.getManufacturer())
|
||||
.between(ObjectUtil.isAllNotEmpty(queryParam.getSearchBeginTime(), queryParam.getSearchEndTime()), "pq_dev.Create_Date", queryParam.getSearchBeginTime(), queryParam.getSearchEndTime());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, false, "pq_dev.Create_Time");
|
||||
}
|
||||
} else {
|
||||
queryWrapper.orderBy(true, false, "pq_dev.Create_Time");
|
||||
}
|
||||
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
|
||||
Page<PqDev> page = this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
page.getRecords().forEach(p -> {
|
||||
if (ObjectUtil.isNotNull(p.getSeries())) {
|
||||
p.setSeries(DeviceUtil.decoderString(1, p.getSeries()));
|
||||
}
|
||||
if (ObjectUtil.isNotNull(p.getDevKey())) {
|
||||
p.setDevKey(DeviceUtil.decoderString(1, p.getDevKey()));
|
||||
}
|
||||
});
|
||||
return page;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqDev(PqDevParam pqDevParam) {
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(pqDevParam, pqDev);
|
||||
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);
|
||||
}
|
||||
}
|
||||
//todo 比对式设备处理
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqDev(PqDevParam.UpdateParam updateParam) {
|
||||
PqDev pqDev = new PqDev();
|
||||
BeanUtil.copyProperties(updateParam, pqDev);
|
||||
if (Objects.nonNull(pqDev.getSeries())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
//todo 比对式设备处理
|
||||
return this.updateById(pqDev);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqDev(List<String> ids) {
|
||||
return this.lambdaUpdate().set(PqDev::getState, DataStateEnum.DELETED.getCode()).in(PqDev::getId, ids).update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void downloadTemplate() {
|
||||
ExcelUtil.exportExcel("被检设备模板.xlsx", "被检设备", PqDevExcel.ExportData.class, new ArrayList<>());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void importPqDevData(List<PqDevExcel.ImportData> pqDevExcelList) {
|
||||
List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
|
||||
//逆向可视化
|
||||
this.reverseVisualize(pqDevList);
|
||||
this.saveBatch(pqDevList);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportPqDevData(PqDevParam.QueryParam queryParam) {
|
||||
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper
|
||||
.like(StrUtil.isNotBlank(queryParam.getName()), "pq_dev.name", queryParam.getName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getPattern()), "pq_dev.pattern", queryParam.getPattern())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getManufacturer()), "pq_dev.manufacturer", queryParam.getManufacturer())
|
||||
.between(ObjectUtil.isAllNotEmpty(queryParam.getSearchBeginTime(), queryParam.getSearchEndTime()), "pq_dev.Create_Date", queryParam.getSearchBeginTime(), queryParam.getSearchEndTime());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, false, "pq_dev.Create_Time");
|
||||
}
|
||||
} else {
|
||||
queryWrapper.orderBy(true, false, "pq_dev.Create_Time");
|
||||
}
|
||||
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
|
||||
List<PqDev> pqDevs = this.list(queryWrapper);
|
||||
this.visualize(pqDevs);
|
||||
List<PqDevExcel.ExportData> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.ExportData.class);
|
||||
ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.ExportData.class, pqDevExcels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listUnbound() {
|
||||
return this.lambdaQuery().eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).isNull(PqDev::getPlanId).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqDev> listBoundByPlanId(String planId) {
|
||||
return this.lambdaQuery().eq(PqDev::getState, DataStateEnum.ENABLE.getCode()).eq(PqDev::getPlanId, planId).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean bindPlan(String planId, List<String> pqDevIds) {
|
||||
List<String> existedBoundPqDevIds = this.listBoundByPlanId(planId).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();
|
||||
|
||||
//绑定 没有的历史绑定而此次绑定的
|
||||
pqDevIds.removeAll(existedBoundPqDevIds);
|
||||
boolean result2 = this.lambdaUpdate().set(PqDev::getPlanId, planId).in(PqDev::getId, pqDevIds).update();
|
||||
|
||||
return result1 && result2;
|
||||
}
|
||||
|
||||
//可视化,各种id回显字典值,解码等操作
|
||||
private void visualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
if (ObjectUtil.isNotNull(pqDev.getPattern())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setPattern(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getDevType())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setDevType(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataById(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getSeries())) {
|
||||
pqDev.setSeries(DeviceUtil.decoderString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.decoderString(1, pqDev.getDevKey()));
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
//逆向可视化
|
||||
private void reverseVisualize(List<PqDev> sourceList) {
|
||||
sourceList.forEach(pqDev -> {
|
||||
if (ObjectUtil.isNotNull(pqDev.getPattern())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getPattern());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setPattern(dictData.getName());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getDevType())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getDevType());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setDevType(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getManufacturer())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getManufacturer());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setManufacturer(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (ObjectUtil.isNotNull(pqDev.getProtocol())) {
|
||||
DictData dictData = dictDataService.getDictDataByName(pqDev.getProtocol());
|
||||
if (ObjectUtil.isNotNull(dictData)) {
|
||||
pqDev.setProtocol(dictData.getId());
|
||||
}
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getSeries())) {
|
||||
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
|
||||
}
|
||||
if (Objects.nonNull(pqDev.getDevKey())) {
|
||||
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
|
||||
}
|
||||
pqDev.setState(DataStateEnum.ENABLE.getCode());
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.njcn.gather.device.device.util;
|
||||
|
||||
import com.njcn.common.utils.sm.Sm4Utils;
|
||||
import com.njcn.common.utils.sm.ThreeDesUtil;
|
||||
import org.apache.commons.codec.binary.Base64;
|
||||
|
||||
/**
|
||||
* pqs
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2022/1/6
|
||||
*/
|
||||
public class DeviceUtil {
|
||||
|
||||
|
||||
/**
|
||||
* cd 系统配置的解密方式
|
||||
* content 需要解密的内容
|
||||
* 解密对应内容
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2021/10/12
|
||||
*/
|
||||
public static String decoderString(Integer cd, String content) {
|
||||
String seriesTmp = null;
|
||||
if (cd == 0) {
|
||||
seriesTmp = Base64.decodeBase64(content).toString();
|
||||
} else if (cd == 1) {
|
||||
seriesTmp = ThreeDesUtil.decryptThreeDes(content);
|
||||
} else if (cd == 2) {
|
||||
//SM4加密密码
|
||||
String secretkey = Sm4Utils.globalSecretKey;
|
||||
Sm4Utils sm4 = new Sm4Utils(secretkey);
|
||||
seriesTmp = sm4.decryptData_ECB(content);
|
||||
}
|
||||
return seriesTmp;
|
||||
}
|
||||
|
||||
/**
|
||||
* cd 系统配置的加密方式
|
||||
* content 需要加密的内容
|
||||
* 加密对应内容
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2021/10/12
|
||||
*/
|
||||
public static String encodeString(Integer cd, String content) {
|
||||
String key = null;
|
||||
if (cd == 0) {
|
||||
key = Base64.encodeBase64String(content.getBytes());
|
||||
} else if (cd == 1) {
|
||||
key = ThreeDesUtil.encryptThreeDes(content);
|
||||
} else if (cd == 2) {
|
||||
//SM4加密密码
|
||||
// String secretkey = Sm4Utils.globalSecretKey;
|
||||
// Sm4Utils sm4 = new Sm4Utils(secretkey);
|
||||
// key = sm4.encryptData_ECB(content);
|
||||
}
|
||||
return key;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,120 @@
|
||||
package com.njcn.gather.device.err.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.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "误差体系管理")
|
||||
@RestController
|
||||
@RequestMapping("/pqErrSys")
|
||||
@RequiredArgsConstructor
|
||||
public class PqErrSysController extends BaseController {
|
||||
private final IPqErrSysService pqErrSysService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询误差体系")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqErrSys>> list(@RequestBody @Validated PqErrSysParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
Page<PqErrSys> result = pqErrSysService.listPqErrSys(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据id查询误差体系")
|
||||
@ApiImplicitParam(name = "id", value = "查询参数", required = true)
|
||||
public HttpResult<PqErrSys> getPqErrSysById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
LogUtil.njcnDebug(log, "{},查询ID为:{}", methodDescribe, id);
|
||||
PqErrSys result = pqErrSysService.getPqErrSysById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增误差体系")
|
||||
@ApiImplicitParam(name = "param", value = "误差体系", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated PqErrSysParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
boolean result = pqErrSysService.addPqErrSys(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 = "param", value = "误差体系", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated PqErrSysParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
boolean result = pqErrSysService.updatePqErrSys(param);
|
||||
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 = pqErrSysService.deletePqErrSys(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@GetMapping("/copy")
|
||||
@ApiOperation("复制误差体系")
|
||||
@ApiImplicitParam(name = "id", value = "误差体系id", required = true)
|
||||
public HttpResult<Object> copy(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("copy");
|
||||
LogUtil.njcnDebug(log, "{},复制ID为:{}", methodDescribe, id);
|
||||
boolean result = pqErrSysService.copyPqErrSys(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.err.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
public interface PqErrSysDtlsMapper extends MPJBaseMapper<PqErrSysDtls> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.err.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
public interface PqErrSysMapper extends MPJBaseMapper<PqErrSys> {
|
||||
|
||||
}
|
||||
|
||||
@@ -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.err.mapper.PqErrSysDtlsMapper">
|
||||
|
||||
|
||||
</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.device.err.mapper.PqErrSysMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.gather.device.err.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.device.pojo.constant.DeviceValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-21
|
||||
*/
|
||||
@Data
|
||||
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)
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "误差判断起始值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.START_VALUE_NOT_NULL)
|
||||
private Float startValue;
|
||||
|
||||
@ApiModelProperty(value = "是否包含起始值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.START_FLAG_NOT_NULL)
|
||||
private Integer startFlag;
|
||||
|
||||
@ApiModelProperty(value = "误差判断结束值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.END_VALUE_NOT_NULL)
|
||||
private Float endValue;
|
||||
|
||||
@ApiModelProperty(value = "是否包含结束值", required = true)
|
||||
@NotNull(message = DeviceValidMessage.END_FLAG_NOT_NULL)
|
||||
private Integer endFlag;
|
||||
|
||||
@ApiModelProperty(value = "判断条件值类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.CONDITION_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ERROR_VALUE_FORMAT_ERROR)
|
||||
private String conditionType;
|
||||
|
||||
@ApiModelProperty(value = "最大值误差", required = true)
|
||||
@NotNull(message = DeviceValidMessage.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)
|
||||
private String errorValueType;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
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.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.Valid;
|
||||
import javax.validation.constraints.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-27
|
||||
*/
|
||||
@Data
|
||||
public class PqErrSysParam {
|
||||
|
||||
@ApiModelProperty(value = "误差体系名称", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DeviceValidMessage.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)
|
||||
private String standardName;
|
||||
|
||||
@ApiModelProperty(value = "标准实施年份", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_TIME_NOT_BLANK)
|
||||
@DateTimeStrValid(format = "yyyy", message = DeviceValidMessage.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)
|
||||
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)
|
||||
private Integer enable;
|
||||
|
||||
@ApiModelProperty(value = "误差详情列表", required = true)
|
||||
@Valid
|
||||
private List<PqErrSysDtlsParam> pqErrSysDtlsList;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = false)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("标准实施年份")
|
||||
@DateTimeStrValid(format = "yyyy", message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
private String standardTime;
|
||||
|
||||
@ApiModelProperty("设备等级")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_LEVEL_FORMAT_ERROR)
|
||||
private String devLevel;
|
||||
}
|
||||
|
||||
@Data
|
||||
@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)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,70 @@
|
||||
package com.njcn.gather.device.err.pojo.po;
|
||||
|
||||
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.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_err_sys")
|
||||
public class PqErrSys extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -90836093088362651L;
|
||||
/**
|
||||
* 误差体系ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 误差体系名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 参照标准名称
|
||||
*/
|
||||
private String standardName;
|
||||
|
||||
/**
|
||||
* 标准推行时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
private LocalDate standardTime;
|
||||
|
||||
/**
|
||||
* 设备等级,字典表
|
||||
*/
|
||||
private String devLevel;
|
||||
|
||||
/**
|
||||
* 状态:0-不启用 1-启用
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<PqErrSysDtls> pqErrSysDtlsList;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.njcn.gather.device.err.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Data
|
||||
@TableName("pq_err_sys_dtls")
|
||||
public class PqErrSysDtls implements Serializable {
|
||||
private static final long serialVersionUID = -52777336589097027L;
|
||||
/**
|
||||
* 误差体系子表ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 所属误差体系ID
|
||||
*/
|
||||
private String errorSysId;
|
||||
|
||||
/**
|
||||
* 检测脚本类型
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 误差判断起始值
|
||||
*/
|
||||
private Float startValue;
|
||||
|
||||
/**
|
||||
* 是否包含起始值
|
||||
*/
|
||||
private Integer startFlag;
|
||||
|
||||
/**
|
||||
* 误差判断结束值
|
||||
*/
|
||||
private Float endValue;
|
||||
|
||||
/**
|
||||
* 是否包含结束值
|
||||
*/
|
||||
private Integer endFlag;
|
||||
|
||||
/**
|
||||
* 判断条件值类型(包括值类型,绝对值、相对值)
|
||||
*/
|
||||
private String conditionType;
|
||||
|
||||
/**
|
||||
* 误差最大值
|
||||
*/
|
||||
private Float maxErrorValue;
|
||||
|
||||
/**
|
||||
* 误差值类型
|
||||
*/
|
||||
private String errorValueType;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.njcn.gather.device.err.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysDtlsParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
public interface IPqErrSysDtlsService extends IService<PqErrSysDtls> {
|
||||
|
||||
/**
|
||||
* 根据误差体系id查询误差详情
|
||||
* @param pqErrSysId 误差体系id
|
||||
* @return
|
||||
*/
|
||||
List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId);
|
||||
|
||||
/**
|
||||
* 新增误差详情
|
||||
* @param pqErrSysId 误差体系id
|
||||
* @param list 新增参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean addPqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list);
|
||||
|
||||
/**
|
||||
* 更新误差详情
|
||||
* @param pqErrSysId 误差体系id
|
||||
* @param list 更新参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updatePqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list);
|
||||
|
||||
/**
|
||||
* 根据误差体系id删除误差详情
|
||||
* @param pqErrSysIds
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqErrSysDtlsByPqErrSysId(List<String> pqErrSysIds);
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
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.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
public interface IPqErrSysService extends IService<PqErrSys> {
|
||||
|
||||
/**
|
||||
* 分页查询误差体系列表
|
||||
*
|
||||
* @param param 分页查询参数
|
||||
* @return 分页查询结果
|
||||
*/
|
||||
Page<PqErrSys> listPqErrSys(PqErrSysParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询误差体系
|
||||
*
|
||||
* @param id id
|
||||
* @return 误差体系
|
||||
*/
|
||||
PqErrSys getPqErrSysById(String id);
|
||||
|
||||
/**
|
||||
* 新增误差体系
|
||||
*
|
||||
* @param param 新增参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean addPqErrSys(PqErrSysParam param);
|
||||
|
||||
/**
|
||||
* 更新误差体系
|
||||
*
|
||||
* @param param 更新参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updatePqErrSys(PqErrSysParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 删除误差体系
|
||||
*
|
||||
* @param ids id列表
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqErrSys(List<String> ids);
|
||||
|
||||
/**
|
||||
* 复制误差体系
|
||||
*
|
||||
* @param id 误差体系id
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean copyPqErrSys(String id);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.device.err.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.gather.device.err.mapper.PqErrSysDtlsMapper;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysDtlsParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSysDtls;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqErrSysDtlsServiceImpl extends ServiceImpl<PqErrSysDtlsMapper, PqErrSysDtls> implements IPqErrSysDtlsService {
|
||||
|
||||
@Override
|
||||
public List<PqErrSysDtls> listPqErrSysDtlsByPqErrSysId(String pqErrSysId) {
|
||||
return this.lambdaQuery().eq(PqErrSysDtls::getErrorSysId, pqErrSysId).list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) {
|
||||
List<PqErrSysDtls> data = new ArrayList<>();
|
||||
for (PqErrSysDtlsParam param : list) {
|
||||
PqErrSysDtls pqErrSysDtls = new PqErrSysDtls();
|
||||
BeanUtils.copyProperties(param, pqErrSysDtls);
|
||||
pqErrSysDtls.setErrorSysId(pqErrSysId);
|
||||
data.add(pqErrSysDtls);
|
||||
}
|
||||
return this.saveBatch(data);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqErrSysDtls(String pqErrSysId, List<PqErrSysDtlsParam> list) {
|
||||
//先按照pqErrSysId全部删除
|
||||
this.deletePqErrSysDtlsByPqErrSysId(Collections.singletonList(pqErrSysId));
|
||||
//再重新插入
|
||||
this.addPqErrSysDtls(pqErrSysId, list);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqErrSysDtlsByPqErrSysId(List<String> pqErrSysIds) {
|
||||
QueryWrapper<PqErrSysDtls> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.in("pq_err_sys_dtls.Error_Sys_Id", pqErrSysIds);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.njcn.gather.device.err.service.impl;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
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.gather.device.err.mapper.PqErrSysMapper;
|
||||
import com.njcn.gather.device.err.pojo.param.PqErrSysParam;
|
||||
import com.njcn.gather.device.err.pojo.po.PqErrSys;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysDtlsService;
|
||||
import com.njcn.gather.device.err.service.IPqErrSysService;
|
||||
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.time.LocalDate;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-27
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqErrSysServiceImpl extends ServiceImpl<PqErrSysMapper, PqErrSys> implements IPqErrSysService {
|
||||
|
||||
private final IPqErrSysDtlsService pqErrSysDtlsService;
|
||||
|
||||
@Override
|
||||
public Page<PqErrSys> listPqErrSys(PqErrSysParam.QueryParam param) {
|
||||
QueryWrapper<PqErrSys> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
queryWrapper.between(ObjectUtil.isNotEmpty(param.getStandardTime()), "pq_err_sys.Standard_Time", param.getStandardTime() + "-01-01", param.getStandardTime() + "-12-31").eq(ObjectUtil.isNotEmpty(param.getDevLevel()), "pq_err_sys.Dev_Level", param.getDevLevel());
|
||||
}
|
||||
queryWrapper.eq("pq_err_sys.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqErrSys getPqErrSysById(String id) {
|
||||
PqErrSys pqErrSys = this.lambdaQuery().eq(PqErrSys::getId, id).eq(PqErrSys::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
if (ObjectUtil.isNotNull(pqErrSys)) {
|
||||
pqErrSys.setPqErrSysDtlsList(pqErrSysDtlsService.listPqErrSysDtlsByPqErrSysId(id));
|
||||
}
|
||||
return pqErrSys;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqErrSys(PqErrSysParam param) {
|
||||
PqErrSys pqErrSys = new PqErrSys();
|
||||
BeanUtils.copyProperties(param, pqErrSys);
|
||||
String id = UUID.randomUUID().toString().replaceAll("-", "");
|
||||
pqErrSys.setId(id);
|
||||
pqErrSys.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
|
||||
pqErrSys.setState(DataStateEnum.ENABLE.getCode());
|
||||
boolean result1 = this.save(pqErrSys);
|
||||
boolean result2 = pqErrSysDtlsService.updatePqErrSysDtls(id, param.getPqErrSysDtlsList());
|
||||
return result1 && result2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqErrSys(PqErrSysParam.UpdateParam param) {
|
||||
PqErrSys pqErrSys = new PqErrSys();
|
||||
BeanUtils.copyProperties(param, pqErrSys);
|
||||
pqErrSys.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
|
||||
boolean result1 = this.updateById(pqErrSys);
|
||||
boolean result2 = pqErrSysDtlsService.updatePqErrSysDtls(param.getId(), param.getPqErrSysDtlsList());
|
||||
return result1 && result2;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqErrSys(List<String> ids) {
|
||||
pqErrSysDtlsService.deletePqErrSysDtlsByPqErrSysId(ids);
|
||||
this.lambdaUpdate().in(PqErrSys::getId, ids).set(PqErrSys::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean copyPqErrSys(String id) {
|
||||
PqErrSys pqErrSys = this.getPqErrSysById(id);
|
||||
pqErrSys.setId(UUID.randomUUID().toString().replaceAll("-", ""));
|
||||
pqErrSys.setName(pqErrSys.getName() + "_副本");
|
||||
pqErrSys.setStandardTime(LocalDate.of(pqErrSys.getStandardTime().getYear(), 1, 1));
|
||||
pqErrSys.getPqErrSysDtlsList().forEach(pqErrSysDtls -> pqErrSysDtls.setId(UUID.randomUUID().toString().replaceAll("-", "")));
|
||||
return this.save(pqErrSys);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,132 @@
|
||||
package com.njcn.gather.device.pojo.constant;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
public interface DeviceValidMessage {
|
||||
|
||||
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||
|
||||
String ID_FORMAT_ERROR = "id格式错误,请检查id参数";
|
||||
|
||||
String PORT_RANGE_ERROR = "端口号范围错误,请检查port参数";
|
||||
|
||||
String NAME_NOT_BLANK = "名称不能为空,请检查name参数";
|
||||
|
||||
String NAME_FORMAT_ERROR = "名称格式错误,请检查name参数";
|
||||
|
||||
String PATTERN_NOT_BLANK = "模式不能为空,请检查pattern参数";
|
||||
|
||||
String DEV_TYPE_NOT_BLANK = "设备类型不能为空,请检查devType参数";
|
||||
|
||||
String DEV_CHNS_NOT_NULL = "设备通道系数不能为空,请检查devChns参数";
|
||||
|
||||
String DEV_VOLT_NOT_NULL = "额定电压不能为空,请检查devVolt参数";
|
||||
|
||||
String DEV_CURR_NOT_NULL = "额定电流不能为空,请检查devCurr参数";
|
||||
|
||||
String MANUFACTURER_NOT_BLANK = "生产厂家不能为空,请检查manufacturer参数";
|
||||
|
||||
String CREATEDATETIME_NOT_NULL = "生产日期不能为空,请检查producedDate参数";
|
||||
|
||||
String CREATEDATETIME_FORMAT_ERROR = "生产日期格式错误,请检查createDateTime参数";
|
||||
|
||||
String FACTORYNO_NOT_BLANK = "出厂编号不能为空,请检查factoryNo参数";
|
||||
|
||||
String FIRMWARE_NOT_BLANK = "固件版本不能为空,请检查firmware参数";
|
||||
|
||||
String SOFTWARE_NOT_BLANK = "软件版本不能为空,请检查software参数";
|
||||
|
||||
String PROTOCOL_NOT_BLANK = "通讯协议不能为空,请检查protocol参数";
|
||||
|
||||
String IP_NOT_BLANK = "IP地址不能为空,请检查ip参数";
|
||||
|
||||
String IP_FORMAT_ERROR = "IP地址格式错误,请检查ip参数";
|
||||
|
||||
String PORT_NOT_NULL = "端口号不能为空,请检查port参数";
|
||||
|
||||
String ENCRYPTION_NOT_NULL = "是否为加密版本不能为空,请检查encryption参数";
|
||||
|
||||
String RECHECK_NUM_NOT_NULL = "复检次数不能为空,请检查reCheckNum参数";
|
||||
|
||||
String PLAN_ID_NOT_NULL = "检测计划ID不能为空,请检查planId参数";
|
||||
|
||||
String PQ_DEV_IDS_NOT_NULL = "设备ID集合不能为null,请检查pqDevIds参数";
|
||||
|
||||
String ARRIVE_DATE_FORMAT_ERROR = "送样日期格式错误,请检查arrivedDateTime参数";
|
||||
|
||||
String ENCRYPTION_FLAG_FORMAT_ERROR = "是否为加密版本格式错误,请检查encryptionFlag参数";
|
||||
|
||||
String RECHECK_NUM_FORMAT_ERROR = "复检次数格式错误,请检查recheckNum参数";
|
||||
|
||||
String PATTERN_FORMAT_ERROR = "模式格式错误,请检查pattern参数";
|
||||
|
||||
String DEV_TYPE_FORMAT_ERROR = "设备类型格式错误,请检查devType参数";
|
||||
|
||||
String DEV_CHNS_RANGE_ERROR = "设备通道系数错误,请检查devChns参数";
|
||||
|
||||
String MANUFACTURER_FORMAT_ERROR = "生产厂家格式错误,请检查manufacturer参数";
|
||||
|
||||
String PROTOCOL_FORMAT_ERROR = "通讯协议格式错误,请检查protocol参数";
|
||||
|
||||
String PLAN_ID_FORMAT_ERROR = "检测计划ID格式错误,请检查planId参数";
|
||||
|
||||
String STANDARD_TIME_FORMAT_ERROR = "标准推行时间格式错误,请检查standardTime参数";
|
||||
|
||||
String SCRIPT_TYPE_NOT_BLANK = "检测脚本类型不能为空,请检查scriptType参数";
|
||||
|
||||
String STANDARD_NAME_NOT_BLANK = "参照标准名称不能为空,请检查standardName参数";
|
||||
|
||||
String STANDARD_NAME_FORMAT_ERROR = "参照标准名称格式错误,请检查standardName参数";
|
||||
|
||||
String STANDARD_TIME_NOT_BLANK = "标准推行时间不能为空,请检查standardTime参数";
|
||||
|
||||
String SCRIPT_TYPE_FORMAT_ERROR = "检测脚本类型格式错误,请检查scriptType参数";
|
||||
|
||||
String DEV_LEVEL_NOT_BLANK = "设备等级不能为空,请检查devLevel参数";
|
||||
|
||||
String DEV_LEVEL_FORMAT_ERROR = "设备等级格式错误,请检查devLevel参数";
|
||||
|
||||
String ENABLE_FORMAT_ERROR = "是否启用格式错误,请检查enable参数";
|
||||
|
||||
String ERR_SYS_ID_NOT_BLANK = "误差体系ID不能为空,请检查errSysId参数";
|
||||
|
||||
String ERR_SYS_DTLS_TYPE_NOT_BLANK = "电能质量检测指标类型不能为空,请检查errSysDtlsType参数";
|
||||
|
||||
String ERR_SYS_DTLS_TYPE_FORMAT_ERROR = "电能质量检测指标类型格式错误,请检查errSysDtlsType参数";
|
||||
|
||||
String START_VALUE_NOT_NULL = "起始值不能为空,请检查startValue参数";
|
||||
|
||||
String START_FLAG_NOT_NULL = "是否包含起始值不能为空,请检查startFlag参数";
|
||||
|
||||
String END_VALUE_NOT_NULL = "结束值不能为空,请检查endValue参数";
|
||||
|
||||
String END_FLAG_NOT_NULL = "是否包含结束值不能为空,请检查endFlag参数";
|
||||
|
||||
String CONDITION_TYPE_NOT_BLANK = "判断条件类型不能为空,请检查conditionType参数";
|
||||
|
||||
String ERROR_VALUE_FORMAT_ERROR = "误差值格式错误,请检查errorValue参数";
|
||||
|
||||
String MAX_ERROR_VALUE_NOT_NULL = "最大误差值不能为空,请检查maxErrorValue参数";
|
||||
|
||||
String ERROR_VALUE_TYPE_NOT_BLANK = "误差值类型不能为空,请检查errorValueType参数";
|
||||
|
||||
String PQ_SOURCE_TYPE_NOT_BLANK = "检测源类型不能为空,请检查pqSourceType参数";
|
||||
|
||||
String PQ_SOURCE_TYPE_FORMAT_ERROR = "检测源类型格式错误,请检查pqSourceType参数";
|
||||
|
||||
String ENABLE_NOT_NULL = "状态不能为空,请检查enable参数";
|
||||
|
||||
String PQ_SOURCE_NAME_FORMAT_ERROR = "检测源名称格式错误,请检查pqSourceName参数";
|
||||
|
||||
String PQ_SOURCE_PARAMETER_ID_NOT_BLANK = "检测源参数ID不能为空,请检查pqSourceParameterId参数";
|
||||
|
||||
String PQ_SOURCE_PARAMETER_PID_NOT_BLANK = "检测源参数PID不能为空,请检查pqSourceParameterId参数";
|
||||
|
||||
String PQ_SOURCE_PARAMETER_TYPE_NOT_BLANK = "检测源参数类型不能为空,请检查pqSourceParameterType参数";
|
||||
|
||||
String PQ_SOURCE_PARAMETER_REMARK_NOT_BLANK = "检测源参数描述不能为空,请检查pqSourceParameterRemark参数";
|
||||
|
||||
String PQ_SOURCE_PARAMETER_VALUE_NOT_BLANK = "参数值不能为空,请检查pqSourceParameterValue参数";
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.njcn.gather.device.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum DeviceResponseEnum {
|
||||
//NAME_REPEAT("A001001", "名称重复"),
|
||||
|
||||
IMPORT_DATA_FAIL("A001002", "导入数据失败"),
|
||||
SERIES_AND_DEVKEY_NOT_BLANK("A001003", "加密设备的序列号和设备密钥不能为空");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
DeviceResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,124 @@
|
||||
package com.njcn.gather.device.script.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.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
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 javax.servlet.http.HttpServletRequest;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "检测脚本管理")
|
||||
@RestController
|
||||
@RequestMapping("/pqScript")
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptController extends BaseController {
|
||||
private final IPqScriptService pqScriptService;
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询检测脚本")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqScript>> list(@RequestBody @Validated PqScriptParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
Page<PqScript> result = pqScriptService.listPqScript(param);
|
||||
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 PqScriptParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
boolean result = pqScriptService.addPqScript(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 PqScriptParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
boolean result = pqScriptService.updatePqScript(param);
|
||||
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 = pqScriptService.deletePqScript(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("getScriptDtlsByScriptId")
|
||||
@ApiOperation("根据脚本id查询检测脚本详情")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<List<PqScriptDtls>> getScriptDtlsByScriptId(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, id);
|
||||
List<PqScriptDtls> result = pqScriptDtlsService.listPqScriptDtlByScriptId(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.UPDATE)
|
||||
@GetMapping("/upgradeToTemplate")
|
||||
@ApiOperation("升级为模板")
|
||||
@ApiImplicitParam(name = "id", value = "检测脚本id", required = true)
|
||||
public HttpResult<Object> upgradeToTemplate(@RequestParam("id") String id, HttpServletRequest request) {
|
||||
String methodDescribe = getMethodDescribe("upgradeToTemplate");
|
||||
LogUtil.njcnDebug(log, "{},升级ID数据为:{}", methodDescribe, id);
|
||||
boolean result = pqScriptService.upgradeToTemplate(id);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface PqScriptDtlsMapper extends MPJBaseMapper<PqScriptDtls> {
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.script.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface PqScriptMapper extends MPJBaseMapper<PqScript> {
|
||||
|
||||
}
|
||||
|
||||
@@ -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.script.mapper.PqScriptDtlsMapper">
|
||||
|
||||
|
||||
</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.device.script.mapper.PqScriptMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,82 @@
|
||||
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.system.pojo.constant.SystemValidMessage;
|
||||
import com.njcn.web.pojo.annotation.DateTimeStrValid;
|
||||
import com.njcn.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/18
|
||||
*/
|
||||
@Data
|
||||
public class PqScriptParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = DeviceValidMessage.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)
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 检测脚本模式,字典表(数字、模拟、比对)
|
||||
*/
|
||||
@ApiModelProperty("模式")
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 检测脚本值类型(在非比对模式情况下,分为相对值检测脚本和绝对值检测脚本)
|
||||
*/
|
||||
@ApiModelProperty("值类型")
|
||||
private String valueType;
|
||||
|
||||
@ApiModelProperty("参照标准名称")
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.ERR_SYS_NAME, message = DeviceValidMessage.STANDARD_NAME_FORMAT_ERROR)
|
||||
private String standardName;
|
||||
|
||||
|
||||
@ApiModelProperty("标准推行时间")
|
||||
@NotBlank(message = DeviceValidMessage.STANDARD_TIME_NOT_BLANK)
|
||||
@DateTimeStrValid(format = "yyyy", message = DeviceValidMessage.STANDARD_TIME_FORMAT_ERROR)
|
||||
private String standardTime;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("类型")
|
||||
private Integer type;
|
||||
|
||||
@ApiModelProperty("值类型")
|
||||
private String valueType;
|
||||
|
||||
@ApiModelProperty("模式")
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
}
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends PqScriptParam {
|
||||
@ApiModelProperty("检测脚本ID")
|
||||
@NotBlank(message = DeviceValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.njcn.gather.device.script.pojo.po;
|
||||
|
||||
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.LocalDateDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
|
||||
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDate;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_script")
|
||||
public class PqScript extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -61550003510158595L;
|
||||
/**
|
||||
* 检测脚本ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测脚本名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 检测脚本类型,字典表(脚本还是模板)
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 检测脚本模式,字典表(数字、模拟、比对)
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 检测脚本值类型(在非比对模式情况下,分为相对值检测脚本和绝对值检测脚本)
|
||||
*/
|
||||
private String valueType;
|
||||
|
||||
/**
|
||||
* 参照标准名称
|
||||
*/
|
||||
private String standardName;
|
||||
|
||||
/**
|
||||
* 标准推行时间
|
||||
*/
|
||||
@JsonFormat(pattern = "yyyy")
|
||||
@JsonDeserialize(using = LocalDateDeserializer.class)
|
||||
@JsonSerialize(using = LocalDateSerializer.class)
|
||||
private LocalDate standardTime;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.gather.device.script.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Data
|
||||
@TableName("pq_script_dtls")
|
||||
public class PqScriptDtls implements Serializable {
|
||||
|
||||
private static final long serialVersionUID = 111579281505485316L;
|
||||
/**
|
||||
* 检测脚本子表ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测脚本ID
|
||||
*/
|
||||
private String scriptId;
|
||||
|
||||
/**
|
||||
* 检测脚本类型,树形字典表(没有树形表则需要拆分字段)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 相别,字典表
|
||||
*/
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* 值
|
||||
*/
|
||||
private Float value;
|
||||
|
||||
/**
|
||||
* 相角
|
||||
*/
|
||||
private Float angle;
|
||||
|
||||
/**
|
||||
* 状态:0-不启用 1-启用
|
||||
*/
|
||||
private Integer enable;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,53 @@
|
||||
package com.njcn.gather.device.script.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface IPqScriptDtlsService extends IService<PqScriptDtls> {
|
||||
|
||||
/**
|
||||
* 保存脚本详情
|
||||
*
|
||||
* @param pqScriptDtls 脚本详情
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean savePqScriptDtls(PqScriptDtls pqScriptDtls);
|
||||
|
||||
/**
|
||||
* 根据id删除脚本详情
|
||||
*
|
||||
* @param ids 脚本详情ids
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqScriptDtlsByIds(List<String> ids);
|
||||
|
||||
/**
|
||||
* 根据脚本id删除脚本详情
|
||||
*
|
||||
* @param scriptIds 脚本id
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqScriptDtlsByScriptId(List<String> scriptIds);
|
||||
|
||||
/**
|
||||
* 修改脚本详情
|
||||
*
|
||||
* @param pqScriptDtls 脚本详情
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updatePqScriptDtls(PqScriptDtls pqScriptDtls);
|
||||
|
||||
/**
|
||||
* 根据脚本id查询脚本详情
|
||||
*
|
||||
* @param scriptId 脚本id
|
||||
* @return 脚本详情列表
|
||||
*/
|
||||
List<PqScriptDtls> listPqScriptDtlByScriptId(String scriptId);
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.gather.device.script.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
public interface IPqScriptService extends IService<PqScript> {
|
||||
|
||||
/**
|
||||
* 分页查询检测脚本
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return
|
||||
*/
|
||||
Page<PqScript> listPqScript(PqScriptParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 新增检测脚本
|
||||
*
|
||||
* @param param 检测脚本
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean addPqScript(PqScriptParam param);
|
||||
|
||||
/**
|
||||
* 删除检测脚本
|
||||
*
|
||||
* @param param 检测脚本id
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean updatePqScript(PqScriptParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 批量删除检测脚本
|
||||
*
|
||||
* @param ids 检测脚本id列表
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean deletePqScript(List<String> ids);
|
||||
|
||||
/**
|
||||
* 将脚本升级为模板
|
||||
* @param id 脚本id
|
||||
* @return 成功返回true, 失败返回false
|
||||
*/
|
||||
boolean upgradeToTemplate(String id);
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.device.script.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.github.yulichang.wrapper.MPJLambdaWrapper;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.gather.device.script.mapper.PqScriptDtlsMapper;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScriptDtls;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptDtlsServiceImpl extends ServiceImpl<PqScriptDtlsMapper, PqScriptDtls> implements IPqScriptDtlsService {
|
||||
|
||||
@Override
|
||||
public boolean savePqScriptDtls(PqScriptDtls pqScriptDtls) {
|
||||
return this.save(pqScriptDtls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqScriptDtlsByIds(List<String> ids) {
|
||||
LambdaQueryWrapper<PqScriptDtls> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(PqScriptDtls::getId, ids);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqScriptDtlsByScriptId(List<String> scriptIds) {
|
||||
LambdaQueryWrapper<PqScriptDtls> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.in(PqScriptDtls::getScriptId, scriptIds);
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqScriptDtls(PqScriptDtls pqScriptDtls) {
|
||||
return this.updateById(pqScriptDtls);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<PqScriptDtls> listPqScriptDtlByScriptId(String scriptId) {
|
||||
MPJLambdaWrapper<PqScriptDtls> queryWrapper = new MPJLambdaWrapper<>();
|
||||
queryWrapper.selectAll(PqScriptDtls.class)
|
||||
.leftJoin(PqScript.class, PqScript::getId, PqScriptDtls::getScriptId)
|
||||
.eq(PqScript::getState, DataStateEnum.ENABLE.getCode())
|
||||
.eq(PqScriptDtls::getScriptId, scriptId);
|
||||
return this.getBaseMapper().selectJoinList(PqScriptDtls.class, queryWrapper);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
package com.njcn.gather.device.script.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.core.conditions.update.LambdaUpdateWrapper;
|
||||
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.gather.device.script.mapper.PqScriptMapper;
|
||||
import com.njcn.gather.device.script.pojo.param.PqScriptParam;
|
||||
import com.njcn.gather.device.script.pojo.po.PqScript;
|
||||
import com.njcn.gather.device.script.service.IPqScriptDtlsService;
|
||||
import com.njcn.gather.device.script.service.IPqScriptService;
|
||||
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.time.LocalDate;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-18
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqScriptServiceImpl extends ServiceImpl<PqScriptMapper, PqScript> implements IPqScriptService {
|
||||
|
||||
private final IPqScriptDtlsService pqScriptDtlsService;
|
||||
|
||||
@Override
|
||||
public Page<PqScript> listPqScript(PqScriptParam.QueryParam param) {
|
||||
QueryWrapper<PqScript> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotEmpty(param)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(param.getName()), "pq_script.name", param.getName())
|
||||
.eq(ObjectUtil.isNotNull(param.getType()), "pq_script.type", param.getType())
|
||||
.eq(StrUtil.isNotBlank(param.getValueType()), "pq_script.Value_Type", param.getValueType())
|
||||
.eq(StrUtil.isNotBlank(param.getPattern()), "pq_script.pattern", param.getPattern());
|
||||
}
|
||||
queryWrapper.eq("pq_script.state", DataStateEnum.ENABLE.getCode()).orderByAsc("pq_script.create_time");
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqScript(PqScriptParam param) {
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
pqScript.setStandardTime(LocalDate.of(Integer.parseInt(param.getStandardTime()), 1, 1));
|
||||
pqScript.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqScript);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqScript(PqScriptParam.UpdateParam param) {
|
||||
PqScript pqScript = new PqScript();
|
||||
BeanUtils.copyProperties(param, pqScript);
|
||||
pqScript.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.updateById(pqScript);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqScript(List<String> ids) {
|
||||
//删除对应的脚本详情
|
||||
pqScriptDtlsService.deletePqScriptDtlsByScriptId(ids);
|
||||
LambdaUpdateWrapper<PqScript> updateWrapper = new LambdaUpdateWrapper<>();
|
||||
updateWrapper.set(PqScript::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(PqScript::getId, ids);
|
||||
return this.update(updateWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean upgradeToTemplate(String id) {
|
||||
PqScript pqScript = this.lambdaQuery().eq(PqScript::getId, id).one();
|
||||
if (pqScript != null) {
|
||||
pqScript.setType(1);
|
||||
return this.updateById(pqScript);
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.njcn.gather.device.source.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.source.pojo.param.PqSourceParam;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
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.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;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-28
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "检测源管理")
|
||||
@RestController
|
||||
@RequestMapping("/pqSource")
|
||||
@RequiredArgsConstructor
|
||||
public class PqSourceController extends BaseController {
|
||||
private final IPqSourceService pqSourceService;
|
||||
|
||||
@OperateInfo
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("分页查询检测源")
|
||||
@ApiImplicitParam(name = "param", value = "查询参数", required = true)
|
||||
public HttpResult<Page<PqSource>> list(@RequestBody @Validated PqSourceParam.QueryParam param) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, param);
|
||||
Page<PqSource> result = pqSourceService.listPqSource(param);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo
|
||||
@GetMapping("/getById")
|
||||
@ApiOperation("根据id查询检测源")
|
||||
@ApiImplicitParam(name = "id", value = "查询参数", required = true)
|
||||
public HttpResult<PqSource> getPqSourceById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("getById");
|
||||
LogUtil.njcnDebug(log, "{},查询ID为:{}", methodDescribe, id);
|
||||
PqSource result = pqSourceService.getPqSourceById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测源")
|
||||
@ApiImplicitParam(name = "param", value = "检测源", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated PqSourceParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, param);
|
||||
boolean result = pqSourceService.addPqSource(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 = "param", value = "检测源", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated PqSourceParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},修改数据为:{}", methodDescribe, param);
|
||||
boolean result = pqSourceService.updatePqSource(param);
|
||||
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 = pqSourceService.deletePqSource(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.device.source.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.device.source.pojo.po.PqSource;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-28
|
||||
*/
|
||||
public interface PqSourceMapper extends MPJBaseMapper<PqSource> {
|
||||
|
||||
}
|
||||
|
||||
@@ -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.source.mapper.PqSourceMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,84 @@
|
||||
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.web.pojo.param.BaseParam;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-28
|
||||
*/
|
||||
@Data
|
||||
public class PqSourceParam {
|
||||
|
||||
/**
|
||||
* 检测源名称(检测源类型 + 设备类型 + 数字自动生成)
|
||||
*/
|
||||
@ApiModelProperty(value = "检测源名称", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.PQ_SOURCE_NAME, message = DeviceValidMessage.PQ_SOURCE_NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 检测模式,字典表
|
||||
*/
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 检测源类型,字典表
|
||||
*/
|
||||
@ApiModelProperty(value = "检测源类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.PQ_SOURCE_TYPE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.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)
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty("源参数")
|
||||
private String parameter;
|
||||
|
||||
// @ApiModelProperty("源参数")
|
||||
// private List<PqSourceParameterParam> parameterList;
|
||||
|
||||
@Data
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty(value = "检测源名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("模式")
|
||||
@NotBlank(message = DeviceValidMessage.PATTERN_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PATTERN_FORMAT_ERROR)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty(value = "检测源类型")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.PQ_SOURCE_TYPE_FORMAT_ERROR)
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "设备类型")
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.DEV_TYPE_FORMAT_ERROR)
|
||||
private String devType;
|
||||
}
|
||||
|
||||
@Data
|
||||
@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)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
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.system.pojo.constant.SystemValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-26
|
||||
*/
|
||||
@Data
|
||||
public class PqSourceParameterParam {
|
||||
|
||||
@ApiModelProperty(value = "id", required = true)
|
||||
@NotNull(message = DeviceValidMessage.PQ_SOURCE_PARAMETER_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty(value = "pid", required = true)
|
||||
@NotNull(message = DeviceValidMessage.PQ_SOURCE_PARAMETER_PID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = DeviceValidMessage.ID_FORMAT_ERROR)
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 枚举类型,包括{ Connect,VOLRange,CURRange,DevInfo}
|
||||
*/
|
||||
@ApiModelProperty(value = "源类型", required = true)
|
||||
@NotBlank(message = DeviceValidMessage.PQ_SOURCE_PARAMETER_TYPE_NOT_BLANK)
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty(value = "描述")
|
||||
@NotBlank(message = DeviceValidMessage.PQ_SOURCE_PARAMETER_REMARK_NOT_BLANK)
|
||||
private String desc;
|
||||
|
||||
@ApiModelProperty(value = "参数值")
|
||||
@NotBlank(message = DeviceValidMessage.PQ_SOURCE_PARAMETER_VALUE_NOT_BLANK)
|
||||
private String value;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@NotNull(message = SystemValidMessage.SORT_NOT_NULL)
|
||||
@Min(value = 1, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
@Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package com.njcn.gather.device.source.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-11-28
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("pq_source")
|
||||
public class PqSource extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = -80375393371680137L;
|
||||
/**
|
||||
* 检测源ID
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测源名称(检测源类型 + 设备类型 + 数字自动生成)
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 检测模式,字典表
|
||||
*/
|
||||
private String pattern;
|
||||
|
||||
/**
|
||||
* 检测源类型,字典表
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 设备类型,字典表
|
||||
*/
|
||||
private String devType;
|
||||
|
||||
/**
|
||||
* 源参数
|
||||
*/
|
||||
private String parameter;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,28 @@
|
||||
package com.njcn.gather.device.source.pojo.po;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-28
|
||||
*/
|
||||
@Data
|
||||
public class PqSourceParameter {
|
||||
|
||||
private String id;
|
||||
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 枚举类型,包括{ Connect,VOLRange,CURRange,DevInfo}
|
||||
*/
|
||||
private String type;
|
||||
|
||||
private String desc;
|
||||
|
||||
private String value;
|
||||
|
||||
private Integer sort;
|
||||
}
|
||||
@@ -0,0 +1,55 @@
|
||||
package com.njcn.gather.device.source.service;
|
||||
|
||||
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 java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-28
|
||||
*/
|
||||
public interface IPqSourceService extends IService<PqSource> {
|
||||
|
||||
/**
|
||||
* 分页查询检测源
|
||||
*
|
||||
* @param param 查询参数
|
||||
* @return 分页数据
|
||||
*/
|
||||
Page<PqSource> listPqSource(PqSourceParam.QueryParam param);
|
||||
|
||||
/**
|
||||
* 根据id查询检测源
|
||||
*
|
||||
* @param id
|
||||
* @return
|
||||
*/
|
||||
PqSource getPqSourceById(String id);
|
||||
|
||||
/**
|
||||
* 新增检测源
|
||||
*
|
||||
* @param param 新增参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean addPqSource(PqSourceParam param);
|
||||
|
||||
/**
|
||||
* 修改检测源
|
||||
*
|
||||
* @param param 修改参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updatePqSource(PqSourceParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 删除检测源
|
||||
*
|
||||
* @param ids 检测源id列表
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deletePqSource(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
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 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.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.service.IPqSourceService;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-28
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqSourceServiceImpl extends ServiceImpl<PqSourceMapper, PqSource> implements IPqSourceService {
|
||||
|
||||
@Override
|
||||
public Page<PqSource> listPqSource(PqSourceParam.QueryParam param) {
|
||||
QueryWrapper<PqSource> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.select(PqSource.class, pqSource -> !pqSource.getColumn().equals("parameter"));
|
||||
if (ObjectUtil.isNotNull(param)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(param.getName()), "pq_source.name", param.getName())
|
||||
.eq(StrUtil.isNotBlank(param.getPattern()), "pq_source.pattern", param.getPattern())
|
||||
.eq(StrUtil.isNotBlank(param.getType()), "pq_source.type", param.getType())
|
||||
.eq(StrUtil.isNotBlank(param.getDevType()), "pq_source.Dev_Type", param.getDevType());
|
||||
}
|
||||
queryWrapper.eq("pq_source.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.page(new Page<>(PageFactory.getPageNum(param), PageFactory.getPageSize(param)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PqSource getPqSourceById(String id) {
|
||||
return this.lambdaQuery().eq(PqSource::getId, id).eq(PqSource::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqSource(PqSourceParam param) {
|
||||
PqSource pqSource = new PqSource();
|
||||
BeanUtil.copyProperties(param, pqSource);
|
||||
pqSource.setParameter(StrUtil.isBlank(pqSource.getParameter()) ? null : pqSource.getParameter());
|
||||
pqSource.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(pqSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqSource(PqSourceParam.UpdateParam param) {
|
||||
PqSource pqSource = new PqSource();
|
||||
BeanUtil.copyProperties(param, pqSource);
|
||||
return this.updateById(pqSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqSource(List<String> ids) {
|
||||
return this.lambdaUpdate().in(PqSource::getId, ids).set(PqSource::getState, DataStateEnum.DELETED.getCode()).update();
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,16 @@
|
||||
<artifactId>system</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>device</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>user</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
||||
@@ -28,7 +28,7 @@ spring:
|
||||
mybatis-plus:
|
||||
mapper-locations: classpath*:com/njcn/**/mapping/*.xml
|
||||
#别名扫描
|
||||
type-aliases-package: com.njcn.gather.system.dictionary.pojo.po
|
||||
type-aliases-package: com.njcn.gather.system.dictionary.pojo.po,com.njcn.gather.machine.pojo.po
|
||||
configuration:
|
||||
#驼峰命名
|
||||
map-underscore-to-camel-case: true
|
||||
|
||||
1
pom.xml
1
pom.xml
@@ -11,6 +11,7 @@
|
||||
<module>entrance</module>
|
||||
<module>system</module>
|
||||
<module>user</module>
|
||||
<module>device</module>
|
||||
</modules>
|
||||
<packaging>pom</packaging>
|
||||
<name>融合各工具的项目</name>
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
系统模块主要包含以下功能:
|
||||
* 审计日志管理
|
||||
* 字典、树形字典管理
|
||||
* 版本注册
|
||||
* 主题管理
|
||||
* 系统文件资源管理
|
||||
* 定时任务管理
|
||||
|
||||
@@ -28,7 +28,11 @@
|
||||
<version>2.3.12</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>com.njcn.gather</groupId>
|
||||
<artifactId>user</artifactId>
|
||||
<version>1.0.0</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
@@ -1,34 +1,106 @@
|
||||
package com.njcn.gather.system.auth.controller;
|
||||
|
||||
import cn.hutool.core.date.DateUnit;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.extra.spring.SpringUtil;
|
||||
import com.njcn.common.bean.CustomCacheUtil;
|
||||
import com.njcn.common.pojo.annotation.OperateInfo;
|
||||
import com.njcn.common.pojo.constant.OperateType;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
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.JwtUtil;
|
||||
import com.njcn.common.utils.LogUtil;
|
||||
import com.njcn.db.mybatisplus.constant.UserConstant;
|
||||
import com.njcn.gather.system.auth.pojo.Token;
|
||||
import com.njcn.gather.user.pojo.constant.UserValidMessage;
|
||||
import com.njcn.gather.user.user.pojo.param.SysUserParam;
|
||||
import com.njcn.gather.user.user.pojo.po.SysUser;
|
||||
import com.njcn.gather.user.user.service.ISysUserService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.logging.log4j.util.Strings;
|
||||
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;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
@Slf4j
|
||||
@RestController
|
||||
@RequestMapping("admin")
|
||||
public class AuthController {
|
||||
@Api(tags = "登录/注销")
|
||||
@RequestMapping("/admin")
|
||||
@RequiredArgsConstructor
|
||||
public class AuthController extends BaseController {
|
||||
|
||||
@RequestMapping("/login")
|
||||
public HttpResult<Token> login() {
|
||||
Token token = new Token();
|
||||
token.setAccessToken("bqddxxwqmfncffacvbpkuxvwvqrhln");
|
||||
HttpResult<Token> result = new HttpResult<>();
|
||||
result.setMessage("成功");
|
||||
result.setCode("A0000");
|
||||
result.setData(token);
|
||||
return result;
|
||||
private final ISysUserService sysUserService;
|
||||
|
||||
// @RequestMapping("/login")
|
||||
// public HttpResult<Token> login() {
|
||||
// Token token = new Token();
|
||||
// token.setAccessToken("bqddxxwqmfncffacvbpkuxvwvqrhln");
|
||||
// HttpResult<Token> result = new HttpResult<>();
|
||||
// result.setMessage("成功");
|
||||
// result.setCode("A0000");
|
||||
// result.setData(token);
|
||||
// return result;
|
||||
// }
|
||||
//
|
||||
// @RequestMapping("/logout")
|
||||
// public HttpResult<String> logout() {
|
||||
// HttpResult<String> result = new HttpResult<>();
|
||||
// result.setMessage("成功");
|
||||
// result.setCode("A0000");
|
||||
// result.setData("退出成功");
|
||||
// return result;
|
||||
// }
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.AUTHENTICATE)
|
||||
@PostMapping("/login")
|
||||
@ApiOperation("登录")
|
||||
public HttpResult<Object> login(@RequestBody SysUserParam.LoginParam param) {
|
||||
String methodDescribe = getMethodDescribe("login");
|
||||
LogUtil.njcnDebug(log, "{},登录参数为:{}", methodDescribe, param);
|
||||
SysUser user = sysUserService.getUserByLoginNameAndPassword(param.getUsername(), param.getPassword());
|
||||
if (user == null) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, UserValidMessage.LOGIN_FAILED);
|
||||
} else {
|
||||
String tokenStr = JwtUtil.generateToken(user.getId());
|
||||
Token token = new Token();
|
||||
token.setAccessToken(tokenStr);
|
||||
Map<String, Object> map = new HashMap<>();
|
||||
map.put("name", user.getName());
|
||||
token.setUserInfo(map);
|
||||
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
|
||||
customCacheUtil.putWithExpireTime(UserConstant.USER_ID, user.getId(), DateUnit.DAY.getMillis());
|
||||
customCacheUtil.putWithExpireTime(UserConstant.USER_NAME, user.getName(), DateUnit.DAY.getMillis());
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, token, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@RequestMapping("/logout")
|
||||
public HttpResult<String> logout() {
|
||||
HttpResult<String> result = new HttpResult<>();
|
||||
result.setMessage("成功");
|
||||
result.setCode("A0000");
|
||||
result.setData("退出成功");
|
||||
return result;
|
||||
@OperateInfo(info = LogEnum.SYSTEM_SERIOUS, operateType = OperateType.LOGOUT)
|
||||
@ApiOperation("注销登录")
|
||||
@PostMapping("/logout")
|
||||
public HttpResult<Object> logout(HttpServletRequest request) {
|
||||
String methodDescribe = getMethodDescribe("logout");
|
||||
LogUtil.njcnDebug(log, "{},注销登录", methodDescribe);
|
||||
String authorization = request.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
||||
if (StrUtil.isNotBlank(authorization)) {
|
||||
String token = authorization.replace(SecurityConstants.AUTHORIZATION_PREFIX, Strings.EMPTY);
|
||||
CustomCacheUtil customCacheUtil = SpringUtil.getBean(CustomCacheUtil.CACHE_NAME);
|
||||
customCacheUtil.remove(UserConstant.USER_ID);
|
||||
JwtUtil.invalidateToken(token);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
}
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,76 @@
|
||||
package com.njcn.gather.system.auth.filter;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.njcn.common.pojo.constant.SecurityConstants;
|
||||
import com.njcn.common.utils.JwtUtil;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import javax.servlet.*;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
import java.io.IOException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/18
|
||||
*/
|
||||
@Slf4j
|
||||
@Component
|
||||
public class AuthGlobalFilter implements Filter, Ordered {
|
||||
private final static List<String> IGNORE_URI = Arrays.asList("/admin/login");
|
||||
|
||||
@Override
|
||||
public int getOrder() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
|
||||
|
||||
HttpServletRequest req = (HttpServletRequest) request;
|
||||
HttpServletResponse res = (HttpServletResponse) response;
|
||||
|
||||
//设置允许跨域的配置
|
||||
// 这里填写允许进行跨域的主机ip(正式上线时可以动态配置具体允许的域名和IP)
|
||||
//rep.setHeader("Access-Control-Allow-Origin", "*");
|
||||
// 允许的访问方法
|
||||
//rep.setHeader("Access-Control-Allow-Methods", "POST, GET, PUT, OPTIONS, DELETE, PATCH");
|
||||
// Access-Control-Max-Age 用于 CORS 相关配置的缓存
|
||||
//rep.setHeader("Access-Control-Max-Age", "3600");
|
||||
//rep.setHeader("Access-Control-Allow-Headers", "token,Origin, X-Requested-With, Content-Type, Accept");
|
||||
|
||||
|
||||
res.setCharacterEncoding("UTF-8");
|
||||
res.setContentType("application/json; charset=utf-8");
|
||||
|
||||
String requestURI = req.getRequestURI();
|
||||
if (IGNORE_URI.contains(requestURI)) {
|
||||
filterChain.doFilter(req, res);
|
||||
} else {
|
||||
String tokenStr = req.getHeader(SecurityConstants.AUTHORIZATION_KEY);
|
||||
if (StrUtil.isBlank(tokenStr) || !tokenStr.startsWith(SecurityConstants.AUTHORIZATION_PREFIX)) {
|
||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
res.getWriter().write(SystemValidMessage.TOKEN_VALID_ERROR);
|
||||
return;
|
||||
}
|
||||
tokenStr = tokenStr.substring(SecurityConstants.AUTHORIZATION_PREFIX.length());
|
||||
try {
|
||||
if (StrUtil.isBlank(tokenStr) || !JwtUtil.verifyToken(tokenStr) || JwtUtil.isExpired(tokenStr)) {
|
||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
res.getWriter().write(SystemValidMessage.TOKEN_VALID_ERROR);
|
||||
} else {
|
||||
filterChain.doFilter(req, res);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
res.setStatus(HttpServletResponse.SC_UNAUTHORIZED);
|
||||
res.getWriter().write(SystemValidMessage.TOKEN_VALID_ERROR);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,13 @@ package com.njcn.gather.system.auth.pojo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class Token {
|
||||
|
||||
private String accessToken;
|
||||
|
||||
private Map<String, Object> userInfo;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package com.njcn.gather.system.config.controller;
|
||||
|
||||
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.config.pojo.param.SysTestConfigParam;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||
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.*;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "检测相关配置")
|
||||
@RestController
|
||||
@RequestMapping("/sysTestConfig")
|
||||
@RequiredArgsConstructor
|
||||
public class SysTestConfigController extends BaseController {
|
||||
private final ISysTestConfigService sysTestConfigService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getConfig")
|
||||
@ApiOperation("获取检测相关配置信息")
|
||||
public HttpResult<SysTestConfig> getConfig() {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
SysTestConfig sysTestConfig = sysTestConfigService.getConfig();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, sysTestConfig, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增检测相关配置信息")
|
||||
@ApiImplicitParam(name = "sysTestConfig", value = "检测相关配置信息", required = true)
|
||||
public HttpResult<Boolean> add(@RequestBody @Validated SysTestConfigParam param) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
boolean result = sysTestConfigService.addTestConfig(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改检测相关配置信息")
|
||||
@ApiImplicitParam(name = "sysTestConfig", value = "检测相关配置信息", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated SysTestConfigParam.UpdateParam sysTestConfig) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{}", methodDescribe);
|
||||
boolean result = sysTestConfigService.updateTestConfig(sysTestConfig);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.system.config.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
public interface SysTestConfigMapper extends MPJBaseMapper<SysTestConfig> {
|
||||
|
||||
}
|
||||
|
||||
@@ -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.config.mapper.SysTestConfigMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,39 @@
|
||||
package com.njcn.gather.system.config.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.*;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/16
|
||||
*/
|
||||
@Data
|
||||
public class SysTestConfigParam {
|
||||
|
||||
@ApiModelProperty(value = "检测报告是否自动生成0 否;1是")
|
||||
@NotNull(message = SystemValidMessage.AUTO_GENERATE_NOT_NULL)
|
||||
@Min(value = 0, message = SystemValidMessage.AUTO_GENERATE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = SystemValidMessage.AUTO_GENERATE_FORMAT_ERROR)
|
||||
private Integer autoGenerate;
|
||||
|
||||
@ApiModelProperty(value = "最大复检次数")
|
||||
@NotNull(message = SystemValidMessage.MAX_RECHECK_NOT_NULL)
|
||||
private Integer maxTime;
|
||||
|
||||
@ApiModelProperty(value = "数据处理规则")
|
||||
@NotBlank(message = SystemValidMessage.DATA_RULE_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DATA_RULE_FORMAT_ERROR)
|
||||
private String dataRule;
|
||||
|
||||
@Data
|
||||
public static class UpdateParam extends SysTestConfigParam {
|
||||
@ApiModelProperty("id")
|
||||
@NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
package com.njcn.gather.system.config.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_test_config")
|
||||
public class SysTestConfig extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 352471858515754310L;
|
||||
/**
|
||||
* 系统配置表Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 检测报告是否自动生成: 0 否;1 是
|
||||
*/
|
||||
@TableField("Auto_Generate")
|
||||
private Integer autoGenerate;
|
||||
|
||||
/**
|
||||
* 最大复检次数,默认3次
|
||||
*/
|
||||
@TableField("Max_Time")
|
||||
private Integer maxTime;
|
||||
|
||||
/**
|
||||
* 数据处理规则, 关联字典(所有值、部分值、cp95值、平均值、任意值),默认任意值
|
||||
*/
|
||||
@TableField("Data_Rule")
|
||||
private String dataRule;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.njcn.gather.system.config.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.config.pojo.param.SysTestConfigParam;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
public interface ISysTestConfigService extends IService<SysTestConfig> {
|
||||
|
||||
/**
|
||||
* 获取检测配置
|
||||
* @return
|
||||
*/
|
||||
SysTestConfig getConfig();
|
||||
|
||||
/**
|
||||
* 添加检测配置
|
||||
* @param param 检测配置
|
||||
* @return 是否添加成功
|
||||
*/
|
||||
boolean addTestConfig(SysTestConfigParam param);
|
||||
|
||||
/**
|
||||
* 更新检测配置
|
||||
* @param param 检测配置
|
||||
* @return 是否更新成功
|
||||
*/
|
||||
boolean updateTestConfig(SysTestConfigParam.UpdateParam param);
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.njcn.gather.system.config.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.gather.system.config.mapper.SysTestConfigMapper;
|
||||
import com.njcn.gather.system.config.pojo.param.SysTestConfigParam;
|
||||
import com.njcn.gather.system.config.pojo.po.SysTestConfig;
|
||||
import com.njcn.gather.system.config.service.ISysTestConfigService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-16
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysTestConfigServiceImpl extends ServiceImpl<SysTestConfigMapper, SysTestConfig> implements ISysTestConfigService {
|
||||
|
||||
@Override
|
||||
public SysTestConfig getConfig() {
|
||||
return this.getOne(new QueryWrapper<SysTestConfig>().last("LIMIT 1"));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addTestConfig(SysTestConfigParam param) {
|
||||
SysTestConfig sysTestConfig = new SysTestConfig();
|
||||
BeanUtils.copyProperties(param, sysTestConfig);
|
||||
sysTestConfig.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(sysTestConfig);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateTestConfig(SysTestConfigParam.UpdateParam param) {
|
||||
SysTestConfig sysTestConfig = new SysTestConfig();
|
||||
BeanUtils.copyProperties(param, sysTestConfig);
|
||||
return this.updateById(sysTestConfig);
|
||||
}
|
||||
}
|
||||
@@ -47,14 +47,13 @@ public class DictDataController extends BaseController {
|
||||
@PostMapping("/listByTypeId")
|
||||
@ApiOperation("根据字典类型id查询字典数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<DictData>> listByTypeId(@RequestBody @Validated DictDataParam.DicTypeIdQueryParam queryParam) {
|
||||
public HttpResult<Page<DictData>> listByTypeId(@RequestBody @Validated DictDataParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("listByTypeId");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<DictData> result = dictDataService.getTypeIdData(queryParam);
|
||||
Page<DictData> result = dictDataService.getDictDataByTypeId(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 新增字典数据
|
||||
*
|
||||
@@ -82,7 +81,7 @@ public class DictDataController extends BaseController {
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改字典数据")
|
||||
@ApiImplicitParam(name = "updateParam", value = "字典数据", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated DictDataParam.DictDataUpdateParam updateParam) {
|
||||
public HttpResult<Object> update(@RequestBody @Validated DictDataParam.UpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = dictDataService.updateDictData(updateParam);
|
||||
@@ -93,7 +92,6 @@ public class DictDataController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 批量删除字典数据
|
||||
*/
|
||||
@@ -112,14 +110,13 @@ public class DictDataController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getDicDataById")
|
||||
@ApiOperation("根据字典id查询字典数据")
|
||||
@ApiImplicitParam(name = "dicIndex", value = "查询参数", required = true)
|
||||
public HttpResult<DictData> getDicDataById(@RequestParam("dicIndex") String dicIndex) {
|
||||
String methodDescribe = getMethodDescribe("getDicDataById");
|
||||
DictData result = dictDataService.getDicDataById(dicIndex);
|
||||
DictData result = dictDataService.getDictDataById(dicIndex);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@@ -129,11 +126,10 @@ public class DictDataController extends BaseController {
|
||||
@ApiImplicitParam(name = "code", value = "查询参数", required = true)
|
||||
public HttpResult<DictData> getDicDataByCode(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("getDicDataByCode");
|
||||
DictData result = dictDataService.getDicDataByCode(code);
|
||||
DictData result = dictDataService.getDictDataByCode(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 获取所有字典数据基础信息
|
||||
*/
|
||||
@@ -151,5 +147,12 @@ public class DictDataController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出字典数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated DictDataParam.QueryParam queryParam) {
|
||||
dictDataService.exportDictData(queryParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,93 @@
|
||||
package com.njcn.gather.system.dictionary.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.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.dictionary.pojo.param.DictPqParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictPq;
|
||||
import com.njcn.gather.system.dictionary.service.IDictPqService;
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/05
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "电能质量指标字典操作")
|
||||
@RestController
|
||||
@RequestMapping("/dictPq")
|
||||
@RequiredArgsConstructor
|
||||
public class DictPqController extends BaseController {
|
||||
|
||||
private final IDictPqService dictPqService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("查询电能质量指标字典")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<DictPq>> list(@RequestBody @Validated DictPqParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<DictPq> result = dictPqService.listDictPqs(queryParam);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增电能质量指标字典")
|
||||
public HttpResult<Object> add(@RequestBody @Validated DictPqParam dictPqParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, dictPqParam);
|
||||
boolean result = dictPqService.addDictPq(dictPqParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("更新电能质量指标字典")
|
||||
@ApiImplicitParam(name = "updateParam", value = "更新参数", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated DictPqParam.UpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},更新数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = dictPqService.updateDictPq(updateParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除电能质量指标字典")
|
||||
@ApiImplicitParam(name = "ids", value = "字典索引", 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 = dictPqService.deleteDictPq(ids);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,181 @@
|
||||
package com.njcn.gather.system.dictionary.controller;
|
||||
|
||||
|
||||
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.dictionary.pojo.param.DictTreeParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.pojo.vo.DictTreeVO;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* 前端控制器
|
||||
* </p>
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@Validated
|
||||
@Slf4j
|
||||
@Api(tags = "字典树操作")
|
||||
@RestController
|
||||
@RequestMapping("/dictTree")
|
||||
@RequiredArgsConstructor
|
||||
public class DictTreeController extends BaseController {
|
||||
|
||||
private final IDictTreeService dictTreeService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getTree")
|
||||
@ApiOperation("按照名称模糊查询字典树")
|
||||
@ApiImplicitParam(name = "keyword", value = "查询参数", required = true)
|
||||
public HttpResult<List<DictTree>> getDictTreeByKeyword(@RequestParam String keyword) {
|
||||
String methodDescribe = getMethodDescribe("getDictTreeByKeyword");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, keyword);
|
||||
List<DictTree> result = dictTreeService.getDictTreeByKeyword(keyword);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增字典树数据")
|
||||
@ApiImplicitParam(name = "dictTreeParam", value = "字典数据", required = true)
|
||||
public HttpResult<Object> add(@RequestBody @Validated DictTreeParam dictTreeParam) {
|
||||
String methodDescribe = getMethodDescribe("add");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, dictTreeParam);
|
||||
boolean result = dictTreeService.addDictTree(dictTreeParam);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改
|
||||
* @param dicParam 修改参数
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改")
|
||||
@ApiImplicitParam(name = "dicParam", value = "数据", required = true)
|
||||
public HttpResult<Boolean> update(@RequestBody @Validated DictTreeParam.UpdateParam dicParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},更新的信息为:{}", methodDescribe,dicParam);
|
||||
boolean result = dictTreeService.updateDictTree(dicParam);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除
|
||||
* @param id id
|
||||
*/
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除")
|
||||
@ApiImplicitParam(name = "id", value = "id", required = true)
|
||||
public HttpResult<Boolean> delete(@RequestParam @Validated String id) {
|
||||
String methodDescribe = getMethodDescribe("delete");
|
||||
LogUtil.njcnDebug(log, "{},删除的id为:{}", methodDescribe,id);
|
||||
boolean result = dictTreeService.deleteDictTree(id);
|
||||
if (result){
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, true, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, false, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/query")
|
||||
@ApiOperation("根据pid查询字典树")
|
||||
public HttpResult<List<DictTreeVO>> query(@RequestParam("pid") String pid) {
|
||||
String methodDescribe = getMethodDescribe("query");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, pid);
|
||||
List<DictTreeVO> result = dictTreeService.queryByPid(pid);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryByCodeList")
|
||||
@ApiOperation("根据Code查询字典树")
|
||||
public HttpResult<List<DictTree>> queryByCodeList(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("queryByCodeList");
|
||||
List<DictTree> result = dictTreeService.queryByCodeList(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryByCode")
|
||||
@ApiOperation("根据Code查询字典树")
|
||||
public HttpResult<DictTreeVO> queryByCode(@RequestParam("code") String code) {
|
||||
String methodDescribe = getMethodDescribe("queryByCode");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, code);
|
||||
DictTreeVO result = dictTreeService.queryByCode(code);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryLastLevelById")
|
||||
@ApiOperation("根据id查询字典树最底层")
|
||||
public HttpResult<List<DictTreeVO>> queryLastLevelById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("queryLastLevelById");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, id);
|
||||
List<DictTreeVO> result = dictTreeService.queryLastLevelById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@PostMapping("/queryById")
|
||||
@ApiOperation("根据id查询数据")
|
||||
public HttpResult<DictTree> queryById(@RequestParam("id") String id) {
|
||||
String methodDescribe = getMethodDescribe("queryById");
|
||||
LogUtil.njcnDebug(log, "{},字典数据为:{}", methodDescribe, id);
|
||||
DictTree result = dictTreeService.queryById(id);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/queryAll")
|
||||
@ApiOperation("查询所有树形字典")
|
||||
public HttpResult<List<DictTree>> queryAll() {
|
||||
String methodDescribe = getMethodDescribe("queryAll");
|
||||
List<DictTree> result = dictTreeService.queryAll();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/queryAllByType")
|
||||
@ApiOperation("分类查询所有树形字典")
|
||||
public HttpResult<List<DictTree>> queryAllByType(@RequestParam("type")Integer type) {
|
||||
String methodDescribe = getMethodDescribe("queryAll");
|
||||
List<DictTree> result = dictTreeService.queryAllByType(type);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -27,7 +27,6 @@ import org.springframework.web.bind.annotation.*;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author hongawen
|
||||
* @since 2021-12-13
|
||||
*/
|
||||
@@ -45,7 +44,7 @@ public class DictTypeController extends BaseController {
|
||||
@PostMapping("/list")
|
||||
@ApiOperation("查询字典类型")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public HttpResult<Page<DictType>> list(@RequestBody @Validated DictTypeParam.DictTypeQueryParam queryParam) {
|
||||
public HttpResult<Page<DictType>> list(@RequestBody @Validated DictTypeParam.QueryParam queryParam) {
|
||||
String methodDescribe = getMethodDescribe("list");
|
||||
LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam);
|
||||
Page<DictType> result = dictTypeService.listDictTypes(queryParam);
|
||||
@@ -62,7 +61,6 @@ public class DictTypeController extends BaseController {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, dictTypeList, methodDescribe);
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增字典类型")
|
||||
@@ -78,12 +76,11 @@ public class DictTypeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改字典类型")
|
||||
@ApiImplicitParam(name = "updateParam", value = "字典类型数据", required = true)
|
||||
public HttpResult<Object> update(@RequestBody @Validated DictTypeParam.DictTypeUpdateParam updateParam) {
|
||||
public HttpResult<Object> update(@RequestBody @Validated DictTypeParam.UpdateParam updateParam) {
|
||||
String methodDescribe = getMethodDescribe("update");
|
||||
LogUtil.njcnDebug(log, "{},字典类型数据为:{}", methodDescribe, updateParam);
|
||||
boolean result = dictTypeService.updateDictType(updateParam);
|
||||
@@ -94,8 +91,6 @@ public class DictTypeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DELETE)
|
||||
@PostMapping("/delete")
|
||||
@ApiOperation("删除字典类型")
|
||||
@@ -111,7 +106,12 @@ public class DictTypeController extends BaseController {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.DOWNLOAD)
|
||||
@PostMapping("/export")
|
||||
@ApiOperation("导出字典类型数据")
|
||||
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
|
||||
public void export(@RequestBody @Validated DictTypeParam.QueryParam queryParam) {
|
||||
dictTypeService.exportDictType(queryParam);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
package com.njcn.gather.system.dictionary.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictPq;
|
||||
|
||||
public interface DictPqMapper extends MPJBaseMapper<DictPq> {
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.njcn.gather.system.dictionary.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.pojo.vo.DictTreeVO;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/8
|
||||
*/
|
||||
public interface DictTreeMapper extends BaseMapper<DictTree> {
|
||||
List<DictTreeVO> queryLastLevelById(@Param("id") String id);
|
||||
}
|
||||
@@ -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.dictionary.mapper.DictPqMapper">
|
||||
|
||||
|
||||
|
||||
</mapper>
|
||||
@@ -0,0 +1,19 @@
|
||||
<?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.dictionary.mapper.DictTreeMapper">
|
||||
<select id="queryLastLevelById" resultType="com.njcn.gather.system.dictionary.pojo.vo.DictTreeVO">
|
||||
SELECT
|
||||
*
|
||||
FROM
|
||||
sys_dict_tree a
|
||||
WHERE
|
||||
a.pids LIKE concat('%',#{id},'%')
|
||||
AND NOT EXISTS (
|
||||
SELECT
|
||||
1
|
||||
FROM
|
||||
sys_dict_tree b
|
||||
WHERE
|
||||
b.pids LIKE concat('%',#{id},'%') and a.id = b.pid)
|
||||
</select>
|
||||
</mapper>
|
||||
@@ -38,7 +38,7 @@ public class DictDataParam {
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@NotNull(message = SystemValidMessage.SORT_NOT_NULL)
|
||||
@Min(value = 0, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
@Min(value = 1, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
@Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
private Integer sort;
|
||||
|
||||
@@ -49,8 +49,8 @@ public class DictDataParam {
|
||||
@ApiModelProperty("与高级算法内部Id描述对应")
|
||||
private Integer algoDescribe;
|
||||
|
||||
|
||||
@ApiModelProperty("字典值,用于记录字典的计算值如10kV记录为 10")
|
||||
//todo 待定
|
||||
@ApiModelProperty("字典值")
|
||||
private String value;
|
||||
|
||||
|
||||
@@ -59,7 +59,7 @@ public class DictDataParam {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class DictDataUpdateParam extends DictDataParam {
|
||||
public static class UpdateParam extends DictDataParam {
|
||||
|
||||
/**
|
||||
* 表Id
|
||||
@@ -68,17 +68,6 @@ public class DictDataParam {
|
||||
@NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class DictDataQueryParam extends BaseParam {
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -86,7 +75,7 @@ public class DictDataParam {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class DicTypeIdQueryParam extends BaseParam {
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("字典类型id")
|
||||
@NotBlank(message = SystemValidMessage.DICT_TYPE_ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.DICT_TYPE_ID_FORMAT_ERROR)
|
||||
|
||||
@@ -0,0 +1,149 @@
|
||||
package com.njcn.gather.system.dictionary.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.*;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
public class DictPqParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DIC_REGEX, message = SystemValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("相别")
|
||||
@NotBlank(message = SystemValidMessage.PHASE_NOT_BLANK)
|
||||
private String phase;
|
||||
|
||||
@ApiModelProperty("数据模型")
|
||||
@NotBlank(message = SystemValidMessage.DATA_TYPE_NOT_BLANK)
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("别名,默认与名称相同")
|
||||
private String otherName;
|
||||
|
||||
@ApiModelProperty("显示名称")
|
||||
private String showName;
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@NotNull(message = SystemValidMessage.SORT_NOT_NULL)
|
||||
@Min(value = 1, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
@Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
private Integer sort;
|
||||
|
||||
@ApiModelProperty("指标数据类型(整型、浮点型、枚举型)")
|
||||
private String type;
|
||||
|
||||
@ApiModelProperty("单位")
|
||||
private String unit;
|
||||
|
||||
@ApiModelProperty("起始次数")
|
||||
private Integer harmStart;
|
||||
|
||||
@ApiModelProperty("结束次数")
|
||||
private Integer harmEnd;
|
||||
|
||||
@ApiModelProperty("数据表表名")
|
||||
@NotBlank(message = SystemValidMessage.CLASS_ID_NOT_BLANK)
|
||||
private String classId;
|
||||
|
||||
@ApiModelProperty("数据统计类型(最大、最小、平均、CP95)")
|
||||
private String statMethod;
|
||||
|
||||
@ApiModelProperty("系统类别(区分用能/电能)")
|
||||
private String systemType;
|
||||
|
||||
@ApiModelProperty("数据是否上送(0:不上送 1:上送)")
|
||||
private Integer tranFlag;
|
||||
|
||||
@ApiModelProperty("上送规则 变化: \"change\" 周期: \"period\"")
|
||||
private String tranRule;
|
||||
|
||||
@ApiModelProperty("evt的事件类别 \"1\"、\"2\"")
|
||||
private String eventType;
|
||||
|
||||
@ApiModelProperty("sts、di的是否存储 1:存储 0:不存储")
|
||||
private Integer storeFlag;
|
||||
|
||||
@ApiModelProperty("sts、do的当前值")
|
||||
private Integer curSts;
|
||||
|
||||
@ApiModelProperty("do的是否可远程控制 1:是 0:否;")
|
||||
private Integer ctlSts;
|
||||
|
||||
@ApiModelProperty("设置最大值")
|
||||
private Double maxNum;
|
||||
|
||||
@ApiModelProperty("设置最小值")
|
||||
private Double minNum;
|
||||
|
||||
@ApiModelProperty("参数为enum可设置的所有值序列")
|
||||
private String setValue;
|
||||
|
||||
@ApiModelProperty("参数string可设置字符串的长度上限")
|
||||
private Integer strlen;
|
||||
|
||||
@ApiModelProperty("参数缺省值、告警code值")
|
||||
private String defaultValue;
|
||||
|
||||
@ApiModelProperty("报表数据来源(统计表表名)")
|
||||
private String resourcesId;
|
||||
|
||||
@ApiModelProperty("限值字段名称")
|
||||
private String limitName;
|
||||
|
||||
@ApiModelProperty("限值表名")
|
||||
private String limitTable;
|
||||
|
||||
@ApiModelProperty("超标判断方式")
|
||||
private String formula;
|
||||
|
||||
@ApiModelProperty("二次值转一次值公式")
|
||||
private String primaryFormula;
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends DictPqParam {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class QueryParam extends BaseParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("别名")
|
||||
private String otherName;
|
||||
|
||||
@ApiModelProperty("显示名称")
|
||||
private String showName;
|
||||
|
||||
@ApiModelProperty("数据模型")
|
||||
private String dataType;
|
||||
|
||||
@ApiModelProperty("数据表表名")
|
||||
private String classId;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.njcn.gather.system.dictionary.pojo.param;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/8
|
||||
*/
|
||||
@Data
|
||||
public class DictTreeParam {
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
@ApiModelProperty(value = "父id")
|
||||
private String pid;
|
||||
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@ApiModelProperty(value = "名称")
|
||||
@NotBlank(message = SystemValidMessage.NAME_NOT_BLANK)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@TableField(value = "编码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 用于区分多种类型的字典树 0.台账对象类型 1.自定义报表指标类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 根据type自定义内容,type:0用于区分对象类型是101电网侧 102用户侧
|
||||
*/
|
||||
private String extend;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class UpdateParam extends DictTreeParam {
|
||||
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
}
|
||||
}
|
||||
@@ -30,22 +30,22 @@ public class DictTypeParam {
|
||||
|
||||
@ApiModelProperty("排序")
|
||||
@NotNull(message = SystemValidMessage.SORT_NOT_NULL)
|
||||
@Min(value = 0, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
@Min(value = 1, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
@Max(value = 999, message = SystemValidMessage.SORT_FORMAT_ERROR)
|
||||
private Integer sort;
|
||||
|
||||
|
||||
@ApiModelProperty("开启等级:0-不开启;1-开启,默认不开启")
|
||||
// @NotNull(message = SystemValidMessage.OPEN_LEVEL_NOT_NULL)
|
||||
// @Min(value = 0, message = SystemValidMessage.OPEN_LEVEL_FORMAT_ERROR)
|
||||
// @Max(value = 1, message = SystemValidMessage.OPEN_LEVEL_FORMAT_ERROR)
|
||||
@NotNull(message = SystemValidMessage.OPEN_LEVEL_NOT_NULL)
|
||||
@Min(value = 0, message = SystemValidMessage.OPEN_LEVEL_FORMAT_ERROR)
|
||||
@Max(value = 1, message = SystemValidMessage.OPEN_LEVEL_FORMAT_ERROR)
|
||||
private Integer openLevel;
|
||||
|
||||
|
||||
@ApiModelProperty("开启算法描述:0-不开启;1-开启,默认不开启")
|
||||
// @NotNull(message = SystemValidMessage.OPEN_DESCRIBE_NOT_NULL)
|
||||
// @Min(value = 0, message = SystemValidMessage.OPEN_DESCRIBE_FORMAT_ERROR)
|
||||
// @Max(value = 1, message = SystemValidMessage.OPEN_DESCRIBE_FORMAT_ERROR)
|
||||
@NotNull(message = SystemValidMessage.OPEN_DESCRIBE_NOT_NULL)
|
||||
@Min(value = 0, message = SystemValidMessage.OPEN_DESCRIBE_FORMAT_ERROR)
|
||||
@Max(value = 1, message = SystemValidMessage.OPEN_DESCRIBE_FORMAT_ERROR)
|
||||
private Integer openDescribe;
|
||||
|
||||
|
||||
@@ -57,7 +57,7 @@ public class DictTypeParam {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class DictTypeUpdateParam extends DictTypeParam {
|
||||
public static class UpdateParam extends DictTypeParam {
|
||||
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@@ -72,7 +72,7 @@ public class DictTypeParam {
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class DictTypeQueryParam extends BaseParam {
|
||||
public static class QueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
private String name;
|
||||
|
||||
|
||||
@@ -0,0 +1,170 @@
|
||||
package com.njcn.gather.system.dictionary.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_dict_pq")
|
||||
public class DictPq extends BaseEntity {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 电能质量指标字典id
|
||||
*/
|
||||
public String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 相别
|
||||
*/
|
||||
private String phase;
|
||||
|
||||
/**
|
||||
* 数据模型 (epd、pqd...)
|
||||
*/
|
||||
private String dataType;
|
||||
|
||||
/**
|
||||
* 别名(默认与Name相同)
|
||||
*/
|
||||
private String otherName;
|
||||
|
||||
/**
|
||||
* 显示名称
|
||||
*/
|
||||
private String showName;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 指标数据类型(整型、浮点型、枚举型)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 单位
|
||||
*/
|
||||
private String unit;
|
||||
|
||||
/**
|
||||
* 起始次数
|
||||
*/
|
||||
private Integer harmStart;
|
||||
|
||||
/**
|
||||
* 结束次数
|
||||
*/
|
||||
private Integer harmEnd;
|
||||
|
||||
/**
|
||||
* 数据表表名
|
||||
*/
|
||||
private String classId;
|
||||
|
||||
/**
|
||||
* 数据统计类型(最大、最小、平均、CP95)
|
||||
*/
|
||||
private String statMethod;
|
||||
|
||||
/**
|
||||
* 系统类别(区分用能/电能)
|
||||
*/
|
||||
private String systemType;
|
||||
|
||||
/**
|
||||
* 数据是否上送(0:不上送 1:上送)
|
||||
*/
|
||||
private Integer tranFlag;
|
||||
|
||||
/**
|
||||
* 上送规则 变化: "change" 周期: "period"
|
||||
*/
|
||||
private String tranRule;
|
||||
|
||||
/**
|
||||
* evt的事件类别 "1"、"2"
|
||||
*/
|
||||
private String eventType;
|
||||
|
||||
/**
|
||||
* sts、di的是否存储 1:存储 0:不存储
|
||||
*/
|
||||
private Integer storeFlag;
|
||||
|
||||
/**
|
||||
* sts、do的当前值
|
||||
*/
|
||||
private Integer curSts;
|
||||
|
||||
/**
|
||||
* do的是否可远程控制 1:是 0:否
|
||||
*/
|
||||
private Integer ctlSts;
|
||||
|
||||
/**
|
||||
* 设置最大值
|
||||
*/
|
||||
private BigDecimal maxNum;
|
||||
|
||||
/**
|
||||
* 设置最小值
|
||||
*/
|
||||
private BigDecimal minNum;
|
||||
|
||||
/**
|
||||
* 参数为enum可设置的所有值序列
|
||||
*/
|
||||
private String setValue;
|
||||
|
||||
/**
|
||||
* 参数string可设置字符串的长度上限
|
||||
*/
|
||||
private Integer strlen;
|
||||
|
||||
/**
|
||||
* 参数缺省值、告警code值
|
||||
*/
|
||||
private String defaultValue;
|
||||
|
||||
/**
|
||||
* 报表数据来源(统计表表名)
|
||||
*/
|
||||
private String resourcesId;
|
||||
|
||||
/**
|
||||
* 限值字段名称
|
||||
*/
|
||||
private String limitName;
|
||||
|
||||
/**
|
||||
* 限值表名
|
||||
*/
|
||||
private String limitTable;
|
||||
|
||||
/**
|
||||
* 超标判断方式
|
||||
*/
|
||||
private String formula;
|
||||
|
||||
/**
|
||||
* 二次值转一次值公式
|
||||
*/
|
||||
private String primaryFormula;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.njcn.gather.system.dictionary.pojo.po;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.njcn.db.mybatisplus.bo.BaseEntity;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/8
|
||||
*/
|
||||
@Data
|
||||
@TableName(value = "sys_dict_tree")
|
||||
public class DictTree extends BaseEntity {
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
@TableId(value = "id", type = IdType.ASSIGN_UUID)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
@TableField(value = "pid")
|
||||
private String pid;
|
||||
|
||||
/**
|
||||
* 父ids
|
||||
*/
|
||||
@TableField(value = "pids")
|
||||
private String pids;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@TableField(value = "name")
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@TableField(value = "code")
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 用于区分多种类型的字典树 0.台账对象类型 1.自定义报表指标类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 根据type自定义内容,type:0用于区分对象类型是101电网侧 102用户侧
|
||||
*/
|
||||
private String extend;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@TableField(value = "sort")
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@TableField(value = "remark")
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 状态(字典 0正常 1停用 2删除)
|
||||
*/
|
||||
@TableField(value = "state")
|
||||
private Integer state;
|
||||
|
||||
/**
|
||||
* 子类
|
||||
*/
|
||||
@TableField(exist = false)
|
||||
private List<DictTree> children;
|
||||
|
||||
@TableField(exist = false)
|
||||
private Integer level;
|
||||
}
|
||||
@@ -0,0 +1,64 @@
|
||||
package com.njcn.gather.system.dictionary.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/6
|
||||
*/
|
||||
@Data
|
||||
public class DictDataExcel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典数据表Id
|
||||
*/
|
||||
@Excel(name = "字典数据id", width = 40)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 字典类型表Id
|
||||
*/
|
||||
@Excel(name = "字典类型id", width = 40)
|
||||
private String typeId;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Excel(name = "名称", width = 20)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@Excel(name = "编码", width = 20)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序", width = 15)
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 事件等级:0-普通;1-中等;2-严重(默认为0)
|
||||
*/
|
||||
@Excel(name = "事件等级", width = 15, replace = {"普通_0", "中等_1", "严重_2"})
|
||||
private Integer level;
|
||||
|
||||
/**
|
||||
* 与高级算法内部Id描述对应;
|
||||
*/
|
||||
@Excel(name = "高级算法内部id", width = 15)
|
||||
private Integer algoDescribe;
|
||||
|
||||
/**
|
||||
* 目前只用于表示电压等级数值
|
||||
*/
|
||||
@Excel(name = "数值", width = 15)
|
||||
private String value;
|
||||
}
|
||||
@@ -0,0 +1,66 @@
|
||||
package com.njcn.gather.system.dictionary.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/8
|
||||
*/
|
||||
@Data
|
||||
public class DictTreeVO implements Serializable {
|
||||
|
||||
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 主键
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 父id
|
||||
*/
|
||||
private String pid;
|
||||
/**
|
||||
* 父类名称
|
||||
*/
|
||||
private String pname;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 用于区分多种类型的字典树 0.台账对象类型 1.自定义报表指标类型
|
||||
*/
|
||||
private Integer type;
|
||||
|
||||
/**
|
||||
* 根据type自定义内容,type:0用于区分对象类型是101电网侧 102用户侧
|
||||
*/
|
||||
private String extend;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
private String remark;
|
||||
|
||||
/**
|
||||
* 状态(字典 0正常 1停用 2删除)
|
||||
*/
|
||||
private String state;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.njcn.gather.system.dictionary.pojo.vo;
|
||||
|
||||
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/5
|
||||
*/
|
||||
@Data
|
||||
public class DictTypeExcel implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/**
|
||||
* 字典类型表Id
|
||||
*/
|
||||
@Excel(name = "id", width = 40)
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 名称
|
||||
*/
|
||||
@Excel(name = "名称", width = 20)
|
||||
private String name;
|
||||
|
||||
/**
|
||||
* 编码
|
||||
*/
|
||||
@Excel(name = "编码", width = 20)
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 排序
|
||||
*/
|
||||
@Excel(name = "排序", width = 15)
|
||||
private Integer sort;
|
||||
|
||||
/**
|
||||
* 开启等级:0-不开启;1-开启,默认不开启
|
||||
*/
|
||||
@Excel(name = "开启等级", width = 15, replace = {"开启_1", "不开启_0"})
|
||||
private Integer openLevel;
|
||||
|
||||
/**
|
||||
* 开启描述:0-不开启;1-开启,默认不开启
|
||||
*/
|
||||
@Excel(name = "开启描述", width = 15, replace = {"开启_1", "不开启_0"})
|
||||
private Integer openDescribe;
|
||||
|
||||
/**
|
||||
* 描述
|
||||
*/
|
||||
@Excel(name = "描述", width = 50)
|
||||
private String remark;
|
||||
}
|
||||
@@ -24,7 +24,7 @@ public interface IDictDataService extends IService<DictData> {
|
||||
* @param queryParam 查询参数
|
||||
* @return 操作结果
|
||||
*/
|
||||
Page<DictData> getTypeIdData(DictDataParam.DicTypeIdQueryParam queryParam);
|
||||
Page<DictData> getDictDataByTypeId(DictDataParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增数据字典
|
||||
@@ -39,7 +39,7 @@ public interface IDictDataService extends IService<DictData> {
|
||||
* @param updateParam 字典数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean updateDictData(DictDataParam.DictDataUpdateParam updateParam);
|
||||
boolean updateDictData(DictDataParam.UpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 批量逻辑删除字典数据
|
||||
@@ -53,19 +53,38 @@ public interface IDictDataService extends IService<DictData> {
|
||||
* @param dicIndex 查询参数
|
||||
* @return 根据字典id查询字典数据
|
||||
*/
|
||||
DictData getDicDataById(String dicIndex);
|
||||
DictData getDictDataById(String dicIndex);
|
||||
|
||||
/**
|
||||
* 根据字典名称获取字典数据
|
||||
* @param name 字典名称
|
||||
* @return 根据字典名称查询字典数据
|
||||
*/
|
||||
DictData getDictDataByName(String name);
|
||||
|
||||
/**
|
||||
* 根据字典code获取字典数据
|
||||
* @param code 字典code
|
||||
* @return 根据字典code查询字典数据
|
||||
*/
|
||||
DictData getDicDataByCode(String code);
|
||||
DictData getDictDataByCode(String code);
|
||||
|
||||
/**
|
||||
* 获取所有字典数据基础信息
|
||||
* @return 返回所有字典数据
|
||||
*/
|
||||
List<SimpleTreeDTO> dictDataCache();
|
||||
|
||||
/**
|
||||
* 导出字典数据
|
||||
* @param queryParam 查询参数
|
||||
*/
|
||||
void exportDictData(DictDataParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 根据字典类型id删除字典数据
|
||||
* @param ids 字典类型id集合
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean deleteDictDataByDictTypeId(List<String> ids);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.gather.system.dictionary.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.dictionary.pojo.param.DictPqParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictPq;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caizehui
|
||||
*/
|
||||
public interface IDictPqService extends IService<DictPq> {
|
||||
/**
|
||||
* 分页查询电能质量指标字典列表
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 电能质量指标字典分页列表
|
||||
*/
|
||||
Page<DictPq> listDictPqs(DictPqParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增电能质量指标字典
|
||||
*
|
||||
* @param dictPqParam 电能质量指标字典类型
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean addDictPq(DictPqParam dictPqParam);
|
||||
|
||||
/**
|
||||
* 修改电能质量指标字典
|
||||
*
|
||||
* @param updateParam 电能质量指标字典类型
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean updateDictPq(DictPqParam.UpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 删除电能质量指标字典
|
||||
*
|
||||
* @param ids id集合
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean deleteDictPq(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.njcn.gather.system.dictionary.service;
|
||||
|
||||
import com.njcn.gather.system.dictionary.pojo.param.DictTreeParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.dictionary.pojo.vo.DictTreeVO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/8
|
||||
*/
|
||||
public interface IDictTreeService extends IService<DictTree> {
|
||||
|
||||
/**
|
||||
* 初始化缓存设备树
|
||||
*/
|
||||
//void refreshDictTreeCache();
|
||||
|
||||
boolean addDictTree(DictTreeParam dictTreeParam);
|
||||
|
||||
boolean updateDictTree(DictTreeParam.UpdateParam param);
|
||||
|
||||
boolean deleteDictTree(String id);
|
||||
|
||||
List<DictTreeVO> queryByPid(String pid);
|
||||
|
||||
DictTreeVO queryByCode(String code);
|
||||
|
||||
List<DictTreeVO> queryLastLevelById(String id);
|
||||
|
||||
/**
|
||||
* 根据id查询字典数据
|
||||
*
|
||||
* @param id id
|
||||
*/
|
||||
DictTree queryById(String id);
|
||||
|
||||
/**
|
||||
* 查询所有树形字典
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/12/18
|
||||
*/
|
||||
List<DictTree> queryAll();
|
||||
|
||||
/**
|
||||
* 分类查询所有树形字典
|
||||
*
|
||||
* @author cdf
|
||||
* @date 2023/12/18
|
||||
*/
|
||||
List<DictTree> queryAllByType(Integer type);
|
||||
|
||||
List<DictTree> queryTree();
|
||||
|
||||
/**
|
||||
* 根据code查询字典树
|
||||
*
|
||||
* @param code code
|
||||
*/
|
||||
List<DictTree> queryByCodeList(String code);
|
||||
|
||||
/**
|
||||
* 根据关键字查询字典树
|
||||
*
|
||||
* @param keyword 关键字
|
||||
* @return 字典树
|
||||
*/
|
||||
List<DictTree> getDictTreeByKeyword(String keyword);
|
||||
}
|
||||
@@ -4,7 +4,6 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@@ -19,7 +18,7 @@ public interface IDictTypeService extends IService<DictType> {
|
||||
* @param queryParam 查询参数
|
||||
* @return 字典列表
|
||||
*/
|
||||
Page<DictType> listDictTypes(DictTypeParam.DictTypeQueryParam queryParam);
|
||||
Page<DictType> listDictTypes(DictTypeParam.QueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增字典类型数据
|
||||
@@ -35,7 +34,7 @@ public interface IDictTypeService extends IService<DictType> {
|
||||
* @param updateParam 字典类型数据
|
||||
* @return 操作结果
|
||||
*/
|
||||
boolean updateDictType(DictTypeParam.DictTypeUpdateParam updateParam);
|
||||
boolean updateDictType(DictTypeParam.UpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 批量逻辑删除字典类型数据
|
||||
@@ -44,6 +43,9 @@ public interface IDictTypeService extends IService<DictType> {
|
||||
*/
|
||||
boolean deleteDictType(List<String> ids);
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* 导出字典类型数据
|
||||
* @param queryParam 查询参数
|
||||
*/
|
||||
public void exportDictType(DictTypeParam.QueryParam queryParam);
|
||||
}
|
||||
|
||||
@@ -13,14 +13,16 @@ import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||
import com.njcn.gather.system.dictionary.mapper.DictDataMapper;
|
||||
import com.njcn.gather.system.dictionary.pojo.dto.DictDataCache;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.param.DictDataParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictData;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
import com.njcn.gather.system.dictionary.pojo.vo.DictDataExcel;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.pojo.dto.SimpleDTO;
|
||||
import com.njcn.web.pojo.dto.SimpleTreeDTO;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
@@ -40,18 +42,20 @@ import java.util.stream.Collectors;
|
||||
public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> implements IDictDataService {
|
||||
|
||||
@Override
|
||||
public Page<DictData> getTypeIdData(DictDataParam.DicTypeIdQueryParam queryParam) {
|
||||
public Page<DictData> getDictDataByTypeId(DictDataParam.QueryParam queryParam) {
|
||||
QueryWrapper<DictData> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_data.name", queryParam.getName());
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_data.code", queryParam.getCode());
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_data.name", queryParam.getName())
|
||||
.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_data.code", queryParam.getCode());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "sys_dict_data.sort");
|
||||
queryWrapper.orderBy(true, true, "sys_dict_data.sort").orderByDesc("sys_dict_data.update_time");
|
||||
}
|
||||
} else {
|
||||
queryWrapper.orderBy(true, true, "sys_dict_data.sort").orderByDesc("sys_dict_data.update_time");
|
||||
}
|
||||
queryWrapper.ne("sys_dict_data.state", DataStateEnum.DELETED.getCode())
|
||||
.eq("sys_dict_data.type_id", queryParam.getTypeId());
|
||||
@@ -72,7 +76,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
|
||||
|
||||
@Override
|
||||
public boolean updateDictData(DictDataParam.DictDataUpdateParam updateParam) {
|
||||
public boolean updateDictData(DictDataParam.UpdateParam updateParam) {
|
||||
checkDicDataName(updateParam, true);
|
||||
DictData dictData = new DictData();
|
||||
BeanUtil.copyProperties(updateParam, dictData);
|
||||
@@ -89,15 +93,19 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
|
||||
|
||||
@Override
|
||||
public DictData getDicDataById(String dicIndex) {
|
||||
return this.baseMapper.selectById(dicIndex);
|
||||
public DictData getDictDataById(String dicIndex) {
|
||||
return this.lambdaQuery().eq(DictData::getId, dicIndex).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictData getDictDataByName(String name) {
|
||||
return this.lambdaQuery().eq(DictData::getName, name).eq(DictData::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictData getDicDataByCode(String code) {
|
||||
public DictData getDictDataByCode(String code) {
|
||||
LambdaQueryWrapper<DictData> queryWrapper = new LambdaQueryWrapper<>();
|
||||
queryWrapper.eq(DictData::getCode,code)
|
||||
queryWrapper.eq(DictData::getCode, code)
|
||||
.eq(DictData::getState, DataStateEnum.ENABLE.getCode());
|
||||
return this.baseMapper.selectOne(queryWrapper);
|
||||
}
|
||||
@@ -105,12 +113,14 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
@Override
|
||||
public List<SimpleTreeDTO> dictDataCache() {
|
||||
MPJLambdaWrapper<DictData> dictTypeWrapper = new MPJLambdaWrapper<DictData>()
|
||||
.eq(DictData::getState, DataStateEnum.ENABLE.getCode())
|
||||
.selectAll(DictData.class)
|
||||
.selectAs(DictType::getId, DictDataCache::getTypeId)
|
||||
.selectAs(DictType::getName,DictDataCache::getTypeName)
|
||||
.selectAs(DictType::getCode,DictDataCache::getTypeCode)
|
||||
.leftJoin(DictType.class, DictType::getId, DictData::getTypeId);
|
||||
List<DictDataCache> allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class,dictTypeWrapper);
|
||||
.selectAs(DictType::getName, DictDataCache::getTypeName)
|
||||
.selectAs(DictType::getCode, DictDataCache::getTypeCode)
|
||||
.leftJoin(DictType.class, DictType::getId, DictData::getTypeId)
|
||||
.eq(DictType::getState, DataStateEnum.ENABLE.getCode());
|
||||
List<DictDataCache> allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class, dictTypeWrapper);
|
||||
|
||||
Map<Object, List<DictDataCache>> dictDataCacheMap = allDictData.stream()
|
||||
.collect(Collectors.groupingBy(DictDataCache::getTypeId));
|
||||
@@ -135,6 +145,34 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportDictData(DictDataParam.QueryParam queryParam) {
|
||||
QueryWrapper<DictData> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_data.name", queryParam.getName())
|
||||
.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_data.code", queryParam.getCode());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "sys_dict_data.sort").orderByDesc("sys_dict_data.update_time");
|
||||
}
|
||||
}
|
||||
queryWrapper.ne("sys_dict_data.state", DataStateEnum.DELETED.getCode())
|
||||
.eq("sys_dict_data.type_id", queryParam.getTypeId());
|
||||
List<DictData> dictDatas = this.list(queryWrapper);
|
||||
List<DictDataExcel> dictDataExcels = BeanUtil.copyToList(dictDatas, DictDataExcel.class);
|
||||
ExcelUtil.exportExcel("字典数据导出数据.xlsx", "字典数据", DictDataExcel.class, dictDataExcels);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDictDataByDictTypeId(List<String> ids) {
|
||||
QueryWrapper<DictData> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("sys_dict_data.type_id", ids)
|
||||
.ne("sys_dict_data.state", DataStateEnum.DELETED.getCode());
|
||||
return this.remove(queryWrapper);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
@@ -142,20 +180,19 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
|
||||
*/
|
||||
private void checkDicDataName(DictDataParam dictDataParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<DictData> dictDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
dictDataLambdaQueryWrapper
|
||||
.eq(DictData::getName, dictDataParam.getName())
|
||||
.eq(DictData::getTypeId, dictDataParam.getTypeId())
|
||||
.eq(DictData::getState, DataStateEnum.ENABLE.getCode());
|
||||
dictDataLambdaQueryWrapper.eq(DictData::getTypeId, dictDataParam.getTypeId())
|
||||
.eq(DictData::getState, DataStateEnum.ENABLE.getCode())
|
||||
.and(w -> w.eq(DictData::getName, dictDataParam.getName()).or().eq(DictData::getCode, dictDataParam.getCode()));
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (dictDataParam instanceof DictDataParam.DictDataUpdateParam) {
|
||||
dictDataLambdaQueryWrapper.ne(DictData::getId, ((DictDataParam.DictDataUpdateParam) dictDataParam).getId());
|
||||
if (dictDataParam instanceof DictDataParam.UpdateParam) {
|
||||
dictDataLambdaQueryWrapper.ne(DictData::getId, ((DictDataParam.UpdateParam) dictDataParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(dictDataLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(SystemResponseEnum.DICT_DATA_NAME_REPEAT);
|
||||
throw new BusinessException(SystemResponseEnum.DICT_DATA_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,105 @@
|
||||
package com.njcn.gather.system.dictionary.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.LambdaQueryWrapper;
|
||||
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.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.IDictPqService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> implements IDictPqService {
|
||||
|
||||
@Override
|
||||
public Page<DictPq> listDictPqs(DictPqParam.QueryParam queryParam) {
|
||||
QueryWrapper<DictPq> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_pq.name", queryParam.getName())
|
||||
.like(StrUtil.isNotBlank(queryParam.getOtherName()), "sys_dict_pq.other_name", queryParam.getOtherName())
|
||||
.like(StrUtil.isNotBlank(queryParam.getShowName()), "sys_dict_pq.show_name", queryParam.getShowName())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getDataType()), "sys_dict_pq.data_type", queryParam.getDataType())
|
||||
.eq(StrUtil.isNotBlank(queryParam.getClassId()), "sys_dict_pq.class_id", queryParam.getClassId());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "sys_dict_pq.sort").orderByDesc("sys_dict_pq.update_time");
|
||||
}
|
||||
} else {
|
||||
queryWrapper.orderBy(true, true, "sys_dict_pq.sort").orderByDesc("sys_dict_pq.update_time");
|
||||
}
|
||||
queryWrapper.ne("sys_dict_pq.state", DataStateEnum.DELETED.getCode());
|
||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addDictPq(DictPqParam dictPqParam) {
|
||||
checkDicPqName(dictPqParam, false);
|
||||
DictPq dictPq = new DictPq();
|
||||
BeanUtil.copyProperties(dictPqParam, dictPq);
|
||||
//默认为正常状态
|
||||
dictPq.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(dictPq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDictPq(DictPqParam.UpdateParam updateParam) {
|
||||
checkDicPqName(updateParam, true);
|
||||
DictPq dictPq = new DictPq();
|
||||
BeanUtil.copyProperties(updateParam, dictPq);
|
||||
return this.updateById(dictPq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDictPq(List<String> ids) {
|
||||
return this.lambdaUpdate()
|
||||
.set(DictPq::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(DictPq::getId, ids)
|
||||
.update();
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查同一数据模型及相别下是否存在相同名称的字典项
|
||||
*
|
||||
* @param dictPqParam 字典项参数
|
||||
* @param isExcludeSelf 是否排除自己
|
||||
*/
|
||||
private void checkDicPqName(DictPqParam dictPqParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<DictPq> dictPqLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
dictPqLambdaQueryWrapper
|
||||
.eq(StrUtil.isNotBlank(dictPqParam.getDataType()), DictPq::getDataType, dictPqParam.getDataType())
|
||||
.eq(StrUtil.isNotBlank(dictPqParam.getName()), DictPq::getName, dictPqParam.getName())
|
||||
.eq(StrUtil.isNotBlank(dictPqParam.getPhase()), DictPq::getPhase, dictPqParam.getPhase())
|
||||
.eq(DictPq::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (dictPqParam instanceof DictPqParam.UpdateParam) {
|
||||
dictPqLambdaQueryWrapper.ne(DictPq::getId, ((DictPqParam.UpdateParam) dictPqParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(dictPqLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(SystemResponseEnum.DICT_PQ_NAME_EXIST);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,212 @@
|
||||
package com.njcn.gather.system.dictionary.service.impl;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.text.StrPool;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
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.system.dictionary.mapper.DictTreeMapper;
|
||||
import com.njcn.gather.system.dictionary.pojo.param.DictTreeParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictTree;
|
||||
import com.njcn.gather.system.dictionary.pojo.vo.DictTreeVO;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTreeService;
|
||||
import com.njcn.gather.system.pojo.constant.DictConst;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.beans.BeanUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/8
|
||||
*/
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictTreeServiceImpl extends ServiceImpl<DictTreeMapper, DictTree> implements IDictTreeService {
|
||||
|
||||
//private final RedisUtil redisUtil;
|
||||
|
||||
// @Override
|
||||
// public void refreshDictTreeCache () {
|
||||
// LambdaQueryWrapper<DictTree> queryWrapper = new LambdaQueryWrapper<>();
|
||||
// queryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||
// List<DictTree> list = this.list(queryWrapper);
|
||||
// redisUtil.saveByKey(AppRedisKey.DICT_TREE, list);
|
||||
// }
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = {Exception.class})
|
||||
public boolean addDictTree(DictTreeParam dictTreeParam) {
|
||||
boolean result;
|
||||
DictTree dictTree = new DictTree();
|
||||
BeanUtils.copyProperties(dictTreeParam, dictTree);
|
||||
if (!Objects.equals(dictTree.getPid(), DictConst.FATHER_ID)) {
|
||||
QueryWrapper<DictTree> queryWrapper = new QueryWrapper<>();
|
||||
queryWrapper.eq("id", dictTree.getPid());
|
||||
DictTree instance = this.baseMapper.selectOne(queryWrapper);
|
||||
dictTree.setPids(instance.getPids() + StrPool.COMMA + instance.getId());
|
||||
} else {
|
||||
dictTree.setPids(DictConst.FATHER_ID);
|
||||
}
|
||||
dictTree.setState(DictConst.ENABLE);
|
||||
result = this.save(dictTree);
|
||||
// if (result) {
|
||||
// refreshDictTreeCache();
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDictTree(DictTreeParam.UpdateParam param) {
|
||||
boolean result;
|
||||
DictTree dictTree = new DictTree();
|
||||
BeanUtils.copyProperties(param, dictTree);
|
||||
result = this.updateById(dictTree);
|
||||
// if (result) {
|
||||
// refreshDictTreeCache();
|
||||
// }
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deleteDictTree(String id) {
|
||||
boolean result = false;
|
||||
List<DictTree> childrenList = this.lambdaQuery().eq(DictTree::getState, DataStateEnum.ENABLE.getCode()).eq(DictTree::getPid, id).list();
|
||||
if (CollectionUtils.isEmpty(childrenList)) {
|
||||
result = this.lambdaUpdate().set(DictTree::getState, DataStateEnum.DELETED.getCode()).in(DictTree::getId, id).update();
|
||||
// if (result) {
|
||||
// refreshRolesFunctionsCache();
|
||||
// }
|
||||
} else {
|
||||
throw new BusinessException(SystemResponseEnum.EXISTS_CHILDREN_NOT_DELETE);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTreeVO> queryByPid(String pid) {
|
||||
List<DictTreeVO> collect = new ArrayList<>();
|
||||
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||
query.eq(DictTree::getPid, pid).eq(DictTree::getState, DictConst.ENABLE).orderByDesc(DictTree::getSort);
|
||||
List<DictTree> resultList = this.list(query);
|
||||
DictTree byId = this.getById(pid);
|
||||
if (CollUtil.isNotEmpty(resultList)) {
|
||||
collect = resultList.stream().map(temp -> {
|
||||
DictTreeVO resultVO = new DictTreeVO();
|
||||
BeanUtils.copyProperties(temp, resultVO);
|
||||
resultVO.setPname(Objects.nonNull(byId) ? byId.getName() : "最高级");
|
||||
return resultVO;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
return collect;
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictTreeVO queryByCode(String code) {
|
||||
LambdaQueryWrapper<DictTree> query = new LambdaQueryWrapper<>();
|
||||
query.clear();
|
||||
query.eq(DictTree::getCode, code).eq(DictTree::getState, DictConst.ENABLE);
|
||||
DictTree result = this.getOne(query);
|
||||
if (result != null) {
|
||||
DictTreeVO resultVO = new DictTreeVO();
|
||||
BeanUtils.copyProperties(result, resultVO);
|
||||
return resultVO;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTreeVO> queryLastLevelById(String id) {
|
||||
return this.baseMapper.queryLastLevelById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
public DictTree queryById(String id) {
|
||||
return this.lambdaQuery().eq(DictTree::getId, id).eq(DictTree::getState, DictConst.ENABLE).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryAll() {
|
||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryAllByType(Integer type) {
|
||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE).eq(DictTree::getType, type);
|
||||
return this.list(lambdaQueryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryTree() {
|
||||
LambdaQueryWrapper<DictTree> lambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
lambdaQueryWrapper.eq(DictTree::getState, DictConst.ENABLE);
|
||||
List<DictTree> dictTreeList = this.list(lambdaQueryWrapper);
|
||||
return dictTreeList.stream().filter(item -> DictConst.FATHER_ID.equals(item.getPid())).peek(item -> {
|
||||
item.setLevel(0);
|
||||
item.setChildren(getChildren(item, dictTreeList));
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTree> queryByCodeList(String code) {
|
||||
List<DictTree> sysDicTreePOList = this.list(new LambdaQueryWrapper<DictTree>().eq(DictTree::getState, 0));
|
||||
return sysDicTreePOList.stream().filter(item -> item.getCode().equals(code)).peek(item -> {
|
||||
item.setLevel(0);
|
||||
item.setChildren(getChildren(item, sysDicTreePOList));
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DictTree> getDictTreeByKeyword(String keyword) {
|
||||
List<DictTree> dictTree = this.queryTree();
|
||||
this.filterTreeByName(dictTree, keyword);
|
||||
return dictTree;
|
||||
}
|
||||
|
||||
private List<DictTree> filterTreeByName(List<DictTree> tree, String keyword) {
|
||||
if (CollectionUtils.isEmpty(tree) || !StrUtil.isNotBlank(keyword)) {
|
||||
return tree;
|
||||
}
|
||||
filter(tree, keyword);
|
||||
return tree;
|
||||
}
|
||||
|
||||
private void filter(List<DictTree> list, String keyword) {
|
||||
for (int i = list.size() - 1; i >= 0; i--) {
|
||||
DictTree dictTree = list.get(i);
|
||||
List<DictTree> children = dictTree.getChildren();
|
||||
if (!dictTree.getName().contains(keyword)) {
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
filter(children, keyword);
|
||||
}
|
||||
if (CollectionUtils.isEmpty(dictTree.getChildren())) {
|
||||
list.remove(i);
|
||||
}
|
||||
} else {
|
||||
if (!CollectionUtils.isEmpty(children)) {
|
||||
filter(children, keyword);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private List<DictTree> getChildren(DictTree dictTree, List<DictTree> all) {
|
||||
return all.stream().filter(item -> item.getPid().equals(dictTree.getId())).peek(item -> {
|
||||
item.setLevel(dictTree.getLevel() + 1);
|
||||
item.setChildren(getChildren(item, all));
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
}
|
||||
@@ -11,11 +11,14 @@ import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.common.pojo.exception.BusinessException;
|
||||
import com.njcn.db.mybatisplus.constant.DbConstant;
|
||||
import com.njcn.gather.system.dictionary.mapper.DictTypeMapper;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
|
||||
import com.njcn.gather.system.dictionary.pojo.po.DictType;
|
||||
import com.njcn.gather.system.dictionary.pojo.vo.DictTypeExcel;
|
||||
import com.njcn.gather.system.dictionary.service.IDictDataService;
|
||||
import com.njcn.gather.system.dictionary.service.IDictTypeService;
|
||||
import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
|
||||
import com.njcn.web.factory.PageFactory;
|
||||
import com.njcn.web.utils.ExcelUtil;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
@@ -28,20 +31,23 @@ import java.util.List;
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> implements IDictTypeService {
|
||||
private final IDictDataService dictDataService;
|
||||
|
||||
@Override
|
||||
public Page<DictType> listDictTypes(DictTypeParam.DictTypeQueryParam queryParam) {
|
||||
public Page<DictType> listDictTypes(DictTypeParam.QueryParam queryParam) {
|
||||
QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_type.name", queryParam.getName());
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_type.code", queryParam.getCode());
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_type.name", queryParam.getName())
|
||||
.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_type.code", queryParam.getCode());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "sys_dict_type.sort");
|
||||
queryWrapper.orderBy(true, true, "sys_dict_type.sort").orderByDesc("sys_dict_type.update_time");
|
||||
}
|
||||
} else {
|
||||
queryWrapper.orderBy(true, true, "sys_dict_type.sort").orderByDesc("sys_dict_type.update_time");
|
||||
}
|
||||
queryWrapper.ne("sys_dict_type.state", DataStateEnum.DELETED.getCode());
|
||||
return this.baseMapper.selectPage(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
@@ -58,7 +64,7 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDictType(DictTypeParam.DictTypeUpdateParam updateParam) {
|
||||
public boolean updateDictType(DictTypeParam.UpdateParam updateParam) {
|
||||
checkDicTypeName(updateParam, true);
|
||||
DictType dictType = new DictType();
|
||||
BeanUtil.copyProperties(updateParam, dictType);
|
||||
@@ -67,31 +73,51 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
|
||||
|
||||
@Override
|
||||
public boolean deleteDictType(List<String> ids) {
|
||||
dictDataService.deleteDictDataByDictTypeId(ids);
|
||||
return this.lambdaUpdate()
|
||||
.set(DictType::getState, DataStateEnum.DELETED.getCode())
|
||||
.in(DictType::getId, ids)
|
||||
.update();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void exportDictType(DictTypeParam.QueryParam queryParam) {
|
||||
QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
|
||||
if (ObjectUtil.isNotNull(queryParam)) {
|
||||
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_type.name", queryParam.getName())
|
||||
.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_type.code", queryParam.getCode());
|
||||
//排序
|
||||
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
|
||||
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
|
||||
} else {
|
||||
//没有排序参数,默认根据sort字段排序,没有排序字段的,根据updateTime更新时间排序
|
||||
queryWrapper.orderBy(true, true, "sys_dict_type.sort").orderByDesc("sys_dict_type.update_time");
|
||||
}
|
||||
}
|
||||
queryWrapper.ne("sys_dict_type.state", DataStateEnum.DELETED.getCode());
|
||||
List<DictType> dictTypes = this.list(queryWrapper);
|
||||
List<DictTypeExcel> dictTypeVOS = BeanUtil.copyToList(dictTypes, DictTypeExcel.class);
|
||||
ExcelUtil.exportExcel("字典类型导出数据.xlsx", "字典类型", DictTypeExcel.class, dictTypeVOS);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的字典类型
|
||||
*/
|
||||
private void checkDicTypeName(DictTypeParam dictTypeParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<DictType> dictTypeLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
dictTypeLambdaQueryWrapper
|
||||
.eq(DictType::getName, dictTypeParam.getName())
|
||||
.eq(DictType::getState, DataStateEnum.ENABLE.getCode());
|
||||
dictTypeLambdaQueryWrapper.eq(DictType::getState, DataStateEnum.ENABLE.getCode())
|
||||
.and(w -> w.eq(DictType::getCode, dictTypeParam.getCode()).or().eq(DictType::getName, dictTypeParam.getName()));
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (dictTypeParam instanceof DictTypeParam.DictTypeUpdateParam) {
|
||||
dictTypeLambdaQueryWrapper.ne(DictType::getId, ((DictTypeParam.DictTypeUpdateParam) dictTypeParam).getId());
|
||||
if (dictTypeParam instanceof DictTypeParam.UpdateParam) {
|
||||
dictTypeLambdaQueryWrapper.ne(DictType::getId, ((DictTypeParam.UpdateParam) dictTypeParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(dictTypeLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(SystemResponseEnum.DICT_TYPE_NAME_REPEAT);
|
||||
throw new BusinessException(SystemResponseEnum.DICT_TYPE_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -59,9 +59,11 @@ public class MenuController {
|
||||
MenuVO menuVO3 = getMenuVORedirect("/system","system","/system/base","Tools","系统配置");
|
||||
MenuVO menuVO31 = getMenuVO("/system/base","base","/system/base/index","UserFilled","通用配置");
|
||||
MenuVO menuVO32 = getMenuVO("/system/dict","dict","/system/dictionary/dictType/index","DataAnalysis","数据字典");
|
||||
MenuVO menuVO33 = getMenuVO("/system/template","template","/system/template/index","Memo","报告模板");
|
||||
MenuVO menuVO34 = getMenuVO("/system/versionRegister","versionRegister","/system/versionRegister/index","SetUp","版本注册");
|
||||
menuVO3.setChildren(CollectionUtil.toList(menuVO31,menuVO32,menuVO33,menuVO34));
|
||||
MenuVO menuVO33 = getMenuVO("/system/dictTree","dictTree","/system/dictionary/dictTree/index","DataAnalysis","树形字典");
|
||||
MenuVO menuVO34 = getMenuVO("/system/dictPq","dictPq","/system/dictionary/dictPq/index","DataAnalysis","电能质量字典");
|
||||
MenuVO menuVO35 = getMenuVO("/system/template","template","/system/template/index","Memo","报告模板");
|
||||
MenuVO menuVO36 = getMenuVO("/system/versionRegister","versionRegister","/system/versionRegister/index","SetUp","版本注册");
|
||||
menuVO3.setChildren(CollectionUtil.toList(menuVO31,menuVO32,menuVO33,menuVO34,menuVO35,menuVO36));
|
||||
menuVOList.add(menuVO3);
|
||||
|
||||
MenuVO menuVO4 = getMenuVO("/log","log","/log/index","TrendCharts","日志管理");
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.njcn.gather.system.pojo.constant;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024/11/8
|
||||
*/
|
||||
public interface DictConst {
|
||||
/**
|
||||
* 状态 0-正常;1-停用;2-删除 默认正常
|
||||
*/
|
||||
int ENABLE = 0;
|
||||
|
||||
int PAUSE = 1;
|
||||
|
||||
int DELETE = 2;
|
||||
|
||||
/**
|
||||
* 顶层父类的pid
|
||||
*/
|
||||
String FATHER_ID = "0";
|
||||
}
|
||||
@@ -8,7 +8,7 @@ package com.njcn.gather.system.pojo.constant;
|
||||
public interface SystemValidMessage {
|
||||
|
||||
|
||||
String MISS_PREFIX="字段不能为空,请检查";
|
||||
String MISS_PREFIX = "字段不能为空,请检查";
|
||||
|
||||
|
||||
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||
@@ -27,13 +27,13 @@ public interface SystemValidMessage {
|
||||
String INDUSTRY_FORMAT_ERROR = "行业格式错误,请检查industry参数";
|
||||
String ADDR_NOT_BLANK = "所属区域不能为空,请检查addr参数";
|
||||
|
||||
String CODE_NOT_BLANK = "编号不能为空,请检查code参数";
|
||||
String CODE_NOT_BLANK = "编码不能为空,请检查code参数";
|
||||
|
||||
String CODE_FORMAT_ERROR = "编号格式错误,请检查code参数";
|
||||
String CODE_FORMAT_ERROR = "编码格式错误,请检查code参数";
|
||||
|
||||
String SORT_NOT_NULL = "排序不能为空,请检查sort参数";
|
||||
|
||||
String SORT_FORMAT_ERROR = "排序格式错误,请检查sort参数";
|
||||
String SORT_FORMAT_ERROR = "排序范围在1至999,请检查sort参数";
|
||||
|
||||
String OPEN_LEVEL_NOT_NULL = "开启等级不能为空,请检查openLevel参数";
|
||||
|
||||
@@ -69,4 +69,25 @@ public interface SystemValidMessage {
|
||||
|
||||
String DEVICE_VERSION_NOT_BLANK = "装置版本json文件不能为空,请检查deviceVersionFile参数";
|
||||
|
||||
String PHASE_NOT_BLANK = "相别不能为空,请检查phase参数";
|
||||
|
||||
String DATA_TYPE_NOT_BLANK = "数据模型不能为空,请检查dataType参数";
|
||||
|
||||
String CLASS_ID_NOT_BLANK = "数据表表名不能为空,请检查classId参数";
|
||||
|
||||
String AUTO_GENERATE_NOT_NULL = "是否自动生成不能为空,请检查autoGenerate参数";
|
||||
|
||||
String MAX_RECHECK_NOT_NULL = "最大复检次数不能为空,请检查maxRecheck参数";
|
||||
|
||||
String DATA_RULE_NOT_BLANK = "数据处理规则不能为空,请检查dataRule参数";
|
||||
|
||||
String DATA_RULE_FORMAT_ERROR = "数据处理规则格式错误,请检查dataRule参数";
|
||||
|
||||
String TYPE_NOT_BLANK = "版本类型不能为空,请检查type参数";
|
||||
|
||||
String AUTO_GENERATE_FORMAT_ERROR = "是否自动生成格式错误,请检查autoGenerate参数";
|
||||
|
||||
String TOKEN_VALID_ERROR = "token校验失败";
|
||||
|
||||
String USER_ID_FORMAT_ERROR = "用户id格式错误,请检查userId参数";
|
||||
}
|
||||
|
||||
@@ -15,8 +15,8 @@ public enum SystemResponseEnum {
|
||||
* A00350 ~ A00449
|
||||
*/
|
||||
SYSTEM_COMMON_ERROR("A00350","系统模块异常"),
|
||||
DICT_TYPE_NAME_REPEAT("A00351", "字典类型名称重复"),
|
||||
DICT_DATA_NAME_REPEAT("A00352", "字典数据名称重复"),
|
||||
DICT_TYPE_REPEAT("A00351", "字典类型名称或编码重复"),
|
||||
DICT_DATA_REPEAT("A00352", "字典数据名称或编码重复"),
|
||||
AREA_CODE_REPEAT("A00353","行政区域编码重复"),
|
||||
LOAD_TYPE_EMPTY("A00354","用能负荷数据为空"),
|
||||
LINE_MARK_EMPTY("A00355","字典监测点评分等级数据为空"),
|
||||
@@ -53,6 +53,9 @@ public enum SystemResponseEnum {
|
||||
TIMER_NOT_EXISTED("A00361", "定时任务执行类不存在"),
|
||||
EXE_EMPTY_PARAM("A00361", "请检查定时器的id,定时器cron表达式,定时任务是否为空!"),
|
||||
|
||||
DICT_PQ_NAME_EXIST("A00389", "当前数据模型及相别下已存在相同名称"),
|
||||
EXISTS_CHILDREN_NOT_DELETE("A00390", "当前字典下存在子字典,不能删除"),
|
||||
|
||||
/**
|
||||
* 审计日志模块异常响应
|
||||
*/
|
||||
|
||||
@@ -0,0 +1,90 @@
|
||||
package com.njcn.gather.system.reg.controller;
|
||||
|
||||
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.reg.pojo.param.SysRegResParam;
|
||||
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
|
||||
import com.njcn.gather.system.reg.pojo.vo.SysRegResVO;
|
||||
import com.njcn.gather.system.reg.service.ISysRegResService;
|
||||
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-11-21
|
||||
*/
|
||||
@Slf4j
|
||||
@Api(tags = "注册版本管理")
|
||||
@RestController
|
||||
@RequestMapping("/sysRegRes")
|
||||
@RequiredArgsConstructor
|
||||
public class SysRegResController extends BaseController {
|
||||
private final ISysRegResService sysRegResService;
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/list")
|
||||
@ApiOperation("查询注册版本列表")
|
||||
public HttpResult<Map<String,SysRegResVO>> listRegRes() {
|
||||
String methodDescribe = getMethodDescribe("listRegRes");
|
||||
LogUtil.njcnDebug(log, "{},查询参数为空", methodDescribe);
|
||||
Map<String,SysRegResVO> result = sysRegResService.listRegRes();
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
|
||||
@GetMapping("/getRegResByType")
|
||||
@ApiOperation("根据类型id查询配置")
|
||||
@ApiImplicitParam(name = "type", value = "类型id,字典值", required = true)
|
||||
public HttpResult<SysRegRes> getRegResByType(@RequestParam("id") String typeId) {
|
||||
String methodDescribe = getMethodDescribe("listByTypeId");
|
||||
LogUtil.njcnDebug(log, "{},查询参数为:{}", methodDescribe, typeId);
|
||||
SysRegRes result = sysRegResService.getRegResByType(typeId);
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, result, methodDescribe);
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.ADD)
|
||||
@PostMapping("/add")
|
||||
@ApiOperation("新增注册版本")
|
||||
@ApiImplicitParam(name = "sysRegRes", value = "注册版本对象", required = true)
|
||||
public HttpResult<String> addRegRes(@RequestBody @Validated SysRegResParam param) {
|
||||
String methodDescribe = getMethodDescribe("addRegRes");
|
||||
LogUtil.njcnDebug(log, "{},新增参数为:{}", methodDescribe, param);
|
||||
boolean result = sysRegResService.addRegRes(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
|
||||
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
|
||||
@PostMapping("/update")
|
||||
@ApiOperation("修改配置")
|
||||
@ApiImplicitParam(name = "param", value = "注册版本更新对象", required = true)
|
||||
public HttpResult<String> updateRegRes(@RequestBody @Validated SysRegResParam.UpdateParam param) {
|
||||
String methodDescribe = getMethodDescribe("updateRegRes");
|
||||
LogUtil.njcnDebug(log, "{},更新参数为:{}", methodDescribe, param);
|
||||
boolean result = sysRegResService.updateRegRes(param);
|
||||
if (result) {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
|
||||
} else {
|
||||
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.system.reg.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
public interface SysRegResMapper extends MPJBaseMapper<SysRegRes> {
|
||||
|
||||
}
|
||||
|
||||
@@ -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.reg.mapper.SysRegResMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.njcn.gather.system.reg.pojo.param;
|
||||
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.system.pojo.constant.SystemValidMessage;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.Pattern;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-21
|
||||
*/
|
||||
@Data
|
||||
public class SysRegResParam {
|
||||
|
||||
// @ApiModelProperty("版本类型")
|
||||
// @NotBlank(message = SystemValidMessage.TYPE_NOT_BLANK)
|
||||
// @Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
// private String type;
|
||||
|
||||
@ApiModelProperty("注册码")
|
||||
@NotBlank(message = SystemValidMessage.CODE_NOT_BLANK)
|
||||
private String code;
|
||||
|
||||
// @ApiModelProperty("密钥")
|
||||
// private String licenseKey;
|
||||
|
||||
@Data
|
||||
public static class UpdateParam {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@NotBlank(message = SystemValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = SystemValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
|
||||
@ApiModelProperty("录波数据有效组数")
|
||||
private Integer waveRecord;
|
||||
|
||||
@ApiModelProperty("实时数据有效组数")
|
||||
private Integer realTime;
|
||||
|
||||
@ApiModelProperty("统计数据有效组数")
|
||||
private Integer statistics;
|
||||
|
||||
@ApiModelProperty("短闪数据有效组数")
|
||||
private Integer flicker;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,71 @@
|
||||
package com.njcn.gather.system.reg.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;
|
||||
import java.time.LocalDate;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
@TableName("sys_reg_res")
|
||||
public class SysRegRes extends BaseEntity implements Serializable {
|
||||
private static final long serialVersionUID = 801772692898301698L;
|
||||
/**
|
||||
* 版本注册表Id
|
||||
*/
|
||||
private String id;
|
||||
|
||||
/**
|
||||
* 版本类型(模拟式、数字式、比对式)
|
||||
*/
|
||||
private String type;
|
||||
|
||||
/**
|
||||
* 注册码
|
||||
*/
|
||||
private String code;
|
||||
|
||||
/**
|
||||
* 密钥
|
||||
*/
|
||||
private String licenseKey;
|
||||
|
||||
/**
|
||||
* 到期时间
|
||||
*/
|
||||
private LocalDate expireDate;
|
||||
|
||||
/**
|
||||
* 录波数据有效组数
|
||||
*/
|
||||
private Integer waveRecord;
|
||||
|
||||
/**
|
||||
* 实时数据有效组数
|
||||
*/
|
||||
private Integer realTime;
|
||||
|
||||
/**
|
||||
* 统计数据有效组数
|
||||
*/
|
||||
private Integer statistics;
|
||||
|
||||
/**
|
||||
* 短闪数据有效组数
|
||||
*/
|
||||
private Integer flicker;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.njcn.gather.system.reg.pojo.vo;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @data 2024-11-25
|
||||
*/
|
||||
@Data
|
||||
public class SysRegResVO {
|
||||
private String code;
|
||||
|
||||
private String expireDate;
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.njcn.gather.system.reg.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.system.reg.pojo.param.SysRegResParam;
|
||||
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
|
||||
import com.njcn.gather.system.reg.pojo.vo.SysRegResVO;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
public interface ISysRegResService extends IService<SysRegRes> {
|
||||
/**
|
||||
* 查询版本注册表
|
||||
* @return
|
||||
*/
|
||||
SysRegRes getRegResByType(String type);
|
||||
|
||||
/**
|
||||
* 新增版本注册表
|
||||
* @param sysRegResParam 版本注册表参数
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean addRegRes(SysRegResParam sysRegResParam);
|
||||
|
||||
/**
|
||||
* 修改配置
|
||||
* @param param
|
||||
* @return 成功返回true,失败返回false
|
||||
*/
|
||||
boolean updateRegRes(SysRegResParam.UpdateParam param);
|
||||
|
||||
/**
|
||||
* 查询版本注册表列表
|
||||
* @return 版本注册信息
|
||||
*/
|
||||
Map<String,SysRegResVO> listRegRes();
|
||||
}
|
||||
@@ -0,0 +1,61 @@
|
||||
package com.njcn.gather.system.reg.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.njcn.common.pojo.enums.common.DataStateEnum;
|
||||
import com.njcn.gather.system.reg.mapper.SysRegResMapper;
|
||||
import com.njcn.gather.system.reg.pojo.param.SysRegResParam;
|
||||
import com.njcn.gather.system.reg.pojo.po.SysRegRes;
|
||||
import com.njcn.gather.system.reg.pojo.vo.SysRegResVO;
|
||||
import com.njcn.gather.system.reg.service.ISysRegResService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024-11-21
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class SysRegResServiceImpl extends ServiceImpl<SysRegResMapper, SysRegRes> implements ISysRegResService {
|
||||
|
||||
@Override
|
||||
public SysRegRes getRegResByType(String type) {
|
||||
return this.lambdaQuery().eq(SysRegRes::getType, type).eq(SysRegRes::getState, DataStateEnum.ENABLE.getCode()).one();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addRegRes(SysRegResParam sysRegResParam) {
|
||||
SysRegRes sysRegRes = new SysRegRes();
|
||||
BeanUtil.copyProperties(sysRegResParam, sysRegRes);
|
||||
sysRegRes.setState(DataStateEnum.ENABLE.getCode());
|
||||
// todo 解析注册码
|
||||
return this.save(sysRegRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateRegRes(SysRegResParam.UpdateParam param) {
|
||||
SysRegRes sysRegRes = new SysRegRes();
|
||||
BeanUtil.copyProperties(param, sysRegRes);
|
||||
if (sysRegRes.getWaveRecord() == -1) {
|
||||
sysRegRes.setWaveRecord(null);
|
||||
}
|
||||
return this.updateById(sysRegRes);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, SysRegResVO> listRegRes() {
|
||||
Map<String, SysRegResVO> map = new HashMap<>();
|
||||
this.list().forEach(item -> {
|
||||
SysRegResVO sysRegResVO = new SysRegResVO();
|
||||
BeanUtil.copyProperties(item, sysRegResVO);
|
||||
map.put(item.getType(), sysRegResVO);
|
||||
});
|
||||
return map;
|
||||
}
|
||||
}
|
||||
@@ -1,6 +1,8 @@
|
||||
#### 简介
|
||||
用户模块主要包含以下功能:
|
||||
* 用户管理
|
||||
* 角色管理
|
||||
* 资源管理
|
||||
* 部门管理
|
||||
* 职位管理(非必须)
|
||||
* 菜单资源管理
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user