| | |
| | | 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.commons.co.ContextCacheUser; |
| | | import com.gkhy.safePlatform.targetDuty.entity.ExamineItem; |
| | | import com.gkhy.safePlatform.targetDuty.entity.TargetDivideDetail; |
| | | import com.gkhy.safePlatform.targetDuty.entity.TargetMng; |
| | |
| | | import com.gkhy.safePlatform.targetDuty.service.CommonService; |
| | | import com.gkhy.safePlatform.targetDuty.service.ExamineItemService; |
| | | import com.gkhy.safePlatform.targetDuty.service.ExamineTemplateService; |
| | | import com.gkhy.safePlatform.targetDuty.service.baseService.ExamineItemBaseService; |
| | | import com.gkhy.safePlatform.targetDuty.service.baseService.ExamineTemplateBaseService; |
| | | import org.springframework.security.core.Authentication; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import com.gkhy.safePlatform.commons.enums.ResultCodes; |
| | |
| | | * @since 2022-07-21 10:58:10 |
| | | */ |
| | | @Service("examineTemplateService") |
| | | public class ExamineTemplateServiceImpl extends ServiceImpl<ExamineTemplateRepository, ExamineTemplate> implements ExamineTemplateService { |
| | | public class ExamineTemplateServiceImpl implements ExamineTemplateService { |
| | | |
| | | @Autowired |
| | | private ExamineTemplateRepository examineTemplateRepository; |
| | | private ExamineTemplateBaseService examineTemplateBaseService; |
| | | |
| | | @Autowired |
| | | private ExamineItemRepository examineItemRepository; |
| | | |
| | | @Autowired |
| | | private ExamineItemService examineItemService; |
| | | private ExamineItemBaseService examineItemBaseService; |
| | | |
| | | @Resource |
| | | private CommonService commonService; |
| | |
| | | Long pageSize = pageQuery.getPageSize(); |
| | | IPage<ExamineTemplate> page = new Page<>(pageIndex, pageSize); |
| | | |
| | | page = baseMapper.selectPage(page, |
| | | page = examineTemplateBaseService.selectPage(page, |
| | | QueryHelpPlus.getPredicate(ExamineTemplate.class, pageQuery.getSearchParams())); |
| | | List<ExamineTemplateDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), ExamineTemplateDto.class); |
| | | |
| | |
| | | |
| | | //获取考核项目明细 |
| | | respList.forEach(f->{ |
| | | List<ExamineItem> list = examineItemRepository.selectList(new QueryWrapper<ExamineItem>().eq("examine_template_id",f.getId())); |
| | | List<ExamineItem> list = examineItemBaseService.selectList(new QueryWrapper<ExamineItem>().eq("examine_template_id",f.getId())); |
| | | f.setExamineItemList(list); |
| | | }); |
| | | |
| | |
| | | |
| | | @Override |
| | | public List<ExamineTemplate> queryAll(ExamineTemplateQueryCriteria criteria) { |
| | | return baseMapper.selectList(QueryHelpPlus.getPredicate(ExamineTemplate.class, criteria)); |
| | | return examineTemplateBaseService.queryAll(criteria); |
| | | } |
| | | |
| | | @Override |
| | | public ExamineTemplateDto selectOne(Serializable id) { |
| | | ExamineTemplate template = this.getById(id); |
| | | ExamineTemplate template = examineTemplateBaseService.getById(id); |
| | | if(template == null){ |
| | | return null; |
| | | } |
| | | |
| | | ExamineTemplateDto dto = BeanCopyUtils.copyBean(template, ExamineTemplateDto.class); |
| | | |
| | | List<ExamineItem> list = examineItemRepository.selectList(new QueryWrapper<ExamineItem>().eq("examine_template_id",template.getId())); |
| | | List<ExamineItem> list = examineItemBaseService.selectList(new QueryWrapper<ExamineItem>().eq("examine_template_id",template.getId())); |
| | | dto.setExamineItemList(list); |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | public void addOrUpdate(ExamineTemplateSaveOrUpdate infoDto) { |
| | | public void addOrUpdate(ExamineTemplateSaveOrUpdate infoDto, Authentication authentication) { |
| | | if(!StringUtils.hasText(infoDto.getTitle())){ |
| | | throw new TargetDutyException("缺少title"); |
| | | } |
| | | // 获取当前用户 |
| | | ContextCacheUser currentUser = (ContextCacheUser) authentication.getPrincipal(); |
| | | |
| | | //设置设定人ID和设定人部门ID |
| | | infoDto.setSetPersonDepartmentId(currentUser.getDepId()); |
| | | infoDto.setSetPersonId(currentUser.getUid()); |
| | | |
| | | if(StringUtils.hasText(infoDto.getDelExamineItems())){ |
| | | List<Long> idList = Arrays.stream(infoDto.getDelExamineItems().split(",")).map(s-> Long.parseLong(s.trim())) |
| | | .collect(Collectors.toList()); |
| | |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | examineItemService.updateBatchById(delList); |
| | | examineItemBaseService.updateBatchById(delList); |
| | | } |
| | | |
| | | ExamineTemplate examineTemplate = BeanCopyUtils.copyBean(infoDto, ExamineTemplate.class); |
| | | examineTemplate.setSetTimem(new Timestamp(new java.util.Date().getTime())); |
| | | if (infoDto.getId() == null) { |
| | | this.save(examineTemplate); |
| | | examineTemplateBaseService.save(examineTemplate); |
| | | } else { |
| | | this.update(examineTemplate,new UpdateWrapper<ExamineTemplate>().eq("id",examineTemplate.getId())); |
| | | examineTemplateBaseService.update(examineTemplate,new UpdateWrapper<ExamineTemplate>().eq("id",examineTemplate.getId())); |
| | | } |
| | | |
| | | List<ExamineItem> list = infoDto.getExamineItemList(); |
| | | list.forEach(f->{f.setExamineTemplateId(infoDto.getId());}); |
| | | examineItemService.saveOrUpdateBatch(list); |
| | | examineItemBaseService.saveOrUpdateBatch(list); |
| | | |
| | | } |
| | | |
| | | @Override |
| | | public void delete(Long[] ids) { |
| | | if(ids == null){ |
| | | throw new TargetDutyException(ResultCodes.CLIENT_PARAM_ILLEGAL); |
| | | } |
| | | List<Long> idList = Arrays.asList(ids); |
| | | |
| | | List<ExamineTemplate> delList = new ArrayList<>(); |
| | | idList.forEach(f->{ |
| | | ExamineTemplate info = new ExamineTemplate(); |
| | | info.setDelFlag(1); |
| | | info.setId(f); |
| | | delList.add(info); |
| | | }); |
| | | examineTemplateBaseService.updateBatchById(delList); |
| | | } |
| | | } |