From 71093a08998b7e642ec859fa3ed45f75b4f92893 Mon Sep 17 00:00:00 2001 From: songhuangfeng123 <shf18767906695@163.com> Date: 星期三, 24 八月 2022 19:02:28 +0800 Subject: [PATCH] fix --- goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineMngServiceImpl.java | 104 +++++++++++++++++++++++++++++++++++++++++---------- 1 files changed, 83 insertions(+), 21 deletions(-) diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineMngServiceImpl.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineMngServiceImpl.java index fc4f62b..69fca26 100644 --- a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineMngServiceImpl.java +++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineMngServiceImpl.java @@ -1,15 +1,21 @@ package com.gkhy.safePlatform.targetDuty.service.impl; import com.alibaba.fastjson.JSONObject; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; 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.ExamineItem; +import com.gkhy.safePlatform.targetDuty.entity.ExamineTemplate; +import com.gkhy.safePlatform.targetDuty.entity.TargetMng; import com.gkhy.safePlatform.targetDuty.model.dto.resp.CurrentExamineDto; import com.gkhy.safePlatform.targetDuty.repository.ExamineItemRepository; import com.gkhy.safePlatform.targetDuty.repository.ExamineMngRepository; import com.gkhy.safePlatform.targetDuty.entity.ExamineMng; +import com.gkhy.safePlatform.targetDuty.repository.ExamineTemplateRepository; +import com.gkhy.safePlatform.targetDuty.service.CommonService; import com.gkhy.safePlatform.targetDuty.service.ExamineMngService; +import com.gkhy.safePlatform.targetDuty.service.ExamineTemplateService; import org.springframework.stereotype.Service; import org.springframework.beans.factory.annotation.Autowired; import com.gkhy.safePlatform.commons.enums.ResultCodes; @@ -22,9 +28,12 @@ import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; import org.springframework.util.StringUtils; +import javax.annotation.Resource; import java.io.Serializable; +import java.util.HashSet; import java.util.List; import java.util.Map; +import java.util.Set; import java.util.function.Function; import java.util.stream.Collectors; @@ -41,9 +50,14 @@ private ExamineMngRepository examineMngRepository; @Autowired private ExamineItemRepository examineItemRepository; - - - @Override + @Resource + private ExamineTemplateRepository examineTemplateRepository; + + @Resource + private CommonService commonService; + + + @Override public ResultVO queryAll(PageQuery<ExamineMngQueryCriteria> pageQuery) { Long pageIndex = pageQuery.getPageIndex(); Long pageSize = pageQuery.getPageSize(); @@ -52,14 +66,50 @@ page = baseMapper.selectPage(page, QueryHelpPlus.getPredicate(ExamineMng.class, pageQuery.getSearchParams())); List<ExamineMngDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), ExamineMngDto.class); - // TODO:获取考核部门名称 - // TODO:获取被考核部门名称 + // --------------------------- 获取部门信息----------------------- + //收集所用到的部门ID + Set<Long> collectDepIdSet = new HashSet(); + respList.forEach(f -> { + collectDepIdSet.add(f.getExamineDepartmentId()); + collectDepIdSet.add(f.getBeExaminedDepartmentId()); + }); + //获取部门名集合 + Map<Long, String> depNameMap = commonService.getDepName(collectDepIdSet); + + respList.forEach(f -> { + f.setExamineDepartmentName(depNameMap.get(f.getExamineDepartmentId())); + f.setBeExaminedDepartmentName(depNameMap.get(f.getBeExaminedDepartmentId())); + }); + + //获取打分明细 + respList.forEach(dto -> { + List<CurrentExamineDto> list = JSONObject.parseArray(dto.getNumberDetailJson(), CurrentExamineDto.class); + List<Long> idList = list.stream().map(CurrentExamineDto::getId).collect(Collectors.toList()); + + if (!idList.isEmpty()) { + List<ExamineItem> itemList = examineItemRepository.selectBatchIds(idList); + Map<Long, ExamineItem> itemMap = itemList.stream().collect( + Collectors.toMap(ExamineItem::getId, Function.identity(), (k1, k2) -> k1)); + + if (itemMap != null) { + list.forEach(f -> { + ExamineItem item = itemMap.get(f.getId()); + if (item != null) { + f.setItemDetail(item.getItemDetail()); + f.setContent(item.getContent()); + f.setJudgeStandard(item.getJudgeStandard()); + } + }); + } + } + dto.setCurrentExamineDtoList(list); + }); return new SearchResultVO<>( true, pageIndex, - pageSize,page.getPages(), + pageSize, page.getPages(), page.getTotal(), respList, ResultCodes.OK @@ -75,33 +125,45 @@ @Override public ExamineMngDto selectOne(Serializable id) { ExamineMng examineMng = this.getById(id); - if(examineMng == null){ + if (examineMng == null) { return null; } ExamineMngDto dto = BeanCopyUtils.copyBean(examineMng, ExamineMngDto.class); - if(!StringUtils.hasText(examineMng.getNumberDetailJson())){ + if (!StringUtils.hasText(examineMng.getNumberDetailJson())) { return dto; } //获取打分明细 - List<CurrentExamineDto> list = JSONObject.parseArray( examineMng.getNumberDetailJson(), CurrentExamineDto.class); + List<CurrentExamineDto> list = JSONObject.parseArray(examineMng.getNumberDetailJson(), CurrentExamineDto.class); List<Long> idList = list.stream().map(CurrentExamineDto::getId).collect(Collectors.toList()); - List<ExamineItem> itemList = examineItemRepository.selectBatchIds(idList); - Map<Long,ExamineItem> itemMap = itemList.stream().collect( - Collectors.toMap(ExamineItem::getId, Function.identity(),(k1, k2)->k1)); - if(itemMap != null){ - list.forEach(f->{ - ExamineItem item = itemMap.get(f.getId()); - if(item != null){ - f.setItemDetail(item.getItemDetail()); - f.setContent(item.getContent()); - } - }); + if (!idList.isEmpty()) { + List<ExamineItem> itemList = examineItemRepository.selectBatchIds(idList); + Map<Long, ExamineItem> itemMap = itemList.stream().collect( + Collectors.toMap(ExamineItem::getId, Function.identity(), (k1, k2) -> k1)); + + if (itemMap != null) { + list.forEach(f -> { + ExamineItem item = itemMap.get(f.getId()); + if (item != null) { + f.setItemDetail(item.getItemDetail()); + f.setContent(item.getContent()); + f.setJudgeStandard(item.getJudgeStandard()); + } + }); + } } dto.setCurrentExamineDtoList(list); + + //获取合格分数 + ExamineTemplate examineTemplate = examineTemplateRepository.selectOne(new QueryWrapper<ExamineTemplate>().eq("id", examineMng.getExamineTemplateId())); + if (examineTemplate != null) { + dto.setAcceptanceNumber(examineTemplate.getAcceptanceNumber()); + dto.setExamineTemplateName(examineTemplate.getTitle()); + } + return dto; } -} \ No newline at end of file +} -- Gitblit v1.9.2