songhuangfeng123
2022-09-08 bfb4c1e1d4e3f99f74a51ef5b67531f9d91d0dde
goal-manage/goal-manage-service/src/main/java/com/gkhy/safePlatform/targetDuty/controller/TargetDutySummaryController.java
@@ -13,6 +13,7 @@
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.service.baseService.TargetDutySummaryBaseService;
import com.gkhy.safePlatform.targetDuty.utils.DateUtils;
import com.gkhy.safePlatform.targetDuty.utils.poihelper.ExcelUtil;
import org.springframework.beans.factory.annotation.Autowired;
@@ -45,6 +46,9 @@
    @Resource
    private TargetDutySummaryService targetDutySummaryService;
    @Resource
    private TargetDutySummaryBaseService targetDutySummaryBaseService;
    @Autowired
    public HttpServletRequest request;
@@ -72,7 +76,7 @@
     */
    @GetMapping(value = "/selectOne/{id}")
    public ResultVO selectOne(@PathVariable Serializable id) {
        return new ResultVO<>(ResultCodes.OK,this.targetDutySummaryService.getById(id));
        return new ResultVO<>(ResultCodes.OK,this.targetDutySummaryBaseService.getById(id));
    }
   /**
@@ -84,9 +88,9 @@
    @PostMapping(value = "/addOrUpdate")
    public ResultVO update(@RequestBody TargetDutySummary targetDutySummary) {
        if (targetDutySummary.getId() == null) {
            return new ResultVO<>(ResultCodes.OK,targetDutySummaryService.save(targetDutySummary));
            return new ResultVO<>(ResultCodes.OK,targetDutySummaryBaseService.save(targetDutySummary));
        } else {
            targetDutySummaryService.update(targetDutySummary,new UpdateWrapper<TargetDutySummary>().eq("id",targetDutySummary.getId()));
            targetDutySummaryBaseService.update(targetDutySummary,new UpdateWrapper<TargetDutySummary>().eq("id",targetDutySummary.getId()));
            return new ResultVO<>(ResultCodes.OK);
        }
    }
@@ -99,19 +103,7 @@
     */
    @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);
        List<TargetDutySummary> delList = new ArrayList<>();
        idList.forEach(f->{
            TargetDutySummary info = new TargetDutySummary();
            info.setDelFlag(1);
            info.setId(f);
            delList.add(info);
        });
        this.targetDutySummaryService.updateBatchById(delList);
        this.targetDutySummaryService.delete(ids);
        return new ResultVO<>(ResultCodes.OK);
    }
@@ -121,35 +113,7 @@
     */
    @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();
        targetDutySummaryService.exportData(queryCriteria);
    }
    public static void main(String[] args) {