项目库-项目详情-统计接口 根据领域分组. 导出.

This commit is contained in:
wangzhijiang
2022-05-19 21:49:37 +08:00
parent 49e057ec28
commit 77d4f387e1
13 changed files with 459 additions and 4 deletions
@@ -173,5 +173,27 @@ public class ProjectLibraryBaseController extends JeroController<ProjectLibraryB
return Result.OK(cut,data);
}
/**
* 项目详情-统计接口-根据领域分组
* @return
*/
@AutoLog(value = "项目详情-统计接口-根据领域分组")
@ApiOperation(value="项目详情-统计接口-根据领域分组", notes="项目详情-统计接口-根据领域分组")
@GetMapping(value = "/getProjectDetailsStatisticsGroupByTerritory")
public Result<?> getProjectDetailsStatisticsGroupByTerritory(@RequestParam Map<String,Object> params) {
Map<String,Object> data = projectLibraryBaseService.getProjectDetailsStatisticsGroupByTerritory(params);
return Result.OK((String)params.get("cut"),data);
}
/**
* 导出excel
*
* @param request
* @param params
*/
@RequestMapping(value = "/exportProjectDetailsStatisticsGroupByTerritoryXls")
public void exportProjectDetailsStatisticsGroupByTerritoryXls(HttpServletResponse response,HttpServletRequest request, Map<String,Object> params) {
projectLibraryBaseService.exportProjectDetailsStatisticsGroupByTerritoryXls(response,request, params);
}
}
@@ -80,4 +80,8 @@ public class ConditionAssessmentEO implements Serializable {
@TableField(exist = false)
private String cut;
/**责任领域**/
@TableField(exist = false)
private String dutyTerritory;
}
@@ -22,6 +22,18 @@ public enum OperatorTypeEnum {
QUERY_TASK_INVENTORY_DETAIL("查询法规清单明细信息","queryTaskInventoryDetail"),
UPDATE_TASK_INVENTORY_DETAIL("更新法规清单明细信息","updateTaskInventoryDetail"),
UPDATE_DRE_TASK_STATUS("更新法规清单明细信息,dre任务状态","updateDreTaskStatus"),
/**
* 项目库 - 项目详情 统计查询 操作类型枚举
*/
QUERY_CURRENT_PROJECT_STATUS_STATISTICS("查询当前项目状态统计","queryCurrentProjectStatusStatistics"),
QUERY_LISTING_TO_CONFIRM_STATISTICS("查询清单确认统计","queryListingToConfirmStatistics"),
QUERY_TASK_TO_CONFIRM_STATISTICS("查询任务确认统计","queryTaskToConfirmStatistics"),
QUERY_DESIGN_STATISTICS("查询设计符合性统计","queryDesignStatistics"),
QUERY_PREHOMO_STATISTICS("查询prehomo统计","queryPrehomoStatistics"),
QUERY_VERIFY_STATISTICS("查询验证符合性统计","queryVerifyStatistics"),
QUERY_CERTIFICATION_PROGRESS_STATISTICS("查询认证进度统计","queryCertificationProgressStatistics"),
;
String name;
@@ -20,4 +20,13 @@ public interface ConditionAssessmentEOMapper extends BaseMapper<ConditionAssessm
* @return
*/
List<Map<String, Object>> getCurrentProjectStatusStatistics(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList);
/**
* 根据 评估状态 查询列表
* @param projectLawsInventoryIdList
* @param conditionAssessment
* @return
*/
List<ConditionAssessmentEO> getProjectStatusAssessListByConditionAssessment(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList,
@Param("conditionAssessment") String conditionAssessment);
}
@@ -28,4 +28,20 @@ public interface ProjectLawsInventoryEOMapper extends BaseMapper<ProjectLawsInve
* @return
*/
List<Map<String, Object>> getTaskToConfirmStatistics(@Param("projectLibraryId")String projectLibraryId);
/**
* 统计该项目中,某一个 清单确认状态的数据 根据领域分组
* @param projectLibraryId 项目库id
* @param inventoryAffirmStatus 清单确认状态
* @return
*/
List<Map<String, Object>> getListingToConfirmStatisticsGroupByTerritory(@Param("projectLibraryId") String projectLibraryId,@Param("inventoryAffirmStatus") String inventoryAffirmStatus);
/**
* 统计该项目中,某一个 任务确认状态的数据 根据领域分组
* @param projectLibraryId
* @param taskAffirmStatus
* @return
*/
List<Map<String, Object>> getTaskToConfirmStatisticsGroupByTerritory(@Param("projectLibraryId") String projectLibraryId, @Param("taskAffirmStatus") String taskAffirmStatus);
}
@@ -40,4 +40,40 @@ public interface ProjectTaskInventoryEOMapper extends BaseMapper<ProjectTaskInve
* @return
*/
List<Map<String, Object>> getVerifyComplianceStatistice(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList);
/**
* 统计该项目中,某一个 设计符合性流程 任务状态的数据 根据领域分组
* @param projectLawsInventoryIdList
* @param designFlowTaskStatus
* @return
*/
List<Map<String, Object>> getDesignComplianceStatisticeGroupByTerritory(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList,
@Param("designFlowTaskStatus") String designFlowTaskStatus);
/**
* 统计该项目中,某一个 prehomo确认流程 任务状态的数据 根据领域分组
* @param projectLawsInventoryIdList
* @param designFlowTaskStatus
* @return
*/
List<Map<String, Object>> getPrehomoStatisticeGroupByTerritory(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList,
@Param("prehomoFlowTaskStatus") String designFlowTaskStatus);
/**
* 统计该项目中,某一个 验证符合性确认流程 任务状态的数据 根据领域分组
* @param projectLawsInventoryIdList
* @param verifyFlowTaskStatus
* @return
*/
List<Map<String, Object>> getVerifyComplianceStatisticeGroupByTerritory(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList,
@Param("verifyFlowTaskStatus") String verifyFlowTaskStatus);
/**
* 统计该项目中,某一个 认证进度的数据 根据领域分组
* @param projectLawsInventoryIdList
* @param certificationProgress
* @return
*/
List<Map<String, Object>> getCertificationProgressStatisticsGroupByTerritory(@Param("projectLawsInventoryIdList") List<String> projectLawsInventoryIdList,
@Param("certificationProgress") String certificationProgress);
}
@@ -12,6 +12,7 @@
<result column="remark" property="remark" />
<result column="project_laws_inventory_id" property="projectLawsInventoryId" />
<result column="role_code" property="roleCode" />
<result column="duty_territory" property="dutyTerritory" />
</resultMap>
<select id="getCurrentProjectStatusStatistics" resultType="hashMap">
@@ -28,4 +29,20 @@
</foreach>
group by condition_assessment
</select>
<select id="getProjectStatusAssessListByConditionAssessment" resultMap="ProjectTaskInventoryConditionAssessmentEOResultMap">
select
DISTINCT ptica.project_laws_inventory_id,
ptica.condition_assessment,
pli.duty_territory
from
project_task_inventory_condition_assessment ptica
left join project_laws_inventory pli on ptica.project_laws_inventory_id = pli.id
where
ptica.project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and ptica.condition_assessment = #{conditionAssessment}
</select>
</mapper>
@@ -69,4 +69,33 @@
project_library_id = #{projectLibraryId}
group by task_affirm_status
</select>
<select id="getListingToConfirmStatisticsGroupByTerritory" resultType="hashmap">
select
count(inventory_affirm_status) as "amount",
inventory_affirm_status as "inventoryAffirmStatus",
id as "id",
duty_territory as "dutyTerritory"
from
project_laws_inventory
where
project_library_id = #{projectLibraryId}
and inventory_affirm_status = #{inventoryAffirmStatus}
group by duty_territory;
</select>
<select id="getTaskToConfirmStatisticsGroupByTerritory" resultType="hashmap">
select
count(task_affirm_status) as "amount",
task_affirm_status as "taskAffirmStatus",
id as "id",
duty_territory as "dutyTerritory"
from
project_laws_inventory
where
project_library_id = #{projectLibraryId}
and task_affirm_status = #{taskAffirmStatus}
group by duty_territory;
</select>
</mapper>
@@ -78,4 +78,76 @@
</foreach>
group by verify_flow_task_status
</select>
<select id="getDesignComplianceStatisticeGroupByTerritory" resultType="hashmap">
select
count(pti.design_flow_task_status) as "amount",
pti.design_flow_task_status as "designFlowTaskStatus",
pti.id as "id",
pli.duty_territory as "dutyTerritory"
from
project_task_inventory pti
left join project_laws_inventory pli on pti.project_laws_inventory_id = pli.id
where
pti.project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and pti.design_flow_task_status = #{designFlowTaskStatus}
group by pli.duty_territory
</select>
<select id="getPrehomoStatisticeGroupByTerritory" resultType="hashmap">
select
count(pti.prehomo_flow_task_status) as "amount",
pti.prehomo_flow_task_status as "prehomoFlowTaskStatus",
pti.id as "id",
pli.duty_territory as "dutyTerritory"
from
project_task_inventory pti
left join project_laws_inventory pli on pti.project_laws_inventory_id = pli.id
where
pti.project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and pti.prehomo_flow_task_status = #{prehomoFlowTaskStatus}
group by pli.duty_territory
</select>
<select id="getVerifyComplianceStatisticeGroupByTerritory" resultType="hashmap">
select
count(pti.verify_flow_task_status) as "amount",
pti.verify_flow_task_status as "verifyFlowTaskStatus",
pti.id as "id",
pli.duty_territory as "dutyTerritory"
from
project_task_inventory pti
left join project_laws_inventory pli on pti.project_laws_inventory_id = pli.id
where
pti.project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and pti.verify_flow_task_status = #{verifyFlowTaskStatus}
group by pli.duty_territory
</select>
<select id="getCertificationProgressStatisticsGroupByTerritory" resultType="hashmap">
select
count(pti.certification_progress) as "amount",
pti.certification_progress as "certificationProgress",
pti.project_laws_inventory_id as "projectLawsInventoryId",
pli.duty_territory as "dutyTerritory"
from
project_task_inventory pti
left join project_laws_inventory pli on pti.project_laws_inventory_id = pli.id
where
pti.project_laws_inventory_id in
<foreach collection="projectLawsInventoryIdList" index="index" item="item" open="(" separator="," close=")">
#{item}
</foreach>
and pti.certification_progress = #{certificationProgress}
group by pli.duty_territory;
</select>
</mapper>
@@ -6,6 +6,7 @@ import com.jero.modules.project.entity.ConditionAssessmentEO;
import com.jero.modules.project.entity. ConditionAssessmentEO;
import com.baomidou.mybatisplus.extension.service.IService;
import java.util.List;
import java.util.Map;
/**
* @Description: 任务清单-项目状态评估表
@@ -82,4 +83,11 @@ public interface IConditionAssessmentEOService extends IService<ConditionAssessm
* @return
*/
List<ConditionAssessmentEO> getProjectStatusAssessList(List<String> projectLawsInventoryIdList);
/**
* 根据 评估状态查询 统计每一个领域下的数量
* @param params
* @return
*/
List<Map<String,Object>> getProjectStatusAssessStatisticsGroupByTerritory(Map<String,Object> params);
}
@@ -4,6 +4,8 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.IService;
import com.jero.modules.project.entity.ProjectLibraryBase;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.text.ParseException;
import java.util.List;
import java.util.Map;
@@ -76,4 +78,13 @@ public interface IProjectLibraryBaseService extends IService<ProjectLibraryBase>
* @return
*/
Map<String, Object> getProjectDetailsStatistics(String id);
/**
* 项目详情-统计接口-根据领域分组
* @param params
* @return
*/
Map<String, Object> getProjectDetailsStatisticsGroupByTerritory(Map<String, Object> params);
void exportProjectDetailsStatisticsGroupByTerritoryXls(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params);
}
@@ -200,4 +200,41 @@ public class ConditionAssessmentEOServiceImpl extends ServiceImpl<ConditionAsses
}
return result;
}
/**
* 根据 评估状态查询 统计每一个领域下的数量
* @param params
* @return
*/
@Override
public List<Map<String,Object>> getProjectStatusAssessStatisticsGroupByTerritory(Map<String,Object> params) {
//项目当前状态颜色
String conditionAssessment = (String) params.get("conditionAssessment");
List<String> projectLawsInventoryIdList = (List<String>) params.get("projectLawsInventoryIdList");
List<Map<String,Object>> result = new ArrayList<>();
if(CollectionUtils.isNotEmpty(projectLawsInventoryIdList)){
List<ConditionAssessmentEO> conditionAssessmentList = this.baseMapper.getProjectStatusAssessListByConditionAssessment(projectLawsInventoryIdList, conditionAssessment);
List<String> dutyTerritoryList = conditionAssessmentList.stream().distinct().map(ConditionAssessmentEO::getDutyTerritory).collect(Collectors.toList());
dutyTerritoryList.forEach(dutyTerritory -> {
Map<String,Object> map = new HashMap<>();
map.put("dutyTerritory",dutyTerritory);
result.add(map);
});
for (Map<String, Object> conditionAssementMap : result) {
int conditionAssessmentCount = 0;
for (ConditionAssessmentEO conditionAssessmentEO : conditionAssessmentList) {
if(com.jero.modules.system.util.StringUtils.equals(conditionAssessmentEO.getDutyTerritory(),conditionAssementMap.get("dutyTerritory").toString())){
conditionAssessmentCount ++;
}
}
conditionAssementMap.put("amount",conditionAssessmentCount);
}
}
return result;
}
}
@@ -4,14 +4,13 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.jero.common.constant.enums.CutEnum;
import com.jero.common.exception.JeroBootException;
import com.jero.common.system.vo.LoginUser;
import com.jero.modules.project.entity.ConditionAssessmentEO;
import com.jero.modules.project.entity.ProjectLawsInventoryEO;
import com.jero.modules.project.entity.ProjectLibraryBase;
import com.jero.modules.project.enums.CertificationProgressEnum;
import com.jero.modules.project.enums.CurrentProjectStatusEnum;
import com.jero.modules.project.enums.InventoryAffirmStatusEnum;
import com.jero.modules.project.enums.TaskAffirmStatusEnum;
import com.jero.modules.project.enums.*;
import com.jero.modules.project.mapper.ProjectLawsInventoryEOMapper;
import com.jero.modules.project.mapper.ProjectLibraryBaseMapper;
import com.jero.modules.project.mapper.ProjectTaskInventoryEOMapper;
@@ -22,10 +21,18 @@ import com.jero.modules.system.mapper.SysDictItemMapper;
import com.jero.modules.system.mapper.SysUserMapper;
import com.jero.modules.system.util.StringUtils;
import org.apache.commons.collections4.CollectionUtils;
import org.apache.poi.hssf.usermodel.HSSFSheet;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.shiro.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException;
import java.util.*;
import java.util.stream.Collectors;
@@ -301,6 +308,181 @@ public class ProjectLibraryBaseServiceImpl extends ServiceImpl<ProjectLibraryBas
return result;
}
/**
* 项目详情-统计接口-根据领域分组
* @param params
* @return
*/
@Override
public Map<String, Object> getProjectDetailsStatisticsGroupByTerritory(Map<String, Object> params) {
String operatorType = (String) params.get("operatorType");
String projectLibraryId = (String) params.get("projectLibraryId");
if(org.apache.commons.lang3.StringUtils.isEmpty(projectLibraryId)){
throw new JeroBootException("项目库id不能为空!");
}
Map<String,Object> result = new HashMap<>();
QueryWrapper<ProjectLawsInventoryEO> lawsInventoryEOQueryWrapper = new QueryWrapper<>();
lawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getProjectLibraryId,projectLibraryId);
lawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getInventoryAffirmStatus, InventoryAffirmStatusEnum.ACCEPTED.getValue());
lawsInventoryEOQueryWrapper.lambda().eq(ProjectLawsInventoryEO::getTaskAffirmStatus, TaskAffirmStatusEnum.ACCEPTED.getValue());
List<ProjectLawsInventoryEO> projectLawsInventoryEOList = projectLawsInventoryEOMapper.selectList(lawsInventoryEOQueryWrapper);
List<String> projectLawsInventoryIdList = projectLawsInventoryEOList.stream().distinct().map(ProjectLawsInventoryEO::getId).collect(Collectors.toList());
if(StringUtils.equals(OperatorTypeEnum.QUERY_CURRENT_PROJECT_STATUS_STATISTICS.getValue(),operatorType)){
params.put("projectLawsInventoryIdList",projectLawsInventoryIdList);
List<Map<String, Object>> conditionAssessmentMapList = this.conditionAssessmentEOService.getProjectStatusAssessStatisticsGroupByTerritory(params);
result.put("conditionAssessmentMapList",conditionAssessmentMapList);
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_LISTING_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
//清单确认 状态
String inventoryAffirmStatus = (String) params.get("inventoryAffirmStatus");
List<Map<String,Object>> listingToConfirmList = this.projectLawsInventoryEOMapper.getListingToConfirmStatisticsGroupByTerritory(projectLibraryId,inventoryAffirmStatus);
result.put("listingToConfirmList",listingToConfirmList);
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_TASK_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
//任务确认 状态
String taskAffirmStatus = (String) params.get("taskAffirmStatus");
List<Map<String,Object>> taskToConfirmList = this.projectLawsInventoryEOMapper.getTaskToConfirmStatisticsGroupByTerritory(projectLibraryId,taskAffirmStatus);
result.put("taskToConfirmList",taskToConfirmList);
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_DESIGN_STATISTICS.getValue(),operatorType)){
//设计符合性 流程任务状态
String designFlowTaskStatus = (String) params.get("designFlowTaskStatus");
if(CollectionUtils.isNotEmpty(projectLawsInventoryIdList)){
List<Map<String,Object>> designComplianceList = this.projectTaskInventoryEOMapper.getDesignComplianceStatisticeGroupByTerritory(projectLawsInventoryIdList,designFlowTaskStatus);
result.put("designComplianceList",designComplianceList);
}
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_PREHOMO_STATISTICS.getValue(),operatorType)){
//prehomo确认 流程任务状态
String prehomoFlowTaskStatus = (String) params.get("prehomoFlowTaskStatus");
if(CollectionUtils.isNotEmpty(projectLawsInventoryIdList)){
List<Map<String,Object>> prehomoList = this.projectTaskInventoryEOMapper.getPrehomoStatisticeGroupByTerritory(projectLawsInventoryIdList,prehomoFlowTaskStatus);
result.put("prehomoList",prehomoList);
}
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_VERIFY_STATISTICS.getValue(),operatorType)){
//验证符合性 流程任务状态
String verifyFlowTaskStatus = (String) params.get("verifyFlowTaskStatus");
if(CollectionUtils.isNotEmpty(projectLawsInventoryIdList)){
List<Map<String,Object>> verifyComplianceList = this.projectTaskInventoryEOMapper.getVerifyComplianceStatisticeGroupByTerritory(projectLawsInventoryIdList,verifyFlowTaskStatus);
result.put("verifyComplianceList",verifyComplianceList);
}
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_CERTIFICATION_PROGRESS_STATISTICS.getValue(),operatorType)){
//认证进度 流程任务状态
String certificationProgress = (String) params.get("certificationProgress");
if(CollectionUtils.isNotEmpty(projectLawsInventoryIdList)){
List<Map<String,Object>> certificationProgressList = this.projectTaskInventoryEOMapper.getCertificationProgressStatisticsGroupByTerritory(projectLawsInventoryIdList,certificationProgress);
result.put("certificationProgressList",certificationProgressList);
}
}
return result;
}
@Override
public void exportProjectDetailsStatisticsGroupByTerritoryXls(HttpServletResponse response, HttpServletRequest request, Map<String, Object> params) {
Map<String, Object> projectDetailsStatisticsGroupByTerritory = getProjectDetailsStatisticsGroupByTerritory(params);
String operatorType = (String) params.get("operatorType");
String cut = (String) params.get("cut");
String sheetName = "";
String title = "";
if (StringUtils.equals(cut,CutEnum.CN.getValue())) {
title = "责任领域,数量";
if(StringUtils.equals(OperatorTypeEnum.QUERY_CURRENT_PROJECT_STATUS_STATISTICS.getValue(),operatorType)){
sheetName = "项目状态";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_LISTING_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
sheetName = "清单确认";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_TASK_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
sheetName = "任务确认";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_DESIGN_STATISTICS.getValue(),operatorType)){
sheetName = "设计符合性";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_PREHOMO_STATISTICS.getValue(),operatorType)){
sheetName = "Pre-homo";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_VERIFY_STATISTICS.getValue(),operatorType)){
sheetName = "验证符合性";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_CERTIFICATION_PROGRESS_STATISTICS.getValue(),operatorType)){
sheetName = "认证进度";
}
}else if (StringUtils.equals(cut,CutEnum.EN.getValue())) {
title = "Responsible Field,Amount";
if(StringUtils.equals(OperatorTypeEnum.QUERY_CURRENT_PROJECT_STATUS_STATISTICS.getValue(),operatorType)){
sheetName = "Project status";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_LISTING_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
sheetName = "Listing to confirm";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_TASK_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
sheetName = "Task to confirm";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_DESIGN_STATISTICS.getValue(),operatorType)){
sheetName = "Design compliance";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_PREHOMO_STATISTICS.getValue(),operatorType)){
sheetName = "Pre-homo";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_VERIFY_STATISTICS.getValue(),operatorType)){
sheetName = "Verify compliance";
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_CERTIFICATION_PROGRESS_STATISTICS.getValue(),operatorType)){
sheetName = "Certification progress";
}
}
OutputStream os = null;
HSSFWorkbook workbook = new HSSFWorkbook();
try {
String fileName = sheetName + ".xlsx";
response.setHeader("Content-Disposition",
"attachment; filename=" + fileName);
response.setContentType("application/force-download");
HSSFSheet sheet = workbook.createSheet(sheetName);
String[] titleArr = title.split(",");
Row firstRow = sheet.createRow(0);
//第0行 1到3列 19到20列 设置居中、表头值。
for (int i = 0; i <= 2; i++){
Cell cell = firstRow.createCell(i);
cell.setCellValue(titleArr[i]);
}
createSheetData(sheet,projectDetailsStatisticsGroupByTerritory,params);
os = response.getOutputStream();
workbook.write(os);
os.flush();
}catch (IOException ex){
if(CutEnum.CN.getValue().equals(cut)){
throw new JeroBootException("下载文件失败");
}else{
throw new JeroBootException("Failed to download file");
}
}
}
public void createSheetData(HSSFSheet sheet,Map<String, Object> projectDetailsStatisticsGroupByTerritory, Map<String, Object> params){
List<Map<String,Object>> exportData = new ArrayList<>();
String operatorType = (String) params.get("operatorType");
if(StringUtils.equals(OperatorTypeEnum.QUERY_CURRENT_PROJECT_STATUS_STATISTICS.getValue(),operatorType)){
exportData = (List<Map<String, Object>>) projectDetailsStatisticsGroupByTerritory.get("conditionAssessmentMapList");
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_LISTING_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
exportData = (List<Map<String, Object>>) projectDetailsStatisticsGroupByTerritory.get("listingToConfirmList");
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_TASK_TO_CONFIRM_STATISTICS.getValue(),operatorType)){
exportData = (List<Map<String, Object>>) projectDetailsStatisticsGroupByTerritory.get("taskToConfirmList");
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_DESIGN_STATISTICS.getValue(),operatorType)){
exportData = (List<Map<String, Object>>) projectDetailsStatisticsGroupByTerritory.get("designComplianceList");
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_PREHOMO_STATISTICS.getValue(),operatorType)){
exportData = (List<Map<String, Object>>) projectDetailsStatisticsGroupByTerritory.get("prehomoList");
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_VERIFY_STATISTICS.getValue(),operatorType)){
exportData = (List<Map<String, Object>>) projectDetailsStatisticsGroupByTerritory.get("verifyComplianceList");
}else if(StringUtils.equals(OperatorTypeEnum.QUERY_CERTIFICATION_PROGRESS_STATISTICS.getValue(),operatorType)){
exportData = (List<Map<String, Object>>) projectDetailsStatisticsGroupByTerritory.get("certificationProgressList");
}
int rowIndex = 1;
for (int dataIndex = 0; dataIndex < exportData.size(); dataIndex++) {
Row dataRow = sheet.createRow(rowIndex);
dataRow.createCell(0).setCellValue(exportData.get(dataIndex).get("dutyTerritory").toString());
dataRow.createCell(1).setCellValue(exportData.get(dataIndex).get("amount").toString());
rowIndex ++;
}
}
}