|
|
@ -1,7 +1,13 @@ |
|
|
|
package com.epmet.datareport.controller.screen; |
|
|
|
|
|
|
|
import cn.afterturn.easypoi.excel.ExcelExportUtil; |
|
|
|
import cn.afterturn.easypoi.excel.entity.TemplateExportParams; |
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
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.Result; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.datareport.service.evaluationindex.screen.ScreenProjectOrgDailyService; |
|
|
@ -17,15 +23,21 @@ import com.epmet.evaluationindex.screen.dto.result.ScreenProjectDistributionResu |
|
|
|
import com.epmet.project.dto.form.CategoryProjectListFormDTO; |
|
|
|
import com.epmet.project.dto.form.CategoryTopAppealFormDTO; |
|
|
|
import com.epmet.project.dto.form.ProjectCategoryFormDTO; |
|
|
|
import com.epmet.project.dto.result.CategoryProjectListResultDTO; |
|
|
|
import com.epmet.project.dto.result.CategoryTopAppealResultDTO; |
|
|
|
import com.epmet.project.dto.result.PageCategoryProjectListResultDTO; |
|
|
|
import com.epmet.project.dto.result.ProjectCategoryResultDTO; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.apache.poi.ss.usermodel.Workbook; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
|
* 项目 |
|
|
@ -175,6 +187,44 @@ public class ScreenProjectController { |
|
|
|
ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.ProjectCategoryForm.class); |
|
|
|
return new Result<List<ProjectCategoryResultDTO>>().ok(screenProjectService.selectProjectCategory(formDTO,tokenDto)); |
|
|
|
} |
|
|
|
/** |
|
|
|
* @Description 【项目分类】查询项目分类 |
|
|
|
* @param formDTO |
|
|
|
* @param tokenDto |
|
|
|
* @author zxc |
|
|
|
* @date 2021/11/4 3:38 下午 |
|
|
|
*/ |
|
|
|
@PostMapping("selectprojectcategory/export") |
|
|
|
public void selectProjectCategoryExport(@RequestBody ProjectCategoryFormDTO formDTO, /*@LoginUser*/ TokenDto tokenDto, HttpServletResponse response) throws Exception { |
|
|
|
tokenDto.setUserId("36bc0fb38565ecdebf8ab9b476b44548"); |
|
|
|
tokenDto.setCustomerId("45687aa479955f9d06204d415238f7cc"); |
|
|
|
ValidatorUtils.validateEntity(formDTO, ProjectCategoryFormDTO.ProjectCategoryForm.class); |
|
|
|
List<ProjectCategoryResultDTO> data = screenProjectService.selectProjectCategory(formDTO, tokenDto); |
|
|
|
String templatePath = "excel/project_category_temp.xlsx"; |
|
|
|
|
|
|
|
StringBuilder dateBuilder = new StringBuilder(); |
|
|
|
if (StringUtils.isNotBlank(formDTO.getStartTime())){ |
|
|
|
dateBuilder.append(formDTO.getStartTime()).append(StrConstant.HYPHEN); |
|
|
|
} |
|
|
|
if (StringUtils.isNotBlank(formDTO.getEndTime())){ |
|
|
|
dateBuilder.append(formDTO.getEndTime()); |
|
|
|
} |
|
|
|
List<ProjectCategoryResultDTO> resultDTOList = new ArrayList<>(); |
|
|
|
data.forEach(e->{ |
|
|
|
resultDTOList.add(e); |
|
|
|
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("exportDate",dateBuilder.toString()); |
|
|
|
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()); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @Description 【项目分类】查询分类下的项目 |
|
|
|