Jelajahi Sumber

feature: 物流概况接口开发

xucaiqin 6 hari lalu
induk
melakukan
3f13f5fde0

+ 10 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/KwtLogisticsOrderController.java

@@ -219,6 +219,16 @@ public class KwtLogisticsOrderController {
         return HttpResult.ok(logisticsConsignmentService.queryList(tradeOrderPara));
     }
 
+    @GetMapping(value = "/base")
+    @Operation(summary = "分页查询物流订单概要信息", description = "分页查询物流订单概要信息")
+    public HttpResult base(@ParameterObject OrderPara orderPara) {
+        LogisticsOrderPara tradeOrderPara = new LogisticsOrderPara();
+        tradeOrderPara.setStartTime(LocalDateTimeUtil.parse(orderPara.getStartTime(), "yyyy-MM-dd HH:mm:ss"));
+        tradeOrderPara.setEndTime(LocalDateTimeUtil.parse(orderPara.getEndTime(), "yyyy-MM-dd HH:mm:ss"));
+        tradeOrderPara.setUserId(orderPara.getUserId());
+        return HttpResult.ok(logisticsConsignmentService.queryBaseList(tradeOrderPara));
+    }
+
 
     /**
      * 运单号下拉列表(支持输入匹配)

+ 1 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/dao/KwtLogisticsOrderMapper.java

@@ -479,4 +479,5 @@ public interface KwtLogisticsOrderMapper extends BaseMapper<KwtLogisticsOrder> {
 
     Long queryCount(@Param("ids") List<Long> ids);
 
+    List<LogisticsBaseOrderVo> selectBase(@Param("para")LogisticsOrderPara orderPara);
 }

+ 6 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/LogisticsOrderPara.java

@@ -1,5 +1,6 @@
 package com.sckw.transport.model;
 
+import io.swagger.v3.oas.annotations.media.Schema;
 import jakarta.validation.constraints.NotNull;
 import lombok.Getter;
 import lombok.Setter;
@@ -28,4 +29,9 @@ public class LogisticsOrderPara implements Serializable {
      * 类型(1供应商,2采购商,3物流属性)
      */
     private Integer type;
+
+    @Schema(description = "物流订单编号")
+    private String logisticsOrderNo;
+    @Schema(description = "贸易订单编号")
+    private String orderNo;
 }

+ 4 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/OrderPara.java

@@ -18,4 +18,8 @@ public class OrderPara {
     private String endTime;
     @Schema(description = "用户id")
     private Long userId;
+    @Schema(description = "物流订单编号")
+    private String logisticsOrderNo;
+    @Schema(description = "贸易订单编号")
+    private String orderNo;
 }

+ 24 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LogisticsBaseOrderVo.java

@@ -0,0 +1,24 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+
+@Data
+public class LogisticsBaseOrderVo implements Serializable {
+    @Serial
+    private static final long serialVersionUID = 4964311980474791569L;
+    private String tyFirmName;
+    private String cyFirmName;
+
+    private Integer count;
+    private BigDecimal amount;
+    private BigDecimal money;//预计运费
+    private BigDecimal pay;//实际运费
+    private BigDecimal loadAmount;//累计装货量
+    private BigDecimal unloadAmount;//累计卸货量
+
+}

+ 15 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LogisticsOrderVo.java

@@ -30,6 +30,20 @@ public class LogisticsOrderVo implements Serializable {
     private String statusLabel;
     private String tyFirmName;
     private String cyFirmName;
-    @JsonFormat(pattern="yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
     private LocalDateTime createTime;
+
+    private String goodsName;
+    private Long goodsId;
+    private BigDecimal price;//运输单价
+    private String billingMode;//计费方式
+    private BigDecimal money;//预计运费
+    private BigDecimal pay;//实际运费
+    private BigDecimal loadAmount;//累计装货量
+    private BigDecimal unloadAmount;//累计卸货量
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime startTime;
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
+    private LocalDateTime endTime;
+
 }

+ 32 - 16
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsConsignmentService.java

@@ -39,6 +39,7 @@ import com.sckw.order.api.dubbo.RemoteTradeOrderAmountService;
 import com.sckw.order.api.dubbo.TradeOrderInfoService;
 import com.sckw.order.api.model.*;
 import com.sckw.product.api.dubbo.GoodsInfoService;
+import com.sckw.product.api.model.GoodsDetails;
 import com.sckw.product.api.model.KwpGoods;
 import com.sckw.redis.config.RedisLockUtil;
 import com.sckw.redis.constant.RedisConstant;
@@ -82,7 +83,6 @@ import java.util.concurrent.Executors;
 import java.util.concurrent.atomic.AtomicInteger;
 import java.util.function.Function;
 import java.util.stream.Collectors;
-import java.util.stream.Stream;
 
 /**
  * @author lfdc
@@ -2240,7 +2240,6 @@ public class KwtLogisticsConsignmentService {
     private static final ExecutorService QUERY_EXECUTOR = Executors.newFixedThreadPool(10);
 
 
-
     public PageDataResult<LogisticsOrderResp> queryLogisticsOrderByPage(QueryLogisticsOrderReq req) {
         log.info("分页查询物流订单传递参数信息:{}", JSONObject.toJSONString(req));
 
@@ -2323,7 +2322,7 @@ public class KwtLogisticsConsignmentService {
      */
     private boolean shouldReturnEmptyResult(Set<Long> logOrderIds, Set<Long> entList, QueryLogisticsOrderReq req) {
         return CollectionUtils.isEmpty(logOrderIds) &&
-                (!org.apache.commons.lang3.StringUtils.isAllBlank(req.getContractId(), req.getGoodsName(),req.getConsignCompanyId(),req.getCarriageCompanyId()));
+                (!org.apache.commons.lang3.StringUtils.isAllBlank(req.getContractId(), req.getGoodsName(), req.getConsignCompanyId(), req.getCarriageCompanyId()));
     }
 
     /**
@@ -2568,6 +2567,19 @@ public class KwtLogisticsConsignmentService {
                 .collect(Collectors.toList());
     }
 
+    public List<LogisticsBaseOrderVo> queryBaseList(LogisticsOrderPara orderPara) {
+        UserResDto userResDto = remoteSystemService.queryUserById(orderPara.getUserId());
+        if (Objects.nonNull(userResDto)) {
+            orderPara.setType(userResDto.getType());
+            Integer systemType = userResDto.getSystemType();
+            if (!Objects.equals(systemType, SystemTypeEnum.MANAGE.getCode())) {
+                orderPara.setEntId(remoteUserService.findChildEntList(userResDto.getEntId()));
+            }
+        }
+
+        return kwtLogisticsOrderMapper.selectBase(orderPara);
+    }
+
     /**
      * 基础查询数据
      */
@@ -2591,7 +2603,6 @@ public class KwtLogisticsConsignmentService {
         }
 
 
-
         public Set<Long> getEntList() {
             return entListFuture.join();
         }
@@ -2724,7 +2735,7 @@ public class KwtLogisticsConsignmentService {
     @NotNull
     private Set<Long> getLogOrderIds(QueryLogisticsOrderReq req, Set<Long> entList, Long allEnt) {
         Set<Long> logOrderIds = Sets.newHashSet();
-        if (Objects.nonNull(allEnt)){
+        if (Objects.nonNull(allEnt)) {
             entList.add(allEnt);
         }
         List<KwtLogisticsOrderUnit> logOrderUnits = logisticsOrderUnitRepository.queryByEntIds(entList);
@@ -2732,7 +2743,7 @@ public class KwtLogisticsConsignmentService {
             Long entId = LoginUserHolder.getEntId();
             // 获取物流订单ID集合
             Set<Long> logOrderIdList = logOrderUnits.stream()
-                    .filter(x->Objects.equals(x.getEntId(),entId))
+                    .filter(x -> Objects.equals(x.getEntId(), entId))
                     .map(KwtLogisticsOrderUnit::getLOrderId)
                     .collect(Collectors.toSet());
 
@@ -2764,10 +2775,10 @@ public class KwtLogisticsConsignmentService {
                         .map(KwtLogisticsOrderContract::getLOrderId)
                         .collect(Collectors.toSet());
                 logOrderIds.addAll(logOrderIdList);
-                logOrderIds  = logOrderIds.stream()
-                        .filter(x->logOrderIdList.contains(x))
+                logOrderIds = logOrderIds.stream()
+                        .filter(x -> logOrderIdList.contains(x))
                         .collect(Collectors.toSet());
-            }else {
+            } else {
                 logOrderIds = Sets.newHashSet();
             }
         }
@@ -2783,7 +2794,7 @@ public class KwtLogisticsConsignmentService {
 //                logOrderIds  = logOrderIds.stream()
 //                        .filter(x->logOrderFormGoodsIds.contains(x))
 //                        .collect(Collectors.toSet());
-            }else {
+            } else {
                 logOrderIds = Sets.newHashSet();
             }
         }
@@ -2884,9 +2895,9 @@ public class KwtLogisticsConsignmentService {
     }
 
     private static BigDecimal getSupAmount(Long tradeOrderId,
-                                       Map<Long, OrderDetailVo> tradeIdAndOrderDetailVoMap,
-                                       Map<Long, List<KwtLogisticsOrder>> tradeIdAndLogOrderList,
-                                       Map<Long, List<KwtWaybillOrderSubtask>> logisticsOrderIdAndSubtaskList) {
+                                           Map<Long, OrderDetailVo> tradeIdAndOrderDetailVoMap,
+                                           Map<Long, List<KwtLogisticsOrder>> tradeIdAndLogOrderList,
+                                           Map<Long, List<KwtWaybillOrderSubtask>> logisticsOrderIdAndSubtaskList) {
         // KwtLogisticsOrder order = logOrderMap.getOrDefault(wbOrder.getLOrderId(), new KwtLogisticsOrder());
         OrderDetailVo detailVo = tradeIdAndOrderDetailVoMap.getOrDefault(tradeOrderId, new OrderDetailVo());
         BigDecimal tradeAmount = Optional.ofNullable(detailVo).map(OrderDetailVo::getAmount).orElse(BigDecimal.ZERO);
@@ -2903,14 +2914,14 @@ public class KwtLogisticsConsignmentService {
                         .filter(Objects::nonNull)
                         .reduce(BigDecimal.ZERO, BigDecimal::add);
                 //logTotatalAmount = logTotatalAmount.add(loadAmountSum);
-                if (org.apache.commons.lang3.StringUtils.equals(billingMode, DictEnum.CHARGING_TYPE_1.getValue())){
+                if (org.apache.commons.lang3.StringUtils.equals(billingMode, DictEnum.CHARGING_TYPE_1.getValue())) {
                     BigDecimal unloadAmountSum = waybillOrderSubtasks.stream()
                             .filter(x -> !Objects.equals(x.getStatus(), CarWaybillV1Enum.CANCELLED.getCode()))
                             .map(KwtWaybillOrderSubtask::getLoadAmount)
                             .filter(Objects::nonNull)
                             .reduce(BigDecimal.ZERO, BigDecimal::add);
                     logTotatalAmount = logTotatalAmount.add(loadAmountSum).add(unloadAmountSum);
-                }else if (org.apache.commons.lang3.StringUtils.equals(billingMode, DictEnum.CHARGING_TYPE_2.getValue())){
+                } else if (org.apache.commons.lang3.StringUtils.equals(billingMode, DictEnum.CHARGING_TYPE_2.getValue())) {
                     BigDecimal unloadAmountSum = waybillOrderSubtasks.stream()
                             .filter(x -> !Objects.equals(x.getStatus(), CarWaybillV1Enum.CANCELLED.getCode()))
                             .map(KwtWaybillOrderSubtask::getUnloadAmount)
@@ -3544,7 +3555,7 @@ public class KwtLogisticsConsignmentService {
         logisticsOrderRepository.updateBatchById(logisticsOrders);
 
         //更新贸易订单数据
-       // updateTradeOrder(tradeIds);
+        // updateTradeOrder(tradeIds);
         return Boolean.TRUE;
     }
 
@@ -3664,9 +3675,14 @@ public class KwtLogisticsConsignmentService {
                 orderPara.setEntId(remoteUserService.findChildEntList(userResDto.getEntId()));
             }
         }
+
         List<LogisticsOrderVo> list = kwtLogisticsOrderMapper.selectData(orderPara);
         if (CollUtil.isNotEmpty(list)) {
             list.forEach(d -> {
+                GoodsDetails detailById = goodsInfoService.getDetail(d.getGoodsId());
+                if (Objects.nonNull(detailById)) {
+                    d.setGoodsName(d.getGoodsName() + detailById.getSpecLabel());
+                }
                 d.setStatusLabel(LogisticsOrderV1Enum.getDesc(d.getStatus()));
             });
             return list;

+ 61 - 6
sckw-modules/sckw-transport/src/main/resources/mapper/KwtLogisticsOrderMapper.xml

@@ -2953,23 +2953,41 @@
 
     <select id="selectData" resultType="com.sckw.transport.model.vo.LogisticsOrderVo">
         select a.id,
-               a.l_order_no AS lOrderNo,
-               a.t_order_no AS tOrderNo,
+               a.l_order_no                          AS lOrderNo,
+               a.t_order_no                          AS tOrderNo,
                a.amount,
-               a.`status`   AS status,
-               d.firm_name  as tyFirmName,
-               e.firm_name  as cyFirmName,
-               e.create_time
+               a.`status`                            AS status,
+               d.firm_name                           as tyFirmName,
+               e.firm_name                           as cyFirmName,
+               a.start_time,
+               a.end_time,
+               g.goods_name,
+               g.goods_id,
+               ifnull(a.amount * a.price, 0)         as money,
+               ifnull(a.amount * a.unload_amount, 0) as pay,
+               a.load_amount,
+               a.unload_amount,
+               a.price,
+               a.billing_mode,
+               a.create_time
         FROM kwt_logistics_order a
                  LEFT JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
             AND d.unit_type = 1 AND d.del_flag = 0
                  LEFT JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
             AND e.unit_type = 2
+                 LEFT JOIN kwt_logistics_order_goods g ON a.id = g.l_order_id AND g.del_flag = 0
+
         <where>
             a.del_flag = 0
             <if test="para.startTime != null and para.endTime != null">
                 and a.create_time between #{para.startTime,jdbcType=TIMESTAMP} and #{para.endTime,jdbcType=TIMESTAMP}
             </if>
+            <if test="para.orderNo != null and para.orderNo != ''">
+                and a.t_order_no = #{para.orderNo}
+            </if>
+            <if test="para.logisticsOrderNo != null and para.logisticsOrderNo != ''">
+                and a.l_order_no = #{para.logisticsOrderNo}
+            </if>
             <if test="para.entId != null and para.entId.size() > 0">
                 <if test="para.type != null and para.type == 3">
                     and
@@ -2990,6 +3008,43 @@
             limit 10
         </where>
     </select>
+    <select id="selectBase" resultType="com.sckw.transport.model.vo.LogisticsBaseOrderVo">
+        select count(1)                                   as count,
+               d.firm_name                                as tyFirmName,
+               e.firm_name                                as cyFirmName,
+               sum(ifnull(a.amount * a.price, 0))         as money,
+               sum(ifnull(a.amount * a.unload_amount, 0)) as pay,
+               sum(a.amount),
+               sum(a.load_amount),
+               sum(a.unload_amount)
+        FROM kwt_logistics_order a
+                 inner JOIN kwt_logistics_order_unit d ON a.id = d.l_order_id
+            AND d.unit_type = 1 AND d.del_flag = 0
+                 inner JOIN kwt_logistics_order_unit e ON a.id = e.l_order_id
+            AND e.unit_type = 2
+
+        <where>
+            a.del_flag = 0
+            <if test="para.entId != null and para.entId.size() > 0">
+                <if test="para.type != null and para.type == 3">
+                    and
+                        e.ent_id in
+                    <foreach collection="para.entId" item="item" open="(" close=")" separator=",">
+                        #{item}
+                    </foreach>
+                </if>
+                <if test="para.type != null">
+                    <if test="para.type == 1 or para.type == 2">
+                        and d.ent_id in
+                        <foreach collection="para.entId" item="item" open="(" close=")" separator=",">
+                            #{item}
+                        </foreach>
+                    </if>
+                </if>
+            </if>
+            group by d.ent_id, e.ent_id
+        </where>
+    </select>
 
     <select id="queryCount" resultType="java.lang.Long">
         select count(1)