电能质量字典crud
This commit is contained in:
34
machine/pom.xml
Normal file
34
machine/pom.xml
Normal file
@@ -0,0 +1,34 @@
|
||||
<?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>machine</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>
|
||||
</dependencies>
|
||||
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.njcn.gather.machine.device.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.machine.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.machine.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.machine.device.service.IPqDevService;
|
||||
import com.njcn.web.controller.BaseController;
|
||||
import com.njcn.web.utils.HttpResultUtil;
|
||||
import io.swagger.annotations.Api;
|
||||
import io.swagger.annotations.ApiImplicitParam;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
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.PqDevQueryParam 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.PqDevUpdateParam 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.njcn.gather.machine.device.mapper;
|
||||
|
||||
import com.github.yulichang.base.MPJBaseMapper;
|
||||
import com.njcn.gather.machine.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.machine.device.mapper.PqDevMapper">
|
||||
|
||||
|
||||
</mapper>
|
||||
|
||||
@@ -0,0 +1,158 @@
|
||||
package com.njcn.gather.machine.device.pojo.param;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.njcn.common.pojo.constant.PatternRegex;
|
||||
import com.njcn.gather.machine.pojo.constant.MachineValidMessage;
|
||||
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.NotNull;
|
||||
import javax.validation.constraints.Pattern;
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
@Data
|
||||
public class PqDevParam {
|
||||
|
||||
@ApiModelProperty("名称")
|
||||
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("设备模式,字典表(数字、模拟、比对)")
|
||||
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
|
||||
private String pattern;
|
||||
|
||||
@ApiModelProperty("设备类型,字典表")
|
||||
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty("设备通道数")
|
||||
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
|
||||
private Integer devChns;
|
||||
|
||||
@ApiModelProperty("额定电压(V)")
|
||||
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
|
||||
private Float devVolt;
|
||||
|
||||
@ApiModelProperty("额定电流(A)")
|
||||
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
|
||||
private Float devCurr;
|
||||
|
||||
@ApiModelProperty("生产厂家,字典表")
|
||||
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
|
||||
private String manufacturer;
|
||||
|
||||
@ApiModelProperty("生产日期")
|
||||
@NotNull(message = MachineValidMessage.PRODUCEDATE_NOT_NULL)
|
||||
private LocalDateTime createdate;
|
||||
|
||||
@ApiModelProperty("出厂编号")
|
||||
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
|
||||
private String createid;
|
||||
|
||||
@ApiModelProperty("固件版本")
|
||||
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
|
||||
private String hardwareVersion;
|
||||
|
||||
@ApiModelProperty("软件版本")
|
||||
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
|
||||
private String softwareVersion;
|
||||
|
||||
@ApiModelProperty("IP地址")
|
||||
@NotBlank(message = MachineValidMessage.IP_NOT_BLANK)
|
||||
private String ip;
|
||||
|
||||
@ApiModelProperty("端口号")
|
||||
@NotNull(message = MachineValidMessage.PORT_NOT_NULL)
|
||||
private Integer port;
|
||||
|
||||
@ApiModelProperty("装置是否为加密版本")
|
||||
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
|
||||
@TableField(value = "is_encryption")
|
||||
private Integer encryption;;
|
||||
|
||||
@ApiModelProperty("装置识别码(3ds加密)")
|
||||
private String series;
|
||||
|
||||
@ApiModelProperty("装置秘钥(3ds加密)")
|
||||
private String devKey;
|
||||
|
||||
@ApiModelProperty("样品编号")
|
||||
private String sampleid;
|
||||
|
||||
@ApiModelProperty("送样日期")
|
||||
private LocalDateTime 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("复检次数,默认为0")
|
||||
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
|
||||
private Integer recheckNum;
|
||||
|
||||
|
||||
/**
|
||||
* 更新操作实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class PqDevUpdateParam extends PqDevParam {
|
||||
|
||||
@ApiModelProperty("id")
|
||||
@NotBlank(message = MachineValidMessage.ID_NOT_BLANK)
|
||||
@Pattern(regexp = PatternRegex.SYSTEM_ID, message = MachineValidMessage.ID_FORMAT_ERROR)
|
||||
private String id;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* 分页查询实体
|
||||
*/
|
||||
@Data
|
||||
@EqualsAndHashCode(callSuper = true)
|
||||
public static class PqDevQueryParam extends BaseParam {
|
||||
@ApiModelProperty("名称")
|
||||
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("设备类型")
|
||||
private String devType;
|
||||
|
||||
@ApiModelProperty("创建时间-开始")
|
||||
private LocalDateTime createTimeStart;
|
||||
|
||||
@ApiModelProperty("创建时间-结束")
|
||||
private LocalDateTime createTimeEnd;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,173 @@
|
||||
package com.njcn.gather.machine.device.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/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;
|
||||
|
||||
/**
|
||||
* 生产日期
|
||||
*/
|
||||
private LocalDateTime createdate;
|
||||
|
||||
/**
|
||||
* 出厂编号
|
||||
*/
|
||||
private String createid;
|
||||
|
||||
/**
|
||||
* 固件版本
|
||||
*/
|
||||
private String hardwareVersion;
|
||||
|
||||
/**
|
||||
* 软件版本
|
||||
*/
|
||||
private String softwareVersion;
|
||||
|
||||
/**
|
||||
* IP地址
|
||||
*/
|
||||
private String ip;
|
||||
|
||||
/**
|
||||
* 端口号
|
||||
*/
|
||||
private Integer port;
|
||||
|
||||
/**
|
||||
* 装置是否为加密版本
|
||||
*/
|
||||
@TableField("is_encryption")
|
||||
private Integer encryption;
|
||||
|
||||
/**
|
||||
* 装置识别码(3ds加密)
|
||||
*/
|
||||
private String series;
|
||||
|
||||
/**
|
||||
* 装置秘钥(3ds加密)
|
||||
*/
|
||||
private String devKey;
|
||||
|
||||
/**
|
||||
* 样品编号
|
||||
*/
|
||||
private String sampleid;
|
||||
|
||||
/**
|
||||
* 送样日期
|
||||
*/
|
||||
private LocalDateTime 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
|
||||
*/
|
||||
private Integer recheckNum;
|
||||
|
||||
/**
|
||||
* 状态:0-删除 1-正常
|
||||
*/
|
||||
private Integer state;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.njcn.gather.machine.device.service;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.machine.device.pojo.po.PqDev;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
public interface IPqDevService extends IService<PqDev> {
|
||||
|
||||
/**
|
||||
* 分页查询被检设备列表
|
||||
*
|
||||
* @param queryParam 查询参数
|
||||
* @return 分页数据,包含被检设备列表
|
||||
*/
|
||||
Page<PqDev> listPqDevs(PqDevParam.PqDevQueryParam queryParam);
|
||||
|
||||
/**
|
||||
* 新增被检设备信息
|
||||
*
|
||||
* @param pqDevParam 被检设备信息
|
||||
* @return 新增成功返回true,否则返回false
|
||||
*/
|
||||
boolean addPqDev(PqDevParam pqDevParam);
|
||||
|
||||
/**
|
||||
* 修改被检设备信息
|
||||
*
|
||||
* @param updateParam 被检设备信息
|
||||
* @return 修改成功返回true,否则返回false
|
||||
*/
|
||||
boolean updatePqDev(PqDevParam.PqDevUpdateParam updateParam);
|
||||
|
||||
/**
|
||||
* 删除被检设备信息
|
||||
*
|
||||
* @param ids 被检设备id列表
|
||||
* @return 删除成功返回true,否则返回false
|
||||
*/
|
||||
boolean deletePqDev(List<String> ids);
|
||||
}
|
||||
@@ -0,0 +1,92 @@
|
||||
package com.njcn.gather.machine.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.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.machine.device.mapper.PqDevMapper;
|
||||
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
|
||||
import com.njcn.gather.machine.device.pojo.po.PqDev;
|
||||
import com.njcn.gather.machine.device.service.IPqDevService;
|
||||
import com.njcn.gather.machine.pojo.enums.MachineResponseEnum;
|
||||
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/06
|
||||
*/
|
||||
@Slf4j
|
||||
@Service
|
||||
@RequiredArgsConstructor
|
||||
public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements IPqDevService {
|
||||
|
||||
@Override
|
||||
public Page<PqDev> listPqDevs(PqDevParam.PqDevQueryParam 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.getDevType()), "pq_dev.dev_type", queryParam.getDevType());
|
||||
//排序
|
||||
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, "pq_dev.update_time");
|
||||
}
|
||||
}
|
||||
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
|
||||
return this.page(new Page<>(PageFactory.getPageNum(queryParam), PageFactory.getPageSize(queryParam)), queryWrapper);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addPqDev(PqDevParam pqDevParam) {
|
||||
checkPqDevName(pqDevParam, false);
|
||||
PqDev dictPq = new PqDev();
|
||||
BeanUtil.copyProperties(pqDevParam, dictPq);
|
||||
//默认为正常状态
|
||||
dictPq.setState(DataStateEnum.ENABLE.getCode());
|
||||
return this.save(dictPq);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updatePqDev(PqDevParam.PqDevUpdateParam updateParam) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean deletePqDev(List<String> ids) {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验参数,检查是否存在相同名称的字典类型
|
||||
*/
|
||||
private void checkPqDevName(PqDevParam pqDevParam, boolean isExcludeSelf) {
|
||||
LambdaQueryWrapper<PqDev> dictDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
||||
dictDataLambdaQueryWrapper
|
||||
.eq(PqDev::getName, pqDevParam.getName())
|
||||
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode());
|
||||
//更新的时候,需排除当前记录
|
||||
if (isExcludeSelf) {
|
||||
if (pqDevParam instanceof PqDevParam.PqDevUpdateParam) {
|
||||
dictDataLambdaQueryWrapper.ne(PqDev::getId, ((PqDevParam.PqDevUpdateParam) pqDevParam).getId());
|
||||
}
|
||||
}
|
||||
int countByAccount = this.count(dictDataLambdaQueryWrapper);
|
||||
//大于等于1个则表示重复
|
||||
if (countByAccount >= 1) {
|
||||
throw new BusinessException(MachineResponseEnum.NAME_REPEAT);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.njcn.gather.machine.pojo.constant;
|
||||
|
||||
/**
|
||||
* @author caozehui
|
||||
* @date 2024/11/06
|
||||
*/
|
||||
public interface MachineValidMessage {
|
||||
|
||||
String ID_NOT_BLANK = "id不能为空,请检查id参数";
|
||||
|
||||
String ID_FORMAT_ERROR = "id格式错误,请检查id参数";
|
||||
|
||||
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 PRODUCEDATE_NOT_NULL = "生产日期不能为空,请检查producedDate参数";
|
||||
|
||||
String FACTORYNO_NOT_BLANK = "出厂编号不能为空,请检查factoryNo参数";
|
||||
|
||||
String FIRMWARE_NOT_BLANK = "固件版本不能为空,请检查firmware参数";
|
||||
|
||||
String SOFTWARE_NOT_BLANK = "软件版本不能为空,请检查software参数";
|
||||
|
||||
String IP_NOT_BLANK = "IP地址不能为空,请检查ip参数";
|
||||
|
||||
String PORT_NOT_NULL = "端口号不能为空,请检查port参数";
|
||||
|
||||
String ENCRYPTION_NOT_NULL = "是否为加密版本不能为空,请检查isEncryption参数";
|
||||
|
||||
String RECHECK_NUM_NOT_NULL = "复检次数不能为空,请检查recheckNum参数";
|
||||
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.njcn.gather.machine.pojo.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
@Getter
|
||||
public enum MachineResponseEnum {
|
||||
NAME_REPEAT("1001", "名称重复");
|
||||
|
||||
private final String code;
|
||||
|
||||
private final String message;
|
||||
|
||||
MachineResponseEnum(String code, String message) {
|
||||
this.code = code;
|
||||
this.message = message;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user