From 1305d0aa469fe7330fd2f8e9fbb10d95042571be Mon Sep 17 00:00:00 2001
From: zhangfeng <1603559716@qq.com>
Date: 星期一, 10 十月 2022 12:33:36 +0800
Subject: [PATCH] 应急系统和事故管理统计接口
---
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineTemplateServiceImpl.java | 91 ++++++++++++++++++++++++++++++++++++---------
1 files changed, 73 insertions(+), 18 deletions(-)
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineTemplateServiceImpl.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineTemplateServiceImpl.java
index 009f89a..f5869ba 100644
--- a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineTemplateServiceImpl.java
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineTemplateServiceImpl.java
@@ -5,6 +5,7 @@
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;
@@ -14,8 +15,12 @@
import com.gkhy.safePlatform.targetDuty.repository.ExamineItemRepository;
import com.gkhy.safePlatform.targetDuty.repository.ExamineTemplateRepository;
import com.gkhy.safePlatform.targetDuty.entity.ExamineTemplate;
+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;
@@ -28,11 +33,10 @@
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
import org.springframework.util.StringUtils;
+import javax.annotation.Resource;
import java.io.Serializable;
import java.sql.Timestamp;
-import java.util.Arrays;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
import java.util.stream.Collectors;
/**
@@ -42,16 +46,16 @@
* @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;
+ private ExamineItemBaseService examineItemBaseService;
- @Autowired
- private ExamineItemService examineItemService;
+ @Resource
+ private CommonService commonService;
@Override
@@ -60,11 +64,28 @@
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);
- // TODO:获取设定人部门名称
+ // --------------------------- 获取部门信息-----------------------
+ //收集所用到的部门ID
+ Set<Long> collectDepIdSet = new HashSet();
+ respList.forEach(f->{
+ collectDepIdSet.add(f.getSetPersonDepartmentId());
+ });
+ //获取部门名集合
+ Map<Long,String> depNameMap = commonService.getDepName(collectDepIdSet);
+
+ respList.forEach(f->{
+ f.setSetPersonDepartmentName(depNameMap.get(f.getSetPersonDepartmentId()));
+ });
+
+ //获取考核项目明细
+ respList.forEach(f->{
+ List<ExamineItem> list = examineItemBaseService.selectList(new QueryWrapper<ExamineItem>().eq("examine_template_id",f.getId()));
+ f.setExamineItemList(list);
+ });
return new SearchResultVO<>(
@@ -80,42 +101,76 @@
@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());
- examineItemService.removeByIds(idList);
+ List<ExamineItem> delList = new ArrayList<>();
+ idList.forEach(f->{
+ ExamineItem info = new ExamineItem();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+ 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);
+ }
}
\ No newline at end of file
--
Gitblit v1.9.2