导出优化

This commit is contained in:
shuo.wang
2025-02-24 18:42:51 +08:00
parent a064b1b08e
commit 778a87403f
3 changed files with 6 additions and 50 deletions

View File

@@ -17,7 +17,6 @@
<select id="getPayTimeByShopIds" resultType="com.cool.store.dto.FranchiseFeeDTO"> <select id="getPayTimeByShopIds" resultType="com.cool.store.dto.FranchiseFeeDTO">
select a.shop_id AS shopId , select a.shop_id AS shopId ,
b.pay_time as payTime, b.pay_time as payTime,
b.combined_field as combinedField,
a.year_franchise_fee as yearFranchiseFee, a.year_franchise_fee as yearFranchiseFee,
a.first_year_manage_fee as firstYearManagementFee, a.first_year_manage_fee as firstYearManagementFee,
a.loan_margin as loanMargin, a.loan_margin as loanMargin,

View File

@@ -32,8 +32,6 @@ public class FranchiseFeeDTO {
private String firstYearFee; private String firstYearFee;
//履约保证金 //履约保证金
private String performanceBond; private String performanceBond;
//组合字段
private String combinedField;
private List<Date> payTimeList; private List<Date> payTimeList;
} }

View File

@@ -107,16 +107,9 @@ public class ExportRealizeServiceImpl implements ExportRealizeService {
List<Long> shopIds = list.stream().map(BranchShopResponse::getShopId).collect(Collectors.toList()); List<Long> shopIds = list.stream().map(BranchShopResponse::getShopId).collect(Collectors.toList());
List<SignFranchiseDO> signFranchises = signFranchiseMapper.selectByShopIds(shopIds); List<SignFranchiseDO> signFranchises = signFranchiseMapper.selectByShopIds(shopIds);
List<FranchiseFeeDTO> franchiseFees = franchiseFeeMapper.getPayTimeByShopIds(shopIds); List<FranchiseFeeDTO> franchiseFees = franchiseFeeMapper.getPayTimeByShopIds(shopIds);
Map<Long, List<Date>> payTimeMap = new HashMap<>(); Map<Long, Date> payTimeMap = franchiseFees.stream().filter(o -> o.getPayTime() != null)
for (FranchiseFeeDTO dto : franchiseFees) { .filter(o -> o.getShopId() != null)
List<Date> payTimeList = JsonToDate(dto.getCombinedField()); .collect(Collectors.toMap(FranchiseFeeDTO::getShopId, FranchiseFeeDTO::getPayTime));
if (dto.getPayTime() != null) {
payTimeList.add(dto.getPayTime());
}
Collections.sort(payTimeList);
payTimeMap.put(dto.getShopId(), payTimeList);
}
Map<Long, FranchiseFeeDTO> franchiseFeeDTOMap = franchiseFees.stream().filter(o -> o.getShopId() != null) Map<Long, FranchiseFeeDTO> franchiseFeeDTOMap = franchiseFees.stream().filter(o -> o.getShopId() != null)
.collect(Collectors.toMap(FranchiseFeeDTO::getShopId, Function.identity())); .collect(Collectors.toMap(FranchiseFeeDTO::getShopId, Function.identity()));
Map<Long, SignFranchiseDO> signFranchiseMap = new HashMap<>(); Map<Long, SignFranchiseDO> signFranchiseMap = new HashMap<>();
@@ -157,22 +150,9 @@ public class ExportRealizeServiceImpl implements ExportRealizeService {
dto.setContractStartTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, signFranchiseDO.getContractStartTime())); dto.setContractStartTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, signFranchiseDO.getContractStartTime()));
dto.setContractEndTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, signFranchiseDO.getContractEndTime())); dto.setContractEndTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, signFranchiseDO.getContractEndTime()));
} }
List<Date> payTime = payTimeMap.getOrDefault(response.getShopId(), new ArrayList<>()); Date payTime = payTimeMap.get(response.getShopId());
for (int i = 0; i < payTime.size() && i <= 3; i++) { if (Objects.nonNull(payTime)) {
switch (i) { dto.setFirstPayTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, payTime));
case 0:
dto.setFirstPayTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, payTime.get(i)));
break;
case 1:
dto.setSecondPayTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, payTime.get(i)));
break;
case 2:
dto.setThirdPayTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, payTime.get(i)));
break;
case 3:
dto.setFourthPayTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, payTime.get(i)));
break;
}
} }
InvoicingDO invoicingDO = InvoicingMap.get(response.getShopId()); InvoicingDO invoicingDO = InvoicingMap.get(response.getShopId());
if (invoicingDO != null) { if (invoicingDO != null) {
@@ -216,26 +196,5 @@ public class ExportRealizeServiceImpl implements ExportRealizeService {
} }
return o.toString(); return o.toString();
} }
private List<Date> JsonToDate(String json) {
ObjectMapper mapper = new ObjectMapper();
// 解析JSON字符串为JsonNode对象
JsonNode jsonNode = null;
try {
jsonNode = mapper.readTree(json);
List<Date> payTimeList = new ArrayList<>();
// 遍历数组节点
for (JsonNode node : jsonNode) {
long payTime = node.get("payTime").asLong();
// 将时间戳转换为Date对象
Date date = new Date(payTime);
payTimeList.add(date);
}
return payTimeList;
} catch (Exception e) {
log.info("解析加盟费缴纳时间json失败");
throw new RuntimeException(e);
}
}
} }