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/RewardPunishmentDetailServiceImpl.java |   73 +++++++++++++++++++++++++++++++-----
 1 files changed, 63 insertions(+), 10 deletions(-)

diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/RewardPunishmentDetailServiceImpl.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/RewardPunishmentDetailServiceImpl.java
index 814f4f1..86ebf54 100644
--- a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/RewardPunishmentDetailServiceImpl.java
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/RewardPunishmentDetailServiceImpl.java
@@ -4,14 +4,21 @@
 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.utils.PageUtils;
 import com.gkhy.safePlatform.targetDuty.entity.ExamineMng;
 import com.gkhy.safePlatform.targetDuty.entity.ExamineTemplate;
 import com.gkhy.safePlatform.targetDuty.entity.RewardPunishmentStandard;
+import com.gkhy.safePlatform.targetDuty.excepiton.TargetDutyException;
 import com.gkhy.safePlatform.targetDuty.model.dto.resp.ExamineMngDto;
+import com.gkhy.safePlatform.targetDuty.model.dto.resp.RewardPunishmentDetailExcel;
 import com.gkhy.safePlatform.targetDuty.repository.RewardPunishmentDetailRepository;
 import com.gkhy.safePlatform.targetDuty.entity.RewardPunishmentDetail;
 import com.gkhy.safePlatform.targetDuty.repository.RewardPunishmentStandardRepository;
 import com.gkhy.safePlatform.targetDuty.service.RewardPunishmentDetailService;
+import com.gkhy.safePlatform.targetDuty.service.baseService.RewardPunishmentDetailBaseService;
+import com.gkhy.safePlatform.targetDuty.service.baseService.RewardPunishmentStandardBaseService;
+import com.gkhy.safePlatform.targetDuty.utils.DateUtils;
+import com.gkhy.safePlatform.targetDuty.utils.poihelper.ExcelUtil;
 import org.springframework.stereotype.Service;
 import org.springframework.beans.factory.annotation.Autowired;
 import com.gkhy.safePlatform.commons.enums.ResultCodes;
@@ -23,8 +30,11 @@
 import com.gkhy.safePlatform.targetDuty.utils.QueryHelpPlus;
 import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
 
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
 import java.io.Serializable;
-import java.util.List;
+import java.net.URLEncoder;
+import java.util.*;
 
 /**
  * 奖惩记录(RewardPunishmentDetail)表服务实现类
@@ -33,22 +43,25 @@
  * @since 2022-07-21 10:15:45
  */
 @Service("rewardPunishmentDetailService")
-public class RewardPunishmentDetailServiceImpl extends ServiceImpl<RewardPunishmentDetailRepository, RewardPunishmentDetail> implements RewardPunishmentDetailService {
+public class RewardPunishmentDetailServiceImpl implements RewardPunishmentDetailService {
 
     @Autowired
-    private RewardPunishmentDetailRepository rewardPunishmentDetailRepository;
+    private RewardPunishmentDetailBaseService rewardPunishmentDetailBaseService;
 
     @Autowired
-    private RewardPunishmentStandardRepository rewardPunishmentStandardRepository;
-    
+    private RewardPunishmentStandardBaseService rewardPunishmentStandardBaseService;
+
+    @Autowired
+    public HttpServletResponse response;
 	
 	@Override
     public ResultVO queryAll(PageQuery<RewardPunishmentDetailQueryCriteria> pageQuery) {
+        PageUtils.checkCheck(pageQuery);
         Long pageIndex = pageQuery.getPageIndex();
         Long pageSize = pageQuery.getPageSize();
         IPage<RewardPunishmentDetailDto> page = new Page<>(pageIndex, pageSize);
 
-        page = baseMapper.queryAll(page,
+        page = rewardPunishmentDetailBaseService.queryAll(page,
                 pageQuery.getSearchParams().getPersonId());
 //        List<RewardPunishmentDetailDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), RewardPunishmentDetailDto.class);
 
@@ -65,26 +78,66 @@
 
     @Override
     public List<RewardPunishmentDetail> queryAll(RewardPunishmentDetailQueryCriteria criteria) {
-        return baseMapper.selectList(QueryHelpPlus.getPredicate(RewardPunishmentDetail.class, criteria));
+        return rewardPunishmentDetailBaseService.queryAll( criteria);
     }
 
 
     @Override
     public List<RewardPunishmentDetail> queryAllRelation(RewardPunishmentDetailQueryCriteria criteria) {
-        return baseMapper.queryAll(criteria.getPersonId());
+        return rewardPunishmentDetailBaseService.queryAll(criteria.getPersonId());
     }
 
     @Override
     public RewardPunishmentDetailDto selectOne(Serializable id) {
-        RewardPunishmentDetail info = this.getById(id);
+        RewardPunishmentDetail info = rewardPunishmentDetailBaseService.getById(id);
         if(info == null){
             return null;
         }
 
         RewardPunishmentDetailDto dto = BeanCopyUtils.copyBean(info, RewardPunishmentDetailDto.class);
 
-        RewardPunishmentStandard standard = rewardPunishmentStandardRepository.selectOne(new QueryWrapper<RewardPunishmentStandard>().eq("id",dto.getRewardPunishmentStandardId()));
+        RewardPunishmentStandard standard = rewardPunishmentStandardBaseService.getOne(new QueryWrapper<RewardPunishmentStandard>().eq("id",dto.getRewardPunishmentStandardId()));
         dto.setRewardPunishmentStandardName(standard.getqName());
         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<RewardPunishmentDetail> delList = new ArrayList<>();
+        idList.forEach(f->{
+            RewardPunishmentDetail info = new RewardPunishmentDetail();
+            info.setDelFlag(1);
+            info.setId(f);
+            delList.add(info);
+        });
+        rewardPunishmentDetailBaseService.updateBatchById(delList);
+    }
+
+    @Override
+    public void exportData(RewardPunishmentDetailQueryCriteria queryCriteria) throws IOException {
+
+        Map<String,String> map = new LinkedHashMap<>();
+        map.put("1","奖惩日期");
+        map.put("2","奖惩类型");
+        map.put("3","被奖惩者");
+        map.put("4","奖惩内容");
+        map.put("5","奖惩依据");
+
+        String key = DateUtils.date2String(new Date(), DateUtils.PATTERN_ALLTIME_NOSIGN) ;
+        String fileName = URLEncoder.encode("奖惩记录"+key+".xls", "UTF-8");
+        response.setContentType("application/vnd.ms-excel");
+        response.setHeader("Content-Disposition", "attachment;filename=" + fileName + ".xlsx");
+        response.setHeader("Access-Control-Expose-Headers", "Content-Disposition");
+
+
+        List<RewardPunishmentDetailExcel> respList = BeanCopyUtils.copyBeanList(this.queryAllRelation(queryCriteria), RewardPunishmentDetailExcel.class);
+
+        ExcelUtil.exportExcel(map,respList , response.getOutputStream(),DateUtils.PATTERN_STANDARD);
+        response.getOutputStream().close();
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.2