| | |
| | | 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.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.exam.common.api.CommonPage; |
| | | import com.gkhy.exam.common.api.CommonResult; |
| | |
| | | import org.springframework.util.CollectionUtils; |
| | | |
| | | import java.time.LocalDateTime; |
| | | import java.util.ArrayList; |
| | | import java.util.HashMap; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | @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); |
| | | } |
| | |
| | | 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); |