donglang 2 месяцев назад
Родитель
Сommit
206608047c

+ 6 - 4
sckw-common/sckw-common-core/src/main/java/com/sckw/core/utils/DateUtils.java

@@ -6,8 +6,9 @@ import com.sckw.core.exception.BusinessException;
 import com.sckw.core.exception.BusinessPlatfromException;
 import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
-import org.jetbrains.annotations.NotNull;
 
+import java.math.BigDecimal;
+import java.math.RoundingMode;
 import java.text.DateFormat;
 import java.text.ParseException;
 import java.text.SimpleDateFormat;
@@ -17,7 +18,6 @@ import java.util.Calendar;
 import java.util.Date;
 import java.util.List;
 import java.util.Objects;
-import java.util.concurrent.TimeUnit;
 import java.util.stream.Collectors;
 import java.util.stream.IntStream;
 
@@ -925,7 +925,7 @@ public class DateUtils extends DateUtil {
     }
 
     /**
-     * 计算两个时间之间的小时数(包含小数
+     * 计算两个时间之间的小时数((保留两位小数,四舍五入)
      * @param startTime 开始时间
      * @param endTime 结束时间
      * @return 小时数(例如:1.5 表示 1小时30分钟)
@@ -946,7 +946,9 @@ public class DateUtils extends DateUtil {
         // 毫秒转小时
         double hours = diffMs / (1000.0 * 3600.0);
 
-        return hours;
+        BigDecimal bigDecimal = new BigDecimal(hours);
+        return bigDecimal.setScale(2, RoundingMode.HALF_UP).doubleValue();
+
     }
 
 

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/handler/TakingOrderHandler.java

@@ -141,7 +141,7 @@ public class TakingOrderHandler extends AbstractWaybillOrderHandler<OrderCircula
         gatekeeper.setEntId(waybillOrder.getEntId());
         gatekeeper.setWOrderId(waybillOrder.getId());
         gatekeeper.setLOrderId(waybillOrder.getLOrderId());
-        gatekeeper.setGoodId(11111L);
+        gatekeeper.setGoodsId(11111L);
         gatekeeper.setGoodsName("测试");
         gatekeeper.setStatus(GatekeeperStatusEnum.PENDING_ENTRY.getCode());
         gatekeeper.setWaybillAcceptTime(waybillOrder.getCreateTime());

+ 10 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtForkliftWaybillOrder.java

@@ -45,6 +45,16 @@ public class KwtForkliftWaybillOrder implements Serializable {
      */
     private Long lOrderId;
 
+    /**
+     * 商品id
+     */
+    private Long goodsId;
+
+    /**
+     * 商品名称
+     */
+    private String goodsName;
+
     /**
      * 装载类型(0装载,1补货)
      */

+ 1 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtGatekeeperWaybillOrder.java

@@ -51,7 +51,7 @@ public class KwtGatekeeperWaybillOrder implements Serializable {
     /**
      * 商品id
      */
-    private Long goodId;
+    private Long goodsId;
 
     /**
      * 商品名称

+ 10 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/forklift/reponse/ForkliftOrderResp.java

@@ -1,5 +1,6 @@
 package com.sckw.transport.model.param.forklift.reponse;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -62,6 +63,12 @@ public class ForkliftOrderResp implements Serializable {
     @Schema(description = "状态(1-待接单,5-已接单、10-已装载)")
     private Integer status;
 
+    /**
+     * 状态描述
+     */
+    @Schema(description = "状态描述")
+    private String statusDesc;
+
     /**
      * 购买企业id
      */
@@ -162,18 +169,21 @@ public class ForkliftOrderResp implements Serializable {
      * 装载接单时间
      */
     @Schema(description = "装载接单时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date acceptOrderTime;
 
     /**
      * 装载完成时间
      */
     @Schema(description = "装载完成时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date finishTime;
 
     /**
      * 运单接单时间
      */
     @Schema(description = "运单接单时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date waybillAcceptTime;
 
 }

+ 12 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/forklift/reponse/GatekeeperOrderResp.java

@@ -1,5 +1,6 @@
 package com.sckw.transport.model.param.forklift.reponse;
 
+import com.fasterxml.jackson.annotation.JsonFormat;
 import io.swagger.v3.oas.annotations.media.Schema;
 import lombok.Data;
 
@@ -56,6 +57,12 @@ public class GatekeeperOrderResp implements Serializable {
     @Schema(description = "状态(1-待进场,5-已进场、10-待离场、15-空载待离场、20-已放行未离场、25-已离场、30-空载离场)")
     private Integer status;
 
+    /**
+     * 状态描述
+     */
+    @Schema(description = "状态描述")
+    private String statusDesc;
+
     /**
      * 购买企业id
      */
@@ -143,18 +150,21 @@ public class GatekeeperOrderResp implements Serializable {
     /**
      * 法定载重
      */
+    @Schema(description = "法定载重")
     private BigDecimal legalLoad;
 
     /**
      * 进场时间
      */
     @Schema(description = "进场时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date intoTime;
 
     /**
      * 出场时间
      */
     @Schema(description = "出场时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date leaveTime;
 
     /**
@@ -167,12 +177,14 @@ public class GatekeeperOrderResp implements Serializable {
      * 运单接单时间
      */
     @Schema(description = "运单接单时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date waybillAcceptTime;
 
     /**
      * 更新时间
      */
     @Schema(description = "更新时间")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private Date updateTime;
 
 }

+ 4 - 30
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/app/ForkliftOrderService.java

@@ -153,24 +153,6 @@ public class ForkliftOrderService {
         Map<Long, KwtLogisticsOrder> logisticsOrderMap = logisticsOrder.stream().collect(Collectors.toMap(KwtLogisticsOrder::getId, Function.identity(), (x, y) -> x));
         Set<Long> tOrderIds = logisticsOrder.stream().map(KwtLogisticsOrder::getTOrderId).collect(Collectors.toSet());
 
-        //查询物流商品
-        List<KwtLogisticsOrderGoods> logisticsOrderGoods = logisticsOrderGoodsRepository.queryByLogOrderIds((List<Long>) lOrderIds);
-        if (CollectionUtils.isEmpty(logisticsOrderGoods)) {
-            log.info("【铲车】无订单商品信息,物流订单id:{}", JSON.toJSONString(lOrderIds));
-            return Collections.emptyList();
-        }
-        Map<Long, KwtLogisticsOrderGoods> logisticsOrderGoodsMap = logisticsOrderGoods.stream().collect(Collectors.toMap(KwtLogisticsOrderGoods::getId, Function.identity(), (x, y) -> x));
-
-        //交易商品信息
-        List<Long> goodsIds = logisticsOrderGoods.stream().map(KwtLogisticsOrderGoods::getGoodsId).distinct().collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(goodsIds)) {
-            log.info("【铲车】无订单商品信息,商品id:{}", JSON.toJSONString(goodsIds));
-        }
-        Map<Long, KwpGoods> goodsIdAndGoodsMap = goodsInfoService.getGoodsByIds(goodsIds);
-
-        //查询字典
-        Map<String, Map<String, String>> dictValueAndDictResDtoMap = remoteSystemService.queryDictByType(Arrays.asList(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.GOODS_SPEC.getType()));
-
         //查询贸易订单企业信息
         List<OrderUnitInfoDetailVO> orderUnitInfoDetailVOS = tradeOrderInfoService.queryOrderUnitInfByTOrderId(tOrderIds);
         if (CollectionUtils.isEmpty(orderUnitInfoDetailVOS)) {
@@ -181,7 +163,7 @@ public class ForkliftOrderService {
 
         //组装铲车订单数据
         return records.stream()
-                .map(forkliftOrder -> buildForkliftOrderResp(forkliftOrder, waybillOrderMap, waybillOrderTicketMap, logisticsOrderMap, logisticsOrderGoodsMap, goodsIdAndGoodsMap, dictValueAndDictResDtoMap, tradeOrderAndUnit))
+                .map(forkliftOrder -> buildForkliftOrderResp(forkliftOrder, waybillOrderMap, waybillOrderTicketMap, logisticsOrderMap, tradeOrderAndUnit))
                 .collect(Collectors.toList());
     }
 
@@ -196,9 +178,6 @@ public class ForkliftOrderService {
                                                      Map<Long, KwtWaybillOrder> waybillOrderMap,
                                                      Map<String, KwtWaybillOrderTicket> waybillOrderTicketMap,
                                                      Map<Long, KwtLogisticsOrder> logisticsOrderMap,
-                                                     Map<Long, KwtLogisticsOrderGoods> logisticsOrderGoodsMap,
-                                                     Map<Long, KwpGoods> goodsIdAndGoodsMap,
-                                                     Map<String, Map<String, String>> dictValueAndDictResDtoMap,
                                                      Map<String, OrderUnitInfoDetailVO> tradeOrderAndUnit) {
         ForkliftOrderResp forklift = new ForkliftOrderResp();
         forklift.setId(forkliftOrder.getId());
@@ -208,6 +187,7 @@ public class ForkliftOrderService {
         forklift.setLogisticsOrderId(forkliftOrder.getLOrderId());
         forklift.setLoadingType(forkliftOrder.getLoadingType());
         forklift.setStatus(forkliftOrder.getStatus());
+        forklift.setStatusDesc(ForkliftStatusEnum.getDesc(forkliftOrder.getStatus()));
         forklift.setDriverId(forkliftOrder.getDriverId());
         forklift.setDriverName(forkliftOrder.getDriverName());
         forklift.setDriverPhone(forkliftOrder.getDriverPhone());
@@ -218,6 +198,8 @@ public class ForkliftOrderService {
         forklift.setCarAxisName(forkliftOrder.getCarAxis());
         forklift.setTruckType(forkliftOrder.getTruckType());
         forklift.setEntrustAmount(forkliftOrder.getEntrustAmount());
+        forklift.setGoodsId(forkliftOrder.getGoodsId());
+        forklift.setGoodsName(forkliftOrder.getGoodsName());
 
         //运单数据
         KwtWaybillOrder waybillOrder = waybillOrderMap.getOrDefault(forkliftOrder.getWOrderId(), new KwtWaybillOrder());
@@ -232,14 +214,6 @@ public class ForkliftOrderService {
         forklift.setPrEntId(orderUnit.getEntId());
         forklift.setPrEntName(orderUnit.getFirmName());
 
-        //商品信息
-        KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMap.getOrDefault(waybillOrder.getLOrderId(), new KwtLogisticsOrderGoods());
-        KwpGoods goods = goodsIdAndGoodsMap.getOrDefault(orderGoods.getGoodsId(), new KwpGoods());
-        Map<String, String> goodsTypeMap= dictValueAndDictResDtoMap.getOrDefault(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), new HashMap<>());
-        Map<String, String> goodsSpecMap= dictValueAndDictResDtoMap.getOrDefault(DictTypeEnum.GOODS_SPEC.getType(), new HashMap<>());
-        forklift.setGoodsName(goods.getName()+"/"+goodsTypeMap.getOrDefault(goods.getGoodsType(),"")+"/"+goodsSpecMap.getOrDefault(goods.getSpec(), ""));
-        forklift.setGoodsId(goods.getId());
-
         //装卸货信息
         KwtWaybillOrderTicket ticket = waybillOrderTicketMap.getOrDefault(forkliftOrder.getWOrderId() + "-" + 1, new KwtWaybillOrderTicket());
         forklift.setTareAmount(ticket.getTareAmount());

+ 18 - 41
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/app/GatekeeperOrderService.java

@@ -156,24 +156,6 @@ public class GatekeeperOrderService {
         Map<Long, KwtLogisticsOrder> logisticsOrderMap = logisticsOrder.stream().collect(Collectors.toMap(KwtLogisticsOrder::getId, Function.identity(), (x, y) -> x));
         Set<Long> tOrderIds = logisticsOrder.stream().map(KwtLogisticsOrder::getTOrderId).collect(Collectors.toSet());
 
-        //查询物流商品
-        List<KwtLogisticsOrderGoods> logisticsOrderGoods = logisticsOrderGoodsRepository.queryByLogOrderIds((List<Long>) lOrderIds);
-        if (CollectionUtils.isEmpty(logisticsOrderGoods)) {
-            log.info("【门卫】无订单商品信息,物流订单id:{}", JSON.toJSONString(lOrderIds));
-            return Collections.emptyList();
-        }
-        Map<Long, KwtLogisticsOrderGoods> logisticsOrderGoodsMap = logisticsOrderGoods.stream().collect(Collectors.toMap(KwtLogisticsOrderGoods::getId, Function.identity(), (x, y) -> x));
-
-        //交易商品信息
-        List<Long> goodsIds = logisticsOrderGoods.stream().map(KwtLogisticsOrderGoods::getGoodsId).distinct().collect(Collectors.toList());
-        if (CollectionUtils.isEmpty(goodsIds)) {
-            log.info("【门卫】无订单商品信息,商品id:{}", JSON.toJSONString(goodsIds));
-        }
-        Map<Long, KwpGoods> goodsIdAndGoodsMap = goodsInfoService.getGoodsByIds(goodsIds);
-
-        //查询字典
-        Map<String, Map<String, String>> dictValueAndDictResDtoMap = remoteSystemService.queryDictByType(Arrays.asList(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), DictTypeEnum.GOODS_SPEC.getType()));
-
         //查询贸易订单企业信息
         List<OrderUnitInfoDetailVO> orderUnitInfoDetailVOS = tradeOrderInfoService.queryOrderUnitInfByTOrderId(tOrderIds);
         if (CollectionUtils.isEmpty(orderUnitInfoDetailVOS)) {
@@ -184,7 +166,7 @@ public class GatekeeperOrderService {
 
         //组装铲车订单数据
         return records.stream()
-                .map(gatekeeperWaybillOrder -> buildGatekeeperOrderResp(gatekeeperWaybillOrder, waybillOrderMap, waybillOrderTicketMap, logisticsOrderMap, logisticsOrderGoodsMap, goodsIdAndGoodsMap, dictValueAndDictResDtoMap, tradeOrderAndUnit))
+                .map(gatekeeperWaybillOrder -> buildGatekeeperOrderResp(gatekeeperWaybillOrder, waybillOrderMap, waybillOrderTicketMap, logisticsOrderMap, tradeOrderAndUnit))
                 .collect(Collectors.toList());
     }
 
@@ -199,9 +181,6 @@ public class GatekeeperOrderService {
                                                      Map<Long, KwtWaybillOrder> waybillOrderMap,
                                                      Map<String, KwtWaybillOrderTicket> waybillOrderTicketMap,
                                                      Map<Long, KwtLogisticsOrder> logisticsOrderMap,
-                                                     Map<Long, KwtLogisticsOrderGoods> logisticsOrderGoodsMap,
-                                                     Map<Long, KwpGoods> goodsIdAndGoodsMap,
-                                                     Map<String, Map<String, String>> dictValueAndDictResDtoMap,
                                                      Map<String, OrderUnitInfoDetailVO> tradeOrderAndUnit) {
 
         GatekeeperOrderResp gatekeeper = new GatekeeperOrderResp();
@@ -211,13 +190,16 @@ public class GatekeeperOrderService {
         gatekeeper.setWaybillOrderId(gatekeeperWaybillOrder.getWOrderId());
         gatekeeper.setLogisticsOrderId(gatekeeperWaybillOrder.getLOrderId());
         gatekeeper.setStatus(gatekeeperWaybillOrder.getStatus());
+        gatekeeper.setStatusDesc(GatekeeperStatusEnum.getDesc(gatekeeperWaybillOrder.getStatus()));
         gatekeeper.setCarAxisName(gatekeeperWaybillOrder.getCarAxis());
-        gatekeeper.setLegalLoad(gatekeeper.getLegalLoad());
+        gatekeeper.setLegalLoad(gatekeeperWaybillOrder.getLegalLoad());
         gatekeeper.setTruckType(gatekeeperWaybillOrder.getTruckType());
         gatekeeper.setIntoTime(gatekeeperWaybillOrder.getIntoTime());
         gatekeeper.setLeaveTime(gatekeeperWaybillOrder.getLeaveTime());
         gatekeeper.setWaybillAcceptTime(gatekeeperWaybillOrder.getWaybillAcceptTime());
         gatekeeper.setEntrustAmount(gatekeeperWaybillOrder.getEntrustAmount());
+        gatekeeper.setGoodsId(gatekeeperWaybillOrder.getGoodsId());
+        gatekeeper.setGoodsName(gatekeeperWaybillOrder.getGoodsName());
 
         //运单数据
         KwtWaybillOrder waybillOrder = waybillOrderMap.getOrDefault(gatekeeperWaybillOrder.getWOrderId(), new KwtWaybillOrder());
@@ -233,13 +215,6 @@ public class GatekeeperOrderService {
         gatekeeper.setPrEntId(orderUnit.getEntId());
         gatekeeper.setPrEntName(orderUnit.getFirmName());
 
-        //商品信息
-        KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMap.getOrDefault(waybillOrder.getLOrderId(), new KwtLogisticsOrderGoods());
-        KwpGoods goods = goodsIdAndGoodsMap.getOrDefault(orderGoods.getGoodsId(), new KwpGoods());
-        Map<String, String> goodsTypeMap= dictValueAndDictResDtoMap.getOrDefault(DictTypeEnum.PRODUCT_NAME_TYPE.getType(), new HashMap<>());
-        Map<String, String> goodsSpecMap= dictValueAndDictResDtoMap.getOrDefault(DictTypeEnum.GOODS_SPEC.getType(), new HashMap<>());
-        gatekeeper.setGoodsName(goods.getName()+"/"+goodsTypeMap.getOrDefault(goods.getGoodsType(),"")+"/"+goodsSpecMap.getOrDefault(goods.getSpec(), ""));
-        gatekeeper.setGoodsId(goods.getId());
 
         //装卸货信息
         KwtWaybillOrderTicket ticket = waybillOrderTicketMap.getOrDefault(gatekeeperWaybillOrder.getWOrderId() + "-" + 1, new KwtWaybillOrderTicket());
@@ -372,12 +347,15 @@ public class GatekeeperOrderService {
      * @return
      */
     private static List<StatisticsWaybillResp.OrderBillStatusStatistics> calculateStatusStatistics(List<GatekeeperOrderResp> gatekeeperOrderList) {
+        //车辆停留超时配置
+        double configHours = 2000;
+
         // 定义状态码聚合规则
-        Map<List<String>, String[]> aggregateRules = Map.of(
-                Arrays.asList("1", "5", "10", "11", "15"), new String[]{"1", "待进场"},
-                Arrays.asList("10", "15", "20"), new String[]{"2", "待离场"},
-                Arrays.asList("5", "10", "15", "20"), new String[]{"3", "场内车辆"},
-                Arrays.asList("5", "10", "15", "20"), new String[]{"4", "异常车辆"}
+        Map<String[], List<String>> aggregateRules = Map.of(
+                new String[]{"1", "待进场"}, Arrays.asList("1"),
+                new String[]{"2", "待离场"}, Arrays.asList("10", "15", "20"),
+                new String[]{"3", "场内车辆"}, Arrays.asList("5", "10", "15", "20"),
+                new String[]{"4", "异常车辆"}, Arrays.asList("5", "10", "15", "20")
         );
 
         // 按原始状态统计数量
@@ -387,13 +365,12 @@ public class GatekeeperOrderService {
         // 进行状态聚合
         List<StatisticsWaybillResp.OrderBillStatusStatistics> aggregatedList = aggregateRules.entrySet().stream()
                 .map(rule -> {
-                    List<String> originalStatuses = rule.getKey();
-                    String[] aggregateInfo = rule.getValue();
+                    String[] aggregateInfo = rule.getKey();
+                    List<String> originalStatuses = rule.getValue();
                     long totalNum = 0;
 
                     // 处理状态为4的异常车辆
-                    if (Objects.equals(aggregateInfo[0],4)) {
-                        double configHours = 0;
+                    if (Objects.equals(aggregateInfo[0],"4")) {
                         totalNum = gatekeeperOrderList.stream().filter(order -> {
                             // 1. 必须包含在定义的异常状态源中 (5,10,15,20)
                             if (!originalStatuses.contains(String.valueOf(order.getStatus()))) {
@@ -439,8 +416,8 @@ public class GatekeeperOrderService {
         if (gatekeeperWaybillOrder == null) {
             throw new BusinessPlatfromException(ErrorCodeEnum.FORKLIFT_ORDER_NOT_FOUND, "当前车辆订单不存在!");
         }
-        if (GatekeeperStatusEnum.PENDING_EXIT.getCode().equals(gatekeeperWaybillOrder.getStatus())
-                || GatekeeperStatusEnum.EMPTY_PENDING_EXIT.getCode().equals(gatekeeperWaybillOrder.getStatus())) {
+        if (!(GatekeeperStatusEnum.PENDING_EXIT.getCode().equals(gatekeeperWaybillOrder.getStatus())
+                || GatekeeperStatusEnum.EMPTY_PENDING_EXIT.getCode().equals(gatekeeperWaybillOrder.getStatus()))) {
             throw new BusinessPlatfromException(ErrorCodeEnum.FORKLIFT_ORDER_STATUS_ERROR, "当前车辆订单状态异常,不能装载完成!");
         }
         //车辆放行后状态更改为:已放行未离场