电能质量字典crud

This commit is contained in:
caozehui
2024-11-06 11:04:16 +08:00
parent bb5e5dfec5
commit e640bd4516
21 changed files with 874 additions and 29 deletions

34
machine/pom.xml Normal file
View 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>

View File

@@ -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);
}
}
}

View File

@@ -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> {
}

View File

@@ -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>

View File

@@ -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;
}
}

View File

@@ -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;
}

View File

@@ -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);
}

View File

@@ -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);
}
}
}

View File

@@ -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参数";
}

View File

@@ -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;
}
}

View File

@@ -11,6 +11,7 @@
<module>entrance</module>
<module>system</module>
<module>user</module>
<module>machine</module>
</modules>
<packaging>pom</packaging>
<name>融合各工具的项目</name>

View File

@@ -11,6 +11,7 @@ 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.DictDataParam;
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
import com.njcn.gather.system.dictionary.pojo.po.DictData;
import com.njcn.gather.system.dictionary.service.IDictDataService;
import com.njcn.web.controller.BaseController;
@@ -146,5 +147,13 @@ public class DictDataController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.NO_DATA, null, methodDescribe);
}
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/export")
@ApiOperation("导出字典数据")
@ApiImplicitParam(name = "queryParam", value = "查询参数",required = true)
public void export(@RequestBody @Validated DictDataParam.DicTypeIdQueryParam queryParam) {
dictDataService.exportDictData(queryParam);
}
}

View File

@@ -26,6 +26,10 @@ import org.springframework.web.bind.annotation.RestController;
import java.util.List;
/**
* @author caozehui
* @date 2024/11/05
*/
@Slf4j
@Api(tags = "电能质量指标字典操作")
@RestController
@@ -46,9 +50,10 @@ public class DictPqController extends BaseController {
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){
public HttpResult<Object> add(@RequestBody @Validated DictPqParam dictPqParam) {
String methodDescribe = getMethodDescribe("add");
LogUtil.njcnDebug(log, "{},新增数据为:{}", methodDescribe, dictPqParam);
boolean result = dictPqService.addDictPq(dictPqParam);
@@ -59,9 +64,11 @@ public class DictPqController extends BaseController {
}
}
@OperateInfo(info = LogEnum.SYSTEM_COMMON, operateType = OperateType.UPDATE)
@PostMapping("/update")
@ApiOperation("更新电能质量指标字典")
public HttpResult<Object> update(@RequestBody @Validated DictPqParam.DictPqUpdateParam updateParam){
@ApiImplicitParam(name = "updateParam", value = "更新参数", required = true)
public HttpResult<Object> update(@RequestBody @Validated DictPqParam.DictPqUpdateParam updateParam) {
String methodDescribe = getMethodDescribe("update");
LogUtil.njcnDebug(log, "{},更新数据为:{}", methodDescribe, updateParam);
boolean result = dictPqService.updateDictPq(updateParam);
@@ -78,7 +85,7 @@ public class DictPqController extends BaseController {
@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));
LogUtil.njcnDebug(log, "{}删除ID数据为{}", methodDescribe, String.join(StrUtil.COMMA, ids));
boolean result = dictPqService.deleteDictPq(ids);
if (result) {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);

View File

@@ -109,7 +109,7 @@ public class DictTypeController extends BaseController {
@OperateInfo(info = LogEnum.SYSTEM_COMMON)
@PostMapping("/export")
@ApiOperation("导出字典类型数据")
@ApiImplicitParam(name = "queryParam", value = "查询参数", required = true)
@ApiImplicitParam(name = "queryParam", value = "查询参数",required = true)
public void export(@RequestBody @Validated DictTypeParam.DictTypeQueryParam queryParam) {
dictTypeService.exportDictType(queryParam);
}

View File

@@ -0,0 +1,94 @@
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 DictDataVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 字典数据表Id
*/
@Excel(name = "字典数据表Id")
private String id;
/**
* 字典类型表Id
*/
@Excel(name = "字典类型表Id")
private String typeId;
/**
* 名称
*/
@Excel(name = "名称")
private String name;
/**
* 编码
*/
@Excel(name = "编码")
private String code;
/**
* 排序
*/
@Excel(name = "排序")
private Integer sort;
/**
* 事件等级0-普通1-中等2-严重(默认为0)
*/
@Excel(name = "事件等级")
private Integer level;
/**
* 与高级算法内部Id描述对应
*/
@Excel(name = "与高级算法内部Id描述对应")
private Integer algoDescribe;
/**
* 目前只用于表示电压等级数值
*/
@Excel(name = "数值")
private String value;
/**
* 状态0-删除 1-正常
*/
@Excel(name = "状态")
private Integer state;
/**
* 创建人
*/
@Excel(name = "创建人")
private String createBy;
/**
* 创建时间
*/
@Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 更新人
*/
@Excel(name = "更新人")
private String updateBy;
/**
* 更新时间
*/
@Excel(name = "更新时间", format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -9,70 +9,81 @@ import java.time.LocalDateTime;
/**
* @author caozehui
* @since 2024-11-05
* @date 2024/11/5
*/
@Data
@AllArgsConstructor
public class DictTypeVO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 字典类型表Id
*/
//private String id;
@Excel(name = "Id")
private String id;
/**
* 名称
*/
@Excel(name = "名称")
private String name;
/**
* 编码
*/
@Excel(name = "编码")
private String code;
/**
* 排序
*/
//private Integer sort;
@Excel(name = "排序")
private Integer sort;
/**
* 开启等级0-不开启1-开启,默认不开启
*/
//private Integer openLevel;
@Excel(name = "开启等级")
private Integer openLevel;
/**
* 开启描述0-不开启1-开启,默认不开启
*/
//private Integer openDescribe;
@Excel(name = "开启描述")
private Integer openDescribe;
/**
* 描述
*/
//private String remark;
@Excel(name = "描述")
private String remark;
/**
* 状态0-删除 1-正常
*/
//private Integer state;
@Excel(name = "状态")
private Integer state;
/**
* 创建人
*/
//private String createBy;
@Excel(name = "创建人")
private String createBy;
/**
* 创建时间
*/
//private String createTime;
@Excel(name = "创建时间", format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime createTime;
/**
* 更新人
*/
//private String updateBy;
@Excel(name = "更新人")
private String updateBy;
/**
* 更新时间
*/
//private String updateTime;
@Excel(name = "更新时间", format = "yyyy-MM-dd HH:mm:ss")
private LocalDateTime updateTime;
}

View File

@@ -68,4 +68,10 @@ public interface IDictDataService extends IService<DictData> {
* @return 返回所有字典数据
*/
List<SimpleTreeDTO> dictDataCache();
/**
* 导出字典数据
* @param queryParam 查询参数
*/
void exportDictData(DictDataParam.DicTypeIdQueryParam queryParam);
}

View File

@@ -13,6 +13,8 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.gather.system.dictionary.mapper.DictDataMapper;
import com.njcn.gather.system.dictionary.pojo.dto.DictDataCache;
import com.njcn.gather.system.dictionary.pojo.vo.DictDataVO;
import com.njcn.gather.system.dictionary.pojo.vo.DictTypeVO;
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;
@@ -21,6 +23,7 @@ import com.njcn.gather.system.dictionary.service.IDictDataService;
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;
@@ -43,8 +46,8 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
public Page<DictData> getTypeIdData(DictDataParam.DicTypeIdQueryParam 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()));
@@ -135,6 +138,26 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
}).collect(Collectors.toList());
}
@Override
public void exportDictData(DictDataParam.DicTypeIdQueryParam 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");
}
}
queryWrapper.ne("sys_dict_data.state", DataStateEnum.DELETED.getCode())
.eq("sys_dict_data.type_id", queryParam.getTypeId());
List<DictData> dictDatas = this.list(queryWrapper);
List<DictDataVO> dictDataVOS = BeanUtil.copyToList(dictDatas, DictDataVO.class);
ExcelUtil.exportExcel("字典数据导出数据.xls", "字典数据", DictDataVO.class, dictDataVOS);
}
/**

View File

@@ -30,7 +30,7 @@ public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> impleme
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.orther_name", queryParam.getOtherName())
.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());
@@ -53,7 +53,6 @@ public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> impleme
BeanUtil.copyProperties(dictPqParam, dictPq);
//默认为正常状态
dictPq.setState(DataStateEnum.ENABLE.getCode());
System.out.println(dictPq.toString());
return this.save(dictPq);
}
@@ -74,7 +73,7 @@ public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> impleme
}
/**
* 校验参数,检查同一数据存储及相别下是否存在相同名称的字典项
* 校验参数,检查同一数据模型及相别下是否存在相同名称的字典项
*
* @param dictPqParam 字典项参数
* @param isExcludeSelf 是否排除自己
@@ -82,7 +81,7 @@ public class DictPqServiceImpl extends ServiceImpl<DictPqMapper, DictPq> impleme
private void checkDicPqName(DictPqParam dictPqParam, boolean isExcludeSelf) {
LambdaQueryWrapper<DictPq> dictPqLambdaQueryWrapper = new LambdaQueryWrapper<>();
dictPqLambdaQueryWrapper
.eq(StrUtil.isNotBlank(dictPqParam.getClassId()), DictPq::getClassId, dictPqParam.getClassId())
.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());

View File

@@ -36,8 +36,8 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
public Page<DictType> listDictTypes(DictTypeParam.DictTypeQueryParam 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()));
@@ -78,10 +78,21 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
@Override
public void exportDictType(DictTypeParam.DictTypeQueryParam queryParam) {
List<DictType> dictTypes = this.listDictTypes(queryParam).getRecords();
//List<DictTypeVO> dictTypeVOS = BeanUtil.copyToList(dictTypes, DictTypeVO.class);
List<DictTypeVO> dictTypeVOS = new ArrayList<>();
dictTypeVOS.add(new DictTypeVO("性别","SEX"));
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");
}
}
queryWrapper.ne("sys_dict_type.state", DataStateEnum.DELETED.getCode());
List<DictType> dictTypes = this.list(queryWrapper);
List<DictTypeVO> dictTypeVOS = BeanUtil.copyToList(dictTypes, DictTypeVO.class);
ExcelUtil.exportExcel("字典类型导出数据.xls", "字典类型", DictTypeVO.class, dictTypeVOS);
}

View File

@@ -53,7 +53,7 @@ public enum SystemResponseEnum {
TIMER_NOT_EXISTED("A00361", "定时任务执行类不存在"),
EXE_EMPTY_PARAM("A00361", "请检查定时器的id定时器cron表达式定时任务是否为空"),
DICT_PQ_NAME_EXIST("", "当前数据存储及相别下已存在相同名称"),
DICT_PQ_NAME_EXIST("A00389", "当前数据模型及相别下已存在相同名称"),
/**
* 审计日志模块异常响应
*/