|
|
|
@ -80,7 +80,18 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
FinishDistributionTrainVO vo = JSONUtil.toBean(entries, FinishDistributionTrainVO.class); |
|
|
|
|
String trainNumber = vo.getTrainNumber(); |
|
|
|
|
String deliveryKind = vo.getDeliveryKind(); |
|
|
|
|
calculateTripCost(trainNumber, deliveryKind); |
|
|
|
|
Map<String, TrunklineWaybillOrderEntity> waybillOrderMap = calculateTripCost(trainNumber, deliveryKind); |
|
|
|
|
// 生成订单 发送延时消息生成报表
|
|
|
|
|
if (CollUtil.isNotEmpty(waybillOrderMap)) { |
|
|
|
|
for (Map.Entry<String, TrunklineWaybillOrderEntity> entityEntry : waybillOrderMap.entrySet()) { |
|
|
|
|
factoryDataClient.sendMessage(SendMsg.builder() |
|
|
|
|
.exchange(ReportConstants.REPORT_EXPENSE_ORDER_EXCHANGE) |
|
|
|
|
.routingKey(ReportConstants.REPORT_EXPENSE_ORDER_ROUTINGKEY) |
|
|
|
|
.message(JSONUtil.toJsonStr(entityEntry.getValue())) |
|
|
|
|
.delay(10000) |
|
|
|
|
.build()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 生成车辆车次成本 发送延时消息生成报表
|
|
|
|
|
factoryDataClient.sendMessage(SendMsg.builder() |
|
|
|
|
.exchange(ReportConstants.REPORT_QUALITY_CAR_FINAL_EXCHANGE) |
|
|
|
@ -92,7 +103,7 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void calculateTripCost(String trainNumber, String deliveryKindParam) { |
|
|
|
|
public Map<String, TrunklineWaybillOrderEntity> calculateTripCost(String trainNumber, String deliveryKindParam) { |
|
|
|
|
// 根据车次查询出包件明细,然后计算对应的成本
|
|
|
|
|
List<QualityDeliverEntity> entities = qualityDeliverService.list(Wrappers.<QualityDeliverEntity>lambdaQuery() |
|
|
|
|
.eq(QualityDeliverEntity::getSignTrainNumber, trainNumber) |
|
|
|
@ -142,7 +153,7 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
for (QualityDeliverEntity qualityDeliverEntity : value) { |
|
|
|
|
QualityDeliverEntity entity = new QualityDeliverEntity(); |
|
|
|
|
entity.setId(qualityDeliverEntity.getId()); |
|
|
|
|
if(ObjectUtil.isEmpty(entity.getCarComplateTime())){ |
|
|
|
|
if(ObjectUtil.isEmpty(qualityDeliverEntity.getCarComplateTime())){ |
|
|
|
|
entity.setCarComplateTime(new Date()); |
|
|
|
|
} |
|
|
|
|
entity.setOrderCode(qualityDeliverEntity.getOrderCode()); |
|
|
|
@ -381,6 +392,7 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
String key = allEntry.getKey(); |
|
|
|
|
lastCode = key; |
|
|
|
|
if (StrUtil.isNotEmpty(allEntry.getValue())) { |
|
|
|
|
log.info("公里数成本 总公里数:{},{}",key, allEntry.getValue()); |
|
|
|
|
total = NumberUtil.add(total, new BigDecimal(allEntry.getValue())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -391,6 +403,7 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
if (CollUtil.isNotEmpty(firstRouteMap)) { |
|
|
|
|
String s = firstRouteMap.get(lastCode); |
|
|
|
|
if (StrUtil.isNotEmpty(s)) { |
|
|
|
|
log.info("公里数成本 返程公里数:{}", s); |
|
|
|
|
total = total.add(new BigDecimal(s)); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -908,23 +921,13 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
waybillOrderMap.put(key, waybillOrderEntity); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
// 生成订单 发送延时消息生成报表
|
|
|
|
|
if (CollUtil.isNotEmpty(waybillOrderMap)) { |
|
|
|
|
for (Map.Entry<String, TrunklineWaybillOrderEntity> entityEntry : waybillOrderMap.entrySet()) { |
|
|
|
|
factoryDataClient.sendMessage(SendMsg.builder() |
|
|
|
|
.exchange(ReportConstants.REPORT_EXPENSE_ORDER_EXCHANGE) |
|
|
|
|
.routingKey(ReportConstants.REPORT_EXPENSE_ORDER_ROUTINGKEY) |
|
|
|
|
.message(JSONUtil.toJsonStr(entityEntry.getValue())) |
|
|
|
|
.delay(10000) |
|
|
|
|
.build()); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return waybillOrderMap; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
private static BigDecimal buildDisCost(QualityDeliverEntity entity, ExpenseDispatchPriceCategoryVO expenseDispatchPriceCategoryVO, QualityDeliverEntity entity1, BigDecimal totalFreight) { |
|
|
|
@ -1036,6 +1039,7 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
private static void buildKilometerCost(ExpenseDispatchPriceVO priceVO, BigDecimal total, Map<Long, QualityDeliverEntity> valueMap, Integer totalNum) { |
|
|
|
|
String kilometerCost = StrUtil.isEmpty(priceVO.getKilometerCost()) ? "0" : priceVO.getKilometerCost(); |
|
|
|
|
BigDecimal mul = NumberUtil.mul(total, new BigDecimal(kilometerCost)); |
|
|
|
|
log.info("公里数成本:{},{},{}", kilometerCost, Convert.toStr(total), Convert.toStr(mul)); |
|
|
|
|
BigDecimal deliveryFeeSum = BigDecimal.ZERO; |
|
|
|
|
int idex = 0; |
|
|
|
|
int size = valueMap.size(); |
|
|
|
@ -1097,12 +1101,20 @@ public class DeliverFinishReportListener implements ReportService {
|
|
|
|
|
if (StrUtil.isNotEmpty(arrivePositioning)) { |
|
|
|
|
// A-B A-C A-D 仓库为起点到每一个点的距离
|
|
|
|
|
Long first = GaoDeApiUtil.measureDistance(firstPositioning, arrivePositioning); |
|
|
|
|
log.info("点位计算结果 first:{}", first); |
|
|
|
|
firstRouteMap.put(value1.getSignReservationCode(), Convert.toStr(ObjectUtil.isNotEmpty(first) ? NumberUtil.div(new BigDecimal(first), 1000) : 0L / 1000)); |
|
|
|
|
if (StrUtil.isEmpty(beforePositioning)) { |
|
|
|
|
beforePositioning = firstPositioning; |
|
|
|
|
} |
|
|
|
|
// 等500毫秒再次调用
|
|
|
|
|
try { |
|
|
|
|
Thread.sleep(500); |
|
|
|
|
} catch (InterruptedException e) { |
|
|
|
|
e.printStackTrace(); |
|
|
|
|
} |
|
|
|
|
// A-B B-C C-D 每一个点为起点到下一个点的距离
|
|
|
|
|
Long distance = GaoDeApiUtil.measureDistance(beforePositioning, arrivePositioning); |
|
|
|
|
log.info("点位计算结果 distance:{}", distance); |
|
|
|
|
String str = Convert.toStr(ObjectUtil.isNotEmpty(distance) ? NumberUtil.div(new BigDecimal(distance), 1000) : 0L / 1000); |
|
|
|
|
// 获取上一个点位的总距离
|
|
|
|
|
// reduce = NumberUtil.add(reduce, new BigDecimal(str));
|
|
|
|
|