|
|
@ -1,6 +1,9 @@ |
|
|
|
package com.epmet.dataaggre.controller; |
|
|
|
|
|
|
|
import com.alibaba.excel.EasyExcel; |
|
|
|
import com.alibaba.excel.ExcelWriter; |
|
|
|
import com.alibaba.excel.annotation.ExcelProperty; |
|
|
|
import com.alibaba.excel.write.metadata.WriteSheet; |
|
|
|
import com.epmet.commons.tools.annotation.LoginUser; |
|
|
|
import com.epmet.commons.tools.annotation.RequirePermission; |
|
|
|
import com.epmet.commons.tools.enums.RequirePermissionEnum; |
|
|
@ -9,6 +12,7 @@ import com.epmet.commons.tools.exception.RenException; |
|
|
|
import com.epmet.commons.tools.page.PageData; |
|
|
|
import com.epmet.commons.tools.security.dto.TokenDto; |
|
|
|
import com.epmet.commons.tools.security.user.LoginUserUtil; |
|
|
|
import com.epmet.commons.tools.utils.ConvertUtils; |
|
|
|
import com.epmet.commons.tools.utils.Result; |
|
|
|
import com.epmet.commons.tools.validator.ValidatorUtils; |
|
|
|
import com.epmet.dataaggre.dto.govorg.CustomerAgencyDTO; |
|
|
@ -20,15 +24,22 @@ import com.epmet.dataaggre.entity.govorg.CustomerGridEntity; |
|
|
|
import com.epmet.dataaggre.enums.GridMemberDataAnalysisEnums; |
|
|
|
import com.epmet.dataaggre.service.AggreGridService; |
|
|
|
import com.epmet.dataaggre.service.govorg.GovOrgService; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.util.CollectionUtils; |
|
|
|
import org.springframework.web.bind.annotation.*; |
|
|
|
|
|
|
|
import javax.validation.constraints.NotBlank; |
|
|
|
import java.io.IOException; |
|
|
|
import java.nio.file.Files; |
|
|
|
import java.nio.file.Path; |
|
|
|
import java.nio.file.Paths; |
|
|
|
import java.util.ArrayList; |
|
|
|
import java.util.Date; |
|
|
|
import java.util.List; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
/** |
|
|
|
* @Author zxc |
|
|
@ -36,6 +47,7 @@ import java.util.List; |
|
|
|
*/ |
|
|
|
@RestController |
|
|
|
@RequestMapping("org") |
|
|
|
@Slf4j |
|
|
|
public class GovOrgController { |
|
|
|
|
|
|
|
@Autowired |
|
|
@ -47,6 +59,24 @@ public class GovOrgController { |
|
|
|
@Autowired |
|
|
|
private AggreGridService aggreGridService; |
|
|
|
|
|
|
|
/** |
|
|
|
* 导出路径 |
|
|
|
*/ |
|
|
|
private Path gridMemberStatsExcelExportDir; |
|
|
|
|
|
|
|
{ |
|
|
|
// 初始化目录
|
|
|
|
String home = System.getProperty("user.home"); |
|
|
|
Path importDir = Paths.get(home, "epmet_files", "grid_member_stats_excel_export"); |
|
|
|
if (Files.notExists(importDir)) { |
|
|
|
try { |
|
|
|
Files.createDirectories(importDir); |
|
|
|
} catch (IOException e) { |
|
|
|
log.error("创建导出暂存目录失败"); |
|
|
|
} |
|
|
|
} |
|
|
|
gridMemberStatsExcelExportDir = importDir; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @param tokenDTO |
|
|
@ -231,24 +261,32 @@ public class GovOrgController { |
|
|
|
*/ |
|
|
|
@PostMapping("pcwork/gridmember-analysis/export") |
|
|
|
public Result exportGridMemberAnalysis4PcWork(@RequestBody GridMemberDataAnalysisFromDTO input) { |
|
|
|
//ValidatorUtils.validateEntity(input, GridMemberDataAnalysisFromDTO.listGridMemberDatas4PcWork.class);
|
|
|
|
//
|
|
|
|
//String agencyId = input.getAgencyId();
|
|
|
|
//Date startTime = input.getStartTime();
|
|
|
|
//Date endTime = input.getEndTime();
|
|
|
|
//
|
|
|
|
//int pageNo = 0;
|
|
|
|
//int pageSize = 1000;
|
|
|
|
//
|
|
|
|
//PageData<GridMemberDataAnalysisResultDTO> page;
|
|
|
|
//do {
|
|
|
|
// page = aggreGridService.getGridMemberDataAnalysis4PcWork(agencyId, pageNo, pageSize, startTime, endTime);
|
|
|
|
// List<GridMemberDataAnalysisResultDTO> pageList = page.getList();
|
|
|
|
//
|
|
|
|
// EasyExcel
|
|
|
|
//
|
|
|
|
//
|
|
|
|
//} while (page.getList().size() == pageSize);
|
|
|
|
ValidatorUtils.validateEntity(input, GridMemberDataAnalysisFromDTO.listGridMemberDatas4PcWork.class); |
|
|
|
|
|
|
|
String agencyId = input.getAgencyId(); |
|
|
|
Date startTime = input.getStartTime(); |
|
|
|
Date endTime = input.getEndTime(); |
|
|
|
|
|
|
|
int pageNo = 0; |
|
|
|
int pageSize = 1000; |
|
|
|
|
|
|
|
String tempFileName = UUID.randomUUID().toString().concat(".xlsx"); |
|
|
|
|
|
|
|
ExcelWriter excelWriter = EasyExcel.write(tempFileName, GridMemberDataAnalysisExcelExportBean.class).build(); |
|
|
|
// 这里注意 如果同一个sheet只要创建一次
|
|
|
|
WriteSheet writeSheet = EasyExcel.writerSheet("模板").build(); |
|
|
|
|
|
|
|
PageData<GridMemberDataAnalysisResultDTO> page; |
|
|
|
do { |
|
|
|
page = aggreGridService.getGridMemberDataAnalysis4PcWork(agencyId, pageNo, pageSize, startTime, endTime); |
|
|
|
List<GridMemberDataAnalysisResultDTO> pageList = page.getList(); |
|
|
|
|
|
|
|
List<GridMemberDataAnalysisExcelExportBean> exportBeans = ConvertUtils.sourceToTarget(pageList, GridMemberDataAnalysisExcelExportBean.class); |
|
|
|
|
|
|
|
excelWriter.write(exportBeans, writeSheet); |
|
|
|
|
|
|
|
|
|
|
|
} while (page.getList().size() == pageSize); |
|
|
|
|
|
|
|
return null; |
|
|
|
} |
|
|
@ -256,21 +294,44 @@ public class GovOrgController { |
|
|
|
/** |
|
|
|
* 网格员数据分析excel导出bean |
|
|
|
*/ |
|
|
|
@Data |
|
|
|
public class GridMemberDataAnalysisExcelExportBean { |
|
|
|
@ExcelProperty("姓名") |
|
|
|
private String staffName; |
|
|
|
|
|
|
|
@ExcelProperty("手机号") |
|
|
|
private String mobile; |
|
|
|
|
|
|
|
@ExcelProperty("所属网格") |
|
|
|
private String orgName; |
|
|
|
|
|
|
|
// 项目议题等
|
|
|
|
@ExcelProperty("项目数") |
|
|
|
private Integer projectCount; |
|
|
|
|
|
|
|
@ExcelProperty("议题转项目数") |
|
|
|
private Integer issueToProjectCount; |
|
|
|
|
|
|
|
@ExcelProperty("议题关闭数") |
|
|
|
private Integer closedIssueCount; |
|
|
|
|
|
|
|
@ExcelProperty("项目事件响应数") |
|
|
|
private Integer projectResponseCount; |
|
|
|
|
|
|
|
@ExcelProperty("项目事件吹哨数") |
|
|
|
private Integer projectTransferCount; |
|
|
|
|
|
|
|
@ExcelProperty("项目事件结案数") |
|
|
|
private Integer projectClosedCount; |
|
|
|
|
|
|
|
// 巡查
|
|
|
|
@ExcelProperty("巡查次数") |
|
|
|
private int patrolTimes; |
|
|
|
|
|
|
|
@ExcelProperty("巡查时长") |
|
|
|
private int totalTime; |
|
|
|
|
|
|
|
@ExcelProperty("例行工作次数") |
|
|
|
private int patrolRoutineWorkTimes; |
|
|
|
} |
|
|
|
|
|
|
|