| | |
| | | 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; |
| | |
| | | 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; |
| | |
| | | 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 + "]"); |
| | | } |
| | | } |