| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | */ |
| | | @Service |
| | | @RequiredArgsConstructor |
| | | @Slf4j |
| | | public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService { |
| | | |
| | | private final YwUnitMapper unitMapper; |
| | |
| | | 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())) { |
| | |
| | | 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()); |
| | | } |
| | | |