| | |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import com.gkhy.safePlatform.targetDuty.entity.TargetMng; |
| | | import com.gkhy.safePlatform.targetDuty.entity.TargetType; |
| | | import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetDivideDetailQueryCriteria; |
| | | import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetExamineSaveOrUpdate; |
| | | import com.gkhy.safePlatform.targetDuty.model.dto.resp.TargetDivideDetailDto; |
| | | import com.gkhy.safePlatform.targetDuty.model.dto.resp.TargetMngDto; |
| | | import com.gkhy.safePlatform.targetDuty.repository.TargetExamineRepository; |
| | | import com.gkhy.safePlatform.targetDuty.entity.TargetExamine; |
| | | import com.gkhy.safePlatform.targetDuty.repository.TargetMngRepository; |
| | | import com.gkhy.safePlatform.targetDuty.repository.TargetTypeRepository; |
| | | import com.gkhy.safePlatform.targetDuty.service.CommonService; |
| | | import com.gkhy.safePlatform.targetDuty.service.TargetDivideDetailService; |
| | | import com.gkhy.safePlatform.targetDuty.service.TargetExamineService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import java.util.Arrays; |
| | | import java.util.List; |
| | | import javax.annotation.Resource; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | |
| | | /** |
| | |
| | | |
| | | @Autowired |
| | | private TargetExamineRepository targetExamineRepository; |
| | | |
| | | |
| | | |
| | | @Override |
| | | |
| | | @Autowired |
| | | private TargetMngRepository targetMngRepository; |
| | | @Resource |
| | | private CommonService commonService; |
| | | |
| | | @Resource |
| | | private TargetDivideDetailService targetDivideDetailService; |
| | | |
| | | @Autowired |
| | | private TargetTypeRepository targetTypeRepository; |
| | | |
| | | @Override |
| | | public ResultVO queryAll(PageQuery<TargetExamineQueryCriteria> pageQuery) { |
| | | Long pageIndex = pageQuery.getPageIndex(); |
| | | Long pageSize = pageQuery.getPageSize(); |
| | | IPage<TargetExamine> page = new Page<>(pageIndex, pageSize); |
| | | IPage<TargetMng> page = new Page<>(pageIndex, pageSize); |
| | | |
| | | page = baseMapper.selectPage(page, |
| | | QueryHelpPlus.getPredicate(TargetExamine.class, pageQuery.getSearchParams())); |
| | | page = targetMngRepository.selectPage(page, |
| | | QueryHelpPlus.getPredicate(TargetMng.class, pageQuery.getSearchParams())); |
| | | List<TargetExamineDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), TargetExamineDto.class); |
| | | respList.forEach(dto->{ |
| | | //查询关联分解信息 |
| | | TargetDivideDetailQueryCriteria criteria = new TargetDivideDetailQueryCriteria(); |
| | | criteria.setTargetId(dto.getId()); |
| | | List<TargetDivideDetailDto> respList1 = BeanCopyUtils.copyBeanList(targetDivideDetailService.queryAll(criteria), TargetDivideDetailDto.class); |
| | | |
| | | // --------------------------- 获取部门信息----------------------- |
| | | //收集所用到的部门ID |
| | | Set<Long> collectDepIdSet = new HashSet(); |
| | | respList1.forEach(f->{ |
| | | collectDepIdSet.add(f.getDutyDepartmentId()); |
| | | collectDepIdSet.add(f.getMakerDepartmentId()); |
| | | }); |
| | | //获取部门名集合 |
| | | Map<Long,String> depNameMap = commonService.getDepName(collectDepIdSet); |
| | | |
| | | respList1.forEach(f->{ |
| | | f.setDutyDepartmentName(depNameMap.get(f.getDutyDepartmentId())); |
| | | f.setMakerDepartmentName(depNameMap.get(f.getMakerDepartmentId())); |
| | | }); |
| | | |
| | | |
| | | // --------------------------- 获取目标分类名称----------------------- |
| | | //收集所用到的目标分类ID |
| | | Set<Long> collectTypeSet = new HashSet(); |
| | | respList1.forEach(f->{ |
| | | collectTypeSet.add(f.getTargetTypeId()); |
| | | }); |
| | | //获取目标分类名集合 |
| | | if(!collectTypeSet.isEmpty()){ |
| | | List<TargetType> typeList = targetTypeRepository.selectBatchIds(collectTypeSet); // TODO |
| | | Map<Long,String> typeNameMap = typeList.stream() |
| | | .collect(Collectors.toMap(TargetType::getId, TargetType::getTypeName,(k1, k2)->k1)); |
| | | |
| | | respList1.forEach(f->{ |
| | | f.setTargetTypeName(typeNameMap.get(f.getTargetTypeId())); |
| | | }); |
| | | } |
| | | |
| | | |
| | | // --------------------------- 获取考核结果----------------------- |
| | | //收集所用到的分解详情ID |
| | | Set<Long> collectExamResultSet = new HashSet(); |
| | | respList1.forEach(f->{ |
| | | collectExamResultSet.add(f.getId()); |
| | | }); |
| | | //获取核结果集合 |
| | | if(!collectTypeSet.isEmpty()){ |
| | | List<TargetExamine> typeList = targetExamineRepository.selectBatchIds(collectTypeSet); |
| | | Map<Long,Integer> examResultMap = typeList.stream() |
| | | .collect(Collectors.toMap(TargetExamine::getId, TargetExamine::getExamineResult,(k1, k2)->k1)); |
| | | |
| | | respList1.forEach(f->{ |
| | | f.setExamineResult(examResultMap.get(f.getId())); |
| | | }); |
| | | } |
| | | |
| | | |
| | | dto.setTargetDivideDetailList(respList1); |
| | | }); |
| | | |
| | | return new SearchResultVO<>( |
| | | true, |
| | | pageIndex, |
| | | pageSize, |
| | | pageSize,page.getPages(), |
| | | page.getTotal(), |
| | | respList, |
| | | ResultCodes.OK |
| | |
| | | return baseMapper.selectList(QueryHelpPlus.getPredicate(TargetExamine.class, criteria)); |
| | | } |
| | | |
| | | @Override |
| | | public void addOrUpdate(TargetExamineSaveOrUpdate infoDto) { |
| | | |
| | | |
| | | if(StringUtils.hasText(infoDto.getDelIds())) { |
| | | List<Long> idList = Arrays.stream(infoDto.getDelIds().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | | this.removeByIds(idList); |
| | | } |
| | | |
| | | infoDto.getExamineList().forEach(f->{ |
| | | f.setTargetId(infoDto.getId()); |
| | | }); |
| | | this.saveOrUpdateBatch(infoDto.getExamineList()); |
| | | } |
| | | // @Override |
| | | // public void addOrUpdate(TargetExamineSaveOrUpdate infoDto) { |
| | | // |
| | | // |
| | | // if(StringUtils.hasText(infoDto.getDelIds())) { |
| | | // List<Long> idList = Arrays.stream(infoDto.getDelIds().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | // .collect(Collectors.toList()); |
| | | // this.removeByIds(idList); |
| | | // } |
| | | // |
| | | // infoDto.getExamineList().forEach(f->{ |
| | | // f.setTargetId(infoDto.getId()); |
| | | // }); |
| | | // this.saveOrUpdateBatch(infoDto.getExamineList()); |
| | | // } |
| | | } |