|
|
@@ -58,6 +58,7 @@ import com.sckw.order.model.vo.res.OrderDetailRes;
|
|
|
import com.sckw.order.model.vo.res.UnitInfoDetailRes;
|
|
|
import com.sckw.order.model.vo.res.*;
|
|
|
import com.sckw.order.repository.KwoTradeOrderUnitRepository;
|
|
|
+import com.sckw.order.util.TradeOrderDashboardUtils;
|
|
|
import com.sckw.payment.api.dubbo.PayCenterDubboService;
|
|
|
import com.sckw.payment.api.dubbo.PaymentDubboService;
|
|
|
import com.sckw.payment.api.feign.PaymentFeignService;
|
|
|
@@ -82,6 +83,7 @@ import com.sckw.system.api.feign.DataPermissionFeignService;
|
|
|
import com.sckw.system.api.model.dto.req.ActualDisPatchDto;
|
|
|
import com.sckw.system.api.model.dto.req.DataPermissionFilterReqDto;
|
|
|
import com.sckw.system.api.model.dto.res.*;
|
|
|
+import com.sckw.transport.api.dubbo.TransportRemoteStatisticsService;
|
|
|
import com.sckw.transport.api.dubbo.TransportRemoteService;
|
|
|
import com.sckw.transport.api.model.dto.TradeOrderWaybillAggDto;
|
|
|
import com.sckw.transport.api.model.param.AddLogisticOrderParam;
|
|
|
@@ -102,7 +104,10 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
+import java.time.LocalDate;
|
|
|
import java.time.LocalDateTime;
|
|
|
+import java.time.ZoneId;
|
|
|
+import java.time.temporal.TemporalAdjusters;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.function.Function;
|
|
|
@@ -141,6 +146,9 @@ public class KwoTradeOrderService {
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false)
|
|
|
private TransportRemoteService transportRemoteService;
|
|
|
|
|
|
+ @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ private TransportRemoteStatisticsService transportRemoteStatisticsService;
|
|
|
+
|
|
|
@DubboReference(version = "1.0.0", group = "design", check = false, timeout = 6000)
|
|
|
protected RemoteFleetService remoteFleetService;
|
|
|
|
|
|
@@ -672,6 +680,7 @@ public class KwoTradeOrderService {
|
|
|
List<OrderProcess> orderProcesses = new ArrayList<>(tracks.size());
|
|
|
List<Long> createBys = tracks.stream().map(KwoTradeOrderTrack::getCreateBy).distinct().toList();
|
|
|
Map<Long, UserCacheResDto> map = remoteSystemService.queryUserCacheMapByIds(createBys);
|
|
|
+ List<Integer> statusList = Arrays.asList(TradeOrderStatusEnum.AUDIT.getCode(), TradeOrderStatusEnum.ING.getCode(), TradeOrderStatusEnum.DEAL.getCode());
|
|
|
tracks.forEach(e -> {
|
|
|
OrderProcess process = BeanUtil.copyProperties(e, OrderProcess.class);
|
|
|
UserCacheResDto user = map.get(process.getCreateBy());
|
|
|
@@ -682,10 +691,22 @@ public class KwoTradeOrderService {
|
|
|
process.setRoleName(String.join(",", roleNames));
|
|
|
}
|
|
|
}
|
|
|
- process.setStatusLabel(OrderStatusEnum.getMsg(process.getStatus()));
|
|
|
- orderProcesses.add(process);
|
|
|
+ if (statusList.contains(process.getStatus())){
|
|
|
+ if (Objects.equals(process.getStatus(),TradeOrderStatusEnum.AUDIT.getCode())){
|
|
|
+ process.setStatusLabel("订单创建");
|
|
|
+ }
|
|
|
+ if (Objects.equals(process.getStatus(),TradeOrderStatusEnum.ING.getCode())){
|
|
|
+ process.setStatusLabel("审核");
|
|
|
+ }
|
|
|
+ if (Objects.equals(process.getStatus(),TradeOrderStatusEnum.DEAL.getCode())){
|
|
|
+ process.setStatusLabel("结算");
|
|
|
+ }
|
|
|
+ orderProcesses.add(process);
|
|
|
+ }
|
|
|
});
|
|
|
- detail.setOrderProcess(orderProcesses);
|
|
|
+ List<OrderProcess> orderProcesses1 = orderProcesses.stream().sorted(Comparator.comparing(OrderProcess::getCreateTime).reversed()).collect(Collectors.toList());
|
|
|
+
|
|
|
+ detail.setOrderProcess(orderProcesses1);
|
|
|
return detail;
|
|
|
}
|
|
|
|
|
|
@@ -1881,6 +1902,86 @@ public class KwoTradeOrderService {
|
|
|
return statistics;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 贸易订单详情看板:完成率、今日/本月完成量、已派车次数(与贸易订单关联运单,按计费方式统计装卸货量)
|
|
|
+ *
|
|
|
+ * @param tOrderId 贸易订单主键
|
|
|
+ * @return 看板数据
|
|
|
+ */
|
|
|
+ public TradeOrderDashboardVO tradeOrderDashboardStatistic(Long tOrderId) {
|
|
|
+ if (Objects.isNull(tOrderId) || tOrderId <= 0) {
|
|
|
+ throw new BusinessException("贸易订单主键不能为空");
|
|
|
+ }
|
|
|
+ KwoTradeOrder order = kwoTradeOrderMapper.selectById(tOrderId);
|
|
|
+ if (order == null) {
|
|
|
+ throw new BusinessException("不存在该订单!");
|
|
|
+ }
|
|
|
+ ZoneId zone = ZoneId.of("Asia/Shanghai");
|
|
|
+ LocalDate today = LocalDate.now(zone);
|
|
|
+ LocalDateTime dayStart = today.atStartOfDay();
|
|
|
+ LocalDateTime dayEnd = dayStart.plusDays(1);
|
|
|
+ LocalDateTime monthStart = today.with(TemporalAdjusters.firstDayOfMonth()).atStartOfDay();
|
|
|
+ LocalDateTime monthEnd = monthStart.plusMonths(1);
|
|
|
+
|
|
|
+ BigDecimal completionRate = TradeOrderDashboardUtils.completionRateOf(order);
|
|
|
+ Long tripCount = getDispatchedWaybillCount(tOrderId);
|
|
|
+
|
|
|
+ Integer chargeType = order.getChargeType();
|
|
|
+ BigDecimal todayVol = BigDecimal.ZERO;
|
|
|
+ BigDecimal monthVol = BigDecimal.ZERO;
|
|
|
+ if (Objects.equals(chargeType, ChargingTypeEnum.ON.getCode())
|
|
|
+ || Objects.equals(chargeType, ChargingTypeEnum.OFF.getCode())) {
|
|
|
+ todayVol = getCompletedWaybillVolume(tOrderId, chargeType, dayStart, dayEnd);
|
|
|
+ monthVol = getCompletedWaybillVolume(tOrderId, chargeType, monthStart, monthEnd);
|
|
|
+ }
|
|
|
+ todayVol = todayVol.setScale(2, RoundingMode.HALF_UP);
|
|
|
+ monthVol = monthVol.setScale(2, RoundingMode.HALF_UP);
|
|
|
+
|
|
|
+ return new TradeOrderDashboardVO()
|
|
|
+ .setCompletionRate(completionRate)
|
|
|
+ .setTodayTotalVolume(todayVol)
|
|
|
+ .setTripCount(tripCount)
|
|
|
+ .setMonthTotalVolume(monthVol);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取贸易订单已派车次。
|
|
|
+ *
|
|
|
+ * @param tOrderId 贸易订单ID
|
|
|
+ * @return 已派车次数
|
|
|
+ */
|
|
|
+ private Long getDispatchedWaybillCount(Long tOrderId) {
|
|
|
+ try {
|
|
|
+ return Optional.ofNullable(transportRemoteStatisticsService.countDispatchedWaybillsByTradeOrderId(tOrderId))
|
|
|
+ .orElse(0L);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询贸易订单已派车次失败,tOrderId={}", tOrderId, e);
|
|
|
+ throw new BusinessException("查询贸易订单已派车次失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 获取贸易订单指定时间范围内的运单完成量。
|
|
|
+ *
|
|
|
+ * @param tOrderId 贸易订单ID
|
|
|
+ * @param chargeType 计费方式
|
|
|
+ * @param startTime 开始时间
|
|
|
+ * @param endTime 结束时间
|
|
|
+ * @return 运单完成量
|
|
|
+ */
|
|
|
+ private BigDecimal getCompletedWaybillVolume(Long tOrderId, Integer chargeType,
|
|
|
+ LocalDateTime startTime, LocalDateTime endTime) {
|
|
|
+ try {
|
|
|
+ return Optional.ofNullable(transportRemoteStatisticsService.sumCompletedWaybillVolumeByTimeRange(
|
|
|
+ tOrderId, chargeType, startTime, endTime))
|
|
|
+ .orElse(BigDecimal.ZERO);
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("查询贸易订单运单完成量失败,tOrderId={}, chargeType={}, startTime={}, endTime={}",
|
|
|
+ tOrderId, chargeType, startTime, endTime, e);
|
|
|
+ throw new BusinessException("查询贸易订单运单完成量失败");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* @desc: 贸易订单列表导出
|
|
|
* @author: yzc
|