| 
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -2,12 +2,15 @@ package com.epmet.datareport.controller.screen; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import cn.afterturn.easypoi.excel.ExcelExportUtil; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import cn.afterturn.easypoi.excel.entity.TemplateExportParams; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.alibaba.excel.EasyExcel; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.alibaba.excel.ExcelWriter; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.alibaba.excel.write.metadata.WriteSheet; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.annotation.LoginUser; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.NumConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.constant.StrConstant; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.dto.result.CustomerStaffInfoCacheResult; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.redis.common.CustomerStaffRedis; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.security.dto.TokenDto; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.ConvertUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.ExcelUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.utils.Result; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.commons.tools.validator.ValidatorUtils; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import com.epmet.datareport.service.evaluationindex.screen.ScreenProjectOrgDailyService; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -34,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import org.springframework.web.bind.annotation.*; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import javax.servlet.http.HttpServletResponse; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.io.InputStream; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.net.URLEncoder; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.ArrayList; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					import java.util.HashMap; | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -209,10 +213,9 @@ public class ScreenProjectController { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            e.setIndex(1); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            resultDTOList.addAll(ConvertUtils.sourceToTarget(e.getChildren(),ProjectCategoryResultDTO.class)); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        }); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String,Object> mapData = new HashMap<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("list",resultDTOList); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("orgName",staffInfo.getAgencyName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("orgName", formDTO.getOrgName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("exportDate",getExportDateStr(formDTO.getStartTime(),formDTO.getEndTime())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        response.setHeader("content-Type", "application/vnd.ms-excel"); | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
							
								
							
						
						
					 | 
				
				 | 
				
					@ -241,30 +244,56 @@ public class ScreenProjectController { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     * @date 2021/11/4 3:38 下午 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					     */ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @PostMapping("selectcategoryprojectlist/export") | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void selectProjectCategoryExport(@RequestBody CategoryProjectListFormDTO formDTO,@LoginUser TokenDto tokenDto, HttpServletResponse response) throws Exception { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //tokenDto.setUserId("36bc0fb38565ecdebf8ab9b476b44548");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        formDTO.setIsPage(false); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //formDTO.setStatus("all");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        //formDTO.setCategoryCode("0102");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.CategoryProjectExportForm.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        PageCategoryProjectListResultDTO data = screenProjectService.selectCategoryProjectList(formDTO,tokenDto); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        String templatePath = "excel/project_temp.xlsx"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    public void selectProjectCategoryExport(@RequestBody CategoryProjectListFormDTO formDTO, @LoginUser TokenDto tokenDto, HttpServletResponse response) throws Exception { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        ExcelWriter excelWriter = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        try { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //tokenDto.setUserId("36bc0fb38565ecdebf8ab9b476b44548");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            formDTO.setPageNo(NumConstant.ONE); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            formDTO.setPageSize(NumConstant.ONE_THOUSAND); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            formDTO.setIsPage(false); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.CategoryProjectExportForm.class); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        CustomerStaffInfoCacheResult staffInfo = CustomerStaffRedis.getStaffInfo(tokenDto.getCustomerId(), tokenDto.getUserId()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Map<String,Object> mapData = new HashMap<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("list",data.getList()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("orgName",staffInfo.getAgencyName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("exportDate",getExportDateStr(formDTO.getStartTime(),formDTO.getEndTime())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        mapData.put("categoryName", formDTO.getCategoryName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        if (StringUtils.isNotBlank(formDTO.getParentCategoryName())){ | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            mapData.put("categoryName", formDTO.getParentCategoryName().concat(StrConstant.HYPHEN).concat(formDTO.getCategoryName())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            Map<String, Object> mapData = new HashMap<>(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            mapData.put("orgName", formDTO.getOrgName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            mapData.put("exportDate", getExportDateStr(formDTO.getStartTime(), formDTO.getEndTime())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            mapData.put("categoryName", formDTO.getCategoryName()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (StringUtils.isNotBlank(formDTO.getParentCategoryName())) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                mapData.put("categoryName", formDTO.getParentCategoryName().concat(StrConstant.HYPHEN).concat(formDTO.getCategoryName())); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        response.setHeader("content-Type", "application/vnd.ms-excel"); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("项目统计.xls", "UTF-8")); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        workbook.write(response.getOutputStream()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String templatePath = "excel/project_temp_easy_excel.xlsx"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            InputStream inputStream = this.getClass().getClassLoader().getResourceAsStream(templatePath); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            //String template = this.getClass().getResource(templatePath).getPath();
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            String fileName = "项目统计.xlsx"; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            excelWriter = EasyExcel.write(ExcelUtils.getOutputStream(fileName, response)).withTemplate(inputStream).build(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            WriteSheet writeSheet = EasyExcel.writerSheet().build(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            excelWriter.fill(mapData, writeSheet); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            PageCategoryProjectListResultDTO data = null; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            do { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                data = screenProjectService.selectCategoryProjectList(formDTO, tokenDto); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                if (data.getList().isEmpty()) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                    break; | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                formDTO.setPageNo(formDTO.getPageNo() + 1); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                excelWriter.fill(data.getList(), writeSheet); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                data.getList().clear(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } while (data.getList().size() == formDTO.getPageSize()); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        String templatePath = "excel/project_temp.xlsx";
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        Workbook workbook = ExcelExportUtil.exportExcel(new TemplateExportParams(templatePath), mapData);
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        response.setHeader("content-Type", "application/vnd.ms-excel");
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        response.addHeader("Content-Disposition", "attachment;fileName=" + URLEncoder.encode("项目统计.xls", "UTF-8"));
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					//        workbook.write(response.getOutputStream());
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } finally { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            if (excelWriter != null) { | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					                excelWriter.finish(); | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					            } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					        } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    } | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					
 | 
				
			
			
		
	
		
			
				
					 | 
					 | 
				
				 | 
				
					    @NotNull | 
				
			
			
		
	
	
		
			
				
					| 
						
							
								
							
						
						
						
					 | 
				
				 | 
				
					
  |