1.excel公共导出模板调整,解决下拉框最大字符255问题,才用隐藏表单来设置下拉框

2.解决冀北试运行报告bug部分
3.解决数据完整性,小数点问题
4.终端监测导出模板和导入功能编写,
This commit is contained in:
wr
2024-08-14 11:44:34 +08:00
parent 1ed56bbac1
commit dbf43633ff
15 changed files with 861 additions and 62 deletions

View File

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

View File

@@ -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<List<Node>> nodeAllList();
}

View File

@@ -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<NodeClient> {
@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<List<Node>> nodeAllList() {
log.error("{}异常,降级处理,异常为:{}", "获取全部前置机", throwable.toString());
throw new BusinessException(finalExceptionEnum);
}
};
}
}

View File

@@ -515,7 +515,7 @@ public class LineIntegrityDataServiceImpl extends ServiceImpl<LineIntegrityDataM
//父级完整性匹配
if (CollectionUtil.isNotEmpty(data)){
BigDecimal reduce = data.stream().map(BigDecimal::new).reduce(BigDecimal.ZERO, BigDecimal::add);
double avg = reduce.divide(new BigDecimal(data.size())).doubleValue();
double avg = reduce.divide(new BigDecimal(data.size()),6,RoundingMode.HALF_UP).doubleValue();
lineAdministrationTree.setIntegrityData(DataStatisticsUtil.dataLimits(avg));
} else {
lineAdministrationTree.setIntegrityData(3.14159);

View File

@@ -1233,11 +1233,13 @@ public class ExportModelController extends BaseController {
String reportFileUrl = "";
try {
String fileName = name + formatter.format(currentTime) + ".docx";
if (isUrl) {
reportFileUrl = wordUtil2.getReportFileUrl(rtfPath, name + formatter.format(currentTime) + ".docx",null ,reportmap);
} else {
wordUtil2.getWord(rtfPath, reportmap, fileName,null, response);
if(ObjectUtil.isNotNull(isUrl)){
if (isUrl) {
reportFileUrl = wordUtil2.getReportFileUrl(rtfPath, name + formatter.format(currentTime) + ".docx",null ,reportmap);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportFileUrl, methodDescribe);
}
}
wordUtil2.getWord(rtfPath, reportmap, fileName,null, response);
} catch (Exception e) {
log.error("获取报告发生异常,异常是" + e.getMessage());
}

View File

@@ -488,8 +488,8 @@ public class ExportModelJBController extends BaseController {
String strTime = String.format("%s——%s。",
new String[]{DateUtil.format(startDate, "yyyy年MM月dd日 HH时mm分ss秒"),
DateUtil.format(endDate, "yyyy年MM月dd日 HH时mm分ss秒")});
reportmap.put("$number$", reportNumber); // 报告编号
reportmap.put("$titlePoint$", crmName); // 客户名称
reportmap.put("$number$", StrUtil.isBlank(reportNumber)?"":reportNumber); // 报告编号
reportmap.put("$titlePoint$",StrUtil.isBlank(crmName)?"":crmName); // 客户名称
reportmap.put("$TitleTime$", formatter.format(currentTime)); // 报告生成时间
reportmap.put("$ReportTitle$",
@@ -1503,11 +1503,13 @@ public class ExportModelJBController extends BaseController {
String reportFileUrl = "";
try {
String fileName = name + formatter.format(currentTime) + ".docx";
if (isUrl) {
reportFileUrl = wordUtil2.getReportFileUrl(rtfPath, name + formatter.format(currentTime) + ".docx",tableList, reportmap);
} else {
wordUtil2.getWord(rtfPath, reportmap, fileName,tableList, response);
if(ObjectUtil.isNotNull(isUrl)){
if (isUrl) {
reportFileUrl = wordUtil2.getReportFileUrl(rtfPath, name + formatter.format(currentTime) + ".docx",tableList, reportmap);
return HttpResultUtil.assembleCommonResponseResult(CommonResponseEnum.SUCCESS, reportFileUrl, methodDescribe);
}
}
wordUtil2.getWord(rtfPath, reportmap, fileName,tableList, response);
} catch (Exception e) {
log.error("获取报告发生异常,异常是" + e.getMessage());
}

View File

@@ -416,9 +416,9 @@ public class ReportServiceImpl implements ReportService {
* @return
*/
private List<Float> reflectDataInV(List<RStatDataInharmVDPO> 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);
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -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<Supervisi
List<SupervisionTempDeviceReport> getDeviceList();
SupervisionDevMainReportVO querySurveyDetail(String id);
void downloadDevTemplate();
void importDevData(MultipartFile file, HttpServletResponse response);
}

View File

@@ -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<SupervisionDevMainReportPOMapper, SupervisionDevMainReportPO> 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<Supervisi
SupervisionDevMainReportPO supervisionDevMainReportPO = new SupervisionDevMainReportPO();
BeanUtils.copyProperties(supervisionDevMainReportParam, supervisionDevMainReportPO);
if(Objects.equals(supervisionDevMainReportParam.getSaveOrCheckflag(),"2")){
if(StringUtils.isEmpty(supervisionDevMainReportParam.getId())){
if (Objects.equals(supervisionDevMainReportParam.getSaveOrCheckflag(), "2")) {
if (StringUtils.isEmpty(supervisionDevMainReportParam.getId())) {
//设备校验ip
checkIp(supervisionDevMainReportParam, false);
}else {
} else {
//设备校验ip
checkIp(supervisionDevMainReportParam, true);
@@ -81,10 +102,10 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
}
//设置状态
if(Objects.equals(supervisionDevMainReportParam.getSaveOrCheckflag(),"1")){
if (Objects.equals(supervisionDevMainReportParam.getSaveOrCheckflag(), "1")) {
supervisionDevMainReportPO.setStatus(BpmTaskStatusEnum.WAIT.getStatus());
}else {
} else {
supervisionDevMainReportPO.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
}
@@ -110,7 +131,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
// supervisionTempLineReportService.save(supervisionTempLineReport);
// 发起 BPM 流程
// 如何未提交审则不需要发起 BPM 流程
if(Objects.equals(supervisionDevMainReportParam.getSaveOrCheckflag(),"2")) {
if (Objects.equals(supervisionDevMainReportParam.getSaveOrCheckflag(), "2")) {
Map<String, Object> processInstanceVariables = new HashMap<>();
BpmProcessInstanceCreateReqDTO bpmProcessInstanceCreateReqDTO = new BpmProcessInstanceCreateReqDTO();
bpmProcessInstanceCreateReqDTO.setProcessDefinitionKey(SupervisionKeyEnum.DEVICE_INFO_ADD.getKey());
@@ -129,10 +150,10 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
public String updateDevReport(SupervisionDevMainReportParam.SupervisionDevMainReportParamUpdate supervisionDevMainReportParam) {
SupervisionDevMainReportPO supervisionDevMainReportPO = this.baseMapper.selectById(supervisionDevMainReportParam.getId());
//判断是否有权限操作
InstanceUtil.judgeUserPower(RequestUtil.getUserIndex(),supervisionDevMainReportPO.getCreateBy());
InstanceUtil.judgeUserPower(RequestUtil.getUserIndex(), supervisionDevMainReportPO.getCreateBy());
supervisionDevMainReportParam.setProcessInstanceId(supervisionDevMainReportPO.getProcessInstanceId());
supervisionDevMainReportParam.setHistoryInstanceId(supervisionDevMainReportPO.getHistoryInstanceId());
BeanUtils.copyProperties(supervisionDevMainReportParam,supervisionDevMainReportPO);
BeanUtils.copyProperties(supervisionDevMainReportParam, supervisionDevMainReportPO);
supervisionDevMainReportPO.setStatus(BpmTaskStatusEnum.RUNNING.getStatus());
supervisionDevMainReportPO.setState(DataStateEnum.ENABLE.getCode());
//处理历史流程id列表
@@ -154,8 +175,6 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
}
@Override
public boolean auditDevReport(SupervisionDevMainReportParam.SupervisionDevMainReportParamUpdate supervisionDevMainReportParamUpdate) {
return true;
@@ -183,13 +202,13 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
queryWrapper.eq("supervision_dev_main_report.status", supervisionDevMainReportQuery.getStatus());
}
if (StrUtil.isNotBlank(supervisionDevMainReportQuery.getSearchValue())) {
queryWrapper.and(x->x
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<Supervisi
DateUtil.endOfDay(DateUtil.parse(supervisionDevMainReportQuery.getSearchEndTime())));
queryWrapper.orderByDesc("supervision_dev_main_report.Update_Time");
Page<SupervisionDevMainReportVO> 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<Supervisi
@Override
public void updateProcessStatus(String businessKey, Integer status) {
this.lambdaUpdate().set(SupervisionDevMainReportPO::getStatus,status).eq(SupervisionDevMainReportPO::getId,businessKey).update();
this.lambdaUpdate().set(SupervisionDevMainReportPO::getStatus, status).eq(SupervisionDevMainReportPO::getId, businessKey).update();
}
@Override
@@ -247,7 +266,7 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
.eq(SupervisionDevMainReportPO::getStatus, 2)
.in(CollectionUtil.isNotEmpty(data), SupervisionDevMainReportPO::getOrgId, data)
.list();
if(CollectionUtil.isNotEmpty(list)){
if (CollectionUtil.isNotEmpty(list)) {
List<String> collect = list.stream().map(SupervisionDevMainReportPO::getId).collect(Collectors.toList());
List<SupervisionTempDeviceReport> list1 = supervisionTempDeviceReportService.lambdaQuery().in(SupervisionTempDeviceReport::getId, collect).list();
return list1;
@@ -260,30 +279,362 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
public SupervisionDevMainReportVO querySurveyDetail(String id) {
SupervisionDevMainReportVO supervisionDevMainReportVO = new SupervisionDevMainReportVO();
SupervisionDevMainReportPO byId = this.getById(id);
BeanUtils.copyProperties(byId,supervisionDevMainReportVO);
BeanUtils.copyProperties(byId, supervisionDevMainReportVO);
UserVO userVO = userFeignClient.getUserById(byId.getReporter()).getData();
supervisionDevMainReportVO.setReporter(userVO.getName());
supervisionDevMainReportVO.setOrgName(deptFeignClient.getDeptById(byId.getOrgId()).getData().getName());
SupervisionTempDeviceReport supervisionTempDeviceReport = supervisionTempDeviceReportService.lambdaQuery().eq(SupervisionTempDeviceReport::getId, id).one();
// supervisionTempDeviceReport.setSubstation(lineFeignClient.getSubstationInfo(supervisionTempDeviceReport.getSubstation()).getData().getName());
if(StringUtils.isNotEmpty(supervisionTempDeviceReport.getPowerCompany())){
supervisionTempDeviceReport.setPowerCompany(deptFeignClient.getDeptById(supervisionTempDeviceReport.getPowerCompany()).getData().getName());
if (StringUtils.isNotEmpty(supervisionTempDeviceReport.getPowerCompany())) {
supervisionTempDeviceReport.setPowerCompany(deptFeignClient.getDeptById(supervisionTempDeviceReport.getPowerCompany()).getData().getName());
}
supervisionDevMainReportVO.setSupervisionTempDeviceReport(supervisionTempDeviceReport);
return supervisionDevMainReportVO;
}
@Override
public void downloadDevTemplate() {
ExportParams exportParams = new ExportParams("终端入网检测数据模板(带*字段均是必填,请严格按照模板标准填入数据)", "终端入网检测数据信息");
//所属地市
List<DictData> jiBeiArea = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.JIBEI_AREA.getCode()).getData();
//所属供电公司 RequestUtil.getDeptIndex()
List<DeptDTO> depts = deptFeignClient.getDepSonDetailByDeptId("0d52f9f6e43ec0ee83013cd32da93f66").getData();
//终端型号
List<DictData> devType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_TYPE.getCode()).getData();
//通讯类型
List<DictData> frontType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.FRONT_TYPE.getCode()).getData();
//获取所有前置机
List<Node> nodes = nodeClient.nodeAllList().getData();
//接线方式
List<DictData> devConnect = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_CONNECT.getCode()).getData();
//厂家
List<DictData> devManufacturer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_MANUFACTURER.getCode()).getData();
//电压互感器类型
List<DictData> voltageTransformer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.VOLTAGE_TRANSFORMER.getCode()).getData();
//中性点接线方式
List<DictData> neutralPoint = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.Neutral_Point.getCode()).getData();
List<PullDown> 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<SupervisionDevMainReportExcel> devExcels = new ArrayList<>();
try {
ExcelImportResult<SupervisionDevMainReportExcel> 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<SupervisionDevMainReportExcel.ExcelMsg> devMsgList = new ArrayList<>();
//所属地市
List<DictData> jiBeiArea = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.JIBEI_AREA.getCode()).getData();
//所属供电公司
List<DeptDTO> deptS = deptFeignClient.getDeptDescendantIndexes(RequestUtil.getDeptIndex(), WebUtil.filterDeptType()).getData();
Map<String, String> deptMap = deptS.stream().collect(Collectors.toMap(DeptDTO::getName, DeptDTO::getId, (k1, k2) -> k1));
//终端型号
List<DictData> devType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_TYPE.getCode()).getData();
//通讯类型
List<DictData> frontType = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.FRONT_TYPE.getCode()).getData();
//获取所有前置机
List<Node> nodes = nodeClient.nodeAllList().getData();
Map<String, String> nodeMap = nodes.stream().collect(Collectors.toMap(Node::getName, Node::getId, (k1, k2) -> k1));
//接线方式
List<DictData> devConnect = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_CONNECT.getCode()).getData();
//厂家
List<DictData> devManufacturer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.DEV_MANUFACTURER.getCode()).getData();
//电压互感器类型
List<DictData> voltageTransformer = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.VOLTAGE_TRANSFORMER.getCode()).getData();
//中性点接线方式
List<DictData> neutralPoint = dicDataFeignClient.getDicDataByTypeCode(DicDataTypeEnum.Neutral_Point.getCode()).getData();
SupervisionDevMainReportPO po;
if (CollectionUtil.isNotEmpty(devExcels)) {
for (SupervisionDevMainReportExcel dev : devExcels) {
//todo 需要根据变电站id进行匹配
LambdaQueryWrapper<SupervisionTempDeviceReport> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper
.eq(SupervisionTempDeviceReport::getSubstation, dev.getSubstation())
.eq(SupervisionTempDeviceReport::getTerminalIp, dev.getTerminalIp());
List<SupervisionTempDeviceReport> list = supervisionTempDeviceReportService.getBaseMapper().selectList(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(list)) {
//过滤已取消的申请和删除的
List<String> collect = list.stream().map(SupervisionTempDeviceReport::getId).collect(Collectors.toList());
List<SupervisionDevMainReportPO> 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<SupervisionTempDeviceReport> lambdaQueryWrapper = new LambdaQueryWrapper<>();
lambdaQueryWrapper
@@ -293,12 +644,11 @@ public class SupervisionDevMainReportPOServiceImpl extends ServiceImpl<Supervisi
if (isExcludeSelf) {
if (supervisionDevMainReportParam instanceof SupervisionDevMainReportParam.SupervisionDevMainReportParamUpdate) {
lambdaQueryWrapper.ne(SupervisionTempDeviceReport::getId, ((SupervisionDevMainReportParam.SupervisionDevMainReportParamUpdate) supervisionDevMainReportParam).getId());
}else {
} else {
lambdaQueryWrapper.ne(SupervisionTempDeviceReport::getId, (supervisionDevMainReportParam).getId());
}
}
List<SupervisionTempDeviceReport> list = supervisionTempDeviceReportService.getBaseMapper().selectList(lambdaQueryWrapper);
if (CollectionUtil.isNotEmpty(list)) {

View File

@@ -757,7 +757,7 @@ public class UserReportPOServiceImpl extends ServiceImpl<UserReportPOMapper, Use
// for (String s : indexArr) {
// indexList.add(PubUtil.getDicById(s, problemIndicators));
// }
userReportSensitivePO.setEnergyQualityIndex(userExcel.getEnergyQualityIndex());
userReportSensitivePO.setEnergyQualityIndex(PubUtil.getDicById(userExcel.getEnergyQualityIndex(),problemIndicators));
userReportSensitivePO.setEvaluationType(PubUtil.getDicById(userExcel.getEvaluationType(), evaluationType));
userReportSensitivePO.setAntiInterferenceTest(userExcel.getAntiInterferenceTest() + "");
userReportSensitivePO.setEvaluationChekDept(userExcel.getEvaluationChekDept());

View File

@@ -137,7 +137,7 @@ public enum DicDataTypeEnum {
LOAD_LEVEL("负荷级别","load_level"),
SUPPLY_CONDITION("供电电源情况","supply_condition"),
JIBEI_AREA("供电电源情况","jibei_area"),
JIBEI_AREA("所属地市","jibei_area"),
Major_Nonlinear_Device("主要非线性设备类型","Major_Nonlinear_Device"),
EVALUATION_DEPT("主要非线性设备类型","evaluation_dept"),
EVALUATION_TYPE("评估类型","Evaluation_Type"),