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/InternalAuditPlanServiceImpl.java |   66 +++++++++++++++++++++++++++++++++
 1 files changed, 66 insertions(+), 0 deletions(-)

diff --git a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditPlanServiceImpl.java b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditPlanServiceImpl.java
index 4d87073..877f502 100644
--- a/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditPlanServiceImpl.java
+++ b/multi-system/src/main/java/com/gkhy/exam/system/service/impl/InternalAuditPlanServiceImpl.java
@@ -1,5 +1,8 @@
 package com.gkhy.exam.system.service.impl;
 
+import cn.hutool.core.util.ObjectUtil;
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.gkhy.exam.common.api.CommonPage;
@@ -12,6 +15,7 @@
 import com.gkhy.exam.system.service.InternalAuditPlanService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.time.LocalDateTime;
 import java.util.List;
@@ -71,4 +75,66 @@
         planMapper.updateById(internalAuditPlan);
         return CommonResult.success();
     }
+
+    @Override
+    @Transactional
+    public CommonResult copyInternalAuditPlan(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<InternalAuditPlan> deleteWrapper = new LambdaUpdateWrapper<>();
+        deleteWrapper.eq(InternalAuditPlan::getCompanyId, companyId)
+                .eq(InternalAuditPlan::getYear, targetYear)
+                .eq(InternalAuditPlan::getDelFlag, 1)
+                .set(InternalAuditPlan::getDelFlag, 2)
+                .set(InternalAuditPlan::getUpdateBy, SecurityUtils.getUsername())
+                .set(InternalAuditPlan::getUpdateTime, LocalDateTime.now());
+        planMapper.update(new InternalAuditPlan(), deleteWrapper);
+
+        LambdaQueryWrapper<InternalAuditPlan> queryWrapperSource = new LambdaQueryWrapper<>();
+        queryWrapperSource.eq(InternalAuditPlan::getCompanyId, companyId)
+                .eq(InternalAuditPlan::getYear, sourceYear)
+                .eq(InternalAuditPlan::getDelFlag, 1);
+        List<InternalAuditPlan> sourcePlans = planMapper.selectList(queryWrapperSource);
+
+        if (ObjectUtil.isEmpty(sourcePlans)) {
+            return CommonResult.success("源年份无相关数据");
+        }
+
+        for (InternalAuditPlan sourcePlan : sourcePlans) {
+            InternalAuditPlan newPlan = new InternalAuditPlan();
+            newPlan.setCompanyId(sourcePlan.getCompanyId());
+            newPlan.setYear(targetYear);
+            newPlan.setPurpose(sourcePlan.getPurpose());
+            newPlan.setAuditPurpose(sourcePlan.getAuditPurpose());
+            newPlan.setReviewBasis(sourcePlan.getReviewBasis());
+            newPlan.setReviewScope(sourcePlan.getReviewScope());
+            newPlan.setReviewCarry(sourcePlan.getReviewCarry());
+            newPlan.setReviewConstitute(sourcePlan.getReviewConstitute());
+            newPlan.setReviewRequire(sourcePlan.getReviewRequire());
+            newPlan.setCompilationId(sourcePlan.getCompilationId());
+            newPlan.setProofreadId(sourcePlan.getProofreadId());
+            newPlan.setCheckId(sourcePlan.getCheckId());
+            newPlan.setRatifyId(sourcePlan.getRatifyId());
+            newPlan.setDelFlag(1);
+            newPlan.setCreateBy(SecurityUtils.getUsername());
+            newPlan.setCreateTime(LocalDateTime.now());
+
+            int insert = planMapper.insert(newPlan);
+            if (insert <= 0) {
+                throw new RuntimeException("复制内审策划数据失败");
+            }
+        }
+
+        return CommonResult.success("成功从年份[" + sourceYear + "]复制到年份[" + targetYear + "]");
+    }
 }

--
Gitblit v1.9.2