微调字典类型和字典数据,被检设备功能实现

This commit is contained in:
caozehui
2024-11-07 19:22:31 +08:00
parent e640bd4516
commit 05cdb20594
15 changed files with 460 additions and 123 deletions

View File

@@ -16,6 +16,11 @@
<artifactId>system</artifactId> <artifactId>system</artifactId>
<version>1.0.0</version> <version>1.0.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.njcn.gather</groupId>
<artifactId>machine</artifactId>
<version>1.0.0</version>
</dependency>
</dependencies> </dependencies>
<build> <build>

View File

@@ -28,7 +28,7 @@ spring:
mybatis-plus: mybatis-plus:
mapper-locations: classpath*:com/njcn/**/mapping/*.xml mapper-locations: classpath*:com/njcn/**/mapping/*.xml
#别名扫描 #别名扫描
type-aliases-package: com.njcn.gather.system.dictionary.pojo.po type-aliases-package: com.njcn.gather.system.dictionary.pojo.po,com.njcn.gather.machine.pojo.po
configuration: configuration:
#驼峰命名 #驼峰命名
map-underscore-to-camel-case: true map-underscore-to-camel-case: true

View File

@@ -1,28 +1,35 @@
package com.njcn.gather.machine.device.controller; package com.njcn.gather.machine.device.controller;
import cn.afterturn.easypoi.excel.ExcelImportUtil;
import cn.afterturn.easypoi.excel.entity.ImportParams;
import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult;
import cn.hutool.core.util.StrUtil; import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo; import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType; import com.njcn.common.pojo.constant.OperateType;
import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum; import com.njcn.common.pojo.enums.response.CommonResponseEnum;
import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult; import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil; import com.njcn.common.utils.LogUtil;
import com.njcn.gather.machine.device.pojo.param.PqDevParam; import com.njcn.gather.machine.device.pojo.param.PqDevParam;
import com.njcn.gather.machine.device.pojo.po.PqDev; import com.njcn.gather.machine.device.pojo.po.PqDev;
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
import com.njcn.gather.machine.device.service.IPqDevService; import com.njcn.gather.machine.device.service.IPqDevService;
import com.njcn.gather.machine.pojo.enums.MachineResponseEnum;
import com.njcn.web.controller.BaseController; import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil; import com.njcn.web.utils.HttpResultUtil;
import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated; import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.*;
import org.springframework.web.bind.annotation.RequestBody; import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import javax.servlet.http.HttpServletResponse;
import java.util.List; import java.util.List;
@@ -94,5 +101,48 @@ public class PqDevController extends BaseController {
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe); return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.FAIL, null, methodDescribe);
} }
} }
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/downloadTemplate")
@ApiOperation("下载被检设备导入文件模板")
public void downloadTemplate() {
pqDevService.downloadTemplate();
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD)
@PostMapping(value = "/import")
@ApiOperation("批量导入被检设备数据")
@ApiImplicitParam(name = "ids", value = "被检设备id", required = true)
public HttpResult<String> importPqDevData(@RequestParam("file") MultipartFile file, HttpServletResponse response) {
String methodDescribe = getMethodDescribe("importPqDevData");
ImportParams params = new ImportParams();
params.setHeadRows(1);
params.setNeedVerify(true);
params.setStartSheetIndex(0);
params.setSheetNum(1);
try {
ExcelImportResult<PqDevExcel> excelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), PqDevExcel.class, params);
//如果存在非法数据,将不合格的数据导出
if (excelImportResult.isVerifyFail()) {
// 此处前端要做特殊处理,具体可以参考技术监督的数据导入
PoiUtil.exportFileByWorkbook(excelImportResult.getFailWorkbook(), "非法被检设备数据.xlsx", response);
throw new BusinessException(MachineResponseEnum.IMPORT_DATA_FAIL);
} else {
//批量录入数据
List<PqDevExcel> sgEventExcels = excelImportResult.getList();
pqDevService.importPqDevData(sgEventExcels);
}
} catch (Exception e) {
throw new BusinessException(MachineResponseEnum.IMPORT_DATA_FAIL);
}
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe);
}
@OperateInfo(info = LogEnum.BUSINESS_COMMON)
@PostMapping("/export")
@ApiOperation("导出被检设备数据")
@ApiImplicitParam(name = "queryParam", value = "查询参数",required = true)
public void export(@RequestBody @Validated PqDevParam.PqDevQueryParam queryParam) {
pqDevService.exportPqDevData(queryParam);
}
}

View File

@@ -1,8 +1,8 @@
package com.njcn.gather.machine.device.pojo.param; package com.njcn.gather.machine.device.pojo.param;
import com.baomidou.mybatisplus.annotation.TableField;
import com.njcn.common.pojo.constant.PatternRegex; import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.machine.pojo.constant.MachineValidMessage; import com.njcn.gather.machine.pojo.constant.MachineValidMessage;
import com.njcn.web.pojo.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam; import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
@@ -11,7 +11,6 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank; import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull; import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern; import javax.validation.constraints.Pattern;
import java.time.LocalDateTime;
/** /**
* @author caozehui * @author caozehui
@@ -20,63 +19,68 @@ import java.time.LocalDateTime;
@Data @Data
public class PqDevParam { public class PqDevParam {
@ApiModelProperty("名称") @ApiModelProperty(value = "名称", required = true)
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK) @NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR) @Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
private String name; private String name;
@ApiModelProperty("设备模式,字典表(数字、模拟、比对)") @ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK) @NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
private String pattern; private String pattern;
@ApiModelProperty("设备类型,字典表") @ApiModelProperty(value = "设备类型,字典表", required = true)
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK) @NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
private String devType; private String devType;
@ApiModelProperty("设备通道数") @ApiModelProperty(value = "设备通道数", required = true)
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL) @NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
private Integer devChns; private Integer devChns;
@ApiModelProperty("额定电压V") @ApiModelProperty(value = "额定电压V", required = true)
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL) @NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt; private Float devVolt;
@ApiModelProperty("额定电流A") @ApiModelProperty(value = "额定电流A", required = true)
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL) @NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr; private Float devCurr;
@ApiModelProperty("生产厂家,字典表") @ApiModelProperty(value = "生产厂家,字典表", required = true)
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK) @NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer; private String manufacturer;
@ApiModelProperty("生产日期") @ApiModelProperty(value = "生产日期", required = true)
@NotNull(message = MachineValidMessage.PRODUCEDATE_NOT_NULL) @NotBlank(message = MachineValidMessage.CREATEDATETIME_NOT_NULL)
private LocalDateTime createdate; @DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.CREATEDATETIME_FORMAT_ERROR)
private String createDate;
@ApiModelProperty("出厂编号") @ApiModelProperty(value = "出厂编号", required = true)
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK) @NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
private String createid; private String createId;
@ApiModelProperty("固件版本") @ApiModelProperty(value = "固件版本", required = true)
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK) @NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion; private String hardwareVersion;
@ApiModelProperty("软件版本") @ApiModelProperty(value = "软件版本", required = true)
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK) @NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion; private String softwareVersion;
@ApiModelProperty("IP地址") @ApiModelProperty(value = "通讯协议", required = true)
@NotBlank(message = MachineValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@ApiModelProperty(value = "IP地址", required = true)
@NotBlank(message = MachineValidMessage.IP_NOT_BLANK) @NotBlank(message = MachineValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = MachineValidMessage.IP_FORMAT_ERROR)
private String ip; private String ip;
@ApiModelProperty("端口号") @ApiModelProperty(value = "端口号", required = true)
@NotNull(message = MachineValidMessage.PORT_NOT_NULL) @NotNull(message = MachineValidMessage.PORT_NOT_NULL)
private Integer port; private Integer port;
@ApiModelProperty("装置是否为加密版本") @ApiModelProperty(value = "装置是否为加密版本", required = true)
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL) @NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
@TableField(value = "is_encryption") private Integer encryption;
private Integer encryption;;
@ApiModelProperty("装置识别码3ds加密") @ApiModelProperty("装置识别码3ds加密")
private String series; private String series;
@@ -85,10 +89,11 @@ public class PqDevParam {
private String devKey; private String devKey;
@ApiModelProperty("样品编号") @ApiModelProperty("样品编号")
private String sampleid; private String sampleId;
@ApiModelProperty("送样日期") @ApiModelProperty(value = "送样日期", required = false)
private LocalDateTime arrivedDate; @DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.ARRIVEDATETIME_FORMAT_ERROR)
private String arrivedDate;
@ApiModelProperty("所属地市名称") @ApiModelProperty("所属地市名称")
private String cityName; private String cityName;
@@ -117,9 +122,9 @@ public class PqDevParam {
@ApiModelProperty("设备关键信息二维码") @ApiModelProperty("设备关键信息二维码")
private String qrCode; private String qrCode;
@ApiModelProperty("复检次数,默认为0") @ApiModelProperty(value = "复检次数,默认为0", required = true)
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL) @NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
private Integer recheckNum; private Integer reCheckNum;
/** /**
@@ -148,11 +153,5 @@ public class PqDevParam {
@ApiModelProperty("设备类型") @ApiModelProperty("设备类型")
private String devType; private String devType;
@ApiModelProperty("创建时间-开始")
private LocalDateTime createTimeStart;
@ApiModelProperty("创建时间-结束")
private LocalDateTime createTimeEnd;
} }
} }

View File

@@ -1,13 +1,19 @@
package com.njcn.gather.machine.device.pojo.po; package com.njcn.gather.machine.device.pojo.po;
import com.baomidou.mybatisplus.annotation.FieldStrategy;
import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName; import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.njcn.db.mybatisplus.bo.BaseEntity; import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data; import lombok.Data;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
import java.io.Serializable; import java.io.Serializable;
import java.time.LocalDateTime; import java.time.LocalDate;
/** /**
* @author caozehui * @author caozehui
@@ -16,7 +22,7 @@ import java.time.LocalDateTime;
@Data @Data
@EqualsAndHashCode(callSuper = true) @EqualsAndHashCode(callSuper = true)
@TableName("pq_dev") @TableName("pq_dev")
public class PqDev extends BaseEntity implements Serializable{ public class PqDev extends BaseEntity implements Serializable {
private static final long serialVersionUID = -45763424394344208L; private static final long serialVersionUID = -45763424394344208L;
/** /**
@@ -62,12 +68,17 @@ public class PqDev extends BaseEntity implements Serializable{
/** /**
* 生产日期 * 生产日期
*/ */
private LocalDateTime createdate; @TableField(value = "CreateDate")
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate createDate;
/** /**
* 出厂编号 * 出厂编号
*/ */
private String createid; @TableField(value = "CreateId")
private String createId;
/** /**
* 固件版本 * 固件版本
@@ -79,6 +90,11 @@ public class PqDev extends BaseEntity implements Serializable{
*/ */
private String softwareVersion; private String softwareVersion;
/**
* 通讯协议,字典表(MMS、PODIF)
*/
private String protocol;
/** /**
* IP地址 * IP地址
*/ */
@@ -92,7 +108,7 @@ public class PqDev extends BaseEntity implements Serializable{
/** /**
* 装置是否为加密版本 * 装置是否为加密版本
*/ */
@TableField("is_encryption") @TableField("IsEncryption")
private Integer encryption; private Integer encryption;
/** /**
@@ -108,12 +124,17 @@ public class PqDev extends BaseEntity implements Serializable{
/** /**
* 样品编号 * 样品编号
*/ */
private String sampleid; @TableField("SampleID")
private String sampleId;
/** /**
* 送样日期 * 送样日期
*/ */
private LocalDateTime arrivedDate; @TableField(updateStrategy = FieldStrategy.IGNORED)
@JsonFormat(pattern = "yyyy-MM-dd")
@JsonDeserialize(using = LocalDateDeserializer.class)
@JsonSerialize(using = LocalDateSerializer.class)
private LocalDate arrivedDate;
/** /**
* 所属地市名称 * 所属地市名称
@@ -163,7 +184,8 @@ public class PqDev extends BaseEntity implements Serializable{
/** /**
* 复检次数,默认为0 * 复检次数,默认为0
*/ */
private Integer recheckNum; @TableField(value = "ReCheck_Num")
private Integer reCheckNum;
/** /**
* 状态0-删除 1-正常 * 状态0-删除 1-正常

View File

@@ -0,0 +1,129 @@
package com.njcn.gather.machine.device.pojo.vo;
import cn.afterturn.easypoi.excel.annotation.Excel;
import com.njcn.common.pojo.constant.PatternRegex;
import com.njcn.gather.machine.pojo.constant.MachineValidMessage;
import lombok.Data;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
import java.io.Serializable;
import java.time.LocalDate;
/**
* @author caozehui
* @data 2024/11/7
*/
@Data
public class PqDevExcel implements Serializable {
private static final long serialVersionUID = 1L;
@Excel(name = "名称", width = 20)
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
private String name;
@Excel(name = "设备模式", width = 20)
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
private String pattern;
@Excel(name = "设备类型", width = 20)
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
@Excel(name = "设备通道数", width = 20)
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
private Integer devChns;
@Excel(name = "额定电压V", width = 15)
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt;
@Excel(name = "额定电流A", width = 15)
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr;
@Excel(name = "生产厂家", width = 20)
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
@Excel(name = "生产日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd")
@NotNull(message = MachineValidMessage.CREATEDATETIME_NOT_NULL)
//@DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.CREATEDATETIME_FORMAT_ERROR)
private LocalDate createDate;
@Excel(name = "出厂编号", width = 40)
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
private String createId;
@Excel(name = "固件版本", width = 15)
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion;
@Excel(name = "软件版本", width = 15)
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
private String softwareVersion;
@Excel(name = "通讯协议", width = 15)
@NotBlank(message = MachineValidMessage.PROTOCOL_NOT_BLANK)
private String protocol;
@Excel(name = "IP地址", width = 20)
@NotBlank(message = MachineValidMessage.IP_NOT_BLANK)
@Pattern(regexp = PatternRegex.IP_REGEX, message = MachineValidMessage.IP_FORMAT_ERROR)
private String ip;
@Excel(name = "端口号")
@NotNull(message = MachineValidMessage.PORT_NOT_NULL)
private Integer port;
@Excel(name = "是否为加密版本1是/0", width = 20)
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
private Integer encryption;
@Excel(name = "识别码(未加密)", width = 30)
private String series;
@Excel(name = "秘钥(未加密)", width = 30)
private String devKey;
@Excel(name = "样品编号", width = 40)
private String sampleId;
@Excel(name = "送样日期yyyy-MM-dd", width = 25, format = "yyyy-MM-dd")
//@DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.ARRIVEDATETIME_FORMAT_ERROR)
private LocalDate arrivedDate;
@Excel(name = "所属地市名称", width = 20)
private String cityName;
@Excel(name = "所属供电公司名称", width = 20)
private String gdName;
@Excel(name = "所属电站名称", width = 20)
private String subName;
@Excel(name = "检测状态", width = 15)
private Integer checkState;
@Excel(name = "检测结果1:合格/0:不合格)", width = 15)
private Integer checkResult;
@Excel(name = "报告状态1生成/0:未生成)", width = 15)
private Integer reportState;
@Excel(name = "归档状态1归档/0:未归档)", width = 15)
private Integer documentState;
@Excel(name = "报告路径", width = 20)
private String reportPath;
@Excel(name = "关键信息二维码", width = 20)
private String qrCode;
@Excel(name = "复检次数", width = 15)
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
private Integer reCheckNum;
}

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.IService; import com.baomidou.mybatisplus.extension.service.IService;
import com.njcn.gather.machine.device.pojo.param.PqDevParam; import com.njcn.gather.machine.device.pojo.param.PqDevParam;
import com.njcn.gather.machine.device.pojo.po.PqDev; import com.njcn.gather.machine.device.pojo.po.PqDev;
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
import java.util.List; import java.util.List;
@@ -44,4 +45,25 @@ public interface IPqDevService extends IService<PqDev> {
* @return 删除成功返回true否则返回false * @return 删除成功返回true否则返回false
*/ */
boolean deletePqDev(List<String> ids); boolean deletePqDev(List<String> ids);
/**
* 下载模板文件
*/
void downloadTemplate();
/**
* 批量导入被检设备信息
*
* @param sgEventExcels
*/
void importPqDevData(List<PqDevExcel> sgEventExcels);
/**
* 导出被检设备信息
*
* @param queryParam 查询参数
*/
void exportPqDevData(PqDevParam.PqDevQueryParam queryParam);
} }

View File

@@ -3,24 +3,27 @@ package com.njcn.gather.machine.device.service.impl;
import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil; 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.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.njcn.common.pojo.enums.common.DataStateEnum; 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.db.mybatisplus.constant.DbConstant;
import com.njcn.gather.machine.device.mapper.PqDevMapper; import com.njcn.gather.machine.device.mapper.PqDevMapper;
import com.njcn.gather.machine.device.pojo.param.PqDevParam; import com.njcn.gather.machine.device.pojo.param.PqDevParam;
import com.njcn.gather.machine.device.pojo.po.PqDev; import com.njcn.gather.machine.device.pojo.po.PqDev;
import com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
import com.njcn.gather.machine.device.service.IPqDevService; import com.njcn.gather.machine.device.service.IPqDevService;
import com.njcn.gather.machine.pojo.enums.MachineResponseEnum; import com.njcn.gather.machine.device.util.DeviceUtil;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
import com.njcn.web.utils.ExcelUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Objects;
/** /**
* @author caozehui * @author caozehui
@@ -36,13 +39,14 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>(); QueryWrapper<PqDev> queryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(queryParam)) { if (ObjectUtil.isNotNull(queryParam)) {
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "pq_dev.name", queryParam.getName()) queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "pq_dev.name", queryParam.getName())
.eq(StrUtil.isNotBlank(queryParam.getDevType()), "pq_dev.dev_type", queryParam.getDevType()); .eq(StrUtil.isNotBlank(queryParam.getDevType()), "pq_dev.dev_type", queryParam.getDevType())
.between(ObjectUtil.isAllNotEmpty(queryParam.getSearchBeginTime(), queryParam.getSearchEndTime()), "pq_dev.CreateDate", queryParam.getSearchBeginTime(), queryParam.getSearchEndTime());
//排序 //排序
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) { if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy())); queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
} else { } else {
//没有排序参数默认根据sort字段排序没有排序字段的根据updateTime更新时间排序 //没有排序参数默认根据sort字段排序没有排序字段的根据updateTime更新时间排序
queryWrapper.orderBy(true, true, "pq_dev.update_time"); queryWrapper.orderBy(true, true, "pq_dev.Create_Time");
} }
} }
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode()); queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
@@ -51,42 +55,79 @@ public class PqDevServiceImpl extends ServiceImpl<PqDevMapper, PqDev> implements
@Override @Override
public boolean addPqDev(PqDevParam pqDevParam) { public boolean addPqDev(PqDevParam pqDevParam) {
checkPqDevName(pqDevParam, false); PqDev pqDev = new PqDev();
PqDev dictPq = new PqDev(); BeanUtil.copyProperties(pqDevParam, pqDev);
BeanUtil.copyProperties(pqDevParam, dictPq); if (Objects.nonNull(pqDev.getSeries())) {
//默认为正常状态 pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
dictPq.setState(DataStateEnum.ENABLE.getCode()); }
return this.save(dictPq); if (Objects.nonNull(pqDev.getDevKey())) {
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
}
//todo 比对式设备处理
pqDev.setState(DataStateEnum.ENABLE.getCode());
return this.save(pqDev);
} }
@Override @Override
public boolean updatePqDev(PqDevParam.PqDevUpdateParam updateParam) { public boolean updatePqDev(PqDevParam.PqDevUpdateParam updateParam) {
return false; PqDev pqDev = new PqDev();
BeanUtil.copyProperties(updateParam, pqDev);
if (Objects.nonNull(pqDev.getSeries())) {
pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
}
if (Objects.nonNull(pqDev.getDevKey())) {
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
}
//todo 比对式设备处理
return this.updateById(pqDev);
} }
@Override @Override
public boolean deletePqDev(List<String> ids) { public boolean deletePqDev(List<String> ids) {
return false; return this.lambdaUpdate()
.set(PqDev::getState, DataStateEnum.DELETED.getCode())
.in(PqDev::getId, ids)
.update();
} }
/** @Override
* 校验参数,检查是否存在相同名称的字典类型 public void downloadTemplate() {
*/ ExcelUtil.exportExcel("被检设备模板.xls", "被检设备", PqDevExcel.class, new ArrayList<>());
private void checkPqDevName(PqDevParam pqDevParam, boolean isExcludeSelf) { }
LambdaQueryWrapper<PqDev> dictDataLambdaQueryWrapper = new LambdaQueryWrapper<>();
dictDataLambdaQueryWrapper @Override
.eq(PqDev::getName, pqDevParam.getName()) public void importPqDevData(List<PqDevExcel> pqDevExcelList) {
.eq(PqDev::getState, DataStateEnum.ENABLE.getCode()); List<PqDev> pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
//更新的时候,需排除当前记录 pqDevList.forEach(pqDev -> {
if (isExcludeSelf) { if (Objects.nonNull(pqDev.getSeries())) {
if (pqDevParam instanceof PqDevParam.PqDevUpdateParam) { pqDev.setSeries(DeviceUtil.encodeString(1, pqDev.getSeries()));
dictDataLambdaQueryWrapper.ne(PqDev::getId, ((PqDevParam.PqDevUpdateParam) pqDevParam).getId()); }
if (Objects.nonNull(pqDev.getDevKey())) {
pqDev.setDevKey(DeviceUtil.encodeString(1, pqDev.getDevKey()));
}
pqDev.setState(DataStateEnum.ENABLE.getCode());
});
this.saveBatch(pqDevList);
}
@Override
public void exportPqDevData(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())
.between(ObjectUtil.isAllNotEmpty(queryParam.getSearchBeginTime(), queryParam.getSearchEndTime()), "pq_dev.CreateDate", queryParam.getSearchBeginTime(), queryParam.getSearchEndTime());
//排序
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
} else {
//没有排序参数默认根据sort字段排序没有排序字段的根据updateTime更新时间排序
queryWrapper.orderBy(true, true, "pq_dev.Create_Time");
} }
} }
int countByAccount = this.count(dictDataLambdaQueryWrapper); queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
//大于等于1个则表示重复 List<PqDev> pqDevs = this.list(queryWrapper);
if (countByAccount >= 1) { List<PqDevExcel> pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.class);
throw new BusinessException(MachineResponseEnum.NAME_REPEAT); ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.class, pqDevExcels);
}
} }
} }

View File

@@ -0,0 +1,62 @@
package com.njcn.gather.machine.device.util;
import com.njcn.common.utils.sm.ThreeDesUtil;
import org.apache.commons.codec.binary.Base64;
/**
* pqs
*
* @author cdf
* @date 2022/1/6
*/
public class DeviceUtil {
/**
* cd 系统配置的解密方式
* content 需要解密的内容
* 解密对应内容
*
* @author cdf
* @date 2021/10/12
*/
public static String decoderString(Integer cd, String content) {
String seriesTmp = null;
if (cd == 0) {
seriesTmp = Base64.decodeBase64(content).toString();
} else if (cd == 1) {
seriesTmp = ThreeDesUtil.decryptThreeDes(content);
} else if (cd == 2) {
//SM4加密密码
// String secretkey = Sm4Utils.globalSecretKey;
// Sm4Utils sm4 = new Sm4Utils(secretkey);
// seriesTmp = sm4.decryptData_ECB(content);
}
return seriesTmp;
}
/**
* cd 系统配置的加密方式
* content 需要加密的内容
* 加密对应内容
*
* @author cdf
* @date 2021/10/12
*/
public static String encodeString(Integer cd, String content) {
String key = null;
if (cd == 0) {
key = Base64.encodeBase64String(content.getBytes());
} else if (cd == 1) {
key = ThreeDesUtil.encryptThreeDes(content);
} else if (cd == 2) {
//SM4加密密码
// String secretkey = Sm4Utils.globalSecretKey;
// Sm4Utils sm4 = new Sm4Utils(secretkey);
// key = sm4.encryptData_ECB(content);
}
return key;
}
}

View File

@@ -26,7 +26,9 @@ public interface MachineValidMessage {
String MANUFACTURER_NOT_BLANK = "生产厂家不能为空请检查manufacturer参数"; String MANUFACTURER_NOT_BLANK = "生产厂家不能为空请检查manufacturer参数";
String PRODUCEDATE_NOT_NULL = "生产日期不能为空请检查producedDate参数"; String CREATEDATETIME_NOT_NULL = "生产日期不能为空请检查producedDate参数";
String CREATEDATETIME_FORMAT_ERROR = "生产日期格式错误请检查createDateTime参数";
String FACTORYNO_NOT_BLANK = "出厂编号不能为空请检查factoryNo参数"; String FACTORYNO_NOT_BLANK = "出厂编号不能为空请检查factoryNo参数";
@@ -34,12 +36,17 @@ public interface MachineValidMessage {
String SOFTWARE_NOT_BLANK = "软件版本不能为空请检查software参数"; String SOFTWARE_NOT_BLANK = "软件版本不能为空请检查software参数";
String PROTOCOL_NOT_BLANK = "通讯协议不能为空请检查protocol参数";
String IP_NOT_BLANK = "IP地址不能为空请检查ip参数"; String IP_NOT_BLANK = "IP地址不能为空请检查ip参数";
String IP_FORMAT_ERROR = "IP地址格式错误请检查ip参数";
String PORT_NOT_NULL = "端口号不能为空请检查port参数"; String PORT_NOT_NULL = "端口号不能为空请检查port参数";
String ENCRYPTION_NOT_NULL = "是否为加密版本不能为空,请检查isEncryption参数"; String ENCRYPTION_NOT_NULL = "是否为加密版本不能为空,请检查encryption参数";
String RECHECK_NUM_NOT_NULL = "复检次数不能为空请检查recheckNum参数"; String RECHECK_NUM_NOT_NULL = "复检次数不能为空请检查reCheckNum参数";
String ARRIVEDATETIME_FORMAT_ERROR = "送样日期格式错误请检查arrivedDateTime参数";
} }

View File

@@ -4,7 +4,9 @@ import lombok.Getter;
@Getter @Getter
public enum MachineResponseEnum { public enum MachineResponseEnum {
NAME_REPEAT("1001", "名称重复"); //NAME_REPEAT("A001001", "名称重复"),
IMPORT_DATA_FAIL("A001002", "导入数据失败");
private final String code; private final String code;

View File

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

View File

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

View File

@@ -13,8 +13,7 @@ import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.db.mybatisplus.constant.DbConstant; import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.gather.system.dictionary.mapper.DictDataMapper; import com.njcn.gather.system.dictionary.mapper.DictDataMapper;
import com.njcn.gather.system.dictionary.pojo.dto.DictDataCache; 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.DictDataExcel;
import com.njcn.gather.system.dictionary.pojo.vo.DictTypeVO;
import com.njcn.gather.system.pojo.enums.SystemResponseEnum; import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
import com.njcn.gather.system.dictionary.pojo.param.DictDataParam; import com.njcn.gather.system.dictionary.pojo.param.DictDataParam;
import com.njcn.gather.system.dictionary.pojo.po.DictData; import com.njcn.gather.system.dictionary.pojo.po.DictData;
@@ -47,7 +46,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
QueryWrapper<DictData> queryWrapper = new QueryWrapper<>(); QueryWrapper<DictData> queryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(queryParam)) { if (ObjectUtil.isNotNull(queryParam)) {
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_data.name", queryParam.getName()) queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_data.name", queryParam.getName())
.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_data.code", queryParam.getCode()); .like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_data.code", queryParam.getCode());
//排序 //排序
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) { if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy())); queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
@@ -100,7 +99,7 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
@Override @Override
public DictData getDicDataByCode(String code) { public DictData getDicDataByCode(String code) {
LambdaQueryWrapper<DictData> queryWrapper = new LambdaQueryWrapper<>(); LambdaQueryWrapper<DictData> queryWrapper = new LambdaQueryWrapper<>();
queryWrapper.eq(DictData::getCode,code) queryWrapper.eq(DictData::getCode, code)
.eq(DictData::getState, DataStateEnum.ENABLE.getCode()); .eq(DictData::getState, DataStateEnum.ENABLE.getCode());
return this.baseMapper.selectOne(queryWrapper); return this.baseMapper.selectOne(queryWrapper);
} }
@@ -110,10 +109,10 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
MPJLambdaWrapper<DictData> dictTypeWrapper = new MPJLambdaWrapper<DictData>() MPJLambdaWrapper<DictData> dictTypeWrapper = new MPJLambdaWrapper<DictData>()
.selectAll(DictData.class) .selectAll(DictData.class)
.selectAs(DictType::getId, DictDataCache::getTypeId) .selectAs(DictType::getId, DictDataCache::getTypeId)
.selectAs(DictType::getName,DictDataCache::getTypeName) .selectAs(DictType::getName, DictDataCache::getTypeName)
.selectAs(DictType::getCode,DictDataCache::getTypeCode) .selectAs(DictType::getCode, DictDataCache::getTypeCode)
.leftJoin(DictType.class, DictType::getId, DictData::getTypeId); .leftJoin(DictType.class, DictType::getId, DictData::getTypeId);
List<DictDataCache> allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class,dictTypeWrapper); List<DictDataCache> allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class, dictTypeWrapper);
Map<Object, List<DictDataCache>> dictDataCacheMap = allDictData.stream() Map<Object, List<DictDataCache>> dictDataCacheMap = allDictData.stream()
.collect(Collectors.groupingBy(DictDataCache::getTypeId)); .collect(Collectors.groupingBy(DictDataCache::getTypeId));
@@ -155,8 +154,8 @@ public class DictDataServiceImpl extends ServiceImpl<DictDataMapper, DictData> i
queryWrapper.ne("sys_dict_data.state", DataStateEnum.DELETED.getCode()) queryWrapper.ne("sys_dict_data.state", DataStateEnum.DELETED.getCode())
.eq("sys_dict_data.type_id", queryParam.getTypeId()); .eq("sys_dict_data.type_id", queryParam.getTypeId());
List<DictData> dictDatas = this.list(queryWrapper); List<DictData> dictDatas = this.list(queryWrapper);
List<DictDataVO> dictDataVOS = BeanUtil.copyToList(dictDatas, DictDataVO.class); List<DictDataExcel> dictDataExcels = BeanUtil.copyToList(dictDatas, DictDataExcel.class);
ExcelUtil.exportExcel("字典数据导出数据.xls", "字典数据", DictDataVO.class, dictDataVOS); ExcelUtil.exportExcel("字典数据导出数据.xlsx", "字典数据", DictDataExcel.class, dictDataExcels);
} }

View File

@@ -13,7 +13,7 @@ import com.njcn.db.mybatisplus.constant.DbConstant;
import com.njcn.gather.system.dictionary.mapper.DictTypeMapper; import com.njcn.gather.system.dictionary.mapper.DictTypeMapper;
import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam; import com.njcn.gather.system.dictionary.pojo.param.DictTypeParam;
import com.njcn.gather.system.dictionary.pojo.po.DictType; import com.njcn.gather.system.dictionary.pojo.po.DictType;
import com.njcn.gather.system.dictionary.pojo.vo.DictTypeVO; import com.njcn.gather.system.dictionary.pojo.vo.DictTypeExcel;
import com.njcn.gather.system.dictionary.service.IDictTypeService; import com.njcn.gather.system.dictionary.service.IDictTypeService;
import com.njcn.gather.system.pojo.enums.SystemResponseEnum; import com.njcn.gather.system.pojo.enums.SystemResponseEnum;
import com.njcn.web.factory.PageFactory; import com.njcn.web.factory.PageFactory;
@@ -21,7 +21,6 @@ import com.njcn.web.utils.ExcelUtil;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.List; import java.util.List;
/** /**
@@ -37,7 +36,7 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
QueryWrapper<DictType> queryWrapper = new QueryWrapper<>(); QueryWrapper<DictType> queryWrapper = new QueryWrapper<>();
if (ObjectUtil.isNotNull(queryParam)) { if (ObjectUtil.isNotNull(queryParam)) {
queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_type.name", queryParam.getName()) queryWrapper.like(StrUtil.isNotBlank(queryParam.getName()), "sys_dict_type.name", queryParam.getName())
.like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_type.code", queryParam.getCode()); .like(StrUtil.isNotBlank(queryParam.getCode()), "sys_dict_type.code", queryParam.getCode());
//排序 //排序
if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) { if (ObjectUtil.isAllNotEmpty(queryParam.getSortBy(), queryParam.getOrderBy())) {
queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy())); queryWrapper.orderBy(true, queryParam.getOrderBy().equals(DbConstant.ASC), StrUtil.toUnderlineCase(queryParam.getSortBy()));
@@ -92,8 +91,8 @@ public class DictTypeServiceImpl extends ServiceImpl<DictTypeMapper, DictType> i
} }
queryWrapper.ne("sys_dict_type.state", DataStateEnum.DELETED.getCode()); queryWrapper.ne("sys_dict_type.state", DataStateEnum.DELETED.getCode());
List<DictType> dictTypes = this.list(queryWrapper); List<DictType> dictTypes = this.list(queryWrapper);
List<DictTypeVO> dictTypeVOS = BeanUtil.copyToList(dictTypes, DictTypeVO.class); List<DictTypeExcel> dictTypeVOS = BeanUtil.copyToList(dictTypes, DictTypeExcel.class);
ExcelUtil.exportExcel("字典类型导出数据.xls", "字典类型", DictTypeVO.class, dictTypeVOS); ExcelUtil.exportExcel("字典类型导出数据.xlsx", "字典类型", DictTypeExcel.class, dictTypeVOS);
} }