From dbf43633ff6d004997d113b49440cfd8a358c58f Mon Sep 17 00:00:00 2001 From: wr <1754607820@qq.com> Date: Wed, 14 Aug 2024 11:44:34 +0800 Subject: [PATCH] =?UTF-8?q?1.excel=E5=85=AC=E5=85=B1=E5=AF=BC=E5=87=BA?= =?UTF-8?q?=E6=A8=A1=E6=9D=BF=E8=B0=83=E6=95=B4,=E8=A7=A3=E5=86=B3?= =?UTF-8?q?=E4=B8=8B=E6=8B=89=E6=A1=86=E6=9C=80=E5=A4=A7=E5=AD=97=E7=AC=A6?= =?UTF-8?q?255=E9=97=AE=E9=A2=98=EF=BC=8C=E6=89=8D=E7=94=A8=E9=9A=90?= =?UTF-8?q?=E8=97=8F=E8=A1=A8=E5=8D=95=E6=9D=A5=E8=AE=BE=E7=BD=AE=E4=B8=8B?= =?UTF-8?q?=E6=8B=89=E6=A1=86=202.=E8=A7=A3=E5=86=B3=E5=86=80=E5=8C=97?= =?UTF-8?q?=E8=AF=95=E8=BF=90=E8=A1=8C=E6=8A=A5=E5=91=8Abug=E9=83=A8?= =?UTF-8?q?=E5=88=86=203.=E8=A7=A3=E5=86=B3=E6=95=B0=E6=8D=AE=E5=AE=8C?= =?UTF-8?q?=E6=95=B4=E6=80=A7=EF=BC=8C=E5=B0=8F=E6=95=B0=E7=82=B9=E9=97=AE?= =?UTF-8?q?=E9=A2=98=204.=E7=BB=88=E7=AB=AF=E7=9B=91=E6=B5=8B=E5=AF=BC?= =?UTF-8?q?=E5=87=BA=E6=A8=A1=E6=9D=BF=E5=92=8C=E5=AF=BC=E5=85=A5=E5=8A=9F?= =?UTF-8?q?=E8=83=BD=E7=BC=96=E5=86=99,?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/njcn/poi/excel/ExcelUtil.java | 107 ++++- .../com/njcn/device/pq/api/NodeClient.java | 26 ++ .../fallback/NodeClientFallbackFactory.java | 46 ++ .../impl/LineIntegrityDataServiceImpl.java | 2 +- .../controller/ExportModelController.java | 10 +- .../controller/ExportModelJBController.java | 14 +- .../service/impl/ReportServiceImpl.java | 8 +- .../enums/SupervisionResponseEnum.java | 1 + .../dto/SupervisionDevMainReportExcel.java | 257 +++++++++++ .../po/device/SupervisionDevMainReportPO.java | 8 + .../device/DeVReportManageController.java | 23 +- .../SupervisionDevMainReportPOService.java | 7 +- ...SupervisionDevMainReportPOServiceImpl.java | 410 ++++++++++++++++-- .../user/impl/UserReportPOServiceImpl.java | 2 +- .../njcn/system/enums/DicDataTypeEnum.java | 2 +- 15 files changed, 861 insertions(+), 62 deletions(-) create mode 100644 pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/NodeClient.java create mode 100644 pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/NodeClientFallbackFactory.java create mode 100644 pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionDevMainReportExcel.java diff --git a/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java b/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java index 7c91a82dd..e39475a70 100644 --- a/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java +++ b/pqs-common/common-poi/src/main/java/com/njcn/poi/excel/ExcelUtil.java @@ -4,6 +4,7 @@ import cn.afterturn.easypoi.excel.ExcelExportUtil; import cn.afterturn.easypoi.excel.entity.ExportParams; import cn.afterturn.easypoi.excel.export.ExcelExportService; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.util.CharsetUtil; import com.njcn.web.utils.HttpServletUtil; import lombok.extern.slf4j.Slf4j; @@ -11,9 +12,8 @@ import org.apache.poi.hssf.usermodel.DVConstraint; import org.apache.poi.hssf.usermodel.HSSFDataValidation; import org.apache.poi.ss.usermodel.*; import org.apache.poi.ss.util.CellRangeAddressList; -import org.apache.poi.xssf.usermodel.XSSFDataValidation; -import org.apache.poi.xssf.usermodel.XSSFDataValidationConstraint; -import org.apache.poi.xssf.usermodel.XSSFRichTextString; +import org.apache.poi.ss.util.CellReference; +import org.apache.poi.xssf.usermodel.*; import javax.servlet.ServletOutputStream; import javax.servlet.http.HttpServletResponse; @@ -21,10 +21,9 @@ import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import java.net.URLEncoder; -import java.util.Collection; -import java.util.List; -import java.util.Objects; +import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** * @author hongawen @@ -80,7 +79,7 @@ public class ExcelUtil { * * @param fileName 文件名 */ - public static void exportExcelByWorkbook(String fileName, Workbook workbook) { + public static void exportExcelByWorkbook(String fileName, Workbook workbook) { HttpServletResponse response = HttpServletUtil.getResponse(); try (ServletOutputStream outputStream = response.getOutputStream()) { fileName = URLEncoder.encode(fileName, CharsetUtil.UTF_8); @@ -116,9 +115,18 @@ public class ExcelUtil { response.setHeader("Content-Disposition", "attachment;filename=" + fileName); response.setContentType("application/octet-stream;charset=UTF-8"); Workbook workbook = ExcelExportUtil.exportExcel(exportParams, pojoClass, dataSet); + setTopLevel(workbook, pullDowns); if (CollUtil.isNotEmpty(pullDowns)) { + int num = 1; for (PullDown pullDown : pullDowns) { - ExcelUtil.selectList(workbook, pullDown.getFirstCol(), pullDown.getLastCol(), pullDown.getStrings().toArray(new String[]{})); + String colName = numberToExcelColumn(num); + int sum = pullDown.getStrings().stream().mapToInt(String::length).sum(); + if(sum>255){ + ExcelUtil.selectListMaxLength(workbook, pullDown.getFirstCol(), pullDown.getLastCol(),pullDown.getStrings().size(),colName); + num++; + }else{ + ExcelUtil.selectList(workbook, pullDown.getFirstCol(), pullDown.getLastCol(), pullDown.getStrings().toArray(new String[]{})); + } } } Sheet sheetAt = workbook.getSheetAt(0); @@ -128,7 +136,7 @@ public class ExcelUtil { for (int i = 0; i < 2; i++) { //获取行 Row row = sheetAt.getRow(i); - if(Objects.isNull(row)){ + if (Objects.isNull(row)) { continue; } for (int j = 0; j < physicalNumberOfCells; j++) { @@ -173,6 +181,8 @@ public class ExcelUtil { } } } + + workbook.write(outputStream); } catch (IOException e) { log.error(">>> 导出数据异常:{}", e.getMessage()); @@ -238,7 +248,27 @@ public class ExcelUtil { // 对sheet页生效 sheet.addValidationData(validation); } - + /** + * @Description: 当下拉框超过最大字符255,设置隐藏表单来进行展示 + * @param workbook + * @param firstCol + * @param lastCol + * @param colName 列A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q,R,S,T,U,V,W,X,Y,Z + * @Author: wr + * @Date: 2024/8/13 15:07 + */ + public static void selectListMaxLength(Workbook workbook,int firstCol, int lastCol,int row ,String colName) { + Sheet sheet = workbook.getSheetAt(0); + // 生成下拉列表 + // 设置数据有效性加载在哪个单元格上,四个参数分别是:起始行、终止行、起始列、终止列 + CellRangeAddressList regions = new CellRangeAddressList(2, 65535, firstCol, lastCol); + String strFormula = workbook.getSheetName(1) + "!$" + colName + "$1:$" + colName + "$" + row; + XSSFDataValidationConstraint hiddentConstraint = new XSSFDataValidationConstraint(DataValidationConstraint.ValidationType.LIST, strFormula); + // 数据有效性对象 + DataValidationHelper help = new XSSFDataValidationHelper((XSSFSheet) sheet); + DataValidation validation = help.createValidation(hiddentConstraint, regions); + sheet.addValidationData(validation); + } /** * 指定名称、数据下载报表(带指定标题将*显示比必填信息),带有下拉信息 @@ -265,7 +295,7 @@ public class ExcelUtil { for (int i = 0; i < 2; i++) { //获取行 Row row = sheetAt.getRow(i); - if(Objects.isNull(row)){ + if (Objects.isNull(row)) { continue; } for (int j = 0; j < physicalNumberOfCells; j++) { @@ -340,5 +370,60 @@ public class ExcelUtil { sheet.addValidationData(validation); } + /** + * 设置隐藏表单来进行下拉框 + * @param workbook + * @param pullDowns + */ + private static void setTopLevel(Workbook workbook, List pullDowns) { + int num = 0; + for (PullDown pullDown : pullDowns) { + int sum = pullDown.getStrings().stream().mapToInt(String::length).sum(); + if (sum > 255) { + // 创建隐藏sheet + String hiddenSheetName = "hiddenSheetA"; + if (num == 0) { + workbook.createSheet(hiddenSheetName); + } + //false展示隐藏sheet ,true不展示隐藏sheet + workbook.setSheetHidden(workbook.getSheetIndex(workbook.getSheet(hiddenSheetName)), true); + Sheet sheet = workbook.getSheet(hiddenSheetName); + if(num == 0){ + //sheet.getLastRowNum无法区分 有一行和没有 所以这里先建一行 + sheet.createRow(0); + } + Row row; //创建数据行 + sheet.setColumnWidth(num, 4000); //设置每列的列宽 + for (int j = 0; j < pullDown.getStrings().size(); j++) { + if (sheet.getLastRowNum() < j) { + row = sheet.createRow(j); //创建数据行 + } else { + row = sheet.getRow(j); + } + //设置对应单元格的值 + row.createCell(num).setCellValue(pullDown.getStrings().get(j)); + } + num++; + } + } + } + + /** + * 获取根据数值获取列字母(1=A,2=B,3=C,.......,27=AA) + * + * @param n + * @return + */ + public static String numberToExcelColumn(int n) { + CellReference cellRef = new CellReference(0, n - 1, false, false); // Row and column are 0-based + int colIndex = cellRef.getCol(); + StringBuilder columnName = new StringBuilder(); + while (colIndex >= 0) { + columnName.insert(0, (char) ('A' + (colIndex % 26))); + colIndex /= 26; + colIndex--; + } + return columnName.toString(); + } } diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/NodeClient.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/NodeClient.java new file mode 100644 index 000000000..052b99035 --- /dev/null +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/NodeClient.java @@ -0,0 +1,26 @@ +package com.njcn.device.pq.api; + +import com.njcn.common.pojo.constant.ServerInfo; +import com.njcn.common.pojo.response.HttpResult; +import com.njcn.device.pq.api.fallback.PqsTerminalLogsClientFallbackFactory; +import com.njcn.device.pq.pojo.po.Node; +import io.swagger.annotations.ApiOperation; +import org.springframework.cloud.openfeign.FeignClient; +import org.springframework.web.bind.annotation.GetMapping; + +import java.util.List; + +/** + * @Description: + * @Author: wr + * @Date: 2024/8/13 10:14 + */ +@FeignClient(value = ServerInfo.DEVICE, path = "/node", fallbackFactory = PqsTerminalLogsClientFallbackFactory.class, contextId = "node") +public interface NodeClient { + + + @ApiOperation("获取全部前置机") + @GetMapping("/nodeAllList") + HttpResult> nodeAllList(); + +} diff --git a/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/NodeClientFallbackFactory.java b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/NodeClientFallbackFactory.java new file mode 100644 index 000000000..a8ec10467 --- /dev/null +++ b/pqs-device/pq-device/pq-device-api/src/main/java/com/njcn/device/pq/api/fallback/NodeClientFallbackFactory.java @@ -0,0 +1,46 @@ +package com.njcn.device.pq.api.fallback; + +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.device.biz.utils.DeviceEnumUtil; +import com.njcn.device.pq.api.NodeClient; +import com.njcn.device.pq.api.PqsTerminalLogsClient; +import com.njcn.device.pq.pojo.po.Node; +import com.njcn.device.pq.pojo.po.PqsTerminalLogs; +import feign.hystrix.FallbackFactory; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Component; + +import java.util.List; + +/** + * @author zbj + * @version 1.0.0 + * @date 2023年04月13日 13:34 + */ +@Slf4j +@Component +public class NodeClientFallbackFactory implements FallbackFactory { + @Override + public NodeClient create(Throwable throwable) { + //判断抛出异常是否为解码器抛出的业务异常 + Enum exceptionEnum = CommonResponseEnum.SERVICE_FALLBACK; + if (throwable.getCause() instanceof BusinessException) { + BusinessException businessException = (BusinessException) throwable.getCause(); + exceptionEnum = DeviceEnumUtil.getExceptionEnum(businessException.getResult()); + } + Enum finalExceptionEnum = exceptionEnum; + return new NodeClient() + { + + @Override + public HttpResult> nodeAllList() { + log.error("{}异常,降级处理,异常为:{}", "获取全部前置机", throwable.toString()); + throw new BusinessException(finalExceptionEnum); + } + }; + + + } +} diff --git a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineIntegrityDataServiceImpl.java b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineIntegrityDataServiceImpl.java index fa5f380fb..7c0fc4534 100644 --- a/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineIntegrityDataServiceImpl.java +++ b/pqs-device/pq-device/pq-device-boot/src/main/java/com/njcn/device/pq/service/impl/LineIntegrityDataServiceImpl.java @@ -515,7 +515,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl reflectDataInV(List value, String name, String attribute) { - Field field = null; + Field field; try { - field = RStatDataVD.class.getDeclaredField(attribute); + field = RStatDataInharmVDPO.class.getDeclaredField(attribute); } catch (NoSuchFieldException e) { throw new RuntimeException(e); } @@ -426,9 +426,9 @@ public class ReportServiceImpl implements ReportService { Field finalField = field; return value.stream().filter(x -> x.getValueType().equals(name)).map(temp -> { - BigDecimal o = null; + Double o; try { - o = (BigDecimal) finalField.get(temp); + o = (Double) finalField.get(temp); } catch (IllegalAccessException e) { throw new RuntimeException(e); } diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java index c00afa80d..e25392a7b 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/enums/SupervisionResponseEnum.java @@ -23,6 +23,7 @@ public enum SupervisionResponseEnum { NO_POWER("A00550","不能操作非自己创建的任务!"), NO_USER_REPORT_UPDATE("A00550","常态化干扰源用户管理信息更新失败,不存在该条信息"), NO_DEPT_POWER("A00550","不能操作非自己部门创建的任务"), + IMPORT_DEV_ERROR("A00550","导入终端检测失败"), ; private final String code; diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionDevMainReportExcel.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionDevMainReportExcel.java new file mode 100644 index 000000000..ce2e503b4 --- /dev/null +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/dto/SupervisionDevMainReportExcel.java @@ -0,0 +1,257 @@ +package com.njcn.supervision.pojo.dto; + +import cn.afterturn.easypoi.excel.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; +import lombok.AllArgsConstructor; +import lombok.Data; +import lombok.EqualsAndHashCode; +import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; + +import javax.validation.constraints.NotBlank; +import java.io.Serializable; +import java.time.LocalDate; +import java.time.LocalDateTime; + +/** + * Description: + * Date: 2024/5/10 18:16【需求编号】 + * + * @author clam + * @version V1.0.0 + */ +@Data +@AllArgsConstructor +@NoArgsConstructor +public class SupervisionDevMainReportExcel { + + + + /** + * 工程预期投产日期 + */ + @Excel(name = "*工程预期投产日期", width = 30) + @NotBlank(message = "不能为空") + @DateTimeFormat(pattern = "yyyy-MM-dd") + private LocalDate expectedProductionDate; + + /** + * 所属地市 + */ + @Excel(name = "*所属地市", width = 30) + @NotBlank(message = "所属地市不能为空") + private String city; + + + //------------------------基本信息--------------------------------------------- + + /** + * 并网变电站 + */ + @Excel(name = "*所属变电站名称", width = 30) + @NotBlank(message = "所属变电站名称不能为空") + private String substation; + + /** + * 所属供电公司 + */ + @Excel(name = "*所属供电公司", width = 30) + @NotBlank(message = "所属供电公司不能为空") + private String powerCompany; + + /** + * 终端型号 + */ + @Excel(name = "*终端型号", width = 30) + @NotBlank(message = "终端型号不能为空") + private String terminalType; + + + /** + * 监测终端名称 + */ + @Excel(name = "*终端名称", width = 30) + @NotBlank(message = "终端名称不能为空") + private String monitoringTerminalName; + + + /** + * 通讯类型 + */ + @Excel(name = "*通讯类型", width = 30) + @NotBlank(message = "通讯类型不能为空") + private String frontType; + + /** + * 监测终端编码 + */ + @Excel(name = "*监测终端编码", width = 30) + @NotBlank(message = "监测终端编码不能为空") + private String monitoringTerminalCode; + + /** + * 终端IP + */ + @Excel(name = "*终端IP", width = 30) + @NotBlank(message = "*终端IP不能为空") + private String terminalIp; + + + /** + * 端口 + */ + @Excel(name = "*端口", width = 30) + @NotBlank(message = "*端口不能为空") + private String terminalPort; + + /** + * 投运时间 + */ + @Excel(name = "*投运时间", width = 30) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @NotBlank(message = "投运时间不能为空") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime commissioningTime; + + /** + * 数据更新时间 + */ + @Excel(name = "数据更新时间", width = 30) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime dataUpdateTime; + + /** + * 所属前置机 + */ + @Excel(name = "*所属前置机", width = 30) + @NotBlank(message = "所属前置机不能为空") + private String frontEndMachine; + + /** + * 监测终端安装位置 + */ + @Excel(name = "*监测终端安装位置", width = 30, replace = {"电网侧_0", "用户侧_1", "_0"}) + @NotBlank(message = "监测终端安装位置不能为空") + private String monitoringDeviceInstallationPosition; + + /** + * 识别码 + */ + @Excel(name = "识别码", width = 30) + private String identificationCode; + + /** + * 终端秘钥 + */ + @Excel(name = "终端秘钥", width = 30) + private String terminalSecretKey; + + /** + * 终端模型 + */ + @Excel(name = "终端模型", width = 30, replace = {"虚拟终端_0", "实际终端_1", "离线_2", "_1"}) + private String terminalModel; + + /** + * 数据类型 + */ + @Excel(name = "数据类型", width = 30, replace = {"暂态系统_0", "稳态系统_1", "两个系统_2", "_2"}) + private String dataType; + + /** + * 终端接线方式类型 + */ + @Excel(name = "*终端接线方式类型", width = 30) + @NotBlank(message = "终端接线方式类型不能为空") + private String terminalWiringMethodType; + + /** + * 厂家 + */ + @Excel(name = "*厂家", width = 30) + @NotBlank(message = "厂家不能为空") + private String manufacturer; + + + /** + * 本次终端检测时间 + */ + @Excel(name = "*本次终端检测时间", width = 30) + @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") + @NotBlank(message = "本次终端检测时间不能为空") + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") + private LocalDateTime currentTerminalDetectionTime; + + + /** + * 电压互感器类型 + */ + @Excel(name = "*电压互感器类型", width = 30) + @NotBlank(message = "*电压互感器类型不能为空") + private String voltageTransformerType; + + + /** + * 中性点接线方式 + */ + @Excel(name = "*中性点接线方式", width = 30) + @NotBlank(message = "中性点接线方式不能为空") + private String neutralPointWiringMethod; + + + /** + * 厂家终端编号 + */ + @Excel(name = "*厂家终端编号", width = 30) + @NotBlank(message = "厂家终端编号不能为空") + private String manufacturerDeviceNumber; + + + /** + * SIM卡号 + */ + @Excel(name = "SIM卡号", width = 30) + @NotBlank(message = "不能为空") + private String simCardNumber; + + /** + * 对时功能 + */ + @Excel(name = "对时功能", width = 30, replace = {"关闭_0", "开启_1", "_0"}) + private String timeSyncFunction; + + /** + * 电镀功能 + */ + @Excel(name = "电镀功能", width = 30, replace = {"关闭_0", "开启_1", "_0"}) + private String electroplatingFunction; + + + /** + * 召换标志 + */ + @Excel(name = "召换标志", width = 30, replace = {"周期触发_0", "变位触发_1", "_0"}) + private String summonFlag; + + /** + * 告警功能 + */ + @Excel(name = "告警功能", width = 30, replace = {"否_0", "是_1", "_0"}) + private String alarmFunction; + + /** + * 合同号 + */ + @Excel(name = "合同号", width = 30) + private String contractNumber; + + @Data + @EqualsAndHashCode(callSuper = true) + public static class ExcelMsg extends SupervisionDevMainReportExcel implements Serializable { + + @Excel(name = "错误信息描述", width = 30) + private String msg; + + } +} diff --git a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionDevMainReportPO.java b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionDevMainReportPO.java index fb0ead5de..e109584ac 100644 --- a/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionDevMainReportPO.java +++ b/pqs-supervision/supervision-api/src/main/java/com/njcn/supervision/pojo/po/device/SupervisionDevMainReportPO.java @@ -8,6 +8,7 @@ import com.njcn.db.bo.BaseEntity; import lombok.AllArgsConstructor; import lombok.Data; import lombok.NoArgsConstructor; +import org.springframework.format.annotation.DateTimeFormat; import java.time.LocalDate; @@ -51,6 +52,7 @@ public class SupervisionDevMainReportPO extends BaseEntity { * 工程预期投产日期 */ @TableField(value = "expected_production_date") + @DateTimeFormat(pattern = "yyyy-MM-dd") private LocalDate expectedProductionDate; /** @@ -152,4 +154,10 @@ public class SupervisionDevMainReportPO extends BaseEntity { */ @TableField(value = "`State`") private Integer state; + + /** + * 状态:0:系统建档 1:外部导入 + */ + @TableField(value = "`import_type`") + private Integer importType; } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/DeVReportManageController.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/DeVReportManageController.java index 1c51b892b..e240a671c 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/DeVReportManageController.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/controller/device/DeVReportManageController.java @@ -13,17 +13,18 @@ import com.njcn.supervision.pojo.po.device.SupervisionTempDeviceReport; import com.njcn.supervision.pojo.vo.device.SupervisionDevMainReportVO; import com.njcn.supervision.service.device.SupervisionDevMainReportPOService; import com.njcn.web.controller.BaseController; -import com.njcn.web.utils.RequestUtil; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiOperation; -import io.swagger.v3.oas.annotations.Operation; +import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; import lombok.extern.slf4j.Slf4j; +import org.springframework.http.MediaType; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; +import org.springframework.web.multipart.MultipartFile; -import javax.validation.Valid; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -138,4 +139,20 @@ public class DeVReportManageController extends BaseController { } + @OperateInfo(info = LogEnum.BUSINESS_COMMON) + @GetMapping(value = "/downloadDevTemplate", produces = MediaType.APPLICATION_OCTET_STREAM_VALUE) + @ApiOperation("下载终端台账入网模板") + public void downloadDevTemplate() { + supervisionDevMainReportPOService.downloadDevTemplate(); + } + + + @PostMapping(value = "/importSensitiveUserData") + @ApiOperation("批量导入终端台账入网") + @OperateInfo(info = LogEnum.BUSINESS_COMMON, operateType = OperateType.ADD) + public HttpResult importDevrData(@ApiParam(value = "文件", required = true) @RequestPart("file") MultipartFile file, HttpServletResponse response) { + String methodDescribe = getMethodDescribe("importDevData"); + supervisionDevMainReportPOService.importDevData(file, response); + return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, null, methodDescribe); + } } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/SupervisionDevMainReportPOService.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/SupervisionDevMainReportPOService.java index bad5a3d22..48a6e8550 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/SupervisionDevMainReportPOService.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/SupervisionDevMainReportPOService.java @@ -1,14 +1,15 @@ package com.njcn.supervision.service.device; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; -import com.baomidou.mybatisplus.extension.service.IService; import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam; import com.njcn.bpm.service.IBpmService; import com.njcn.supervision.pojo.param.device.SupervisionDevMainReportParam; import com.njcn.supervision.pojo.po.device.SupervisionDevMainReportPO; import com.njcn.supervision.pojo.po.device.SupervisionTempDeviceReport; import com.njcn.supervision.pojo.vo.device.SupervisionDevMainReportVO; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; import java.util.List; /** @@ -38,4 +39,8 @@ public interface SupervisionDevMainReportPOService extends IBpmService getDeviceList(); SupervisionDevMainReportVO querySurveyDetail(String id); + + void downloadDevTemplate(); + + void importDevData(MultipartFile file, HttpServletResponse response); } diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java index 49bc1ea95..8e1e9647a 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/device/impl/SupervisionDevMainReportPOServiceImpl.java @@ -1,5 +1,9 @@ package com.njcn.supervision.service.device.impl; +import cn.afterturn.easypoi.excel.ExcelImportUtil; +import cn.afterturn.easypoi.excel.entity.ExportParams; +import cn.afterturn.easypoi.excel.entity.ImportParams; +import cn.afterturn.easypoi.excel.entity.result.ExcelImportResult; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.text.StrPool; @@ -16,10 +20,19 @@ import com.njcn.bpm.pojo.dto.BpmProcessInstanceCreateReqDTO; import com.njcn.bpm.pojo.param.instance.BpmProcessInstanceCancelParam; import com.njcn.common.pojo.enums.common.DataStateEnum; import com.njcn.common.pojo.exception.BusinessException; +import com.njcn.device.pms.utils.PubUtil; import com.njcn.device.pq.api.LineFeignClient; +import com.njcn.device.pq.api.NodeClient; +import com.njcn.device.pq.pojo.po.Node; +import com.njcn.poi.excel.ExcelUtil; +import com.njcn.poi.excel.PullDown; +import com.njcn.poi.util.PoiUtil; import com.njcn.supervision.enums.FlowStatusEnum; import com.njcn.supervision.enums.SupervisionKeyEnum; +import com.njcn.supervision.enums.SupervisionResponseEnum; import com.njcn.supervision.mapper.device.SupervisionDevMainReportPOMapper; +import com.njcn.supervision.pojo.dto.SensitiveUserSExcel; +import com.njcn.supervision.pojo.dto.SupervisionDevMainReportExcel; import com.njcn.supervision.pojo.param.device.SupervisionDevMainReportParam; import com.njcn.supervision.pojo.param.device.SupervisionTempDeviceReportParam; import com.njcn.supervision.pojo.po.device.SupervisionDevMainReportPO; @@ -28,22 +41,30 @@ import com.njcn.supervision.pojo.vo.device.SupervisionDevMainReportVO; import com.njcn.supervision.service.device.SupervisionDevMainReportPOService; import com.njcn.supervision.service.device.SupervisionTempDeviceReportService; import com.njcn.supervision.utils.InstanceUtil; +import com.njcn.system.api.DicDataFeignClient; +import com.njcn.system.enums.DicDataTypeEnum; +import com.njcn.system.pojo.po.DictData; import com.njcn.user.api.DeptFeignClient; import com.njcn.user.api.UserFeignClient; +import com.njcn.user.pojo.dto.DeptDTO; import com.njcn.user.pojo.vo.UserVO; import com.njcn.web.factory.PageFactory; import com.njcn.web.utils.RequestUtil; +import com.njcn.web.utils.WebUtil; import lombok.RequiredArgsConstructor; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.BeanUtils; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletResponse; +import java.time.LocalDate; import java.util.*; import java.util.stream.Collectors; +import java.util.stream.Stream; /** - * * Description: * Date: 2024/5/10 18:10【需求编号】 * @@ -55,12 +76,13 @@ import java.util.stream.Collectors; public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl implements SupervisionDevMainReportPOService { - private final BpmProcessFeignClient bpmProcessFeignClient; private final SupervisionTempDeviceReportService supervisionTempDeviceReportService; private final DeptFeignClient deptFeignClient; private final UserFeignClient userFeignClient; private final LineFeignClient lineFeignClient; + private final DicDataFeignClient dicDataFeignClient; + private final NodeClient nodeClient; @Override @Transactional(rollbackFor = Exception.class) @@ -68,12 +90,11 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl processInstanceVariables = new HashMap<>(); BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO(); bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.DEVICE_INFO_ADD.getKey()); @@ -129,10 +150,10 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImplx + queryWrapper.and(x -> x .like("dev.substation_name", supervisionDevMainReportQuery.getSearchValue()) .or() .like("dev.monitoring_terminal_code", supervisionDevMainReportQuery.getSearchValue()) .or() .like("dev.monitoring_terminal_name", supervisionDevMainReportQuery.getSearchValue()) - ); + ); } //添加上时间范围 queryWrapper.between("supervision_dev_main_report.Create_Time", @@ -197,7 +216,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl page = this.baseMapper.page(new Page<>(PageFactory.getPageNum(supervisionDevMainReportQuery), PageFactory.getPageSize(supervisionDevMainReportQuery)), queryWrapper); - page.getRecords().stream().forEach(temp->{ + page.getRecords().stream().forEach(temp -> { // temp.setOrgName((deptFeignClient.getDeptById(temp.getOrgId()).getData().getName())); //处理特殊字段,用户名、部门名 UserVO userVO = userFeignClient.getUserById(temp.getReporter()).getData(); @@ -209,7 +228,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl collect = list.stream().map(SupervisionDevMainReportPO::getId).collect(Collectors.toList()); List list1 = supervisionTempDeviceReportService.lambdaQuery().in(SupervisionTempDeviceReport::getId, collect).list(); return list1; @@ -260,30 +279,362 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl jiBeiArea = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.JIBEI_AREA.getCode()).getData(); + //所属供电公司 RequestUtil.getDeptIndex() + List depts = deptFeignClient.getDepSonDetailByDeptId("0d52f9f6e43ec0ee83013cd32da93f66").getData(); + //终端型号 + List devType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_TYPE.getCode()).getData(); + //通讯类型 + List frontType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.FRONT_TYPE.getCode()).getData(); + //获取所有前置机 + List nodes = nodeClient.nodeAllList().getData(); + + //接线方式 + List devConnect = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_CONNECT.getCode()).getData(); + //厂家 + List devManufacturer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_MANUFACTURER.getCode()).getData(); + //电压互感器类型 + List voltageTransformer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.VOLTAGE_TRANSFORMER.getCode()).getData(); + //中性点接线方式 + List neutralPoint = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.Neutral_Point.getCode()).getData(); + + + List pullDowns = new ArrayList<>(); + + PullDown pullDown; + pullDown = new PullDown(); + pullDown.setFirstCol(1); + pullDown.setLastCol(1); + pullDown.setStrings(jiBeiArea.stream().map(DictData::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + //缺少变电站名称 +// pullDown = new PullDown(); +// pullDown.setFirstCol(2); +// pullDown.setLastCol(2); +// pullDown.setStrings(); +// pullDowns.add(pullDown); + + pullDown = new PullDown(); + pullDown.setFirstCol(3); + pullDown.setLastCol(3); + pullDown.setStrings(depts.stream().map(DeptDTO::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + pullDown = new PullDown(); + pullDown.setFirstCol(4); + pullDown.setLastCol(4); + pullDown.setStrings(devType.stream().map(DictData::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + + pullDown = new PullDown(); + pullDown.setFirstCol(6); + pullDown.setLastCol(6); + pullDown.setStrings(frontType.stream().filter(x -> "CLD".equals(x.getCode()) || "61850".equals(x.getCode())).map(DictData::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + pullDown = new PullDown(); + pullDown.setFirstCol(12); + pullDown.setLastCol(12); + pullDown.setStrings(nodes.stream().map(Node::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + //监测终端安装位置 0:电网侧 1:用户侧 + pullDown = new PullDown(); + pullDown.setFirstCol(13); + pullDown.setLastCol(13); + pullDown.setStrings(Stream.of("电网侧", "用户侧").collect(Collectors.toList())); + pullDowns.add(pullDown); + + //终端模型 0:虚拟终端 1:实际终端 2:离线 + pullDown = new PullDown(); + pullDown.setFirstCol(16); + pullDown.setLastCol(16); + pullDown.setStrings(Stream.of("实际终端", "虚拟终端", "离线").collect(Collectors.toList())); + pullDowns.add(pullDown); + + //数据类型 0:暂态系统 1:稳态系统 2:两个系统 + pullDown = new PullDown(); + pullDown.setFirstCol(17); + pullDown.setLastCol(17); + pullDown.setStrings(Stream.of("两个系统", "暂态系统", "稳态系统").collect(Collectors.toList())); + pullDowns.add(pullDown); + + pullDown = new PullDown(); + pullDown.setFirstCol(18); + pullDown.setLastCol(18); + pullDown.setStrings(devConnect.stream().map(DictData::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + + pullDown = new PullDown(); + pullDown.setFirstCol(19); + pullDown.setLastCol(19); + pullDown.setStrings(devManufacturer.stream().map(DictData::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + + pullDown = new PullDown(); + pullDown.setFirstCol(21); + pullDown.setLastCol(21); + pullDown.setStrings(voltageTransformer.stream().map(DictData::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + pullDown = new PullDown(); + pullDown.setFirstCol(22); + pullDown.setLastCol(22); + pullDown.setStrings(neutralPoint.stream().map(DictData::getName).distinct().collect(Collectors.toList())); + pullDowns.add(pullDown); + + + pullDown = new PullDown(); + pullDown.setFirstCol(25); + pullDown.setLastCol(25); + pullDown.setStrings(Stream.of("关闭", "开启").collect(Collectors.toList())); + pullDowns.add(pullDown); + + pullDown = new PullDown(); + pullDown.setFirstCol(26); + pullDown.setLastCol(26); + pullDown.setStrings(Stream.of("关闭", "开启").collect(Collectors.toList())); + pullDowns.add(pullDown); + + //召唤标志 0:周期触发 1:变位触发 + pullDown = new PullDown(); + pullDown.setFirstCol(27); + pullDown.setLastCol(27); + pullDown.setStrings(Stream.of("周期触发", "变位触发").collect(Collectors.toList())); + pullDowns.add(pullDown); + + + pullDown = new PullDown(); + pullDown.setFirstCol(28); + pullDown.setLastCol(28); + pullDown.setStrings(Stream.of("否", "是").collect(Collectors.toList())); + pullDowns.add(pullDown); + + ExcelUtil.exportExcelPullDown(exportParams, "终端入网检测数据模板.xlsx", pullDowns, SupervisionDevMainReportExcel.class, new ArrayList<>()); + + } + + @Override + public void importDevData(MultipartFile file, HttpServletResponse response) { + ImportParams params = new ImportParams(); + params.setHeadRows(1);//表头 + params.setTitleRows(1);//标题 + params.setNeedVerify(true); + params.setStartSheetIndex(0); + params.setSheetNum(1); + List devExcels = new ArrayList<>(); + try { + ExcelImportResult sensitiveUserExcelExcelImportResult = ExcelImportUtil.importExcelMore(file.getInputStream(), SensitiveUserSExcel.class, params); + //如果存在非法数据,将不合格的数据导出 + if (sensitiveUserExcelExcelImportResult.isVerifyFail()) { + PoiUtil.exportFileByWorkbook(sensitiveUserExcelExcelImportResult.getFailWorkbook(), "非法数据.xlsx", response); + } else { + devExcels = sensitiveUserExcelExcelImportResult.getList(); + } + } catch (Exception e) { + throw new BusinessException(SupervisionResponseEnum.IMPORT_DEV_ERROR); + } + List devMsgList = new ArrayList<>(); + //所属地市 + List jiBeiArea = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.JIBEI_AREA.getCode()).getData(); + + //所属供电公司 + List deptS = deptFeignClient.getDeptDescendantIndexes(RequestUtil.getDeptIndex(), WebUtil.filterDeptType()).getData(); + Map deptMap = deptS.stream().collect(Collectors.toMap(DeptDTO::getName, DeptDTO::getId, (k1, k2) -> k1)); + + //终端型号 + List devType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_TYPE.getCode()).getData(); + //通讯类型 + List frontType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.FRONT_TYPE.getCode()).getData(); + //获取所有前置机 + List nodes = nodeClient.nodeAllList().getData(); + Map nodeMap = nodes.stream().collect(Collectors.toMap(Node::getName, Node::getId, (k1, k2) -> k1)); + + //接线方式 + List devConnect = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_CONNECT.getCode()).getData(); + + //厂家 + List devManufacturer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_MANUFACTURER.getCode()).getData(); + //电压互感器类型 + List voltageTransformer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.VOLTAGE_TRANSFORMER.getCode()).getData(); + //中性点接线方式 + List neutralPoint = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.Neutral_Point.getCode()).getData(); + + SupervisionDevMainReportPO po; + if (CollectionUtil.isNotEmpty(devExcels)) { + for (SupervisionDevMainReportExcel dev : devExcels) { + //todo 需要根据变电站id进行匹配 + LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); + lambdaQueryWrapper + .eq(SupervisionTempDeviceReport::getSubstation, dev.getSubstation()) + .eq(SupervisionTempDeviceReport::getTerminalIp, dev.getTerminalIp()); + List list = supervisionTempDeviceReportService.getBaseMapper().selectList(lambdaQueryWrapper); + if (CollectionUtil.isNotEmpty(list)) { + //过滤已取消的申请和删除的 + List collect = list.stream().map(SupervisionTempDeviceReport::getId).collect(Collectors.toList()); + List list1 = this.lambdaQuery().in(SupervisionDevMainReportPO::getId, collect).list(); + list1 = list1.stream() + .filter(userReportPO -> !userReportPO.getStatus().equals(FlowStatusEnum.CANCEL.getCode())) + .filter(userReportPO -> userReportPO.getState().equals(DataStateEnum.ENABLE.getCode())) + .collect(Collectors.toList()); + //如果还存在,则说明有人申请过了 + if (CollectionUtil.isNotEmpty(list1)) { + //该用户已经录入 + SupervisionDevMainReportExcel.ExcelMsg sensitiveUserExcelMsg = new SupervisionDevMainReportExcel.ExcelMsg(); + BeanUtils.copyProperties(dev, sensitiveUserExcelMsg); + sensitiveUserExcelMsg.setMsg(dev.getTerminalIp().concat("Ip已占用")); + devMsgList.add(sensitiveUserExcelMsg); + continue; + } + } + //基础报告信息 + po = new SupervisionDevMainReportPO(); + po.setReporter(RequestUtil.getUserIndex()); + po.setReportDate(LocalDate.now()); + po.setOrgId(RequestUtil.getDeptIndex()); + po.setExpectedProductionDate(dev.getExpectedProductionDate()); + po.setCity(PubUtil.getDicById(dev.getCity(), jiBeiArea)); + po.setUserStatus("1"); +// po.setAcceptanceInspectionReport(); +// po.setAcceptanceInspectionReportSingle(); +// po.setTypeExperimentReport(); +// po.setFactoryInspectionReport(); +// po.setPerformanceTestReport(); +// po.setInformationSecurityTestReport(); +// po.setOtherAttachments(); + po.setImportType(1); + po.setStatus(2); + po.setState(DataStateEnum.ENABLE.getCode()); + this.save(po); + //终端基础信息 + StringBuilder msg = new StringBuilder(); + SupervisionTempDeviceReport devDetails = new SupervisionTempDeviceReport(); + devDetails.setId(po.getId()); + if(deptMap.containsKey(dev.getPowerCompany())){ + devDetails.setPowerCompany(deptMap.get(dev.getPowerCompany())); + }else{ + msg.append("所属供电公司不存在!"); + } + //todo 需要根据变电站id进行匹配 +// devDetails.setCustomSubstationFlag(); +// devDetails.setSubstation(); +// devDetails.setSubstationName(); +// devDetails.setSubstationVoltageLevel(); +// devDetails.setLongitude(); +// devDetails.setLatitude(); + + devDetails.setMonitoringTerminalCode(dev.getMonitoringTerminalName()); + devDetails.setMonitoringTerminalName(dev.getMonitoringTerminalName()); + String dy = PubUtil.getDicById(dev.getVoltageTransformerType(), voltageTransformer); + if(StrUtil.isNotBlank(dy)){ + devDetails.setVoltageTransformerType(dy); + }else{ + msg.append("电压互感器类型不存在!"); + } + String jx = PubUtil.getDicById(dev.getTerminalWiringMethodType(), devConnect); + if(StrUtil.isNotBlank(jx)){ + devDetails.setTerminalWiringMethodType(jx); + }else{ + msg.append("终端接线方式类型不存在!"); + } + String zx = PubUtil.getDicById(dev.getNeutralPointWiringMethod(), neutralPoint); + if(StrUtil.isNotBlank(zx)){ + devDetails.setNeutralPointWiringMethod(zx); + }else{ + msg.append("中性点接线方式不存在!"); + } + String cj = PubUtil.getDicById(dev.getManufacturer(), devManufacturer); + if(StrUtil.isNotBlank(cj)){ + devDetails.setManufacturer(cj); + }else{ + msg.append("厂家不存在!"); + } + devDetails.setManufacturerDeviceNumber(dev.getManufacturerDeviceNumber()); + devDetails.setTerminalIp(dev.getTerminalIp()); + + String xh = PubUtil.getDicById(dev.getTerminalType(), devType); + if(StrUtil.isNotBlank(xh)){ + devDetails.setTerminalType(xh); + }else{ + msg.append("终端型号不存在!"); + } + devDetails.setTerminalPort(dev.getTerminalPort()); + if(nodeMap.containsKey(dev.getFrontEndMachine())){ + devDetails.setFrontEndMachine(nodeMap.get(dev.getFrontEndMachine())); + }else{ + msg.append("所属前置机不存在!"); + } + devDetails.setCurrentTerminalDetectionTime(dev.getCurrentTerminalDetectionTime()); + devDetails.setNextTerminalInspectionTime(dev.getCurrentTerminalDetectionTime().plusYears(5)); + devDetails.setIdentificationCode(dev.getIdentificationCode()); + devDetails.setTerminalSecretKey(dev.getTerminalSecretKey()); + devDetails.setTerminalModel(dev.getTerminalModel()); + devDetails.setDataType(dev.getDataType()); + devDetails.setCommunicationStatus("0"); + devDetails.setSimCardNumber(dev.getSimCardNumber()); + devDetails.setCommissioningTime(dev.getCommissioningTime()); + devDetails.setDataUpdateTime(dev.getDataUpdateTime()); + devDetails.setTimeSyncFunction(Integer.parseInt(dev.getTimeSyncFunction())); + devDetails.setElectroplatingFunction(Integer.parseInt(dev.getElectroplatingFunction())); + devDetails.setMonitoringDeviceInstallationPosition(dev.getMonitoringDeviceInstallationPosition()); + devDetails.setSummonFlag(dev.getSummonFlag()); + devDetails.setAlarmFunction(dev.getAlarmFunction()); + devDetails.setContractNumber(dev.getContractNumber()); + String tx = PubUtil.getDicById(dev.getFrontType(), frontType); + if(StrUtil.isNotBlank(tx)){ + devDetails.setFrontType(tx); + }else{ + msg.append("通讯类型不存在!"); + } + String string = msg.toString(); + if(StrUtil.isNotBlank(string)){ + SupervisionDevMainReportExcel.ExcelMsg sensitiveUserExcelMsg = new SupervisionDevMainReportExcel.ExcelMsg(); + BeanUtils.copyProperties(dev, sensitiveUserExcelMsg); + sensitiveUserExcelMsg.setMsg(string); + devMsgList.add(sensitiveUserExcelMsg); + continue; + } + supervisionTempDeviceReportService.saveOrUpdate(devDetails); + } + } + //判断有没有错误信息 + if (CollectionUtil.isNotEmpty(devMsgList)) { + ExcelUtil.exportExcel("失败列表.xlsx", SupervisionDevMainReportExcel.ExcelMsg.class, devMsgList); + } + } + /** - * @Description: 判断设备ip是否重复,如果重复提示 - * @Param: supervisionDevMainReportParam终端详情 isExcludeSelf是否排除自己,一般新增不排除,更新时需要排除自己 - * @return: void - * @Author: clam - * @Date: 2024/5/11 - */ + * @Description: 判断设备ip是否重复,如果重复提示 + * @Param: supervisionDevMainReportParam终端详情 isExcludeSelf是否排除自己,一般新增不排除,更新时需要排除自己 + * @return: void + * @Author: clam + * @Date: 2024/5/11 + */ private void checkIp(SupervisionDevMainReportParam supervisionDevMainReportParam, boolean isExcludeSelf) { //如果保存不填ip则不校验 - if(!StringUtils.isEmpty(supervisionDevMainReportParam.getSupervisionTempDeviceReportParam().getTerminalIp())) { + if (!StringUtils.isEmpty(supervisionDevMainReportParam.getSupervisionTempDeviceReportParam().getTerminalIp())) { LambdaQueryWrapper lambdaQueryWrapper = new LambdaQueryWrapper<>(); lambdaQueryWrapper @@ -293,12 +644,11 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl list = supervisionTempDeviceReportService.getBaseMapper().selectList(lambdaQueryWrapper); if (CollectionUtil.isNotEmpty(list)) { diff --git a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java index 3e93665b4..a02619c3b 100644 --- a/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java +++ b/pqs-supervision/supervision-boot/src/main/java/com/njcn/supervision/service/user/impl/UserReportPOServiceImpl.java @@ -757,7 +757,7 @@ public class UserReportPOServiceImpl extends ServiceImpl