wangxianzhang 3 years ago
parent
commit
ff83ad0844
  1. 17
      epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/dtos/result/JiMuReportBriefResultDTO.java
  2. 8
      epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java
  3. 7
      epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java
  4. 4
      epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java
  5. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java
  6. 17
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java
  7. 77
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java
  8. 102
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java
  9. 10
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java
  10. 48
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java
  11. 22
      epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java
  12. 121
      epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java
  13. 2
      epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

17
epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/dtos/result/JiMuReportBriefResultDTO.java

@ -0,0 +1,17 @@
package com.epmet.commons.feignclient.dtos.result;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* 报表简要信息result dto
*/
@Data
@NoArgsConstructor
@AllArgsConstructor
public class JiMuReportBriefResultDTO {
private String id;
private String code;
private String name;
}

8
epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/JiMuReportOpenFeignClient.java

@ -3,6 +3,7 @@ package com.epmet.commons.feignclient.feigns;
import com.epmet.commons.feignclient.dtos.JiMuPage;
import com.epmet.commons.feignclient.dtos.JiMuResult;
import com.epmet.commons.feignclient.dtos.form.JimuReportExportRequestDTO;
import com.epmet.commons.feignclient.dtos.result.JiMuReportBriefResultDTO;
import com.epmet.commons.feignclient.dtos.result.JiMuReportDetailResultDTO;
import com.epmet.commons.feignclient.dtos.result.JimuReportDbDataResultDTO;
import com.epmet.commons.feignclient.dtos.result.JimuReportFieldTreeResultDTO;
@ -44,4 +45,11 @@ public interface JiMuReportOpenFeignClient {
@PostMapping("jmreport/exportAllExcelStream")
Response exportAllExcelStream(JimuReportExportRequestDTO param);
/**
* 报表简要信息
* @return
*/
@GetMapping("jmreport/get/{report-id}")
JiMuResult<JiMuReportBriefResultDTO> getReportBrief(@PathVariable("report-id") String reportId);
}

7
epmet-commons/epmet-commons-feignclient/src/main/java/com/epmet/commons/feignclient/feigns/fallback/JiMuReportOpenFeignClientFallback.java

@ -3,6 +3,7 @@ package com.epmet.commons.feignclient.feigns.fallback;
import com.epmet.commons.feignclient.dtos.JiMuPage;
import com.epmet.commons.feignclient.dtos.JiMuResult;
import com.epmet.commons.feignclient.dtos.form.JimuReportExportRequestDTO;
import com.epmet.commons.feignclient.dtos.result.JiMuReportBriefResultDTO;
import com.epmet.commons.feignclient.dtos.result.JiMuReportDetailResultDTO;
import com.epmet.commons.feignclient.dtos.result.JimuReportDbDataResultDTO;
import com.epmet.commons.feignclient.dtos.result.JimuReportFieldTreeResultDTO;
@ -48,4 +49,10 @@ public class JiMuReportOpenFeignClientFallback implements JiMuReportOpenFeignCli
JiMuResult rst = new JiMuResult<>(false, "请求失败", 200, null,null);
return rst;
}
@Override
public JiMuResult<JiMuReportBriefResultDTO> getReportBrief(String reportID) {
JiMuResult rst = new JiMuResult<>(false, "请求失败", 200, null,null);
return rst;
}
}

4
epmet-commons/epmet-commons-tools/src/main/java/com/epmet/commons/tools/enums/CoveragePlaceTypeEnum.java

@ -18,7 +18,9 @@ public enum CoveragePlaceTypeEnum {
VOLUNTEER("volunteer", "志愿者"),
GROUP_RENT("group_rent", "群租房"),
EVENT("event", "城市管理事件"),
ZHZL_RQ("zhzl_rq", "综合治理人群");
ZHZL_RQ("zhzl_rq", "综合治理人群"),
NUCLEIC_POINT("nucleic_point", "核酸检测点"),
VACCINE_POINT("vaccine_point", "疫苗接种点");
private final String code;
private final String name;

17
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointNucleicMonitoringDao.java

@ -0,0 +1,17 @@
package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 核酸监测点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Mapper
public interface IcPointNucleicMonitoringDao extends BaseDao<IcPointNucleicMonitoringEntity> {
}

17
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/dao/epmetuser/IcPointVaccinesInoculationDao.java

@ -0,0 +1,17 @@
package com.epmet.dataaggre.dao.epmetuser;
import com.epmet.commons.mybatis.dao.BaseDao;
import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity;
import org.apache.ibatis.annotations.Mapper;
/**
* 疫苗接种点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Mapper
public interface IcPointVaccinesInoculationDao extends BaseDao<IcPointVaccinesInoculationEntity> {
}

77
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointNucleicMonitoringEntity.java

@ -0,0 +1,77 @@
package com.epmet.dataaggre.entity.epmetuser;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 核酸监测点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ic_point_nucleic_monitoring")
public class IcPointNucleicMonitoringEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 所属组织ID
*/
private String orgId;
/**
* 所属组织名称
*/
private String orgName;
/**
* 组织ID上级
*/
private String pid;
/**
* 组织ID所有上级
*/
private String pids;
/**
* 核酸监测点名称
*/
private String name;
/**
* 服务时间
*/
private String serveTime;
/**
* 咨询电话
*/
private String mobile;
/**
* 监测点地址
*/
private String address;
/**
* 经度
*/
private String longitude;
/**
* 纬度
*/
private String latitude;
}

102
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/entity/epmetuser/IcPointVaccinesInoculationEntity.java

@ -0,0 +1,102 @@
package com.epmet.dataaggre.entity.epmetuser;
import com.baomidou.mybatisplus.annotation.TableName;
import com.epmet.commons.mybatis.entity.BaseEpmetEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
/**
* 疫苗接种点
*
* @author generator generator@elink-cn.com
* @since v1.0.0 2022-06-20
*/
@Data
@EqualsAndHashCode(callSuper=false)
@TableName("ic_point_vaccines_inoculation")
public class IcPointVaccinesInoculationEntity extends BaseEpmetEntity {
private static final long serialVersionUID = 1L;
/**
* 客户ID
*/
private String customerId;
/**
* 所属组织ID
*/
private String orgId;
/**
* 所属组织名称
*/
private String orgName;
/**
* 组织ID上级
*/
private String pid;
/**
* 组织ID所有上级
*/
private String pids;
/**
* 疫苗接种点名称
*/
private String name;
/**
* 接种日期
*/
private String inoculationDate;
/**
* 接种上午开始时间
*/
private String moStartTime;
/**
* 接种上午结束时间
*/
private String moEndTime;
/**
* 接种下午开始时间
*/
private String afStartTime;
/**
* 接种下午结束时间
*/
private String afEndTime;
/**
* 暂无疫苗12
*/
private String noAvailableVaccines;
/**
* 咨询电话
*/
private String mobile;
/**
* 接种点地址
*/
private String address;
/**
* 经度
*/
private String longitude;
/**
* 纬度
*/
private String latitude;
}

10
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/EpmetUserService.java

@ -15,6 +15,8 @@ import com.epmet.dataaggre.dto.govorg.result.GridStaffResultDTO;
import com.epmet.dataaggre.dto.govorg.result.MemberProjectInfoResultDTO;
import com.epmet.dataaggre.dto.govproject.result.ProjectAnalysisResultDTO;
import com.epmet.dataaggre.entity.epmetuser.CustomerStaffEntity;
import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity;
import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity;
import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity;
import com.epmet.dto.IcResiUserDTO;
import com.epmet.dto.UserBaseInfoDTO;
@ -240,4 +242,12 @@ public interface EpmetUserService {
List<IcResiUserEntity> listVolunteers(String customerId, String agencyId, String staffOrgIds, String search, String resiCategory);
List<NowStatsDataResultDTO> getNowResiUser(NowStatsDataFormDTO formDTO);
Integer countVaccinePoint(String customerId, String agencyId, String staffOrgIds, String search);
Integer countNucleicPoint(String customerId, String agencyId, String staffOrgIds, String search);
List<IcPointVaccinesInoculationEntity> listVaccinePoints(String customerId, String agencyId, String staffOrgIds, String search);
List<IcPointNucleicMonitoringEntity> listNucleicPoints(String customerId, String agencyId,String staffOrgIds, String search);
}

48
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/epmetuser/impl/EpmetUserServiceImpl.java

@ -94,6 +94,10 @@ public class EpmetUserServiceImpl implements EpmetUserService {
private CustomerFootBarService customerFootBarService;
@Resource
private RegisterRelationDao registerRelationDao;
@Resource
private IcPointVaccinesInoculationDao pointVaccinesInoculationDao;
@Resource
private IcPointNucleicMonitoringDao pointNucleicMonitoringDao;
/**
* @Description 根据UserIds查询
@ -923,4 +927,48 @@ public class EpmetUserServiceImpl implements EpmetUserService {
List<NowStatsDataResultDTO> list = registerRelationDao.selectNowResiUser(formDTO);
return list;
}
@Override
public Integer countVaccinePoint(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointVaccinesInoculationEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointVaccinesInoculationEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointVaccinesInoculationEntity::getPids, staffOrgIds)
.or()
.eq(IcPointVaccinesInoculationEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointVaccinesInoculationEntity::getName, search);
return pointVaccinesInoculationDao.selectCount(query);
}
@Override
public Integer countNucleicPoint(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointNucleicMonitoringEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointNucleicMonitoringEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointNucleicMonitoringEntity::getPids, staffOrgIds)
.or()
.eq(IcPointNucleicMonitoringEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointNucleicMonitoringEntity::getName, search);
return pointNucleicMonitoringDao.selectCount(query);
}
@Override
public List<IcPointVaccinesInoculationEntity> listVaccinePoints(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointVaccinesInoculationEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointVaccinesInoculationEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointVaccinesInoculationEntity::getPids, staffOrgIds)
.or()
.eq(IcPointVaccinesInoculationEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointVaccinesInoculationEntity::getName, search);
return pointVaccinesInoculationDao.selectList(query);
}
@Override
public List<IcPointNucleicMonitoringEntity> listNucleicPoints(String customerId, String agencyId, String staffOrgIds, String search) {
LambdaQueryWrapper<IcPointNucleicMonitoringEntity> query = new LambdaQueryWrapper<>();
query.eq(IcPointNucleicMonitoringEntity::getCustomerId, customerId);
query.and(w -> w.likeRight(IcPointNucleicMonitoringEntity::getPids, staffOrgIds)
.or()
.eq(IcPointNucleicMonitoringEntity::getOrgId, agencyId));
query.like(StringUtils.isNotBlank(search), IcPointNucleicMonitoringEntity::getName, search);
return pointNucleicMonitoringDao.selectList(query);
}
}

22
epmet-module/data-aggregator/data-aggregator-server/src/main/java/com/epmet/dataaggre/service/impl/CoverageServiceImpl.java

@ -30,6 +30,8 @@ import com.epmet.dataaggre.dto.govorg.form.DataListLeftSubTotalFormDTO;
import com.epmet.dataaggre.dto.govorg.form.SearchDetailFormDTO;
import com.epmet.dataaggre.dto.govorg.result.*;
import com.epmet.dataaggre.dto.resigroup.result.OrgInfoCommonDTO;
import com.epmet.dataaggre.entity.epmetuser.IcPointNucleicMonitoringEntity;
import com.epmet.dataaggre.entity.epmetuser.IcPointVaccinesInoculationEntity;
import com.epmet.dataaggre.entity.epmetuser.IcResiUserEntity;
import com.epmet.dataaggre.entity.govorg.*;
import com.epmet.dataaggre.entity.govproject.IcEventEntity;
@ -628,6 +630,12 @@ public class CoverageServiceImpl implements CoverageService {
// 志愿者
String[] parts = categoryKey.split("_");
return epmetUserService.countVolunteers(customerId, agencyId, staffOrgIds, search, parts[1]);
} else if (CoveragePlaceTypeEnum.VACCINE_POINT.getCode().equals(placeType)) {
// 疫苗接种点
return epmetUserService.countVaccinePoint(customerId, agencyId, staffOrgIds, search);
} else if (CoveragePlaceTypeEnum.NUCLEIC_POINT.getCode().equals(placeType)) {
// 核酸检测点
return epmetUserService.countNucleicPoint(customerId, agencyId, staffOrgIds, search);
}
return 0;
@ -805,6 +813,20 @@ public class CoverageServiceImpl implements CoverageService {
coordinates[1], coordinates[0]);
}).collect(Collectors.toList());
} else if (CoveragePlaceTypeEnum.VACCINE_POINT.getCode().equals(placeType)) {
// 疫苗接种点
List<IcPointVaccinesInoculationEntity> vps = epmetUserService.listVaccinePoints(customerId, agencyId, staffOrgIds, search);
return vps.stream()
.map(vp -> new CoverageAnalisisDataListResultDTO(vp.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null,
placeType, vp.getName(), vp.getLatitude(), vp.getLongitude()))
.collect(Collectors.toList());
} else if (CoveragePlaceTypeEnum.NUCLEIC_POINT.getCode().equals(placeType)) {
// 核酸检测点
List<IcPointNucleicMonitoringEntity> nps = epmetUserService.listNucleicPoints(customerId, agencyId, staffOrgIds, search);
return nps.stream()
.map(np -> new CoverageAnalisisDataListResultDTO(np.getId(), categoryKey, isPage ? categoryDict.getCategoryName() : null,
placeType, np.getName(), np.getLatitude(), np.getLongitude()))
.collect(Collectors.toList());
}
return new ArrayList<>();
}

121
epmet-module/oper-customize/oper-customize-server/src/main/java/com/epmet/service/impl/IcCustomerReportServiceImpl.java

@ -9,10 +9,7 @@ import com.epmet.commons.feignclient.dtos.JiMuPage;
import com.epmet.commons.feignclient.dtos.JiMuResult;
import com.epmet.commons.feignclient.dtos.form.JiMuReportFormDTO;
import com.epmet.commons.feignclient.dtos.form.JimuReportExportRequestDTO;
import com.epmet.commons.feignclient.dtos.result.JiMuReportDetailResultDTO;
import com.epmet.commons.feignclient.dtos.result.JiMuReportResultDTO;
import com.epmet.commons.feignclient.dtos.result.JimuReportDbDataResultDTO;
import com.epmet.commons.feignclient.dtos.result.JimuReportFieldTreeResultDTO;
import com.epmet.commons.feignclient.dtos.result.*;
import com.epmet.commons.feignclient.feigns.JiMuReportOpenFeignClient;
import com.epmet.commons.mybatis.service.impl.BaseServiceImpl;
import com.epmet.commons.tools.constant.*;
@ -280,45 +277,63 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
// 1. 首先去积木服务,查询出报表数据源的详细信息,包括报表url,isList;获取到哪一列是id(idFieldName)
// 根据报表id查询数据源列表,取出第一个
// 查询报表的字段列表(含数据源列表)
JiMuResult<List<List<JimuReportFieldTreeResultDTO>>> fResult = jiMuReportOpenFeignClient.fieldTree(reportId);
if (fResult == null || !fResult.isSuccess()) {
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到字段列表,报表ID:" + reportId, "根据报表id未找到字段列表,报表ID:" + reportId);
}
String datasourceId = fResult.getResult().get(0).get(0).getDbId();
// 根据数据源ID查询数据源信息
// 报表数据源信息
JiMuResult<JimuReportDbDataResultDTO> dbData = jiMuReportOpenFeignClient.loadDbData(datasourceId);
if (fResult == null || !fResult.isSuccess()) {
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到数据源,报表ID:" + reportId, "根据报表id未找到数据源,报表ID:" + reportId);
}
JimuReportDbDataResultDTO.ReportDB reportDb = dbData.getResult().getReportDb();
// 报表简要信息
JiMuResult<JiMuReportBriefResultDTO> reportBriefResult = jiMuReportOpenFeignClient.getReportBrief(reportId);
if (fResult == null || !fResult.isSuccess()) {
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "根据报表id未找到报表信息,报表ID:" + reportId, "根据报表id未找到报表信息,报表ID:" + reportId);
}
JiMuReportBriefResultDTO reportBrief = reportBriefResult.getResult();
// api的url
String apiUrl = reportDb.getApiUrl();
// api方法
//String apiMethod = reportDb.getApiMethod();
String apiMethod = reportDb.getApiMethod();
// 是否是集合
//String isList = reportDb.getIsList();
// 返回的列表中,哪个字段是ID
String idFieldName = null;
String nameFieldName = null;
boolean isHttps = false;
Matcher matcher = Pattern.compile("(http://|https://).+idFieldName=(\\w+).*").matcher(apiUrl);
Matcher matcher = Pattern.compile("(http://|https://).+idFieldName=(\\w+).+nameFieldName=(\\w+).*").matcher(apiUrl);
if (matcher.matches()) {
String proto = matcher.group(1);
if ("https://".equals(proto)) {
isHttps = true;
}
idFieldName = matcher.group(2);
nameFieldName = matcher.group(3);
}
if (StringUtils.isBlank(idFieldName)) {
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "配置的业务api url缺少idFieldName列");
}
if (StringUtils.isBlank(idFieldName)) {
throw new EpmetException(EpmetErrorCode.SERVER_ERROR.getCode(), "配置的业务api url缺少nameFieldName列");
}
// 2. 调用该url的接口,获取到一个列表,根据idFieldName取出ID列
List<String> ids = listIds(bizId, paramKey, apiUrl, isHttps, idFieldName);
HashMap<String, String> idAndNames = listBizObjectIdAndName(bizId, paramKey, apiUrl, isHttps, idFieldName, nameFieldName, apiMethod);
// 3. 然后以这一列作为查询条件,循环,继续调用该接口,得到单条数据,每一条数据都下载一个excel,最后将其打包为一个压缩包下载
Path storePath = makeTemporaryDownloadDir(reportId);
// 4.生成压缩文件
Path zipFile = downloadAndComppress(storePath, reportId, reportDb.getDbChName(), paramKey, ids);
Path zipFile = downloadAndCompress(storePath, reportId, reportBrief.getName(), paramKey, idAndNames);
// 5.下载
try (FileInputStream fis = new FileInputStream(zipFile.toFile())) {
@ -342,10 +357,9 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
/**
* 批量下载
* @param storePath 本次导出文件的存储路径子目录包括zip文件时间戳命名的子目录用于存放临时excel(导出完成会删掉)
* @param ids
* @return 压缩文件路径
*/
private Path downloadAndComppress(Path storePath, String reportId, String reportName, String paramKey, List<String> ids) {
private Path downloadAndCompress(Path storePath, String reportId, String reportName, String paramKey, HashMap<String, String> idAndNames) {
// 请求头
Map<String, Object> headers = new HashMap<>();
headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER));
@ -360,7 +374,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
param.getQueryParam().setParamKey(paramKey);
param.getQueryParam().setToken(EpmetRequestHolder.getLoginUserAuthorizationToken());
ArrayList<File> files = new ArrayList<>();
HashMap<String, File> files = new HashMap<>();
String currentTimeStr = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyyMMdd_HHmmss"));
@ -373,9 +387,11 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
}
// 将所有id分片,交给多个线程并行处理
List<List<String>> idParts = ListUtils.partition(ids, 100);
ArrayList<String> idList = new ArrayList<>();
idList.addAll(idAndNames.keySet());
List<List<String>> idParts = ListUtils.partition(idList, 100);
// 1. 循环下载所有id对应的excel
// 1. 循环下载所有id对应的excel(积木报表的导出接口有并发问题,多线程会导出空表,暂时不用多线程了)
CountDownLatch cdl = new CountDownLatch(idParts.size());
for (List<String> idPart : idParts) {
CompletableFuture.runAsync(() -> {
@ -397,9 +413,15 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
final ZipOutputStream zos = new ZipOutputStream(fos)) {
// 循环每一个文件
for (File file : files) {
try (final FileInputStream fis = new FileInputStream(file.getAbsolutePath())) {
zos.putNextEntry(new ZipEntry(reportName + "_" + currentTimeStr + "/" + file.getName()));
HashMap<String, Integer> bizObjNameAndCount = new HashMap<>(32);
for (Map.Entry<String, File> entry : files.entrySet()) {
String bizObjectId = entry.getKey();
File file = entry.getValue();
String bizObjName = getNumberedObjName(bizObjNameAndCount, idAndNames.get(bizObjectId));
try (FileInputStream fis = new FileInputStream(file.getAbsolutePath())) {
zos.putNextEntry(new ZipEntry(String.format("%s_%s/%s_%s.xlsx", reportName, currentTimeStr, reportName, bizObjName)));
final byte[] buffer = new byte[10240];
for (int len; (len = fis.read(buffer)) > 0; ) {
zos.write(buffer, 0, len);
@ -421,6 +443,28 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
return zipFile;
}
/**
* 为业务对象名称编号解决重名对象问题
* @param bizObjNameAndCount 业务对象名称/出现次数map
* @param bizObjName 原始业务对象名
* @return
*/
public String getNumberedObjName(HashMap<String, Integer> bizObjNameAndCount, String bizObjName) {
Integer nameCount = bizObjNameAndCount.get(bizObjName);
if (nameCount == null) {
nameCount = 1;
bizObjNameAndCount.put(bizObjName, nameCount);
} else {
bizObjNameAndCount.put(bizObjName, ++nameCount);
}
if (nameCount > 1) {
bizObjName = String.format("%s(%d)", bizObjName, nameCount);
}
return bizObjName;
}
/**
* 批量下载xlsx
* @param reportId
@ -429,21 +473,9 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
* @param xlsxStorePath
* @param files
*/
public void downloadXlsByBatchByBizId(String reportId, List<String> bizIds, JimuReportExportRequestDTO param, Path xlsxStorePath, ArrayList<File> files,
CountDownLatch cdl) {
public void downloadXlsByBatchByBizId(String reportId, List<String> bizIds, JimuReportExportRequestDTO param,
Path xlsxStorePath, Map<String, File> files, CountDownLatch cdl) {
for (String id : bizIds) {
try {
Thread.sleep(200l);
} catch (InterruptedException e) {
final String errorMsg = ExceptionUtils.getErrorStackTrace(e);
log.error("【报表批量导出】循环导出-请求jmreport,等待过程中睡眠发生意外:{}", errorMsg);
}
//if (!Arrays.asList("1501821697823608834","1501821694665297922","1501821695114088450","1501821695177003009","1501821695269277697","1501821695344775169","1501821695579656193","1501821695676125186","1501821695755816962","1501821695843897346","1501821695978115074","1501821696108138497","1501821696179441665","1501821696229773313","1501821696284299266","1501821696334630913","1501821696393351170","1501821696452071426","1501821696502403073","1501821696582094849","1501821696645009409","1501821696758255617","1501821696871501826","1501821696917639169","1501821696955387906","1501821696993136641","1501821697135742977","1501821697181880321","1501821697232211969","1501821697274155009").contains(id)) {
// continue;
//}
param.getQueryParam().setId(id);
final Response response = jiMuReportOpenFeignClient.exportAllExcelStream(param);
// 取出文件后缀
@ -456,7 +488,7 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
final File excelFile = xlsxStorePath.resolve("file_" + id + matcher.group(2)).toFile();
files.add(excelFile);
files.put(id, excelFile);
try (FileOutputStream fos = new FileOutputStream(excelFile)) {
IOUtils.copy(response.body().asInputStream(), fos);
} catch (Exception e) {
@ -507,26 +539,33 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
}
/**
* 列出id列表批量下载用
* 列出id和name列表(生成文件用到了name)批量下载用
*
* @param apiUrl
* @param isHttps
* @param idFieldName
* @return
*/
public List<String> listIds(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName) {
public HashMap<String, String> listBizObjectIdAndName(String id, String paramKey, String apiUrl, boolean isHttps, String idFieldName, String nameFieldName, String apiMethod) {
apiUrl = apiUrl.replace("'${id}'", id == null ? "" : id);
apiUrl = apiUrl.replace("'${paramKey}'", paramKey);
Map<String, Object> headers = new HashMap<>();
headers.put(Constant.AUTHORIZATION_HEADER, EpmetRequestHolder.getHeader(Constant.AUTHORIZATION_HEADER));
Result<String> stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":" + id + "}", headers);
Result<String> stringResult;
// 请求方法0-get,1-post
if (NumConstant.ONE_STR.equals(apiMethod)) {
stringResult = HttpClientManager.getInstance().sendPost(apiUrl, isHttps, "{\"id\":\"" + (id == null ? "" : id) + "\"}", headers);
} else {
stringResult = HttpClientManager.getInstance().sendGet(apiUrl, isHttps, null, headers);
}
JSONObject dataJsonObject = JSON.parseObject(stringResult.getData());
Object data = dataJsonObject.get("data");
JSONArray array = new JSONArray();
ArrayList<String> ids = new ArrayList<>();
JSONArray array;
HashMap<String, String> idAndNames = new HashMap<>();
if (data instanceof JSONObject) {
// 这种可能是pageData的
@ -539,8 +578,10 @@ public class IcCustomerReportServiceImpl extends BaseServiceImpl<IcCustomerRepor
for (ListIterator<Object> it = array.listIterator(); it.hasNext(); ) {
JSONObject e = (JSONObject) it.next();
ids.add(e.getString(idFieldName));
String idValue = e.getString(idFieldName);
String nameValue = e.getString(nameFieldName);
idAndNames.put(idValue, nameValue);
}
return ids;
return idAndNames;
}
}

2
epmet-user/epmet-user-server/src/main/java/com/epmet/controller/IcResiUserController.java

@ -560,7 +560,7 @@ public class IcResiUserController implements ResultDataResolver {
* @remark 用于报表调用的接口 试试
*/
@ReportRequest
@NoRepeatSubmit
//@NoRepeatSubmit
@RequestMapping(value = "/exportExcelCustomData")
public Map<String, Object> exportExcelCustomData(@LoginUser TokenDto tokenDto, @RequestParam("templateId") String templateId,
@RequestBody ExportResiUserFormDTO pageFormDTO) throws Exception {

Loading…
Cancel
Save