From 2e8641d7710bf48474cb80b744f370497caf08c8 Mon Sep 17 00:00:00 2001 From: lishuai Date: Thu, 26 Sep 2024 17:52:31 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BC=98=E5=8C=96=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=B8=85=E9=99=A4=E5=8A=9F=E8=83=BD=202024=E5=B9=B49=E6=9C=882?= =?UTF-8?q?6=E6=97=A516:26:43?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../reissue/service/impl/DataReissueServiceImpl.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/modules/thing/src/main/java/com/thing/reissue/service/impl/DataReissueServiceImpl.java b/modules/thing/src/main/java/com/thing/reissue/service/impl/DataReissueServiceImpl.java index b38dfa1..41d4a67 100644 --- a/modules/thing/src/main/java/com/thing/reissue/service/impl/DataReissueServiceImpl.java +++ b/modules/thing/src/main/java/com/thing/reissue/service/impl/DataReissueServiceImpl.java @@ -173,7 +173,11 @@ public class DataReissueServiceImpl extends BaseServiceImpl params = new HashMap(); params.put("entityType", deviceId.getEntityType().name()); @@ -185,11 +189,9 @@ public class DataReissueServiceImpl extends BaseServiceImpl Date: Fri, 27 Sep 2024 09:34:30 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E7=89=A9=E8=AE=A1=E7=AE=97=E6=97=A5?= =?UTF-8?q?=E5=BF=97=E5=AF=BC=E5=87=BA=E5=86=85=E5=AE=B9=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../thing/calculation/excel/CalcLogExcel.java | 34 +++++++++++-------- .../service/impl/CalcLogServiceImpl.java | 18 +++++++--- 2 files changed, 34 insertions(+), 18 deletions(-) diff --git a/modules/calculation/src/main/java/com/thing/calculation/excel/CalcLogExcel.java b/modules/calculation/src/main/java/com/thing/calculation/excel/CalcLogExcel.java index 3aa5407..3026d42 100644 --- a/modules/calculation/src/main/java/com/thing/calculation/excel/CalcLogExcel.java +++ b/modules/calculation/src/main/java/com/thing/calculation/excel/CalcLogExcel.java @@ -3,19 +3,14 @@ package com.thing.calculation.excel; import cn.afterturn.easypoi.excel.annotation.Excel; import com.thing.calculation.dto.CalcLogDTO; -import com.thing.calculation.dto.CalcSourceConfigDTO; -import com.thing.calculation.dto.CalcTargetConfigDTO; -import com.thing.calculation.enumeration.CalcConfigType; +import com.thing.calculation.enumeration.CalcConfigType; import com.thing.common.core.utils.ConvertUtils; import com.thing.common.core.utils.DateTimeUtils; import lombok.Data; -import java.util.ArrayList; -import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.function.Function; import java.util.stream.Collectors; /** @@ -27,10 +22,10 @@ public class CalcLogExcel { @Excel(name = "计算类型", orderNum = "1") private String calcType; - @Excel(name = "结果物名称", orderNum = "2", width = 18) + @Excel(name = "结果物名称", orderNum = "2", width = 25) private String targetThingName; - @Excel(name = "结果物编码", orderNum = "3", width = 18) + @Excel(name = "结果物编码", orderNum = "3", width = 25) private String targetThingCode; @Excel(name = "结果属性名称", orderNum = "4", width = 18) @@ -39,23 +34,34 @@ public class CalcLogExcel { @Excel(name = "结果属性编码", orderNum = "5", width = 15) private String targetAttrCode; - @Excel(name = "异常信息", orderNum = "6", width = 20) + @Excel(name = "计算结果", orderNum = "7", width = 18) + private String result; + + @Excel(name = "计算公式", orderNum = "8", width = 20) + private String formula; + + @Excel(name = "计算参数", orderNum = "9", width = 65) + private String sourceInfo; + + @Excel(name = "异常信息", orderNum = "10", width = 20) private String errorInfo; - @Excel(name = "计算生成事件", orderNum = "7", width = 18) + @Excel(name = "计算生成时间", orderNum = "11", width = 18) private String createTime; - @Excel(name = "数据异常时间", orderNum = "8", width = 18) + @Excel(name = "数据异常时间", orderNum = "12", width = 18) private String dataTime; - public static List convertFromDTO(List dtoList) { - return dtoList.stream().map(CalcLogExcel::convertFromDTO).collect(Collectors.toList()); + public static List convertFromDTO(List dtoList, Map calcTypeMap) { + return dtoList.stream().map(e -> convertFromDTO(e, calcTypeMap)).collect(Collectors.toList()); } - private static CalcLogExcel convertFromDTO(CalcLogDTO dto) { + private static CalcLogExcel convertFromDTO(CalcLogDTO dto, Map calcTypeMap) { CalcLogExcel excel = ConvertUtils.sourceToTarget(dto, CalcLogExcel.class); + Integer calcType = calcTypeMap.get(dto.getCalcTargetConfigId()); excel.setCreateTime(DateTimeUtils.timestamp2Str(dto.getCreateDate())); excel.setDataTime(DateTimeUtils.timestamp2Str(dto.getTime())); + excel.setCalcType(CalcConfigType.getNameByCode(calcType)); return excel; } } diff --git a/modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcLogServiceImpl.java b/modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcLogServiceImpl.java index 6389dd2..e64bbbd 100644 --- a/modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcLogServiceImpl.java +++ b/modules/calculation/src/main/java/com/thing/calculation/service/impl/CalcLogServiceImpl.java @@ -14,21 +14,23 @@ import com.thing.calculation.enumeration.CalcStatus; import com.thing.calculation.excel.CalcLogExcel; import com.thing.calculation.mapper.CalcLogMapper; import com.thing.calculation.service.CalcLogService; +import com.thing.calculation.service.CalcTargetConfigService; import com.thing.common.core.utils.excel.ExcelUtils; import com.thing.common.core.web.response.PageData; import com.thing.common.orm.service.impl.BaseServiceImpl; import com.thing.sys.security.context.UserContext; +import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; -import lombok.RequiredArgsConstructor; - import org.apache.commons.collections4.MapUtils; import org.apache.commons.lang3.StringUtils; +import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.stream.Collectors; /** * 物计算日志表 @@ -37,8 +39,9 @@ import java.util.*; * @since 5.1 2024-02-27 */ @Service -@RequiredArgsConstructor public class CalcLogServiceImpl extends BaseServiceImpl implements CalcLogService { + @Resource @Lazy + private CalcTargetConfigService targetConfigService; /** 日志过期时间跨度 */ private static final Long TIMEOUT_INTERVAL = 1000 * 60 * 60 * 24 * 7L; @@ -153,7 +156,14 @@ public class CalcLogServiceImpl extends BaseServiceImpl params, HttpServletResponse response) { List logs = listAs(getWrapper(params), CalcLogDTO.class); - List excels = CalcLogExcel.convertFromDTO(logs); + List configs = targetConfigService.getAllEnabled(); + Map calcTypeMap = + configs.stream() + .collect( + Collectors.toMap( + CalcTargetConfigDTO::getId, + CalcTargetConfigDTO::getConfigType)); + List excels = CalcLogExcel.convertFromDTO(logs, calcTypeMap); ExcelUtils.exportExcel(excels, null, "物计算异常记录", CalcLogExcel.class, "物计算异常记录.xls", response); }