导出优化
This commit is contained in:
@@ -17,7 +17,6 @@
|
||||
<select id="getPayTimeByShopIds" resultType="com.cool.store.dto.FranchiseFeeDTO">
|
||||
select a.shop_id AS shopId ,
|
||||
b.pay_time as payTime,
|
||||
b.combined_field as combinedField,
|
||||
a.year_franchise_fee as yearFranchiseFee,
|
||||
a.first_year_manage_fee as firstYearManagementFee,
|
||||
a.loan_margin as loanMargin,
|
||||
|
||||
@@ -32,8 +32,6 @@ public class FranchiseFeeDTO {
|
||||
private String firstYearFee;
|
||||
//履约保证金
|
||||
private String performanceBond;
|
||||
//组合字段
|
||||
private String combinedField;
|
||||
|
||||
private List<Date> payTimeList;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user