| | |
| | | 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; |
| | |
| | | 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)表控制层 |
| | |
| | | */ |
| | | @Resource |
| | | private TargetDutySummaryService targetDutySummaryService; |
| | | |
| | | @Autowired |
| | | public HttpServletRequest request; |
| | | |
| | | @Autowired |
| | | public HttpServletResponse response; |
| | | |
| | | /** |
| | | * 分页查询所有数据 |
| | |
| | | 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) { |
| | | TargetDutySummary mng = new TargetDutySummary(); |
| | | mng.setYear("2020"); |
| | |
| | | mng.setExamineResult(1); |
| | | |
| | | mng.setYiYue("1"); |
| | | mng.setFebruary("2"); |
| | | mng.setErYue("3"); |
| | | mng.setSanYue("4"); |
| | | mng.setSiYue("5"); |