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/TargetDutySummaryServiceImpl.java | 76 +++++++++++++++++++++++++++++++++----
1 files changed, 67 insertions(+), 9 deletions(-)
diff --git a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/TargetDutySummaryServiceImpl.java b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/TargetDutySummaryServiceImpl.java
index 0a4a01f..75f57d9 100644
--- a/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/TargetDutySummaryServiceImpl.java
+++ b/goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/service/impl/TargetDutySummaryServiceImpl.java
@@ -3,10 +3,15 @@
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.excepiton.TargetDutyException;
+import com.gkhy.safePlatform.targetDuty.model.dto.resp.TargetDutySummaryExcel;
import com.gkhy.safePlatform.targetDuty.repository.TargetDutySummaryRepository;
import com.gkhy.safePlatform.targetDuty.entity.TargetDutySummary;
import com.gkhy.safePlatform.targetDuty.service.CommonService;
import com.gkhy.safePlatform.targetDuty.service.TargetDutySummaryService;
+import com.gkhy.safePlatform.targetDuty.service.baseService.TargetDutySummaryBaseService;
+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;
@@ -19,10 +24,10 @@
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
import javax.annotation.Resource;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.*;
/**
* (TargetDutySummary)表服务实现类
@@ -31,14 +36,16 @@
* @since 2022-07-21 15:35:14
*/
@Service("targetDutySummaryService")
-public class TargetDutySummaryServiceImpl extends ServiceImpl<TargetDutySummaryRepository, TargetDutySummary> implements TargetDutySummaryService {
+public class TargetDutySummaryServiceImpl implements TargetDutySummaryService {
@Autowired
- private TargetDutySummaryRepository targetDutySummaryRepository;
+ private TargetDutySummaryBaseService targetDutySummaryBaseService;
@Resource
private CommonService commonService;
-
+
+ @Autowired
+ public HttpServletResponse response;
@Override
public ResultVO queryAll(PageQuery<TargetDutySummaryQueryCriteria> pageQuery) {
@@ -46,7 +53,7 @@
Long pageSize = pageQuery.getPageSize();
IPage<TargetDutySummary> page = new Page<>(pageIndex, pageSize);
- page = baseMapper.selectPage(page,
+ page = targetDutySummaryBaseService.selectPage(page,
QueryHelpPlus.getPredicate(TargetDutySummary.class, pageQuery.getSearchParams()));
List<TargetDutySummaryDto> respList = BeanCopyUtils.copyBeanList(page.getRecords(), TargetDutySummaryDto.class);
@@ -76,6 +83,57 @@
@Override
public List<TargetDutySummary> queryAll(TargetDutySummaryQueryCriteria criteria) {
- return baseMapper.selectList(QueryHelpPlus.getPredicate(TargetDutySummary.class, criteria));
+ return targetDutySummaryBaseService.queryAll( criteria);
+ }
+
+ @Override
+ public void delete(Long[] ids) {
+ if(ids == null){
+ throw new TargetDutyException(ResultCodes.CLIENT_PARAM_ILLEGAL);
+ }
+ List<Long> idList = Arrays.asList(ids);
+
+ List<TargetDutySummary> delList = new ArrayList<>();
+ idList.forEach(f->{
+ TargetDutySummary info = new TargetDutySummary();
+ info.setDelFlag(1);
+ info.setId(f);
+ delList.add(info);
+ });
+ targetDutySummaryBaseService.updateBatchById(delList);
+ }
+
+ @Override
+ public void exportData(TargetDutySummaryQueryCriteria queryCriteria) throws IOException {
+
+ Map<String,String> map = new LinkedHashMap<>();
+ map.put("1","责任部门");
+ map.put("2","安全目标指标");
+ map.put("3","考核指标");
+ map.put("4","1月");
+ map.put("5","2月");
+ map.put("6","3月");
+ map.put("7","4月");
+ map.put("8","5月");
+ map.put("9","6月");
+ map.put("10","7月");
+ map.put("11","8月");
+ map.put("12","9月");
+ map.put("13","10月");
+ map.put("14","11月");
+ map.put("15","12月");
+ map.put("16","考核结果");
+
+ 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<TargetDutySummaryExcel> respList = BeanCopyUtils.copyBeanList(this.queryAll(queryCriteria), TargetDutySummaryExcel.class);
+
+ ExcelUtil.exportExcel(map,respList , response.getOutputStream(),DateUtils.PATTERN_STANDARD);
+ response.getOutputStream().close();
}
}
\ No newline at end of file
--
Gitblit v1.9.2