diff --git a/entrance/pom.xml b/entrance/pom.xml
index 4aba6278..40de7324 100644
--- a/entrance/pom.xml
+++ b/entrance/pom.xml
@@ -16,6 +16,11 @@
system
1.0.0
+
+ com.njcn.gather
+ machine
+ 1.0.0
+
diff --git a/entrance/src/main/resources/application.yml b/entrance/src/main/resources/application.yml
index b65e0c11..e62fef4a 100644
--- a/entrance/src/main/resources/application.yml
+++ b/entrance/src/main/resources/application.yml
@@ -28,7 +28,7 @@ spring:
mybatis-plus:
mapper-locations: classpath*:com/njcn/**/mapping/*.xml
#别名扫描
- type-aliases-package: com.njcn.gather.system.dictionary.pojo.po
+ type-aliases-package: com.njcn.gather.system.dictionary.pojo.po,com.njcn.gather.machine.pojo.po
configuration:
#驼峰命名
map-underscore-to-camel-case: true
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
index 1f9a0a9f..3cb735ea 100644
--- 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
@@ -1,28 +1,35 @@
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 com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.njcn.common.pojo.annotation.OperateInfo;
import com.njcn.common.pojo.constant.OperateType;
+import com.njcn.common.pojo.enums.common.LogEnum;
import com.njcn.common.pojo.enums.response.CommonResponseEnum;
+import com.njcn.common.pojo.exception.BusinessException;
import com.njcn.common.pojo.response.HttpResult;
import com.njcn.common.utils.LogUtil;
import com.njcn.gather.machine.device.pojo.param.PqDevParam;
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.pojo.enums.MachineResponseEnum;
import com.njcn.web.controller.BaseController;
import com.njcn.web.utils.HttpResultUtil;
+import com.njcn.web.utils.PoiUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.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 org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+import javax.servlet.http.HttpServletResponse;
import java.util.List;
@@ -94,5 +101,48 @@ public class PqDevController extends BaseController {
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 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 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 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);
+ }
+}
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
index 79b3ac42..110d184d 100644
--- 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
@@ -1,8 +1,8 @@
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.annotation.DateTimeStrValid;
import com.njcn.web.pojo.param.BaseParam;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
@@ -11,7 +11,6 @@ import lombok.EqualsAndHashCode;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;
-import java.time.LocalDateTime;
/**
* @author caozehui
@@ -20,63 +19,68 @@ import java.time.LocalDateTime;
@Data
public class PqDevParam {
- @ApiModelProperty("名称")
+ @ApiModelProperty(value = "名称", required = true)
@NotBlank(message = MachineValidMessage.NAME_NOT_BLANK)
@Pattern(regexp = PatternRegex.DEV_NAME_REGEX, message = MachineValidMessage.NAME_FORMAT_ERROR)
private String name;
- @ApiModelProperty("设备模式,字典表(数字、模拟、比对)")
+ @ApiModelProperty(value = "设备模式,字典表(数字、模拟、比对)", required = true)
@NotBlank(message = MachineValidMessage.PATTERN_NOT_BLANK)
private String pattern;
- @ApiModelProperty("设备类型,字典表")
+ @ApiModelProperty(value = "设备类型,字典表", required = true)
@NotBlank(message = MachineValidMessage.DEV_TYPE_NOT_BLANK)
private String devType;
- @ApiModelProperty("设备通道数")
+ @ApiModelProperty(value = "设备通道数", required = true)
@NotNull(message = MachineValidMessage.DEV_CHNS_NOT_NULL)
private Integer devChns;
- @ApiModelProperty("额定电压(V)")
+ @ApiModelProperty(value = "额定电压(V)", required = true)
@NotNull(message = MachineValidMessage.DEV_VOLT_NOT_NULL)
private Float devVolt;
- @ApiModelProperty("额定电流(A)")
+ @ApiModelProperty(value = "额定电流(A)", required = true)
@NotNull(message = MachineValidMessage.DEV_CURR_NOT_NULL)
private Float devCurr;
- @ApiModelProperty("生产厂家,字典表")
+ @ApiModelProperty(value = "生产厂家,字典表", required = true)
@NotBlank(message = MachineValidMessage.MANUFACTURER_NOT_BLANK)
private String manufacturer;
- @ApiModelProperty("生产日期")
- @NotNull(message = MachineValidMessage.PRODUCEDATE_NOT_NULL)
- private LocalDateTime createdate;
+ @ApiModelProperty(value = "生产日期", required = true)
+ @NotBlank(message = MachineValidMessage.CREATEDATETIME_NOT_NULL)
+ @DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.CREATEDATETIME_FORMAT_ERROR)
+ private String createDate;
- @ApiModelProperty("出厂编号")
+ @ApiModelProperty(value = "出厂编号", required = true)
@NotBlank(message = MachineValidMessage.FACTORYNO_NOT_BLANK)
- private String createid;
+ private String createId;
- @ApiModelProperty("固件版本")
+ @ApiModelProperty(value = "固件版本", required = true)
@NotBlank(message = MachineValidMessage.FIRMWARE_NOT_BLANK)
private String hardwareVersion;
- @ApiModelProperty("软件版本")
+ @ApiModelProperty(value = "软件版本", required = true)
@NotBlank(message = MachineValidMessage.SOFTWARE_NOT_BLANK)
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)
+ @Pattern(regexp = PatternRegex.IP_REGEX, message = MachineValidMessage.IP_FORMAT_ERROR)
private String ip;
- @ApiModelProperty("端口号")
+ @ApiModelProperty(value = "端口号", required = true)
@NotNull(message = MachineValidMessage.PORT_NOT_NULL)
private Integer port;
- @ApiModelProperty("装置是否为加密版本")
+ @ApiModelProperty(value = "装置是否为加密版本", required = true)
@NotNull(message = MachineValidMessage.ENCRYPTION_NOT_NULL)
- @TableField(value = "is_encryption")
- private Integer encryption;;
+ private Integer encryption;
@ApiModelProperty("装置识别码(3ds加密)")
private String series;
@@ -85,10 +89,11 @@ public class PqDevParam {
private String devKey;
@ApiModelProperty("样品编号")
- private String sampleid;
+ private String sampleId;
- @ApiModelProperty("送样日期")
- private LocalDateTime arrivedDate;
+ @ApiModelProperty(value = "送样日期", required = false)
+ @DateTimeStrValid(format = "yyyy-MM-dd", message = MachineValidMessage.ARRIVEDATETIME_FORMAT_ERROR)
+ private String arrivedDate;
@ApiModelProperty("所属地市名称")
private String cityName;
@@ -117,9 +122,9 @@ public class PqDevParam {
@ApiModelProperty("设备关键信息二维码")
private String qrCode;
- @ApiModelProperty("复检次数,默认为0")
+ @ApiModelProperty(value = "复检次数,默认为0", required = true)
@NotNull(message = MachineValidMessage.RECHECK_NUM_NOT_NULL)
- private Integer recheckNum;
+ private Integer reCheckNum;
/**
@@ -148,11 +153,5 @@ public class PqDevParam {
@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
index 81f7e3a5..7738eb28 100644
--- 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
@@ -1,13 +1,19 @@
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.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateDeserializer;
+import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer;
import com.njcn.db.mybatisplus.bo.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import java.io.Serializable;
-import java.time.LocalDateTime;
+import java.time.LocalDate;
/**
* @author caozehui
@@ -16,7 +22,7 @@ import java.time.LocalDateTime;
@Data
@EqualsAndHashCode(callSuper = true)
@TableName("pq_dev")
-public class PqDev extends BaseEntity implements Serializable{
+public class PqDev extends BaseEntity implements Serializable {
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;
+ /**
+ * 通讯协议,字典表(MMS、PODIF)
+ */
+ private String protocol;
+
/**
* IP地址
*/
@@ -92,7 +108,7 @@ public class PqDev extends BaseEntity implements Serializable{
/**
* 装置是否为加密版本
*/
- @TableField("is_encryption")
+ @TableField("IsEncryption")
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
*/
- private Integer recheckNum;
+ @TableField(value = "ReCheck_Num")
+ private Integer reCheckNum;
/**
* 状态:0-删除 1-正常
diff --git a/machine/src/main/java/com/njcn/gather/machine/device/pojo/vo/PqDevExcel.java b/machine/src/main/java/com/njcn/gather/machine/device/pojo/vo/PqDevExcel.java
new file mode 100644
index 00000000..e66c36fa
--- /dev/null
+++ b/machine/src/main/java/com/njcn/gather/machine/device/pojo/vo/PqDevExcel.java
@@ -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;
+}
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
index 14018777..ac3be5d2 100644
--- 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
@@ -4,6 +4,7 @@ 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 com.njcn.gather.machine.device.pojo.vo.PqDevExcel;
import java.util.List;
@@ -44,4 +45,25 @@ public interface IPqDevService extends IService {
* @return 删除成功返回true,否则返回false
*/
boolean deletePqDev(List ids);
+
+ /**
+ * 下载模板文件
+ */
+ void downloadTemplate();
+
+ /**
+ * 批量导入被检设备信息
+ *
+ * @param sgEventExcels
+ */
+ void importPqDevData(List sgEventExcels);
+
+ /**
+ * 导出被检设备信息
+ *
+ * @param queryParam 查询参数
+ */
+ void exportPqDevData(PqDevParam.PqDevQueryParam queryParam);
+
+
}
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
index e05ed335..3cd7ce78 100644
--- 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
@@ -3,24 +3,27 @@ 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.pojo.vo.PqDevExcel;
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.utils.ExcelUtil;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.ObjectUtils;
import org.springframework.stereotype.Service;
+import java.util.ArrayList;
import java.util.List;
+import java.util.Objects;
/**
* @author caozehui
@@ -36,13 +39,14 @@ public class PqDevServiceImpl extends ServiceImpl implements
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());
+ .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.update_time");
+ queryWrapper.orderBy(true, true, "pq_dev.Create_Time");
}
}
queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
@@ -51,42 +55,79 @@ public class PqDevServiceImpl extends ServiceImpl implements
@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);
+ PqDev pqDev = new PqDev();
+ BeanUtil.copyProperties(pqDevParam, 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 比对式设备处理
+ pqDev.setState(DataStateEnum.ENABLE.getCode());
+ return this.save(pqDev);
}
@Override
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
public boolean deletePqDev(List ids) {
- return false;
+ return this.lambdaUpdate()
+ .set(PqDev::getState, DataStateEnum.DELETED.getCode())
+ .in(PqDev::getId, ids)
+ .update();
}
- /**
- * 校验参数,检查是否存在相同名称的字典类型
- */
- 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());
+ @Override
+ public void downloadTemplate() {
+ ExcelUtil.exportExcel("被检设备模板.xls", "被检设备", PqDevExcel.class, new ArrayList<>());
+ }
+
+ @Override
+ public void importPqDevData(List pqDevExcelList) {
+ List pqDevList = BeanUtil.copyToList(pqDevExcelList, PqDev.class);
+ pqDevList.forEach(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()));
+ }
+ pqDev.setState(DataStateEnum.ENABLE.getCode());
+ });
+ this.saveBatch(pqDevList);
+ }
+
+ @Override
+ public void exportPqDevData(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())
+ .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);
- //大于等于1个则表示重复
- if (countByAccount >= 1) {
- throw new BusinessException(MachineResponseEnum.NAME_REPEAT);
- }
+ queryWrapper.eq("pq_dev.state", DataStateEnum.ENABLE.getCode());
+ List pqDevs = this.list(queryWrapper);
+ List pqDevExcels = BeanUtil.copyToList(pqDevs, PqDevExcel.class);
+ ExcelUtil.exportExcel("被检设备导出数据.xlsx", "被检设备", PqDevExcel.class, pqDevExcels);
}
}
diff --git a/machine/src/main/java/com/njcn/gather/machine/device/util/DeviceUtil.java b/machine/src/main/java/com/njcn/gather/machine/device/util/DeviceUtil.java
new file mode 100644
index 00000000..e7401a8e
--- /dev/null
+++ b/machine/src/main/java/com/njcn/gather/machine/device/util/DeviceUtil.java
@@ -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;
+ }
+
+}
+
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
index 7d8e9a67..4da3e90b 100644
--- 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
@@ -26,7 +26,9 @@ public interface MachineValidMessage {
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参数";
@@ -34,12 +36,17 @@ public interface MachineValidMessage {
String SOFTWARE_NOT_BLANK = "软件版本不能为空,请检查software参数";
+ String PROTOCOL_NOT_BLANK = "通讯协议不能为空,请检查protocol参数";
+
String IP_NOT_BLANK = "IP地址不能为空,请检查ip参数";
+ String IP_FORMAT_ERROR = "IP地址格式错误,请检查ip参数";
+
String PORT_NOT_NULL = "端口号不能为空,请检查port参数";
- String ENCRYPTION_NOT_NULL = "是否为加密版本不能为空,请检查isEncryption参数";
+ String ENCRYPTION_NOT_NULL = "是否为加密版本不能为空,请检查encryption参数";
- String RECHECK_NUM_NOT_NULL = "复检次数不能为空,请检查recheckNum参数";
+ String RECHECK_NUM_NOT_NULL = "复检次数不能为空,请检查reCheckNum参数";
+ String ARRIVEDATETIME_FORMAT_ERROR = "送样日期格式错误,请检查arrivedDateTime参数";
}
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
index 39e1939a..be07e6ff 100644
--- 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
@@ -4,7 +4,9 @@ import lombok.Getter;
@Getter
public enum MachineResponseEnum {
- NAME_REPEAT("1001", "名称重复");
+ //NAME_REPEAT("A001001", "名称重复"),
+
+ IMPORT_DATA_FAIL("A001002", "导入数据失败");
private final String code;
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/DictDataExcel.java
similarity index 69%
rename from system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictDataVO.java
rename to system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictDataExcel.java
index 8ab698b1..567ff8b2 100644
--- 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/DictDataExcel.java
@@ -11,84 +11,84 @@ import java.time.LocalDateTime;
* @data 2024/11/6
*/
@Data
-public class DictDataVO implements Serializable {
+public class DictDataExcel implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 字典数据表Id
*/
- @Excel(name = "字典数据表Id")
+ @Excel(name = "字典数据id", width = 40)
private String id;
/**
* 字典类型表Id
*/
- @Excel(name = "字典类型表Id")
+ @Excel(name = "字典类型id", width = 40)
private String typeId;
/**
* 名称
*/
- @Excel(name = "名称")
+ @Excel(name = "名称", width = 20)
private String name;
/**
* 编码
*/
- @Excel(name = "编码")
+ @Excel(name = "编码", width = 20)
private String code;
/**
* 排序
*/
- @Excel(name = "排序")
+ @Excel(name = "排序", width = 15)
private Integer sort;
/**
* 事件等级:0-普通;1-中等;2-严重(默认为0)
*/
- @Excel(name = "事件等级")
+ @Excel(name = "事件等级", width = 15)
private Integer level;
/**
* 与高级算法内部Id描述对应;
*/
- @Excel(name = "与高级算法内部Id描述对应")
+ @Excel(name = "高级算法内部id", width = 15)
private Integer algoDescribe;
/**
* 目前只用于表示电压等级数值
*/
- @Excel(name = "数值")
+ @Excel(name = "数值", width = 15)
private String value;
/**
* 状态:0-删除 1-正常
*/
- @Excel(name = "状态")
- private Integer state;
+// @Excel(name = "状态", width = 15)
+// private Integer state;
/**
* 创建人
*/
- @Excel(name = "创建人")
+ @Excel(name = "创建人", width = 40)
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;
/**
* 更新人
*/
- @Excel(name = "更新人")
+ @Excel(name = "更新人", width = 40)
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;
}
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/DictTypeExcel.java
similarity index 71%
rename from system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictTypeVO.java
rename to system/src/main/java/com/njcn/gather/system/dictionary/pojo/vo/DictTypeExcel.java
index 687669bb..692cfad3 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/DictTypeExcel.java
@@ -12,78 +12,78 @@ import java.time.LocalDateTime;
* @date 2024/11/5
*/
@Data
-public class DictTypeVO implements Serializable {
+public class DictTypeExcel implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 字典类型表Id
*/
- @Excel(name = "Id")
+ @Excel(name = "id", width = 40)
private String id;
/**
* 名称
*/
- @Excel(name = "名称")
+ @Excel(name = "名称", width = 20)
private String name;
/**
* 编码
*/
- @Excel(name = "编码")
+ @Excel(name = "编码", width = 20)
private String code;
/**
* 排序
*/
- @Excel(name = "排序")
+ @Excel(name = "排序", width = 15)
private Integer sort;
/**
* 开启等级:0-不开启;1-开启,默认不开启
*/
- @Excel(name = "开启等级")
+ @Excel(name = "开启等级", width = 15)
private Integer openLevel;
/**
* 开启描述:0-不开启;1-开启,默认不开启
*/
- @Excel(name = "开启描述")
+ @Excel(name = "开启描述", width = 15)
private Integer openDescribe;
/**
* 描述
*/
- @Excel(name = "描述")
+ @Excel(name = "描述", width = 50)
private String remark;
/**
* 状态:0-删除 1-正常
*/
- @Excel(name = "状态")
- private Integer state;
+// @Excel(name = "状态", width = 15)
+// private Integer state;
/**
* 创建人
*/
- @Excel(name = "创建人")
+ @Excel(name = "创建人", width = 40)
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;
/**
* 更新人
*/
- @Excel(name = "更新人")
+ @Excel(name = "更新人", width = 40)
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;
}
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 dc3f2818..3bd8e5f3 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,8 +13,7 @@ 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.dictionary.pojo.vo.DictDataExcel;
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;
@@ -47,7 +46,7 @@ public class DictDataServiceImpl extends ServiceImpl i
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());
+ .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()));
@@ -100,7 +99,7 @@ public class DictDataServiceImpl extends ServiceImpl i
@Override
public DictData getDicDataByCode(String code) {
LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>();
- queryWrapper.eq(DictData::getCode,code)
+ queryWrapper.eq(DictData::getCode, code)
.eq(DictData::getState, DataStateEnum.ENABLE.getCode());
return this.baseMapper.selectOne(queryWrapper);
}
@@ -110,10 +109,10 @@ public class DictDataServiceImpl extends ServiceImpl i
MPJLambdaWrapper dictTypeWrapper = new MPJLambdaWrapper()
.selectAll(DictData.class)
.selectAs(DictType::getId, DictDataCache::getTypeId)
- .selectAs(DictType::getName,DictDataCache::getTypeName)
- .selectAs(DictType::getCode,DictDataCache::getTypeCode)
+ .selectAs(DictType::getName, DictDataCache::getTypeName)
+ .selectAs(DictType::getCode, DictDataCache::getTypeCode)
.leftJoin(DictType.class, DictType::getId, DictData::getTypeId);
- List allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class,dictTypeWrapper);
+ List allDictData = this.getBaseMapper().selectJoinList(DictDataCache.class, dictTypeWrapper);
Map