From e640bd4516a733011f4cdd7f87f5eaf14e116829 Mon Sep 17 00:00:00 2001 From: caozehui <2427765068@qq.com> Date: Wed, 6 Nov 2024 11:04:16 +0800 Subject: [PATCH] =?UTF-8?q?=E7=94=B5=E8=83=BD=E8=B4=A8=E9=87=8F=E5=AD=97?= =?UTF-8?q?=E5=85=B8crud?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- machine/pom.xml | 34 ++++ .../device/controller/PqDevController.java | 98 ++++++++++ .../machine/device/mapper/PqDevMapper.java | 13 ++ .../device/mapper/mapping/PqDevMapper.xml | 7 + .../machine/device/pojo/param/PqDevParam.java | 158 ++++++++++++++++ .../gather/machine/device/pojo/po/PqDev.java | 173 ++++++++++++++++++ .../machine/device/service/IPqDevService.java | 47 +++++ .../device/service/impl/PqDevServiceImpl.java | 92 ++++++++++ .../pojo/constant/MachineValidMessage.java | 45 +++++ .../pojo/enums/MachineResponseEnum.java | 17 ++ pom.xml | 1 + .../controller/DictDataController.java | 9 + .../controller/DictPqController.java | 13 +- .../controller/DictTypeController.java | 2 +- .../system/dictionary/pojo/vo/DictDataVO.java | 94 ++++++++++ .../system/dictionary/pojo/vo/DictTypeVO.java | 35 ++-- .../dictionary/service/IDictDataService.java | 6 + .../service/impl/DictDataServiceImpl.java | 27 ++- .../service/impl/DictPqServiceImpl.java | 7 +- .../service/impl/DictTypeServiceImpl.java | 23 ++- .../system/pojo/enums/SystemResponseEnum.java | 2 +- 21 files changed, 874 insertions(+), 29 deletions(-) create mode 100644 machine/pom.xml create mode 100644 machine/src/main/java/com/njcn/gather/machine/device/controller/PqDevController.java create mode 100644 machine/src/main/java/com/njcn/gather/machine/device/mapper/PqDevMapper.java create mode 100644 machine/src/main/java/com/njcn/gather/machine/device/mapper/mapping/PqDevMapper.xml create mode 100644 machine/src/main/java/com/njcn/gather/machine/device/pojo/param/PqDevParam.java create mode 100644 machine/src/main/java/com/njcn/gather/machine/device/pojo/po/PqDev.java create mode 100644 machine/src/main/java/com/njcn/gather/machine/device/service/IPqDevService.java create mode 100644 machine/src/main/java/com/njcn/gather/machine/device/service/impl/PqDevServiceImpl.java create mode 100644 machine/src/main/java/com/njcn/gather/machine/pojo/constant/MachineValidMessage.java create mode 100644 machine/src/main/java/com/njcn/gather/machine/pojo/enums/MachineResponseEnum.java create mode 100644 system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictDataVO.java diff --git a/machine/pom.xml b/machine/pom.xml new file mode 100644 index 00000000..8e0b4f85 --- /dev/null +++ b/machine/pom.xml @@ -0,0 +1,34 @@ + + + 4.0.0 + + com.njcn.gather + CN_Gather + 1.0.0 + + machine + + + + com.njcn + njcn-common + 0.0.1 + + + + com.njcn + mybatis-plus + 0.0.1 + + + + com.njcn + spingboot2.3.12 + 2.3.12 + + + + + \ No newline at end of file diff --git a/machine/src/main/java/com/njcn/gather/machine/device/controller/PqDevController.java b/machine/src/main/java/com/njcn/gather/machine/device/controller/PqDevController.java new file mode 100644 index 00000000..1f9a0a9f --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/device/controller/PqDevController.java @@ -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> list(@RequestBody @Validated PqDevParam.PqDevQueryParam queryParam) { + String methodDescribe = getMethodDescribe("list"); + LogUtil.njcnDebug(log, "{},查询数据为:{}", methodDescribe, queryParam); + Page 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 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 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 delete(@RequestBody List 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); + } + } +} + diff --git a/machine/src/main/java/com/njcn/gather/machine/device/mapper/PqDevMapper.java b/machine/src/main/java/com/njcn/gather/machine/device/mapper/PqDevMapper.java new file mode 100644 index 00000000..52bf71d8 --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/device/mapper/PqDevMapper.java @@ -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 { + +} + diff --git a/machine/src/main/java/com/njcn/gather/machine/device/mapper/mapping/PqDevMapper.xml b/machine/src/main/java/com/njcn/gather/machine/device/mapper/mapping/PqDevMapper.xml new file mode 100644 index 00000000..09d4a1f1 --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/device/mapper/mapping/PqDevMapper.xml @@ -0,0 +1,7 @@ + + + + + + + diff --git a/machine/src/main/java/com/njcn/gather/machine/device/pojo/param/PqDevParam.java b/machine/src/main/java/com/njcn/gather/machine/device/pojo/param/PqDevParam.java new file mode 100644 index 00000000..79b3ac42 --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/device/pojo/param/PqDevParam.java @@ -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; + } +} diff --git a/machine/src/main/java/com/njcn/gather/machine/device/pojo/po/PqDev.java b/machine/src/main/java/com/njcn/gather/machine/device/pojo/po/PqDev.java new file mode 100644 index 00000000..81f7e3a5 --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/device/pojo/po/PqDev.java @@ -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; +} + diff --git a/machine/src/main/java/com/njcn/gather/machine/device/service/IPqDevService.java b/machine/src/main/java/com/njcn/gather/machine/device/service/IPqDevService.java new file mode 100644 index 00000000..14018777 --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/device/service/IPqDevService.java @@ -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 { + + /** + * 分页查询被检设备列表 + * + * @param queryParam 查询参数 + * @return 分页数据,包含被检设备列表 + */ + Page 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 ids); +} diff --git a/machine/src/main/java/com/njcn/gather/machine/device/service/impl/PqDevServiceImpl.java b/machine/src/main/java/com/njcn/gather/machine/device/service/impl/PqDevServiceImpl.java new file mode 100644 index 00000000..e05ed335 --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/device/service/impl/PqDevServiceImpl.java @@ -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 implements IPqDevService { + + @Override + public Page listPqDevs(PqDevParam.PqDevQueryParam queryParam) { + QueryWrapper 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 ids) { + return false; + } + + /** + * 校验参数,检查是否存在相同名称的字典类型 + */ + private void checkPqDevName(PqDevParam pqDevParam, boolean isExcludeSelf) { + LambdaQueryWrapper 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); + } + } +} diff --git a/machine/src/main/java/com/njcn/gather/machine/pojo/constant/MachineValidMessage.java b/machine/src/main/java/com/njcn/gather/machine/pojo/constant/MachineValidMessage.java new file mode 100644 index 00000000..7d8e9a67 --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/pojo/constant/MachineValidMessage.java @@ -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参数"; + +} diff --git a/machine/src/main/java/com/njcn/gather/machine/pojo/enums/MachineResponseEnum.java b/machine/src/main/java/com/njcn/gather/machine/pojo/enums/MachineResponseEnum.java new file mode 100644 index 00000000..39e1939a --- /dev/null +++ b/machine/src/main/java/com/njcn/gather/machine/pojo/enums/MachineResponseEnum.java @@ -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; + } +} diff --git a/pom.xml b/pom.xml index 6cdf0831..86b434be 100644 --- a/pom.xml +++ b/pom.xml @@ -11,6 +11,7 @@ entrance system user + machine pom 融合各工具的项目 diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictDataController.java b/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictDataController.java index 99cf17fa..33da717e 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictDataController.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictDataController.java @@ -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); + } } diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictPqController.java b/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictPqController.java index 29cbbe80..2e2954c3 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictPqController.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictPqController.java @@ -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 add(@RequestBody @Validated DictPqParam dictPqParam){ + public HttpResult 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 update(@RequestBody @Validated DictPqParam.DictPqUpdateParam updateParam){ + @ApiImplicitParam(name = "updateParam", value = "更新参数", required = true) + public HttpResult 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 delete(@RequestBody List 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); diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictTypeController.java b/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictTypeController.java index 9651bfef..53fcec05 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictTypeController.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/controller/DictTypeController.java @@ -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); } diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictDataVO.java b/system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictDataVO.java new file mode 100644 index 00000000..8ab698b1 --- /dev/null +++ b/system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictDataVO.java @@ -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; +} diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictTypeVO.java b/system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictTypeVO.java index 984053f7..687669bb 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictTypeVO.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictTypeVO.java @@ -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; } diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/service/IDictDataService.java b/system/src/main/java/com/njcn/gather/system/dictionary/service/IDictDataService.java index a9dc9d45..27d82405 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/service/IDictDataService.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/service/IDictDataService.java @@ -68,4 +68,10 @@ public interface IDictDataService extends IService { * @return 返回所有字典数据 */ List dictDataCache(); + + /** + * 导出字典数据 + * @param queryParam 查询参数 + */ + void exportDictData(DictDataParam.DicTypeIdQueryParam queryParam); } diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictDataServiceImpl.java b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictDataServiceImpl.java index e3693960..dc3f2818 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictDataServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictDataServiceImpl.java @@ -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 i public Page getTypeIdData(DictDataParam.DicTypeIdQueryParam queryParam) { QueryWrapper 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 i }).collect(Collectors.toList()); } + @Override + public void exportDictData(DictDataParam.DicTypeIdQueryParam queryParam) { + QueryWrapper 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 dictDatas = this.list(queryWrapper); + List dictDataVOS = BeanUtil.copyToList(dictDatas, DictDataVO.class); + ExcelUtil.exportExcel("字典数据导出数据.xls", "字典数据", DictDataVO.class, dictDataVOS); + } /** diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java index 3877e29d..7a2659a0 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictPqServiceImpl.java @@ -30,7 +30,7 @@ public class DictPqServiceImpl extends ServiceImpl impleme QueryWrapper 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 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 impleme } /** - * 校验参数,检查同一数据存储及相别下是否存在相同名称的字典项 + * 校验参数,检查同一数据模型及相别下是否存在相同名称的字典项 * * @param dictPqParam 字典项参数 * @param isExcludeSelf 是否排除自己 @@ -82,7 +81,7 @@ public class DictPqServiceImpl extends ServiceImpl impleme private void checkDicPqName(DictPqParam dictPqParam, boolean isExcludeSelf) { LambdaQueryWrapper 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()); diff --git a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java index 03171cb7..6d2d4b86 100644 --- a/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java +++ b/system/src/main/java/com/njcn/gather/system/dictionary/service/impl/DictTypeServiceImpl.java @@ -36,8 +36,8 @@ public class DictTypeServiceImpl extends ServiceImpl i public Page listDictTypes(DictTypeParam.DictTypeQueryParam queryParam) { QueryWrapper 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 i @Override public void exportDictType(DictTypeParam.DictTypeQueryParam queryParam) { - List dictTypes = this.listDictTypes(queryParam).getRecords(); - //List dictTypeVOS = BeanUtil.copyToList(dictTypes, DictTypeVO.class); - List dictTypeVOS = new ArrayList<>(); - dictTypeVOS.add(new DictTypeVO("性别","SEX")); + QueryWrapper 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 dictTypes = this.list(queryWrapper); + List dictTypeVOS = BeanUtil.copyToList(dictTypes, DictTypeVO.class); ExcelUtil.exportExcel("字典类型导出数据.xls", "字典类型", DictTypeVO.class, dictTypeVOS); } diff --git a/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java b/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java index e7040e06..f0cbbaf1 100644 --- a/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java +++ b/system/src/main/java/com/njcn/gather/system/pojo/enums/SystemResponseEnum.java @@ -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", "当前数据模型及相别下已存在相同名称"), /** * 审计日志模块异常响应 */