| | |
| | | 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.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.service.ExamineMngService; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.gkhy.safePlatform.commons.enums.ResultCodes; |
| | | import com.gkhy.safePlatform.commons.query.PageQuery; |
| | | import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; |
| | | import com.gkhy.safePlatform.commons.utils.PageUtils; |
| | | import com.gkhy.safePlatform.commons.vo.ResultVO; |
| | | import com.gkhy.safePlatform.commons.vo.SearchResultVO; |
| | | import com.gkhy.safePlatform.targetDuty.entity.ExamineItem; |
| | | import com.gkhy.safePlatform.targetDuty.entity.ExamineMng; |
| | | import com.gkhy.safePlatform.targetDuty.entity.ExamineTemplate; |
| | | import com.gkhy.safePlatform.targetDuty.excepiton.TargetDutyException; |
| | | import com.gkhy.safePlatform.targetDuty.model.dto.req.ExamineMngQueryCriteria; |
| | | import com.gkhy.safePlatform.targetDuty.model.dto.resp.CurrentExamineDto; |
| | | import com.gkhy.safePlatform.targetDuty.model.dto.resp.ExamineMngDto; |
| | | import com.gkhy.safePlatform.targetDuty.service.CommonService; |
| | | import com.gkhy.safePlatform.targetDuty.service.ExamineMngService; |
| | | import com.gkhy.safePlatform.targetDuty.service.baseService.ExamineItemBaseService; |
| | | import com.gkhy.safePlatform.targetDuty.service.baseService.ExamineMngBaseService; |
| | | import com.gkhy.safePlatform.targetDuty.service.baseService.ExamineTemplateBaseService; |
| | | import com.gkhy.safePlatform.targetDuty.utils.QueryHelpPlus; |
| | | import com.gkhy.safePlatform.commons.utils.BeanCopyUtils; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.util.StringUtils; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.io.Serializable; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.*; |
| | | import java.util.function.Function; |
| | | import java.util.stream.Collectors; |
| | | |
| | |
| | | * @since 2022-07-21 13:43:08 |
| | | */ |
| | | @Service("examineMngService") |
| | | public class ExamineMngServiceImpl extends ServiceImpl<ExamineMngRepository, ExamineMng> implements ExamineMngService { |
| | | public class ExamineMngServiceImpl implements ExamineMngService { |
| | | |
| | | @Autowired |
| | | private ExamineMngRepository examineMngRepository; |
| | | private ExamineMngBaseService examineMngBaseService; |
| | | @Autowired |
| | | private ExamineItemRepository examineItemRepository; |
| | | private ExamineItemBaseService examineItemBaseService; |
| | | @Resource |
| | | private ExamineTemplateBaseService examineTemplateBaseService; |
| | | |
| | | @Resource |
| | | private CommonService commonService; |
| | | |
| | | |
| | | @Override |
| | | public ResultVO queryAll(PageQuery<ExamineMngQueryCriteria> pageQuery) { |
| | | PageUtils.checkCheck(pageQuery); |
| | | Long pageIndex = pageQuery.getPageIndex(); |
| | | Long pageSize = pageQuery.getPageSize(); |
| | | IPage<ExamineMng> page = new Page<>(pageIndex, pageSize); |
| | | |
| | | page = baseMapper.selectPage(page, |
| | | page = examineMngBaseService.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 = examineItemBaseService.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, |
| | |
| | | |
| | | @Override |
| | | public List<ExamineMng> queryAll(ExamineMngQueryCriteria criteria) { |
| | | return baseMapper.selectList(QueryHelpPlus.getPredicate(ExamineMng.class, criteria)); |
| | | return examineMngBaseService.queryAll(criteria); |
| | | } |
| | | |
| | | @Override |
| | | public ExamineMngDto selectOne(Serializable id) { |
| | | ExamineMng examineMng = this.getById(id); |
| | | ExamineMng examineMng = examineMngBaseService.getById(id); |
| | | if(examineMng == null){ |
| | | return null; |
| | | } |
| | |
| | | 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(!idList.isEmpty()) { |
| | | List<ExamineItem> itemList = examineItemBaseService.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 (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 = examineTemplateBaseService.getOne(new QueryWrapper<ExamineTemplate>().eq("id",examineMng.getExamineTemplateId())); |
| | | if(examineTemplate != null){ |
| | | dto.setAcceptanceNumber(examineTemplate.getAcceptanceNumber()); |
| | | dto.setExamineTemplateName(examineTemplate.getTitle()); |
| | | } |
| | | |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | public void delete(Long[] ids) { |
| | | if(ids == null){ |
| | | throw new TargetDutyException(ResultCodes.CLIENT_PARAM_ILLEGAL); |
| | | } |
| | | List<Long> idList = Arrays.asList(ids); |
| | | |
| | | List<ExamineMng> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | ExamineMng info = new ExamineMng(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | examineMngBaseService.updateBatchById(delList); |
| | | } |
| | | } |