Commit 7461ee2f by 叶立庆

Merge branch 'master' into 'v5.8.2.1'

上线合并

See merge request !1
2 parents 4dcf2dfd 74063a85
...@@ -114,14 +114,17 @@ public class DailyReportDataService { ...@@ -114,14 +114,17 @@ public class DailyReportDataService {
return null; return null;
} }
DailyReportRecord latestRecord = queryLatestSubmittedRecord(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate); List<DailyReportRecord> recordList = querySubmittedRecordsByDate(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate);
if (latestRecord == null) { if (CollectionUtils.isEmpty(recordList)) {
log.info("queryNegotiationData no record found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryNegotiationData no record found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return null; return null;
} }
Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(Collections.singletonList(latestRecord.getId())); DailyReportRecord latestRecord = recordList.get(recordList.size() - 1);
List<Map<String, String>> negotiationRows = buildNegotiationRows(latestRecord, subformDataMap); Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(recordList.stream()
.map(DailyReportRecord::getId)
.collect(Collectors.toList()));
List<Map<String, String>> negotiationRows = collectNegotiationRows(recordList, record -> buildNegotiationRows(record, subformDataMap));
if (CollectionUtils.isEmpty(negotiationRows)) { if (CollectionUtils.isEmpty(negotiationRows)) {
log.info("queryNegotiationData no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryNegotiationData no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return null; return null;
...@@ -205,14 +208,17 @@ public class DailyReportDataService { ...@@ -205,14 +208,17 @@ public class DailyReportDataService {
return Collections.emptyList(); return Collections.emptyList();
} }
DailyReportRecord latestRecord = queryLatestSubmittedRecord(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate); List<DailyReportRecord> recordList = querySubmittedRecordsByDate(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate);
if (latestRecord == null) { if (CollectionUtils.isEmpty(recordList)) {
log.info("queryExtendedWarrantyNegotiationRows no record found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryExtendedWarrantyNegotiationRows no record found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return Collections.emptyList(); return Collections.emptyList();
} }
Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(Collections.singletonList(latestRecord.getId())); Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(recordList.stream()
List<Map<String, String>> negotiationRows = buildExtendedWarrantyNegotiationRows(latestRecord, subformDataMap); .map(DailyReportRecord::getId)
.collect(Collectors.toList()));
List<Map<String, String>> negotiationRows = collectNegotiationRows(recordList,
record -> buildExtendedWarrantyNegotiationRows(record, subformDataMap));
if (CollectionUtils.isEmpty(negotiationRows)) { if (CollectionUtils.isEmpty(negotiationRows)) {
log.info("queryExtendedWarrantyNegotiationRows no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryExtendedWarrantyNegotiationRows no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return Collections.emptyList(); return Collections.emptyList();
...@@ -231,14 +237,17 @@ public class DailyReportDataService { ...@@ -231,14 +237,17 @@ public class DailyReportDataService {
return Collections.emptyList(); return Collections.emptyList();
} }
DailyReportRecord latestRecord = queryLatestSubmittedRecord(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate); List<DailyReportRecord> recordList = querySubmittedRecordsByDate(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate);
if (latestRecord == null) { if (CollectionUtils.isEmpty(recordList)) {
log.info("queryExtendedWarrantyLanTuNegotiationRows no record found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryExtendedWarrantyLanTuNegotiationRows no record found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return Collections.emptyList(); return Collections.emptyList();
} }
Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(Collections.singletonList(latestRecord.getId())); Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(recordList.stream()
List<Map<String, String>> negotiationRows = buildExtendedWarrantyLanTuNegotiationRows(latestRecord, subformDataMap); .map(DailyReportRecord::getId)
.collect(Collectors.toList()));
List<Map<String, String>> negotiationRows = collectNegotiationRows(recordList,
record -> buildExtendedWarrantyLanTuNegotiationRows(record, subformDataMap));
if (CollectionUtils.isEmpty(negotiationRows)) { if (CollectionUtils.isEmpty(negotiationRows)) {
log.info("queryExtendedWarrantyLanTuNegotiationRows no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryExtendedWarrantyLanTuNegotiationRows no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return Collections.emptyList(); return Collections.emptyList();
...@@ -287,14 +296,17 @@ public class DailyReportDataService { ...@@ -287,14 +296,17 @@ public class DailyReportDataService {
return Collections.emptyList(); return Collections.emptyList();
} }
DailyReportRecord latestRecord = queryLatestSubmittedRecord(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate); List<DailyReportRecord> recordList = querySubmittedRecordsByDate(merchantId, DailyReportTemplateTypeEnum.DISCUSSION.getValue(), reportDate);
if (latestRecord == null) { if (CollectionUtils.isEmpty(recordList)) {
log.info("queryExtendedWarrantyOtherNegotiationRows no record found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryExtendedWarrantyOtherNegotiationRows no record found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return Collections.emptyList(); return Collections.emptyList();
} }
Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(Collections.singletonList(latestRecord.getId())); Map<Integer, List<DailyReportSubformData>> subformDataMap = querySubformDataMap(recordList.stream()
List<Map<String, String>> negotiationRows = buildExtendedWarrantyOtherNegotiationRows(latestRecord, subformDataMap); .map(DailyReportRecord::getId)
.collect(Collectors.toList()));
List<Map<String, String>> negotiationRows = collectNegotiationRows(recordList,
record -> buildExtendedWarrantyOtherNegotiationRows(record, subformDataMap));
if (CollectionUtils.isEmpty(negotiationRows)) { if (CollectionUtils.isEmpty(negotiationRows)) {
log.info("queryExtendedWarrantyOtherNegotiationRows no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate); log.info("queryExtendedWarrantyOtherNegotiationRows no rows found, merchantId:{}, reportDate:{}", merchantId, reportDate);
return Collections.emptyList(); return Collections.emptyList();
...@@ -362,6 +374,21 @@ public class DailyReportDataService { ...@@ -362,6 +374,21 @@ public class DailyReportDataService {
} }
/** /**
* 查询指定日期下当天所有已提交的日报记录
*/
private List<DailyReportRecord> querySubmittedRecordsByDate(Integer merchantId, Byte templateType, String reportDate) {
Example example = new Example(DailyReportRecord.class);
example.createCriteria()
.andEqualTo("deletedFlag", DeleteFlagEnum.N.getValue())
.andEqualTo("merchantId", merchantId)
.andEqualTo("templateType", templateType)
.andEqualTo("reportStatus", (byte) 1)
.andEqualTo("reportDate", reportDate);
example.setOrderByClause("id asc");
return dailyReportRecordMapper.selectByExample(example);
}
/**
* 今日汇总 * 今日汇总
*/ */
private LightChangeDailyReportData.DailyReportSummary buildTodaySummary(Integer recordId, private LightChangeDailyReportData.DailyReportSummary buildTodaySummary(Integer recordId,
...@@ -1286,10 +1313,20 @@ public class DailyReportDataService { ...@@ -1286,10 +1313,20 @@ public class DailyReportDataService {
summary.setMonthAvgOrderPrice(monthAvgOrderPriceTotal); summary.setMonthAvgOrderPrice(monthAvgOrderPriceTotal);
summary.setMonthOriginalFilmUpgradeCount(monthOriginalFilmUpgradeCount); summary.setMonthOriginalFilmUpgradeCount(monthOriginalFilmUpgradeCount);
if (!Objects.equals(monthOriginalFilmSystemCount, BigDecimal.ZERO)) {
monthOriginalFilmSystemCount = monthOriginalFilmSystemCount.multiply(BigDecimal.valueOf(100));
}
summary.setMonthOriginalFilmPermeability(monthOriginalFilmSystemCount); summary.setMonthOriginalFilmPermeability(monthOriginalFilmSystemCount);
summary.setMonthOriginalCarCoatUpgradeCount(monthOriginalCarCoatUpgradeCount); summary.setMonthOriginalCarCoatUpgradeCount(monthOriginalCarCoatUpgradeCount);
if (!Objects.equals(monthOriginalCarCoatSystemCount, BigDecimal.ZERO)) {
monthOriginalCarCoatSystemCount = monthOriginalCarCoatSystemCount.multiply(BigDecimal.valueOf(100));
}
summary.setMonthOriginalCarCoatPermeability(monthOriginalCarCoatSystemCount); summary.setMonthOriginalCarCoatPermeability(monthOriginalCarCoatSystemCount);
summary.setMonthBoutiqueUpgradeCount(monthBoutiqueUpgradeCount); summary.setMonthBoutiqueUpgradeCount(monthBoutiqueUpgradeCount);
if (!Objects.equals(monthBoutiqueSystemCount, BigDecimal.ZERO)) {
monthBoutiqueSystemCount = monthBoutiqueSystemCount.multiply(BigDecimal.valueOf(100));
}
summary.setMonthBoutiqueUpgradeRate(monthBoutiqueSystemCount); summary.setMonthBoutiqueUpgradeRate(monthBoutiqueSystemCount);
if (monthBookingCount > 0 && monthBookingTouchCount > 0) { if (monthBookingCount > 0 && monthBookingTouchCount > 0) {
...@@ -1395,6 +1432,22 @@ public class DailyReportDataService { ...@@ -1395,6 +1432,22 @@ public class DailyReportDataService {
return result; return result;
} }
private List<Map<String, String>> collectNegotiationRows(List<DailyReportRecord> recordList,
java.util.function.Function<DailyReportRecord, List<Map<String, String>>> rowBuilder) {
if (CollectionUtils.isEmpty(recordList) || rowBuilder == null) {
return Collections.emptyList();
}
List<Map<String, String>> result = new ArrayList<>();
for (DailyReportRecord record : recordList) {
List<Map<String, String>> rows = rowBuilder.apply(record);
if (CollectionUtils.isEmpty(rows)) {
continue;
}
result.addAll(rows);
}
return result;
}
private Map<String, String> buildSalesRow(String merchantName, String reportDate, String staffName, private Map<String, String> buildSalesRow(String merchantName, String reportDate, String staffName,
Map<String, String> todayRow, List<Map<String, String>> monthRows) { Map<String, String> todayRow, List<Map<String, String>> monthRows) {
Map<String, String> row = new LinkedHashMap<>(); Map<String, String> row = new LinkedHashMap<>();
......
...@@ -798,6 +798,7 @@ public class DailyReportRecordService { ...@@ -798,6 +798,7 @@ public class DailyReportRecordService {
.andEqualTo("merchantId", dailyReportRecordDTO.getMerchantId()) .andEqualTo("merchantId", dailyReportRecordDTO.getMerchantId())
.andEqualTo("sceneType", dailyReportRecordDTO.getSceneType()) .andEqualTo("sceneType", dailyReportRecordDTO.getSceneType())
.andEqualTo("templateType", dailyReportRecordDTO.getTemplateType()) .andEqualTo("templateType", dailyReportRecordDTO.getTemplateType())
.andEqualTo("reportStatus", dailyReportRecordDTO.getReportStatus())
.andBetween("reportDate", dailyReportRecordDTO.getReportStartDate(), dailyReportRecordDTO.getReportEndDate()); .andBetween("reportDate", dailyReportRecordDTO.getReportStartDate(), dailyReportRecordDTO.getReportEndDate());
// 门店日报不按个人维度过滤 // 门店日报不按个人维度过滤
if (!Objects.equals(DailyReportTemplateTypeEnum.MERCHANT_DAILY_REPORT.getValue(), dailyReportRecordDTO.getTemplateType())) { if (!Objects.equals(DailyReportTemplateTypeEnum.MERCHANT_DAILY_REPORT.getValue(), dailyReportRecordDTO.getTemplateType())) {
......
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!