Commit 038eff36 authored by chenzhao's avatar chenzhao

统计首页导出开发

parent 823a338f
package com.yeejoin.amos.boot.module.hygf.api.Enum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.StringUtils;
import java.util.List;
@Getter
@AllArgsConstructor
public enum StatisicsHomePageEnum {
序号("xh",0),
省份("sf",1),
项目公司("regionalCompaniesName",2),
代理商("developerName",3),
实际建设容量("realScale",4),
勘察未通过("kcwtg",5),
勘察未通过容量("kcwtgrl",6),
勘察进行中("kcjxz",7),
勘察进行中容量("kcjxzrl",8),
勘察已完成("kcywc",9),
勘察已完成容量("kcywcrl",10),
备货未通过("bhwtg",11),
备货未通过容量("bhwtgrl",12),
备货进行中("bhjxz",13),
备货进行中容量("bhjxzrl",14),
备货已完成("bhywc",15),
备货已完成容量("bhywcrl",16),
施工未通过("sgwtg",17),
施工未通过容量("sgwtgrl",18),
施工进行中("sgjxz",19),
施工进行中容量("sgjxzrl",20),
施工已完成("sgywc",21),
施工已完成容量("sgywcrl",22),
并网未通过("bwwtg",23),
并网未通过容量("bwwtgrl",24),
并网进行中("bwjxz",25),
并网进行中容量("bwjxzrl",26),
并网已完成("bwywc",27),
并网已完成容量("bwywcrl",28),
验收未通过("yswtg",29),
验收未通过容量("yswtgrl",30),
验收进行中("ysjxz",31),
验收进行中容量("ysjxzrl",32),
验收已完成("ysywc",33),
验收已完成容量("ysywcrl",34),
融资公司("rzgs",35),
融资户数("rzhs",36),
融资容量("rzrl",37),
融资单价("rzdj",38),
放款金额("fkje",30);
/**
* 名称,描述
*/
private String name;
/**
* 编码
*/
private int code;
public static Integer getCodeByName(String name) {
for(StatisicsHomePageEnum obj: StatisicsHomePageEnum.values()) {
if (obj.getName().equals(name)) {
return obj.getCode();
}
}
return null;
}
}
...@@ -12,6 +12,12 @@ public interface StatisticsHomepageMapper { ...@@ -12,6 +12,12 @@ public interface StatisticsHomepageMapper {
@UserEmpower(field ={"ph.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and") @UserEmpower(field ={"ph.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> surveyStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district); public List<Map<String,Object>> surveyStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"ph.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> homePageExport(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"b.regionalCompaniesCode"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> merCount(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and") @UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public List<Map<String,Object>> contractStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district); public List<Map<String,Object>> contractStatusTotal(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and") @UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
...@@ -32,4 +38,7 @@ public interface StatisticsHomepageMapper { ...@@ -32,4 +38,7 @@ public interface StatisticsHomepageMapper {
public List<Map<String,Object>> inverterTotalJp(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district, @RequestParam(value = "regions")List<String> regions); public List<Map<String,Object>> inverterTotalJp(@RequestParam(value = "developerCode") String developerCode, @RequestParam(value = "regionalCompaniesCode")String regionalCompaniesCode, @RequestParam(value = "province")String province, @RequestParam(value = "city") String city, @RequestParam(value = "district")String district, @RequestParam(value = "regions")List<String> regions);
@UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and") @UserEmpower(field ={"hygf_peasant_household.regional_companies_code"},dealerField ={"hygf_peasant_household.developer_code"} ,fieldConditions ={"eq"} ,relationship="and")
public Map<String,Object> stationNum(String developerCode, String regionalCompaniesCode, String province, String city, String district); public Map<String,Object> stationNum(String developerCode, String regionalCompaniesCode, String province, String city, String district);
public String selectProvince (String regionSeq);
} }
...@@ -305,9 +305,8 @@ ...@@ -305,9 +305,8 @@
</select> </select>
<select id="inverterTotal" resultType="map"> <select id="inverterTotal" resultType="map">
SELECT SELECT
FLOOR(SUM((LENGTH(construction_inverter_info)-LENGTH(REPLACE(construction_inverter_info,'id',''))))/LENGTH('id')) AS total, FLOOR(SUM((LENGTH(construction_inverter_info)-LENGTH(REPLACE(construction_inverter_info,'"id"',''))))/LENGTH('"id"')) AS total,
'户用开发逆变器' AS statusText, '户用开发逆变器' AS statusText,
0 AS realScale 0 AS realScale
FROM FROM
...@@ -379,4 +378,150 @@ ...@@ -379,4 +378,150 @@
</if> </if>
</select> </select>
<select id="homePageExport" resultType="map">
SELECT
ph.regional_companies_name as regionalCompaniesName,
ph.developer_name developerName,
SUM( IFNULL(ei.real_scale,0)) AS realScale,
SUM( CASE WHEN ps.process_status = '不通过' THEN 1 ELSE 0 END ) AS kcwtg,
SUM( CASE WHEN ps.process_status = '进行中' THEN 1 ELSE 0 END ) AS kcjxz,
SUM( CASE WHEN ps.process_status = '完成' THEN 1 ELSE 0 END ) AS kcywc,
SUM( CASE WHEN ph.preparation_money_state = '备货完成' THEN 1 ELSE 0 END ) AS bhywc,
SUM( CASE WHEN ph.preparation_money_state = '待收货' THEN 1 ELSE 0 END ) AS bhjxz,
SUM( CASE WHEN ph.preparation_money_state = '待补货' THEN 1 ELSE 0 END ) AS bhwtg,
SUM( CASE WHEN wops.power_station_construction_status = '未通过' THEN 1 ELSE 0 END ) AS sgwtg,
SUM( CASE WHEN wops.power_station_construction_status = '未通过' THEN ei.real_scale ELSE 0 END ) AS sgwtgrl,
SUM( CASE WHEN wops.power_station_construction_status != '未通过' AND wops.power_station_construction_status != '已完工' AND wops.power_station_construction_status != '待施工' THEN 1 ELSE 0 END ) AS sgjxz,
SUM( CASE WHEN wops.power_station_construction_status != '未通过' AND wops.power_station_construction_status != '已完工' AND wops.power_station_construction_status != '待施工' THEN ei.real_scale ELSE 0 END ) AS sgjxzrl,
SUM( CASE WHEN wops.power_station_construction_status = '已完工' THEN 1 ELSE 0 END ) AS sgywc,
SUM( CASE WHEN wops.power_station_construction_status = '已完工' THEN ei.real_scale ELSE 0 END ) AS sgywcrl,
SUM( CASE WHEN br.grid_status = '4' THEN 1 ELSE 0 END ) AS bwwtg,
SUM( CASE WHEN br.grid_status = '4' THEN ei.real_scale ELSE 0 END ) AS bwwtgrl,
SUM( CASE WHEN br.grid_status != '4' AND br.grid_status != '3' AND br.grid_status != '1' THEN ei.real_scale ELSE 0 END ) AS bwjxz,
SUM( CASE WHEN br.grid_status != '4' AND br.grid_status != '3' AND br.grid_status != '1' THEN ei.real_scale ELSE 0 END ) AS bwjxzrl,
SUM( CASE WHEN br.grid_status = '3' THEN 1 ELSE 0 END ) AS bwywc,
SUM( CASE WHEN br.grid_status = '3' THEN ei.real_scale ELSE 0 END ) AS bwywcrl,
SUM( CASE WHEN ac.acceptance_check_status = '3' THEN 1 ELSE 0 END ) AS ysywc,
SUM( CASE WHEN ac.acceptance_check_status = '3' THEN ei.real_scale ELSE 0 END ) AS ysywcrl,
SUM( CASE WHEN ac.acceptance_check_status = '4' THEN 1 ELSE 0 END ) AS yswtg,
SUM( CASE WHEN ac.acceptance_check_status = '4' THEN ei.real_scale ELSE 0 END ) AS yswtgrl,
SUM( CASE WHEN ac.acceptance_check_status != '3' AND ac.acceptance_check_status != '4' AND ac.acceptance_check_status != '15' THEN 1 ELSE 0 END ) AS ysjxz,
SUM( CASE WHEN ac.acceptance_check_status != '3' AND ac.acceptance_check_status != '4' AND ac.acceptance_check_status != '15' THEN ei.real_scale ELSE 0 END ) AS ysjxzrl,
SUM(CASE WHEN fi.status = '放款完成' THEN 1 ELSE 0 END) as rzhs,
MAX(CASE WHEN fi.status = '放款完成' THEN fi.unit_price ELSE 0 END) as rzdj,
MAX(CASE WHEN fi.status = '放款完成' THEN fi.financing_companies_name ELSE ''END) as rzgs,
SUM(CASE WHEN fi.status = '放款完成' THEN fi.disbursement_money ELSE 0 END) as fkje,
SUM(CASE WHEN fi.status = '放款完成' THEN ei.real_scale ELSE 0 END) AS rzrl
FROM
hygf_peasant_household ph
LEFT JOIN hygf_power_station ps ON ps.peasant_household_id = ph.sequence_nbr
LEFT JOIN hygf_work_order_power_station wops ON wops.peasant_household_id = ph.sequence_nbr
LEFT JOIN hygf_power_station_engineering_info ei ON ei.work_order_power_station_id = wops.sequence_nbr
LEFT JOIN hygf_acceptance_check ac ON ac.peasant_household_id = ph.sequence_nbr
LEFT JOIN hygf_basic_grid_record br ON br.peasant_household_id = ph.sequence_nbr
LEFT JOIN hygf_financing_info fi ON fi.peasant_household_id = ph.sequence_nbr
WHERE
ps.is_delete = 0
<if test="developerCode != null and developerCode != ''">
AND ph.developer_code = #{developerCode}
</if>
<if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">
AND ph.regional_companies_code = #{regionalCompaniesCode}
</if>
<if test="province != null and province != ''">
AND ph.project_address LIKE CONCAT ('%',#{province},'%')
</if>
<if test="city != null and city != ''">
AND ph.project_address LIKE CONCAT ('%',#{city},'%')
</if>
<if test="district != null and district != ''">
AND ph.project_address LIKE CONCAT ('%',#{district},'%')
</if>
GROUP BY
ph.regional_companies_name,
ph.developer_name
order by
ph.regional_companies_name,ph.developer_name
</select>
<select id="merCount" resultType="map">
SELECT
count( regionalCompaniesName ) AS total,
max( regionalCompaniesName ) regionalCompaniesName,
max( regionSeq ) AS regionSeq,
max( regionalCompaniesCode ) AS regionalCompaniesCode,
max( developerCode ) AS developerCode,
max( projectAddress ) AS projectAddress
FROM
(
SELECT
ph.regional_companies_name AS regionalCompaniesName,
ph.developer_name developerName,
max( pc.REGION_SEQ ) AS regionSeq,
max( ph.regional_companies_code ) AS regionalCompaniesCode,
max( ph.developer_code ) AS developerCode,
max( ph.project_address ) AS projectAddress
FROM
hygf_peasant_household ph
LEFT JOIN privilege_company pc ON pc.SEQUENCE_NBR = ph.regional_companies_seq
<where>
<if test="developerCode != null and developerCode != ''">
AND ph.developer_code = #{developerCode}
</if>
<if test="regionalCompaniesCode != null and regionalCompaniesCode != ''">
AND ph.regional_companies_code = #{regionalCompaniesCode}
</if>
<if test="province != null and province != ''">
AND ph.project_address LIKE CONCAT ('%',#{province},'%')
</if>
<if test="city != null and city != ''">
AND ph.project_address LIKE CONCAT ('%',#{city},'%')
</if>
<if test="district != null and district != ''">
AND ph.project_address LIKE CONCAT ('%',#{district},'%')
</if>
</where>
GROUP BY
ph.regional_companies_name,
ph.developer_name
ORDER BY
ph.regional_companies_name,
ph.developer_name
) b
GROUP BY
regionalCompaniesName
</select>
<select id="selectProvince" resultType="String">
WITH RECURSIVE ParentTree AS (
-- 初始查询:选择根节点
SELECT
SEQUENCE_NBR,
PARENT_ID,
REGION_NAME
FROM
systemctl_region sr
WHERE
sr.SEQUENCE_NBR = #{regionSeq}
UNION ALL
-- 递归部分:选择父节点
SELECT
p.SEQUENCE_NBR,
p.PARENT_ID,
p.REGION_NAME
FROM
systemctl_region p
JOIN
ParentTree pt ON p.SEQUENCE_NBR = pt.PARENT_ID
)
SELECT
pt.REGION_NAME AS topLevelNodeName
FROM
ParentTree pt
WHERE
pt.PARENT_ID = 0;
</select>
</mapper> </mapper>
\ No newline at end of file
...@@ -110,7 +110,7 @@ public class CommonController { ...@@ -110,7 +110,7 @@ public class CommonController {
@TycloudOperation(ApiLevel = UserType.AGENCY) @TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "资料下载进度获取", notes = "资料下载进度获取") @ApiOperation(httpMethod = "GET", value = "资料下载进度获取", notes = "资料下载进度获取")
@UserLimits @UserLimits
public ResponseModel<Map<String, Object>> getSchedule(@RequestParam(required = false) String developerCode, public ResponseModel<Map<String, Object>> statisticsHomepage(@RequestParam(required = false) String developerCode,
@RequestParam(required = false) String regionalCompaniesCode, @RequestParam(required = false) String regionalCompaniesCode,
@RequestParam(required = false) String province, @RequestParam(required = false) String province,
@RequestParam(required = false) String city, @RequestParam(required = false) String city,
...@@ -118,6 +118,26 @@ public class CommonController { ...@@ -118,6 +118,26 @@ public class CommonController {
return ResponseHelper.buildResponse(statisticsHomepageService.statisticsHomepage(developerCode,regionalCompaniesCode,province,city,district)); return ResponseHelper.buildResponse(statisticsHomepageService.statisticsHomepage(developerCode,regionalCompaniesCode,province,city,district));
}
/**
* 统计首页环形图
*
* @return
*/
@GetMapping(value = "/homePageExport")
@TycloudOperation(ApiLevel = UserType.AGENCY)
@ApiOperation(httpMethod = "GET", value = "资料下载进度获取", notes = "资料下载进度获取")
@UserLimits
public void homePageExport(@RequestParam(required = false) String developerCode,
@RequestParam(required = false) String regionalCompaniesCode,
@RequestParam(required = false) String province,
@RequestParam(required = false) String city,
@RequestParam(required = false) String district,
HttpServletResponse response) throws IOException {
statisticsHomepageService.homePageExport(developerCode,regionalCompaniesCode,province,city,district,response);
} }
} }
...@@ -1773,7 +1773,6 @@ public class CommonServiceImpl { ...@@ -1773,7 +1773,6 @@ public class CommonServiceImpl {
result.add(map); result.add(map);
} }
} }
return result; return result;
} }
......
...@@ -87,6 +87,7 @@ public class FinancingInfoHistoryServiceImpl extends BaseService<FinancingInfoHi ...@@ -87,6 +87,7 @@ public class FinancingInfoHistoryServiceImpl extends BaseService<FinancingInfoHi
e.setDisbursementTime(financingInfoDto.getDisbursementTime()); e.setDisbursementTime(financingInfoDto.getDisbursementTime());
e.setUnitPrice(financingInfoDto.getUnitPrice()); e.setUnitPrice(financingInfoDto.getUnitPrice());
e.setFinancingCompaniesName(financingInfoDto.getFinancingCompaniesName()); e.setFinancingCompaniesName(financingInfoDto.getFinancingCompaniesName());
e.setBacthNo(financingInfoDto.getBacthNo());
e.setStatus("放款完成"); e.setStatus("放款完成");
if (financingInfoDto.getFiles() != null){ if (financingInfoDto.getFiles() != null){
e.setFile(JSON.toJSONString(financingInfoDto.getFiles())); e.setFile(JSON.toJSONString(financingInfoDto.getFiles()));
......
...@@ -341,9 +341,9 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina ...@@ -341,9 +341,9 @@ public class FinancingInfoServiceImpl extends BaseService<FinancingInfoDto, Fina
financingInfo.setStatus(statusName); financingInfo.setStatus(statusName);
} }
if (params.containsKey("isHistory")) { // if (params.containsKey("isHistory")) {
financingInfo.setStatus("退回建档"); // financingInfo.setStatus("退回建档");
} // }
if("放款完成".equals(financingInfo.getStatus())){ if("放款完成".equals(financingInfo.getStatus())){
financingInfo.setTrEndTime(new Date()); financingInfo.setTrEndTime(new Date());
} }
......
...@@ -4,15 +4,31 @@ import cn.hutool.core.collection.CollectionUtil; ...@@ -4,15 +4,31 @@ import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.map.MapBuilder; import cn.hutool.core.map.MapBuilder;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.sun.org.apache.bcel.internal.generic.SWITCH; import com.sun.org.apache.bcel.internal.generic.SWITCH;
import com.yeejoin.amos.boot.biz.common.utils.DateUtils;
import com.yeejoin.amos.boot.module.hygf.api.Enum.CommonEnum;
import com.yeejoin.amos.boot.module.hygf.api.Enum.StatisicsHomePageEnum;
import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold; import com.yeejoin.amos.boot.module.hygf.api.entity.PeasantHousehold;
import com.yeejoin.amos.boot.module.hygf.api.mapper.JpStationMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.JpStationMapper;
import com.yeejoin.amos.boot.module.hygf.api.mapper.StatisticsHomepageMapper; import com.yeejoin.amos.boot.module.hygf.api.mapper.StatisticsHomepageMapper;
import org.apache.activemq.util.MapHelper; import org.apache.activemq.util.MapHelper;
import org.apache.poi.ss.usermodel.*;
import org.apache.poi.ss.util.CellRangeAddress;
import org.apache.poi.xssf.usermodel.XSSFClientAnchor;
import org.apache.poi.xssf.usermodel.XSSFDrawing;
import org.apache.poi.xssf.usermodel.XSSFSheet;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ClassPathResource;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Field;
import java.math.BigDecimal; import java.math.BigDecimal;
import java.net.URL;
import java.net.URLEncoder;
import java.util.*; import java.util.*;
@Service @Service
...@@ -288,4 +304,82 @@ public class StatisticsHomepageServiceImpl { ...@@ -288,4 +304,82 @@ public class StatisticsHomepageServiceImpl {
return list; return list;
} }
public void homePageExport(String developerCode, String regionalCompaniesCode, String province, String city, String district, HttpServletResponse response) throws IOException {
List<Map<String, Object>> maps = statisticsHomepageMapper.homePageExport(developerCode, regionalCompaniesCode, province, city, district);
List<Map<String, Object>> merCountMap = statisticsHomepageMapper.merCount(developerCode, regionalCompaniesCode, province, city, district);
String templatePath = "templates/homePageExport.xlsx";
Workbook workbook = null;
try ( InputStream fis = new ClassPathResource(templatePath).getInputStream()) {
workbook = new XSSFWorkbook(fis);
Sheet firstSheet = workbook.getSheetAt(0);
fillSheet(firstSheet, maps);
int startNum = 4;
for (Map<String, Object> map : merCountMap) {
if (!map.get("total").toString().equals("1")){
int total = Integer.valueOf(map.get("total").toString()) -1 ;
int endNum = startNum+total;
String regionName = statisticsHomepageMapper.selectProvince(map.get("regionSeq").toString());
firstSheet.getRow(startNum).getCell(1).setCellValue(regionName);
CellRangeAddress cellRangeAddress2 = new CellRangeAddress(startNum, endNum, 1, 1);
CellRangeAddress cellRangeAddress = new CellRangeAddress(startNum, endNum, 2, 2);
CellRangeAddress cellRangeAddress1 = new CellRangeAddress(startNum, endNum, 35, 35);
firstSheet.addMergedRegion(cellRangeAddress);
firstSheet.addMergedRegion(cellRangeAddress1);
firstSheet.addMergedRegion(cellRangeAddress2);
startNum = endNum +1;
}else {
startNum +=1;
}
}
response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode("统计数据.xlsx", "UTF-8"));
response.setHeader("content-Type", "application/vnd.ms-excel");
response.flushBuffer();
workbook.write(response.getOutputStream());
workbook.close();
}
}
private void fillSheet(Sheet sheet, List<Map<String, Object>> data) {
if (Objects.isNull(data)){
return;
}
int startRow = 4;
sheet.setDefaultColumnWidth(0);
Map<String, List<Integer>> merList = new HashMap<>();
for (int dataIndex = 0; dataIndex < data.size(); dataIndex++) {
Row dataRow = sheet.createRow(startRow + dataIndex);
dataRow.createCell(0).setCellValue(dataIndex+1);
Map<String, Object> result = (Map<String, Object>) data.get(dataIndex);
for (String key : result.keySet()) {
Cell dataCell = dataRow.createCell(StatisicsHomePageEnum.getCodeByName(key));
dataCell.setCellValue(result.get(key).toString());
}
}
}
public static List<Map<String, Object>> convertList(List<Object> objectList) {
List<Map<String, Object>> result = new ArrayList<>();
for (Object obj : objectList) {
if (obj != null) {
Map<String, Object> map = new HashMap<>();
Field[] fields = obj.getClass().getDeclaredFields();
for (Field field : fields) {
field.setAccessible(true); // 允许访问私有字段(如果需要)
try {
map.put(field.getName(), field.get(obj));
} catch (IllegalAccessException e) {
e.printStackTrace();
// 可以选择记录日志或抛出异常
}
}
result.add(map);
}
}
return result;
}
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment