From bfb4c1e1d4e3f99f74a51ef5b67531f9d91d0dde Mon Sep 17 00:00:00 2001
From: songhuangfeng123 <shf18767906695@163.com>
Date: 星期四, 08 九月 2022 09:13:38 +0800
Subject: [PATCH] 目标fix

---
 goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/ExamineTemplateServiceImpl.java |   60 ++++++++++++++++++++++++++++++++++++++++++++----------------
 1 files changed, 44 insertions(+), 16 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 e47e4e8..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;
@@ -17,6 +18,9 @@
 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;
@@ -42,16 +46,13 @@
  * @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;
@@ -63,7 +64,7 @@
         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);
 
@@ -82,7 +83,7 @@
 
         //获取考核项目明细
         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);
         });
 
@@ -100,25 +101,35 @@
 
     @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());
@@ -129,20 +140,37 @@
                 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);
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.2