| | |
| | | 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.InternalAuditCheckService; |
| | | 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.LocalDate; |
| | |
| | | carryMapper.updateById(internalAuditCarry); |
| | | return CommonResult.success(); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | @Transactional |
| | | public CommonResult copyInternalAuditCarry(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<InternalAuditCarry> deleteWrapper = new LambdaUpdateWrapper<>(); |
| | | deleteWrapper.eq(InternalAuditCarry::getCompanyId, companyId) |
| | | .eq(InternalAuditCarry::getYear, targetYear) |
| | | .eq(InternalAuditCarry::getDelFlag, 1) |
| | | .set(InternalAuditCarry::getDelFlag, 2) |
| | | .set(InternalAuditCarry::getUpdateBy, SecurityUtils.getUsername()) |
| | | .set(InternalAuditCarry::getUpdateTime, LocalDateTime.now()); |
| | | carryMapper.update(new InternalAuditCarry(), deleteWrapper); |
| | | |
| | | LambdaQueryWrapper<InternalAuditCarry> queryWrapperSource = new LambdaQueryWrapper<>(); |
| | | queryWrapperSource.eq(InternalAuditCarry::getCompanyId, companyId) |
| | | .eq(InternalAuditCarry::getYear, sourceYear) |
| | | .eq(InternalAuditCarry::getDelFlag, 1); |
| | | List<InternalAuditCarry> sourceCarries = carryMapper.selectList(queryWrapperSource); |
| | | |
| | | if (ObjectUtil.isEmpty(sourceCarries)) { |
| | | return CommonResult.success("源年份无相关数据"); |
| | | } |
| | | |
| | | for (InternalAuditCarry sourceCarry : sourceCarries) { |
| | | InternalAuditCarry newCarry = new InternalAuditCarry(); |
| | | newCarry.setCompanyId(sourceCarry.getCompanyId()); |
| | | newCarry.setYear(targetYear); |
| | | newCarry.setAuditPurpose(sourceCarry.getAuditPurpose()); |
| | | newCarry.setReviewBasis(sourceCarry.getReviewBasis()); |
| | | newCarry.setReviewScope(sourceCarry.getReviewScope()); |
| | | newCarry.setReviewStart(sourceCarry.getReviewStart()); |
| | | newCarry.setReviewEnd(sourceCarry.getReviewEnd()); |
| | | newCarry.setReviewPerson(sourceCarry.getReviewPerson()); |
| | | newCarry.setFirstStarttime(sourceCarry.getFirstStarttime()); |
| | | newCarry.setFirstEndtime(sourceCarry.getFirstEndtime()); |
| | | newCarry.setLastStarttime(sourceCarry.getLastStarttime()); |
| | | newCarry.setLastEndtime(sourceCarry.getLastEndtime()); |
| | | newCarry.setCompilationId(sourceCarry.getCompilationId()); |
| | | newCarry.setProofreadId(sourceCarry.getProofreadId()); |
| | | newCarry.setCheckId(sourceCarry.getCheckId()); |
| | | newCarry.setRatifyId(sourceCarry.getRatifyId()); |
| | | newCarry.setDelFlag(1); |
| | | newCarry.setCreateBy(SecurityUtils.getUsername()); |
| | | newCarry.setCreateTime(LocalDateTime.now()); |
| | | newCarry.setUpdateBy(SecurityUtils.getUsername()); |
| | | newCarry.setUpdateTime(LocalDateTime.now()); |
| | | |
| | | int insert = carryMapper.insert(newCarry); |
| | | if (insert <= 0) { |
| | | throw new RuntimeException("复制内审计划实施主表数据失败"); |
| | | } |
| | | |
| | | List<InternalAuditCarryDept> sourceDeptList = carryMapper.selectCarryDeptList(sourceCarry.getId()); |
| | | if (ObjectUtil.isNotEmpty(sourceDeptList)) { |
| | | List<InternalAuditCarryDept> newDeptList = new ArrayList<>(); |
| | | for (InternalAuditCarryDept sourceDept : sourceDeptList) { |
| | | InternalAuditCarryDept newDept = new InternalAuditCarryDept(); |
| | | newDept.setCarryId(newCarry.getId()); |
| | | newDept.setDeptId(sourceDept.getDeptId()); |
| | | newDept.setCheckId(sourceDept.getCheckId()); |
| | | newDept.setDate(sourceDept.getDate()); |
| | | newDept.setStartTime(sourceDept.getStartTime()); |
| | | newDept.setEndTime(sourceDept.getEndTime()); |
| | | newDeptList.add(newDept); |
| | | } |
| | | carryMapper.insertCarryDept(newDeptList); |
| | | } |
| | | } |
| | | |
| | | return CommonResult.success("成功从年份[" + sourceYear + "]复制到年份[" + targetYear + "]"); |
| | | } |
| | | |
| | | } |