导出优化

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

@@ -107,16 +107,9 @@ public class ExportRealizeServiceImpl implements ExportRealizeService {
List<Long> shopIds = list.stream().map(BranchShopResponse::getShopId).collect(Collectors.toList());
List<SignFranchiseDO> signFranchises = signFranchiseMapper.selectByShopIds(shopIds);
List<FranchiseFeeDTO> franchiseFees = franchiseFeeMapper.getPayTimeByShopIds(shopIds);
Map<Long, List<Date>> payTimeMap = new HashMap<>();
for (FranchiseFeeDTO dto : franchiseFees) {
List<Date> payTimeList = JsonToDate(dto.getCombinedField());
if (dto.getPayTime() != null) {
payTimeList.add(dto.getPayTime());
}
Collections.sort(payTimeList);
payTimeMap.put(dto.getShopId(), payTimeList);
}
Map<Long, Date> payTimeMap = franchiseFees.stream().filter(o -> o.getPayTime() != null)
.filter(o -> o.getShopId() != null)
.collect(Collectors.toMap(FranchiseFeeDTO::getShopId, FranchiseFeeDTO::getPayTime));
Map<Long, FranchiseFeeDTO> franchiseFeeDTOMap = franchiseFees.stream().filter(o -> o.getShopId() != null)
.collect(Collectors.toMap(FranchiseFeeDTO::getShopId, Function.identity()));
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.setContractEndTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, signFranchiseDO.getContractEndTime()));
}
List<Date> payTime = payTimeMap.getOrDefault(response.getShopId(), new ArrayList<>());
for (int i = 0; i < payTime.size() && i <= 3; i++) {
switch (i) {
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;
}
Date payTime = payTimeMap.get(response.getShopId());
if (Objects.nonNull(payTime)) {
dto.setFirstPayTime(DateUtils.parseDateToStr(SPECIAL_DATE_START_1, payTime));
}
InvoicingDO invoicingDO = InvoicingMap.get(response.getShopId());
if (invoicingDO != null) {
@@ -216,26 +196,5 @@ public class ExportRealizeServiceImpl implements ExportRealizeService {
}
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);
}
}
}