songhuangfeng123
2022-08-18 233fb69fa9d1694e97337d74fa3da72cacda04c1
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetDutySummaryController.java
@@ -1,15 +1,21 @@
package com.gkhy.safePlatform.targetDuty.controller;
import java.util.Date;
import java.io.IOException;
import java.net.URLEncoder;
import java.util.*;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gkhy.safePlatform.commons.utils.BeanCopyUtils;
import com.gkhy.safePlatform.targetDuty.entity.TargetDutySummary;
import com.gkhy.safePlatform.targetDuty.entity.TargetMng;
import com.gkhy.safePlatform.targetDuty.model.dto.resp.TargetDutySummaryExcel;
import com.gkhy.safePlatform.targetDuty.service.TargetDutySummaryService;
import com.gkhy.safePlatform.targetDuty.utils.DateUtils;
import com.gkhy.safePlatform.targetDuty.utils.poihelper.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.gkhy.safePlatform.commons.query.PageQuery;
import com.gkhy.safePlatform.commons.utils.PageUtils;
@@ -18,11 +24,11 @@
import com.gkhy.safePlatform.targetDuty.model.dto.req.TargetDutySummaryQueryCriteria;
import java.sql.Timestamp;
import java.util.Arrays;
import java.util.stream.Collectors;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.Serializable;
import java.util.List;
/**
 * (TargetDutySummary)表控制层
@@ -39,6 +45,12 @@
    @Resource
    private TargetDutySummaryService targetDutySummaryService;
    @Autowired
    public HttpServletRequest request;
    @Autowired
    public HttpServletResponse response;
    /**
     * 分页查询所有数据
     *
@@ -47,7 +59,7 @@
     */
    @PostMapping(value = "/page/list")
    public ResultVO selectAll(@RequestBody PageQuery<TargetDutySummaryQueryCriteria> pageQuery){
      PageUtils.checkCheck(pageQuery.getPageIndex(), pageQuery.getPageSize());
        PageUtils.checkCheck(pageQuery);
      return this.targetDutySummaryService.queryAll(pageQuery);
    }
   
@@ -85,12 +97,51 @@
     * @param ids 主键结合
     * @return 删除结果
     */
    @GetMapping(value = "/delete")
    public ResultVO delete(String ids) {
   List<String> idList = Arrays.stream(ids.split(","))
                .collect(Collectors.toList());
    @RequestMapping(value = "/delete",method = RequestMethod.POST)
    public ResultVO delete(@RequestBody Long[] ids) {
        if(ids == null){
            return new ResultVO<>(ResultCodes.CLIENT_PARAM_ILLEGAL);
        }
        List<Long> idList = Arrays.asList(ids);
        this.targetDutySummaryService.removeByIds(idList);
        return new ResultVO<>(ResultCodes.OK);
    }
    /**
     * 导出一览数据
     *
     */
    @GetMapping(value = "/exportData")
    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(targetDutySummaryService.queryAll(queryCriteria), TargetDutySummaryExcel.class);
        ExcelUtil.exportExcel(map,respList , response.getOutputStream(),DateUtils.PATTERN_STANDARD);
        response.getOutputStream().close();
    }
    public static void main(String[] args) {
@@ -102,7 +153,6 @@
        mng.setExamineResult(1);
        mng.setYiYue("1");
        mng.setFebruary("2");
        mng.setErYue("3");
        mng.setSanYue("4");
        mng.setSiYue("5");