zxl
4 天以前 c83101eb62f5d4906b9c01ceea6b21a37f9e84d8
ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
@@ -1,5 +1,6 @@
package com.ycl.platform.service.impl;
import com.alibaba.fastjson2.JSON;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.conditions.query.LambdaQueryChainWrapper;
@@ -33,6 +34,7 @@
import jakarta.servlet.http.HttpServletResponse;
import lombok.RequiredArgsConstructor;
import lombok.SneakyThrows;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -50,6 +52,7 @@
 */
@Service
@RequiredArgsConstructor
@Slf4j
public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
    private final YwUnitMapper unitMapper;
@@ -266,9 +269,15 @@
        if (query.getEffectTimeEnd() != null) {
            query.setEffectTimeEnd(DateUtils.getDayEnd(query.getEffectTimeEnd()));
        }
        long dbStartTime = System.currentTimeMillis();
        baseMapper.page(page, query);
        long dbCostTime = System.currentTimeMillis() - dbStartTime;
        // 5. 打印耗时日志(含请求参数,方便后续排查慢查询)
        log.info("报表数据库查询耗时:{}ms,查询参数:{}", dbCostTime, JSON.toJSONString(query));
        long dictStartTime = System.currentTimeMillis();
        List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type");
        long dictEndTime = System.currentTimeMillis() - dictStartTime;
        Map<String, String> dictMap = errorTypeList.stream().collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel));
        page.getRecords().stream().forEach(item -> {
            if (StringUtils.hasText(item.getErrorType())) {
@@ -280,9 +289,16 @@
                        sb.append(s).append("、");
                    }
                });
                item.setErrorType(sb.substring(0, sb.length() - 1));
                if (sb.length() > 0) {
                    item.setErrorType(sb.substring(0, sb.length() - 1));
                } else {
                    // 无匹配标签时,可设为空字符串或保留原始 errorType
                    item.setErrorType("");
                    // 或 item.setErrorType(item.getErrorType()); // 保留原始编码
                }
            }
        });
        log.info("组装信息耗时:{}ms", dictEndTime);
        return Result.ok().data(page).total(page.getTotal());
    }