From c26e227abe288476c11b0a8b7875045e71efa14c Mon Sep 17 00:00:00 2001
From: “djh” <“3298565835@qq.com”>
Date: Thu, 30 Apr 2026 17:30:00 +0800
Subject: [PATCH] 新增修改
---
multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditCheckServiceImpl.java | 165 +++++++++++++++++++++++++++++++++++-------------------
1 files changed, 106 insertions(+), 59 deletions(-)
diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditCheckServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditCheckServiceImpl.java
index 82fbd3a..d3ea65d 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditCheckServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditCheckServiceImpl.java
@@ -2,29 +2,26 @@
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gkhy.exam.common.api.CommonPage;
import com.gkhy.exam.common.api.CommonResult;
-import com.gkhy.exam.common.domain.entity.SysDept;
-import com.gkhy.exam.common.exception.ApiException;
import com.gkhy.exam.common.utils.PageUtils;
import com.gkhy.exam.common.utils.SecurityUtils;
import com.gkhy.exam.system.domain.InternalAuditCheck;
import com.gkhy.exam.system.domain.InternalAuditCheckCatalogue;
-import com.gkhy.exam.system.domain.InternalAuditCheckContent;
-import com.gkhy.exam.system.domain.InternalAuditCheckPerson;
-import com.gkhy.exam.system.domain.vo.InternalAuditCheckVo;
import com.gkhy.exam.system.mapper.*;
import com.gkhy.exam.system.service.InternalAuditCheckService;
-import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
-import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
-import java.util.*;
+import java.util.ArrayList;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
import java.util.stream.Collectors;
/**
@@ -52,9 +49,9 @@
@Autowired
private SysDeptMapper sysDeptMapper;
@Override
- public CommonPage selectInternalAuditCheckList(Integer companyId) {
+ public CommonPage selectInternalAuditCheckList(Integer companyId,String year) {
PageUtils.startPage();
- List<InternalAuditCheck> internalAuditChecks = internalAuditCheckMapper.selectInternalAuditCheckList(companyId);
+ List<InternalAuditCheck> internalAuditChecks = internalAuditCheckMapper.selectInternalAuditCheckList(companyId, year);
if (!CollectionUtils.isEmpty(internalAuditChecks)) {
batchLoadCheckDetails(internalAuditChecks);
}
@@ -79,13 +76,6 @@
.map(InternalAuditCheckCatalogue::getId)
.collect(Collectors.toList());
- //批量查询所有内容
- List<InternalAuditCheckContent> allContents = checkContentMapper.selectByCatalogueIds(catalogueIds);
-
- //按目录ID分组内容
- Map<Integer, List<InternalAuditCheckContent>> contentMap = allContents.stream()
- .collect(Collectors.groupingBy(InternalAuditCheckContent::getCheckCatalogueId));
-
//按检查ID分组目录
Map<Integer, List<InternalAuditCheckCatalogue>> catalogueMap = allCatalogues.stream()
.collect(Collectors.groupingBy(InternalAuditCheckCatalogue::getCheckId));
@@ -94,10 +84,6 @@
for (InternalAuditCheck check : checks) {
List<InternalAuditCheckCatalogue> catalogues = catalogueMap.get(check.getId());
if (!CollectionUtils.isEmpty(catalogues)) {
- for (InternalAuditCheckCatalogue catalogue : catalogues) {
- List<InternalAuditCheckContent> contents = contentMap.get(catalogue.getId());
- catalogue.setCheckContents(contents != null ? contents : new ArrayList<>());
- }
check.setCheckCatalogues(catalogues);
}
}
@@ -117,7 +103,6 @@
return CommonResult.failed("当前部门存在,请勿重复添加");
}
-
internalAuditCheck.setCreateBy(SecurityUtils.getUsername());
internalAuditCheck.setCreateTime(LocalDateTime.now());
int insert = internalAuditCheckMapper.insert(internalAuditCheck);
@@ -130,44 +115,18 @@
return CommonResult.success();
}
//批量处理目录和内容
- batchInsertCataloguesAndContents(internalAuditCheck.getId(), checkCatalogues);
- return CommonResult.success();
-
- }
-
- private void batchInsertCataloguesAndContents(Integer checkId, List<InternalAuditCheckCatalogue> catalogues) {
- // 1. 设置目录的检查ID并批量插入
- for (InternalAuditCheckCatalogue catalogue : catalogues) {
- catalogue.setCheckId(checkId);
+ for (InternalAuditCheckCatalogue catalogue : checkCatalogues) {
+ catalogue.setCheckId(internalAuditCheck.getId());
}
// 批量插入目录
- int catalogueInsertCount = checkCatalogueMapper.insertBatch(catalogues);
- if (catalogueInsertCount != catalogues.size()) {
+ int catalogueInsertCount = checkCatalogueMapper.insertBatch(checkCatalogues);
+
+ if (catalogueInsertCount != checkCatalogues.size()) {
throw new RuntimeException("插入目录记录数量不匹配");
}
+ return CommonResult.success();
- // 2. 收集所有内容并设置目录ID
- List<InternalAuditCheckContent> allContents = new ArrayList<>();
- for (int i = 0; i < catalogues.size(); i++) {
- InternalAuditCheckCatalogue catalogue = catalogues.get(i);
- List<InternalAuditCheckContent> contents = catalogue.getCheckContents();
-
- if (!CollectionUtils.isEmpty(contents)) {
- for (InternalAuditCheckContent content : contents) {
- content.setCheckCatalogueId(catalogue.getId());
- }
- allContents.addAll(contents);
- }
- }
-
- // 3. 批量插入内容
- if (!CollectionUtils.isEmpty(allContents)) {
- int contentInsertCount = checkContentMapper.insertBatchs(allContents);
- if (contentInsertCount != allContents.size()) {
- throw new RuntimeException("插入内容记录数量不匹配");
- }
- }
}
@Override
@@ -176,14 +135,17 @@
internalAuditCheck.setUpdateTime(LocalDateTime.now());
int update = internalAuditCheckMapper.updateById(internalAuditCheck);
if (update>0){
- checkCatalogueMapper.updatebyCheckId(internalAuditCheck.getId());
-
List<InternalAuditCheckCatalogue> checkCatalogues = internalAuditCheck.getCheckCatalogues();
if (CollectionUtils.isEmpty(checkCatalogues)) {
return CommonResult.success();
}
+ for (InternalAuditCheckCatalogue catalogue : checkCatalogues) {
+ catalogue.setCheckId(internalAuditCheck.getId());
+ }
- batchInsertCataloguesAndContents(internalAuditCheck.getId(), checkCatalogues);
+ // 批量插入目录
+ checkCatalogueMapper.updateCheckCatalogues(checkCatalogues);
+
return CommonResult.success();
}
return CommonResult.failed();
@@ -210,7 +172,16 @@
if (update>0){
checkCatalogueMapper.updatebyCheckId(internalAuditCheck.getId());
List<InternalAuditCheckCatalogue> checkCatalogues = internalAuditCheck.getCheckCatalogues();
- batchInsertCataloguesAndContents(internalAuditCheck.getId(), checkCatalogues);
+ for (InternalAuditCheckCatalogue catalogue : checkCatalogues) {
+ catalogue.setCheckId(internalAuditCheck.getId());
+ }
+
+ // 批量插入目录
+ int catalogueInsertCount = checkCatalogueMapper.saveBatch(checkCatalogues);
+
+ if (catalogueInsertCount != checkCatalogues.size()) {
+ throw new RuntimeException("插入目录记录数量不匹配");
+ }
}
return CommonResult.success();
}
@@ -220,6 +191,82 @@
return internalAuditCheckMapper.selectByMap(stringObjectHashMap);
}
+
+ @Override
+ @Transactional
+ public CommonResult copyInternalAuditCheck(Integer companyId, String sourceYear, String targetYear) {
+ if (companyId == null) {
+ companyId = SecurityUtils.getCompanyId().intValue();
+ }
+
+ if (sourceYear == null || sourceYear.trim().isEmpty()) {
+ return CommonResult.failed("源年份不能为空");
+ }
+
+ if (targetYear == null || targetYear.trim().isEmpty()) {
+ return CommonResult.failed("目标年份不能为空");
+ }
+
+ LambdaUpdateWrapper<InternalAuditCheck> deleteWrapper = new LambdaUpdateWrapper<>();
+ deleteWrapper.eq(InternalAuditCheck::getCompanyId, companyId)
+ .eq(InternalAuditCheck::getYear, targetYear)
+ .eq(InternalAuditCheck::getDelFlag, 0)
+ .set(InternalAuditCheck::getDelFlag, 2)
+ .set(InternalAuditCheck::getUpdateBy, SecurityUtils.getUsername())
+ .set(InternalAuditCheck::getUpdateTime, LocalDateTime.now());
+ internalAuditCheckMapper.update(new InternalAuditCheck(), deleteWrapper);
+
+ LambdaQueryWrapper<InternalAuditCheck> queryWrapperSource = new LambdaQueryWrapper<>();
+ queryWrapperSource.eq(InternalAuditCheck::getCompanyId, companyId)
+ .eq(InternalAuditCheck::getYear, sourceYear)
+ .eq(InternalAuditCheck::getDelFlag, 0);
+ List<InternalAuditCheck> sourceChecks = internalAuditCheckMapper.selectList(queryWrapperSource);
+
+ if (ObjectUtil.isEmpty(sourceChecks)) {
+ return CommonResult.success("源年份无相关数据");
+ }
+
+ batchLoadCheckDetails(sourceChecks);
+
+ for (InternalAuditCheck sourceCheck : sourceChecks) {
+ InternalAuditCheck newCheck = new InternalAuditCheck();
+ newCheck.setCompanyId(sourceCheck.getCompanyId());
+ newCheck.setYear(targetYear);
+ newCheck.setDeptId(sourceCheck.getDeptId());
+ newCheck.setPersonId(sourceCheck.getPersonId());
+ newCheck.setCheckTime(sourceCheck.getCheckTime());
+ newCheck.setStartTime(sourceCheck.getStartTime());
+ newCheck.setEndTime(sourceCheck.getEndTime());
+ newCheck.setDelFlag(0);
+ newCheck.setCreateBy(SecurityUtils.getUsername());
+ newCheck.setCreateTime(LocalDateTime.now());
+ newCheck.setUpdateBy(SecurityUtils.getUsername());
+ newCheck.setUpdateTime(LocalDateTime.now());
+
+ int insert = internalAuditCheckMapper.insert(newCheck);
+ if (insert <= 0) {
+ throw new RuntimeException("复制内审检查主表数据失败");
+ }
+
+ List<InternalAuditCheckCatalogue> sourceCatalogues = sourceCheck.getCheckCatalogues();
+ if (ObjectUtil.isNotEmpty(sourceCatalogues)) {
+ List<InternalAuditCheckCatalogue> newCatalogues = new ArrayList<>();
+ for (InternalAuditCheckCatalogue sourceCatalogue : sourceCatalogues) {
+ InternalAuditCheckCatalogue newCatalogue = new InternalAuditCheckCatalogue();
+ newCatalogue.setCheckId(newCheck.getId());
+ newCatalogue.setCatalogueId(sourceCatalogue.getCatalogueId());
+ newCatalogue.setPointKey(sourceCatalogue.getPointKey());
+ newCatalogue.setResult(sourceCatalogue.getResult());
+ newCatalogue.setFind(sourceCatalogue.getFind());
+ newCatalogues.add(newCatalogue);
+ }
+ checkCatalogueMapper.insertBatch(newCatalogues);
+ }
+ }
+
+ return CommonResult.success("复制成功");
+ }
+
// @Override
// public CommonResult internalAuditCheckInfo(Integer id) {
// InternalAuditCheck internalAuditCheck = internalAuditCheckMapper.selectById(id);
--
Gitblit v1.9.2