From cb415813de667096290d6bd0f924f5b523104117 Mon Sep 17 00:00:00 2001
From: zxl <763096477@qq.com>
Date: 星期一, 10 十一月 2025 17:41:04 +0800
Subject: [PATCH] 报备工单bug修改,定时任务在线问题修改新增导出扣分明细功能

---
 ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java |  342 +++++++++++++++++++++++++++++++++++++++++++++-----------
 1 files changed, 274 insertions(+), 68 deletions(-)

diff --git a/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java b/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
index 1f80460..c3eff9b 100644
--- a/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
+++ b/ycl-server/src/main/java/com/ycl/platform/service/impl/ReportServiceImpl.java
@@ -1,40 +1,47 @@
 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 com.baomidou.mybatisplus.extension.conditions.update.LambdaUpdateChainWrapper;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.ycl.platform.domain.dto.ReportImportDTO;
-import com.ycl.platform.domain.entity.Report;
-import com.ycl.platform.domain.entity.YwPeople;
+import com.ycl.platform.domain.entity.*;
 import com.ycl.platform.domain.form.ReportAuditingForm;
 import com.ycl.platform.domain.form.ReportForm;
 import com.ycl.platform.domain.query.ReportQuery;
 import com.ycl.platform.domain.vo.ReportVO;
+import com.ycl.platform.domain.vo.YwPointVO;
 import com.ycl.platform.mapper.ReportMapper;
 import com.ycl.platform.mapper.YwPeopleMapper;
 import com.ycl.platform.mapper.YwPointMapper;
 import com.ycl.platform.mapper.YwUnitMapper;
+import com.ycl.platform.service.ReportAuditingRecordService;
+import com.ycl.platform.service.ReportErrorTypeService;
 import com.ycl.platform.service.ReportService;
 import com.ycl.system.Result;
+import com.ycl.system.entity.SysDictData;
 import com.ycl.system.page.PageUtil;
+import com.ycl.system.service.ISysDictTypeService;
 import com.ycl.utils.DateUtils;
 import com.ycl.utils.SecurityUtils;
+import com.ycl.utils.StringUtils;
 import com.ycl.utils.html.EscapeUtil;
 import com.ycl.utils.poi.ExcelUtil;
 import com.ycl.utils.uuid.IdUtils;
-import enumeration.general.ErrorTypeEnum;
 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;
 import org.springframework.util.Assert;
+import org.springframework.util.CollectionUtils;
 
-import java.util.ArrayList;
-import java.util.Date;
-import java.util.List;
-import java.util.Objects;
+import java.util.*;
 import java.util.stream.Collectors;
 
 /**
@@ -45,11 +52,15 @@
  */
 @Service
 @RequiredArgsConstructor
+@Slf4j
 public class ReportServiceImpl extends ServiceImpl<ReportMapper, Report> implements ReportService {
 
     private final YwUnitMapper unitMapper;
     private final YwPointMapper ywpointMapper;
     private final YwPeopleMapper peopleMapper;
+    private final ReportErrorTypeService reportErrorTypeService;
+    private final ISysDictTypeService dictTypeService;
+    private final ReportAuditingRecordService reportAuditingRecordService;
 
     /**
      * 娣诲姞
@@ -57,26 +68,49 @@
      * @return
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Result add(ReportForm form) {
         if (Objects.isNull(form.getPointId())) {
             throw new RuntimeException("鐐逛綅涓嶈兘涓虹┖");
         }
-        Long userId = SecurityUtils.getUserId();
-        YwPeople people = new LambdaQueryChainWrapper<>(peopleMapper).eq(YwPeople::getUserId, userId).one();
-        form.setPeopleId(people.getId());
-        form.setUnitId(people.getBelongUnit());
+        Integer unitId = SecurityUtils.getUnitId();
+        if (Objects.isNull(unitId)) {
+            throw new RuntimeException("闈炶繍缁村崟浣嶆殏鏃舵棤娉曟姤澶�");
+        }
+        form.setUnitId(unitId);
+        Long userId = SecurityUtils.getLoginUser().getUserId();
+        form.setPeopleId(Integer.parseInt(userId+""));
+        if ("浜嬪墠鎶ュ".equals(form.getReportType())) {
+            // 濡傛灉鏄簨鍓嶆姤澶囬渶瑕佹楠屾槸鍚﹀凡缁忕敓鎴愪笅鍙戝伐鍗�
+            YwPointVO point = ywpointMapper.countNotFinishedWorkOrderByGb(form.getPointId());
+            if (Objects.nonNull(point)) {
+                throw new RuntimeException(String.format("鐐逛綅銆�%s銆戝凡缁忓瓨鍦ㄤ笅鍙戝伐鍗曪紝鏃犳硶浜嬪墠鎶ュ", point.getPointName()));
+            }
+        }
+        YwPoint point = new LambdaQueryChainWrapper<>(ywpointMapper)
+                .eq(YwPoint::getSerialNumber, form.getPointId())
+                .one();
+        if (Objects.isNull(point)) {
+            throw new RuntimeException("鐐逛綅涓嶅瓨鍦�");
+        }
         Report entity = ReportForm.getEntityByForm(form, null);
-        entity.setSerialNumber(form.getPointId());
-        entity.setErrorType(String.join(",", form.getErrorType()));
+        entity.setSerialNumber(point.getSerialNumber());
         entity.setStatus(0);
-        entity.setIdentify(IdUtils.timeAddRandomNO(3));
         Date now = new Date();
         entity.setCreateTime(now);
         entity.setUpdateTime(now);
-        if(baseMapper.insert(entity) > 0) {
-            return Result.ok("娣诲姞鎴愬姛");
-        }
-        return Result.error("娣诲姞澶辫触");
+        entity.setIdentify(IdUtils.randomNO(now));
+        baseMapper.insert(entity);
+        List<ReportErrorType> errorTypeList = form.getErrorTypeList().stream().map(item -> {
+            ReportErrorType reportErrorType = new ReportErrorType();
+            reportErrorType.setErrorType(item);
+            reportErrorType.setDeleted(0);
+            reportErrorType.setCreateTime(now);
+            reportErrorType.setReportId(entity.getId());
+            return reportErrorType;
+        }).collect(Collectors.toList());
+        reportErrorTypeService.saveBatch(errorTypeList);
+        return Result.ok("鎶ュ鎴愬姛");
     }
 
     @Override
@@ -90,33 +124,60 @@
     @SneakyThrows
     @Transactional
     public Result importData(ReportForm form) {
-        if (Objects.isNull(form.getImportPointId())) {
-            throw new RuntimeException("鐐逛綅涓嶈兘涓虹┖");
+        Integer unitId = SecurityUtils.getUnitId();
+        if (Objects.isNull(unitId)) {
+            throw new RuntimeException("闈炶繍缁村崟浣嶆殏鏃舵棤娉曟姤澶�");
         }
-        Long userId = SecurityUtils.getUserId();
-        YwPeople people = new LambdaQueryChainWrapper<>(peopleMapper).eq(YwPeople::getUserId, userId).one();
-        form.setPeopleId(people.getId());
-        form.setUnitId(people.getBelongUnit());
+        form.setUnitId(unitId);
+        form.setBeginCreateTime(DateUtils.parseDate(form.getBeginCreateTimeStr()));
+        form.setEndCreateTime(DateUtils.parseDate(form.getEndCreateTimeStr()));
         // 璇诲彇excel鏁版嵁
         ExcelUtil<ReportImportDTO> excelUtil = new ExcelUtil<>(ReportImportDTO.class);
         List<ReportImportDTO> list = excelUtil.importExcel(form.getImportPointId().getInputStream());
+        Date now = DateUtils.getNowDate();
         // 鎵归噺鎻掑叆
-        ArrayList<Report> reports = new ArrayList<>();
-        long l = System.currentTimeMillis();
-        list.forEach( item -> {
+        String pid = IdUtils.randomNO(now);
+        Integer success = 0;
+        for (ReportImportDTO item : list) {
+            if ("浜嬪墠鎶ュ".equals(form.getReportType())) {
+                // 濡傛灉鏄簨鍓嶆姤澶囬渶瑕佹楠屾槸鍚﹀凡缁忕敓鎴愪笅鍙戝伐鍗�
+                YwPointVO point = ywpointMapper.countNotFinishedWorkOrderByGb(item.getSerialNumber());
+                if (Objects.nonNull(point)) {
+                    throw new RuntimeException(String.format("鐐逛綅銆�%s銆戝凡缁忓瓨鍦ㄤ笅鍙戝伐鍗曪紝鏃犳硶浜嬪墠鎶ュ", point.getPointName()));
+                }
+            }
+            YwPoint point = new LambdaQueryChainWrapper<>(ywpointMapper)
+                    .eq(YwPoint::getSerialNumber, item.getSerialNumber())
+                    .one();
+            if (Objects.isNull(point)) {
+                continue;
+            }
             Report entity = ReportForm.getEntityByForm(form, null);
-            entity.setImportBatchNumber(String.valueOf(l));
+            entity.setImportBatchNumber(pid);
             entity.setSerialNumber(item.getSerialNumber());
             entity.setStatus(0);
-            entity.setIdentify(IdUtils.timeAddRandomNO(3));
-            entity.setCreateTime(DateUtils.getNowDate());
-            entity.setUpdateTime(DateUtils.getNowDate());
-            reports.add(entity);
-        });
-        if (saveBatch(reports)) {
-            return Result.ok("瀵煎叆鎴愬姛");
+            entity.setIdentify(IdUtils.randomNO(now));
+            entity.setCreateTime(now);
+            entity.setUpdateTime(now);
+            baseMapper.insert(entity);
+            List<ReportErrorType> errorTypeList = form.getErrorTypeList().stream().map(err -> {
+                ReportErrorType reportErrorType = new ReportErrorType();
+                reportErrorType.setErrorType(err);
+                reportErrorType.setDeleted(0);
+                reportErrorType.setCreateTime(now);
+                reportErrorType.setReportId(entity.getId());
+                return reportErrorType;
+            }).collect(Collectors.toList());
+            reportErrorTypeService.saveBatch(errorTypeList);
+            success++;
         }
-        return Result.error("娣诲姞澶辫触");
+        return Result.ok("鎶ュ鐐逛綅鏁帮細" + list.size() + "锛屽鍏ユ垚鍔熸暟锛�" + success);
+    }
+
+    @Override
+    public Result getTogether(String pid) {
+        List<Report> list = baseMapper.getTogether(pid);
+        return Result.ok().data(list);
     }
 
     /**
@@ -125,6 +186,7 @@
      * @return
      */
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Result update(ReportForm form) {
 
         Report entity = baseMapper.selectById(form.getId());
@@ -132,21 +194,36 @@
         Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
         Date now = new Date();
         entity.setUpdateTime(now);
-        if (0 == entity.getStatus()) {
-            // 寰呭鏍哥殑鐩存帴鏀�
-            BeanUtils.copyProperties(form, entity);
-            baseMapper.updateById(entity);
-        } else if (2 == entity.getStatus()) {
-            // 濡傛灉鏄湭瀹℃牳閫氳繃锛岃繘琛屼慨鏀癸紝閭d箞鐩存帴鏂板锛堜负浜嗕繚瀛樺鏍歌褰曪級
-            Report report = new Report();
-            BeanUtils.copyProperties(entity, report);
-            BeanUtils.copyProperties(form, report);
-            report.setId(null);
-            report.setStatus(0);
-            report.setAuditingTime(null);
-            report.setAuditOpinion(null);
-            baseMapper.insert(report);
+        if ("浜嬪墠鎶ュ".equals(form.getReportType())) {
+            // 濡傛灉鏄簨鍓嶆姤澶囬渶瑕佹楠屾槸鍚﹀凡缁忕敓鎴愪笅鍙戝伐鍗�
+            YwPointVO point = ywpointMapper.countNotFinishedWorkOrderByGb(form.getPointId());
+            if (Objects.nonNull(point)) {
+                throw new RuntimeException(String.format("鐐逛綅銆�%s銆戝凡缁忓瓨鍦ㄤ笅鍙戝伐鍗曪紝鏃犳硶浜嬪墠鎶ュ", point.getPointName()));
+            }
         }
+        YwPoint point = new LambdaQueryChainWrapper<>(ywpointMapper)
+                .eq(YwPoint::getSerialNumber, form.getPointId())
+                .one();
+        if (Objects.isNull(point)) {
+            throw new RuntimeException("鐐逛綅涓嶅瓨鍦�");
+        }
+        BeanUtils.copyProperties(form, entity);
+        entity.setSerialNumber(form.getPointId());
+        // 閲嶇疆涓哄緟瀹℃牳
+        entity.setStatus(0);
+        baseMapper.updateById(entity);
+        new LambdaUpdateChainWrapper<>(reportErrorTypeService.getBaseMapper())
+                .eq(ReportErrorType::getReportId, form.getId())
+                .remove();
+        List<ReportErrorType> errorTypeList = form.getErrorTypeList().stream().map(err -> {
+            ReportErrorType reportErrorType = new ReportErrorType();
+            reportErrorType.setErrorType(err);
+            reportErrorType.setDeleted(0);
+            reportErrorType.setCreateTime(now);
+            reportErrorType.setReportId(entity.getId());
+            return reportErrorType;
+        }).collect(Collectors.toList());
+        reportErrorTypeService.saveBatch(errorTypeList);
         return Result.ok("淇敼鎴愬姛");
     }
 
@@ -184,8 +261,38 @@
     @Override
     public Result page(ReportQuery query) {
         IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class);
+        query.setUnitId(SecurityUtils.getUnitId());
+        if (query.getReportTimeEnd() != null) {
+            query.setReportTimeEnd(DateUtils.getDayEnd(query.getReportTimeEnd()));
+        }
+
+        if (query.getEffectTimeEnd() != null) {
+            query.setEffectTimeEnd(DateUtils.getDayEnd(query.getEffectTimeEnd()));
+        }
+        long dbStartTime = System.currentTimeMillis();
         baseMapper.page(page, query);
-        page.getRecords().forEach(item -> item.setErrorType(ErrorTypeEnum.getEnumValue(item.getErrorType())));
+        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())) {
+                item.setErrorTypeList(List.of(item.getErrorType().split(",")));
+                StringBuilder sb = new StringBuilder();
+                item.getErrorTypeList().stream().forEach(err -> {
+                    String s = dictMap.get(err);
+                    if (org.springframework.util.StringUtils.hasText(s)) {
+                        sb.append(s).append("銆�");
+                    }
+                });
+                item.setErrorType(sb.substring(0, sb.length() - 1));
+            }
+        });
+        log.info("缁勮淇℃伅鑰楁椂锛歿}ms", dictEndTime);
         return Result.ok().data(page).total(page.getTotal());
     }
 
@@ -196,10 +303,16 @@
      */
     @Override
     public Result detail(String id) {
-
         Report entity = baseMapper.selectById(id);
         Assert.notNull(entity, "璁板綍涓嶅瓨鍦�");
         ReportVO vo = ReportVO.getVoByEntity(entity, null);
+        vo.setPointId(vo.getSerialNumber());
+        List<ReportErrorType> errList = new LambdaQueryChainWrapper<>(reportErrorTypeService.getBaseMapper())
+                .select(ReportErrorType::getErrorType)
+                .eq(ReportErrorType::getReportId, id)
+                .list();
+        List<String> list = errList.stream().map(ReportErrorType::getErrorType).collect(Collectors.toList());
+        vo.setErrorTypeList(list);
         return Result.ok().data(vo);
     }
 
@@ -220,16 +333,79 @@
 
     @Override
     public List<ReportVO> export(ReportQuery query) {
+        // 1. 鍒嗛〉鏌ヨ涓绘暟鎹紙涓嶅彉锛�
         IPage<ReportVO> page = PageUtil.getPage(query, ReportVO.class);
         page.setSize(-1);
+        query.setUnitId(SecurityUtils.getUnitId());
         baseMapper.page(page, query);
-        page.getRecords().forEach(item -> {
-            item.setErrorType(ErrorTypeEnum.getEnumValue(item.getErrorType()));
-            item.setReportContent(EscapeUtil.clean(item.getReportContent()));
-        });
-        return page.getRecords();
-    }
+        List<ReportVO> records = page.getRecords();
+        if (CollectionUtils.isEmpty(records)) {
+            return Collections.emptyList();
+        }
 
+        // 2. 鎵归噺鏌ヨ瀛楀吀鏁版嵁锛堜笉鍙橈紝寤鸿鍔犵紦瀛橈級
+        List<SysDictData> errorTypeList = dictTypeService.selectDictDataByType("report_error_type");
+        Map<String, String> errorDictMap = errorTypeList.stream()
+                .collect(Collectors.toMap(SysDictData::getDictValue, SysDictData::getDictLabel, (k1, k2) -> k2));
+
+        // 3. 鎵归噺鏌ヨ瀹℃牳璁板綍锛堟牳蹇冧慨鏀癸細鐢ㄥ瓙鏌ヨ鏇夸唬绐楀彛鍑芥暟锛屽吋瀹逛綆鐗堟湰MySQL锛�
+        List<Integer> reportIds = records.stream().map(ReportVO::getId).collect(Collectors.toList());
+        // 瀛愭煡璇細鑾峰彇姣忎釜reportId鐨勬渶鏂板垱寤烘椂闂�
+        LambdaQueryWrapper<ReportAuditingRecord> maxTimeQuery = new LambdaQueryWrapper<ReportAuditingRecord>()
+                .in(ReportAuditingRecord::getReportId, reportIds)
+                .groupBy(ReportAuditingRecord::getReportId)
+                .select(ReportAuditingRecord::getReportId, ReportAuditingRecord::getCreateTime); // 鍒嗙粍鏌eportId鍜屾渶澶ф椂闂�
+
+        // 涓绘煡璇細鍏宠仈瀛愭煡璇紝鎷垮埌姣忎釜reportId鏈�鏂扮殑瀹℃牳璁板綍
+        List<ReportAuditingRecord> allAuditRecords = reportAuditingRecordService.getBaseMapper().selectList(
+                new LambdaQueryWrapper<ReportAuditingRecord>()
+                        .in(ReportAuditingRecord::getReportId, reportIds)
+                        // 鍏宠仈瀛愭煡璇紝鍖归厤reportId鍜屾渶鏂板垱寤烘椂闂�
+                        .inSql(ReportAuditingRecord::getCreateTime,
+                                "SELECT MAX(create_time) FROM t_report_auditing_record WHERE report_id IN (" +
+                                        reportIds.stream().map(String::valueOf).collect(Collectors.joining(",")) +
+                                        ") GROUP BY report_id")
+        );
+
+        // 鏋勫缓reportId -> 鏈�鏂板鏍歌褰曠殑Map锛堜笉鍙橈級
+        Map<Integer, ReportAuditingRecord> auditRecordMap = allAuditRecords.stream()
+                .collect(Collectors.toMap(ReportAuditingRecord::getReportId, record -> record, (k1, k2) -> {
+                    // 鏋佺鎯呭喌锛氬悓涓�reportId鏈夌浉鍚屽垱寤烘椂闂寸殑璁板綍锛屽彇浠绘剰涓�涓紙鎸夊垱寤烘椂闂村�掑簭鍙栫涓�涓級
+                    return k1.getCreateTime().after(k2.getCreateTime()) ? k1 : k2;
+                }));
+
+        // 4. 寰幆澶勭悊鏁版嵁锛堜笉鍙橈紝淇濈暀涔嬪墠鐨勫瓧绗︿覆浼樺寲鍜岀┖鍊煎鐞嗭級
+        records.forEach(item -> {
+            // 澶勭悊鏁呴殰绫诲瀷锛堜笉鍙橈級
+            String errorType = item.getErrorType();
+            if (StringUtils.hasText(errorType)) {
+                String[] errorTypeArr = StringUtils.split(errorType, ",");
+                StringJoiner sj = new StringJoiner("銆�");
+                for (String err : errorTypeArr) {
+                    String dictLabel = errorDictMap.get(err);
+                    if (StringUtils.hasText(dictLabel)) {
+                        sj.add(dictLabel);
+                    }
+                }
+                item.setErrorTypeList(Arrays.asList(errorTypeArr));
+                item.setErrorType(sj.toString());
+            }
+
+            // 澶勭悊瀹℃牳缁撴灉锛堜笉鍙橈紝浠嶮ap鑾峰彇锛�
+            ReportAuditingRecord auditRecord = auditRecordMap.get(item.getId());
+            if (auditRecord != null) {
+                item.setResultStr(auditRecord.getResult() ? "閫氳繃" : "鏈�氳繃");
+                item.setResultRemark(auditRecord.getResultRemark());
+                item.setAuditingTime(auditRecord.getCreateTime());
+            } else {
+                item.setResultStr("瀹℃牳涓�");
+            }
+
+            item.setReportContent(EscapeUtil.clean(StringUtils.defaultString(item.getReportContent())));
+        });
+
+        return records;
+    }
 
     @Override
     public Result auditingRecord(Integer id) {
@@ -238,19 +414,49 @@
     }
 
     @Override
+    @Transactional(rollbackFor = Exception.class)
     public Result auditing(ReportAuditingForm form) {
-        Report report = baseMapper.selectById(form.getId());
-        if (Objects.isNull(report)) {
-            throw new RuntimeException("瀹℃牳鐨勬姤澶囦笉瀛樺湪");
+        if (CollectionUtils.isEmpty(form.getTogetherList())) {
+            form.setTogetherList(new ArrayList<>(2));
         }
-        if (form.getAuditingResult()) {
-            report.setStatus(1);
-        } else {
-            report.setStatus(2);
+        form.getTogetherList().add(form.getId());
+        for (Integer id : form.getTogetherList()) {
+            Report report = baseMapper.selectById(id);
+            if (Objects.isNull(report)) {
+                continue;
+            }
+            if (form.getAuditingResult()) {
+                report.setStatus(1);
+            } else {
+                report.setStatus(2);
+            }
+            Date now = new Date();
+            report.setUpdateTime(now);
+            baseMapper.updateById(report);
+
+            // 娣诲姞涓�鏉″鏍歌褰�
+            ReportAuditingRecord reportAuditingRecord = new ReportAuditingRecord();
+            reportAuditingRecord.setReportId(id);
+            reportAuditingRecord.setDeleted(0);
+            reportAuditingRecord.setCreateTime(now);
+            reportAuditingRecord.setResultRemark(form.getAuditOpinion());
+            reportAuditingRecord.setResult(form.getAuditingResult());
+            reportAuditingRecordService.save(reportAuditingRecord);
         }
-        report.setAuditOpinion(form.getAuditOpinion());
-        report.setAuditingTime(new Date());
-        baseMapper.updateById(report);
         return Result.ok("鎿嶄綔鎴愬姛");
     }
+
+    @Override
+    public Result getListByGb(String gb) {
+        List<ReportVO> list = baseMapper.getListByGb(gb);
+        for (ReportVO report : list) {
+            List<ReportErrorType> errors = new LambdaQueryChainWrapper<>(reportErrorTypeService.getBaseMapper())
+                    .eq(ReportErrorType::getReportId, report.getId())
+                    .orderByDesc(ReportErrorType::getCreateTime)
+                    .list();
+            String err = errors.stream().map(ReportErrorType::getErrorType).collect(Collectors.joining(","));
+            report.setErrorType(err);
+        }
+        return Result.ok().data(list);
+    }
 }

--
Gitblit v1.8.0