diff --git a/blade-biz-common/src/main/java/org/springblade/common/utils/GaoDeApiUtil.java b/blade-biz-common/src/main/java/org/springblade/common/utils/GaoDeApiUtil.java index 15a7c24c4..467696375 100644 --- a/blade-biz-common/src/main/java/org/springblade/common/utils/GaoDeApiUtil.java +++ b/blade-biz-common/src/main/java/org/springblade/common/utils/GaoDeApiUtil.java @@ -85,6 +85,7 @@ public class GaoDeApiUtil { * @Author zqb 2024/9/14 **/ public static Long measureDistance(String origins, String destination) { + // 计算距离服务高德每秒钟只能接收3次,需要评估每秒请求次数 // lat 小 log 大 String key = "40448f21dfc7a531e9db4c405d955bea"; String urlString = "https://restapi.amap.com/v3/distance?key=" + key + "&origins=" + origins + "&destination=" + destination; @@ -102,6 +103,7 @@ public class GaoDeApiUtil { in.close(); // 解析结果 JSONObject jsonObject = JSONObject.parseObject(res); + log.info("根据经纬度测量路径获取成功:{}", jsonObject.toJSONString()); JSONArray results = jsonObject.getJSONArray("results"); if (CollUtil.isNotEmpty(results)) { return results.getJSONObject(0).getLong("distance"); diff --git a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java index d8dd89f30..c0e68d627 100644 --- a/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java +++ b/blade-service-api/logpm-statisticsdata-api/src/main/java/com/logpm/statistics/feign/IExpenseDispatchClient.java @@ -25,8 +25,8 @@ public interface IExpenseDispatchClient { void saveTrainDetailEntity(@RequestBody ExpenseDispatchTrainDetailEntity entity); @PostMapping(API_PREFIX + "/saveDispatchOrderDetailEntity") - void saveDispatchOrderDetailEntity(ExpenseDispatchOrderDetailEntity orderDetailEntity); + void saveDispatchOrderDetailEntity(@RequestBody ExpenseDispatchOrderDetailEntity orderDetailEntity); @PostMapping(API_PREFIX + "/saveWarehouseOrderEntity") - void saveWarehouseOrderEntity(ExpenseWarehouseOrderEntity orderDetailEntity); + void saveWarehouseOrderEntity(@RequestBody ExpenseWarehouseOrderEntity orderDetailEntity); } diff --git a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java index 3203dac2f..d56c7cfab 100644 --- a/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java +++ b/blade-service/logpm-distribution/src/main/java/com/logpm/distribution/receiver/report/DeliverFinishReportListener.java @@ -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 waybillOrderMap = calculateTripCost(trainNumber, deliveryKind); + // 生成订单 发送延时消息生成报表 + if (CollUtil.isNotEmpty(waybillOrderMap)) { + for (Map.Entry 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 calculateTripCost(String trainNumber, String deliveryKindParam) { // 根据车次查询出包件明细,然后计算对应的成本 List entities = qualityDeliverService.list(Wrappers.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 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 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));