Эх сурвалжийг харах

1.新增v4.2版本分包托运接口
2.修改v4.2版本订单详情接口
3.修改v4.3版本分包订单详情接口

lengfaqiang 1 жил өмнө
parent
commit
6fbde7f39d
13 өөрчлөгдсөн 1474 нэмэгдсэн , 123 устгасан
  1. 22 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/KwtLogisticsConsignmentController.java
  2. 10 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/KwtLogisticsOrderAddress.java
  3. 232 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/LogisticOrderSubcontractDto.java
  4. 258 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/LogisticsOrderSubcontractDto.java
  5. 1 1
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/param/AddLogisticsOrderParam.java
  6. 43 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LoadAddressVo.java
  7. 45 40
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/OrderDetailVO.java
  8. 42 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/UnLoadAddressVo.java
  9. 77 35
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtAcceptCarriageOrderService.java
  10. 8 0
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsConsignmentService.java
  11. 612 7
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsOrderConsignmentService.java
  12. 69 27
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtTransportCommonService.java
  13. 55 12
      sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/operateService/KwtManagementLogisticsOrderService.java

+ 22 - 1
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/controller/KwtLogisticsConsignmentController.java

@@ -14,6 +14,7 @@ import com.sckw.core.web.constant.HttpStatus;
 import com.sckw.core.web.response.HttpResult;
 import com.sckw.excel.utils.ExcelUtil;
 import com.sckw.transport.model.dto.LogisticsConsignmentDto;
+import com.sckw.transport.model.dto.LogisticsOrderSubcontractDto;
 import com.sckw.transport.model.dto.OrderManualCompletionDto;
 import com.sckw.transport.model.param.AddLogisticsOrderParam;
 import com.sckw.transport.model.param.LogisticsConsignmentParam;
@@ -367,7 +368,7 @@ public class KwtLogisticsConsignmentController {
 
 
     /**
-     * 采购订单/销售订单-物流托运 V4.2
+     * 采购订单/销售订单-物流托运-V4.2
      *
      * @param logisticsConsignmentDto 页面请求参数
      * @return  响应结果
@@ -406,4 +407,24 @@ public class KwtLogisticsConsignmentController {
     }
 
 
+    /**
+     * 物流订单-分包托运-V4.2
+     *
+     * @param logisticsOrderSubcontractDto 页面请求参数
+     * @return  响应结果
+     */
+    @Validated
+    @RepeatSubmit(interval = 1000,message ="前方拥堵,请稍后尝试")
+    @RequestMapping(value = "/logisticsOrderSubcontract", method = RequestMethod.POST)
+    public HttpResult logisticsOrderSubcontract(@Valid @RequestBody LogisticsOrderSubcontractDto logisticsOrderSubcontractDto) {
+        log.info("物流订单-分包托运传递参数信息:{}", JSONObject.toJSONString(logisticsOrderSubcontractDto));
+        try {
+            return logisticsConsignmentService.logisticsOrderSubcontract(logisticsOrderSubcontractDto);
+        } catch (Exception e) {
+            log.error("物流订单-分包托运 error :{}", e.getMessage(), e);
+            return HttpResult.error(HttpStatus.GLOBAL_EXCEPTION_CODE, e.getMessage());
+        }
+    }
+
+
 }

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

@@ -25,6 +25,16 @@ public class KwtLogisticsOrderAddress implements Serializable {
      */
     private Long lOrderId;
 
+    /**
+     * 贸易订单地址id
+     */
+    private Long tAddressId;
+
+    /**
+     * 上级物流订单地址id
+     */
+    private Long pAddressId;
+
     /**
      * 地址类型(1装货地址、2卸货地址)
      */

+ 232 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/LogisticOrderSubcontractDto.java

@@ -0,0 +1,232 @@
+package com.sckw.transport.model;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.constraints.DecimalMin;
+import jakarta.validation.constraints.Digits;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.Data;
+import org.hibernate.validator.constraints.Length;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+
+
+/**
+ * @author lfdc
+ * @description 承运订单-分包托运DTO
+ * @date 2023-06-26 17:06:52
+ */
+@Data
+public class LogisticOrderSubcontractDto implements Serializable {
+
+    /**
+     *总量
+     */
+    private BigDecimal amount;
+    /**
+     * 分配承运量
+     */
+    @Digits(integer = 10,fraction = 2,message = "分配承运量填写错误")
+    @DecimalMin(value = "0.00",message = "委托量不能小于{value}")
+    private BigDecimal carryingCapacity;
+    /**
+     * 分配承运量使用的单位
+     */
+    private String carryingCapacityUnit;
+
+    /**
+     * 托运单位
+     */
+    @NotNull(message = "托运单位名称不能为空")
+    private String checkCompany;
+    /**
+     * 托运单位id
+     */
+    @NotNull(message = "托运单位id不能为空")
+    private String checkCompanyId;
+
+    /**
+     * 托运联系电话
+     */
+    @NotNull(message = "托运联系电话不能为空")
+    private String checkContactPhone;
+    /**
+     * 托运联系人
+     */
+    @NotNull(message = "托运联系人不能为空")
+    private String checkContacts;
+
+    /**
+     * 托运联系人id
+     */
+    @NotNull(message = "托运联系人id不能为空")
+    private String checkContactsId;
+    /**
+     * 承运联系人id
+     */
+    @NotNull(message = "承运联系人id不能为空")
+    private String consignContactsId;
+
+    /**
+     * 合理损耗
+     */
+//    @NotNull(message = "合理损耗不能为空")
+    @Digits(integer = 5, fraction = 2,message = "合理损耗格式填写错误")
+    private BigDecimal loss;
+    /**
+     * 合理损耗单位
+     */
+    private String lossUnit;
+
+    /**
+     * 商品价值(扣亏货值)
+     */
+//    @NotNull(message = "扣亏货值不能为空")
+    @Digits(integer = 5, fraction = 2,message = "商品价值(扣亏货值)格式填写错误")
+    private BigDecimal goodsPrice;
+    /**
+     * 商品价值(扣亏货值)单位
+     */
+    private String goodsPriceUnit;
+    /**
+     * 承运单位
+     */
+    @NotBlank(message = "承运单位不能为空")
+    private String consignCompany;
+
+    /**
+     * 承运单位ID
+     */
+    @NotBlank(message = "承运单位ID不能为空")
+    private String consignCompanyId;
+
+    /**
+     * 承运联系电话
+     */
+    @NotNull(message = "承运联系电话不能为空")
+    private String consignContactPhone;
+    /**
+     * 承运联系人
+     */
+    @NotNull(message = "承运联系人不能为空")
+    private String consignContacts;
+
+    /**
+     * 结算周期(周结、月结、季结)
+     */
+//    @NotNull(message = "结算周期不能为空")
+    private Long settlementCycle;
+
+    /**
+     * 合同id
+     */
+    @NotNull(message = "合同id不能为空")
+    private String contractId;
+    /**
+     * 合同编号
+     */
+    @NotNull(message = "合同编号不能为空")
+    private String contractNo;
+
+    /**
+     * 合同名称
+     */
+    @NotNull(message = "合同名称不能为空")
+    private String contractName;
+
+    /**
+     * 合同签约方式
+     */
+    @NotNull(message = "合同签约方式不能为空")
+    private String payment;
+    /**
+     * 货物名称
+     */
+    @NotNull(message = "货物名称不能为空")
+    private String goodsName;
+
+    /**
+     * 货物id
+     */
+//    @NotNull(message = "货物id不能为空")
+    private String goodsId;
+
+    /**
+     * skuId
+     */
+    private String skuId;
+
+    /**
+     * 是否全量
+     */
+    @NotNull(message = "是否全量不能为空")
+    private Boolean isFullDose;
+
+    /**
+     * 订单id-分包时要使用
+     */
+    @JsonProperty("lOrderId")
+    private String lOrderId;
+
+    /**
+     * 订单编号-分包时要使用
+     */
+    @JsonProperty("lOrderNo")
+    private String lOrderNo;
+
+    /**
+     * 运价
+     */
+    @NotNull(message = "运价不能为空")
+    @Digits(integer = 5,fraction = 2,message = "运价格式填写错误!")
+    private BigDecimal price;
+
+    /**
+     * 运价方式
+     */
+    @NotNull(message = "运价方式不能为空")
+    private String priceType;
+
+    /**
+     * 计划卸货日期
+     */
+    @NotNull(message = "计划卸货日期不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate receiveGoodsDateTime;
+
+    /**
+     * 计划发货日期
+     */
+    @NotNull(message = "计划发货日期不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate shipmentsDateTime;
+
+    /**
+     * 税率
+     */
+    @NotNull(message = "税率不能为空")
+    private Long taxRate;
+    /**
+     * 备注
+     */
+    @Length(max = 200, message = "单据编号长度错误最大长度:{max}")
+    private String remark;
+    /**
+     * 计费方式
+     */
+    @NotNull(message = "计费方式不能为空")
+    private String billingMode;
+
+    /**
+     * 扣亏货值
+     */
+    @Digits(integer = 5,fraction = 2,message = "扣亏货值格式填写错误")
+    private BigDecimal defectiveValue;
+
+}

+ 258 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/dto/LogisticsOrderSubcontractDto.java

@@ -0,0 +1,258 @@
+package com.sckw.transport.model.dto;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import jakarta.validation.constraints.DecimalMin;
+import jakarta.validation.constraints.Digits;
+import jakarta.validation.constraints.NotBlank;
+import jakarta.validation.constraints.NotNull;
+import lombok.AllArgsConstructor;
+import lombok.Data;
+import lombok.NoArgsConstructor;
+import org.hibernate.validator.constraints.Length;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+import java.time.LocalDate;
+import java.util.List;
+
+/**
+ * @author lfdc
+ * @description 物流订单-分包托运-v4.2
+ * @date 2024-03-05 14:03:45
+ */
+@Data
+@AllArgsConstructor
+@NoArgsConstructor
+public class LogisticsOrderSubcontractDto implements Serializable {
+
+    /**
+     * 订单类型-托运订单1-承运订单2
+     */
+    private String type;
+    /**
+     *总量
+     */
+    private BigDecimal amount;
+    /**
+     * 分配承运量
+     */
+    @Digits(integer = 10,fraction = 2,message = "分配承运量填写错误")
+    @DecimalMin(value = "0.00",message = "委托量不能小于{value}")
+    private BigDecimal carryingCapacity;
+    /**
+     * 分配承运量使用的单位
+     */
+    private String carryingCapacityUnit;
+
+    /**
+     * 托运单位
+     */
+    @NotNull(message = "托运单位名称不能为空")
+    private String consignCompany;
+    /**
+     * 托运单位id
+     */
+    @NotNull(message = "托运单位id不能为空")
+    private String consignCompanyId;
+
+    /**
+     * 托运联系电话
+     */
+    @NotNull(message = "托运联系电话不能为空")
+    private String consignContactPhone;
+    /**
+     * 托运联系人
+     */
+    @NotNull(message = "托运联系人不能为空")
+    private String consignContacts;
+
+    /**
+     * 托运联系人id
+     */
+    @NotNull(message = "托运联系人id不能为空")
+    private String consignContactsId;
+    /**
+     * 承运联系人id
+     */
+    @NotNull(message = "承运联系人id不能为空")
+    private String acceptContactsId;
+
+    /**
+     * 合理损耗
+     */
+//    @NotNull(message = "合理损耗不能为空")
+    @Digits(integer = 5, fraction = 2,message = "合理损耗格式填写错误")
+    private BigDecimal loss;
+    /**
+     * 合理损耗单位
+     */
+    private String lossUnit;
+
+    /**
+     * 商品价值(扣亏货值)
+     */
+//    @NotNull(message = "扣亏货值不能为空")
+    @Digits(integer = 5, fraction = 2,message = "商品价值(扣亏货值)格式填写错误")
+    private BigDecimal goodsPrice;
+    /**
+     * 商品价值(扣亏货值)单位
+     */
+    private String goodsPriceUnit;
+    /**
+     * 承运单位
+     */
+    @NotBlank(message = "承运单位不能为空")
+    private String acceptCompany;
+
+    /**
+     * 承运单位ID
+     */
+    @NotBlank(message = "承运单位ID不能为空")
+    private String acceptCompanyId;
+
+    /**
+     * 承运联系电话
+     */
+    @NotNull(message = "承运联系电话不能为空")
+    private String acceptContactPhone;
+    /**
+     * 承运联系人
+     */
+    @NotNull(message = "承运联系人不能为空")
+    private String acceptContacts;
+
+    /**
+     * 结算周期(周结、月结、季结)
+     */
+//    @NotNull(message = "结算周期不能为空")
+    private Long settlementCycle;
+
+    /**
+     * 合同id
+     */
+    @NotNull(message = "合同id不能为空")
+    private String contractId;
+    /**
+     * 合同编号
+     */
+    @NotNull(message = "合同编号不能为空")
+    private String contractNo;
+
+    /**
+     * 合同名称
+     */
+    @NotNull(message = "合同名称不能为空")
+    private String contractName;
+
+    /**
+     * 合同签约方式
+     */
+    @NotNull(message = "合同签约方式不能为空")
+    private String payment;
+    /**
+     * 货物名称
+     */
+    @NotNull(message = "货物名称不能为空")
+    private String goodsName;
+
+    /**
+     * 货物id
+     */
+//    @NotNull(message = "货物id不能为空")
+    private String goodsId;
+
+    /**
+     * skuId
+     */
+    private String skuId;
+
+    /**
+     * 是否全量
+     */
+    @NotNull(message = "是否全量不能为空")
+    private Boolean isFullDose;
+
+    /**
+     * 订单id-分包时要使用
+     */
+    @JsonProperty("lOrderId")
+    private String lOrderId;
+
+    /**
+     * 订单编号-分包时要使用
+     */
+    @JsonProperty("lOrderNo")
+    private String lOrderNo;
+
+    /**
+     * 运价
+     */
+    @NotNull(message = "运价不能为空")
+    @Digits(integer = 5,fraction = 2,message = "运价格式填写错误!")
+    private BigDecimal price;
+
+    /**
+     * 运价方式
+     */
+    @NotNull(message = "运价方式不能为空")
+    private String priceType;
+
+    /**
+     * 计划卸货日期
+     */
+    @NotNull(message = "计划卸货日期不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate startTime;
+
+    /**
+     * 计划发货日期
+     */
+    @NotNull(message = "计划发货日期不能为空")
+    @JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
+    @DateTimeFormat(pattern = "yyyy-MM-dd")
+    private LocalDate endTime;
+
+    /**
+     * 税率
+     */
+    @NotNull(message = "税率不能为空")
+    private Long taxRate;
+    /**
+     * 备注
+     */
+    @Length(max = 200, message = "单据编号长度错误最大长度:{max}")
+    private String remark;
+    /**
+     * 计费方式
+     */
+    @NotNull(message = "计费方式不能为空")
+    private String billingMode;
+
+    /**
+     * 扣亏货值
+     */
+    @Digits(integer = 5,fraction = 2,message = "扣亏货值格式填写错误")
+    private BigDecimal defectiveValue;
+
+    /**
+     * 地址信息
+     */
+    @NotNull(message = "地址信息不能为空")
+    @JsonProperty("addressInfo")
+    private List<AddressInfoDto> addressInfo;
+
+//    /**
+//     * 辅助单位
+//     */
+//    @JsonProperty("assistUnit")
+//    private List<GoodsUnitParam> assistUnit;
+
+    /**
+     * 线路分配
+     */
+    @JsonProperty("lineFreightList")
+    private List<LineFreightDto> lineFreightList;
+}

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

@@ -153,7 +153,7 @@ public class AddLogisticsOrderParam implements Serializable {
     /**
      * 税率单位
      */
-    @NotNull(message = "税率单位不能为空")
+    @NotBlank(message = "税率单位不能为空")
     private String taxRateUnit;
 
     /**

+ 43 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/LoadAddressVo.java

@@ -0,0 +1,43 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2024-03-06 15:03:37
+ */
+@Data
+public class LoadAddressVo implements Serializable {
+
+    /**
+     * 装货地址
+     */
+    private String loadName;
+
+    /**
+     * 装货地址
+     */
+    private String loadAddress;
+    /**
+     * 装货联系人
+     */
+    private String loadContacts;
+    /**
+     * 装货联系电话
+     */
+    private String loadPhone;
+    /**
+     * 装货详细地址
+     */
+    private String loadAddressDetail;
+
+    /**
+     * 装货量
+     */
+    private BigDecimal loadAmount;
+
+}

+ 45 - 40
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/OrderDetailVO.java

@@ -6,6 +6,7 @@ import lombok.Data;
 import java.math.BigDecimal;
 import java.time.LocalDateTime;
 import java.util.Date;
+import java.util.List;
 
 /**
  * @author lfdc
@@ -162,47 +163,51 @@ public class OrderDetailVO {
      */
     private String contractNo;
 
-    /**
-     * 装货地址
-     */
-    private String loadName;
+//    /**
+//     * 装货地址
+//     */
+//    private String loadName;
+//
+//    /**
+//     * 装货地址
+//     */
+//    private String loadAddress;
+//    /**
+//     * 装货联系人
+//     */
+//    private String loadContacts;
+//    /**
+//     * 装货联系电话
+//     */
+//    private String loadPhone;
+//    /**
+//     * 装货详细地址
+//     */
+//    private String loadAddressDetail;
 
-    /**
-     * 装货地址
-     */
-    private String loadAddress;
-    /**
-     * 装货联系人
-     */
-    private String loadContacts;
-    /**
-     * 装货联系电话
-     */
-    private String loadPhone;
-    /**
-     * 装货详细地址
-     */
-    private String loadAddressDetail;
-    /**
-     * 装货地名
-     */
-    private String unloadName;
-    /**
-     * 装货详细地址
-     */
-    private String unloadAddress;
-    /**
-     * 卸货联系人
-     */
-    private String unloadContacts;
-    /**
-     * 卸货联系电话
-     */
-    private String unloadPhone;
-    /**
-     * 卸货详细地址
-     */
-    private String unloadAddressDetail;
+    private List<LoadAddressVo> loadAddressList;
+
+    private List<UnLoadAddressVo> unloadAddressList;
+//    /**
+//     * 卸货地名
+//     */
+//    private String unloadName;
+//    /**
+//     * 卸货详细地址
+//     */
+//    private String unloadAddress;
+//    /**
+//     * 卸货联系人
+//     */
+//    private String unloadContacts;
+//    /**
+//     * 卸货联系电话
+//     */
+//    private String unloadPhone;
+//    /**
+//     * 卸货详细地址
+//     */
+//    private String unloadAddressDetail;
 
     /**
      * 卸货-履约量(自己+下游承运总卸货量)

+ 42 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/model/vo/UnLoadAddressVo.java

@@ -0,0 +1,42 @@
+package com.sckw.transport.model.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+import java.math.BigDecimal;
+
+/**
+ * @author lfdc
+ * @description
+ * @date 2024-03-06 15:03:37
+ */
+@Data
+public class UnLoadAddressVo implements Serializable {
+
+    /**
+     * 卸货地名
+     */
+    private String unloadName;
+    /**
+     * 卸货详细地址
+     */
+    private String unloadAddress;
+    /**
+     * 卸货联系人
+     */
+    private String unloadContacts;
+    /**
+     * 卸货联系电话
+     */
+    private String unloadPhone;
+    /**
+     * 卸货详细地址
+     */
+    private String unloadAddressDetail;
+
+    /**
+     * 卸货量
+     */
+    private BigDecimal unloadAmount;
+
+}

+ 77 - 35
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtAcceptCarriageOrderService.java

@@ -114,50 +114,53 @@ public class KwtAcceptCarriageOrderService {
     PaymentDubboService paymentDubboService;
 
     @Autowired
-    KwtTransportCommonService transportCommonService;
+    public KwtLogisticsOrderGoodsService logisticsOrderGoodsService;
 
     @Autowired
-    private MessageUrlConfig messageUrlConfig;
+    public KwtWaybillOrderService waybillOrderService;
 
     @Autowired
-    public KwtCommonService commonService;
+    KwtTransportCommonService transportCommonService;
 
     @Autowired
-    public KwtWaybillOrderService waybillOrderService;
+    private MessageUrlConfig messageUrlConfig;
 
     @Autowired
-    public KwtLogisticsOrderGoodsService logisticsOrderGoodsService;
+    public KwtCommonService commonService;
 
     @Resource
     private StreamBridge streamBridge;
 
     @Autowired
-    private KwtLogisticsOrderMapper logisticsOrderMapper;
-
-    @Autowired
-    private KwtLogisticsOrderTrackMapper logisticsOrderTrackMapper;
+    public KwtLogisticsOrderContractMapper kwtLogisticsOrderContractMapper;
 
     @Autowired
-    private KwtWaybillOrderMapper waybillOrderMapper;
+    private KwtLogisticsOrderCirculateMapper logisticsOrderCirculateMapper;
 
     @Autowired
-    private KwtWaybillOrderTicketMapper waybillOrderTicketMapper;
+    private KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
 
     @Autowired
     public KwtLogisticsOrderGoodsMapper kwtLogisticsOrderGoodsMapper;
 
     @Autowired
-    public KwtLogisticsOrderContractMapper kwtLogisticsOrderContractMapper;
+    public KwtLogisticsOrderAmountMapper logisticsOrderAmountMapper;
 
     @Autowired
-    private KwtLogisticsOrderCirculateMapper logisticsOrderCirculateMapper;
+    private KwtLogisticsOrderTrackMapper logisticsOrderTrackMapper;
 
     @Autowired
-    private KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
+    private KwtWaybillOrderTicketMapper waybillOrderTicketMapper;
 
     @Autowired
     public KwtLogisticsOrderUnitMapper logisticsOrderUnitMapper;
 
+    @Autowired
+    private KwtLogisticsOrderMapper logisticsOrderMapper;
+
+    @Autowired
+    private KwtWaybillOrderMapper waybillOrderMapper;
+
     @Autowired
     private MongoTemplate mongoTemplate;
 
@@ -200,7 +203,7 @@ public class KwtAcceptCarriageOrderService {
                     throw new BusinessException("分配承运量必须填写大于0.00");
                 }
                 BigDecimal subtract = logisticsOrder.getAmount().subtract((logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount()));
-                if (bo.getCarryingCapacity().compareTo(subtract) == 1) {
+                if (bo.getCarryingCapacity().compareTo(subtract) < 1) {
                     throw new BusinessException("分配承运量必须可待分配量");
                 }
                 KwtLogisticsOrder order = new KwtLogisticsOrder();
@@ -1768,10 +1771,10 @@ public class KwtAcceptCarriageOrderService {
         KwtLogisticsOrderUnit unitTwo = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
                 .eq(StringUtils.isNotBlank(Long.parseLong(id)), KwtLogisticsOrderUnit::getLOrderId, Long.parseLong(id))
                 .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
-        KwtLogisticsOrderAddress loadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+        List<KwtLogisticsOrderAddress> loadOrderAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                 .eq(StringUtils.isNotBlank(Long.parseLong(id)), KwtLogisticsOrderAddress::getLOrderId, Long.parseLong(id))
                 .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
-        KwtLogisticsOrderAddress unloadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+        List<KwtLogisticsOrderAddress> unloadOrderAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                 .eq(StringUtils.isNotBlank(Long.parseLong(id)), KwtLogisticsOrderAddress::getLOrderId, Long.parseLong(id))
                 .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO));
         KwtLogisticsOrderGoods orderGoods = kwtLogisticsOrderGoodsMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderGoods>()
@@ -1780,8 +1783,6 @@ public class KwtAcceptCarriageOrderService {
         orderDetailVO.setRemark(logisticsOrder.getRemark());
         orderDetailVO.setTaxRate(logisticsOrder.getTaxRate());
         orderDetailVO.setTaxRateLabel(logisticsOrder.getTaxRate() + "%");
-        orderDetailVO.setLoadName(loadOrderAddress.getName());
-        orderDetailVO.setUnloadName(unloadOrderAddress.getName());
         orderDetailVO.setId(String.valueOf(logisticsOrder.getId()));
         if (contract != null) {
             orderDetailVO.setContractId(contract.getContractId() == null ? null : String.valueOf(contract.getContractId()));
@@ -1812,22 +1813,63 @@ public class KwtAcceptCarriageOrderService {
         orderDetailVO.setPrice(logisticsOrder.getPrice() == null ? null : logisticsOrder.getPrice());
         orderDetailVO.setLoss(logisticsOrder.getLoss() == null ? null : logisticsOrder.getLoss());
         orderDetailVO.setDeduct(logisticsOrder.getGoodsPrice() == null ? null : logisticsOrder.getGoodsPrice());
-        orderDetailVO.setLoadAddress(loadOrderAddress.getName());
-        orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
-        orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
-        if (loadOrderAddress.getDetailAddress().contains(loadOrderAddress.getCityName())) {
-            orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
-        } else {
-            orderDetailVO.setLoadAddressDetail(loadOrderAddress.getCityName() + loadOrderAddress.getDetailAddress());
-        }
-        orderDetailVO.setUnloadAddress(unloadOrderAddress.getName());
-        orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
-        orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
-        if (unloadOrderAddress.getDetailAddress().contains(unloadOrderAddress.getCityName())) {
-            orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
-        } else {
-            orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getCityName() + unloadOrderAddress.getDetailAddress());
-        }
+
+        List<LoadAddressVo> loadAddressList = new ArrayList<>();
+        loadOrderAddress.forEach(loadAddress -> {
+            LoadAddressVo vo = new LoadAddressVo();
+            vo.setLoadName(loadAddress.getName());
+            vo.setLoadAddress(loadAddress.getCityName());
+            vo.setLoadContacts(loadAddress.getContacts());
+            vo.setLoadPhone(loadAddress.getPhone());
+            vo.setLoadAddressDetail(loadAddress.getDetailAddress());
+            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
+                    .eq(KwtLogisticsOrderAmount::getLOrderId, loadAddress.getLOrderId())
+                    .eq(KwtLogisticsOrderAmount::getLAddressId, loadAddress.getId())
+                    .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
+            );
+            vo.setLoadAmount(orderAmount != null ? orderAmount.getLoadAmount() : new BigDecimal("0.00"));
+            loadAddressList.add(vo);
+
+        });
+        orderDetailVO.setLoadAddressList(loadAddressList);
+
+        List<UnLoadAddressVo> unloadAddressList = new ArrayList<>();
+        unloadOrderAddress.forEach(unloadAddress -> {
+            UnLoadAddressVo vo = new UnLoadAddressVo();
+            vo.setUnloadName(unloadAddress.getName());
+            vo.setUnloadAddress(unloadAddress.getCityName());
+            vo.setUnloadContacts(unloadAddress.getContacts());
+            vo.setUnloadPhone(unloadAddress.getPhone());
+            vo.setUnloadAddressDetail(unloadAddress.getDetailAddress());
+            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
+                    .eq(KwtLogisticsOrderAmount::getLOrderId, unloadAddress.getLOrderId())
+                    .eq(KwtLogisticsOrderAmount::getLAddressId, unloadAddress.getId())
+                    .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
+            );
+            vo.setUnloadAmount(orderAmount != null ? orderAmount.getUnloadAmount() : new BigDecimal("0.00"));
+            unloadAddressList.add(vo);
+
+        });
+        orderDetailVO.setUnloadAddressList(unloadAddressList);
+
+//        orderDetailVO.setLoadName(loadOrderAddress.getName());
+//        orderDetailVO.setUnloadName(unloadOrderAddress.getName());
+//        orderDetailVO.setLoadAddress(loadOrderAddress.getName());
+//        orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
+//        orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
+//        if (loadOrderAddress.getDetailAddress().contains(loadOrderAddress.getCityName())) {
+//            orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
+//        } else {
+//            orderDetailVO.setLoadAddressDetail(loadOrderAddress.getCityName() + loadOrderAddress.getDetailAddress());
+//        }
+//        orderDetailVO.setUnloadAddress(unloadOrderAddress.getName());
+//        orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
+//        orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
+//        if (unloadOrderAddress.getDetailAddress().contains(unloadOrderAddress.getCityName())) {
+//            orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
+//        } else {
+//            orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getCityName() + unloadOrderAddress.getDetailAddress());
+//        }
         orderDetailVO.setSettlementCycle(logisticsOrder.getSettlementCycle() == null ? null : String.valueOf(logisticsOrder.getSettlementCycle()));
         orderDetailVO.setBillingMode(logisticsOrder.getBillingMode());
         orderDetailVO.setScheduleStartTime(logisticsOrder.getStartTime() == null ? null : logisticsOrder.getStartTime());

+ 8 - 0
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsConsignmentService.java

@@ -2185,6 +2185,10 @@ public class KwtLogisticsConsignmentService {
         return HttpResult.ok();
     }
 
+    /**
+     * 采购订单/销售订单-物流托运-v4.2
+     * @param dto
+     */
     private void logisticsConsignmentSave(LogisticsConsignmentDto dto) {
         logisticsOrderConsignmentService.logisticsConsignmentSave(dto);
     }
@@ -2197,4 +2201,8 @@ public class KwtLogisticsConsignmentService {
     public HttpResult addLogisticsOrder(AddLogisticsOrderParam addLogisticsOrderParam) {
         return logisticsOrderConsignmentService.addLogisticsOrder(addLogisticsOrderParam);
     }
+
+    public HttpResult logisticsOrderSubcontract(LogisticsOrderSubcontractDto logisticsOrderSubcontractDto) {
+        return logisticsOrderConsignmentService.logisticsOrderSubcontract(logisticsOrderSubcontractDto);
+    }
 }

+ 612 - 7
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtLogisticsOrderConsignmentService.java

@@ -6,8 +6,10 @@ import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.sckw.contract.api.RemoteContractService;
 import com.sckw.contract.api.model.dto.res.ContractCommonInfoResDto;
+import com.sckw.core.common.enums.StringConstant;
 import com.sckw.core.common.enums.enums.DictTypeEnum;
 import com.sckw.core.exception.BusinessException;
+import com.sckw.core.model.constant.Global;
 import com.sckw.core.model.constant.NumberConstant;
 import com.sckw.core.model.enums.CooperateTypeEnum;
 import com.sckw.core.model.enums.LogisticsOrderEnum;
@@ -34,6 +36,7 @@ import com.sckw.order.api.model.*;
 import com.sckw.product.api.dubbo.GoodsInfoService;
 import com.sckw.product.api.model.KwpGoods;
 import com.sckw.redis.config.RedisLockUtil;
+import com.sckw.redis.constant.RedisConstant;
 import com.sckw.stream.enums.MessageEnum;
 import com.sckw.stream.model.SckwBusSum;
 import com.sckw.system.api.RemoteSystemService;
@@ -41,10 +44,7 @@ import com.sckw.system.api.model.dto.res.EntCacheResDto;
 import com.sckw.transport.common.config.MessageUrlConfig;
 import com.sckw.transport.dao.*;
 import com.sckw.transport.model.*;
-import com.sckw.transport.model.dto.AddressInfoDto;
-import com.sckw.transport.model.dto.ContractDto;
-import com.sckw.transport.model.dto.LineFreightDto;
-import com.sckw.transport.model.dto.LogisticsConsignmentDto;
+import com.sckw.transport.model.dto.*;
 import com.sckw.transport.model.param.AddLogisticsOrderParam;
 import jakarta.annotation.Resource;
 import lombok.extern.slf4j.Slf4j;
@@ -57,6 +57,7 @@ import org.springframework.util.ObjectUtils;
 
 import java.math.BigDecimal;
 import java.util.*;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 /**
@@ -139,7 +140,7 @@ public class KwtLogisticsOrderConsignmentService {
     public KwtLogisticsOrderGoodsMapper goodsMapper;
 
     /**
-     * 采购订单/销售订单-物流托运-4.2
+     * 采购订单/销售订单-物流托运-v4.2
      *
      * @param dto
      */
@@ -457,6 +458,7 @@ public class KwtLogisticsOrderConsignmentService {
                     loadOrderAddress.setCityCode(detail.getCityCode());
                     loadOrderAddress.setLng(detail.getLng());
                     loadOrderAddress.setSort(addressInfoDto.getSort());
+                    loadOrderAddress.setTAddressId(Long.parseLong(addressInfoDto.getAddressId()));
                     logisticsOrderAddressMapper.insert(loadOrderAddress);
 
                     KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
@@ -500,6 +502,7 @@ public class KwtLogisticsOrderConsignmentService {
                     unloadOrderAddress.setCityCode(detail.getCityCode());
                     unloadOrderAddress.setLng(detail.getLng());
                     unloadOrderAddress.setSort(addressInfoDto.getSort());
+                    unloadOrderAddress.setTAddressId(Long.parseLong(addressInfoDto.getAddressId()));
                     logisticsOrderAddressMapper.insert(unloadOrderAddress);
 
                     KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
@@ -1083,8 +1086,8 @@ public class KwtLogisticsOrderConsignmentService {
         List<AddressInfoDto> addressInfo = orderDTO.getAddressInfo();
         List<String> addressIds = addressInfo.stream().map(AddressInfoDto::getAddressId).collect(Collectors.toList());
         Map<Long, EntAddressResDto> addressDetailMap = manageService.queryAddressListByAddressIdList(addressIds);
-        if (addressDetailMap.isEmpty()){
-            log.info("no address :{}",JSONObject.toJSONString(addressIds));
+        if (addressDetailMap.isEmpty()) {
+            log.info("no address :{}", JSONObject.toJSONString(addressIds));
             throw new BusinessException("地址信息异常");
         }
         Map<Integer, List<AddressInfoDto>> addressMap = addressInfo.stream().collect(Collectors.groupingBy(AddressInfoDto::getAddressType));
@@ -1359,4 +1362,606 @@ public class KwtLogisticsOrderConsignmentService {
             }
         }
     }
+
+    /**
+     * 物流订单-分包托运
+     *
+     * @param logisticsOrderSubcontractDto
+     * @return
+     */
+    public HttpResult logisticsOrderSubcontract(LogisticsOrderSubcontractDto bo) {
+        HttpResult httpResult = ValidUtil.serviceValid(bo);
+        String key = String.format(RedisConstant.LOGISTICS_ORDER_SUBCONTRACT_KEY, bo.getLOrderId());
+        if (redisLockUtil.tryLock(key)) {
+            try {
+                if (!String.valueOf(HttpStatus.SUCCESS_CODE).equals(String.valueOf(httpResult.getCode()))) {
+                    httpResult.setMsg(httpResult.getMsg());
+                    httpResult.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
+                    return httpResult;
+                }
+
+                KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectById(bo.getLOrderId());
+                if (logisticsOrder == null) {
+                    log.error("订单id查找失败:{},订单编号:{}", bo.getLOrderId(), bo.getLOrderNo());
+                    throw new BusinessException("单据错误,数据不存在");
+                }
+                //todo  校验当前登录角色是否具有4P物流角色
+                EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
+                if (entCacheResDto == null) {
+                    log.info("承运订单-分包托运 用户id:{}", LoginUserHolder.getUserId());
+                    throw new BusinessException("企业信息查询异常");
+                }
+                if (!entCacheResDto.getEntTypes().contains(String.valueOf(NumberConstant.THREE))) {
+                    throw new BusinessException("当前用户企业不具有分包功能权限!");
+                }
+                if (bo.getCarryingCapacity().compareTo(NumberConstant.ZERO_TWO) == 0) {
+                    throw new BusinessException("分配承运量必须填写大于0.00");
+                }
+                BigDecimal subtract = logisticsOrder.getAmount().subtract((logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount()));
+                if (bo.getCarryingCapacity().compareTo(subtract) > 0) {
+                    throw new BusinessException("分配承运量必须可待分配量");
+                }
+                KwtLogisticsOrder order = new KwtLogisticsOrder();
+                if (!bo.getIsFullDose()) {
+                    BigDecimal amount = bo.getAmount();
+                    BigDecimal carryingCapacity = bo.getCarryingCapacity();
+                    if (amount.compareTo(carryingCapacity) < 0) {
+                        log.error("运订单分包托运-可分配量分配错误:{}", bo.getLOrderId());
+                        throw new RuntimeException("可分配量分配错误");
+                    }
+                    if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
+                        throw new RuntimeException("不是全量分配时,分配量不能为空!");
+                    }
+                    order.setAmount(bo.getCarryingCapacity());
+                    order.setUnit(bo.getCarryingCapacityUnit());
+                } else {
+                    order.setAmount(new BigDecimal(NumberConstant.ZERO));
+                    order.setSubcontractAmount(new BigDecimal(NumberConstant.ZERO));
+                    order.setUnit(bo.getCarryingCapacityUnit());
+                }
+                BigDecimal subcontractAmount = logisticsOrder.getSubcontractAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getSubcontractAmount();
+                BigDecimal entrustAmount = logisticsOrder.getEntrustAmount() == null ? NumberConstant.ZERO_TWO : logisticsOrder.getEntrustAmount();
+                BigDecimal waitDistributionAmount = logisticsOrder.getAmount().subtract(subcontractAmount).subtract(entrustAmount);
+                if (waitDistributionAmount.compareTo(NumberConstant.ZERO_TWO) == 0) {
+                    throw new RuntimeException("剩余可分配量为0,不可进行分包操作!");
+                }
+                int level = logisticsLevel(logisticsOrder);
+                long number = logisticsOrderMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrder>()
+                                .eq(KwtLogisticsOrder::getDelFlag, NumberConstant.ZERO)
+                                .apply(logisticsOrder.getId() != null, "FIND_IN_SET ('" + bo.getLOrderId() + "', pids)").ne(KwtLogisticsOrder::getId, bo.getLOrderId()))
+                        .stream().count();
+                String pidOrderNo = logisticsOrder.getLOrderNo();
+                String substring = pidOrderNo.substring(0, 11);
+                String lOrderNo = substring + logisticsOrder.getType() + String.valueOf(level) + String.valueOf(number + 1);
+                Long orderId = new IdWorker(NumberConstant.ONE).nextId();
+                //分包托运需要判断处于哪一级分包托运,需要记录当前分包数据-分包上游数据
+                //判断是否已存在分包【当前分包只允许加上主单一共四级】
+                if (level >= 4) {
+                    throw new RuntimeException("分包次数已达上限!");
+                }
+                String pids = logisticsOrder.getPids();
+                if (StringUtils.isNotBlank(pids)) {
+                    pids = pids + StringConstant.COMMA + orderId;
+                } else {
+                    pids = bo.getLOrderId() + StringConstant.COMMA + orderId;
+                }
+                /**判断生成物流订单应生成哪一种单据状态*/
+                List<Long> contractList = new ArrayList<>();
+                contractList.add(Long.parseLong(bo.getContractId()));
+                Map<Long, ContractCommonInfoResDto> longContractCommonInfoResDtoMap = contractService.queryContractBaseInfo(contractList);
+                if (CollectionUtils.isEmpty(longContractCommonInfoResDtoMap)) {
+                    throw new RuntimeException("并未有对应合同,应先签约合同");
+                }
+                if (longContractCommonInfoResDtoMap.get(Long.parseLong(bo.getContractId())) == null) {
+                    throw new RuntimeException("并未有对应合同,应先签约合同");
+                }
+                ContractCommonInfoResDto infoResDto = longContractCommonInfoResDtoMap.get(Long.parseLong(bo.getContractId()));
+                /**状态判断
+                 * 是否是已签约合同
+                 * */
+                // 0 已签约 1待签约
+                Integer status = infoResDto.getStatus();
+                Integer orderStatus = LogisticsOrderEnum.PENDING_ORDER.getCode();
+                if (NumberConstant.ONE == status) {
+                    orderStatus = LogisticsOrderEnum.TO_BE_PLANNED.getCode();
+                } else if (NumberConstant.ZERO == status) {
+                    orderStatus = LogisticsOrderEnum.PENDING_ORDER.getCode();
+                } else {
+                    log.info("分包托运-物流订单id:{}," +
+                                    "物流订单编号:{},合同id:{},合同信息:{}",
+                            bo.getLOrderId(), bo.getLOrderNo(),
+                            bo.getContractId(), JSONObject.toJSONString(infoResDto));
+                    throw new RuntimeException("分包托运合同异常");
+                }
+                //主体信息保存
+                logisticsOrderGoodsService.insertSubcontractLogisticsGoods(logisticsOrder, lOrderNo, orderId);
+                insertSubcontractLogisticsOrder(bo, lOrderNo, order, orderId, pids, orderStatus, logisticsOrder);
+                insertSubcontractLogisticsOrderContract(bo, orderId, infoResDto);
+                insertSubcontractLogisticsOrderUnit(bo, orderId);
+                insertSubcontractLogisticsOrderAddressAndAmount(bo, orderId, logisticsOrder);
+                insertLogisticsOrderTrack(bo, orderId, orderStatus);
+                if (bo.getBillingMode().equals("4")) {
+                    insertLogisticsOrderLineFreight(bo, orderId);
+                }
+                //修改上级分配量以及可分配量委托量等
+                logisticsOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(bo.getCarryingCapacity()));
+                logisticsOrderMapper.updateById(logisticsOrder);
+
+                List<AddressInfoDto> addressInfo = bo.getAddressInfo();
+                addressInfo.forEach(addressInfoDto -> {
+                    String addressId = addressInfoDto.getAddressId();
+                    KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectById(addressId);
+                    if (orderAmount != null) {
+                        orderAmount.setSubcontractAmount(orderAmount.getSubcontractAmount().add(addressInfoDto.getAmount()));
+                        logisticsOrderAmountMapper.updateById(orderAmount);
+                    }
+                });
+
+
+                /**数据发送至消息列表*/
+                String type = bo.getType();
+                if ("1".equals(type)){
+                    /**托运订单*/
+                }else if ("2".equals(type)){
+                    /**承运订单*/
+                    EntCacheResDto consignentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getAcceptCompanyId()));
+                    EntCacheResDto checkentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getConsignCompanyId()));
+                    //托运单位
+                    KwtLogisticsOrderUnit checkUnit = new KwtLogisticsOrderUnit();
+                    checkUnit.setUnitType(1);
+                    checkUnit.setFirmName(bo.getConsignCompany());
+                    checkUnit.setEntId(Long.parseLong(bo.getConsignCompanyId()));
+                    checkUnit.setTopEntId(consignentMap == null ? null : consignentMap.getId());
+                    checkUnit.setContactsId(Long.parseLong(bo.getConsignContactsId()));
+                    //承运单位
+                    KwtLogisticsOrderUnit carriageUnit = new KwtLogisticsOrderUnit();
+                    carriageUnit.setUnitType(2);
+                    carriageUnit.setFirmName(bo.getAcceptCompany());
+                    carriageUnit.setEntId(Long.parseLong(bo.getAcceptCompanyId()));
+                    carriageUnit.setContactsId(Long.parseLong(bo.getAcceptContactsId()));
+                    carriageUnit.setFirmName(bo.getAcceptCompany());
+                    carriageUnit.setTopEntId(checkentMap == null ? null : checkentMap.getId());
+
+//        commonService.initIatingLogisticsConsignment(checkUnit, carriageUnit, logisticsOrder.getLOrderNo(), logisticsOrder.getCreateBy(), logisticsOrder.getEntId());
+                    commonService.newSendLogisticsOrderToMessage(carriageUnit, checkUnit, logisticsOrder.getLOrderNo(), logisticsOrder.getCreateBy(), logisticsOrder.getEntId(),
+                            messageUrlConfig.getPc().getConsignLogisticsAddOrderUrl(), messageUrlConfig.getApp().getConsignLogisticsAddOrderUrl(),
+                            messageUrlConfig.getPc().getCarriageLogisticsAddOrderUrl(), messageUrlConfig.getApp().getCarriageLogisticsAddOrderUrl(),
+                            MessageEnum.INITIATING_LOGISTICS_CONSIGNMENT, MessageEnum.NEW_CARRIAGE_ORDER,
+                            "1");
+                }
+                //修改父级mongodb数据
+                //更新mongodb
+                SckwLogisticsOrder lOrder = new SckwLogisticsOrder();
+                lOrder.set_id(order.getId());
+                lOrder.setLOrderId(order.getId());
+                lOrder.setEntrustAmount(order.getEntrustAmount());
+                lOrder.setStatus(String.valueOf(order.getStatus()));
+                lOrder.setUpdateTime(order.getUpdateTime());
+                lOrder.setUpdateBy(order.getUpdateBy());
+                lOrder.setUpdateByName(LoginUserHolder.getUserName());
+                lOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(bo.getCarryingCapacity()));
+//        lOrder.setIgnoreAmount(logisticsOrder.getIgnoreAmount().subtract(bo.getCarryingCapacity()));
+                //rabbitMq业务汇总数据发送/消费对象
+                SckwBusSum busSum = new SckwBusSum();
+                //业务汇总类型
+                busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
+                //操作对象(1新增/2修改/3替换数据)
+                busSum.setMethod(2);
+                //业务汇总数据对象
+                busSum.setObject(lOrder);
+                streamBridge.send("sckw-busSum", com.alibaba.fastjson2.JSON.toJSONString(busSum));
+                //新增当前分包mongodb数据
+                subcontractSendMongoDB(lOrderNo, orderId, bo, logisticsOrder, orderStatus);
+            } finally {
+                redisLockUtil.unlock(key);
+            }
+            return HttpResult.ok();
+        }
+        return HttpResult.error("当前数据正在处理,请勿重复提交");
+    }
+
+    private void subcontractSendMongoDB(String lOrderNo, Long orderId, LogisticsOrderSubcontractDto bo, KwtLogisticsOrder kwtLogisticsOrder, Integer orderStatus) {
+        SckwLogisticsOrder logisticsOrder = new SckwLogisticsOrder();
+        logisticsOrder.setStatus(String.valueOf(orderStatus));
+        logisticsOrder.setLOrderId(orderId);
+        logisticsOrder.setLOrderNo(lOrderNo);
+        logisticsOrder.setLOrderPid(Long.parseLong(bo.getLOrderId()));
+        logisticsOrder.setSettlementCycle(bo.getSettlementCycle());
+        logisticsOrder.setPrice(bo.getPrice());
+        logisticsOrder.setPriceType(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()) == null ?
+                null : Long.parseLong(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()).getValue()));
+        if (!bo.getIsFullDose()) {
+            if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
+                throw new RuntimeException("不是全量分配时,分配量不能为空!");
+            }
+            logisticsOrder.setAmount(bo.getCarryingCapacity());
+            logisticsOrder.setUnit(bo.getCarryingCapacityUnit());
+            logisticsOrder.setCarryingCapacity(bo.getCarryingCapacity());
+        } else {
+            logisticsOrder.setAmount(NumberConstant.ZERO_TWO);
+            logisticsOrder.setSubcontractAmount(NumberConstant.ZERO_TWO);
+            logisticsOrder.setCarryingCapacity(NumberConstant.ZERO_TWO);
+        }
+        logisticsOrder.setLoss(bo.getLoss() == null ? null : bo.getLoss());
+        logisticsOrder.setLossUnit(bo.getLossUnit());
+        logisticsOrder.setGoodsPrice(bo.getGoodsPrice());
+        BigDecimal decimal = new BigDecimal(NumberConstant.ZERO);
+        logisticsOrder.setSubcontractAmount(decimal);
+        logisticsOrder.setEntrustAmount(decimal);
+        logisticsOrder.setUnloadAmount(decimal);
+        logisticsOrder.setLoadAmount(decimal);
+        logisticsOrder.setIgnoreAmount(decimal);
+        logisticsOrder.setDeficitPrice(decimal);
+        logisticsOrder.setPayment(Long.parseLong(bo.getPayment()));
+        logisticsOrder.setTaxRate(bo.getTaxRate() == null ? null : new BigDecimal(bo.getTaxRate()));
+        logisticsOrder.setRemark(bo.getRemark());
+        logisticsOrder.setEntId(LoginUserHolder.getEntId());
+        logisticsOrder.setFirmName(remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId()).getFirmName());
+        if (bo.getGoodsId() != null) {
+            logisticsOrder.setGoodsId(Long.parseLong(bo.getGoodsId()));
+            KwpGoods goods = goodsInfoService.getGoodsById(Long.parseLong(bo.getGoodsId()));
+            logisticsOrder.setGoodsType(goods == null ? null : goods.getGoodsType());
+            logisticsOrder.setGoodsSpec(goods == null ? null : goods.getSpec());
+        }
+        logisticsOrder.setGoodsName(bo.getGoodsName());
+        logisticsOrder.setContractId(bo.getContractId());
+        logisticsOrder.setContractNo(bo.getContractNo());
+        logisticsOrder.setContractName(bo.getContractName());
+        logisticsOrder.setContractSigningWay(bo.getPayment());
+        logisticsOrder.setCheckEntId(Long.parseLong(bo.getConsignCompanyId()));
+        logisticsOrder.setCheckFirmName(bo.getConsignCompany());
+        logisticsOrder.setCheckContacts(bo.getConsignContacts());
+        logisticsOrder.setCheckPhone(bo.getConsignContactPhone());
+        logisticsOrder.setCarrierEntId(Long.parseLong(bo.getAcceptContactsId()));
+        logisticsOrder.setCarrierFirmName(bo.getAcceptCompany());
+        logisticsOrder.setCarrierContacts(bo.getAcceptContacts());
+        //TODO 生成时并无时间
+//        logisticsOrder.setLoadTime();
+//        logisticsOrder.setunLoadTime();
+        logisticsOrder.setCreateBy(LoginUserHolder.getUserId());
+        logisticsOrder.setCreateByName(LoginUserHolder.getUserName());
+        logisticsOrder.setCreateTime(new Date());
+        logisticsOrder.setUpdateBy(LoginUserHolder.getUserId());
+        logisticsOrder.setUpdateByName(LoginUserHolder.getUserName());
+        logisticsOrder.setUpdateTime(new Date());
+        logisticsOrder.setGoodsPriceUnit(bo.getGoodsPriceUnit());
+        logisticsOrder.setContractName(bo.getContractName());
+        logisticsOrder.setBillingMode(bo.getBillingMode());
+        //rabbitMq业务汇总数据发送/消费对象
+        SckwBusSum busSum = new SckwBusSum();
+        //业务汇总类型
+        busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
+        //操作对象(1新增/2修改)
+        busSum.setMethod(1);
+        //业务汇总数据对象
+        busSum.setObject(logisticsOrder);
+        streamBridge.send("sckw-busSum", JSON.toJSONString(busSum));
+
+    }
+
+    private void insertLogisticsOrderLineFreight(LogisticsOrderSubcontractDto dto, Long orderId) {
+        List<LineFreightDto> lineFreightList = dto.getLineFreightList();
+        List<Long> lineFreightId = lineFreightList.stream().map(t -> t.getLineFreightId()).distinct().collect(Collectors.toList());
+        Map<Long, LineFreightAddressRes> resMap = manageService.findLineFreightAddress(lineFreightId);
+        if (resMap != null) {
+            lineFreightId.stream().forEach(id -> {
+                if (resMap.get(id) != null) {
+                    LineFreightAddressRes res = resMap.get(id);
+                    KwtLogisticsOrderLineFreightRate lineFreightRate = new KwtLogisticsOrderLineFreightRate();
+                    lineFreightRate.setLOrderId(orderId);
+                    lineFreightRate.setName(res.getName());
+                    lineFreightRate.setLoadName(res.getLoadName());
+                    lineFreightRate.setLoadCityCode(res.getLoadCityCode());
+                    lineFreightRate.setLoadCityName(res.getLoadCityName());
+                    lineFreightRate.setLoadDetailAddress(res.getLoadDetailAddress());
+                    lineFreightRate.setLoadLat(res.getLoadLat());
+                    lineFreightRate.setLoadLng(res.getLoadLng());
+                    lineFreightRate.setUnloadName(res.getUnloadName());
+                    lineFreightRate.setUnloadCityCode(res.getUnloadCityCode());
+                    lineFreightRate.setUnloadCityName(res.getUnloadCityName());
+                    lineFreightRate.setUnloadDetailAddress(res.getUnloadDetailAddress());
+                    lineFreightRate.setUnloadLat(res.getUnloadLat());
+                    lineFreightRate.setUnloadLng(res.getUnloadLng());
+                    lineFreightRate.setTransportMileage(res.getTransportMileage());
+                    lineFreightRate.setTransportPrice(res.getTransportPrice());
+                    BigDecimal defultBigDecimal = new BigDecimal("0.00");
+                    lineFreightRate.setSettlementAmount(defultBigDecimal);
+                    lineFreightRate.setId(new IdWorker(NumberConstant.FOUR).nextId());
+                    lineFreightRate.setRemark(res.getRemark());
+                    lineFreightRate.setStatus(res.getStatus());
+                    lineFreightRate.setCreateBy(LoginUserHolder.getUserId());
+                    lineFreightRate.setCreateTime(new Date());
+                    lineFreightRate.setUpdateBy(LoginUserHolder.getUserId());
+                    lineFreightRate.setUpdateTime(new Date());
+                    lineFreightRate.setDelFlag(0);
+                    logisticsOrderLineFreightRateMapper.insert(lineFreightRate);
+                }
+            });
+        }
+
+    }
+
+    private void insertLogisticsOrderTrack(LogisticsOrderSubcontractDto bo, Long orderId, Integer orderStatus) {
+        KwtLogisticsOrderTrack entity = new KwtLogisticsOrderTrack();
+        entity.setId(new IdWorker(NumberConstant.ONE).nextId());
+        entity.setLOrderId(orderId);
+        entity.setStatus(orderStatus);
+        entity.setCreateTime(new Date());
+        entity.setUpdateTime(new Date());
+        entity.setCreateBy(LoginUserHolder.getUserId());
+        entity.setUpdateBy(LoginUserHolder.getUserId());
+        entity.setRemark(bo.getRemark());
+        logisticsOrderTrackMapper.insert(entity);
+    }
+
+    private void insertSubcontractLogisticsOrderAddressAndAmount(LogisticsOrderSubcontractDto bo, Long orderId, KwtLogisticsOrder logisticsOrder) {
+        List<AddressInfoDto> addressInfo = bo.getAddressInfo();
+        Map<Integer, List<AddressInfoDto>> addressMap = addressInfo.stream().collect(Collectors.groupingBy(AddressInfoDto::getAddressType));
+
+        /**处理装货*/
+        List<AddressInfoDto> loadAddress = addressMap.get(NumberConstant.ONE);
+        List<String> loadAddressIds = loadAddress.stream().map(AddressInfoDto::getAddressId).distinct().collect(Collectors.toList());
+        List<KwtLogisticsOrderAddress> orderLoadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+                .eq(KwtLogisticsOrderAddress::getLOrderId, logisticsOrder.getId())
+                .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE)
+                .in(KwtLogisticsOrderAddress::getId, loadAddressIds)
+        );
+        Map<Long, KwtLogisticsOrderAddress> parentLoadOrderMap = new HashMap<Long, KwtLogisticsOrderAddress>();
+        if (!CollectionUtils.isEmpty(orderLoadAddress)) {
+            parentLoadOrderMap = orderLoadAddress.stream().collect(Collectors.toMap(KwtLogisticsOrderAddress::getId, Function.identity()));
+        }
+        if (!CollectionUtils.isEmpty(loadAddress)) {
+            for (AddressInfoDto address : loadAddress) {
+                if (address.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+                    continue;
+                }
+                if (parentLoadOrderMap.get(address.getAddressId()) != null) {
+                    KwtLogisticsOrderAddress loadAddressData = parentLoadOrderMap.get(address.getAddressId());
+                    KwtLogisticsOrderAddress loadOrderAddress = new KwtLogisticsOrderAddress();
+                    long addressId = new IdWorker(NumberConstant.ONE).nextId();
+                    loadOrderAddress.setId(addressId);
+                    loadOrderAddress.setAddressType(NumberConstant.ONE);
+                    loadOrderAddress.setTAddressId(loadAddressData.getTAddressId() == null ? null : loadAddressData.getTAddressId());
+                    loadOrderAddress.setPAddressId(loadAddressData.getId());
+                    loadOrderAddress.setDetailAddress(loadAddressData.getDetailAddress());
+                    loadOrderAddress.setContacts(loadAddressData.getContacts());
+                    loadOrderAddress.setLOrderId(orderId);
+                    loadOrderAddress.setLat(loadAddressData.getLat());
+                    loadOrderAddress.setFence(loadAddressData.getFence());
+                    loadOrderAddress.setCityName(loadAddressData.getCityName());
+                    loadOrderAddress.setEntryType(NumberConstant.FOUR);
+                    loadOrderAddress.setCreateTime(new Date());
+                    loadOrderAddress.setPhone(loadAddressData.getPhone());
+                    loadOrderAddress.setCreateBy(LoginUserHolder.getUserId());
+                    loadOrderAddress.setUpdateBy(LoginUserHolder.getUserId());
+                    loadOrderAddress.setUpdateTime(new Date());
+                    loadOrderAddress.setName(loadAddressData.getName());
+                    loadOrderAddress.setType(loadAddressData.getType());
+                    loadOrderAddress.setCityCode(loadAddressData.getCityCode());
+                    loadOrderAddress.setLng(loadAddressData.getLng());
+                    loadOrderAddress.setRemark(loadAddressData.getRemark());
+                    loadOrderAddress.setStatus(loadAddressData.getStatus());
+                    logisticsOrderAddressMapper.insert(loadOrderAddress);
+
+                    KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
+                    BigDecimal defaultBigDecimal = new BigDecimal("0.00");
+                    orderAmount.setLOrderId(orderId);
+                    orderAmount.setLAddressId(addressId);
+                    orderAmount.setAmount(address.getAmount());
+                    orderAmount.setSubcontractAmount(defaultBigDecimal);
+                    orderAmount.setEntrustAmount(defaultBigDecimal);
+                    orderAmount.setLoadAmount(defaultBigDecimal);
+                    orderAmount.setUnloadAmount(defaultBigDecimal);
+                    orderAmount.setIgnoreAmount(defaultBigDecimal);
+                    orderAmount.setId(new IdWorker(NumberConstant.THREE).nextId());
+                    orderAmount.setStatus(0);
+                    orderAmount.setCreateBy(LoginUserHolder.getUserId());
+                    orderAmount.setCreateTime(new Date());
+                    orderAmount.setUpdateBy(LoginUserHolder.getUserId());
+                    orderAmount.setUpdateTime(new Date());
+                    orderAmount.setDelFlag(0);
+                    logisticsOrderAmountMapper.insert(orderAmount);
+                }
+            }
+
+        }
+        /**处理卸货*/
+        List<AddressInfoDto> unloadAddress = addressMap.get(NumberConstant.TWO);
+        List<String> unloadAddressIds = unloadAddress.stream().map(AddressInfoDto::getAddressId).distinct().collect(Collectors.toList());
+        List<KwtLogisticsOrderAddress> orderUnLoadAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+                .eq(KwtLogisticsOrderAddress::getLOrderId, logisticsOrder.getId())
+                .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO)
+                .in(KwtLogisticsOrderAddress::getId, unloadAddressIds)
+        );
+        Map<Long, KwtLogisticsOrderAddress> parentUnloadOrderMap = new HashMap<Long, KwtLogisticsOrderAddress>();
+        if (!CollectionUtils.isEmpty(orderUnLoadAddress)) {
+            parentUnloadOrderMap = orderUnLoadAddress.stream().collect(Collectors.toMap(KwtLogisticsOrderAddress::getId, Function.identity()));
+        }
+
+        if (!ObjectUtils.isEmpty(unloadAddress)) {
+            for (AddressInfoDto address : unloadAddress) {
+                if (address.getAmount().compareTo(new BigDecimal("0.00")) == 0) {
+                    continue;
+                }
+                if (parentLoadOrderMap.get(address.getAddressId()) != null) {
+                    KwtLogisticsOrderAddress loadAddressData = parentLoadOrderMap.get(address.getAddressId());
+                    KwtLogisticsOrderAddress unloadOrderAddress = new KwtLogisticsOrderAddress();
+                    long addressId = new IdWorker(NumberConstant.ONE).nextId();
+                    unloadOrderAddress.setId(addressId);
+                    unloadOrderAddress.setAddressType(NumberConstant.TWO);
+                    unloadOrderAddress.setTAddressId(loadAddressData.getTAddressId() == null ? null : loadAddressData.getTAddressId());
+                    unloadOrderAddress.setPAddressId(loadAddressData.getId());
+                    unloadOrderAddress.setId(new IdWorker(NumberConstant.ONE).nextId());
+                    unloadOrderAddress.setContacts(loadAddressData.getContacts());
+                    unloadOrderAddress.setLOrderId(orderId);
+                    unloadOrderAddress.setLat(loadAddressData.getLat());
+                    unloadOrderAddress.setFence(loadAddressData.getFence());
+                    unloadOrderAddress.setCityName(loadAddressData.getCityName());
+                    unloadOrderAddress.setEntryType(NumberConstant.FOUR);
+                    unloadOrderAddress.setPhone(loadAddressData.getPhone());
+                    unloadOrderAddress.setDetailAddress(loadAddressData.getDetailAddress());
+                    unloadOrderAddress.setCreateTime(new Date());
+                    unloadOrderAddress.setCreateBy(LoginUserHolder.getUserId());
+                    unloadOrderAddress.setUpdateBy(LoginUserHolder.getUserId());
+                    unloadOrderAddress.setUpdateTime(new Date());
+                    unloadOrderAddress.setName(loadAddressData.getName());
+                    unloadOrderAddress.setType(loadAddressData.getType());
+                    unloadOrderAddress.setCityCode(loadAddressData.getCityCode());
+                    unloadOrderAddress.setLng(loadAddressData.getLng());
+                    unloadOrderAddress.setRemark(loadAddressData.getRemark());
+                    unloadOrderAddress.setStatus(loadAddressData.getStatus());
+                    logisticsOrderAddressMapper.insert(unloadOrderAddress);
+
+                    KwtLogisticsOrderAmount orderAmount = new KwtLogisticsOrderAmount();
+                    BigDecimal defaultBigDecimal = new BigDecimal("0.00");
+                    orderAmount.setLOrderId(orderId);
+                    orderAmount.setLAddressId(addressId);
+                    orderAmount.setAmount(address.getAmount());
+                    orderAmount.setSubcontractAmount(defaultBigDecimal);
+                    orderAmount.setEntrustAmount(defaultBigDecimal);
+                    orderAmount.setLoadAmount(defaultBigDecimal);
+                    orderAmount.setUnloadAmount(defaultBigDecimal);
+                    orderAmount.setIgnoreAmount(defaultBigDecimal);
+                    orderAmount.setId(new IdWorker(NumberConstant.THREE).nextId());
+                    orderAmount.setStatus(0);
+                    orderAmount.setCreateBy(LoginUserHolder.getUserId());
+                    orderAmount.setCreateTime(new Date());
+                    orderAmount.setUpdateBy(LoginUserHolder.getUserId());
+                    orderAmount.setUpdateTime(new Date());
+                    orderAmount.setDelFlag(0);
+                    logisticsOrderAmountMapper.insert(orderAmount);
+                }
+            }
+        }
+    }
+
+
+    private void insertSubcontractLogisticsOrderUnit(LogisticsOrderSubcontractDto bo, Long orderId) {
+        EntCacheResDto consignentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getAcceptCompanyId()));
+        EntCacheResDto checkentMap = remoteSystemService.queryEntTreeById(Long.parseLong(bo.getConsignCompanyId()));
+        KwtLogisticsOrderUnit checkUnit = new KwtLogisticsOrderUnit()
+                .setLOrderId(orderId)
+                .setId(new IdWorker(NumberConstant.ONE).nextId())
+                .setUnitType(NumberConstant.ONE)
+                .setFirmName(bo.getConsignCompany())
+                .setRemark(bo.getRemark())
+                .setTopEntId(checkentMap == null ? null : checkentMap.getId())
+                .setEntId(Long.parseLong(bo.getConsignCompanyId()))
+                .setContacts(bo.getConsignContacts())
+                .setPhone(bo.getConsignContactPhone())
+                .setCreateBy(LoginUserHolder.getUserId())
+                .setCreateTime(new Date())
+                .setUpdateBy(LoginUserHolder.getUserId())
+                .setUpdateTime(new Date())
+                .setContactsId(Long.parseLong(bo.getConsignContactsId()));
+        logisticsOrderUnitMapper.insert(checkUnit);
+
+        KwtLogisticsOrderUnit consignUnit = new KwtLogisticsOrderUnit()
+                .setLOrderId(orderId)
+                .setId(new IdWorker(NumberConstant.ONE).nextId())
+                .setUnitType(NumberConstant.TWO)
+                .setFirmName(bo.getAcceptCompany())
+                .setRemark(bo.getRemark())
+                .setTopEntId(consignentMap == null ? null : consignentMap.getId())
+                .setEntId(Long.parseLong(bo.getAcceptCompanyId()))
+                .setContacts(bo.getAcceptContacts())
+                .setPhone(bo.getAcceptContactPhone())
+                .setCreateBy(LoginUserHolder.getUserId())
+                .setCreateTime(new Date())
+                .setUpdateBy(LoginUserHolder.getUserId())
+                .setUpdateTime(new Date())
+                .setContactsId(Long.parseLong(bo.getAcceptContactsId()));
+        logisticsOrderUnitMapper.insert(consignUnit);
+    }
+
+
+    private void insertSubcontractLogisticsOrderContract(LogisticsOrderSubcontractDto bo, Long orderId, ContractCommonInfoResDto infoResDto) {
+        KwtLogisticsOrderContract kwtLogisticsOrderContract = new KwtLogisticsOrderContract();
+        kwtLogisticsOrderContract.setId(new IdWorker(NumberConstant.ONE).nextId());
+        kwtLogisticsOrderContract.setLOrderId(orderId);
+        kwtLogisticsOrderContract.setContractId(Long.parseLong(bo.getContractId()));
+        kwtLogisticsOrderContract.setContractName(bo.getContractName() == null ? infoResDto.getContactName() : bo.getContractName());
+        kwtLogisticsOrderContract.setContractNo(bo.getContractNo() == null ? infoResDto.getContractCode() : bo.getContractNo());
+        kwtLogisticsOrderContract.setSigningWay(infoResDto.getSigningWay() != null ? String.valueOf(infoResDto.getSigningWay()) : null);
+        kwtLogisticsOrderContract.setRemark(bo.getRemark());
+        kwtLogisticsOrderContract.setCreateBy(LoginUserHolder.getUserId());
+        kwtLogisticsOrderContract.setUpdateBy(LoginUserHolder.getUserId());
+        kwtLogisticsOrderContract.setCreateTime(new Date());
+        kwtLogisticsOrderContract.setUpdateTime(new Date());
+        logisticsOrderContractMapper.insert(kwtLogisticsOrderContract);
+    }
+
+    /**
+     * 分包托运-订单-主体
+     *
+     * @param bo             页面填写分包数据
+     * @param lOrderNo       当前分包物流订单编号
+     * @param order          当前物流订单数据
+     * @param orderId        当前订单主键id
+     * @param pids           组装的pids
+     * @param orderStatus    当前单据状态
+     * @param logisticsOrder 父级物流订单
+     */
+    private void insertSubcontractLogisticsOrder(LogisticsOrderSubcontractDto bo, String lOrderNo,
+                                                 KwtLogisticsOrder order,
+                                                 Long orderId, String pids, Integer orderStatus, KwtLogisticsOrder logisticsOrder) {
+        order.setId(orderId);
+        order.setEntId(LoginUserHolder.getEntId());
+        order.setType(logisticsOrder.getType());
+        order.setTOrderId(logisticsOrder.getTOrderId());
+        order.setTOrderNo(logisticsOrder.getTOrderNo());
+        order.setLOrderNo(lOrderNo);
+        //分包时,存放分包上级id
+        order.setPid(Long.parseLong(bo.getLOrderId()));
+        //存放所有的分包的父级id
+        order.setPids(pids);
+        order.setSettlementCycle(bo.getSettlementCycle());
+        order.setPrice(bo.getPrice());
+        order.setPriceType(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()) == null ?
+                null : Long.parseLong(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getPriceType()).getValue()));
+        order.setAmount(bo.getCarryingCapacity());
+        order.setBillingMode(bo.getBillingMode());
+        order.setLoss(bo.getLoss());
+        order.setLossUnit(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.UNIT_TYPE.getType(), bo.getLossUnit()) == null ?
+                null : remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.UNIT_TYPE.getType(), bo.getLossUnit()).getValue());
+        order.setGoodsPrice(bo.getGoodsPrice() == null ? null : bo.getGoodsPrice());
+        order.setGoodsPriceUnit(remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getGoodsPriceUnit()) == null ?
+                null : remoteSystemService.queryDictByTypeAndValue(DictTypeEnum.PRICE_TYPE.getType(), bo.getGoodsPriceUnit()).getValue());
+        order.setStartTime(bo.getStartTime() == null ? null : DateUtil.localDateToLocalDateTimeStart(bo.getStartTime()));
+        order.setEndTime(bo.getEndTime() == null ? null : DateUtil.localDateToLocalDateTimeEnd(bo.getEndTime()));
+        order.setRemark(bo.getRemark());
+        order.setPayment(Long.parseLong(bo.getPayment()));
+        order.setTaxRate(new BigDecimal(bo.getTaxRate()));
+        order.setCreateBy(LoginUserHolder.getUserId());
+        order.setCreateTime(new Date());
+        order.setUpdateBy(LoginUserHolder.getUserId());
+        order.setUpdateTime(new Date());
+        order.setStatus(orderStatus);
+        /**补充默认值*/
+        BigDecimal decimal = new BigDecimal(NumberConstant.ZERO);
+        order.setEntrustAmount(decimal);
+        order.setSubcontractAmount(decimal);
+        order.setLoadAmount(decimal);
+        order.setUnloadAmount(decimal);
+        order.setIgnoreAmount(decimal);
+        order.setDeficitPrice(decimal);
+        order.setDeficitAmount(decimal);
+        order.setTotalUnloadAmount(decimal);
+        order.setTotalLoadAmount(decimal);
+        order.setBindStatus(String.valueOf(NumberConstant.ZERO));
+        logisticsOrderMapper.insert(order);
+    }
+
+    /**
+     * @param logisticsOrder 承运订单
+     * @description 当前承运订单所属分包层级
+     * @author zk
+     * @date 2023/7/24
+     **/
+    public int logisticsLevel(KwtLogisticsOrder logisticsOrder) {
+        String pids = logisticsOrder.getPids();
+        String[] idArrays = StringUtils.isBlank(pids) ? new String[0] : pids.split(Global.COMMA);
+        return idArrays.length <= 1 ? Global.NUMERICAL_ONE : idArrays.length;
+    }
+
 }

+ 69 - 27
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/KwtTransportCommonService.java

@@ -72,39 +72,43 @@ public class KwtTransportCommonService {
     @DubboReference(version = "1.0.0", group = "design", check = false, timeout = 10000)
     RemoteContractService remoteContractService;
 
-    @Autowired
-    RedisLockUtil redisLockUtil;
-
     @Autowired
     MessageUrlConfig messageUrlConfig;
 
     @Autowired
-    public KwtCommonService commonService;
+    RedisLockUtil redisLockUtil;
 
-    @Autowired
-    public KwtWaybillOrderService waybillOrderService;
 
     @Autowired
     public KwtLogisticsOrderGoodsService logisticsOrderGoodsService;
 
     @Autowired
-    public KwtLogisticsOrderGoodsMapper logisticsOrderGoodsMapper;
+    public KwtWaybillOrderService waybillOrderService;
 
     @Autowired
-    public KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
+    public KwtCommonService commonService;
 
     @Autowired
-    public KwtLogisticsOrderMapper logisticsOrderMapper;
+    public KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
 
     @Autowired
     public KwtLogisticsOrderAddressMapper logisticsOrderAddressMapper;
 
+    @Autowired
+    public KwtLogisticsOrderAmountMapper logisticsOrderAmountMapper;
+
     @Autowired
     public KwtLogisticsOrderTrackMapper logisticsOrderTrackMapper;
 
+    @Autowired
+    public KwtLogisticsOrderGoodsMapper logisticsOrderGoodsMapper;
+
     @Autowired
     public KwtLogisticsOrderUnitMapper logisticsOrderUnitMapper;
 
+    @Autowired
+    public KwtLogisticsOrderMapper logisticsOrderMapper;
+
     @Autowired
     public KwtWaybillOrderMapper waybillOrderMapper;
 
@@ -151,9 +155,9 @@ public class KwtTransportCommonService {
      */
     private OrderDetailVO getOrderData(DocumentParamDTO dto) {
         KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
-                        .eq(KwtLogisticsOrder::getId, dto.getId())
-                        .eq(StringUtils.isNotBlank(dto.getDocumentNo()), KwtLogisticsOrder::getLOrderNo, dto.getDocumentNo())
-                );
+                .eq(KwtLogisticsOrder::getId, dto.getId())
+                .eq(StringUtils.isNotBlank(dto.getDocumentNo()), KwtLogisticsOrder::getLOrderNo, dto.getDocumentNo())
+        );
         if (logisticsOrder == null) {
             log.info("查无单据:{}", JSONObject.toJSONString(dto));
             throw new RuntimeException("查无单据");
@@ -167,10 +171,10 @@ public class KwtTransportCommonService {
         KwtLogisticsOrderUnit unitTwo = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
                 .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderUnit::getLOrderId, dto.getId())
                 .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
-        KwtLogisticsOrderAddress loadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+        List<KwtLogisticsOrderAddress> loadOrderAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                 .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderAddress::getLOrderId, dto.getId())
                 .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
-        KwtLogisticsOrderAddress unloadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+        List<KwtLogisticsOrderAddress> unloadOrderAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                 .eq(StringUtils.isNotBlank(dto.getId()), KwtLogisticsOrderAddress::getLOrderId, dto.getId())
                 .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO));
         KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderGoods>()
@@ -212,16 +216,54 @@ public class KwtTransportCommonService {
         orderDetailVO.setPrice(logisticsOrder.getPrice() == null ? null : logisticsOrder.getPrice());
         orderDetailVO.setLoss(logisticsOrder.getLoss() == null ? null : logisticsOrder.getLoss());
         orderDetailVO.setDeduct(logisticsOrder.getGoodsPrice() == null ? null : logisticsOrder.getGoodsPrice());
-        orderDetailVO.setLoadName(loadOrderAddress.getName());
-        orderDetailVO.setLoadAddress(loadOrderAddress.getCityName());
-        orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
-        orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
-        orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
-        orderDetailVO.setUnloadName(unloadOrderAddress.getName());
-        orderDetailVO.setUnloadAddress(unloadOrderAddress.getCityName());
-        orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
-        orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
-        orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
+//        orderDetailVO.setLoadName(loadOrderAddress.getName());
+//        orderDetailVO.setLoadAddress(loadOrderAddress.getCityName());
+//        orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
+//        orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
+//        orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
+//        orderDetailVO.setUnloadName(unloadOrderAddress.getName());
+//        orderDetailVO.setUnloadAddress(unloadOrderAddress.getCityName());
+//        orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
+//        orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
+//        orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
+        List<LoadAddressVo> loadAddressList = new ArrayList<>();
+        loadOrderAddress.forEach(loadAddress -> {
+            LoadAddressVo vo = new LoadAddressVo();
+            vo.setLoadName(loadAddress.getName());
+            vo.setLoadAddress(loadAddress.getCityName());
+            vo.setLoadContacts(loadAddress.getContacts());
+            vo.setLoadPhone(loadAddress.getPhone());
+            vo.setLoadAddressDetail(loadAddress.getDetailAddress());
+            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
+                    .eq(KwtLogisticsOrderAmount::getLOrderId, loadAddress.getLOrderId())
+                    .eq(KwtLogisticsOrderAmount::getLAddressId, loadAddress.getId())
+                    .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
+            );
+            vo.setLoadAmount(orderAmount != null ? orderAmount.getLoadAmount() : new BigDecimal("0.00"));
+            loadAddressList.add(vo);
+
+        });
+        orderDetailVO.setLoadAddressList(loadAddressList);
+
+        List<UnLoadAddressVo> unloadAddressList = new ArrayList<>();
+        unloadOrderAddress.forEach(unloadAddress -> {
+            UnLoadAddressVo vo = new UnLoadAddressVo();
+            vo.setUnloadName(unloadAddress.getName());
+            vo.setUnloadAddress(unloadAddress.getCityName());
+            vo.setUnloadContacts(unloadAddress.getContacts());
+            vo.setUnloadPhone(unloadAddress.getPhone());
+            vo.setUnloadAddressDetail(unloadAddress.getDetailAddress());
+            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
+                    .eq(KwtLogisticsOrderAmount::getLOrderId, unloadAddress.getLOrderId())
+                    .eq(KwtLogisticsOrderAmount::getLAddressId, unloadAddress.getId())
+                    .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
+            );
+            vo.setUnloadAmount(orderAmount != null ? orderAmount.getUnloadAmount() : new BigDecimal("0.00"));
+            unloadAddressList.add(vo);
+
+        });
+        orderDetailVO.setUnloadAddressList(unloadAddressList);
+
         orderDetailVO.setSettlementCycle(logisticsOrder.getSettlementCycle() == null ? null : String.valueOf(logisticsOrder.getSettlementCycle()));
         if (logisticsOrder.getSettlementCycle() != null) {
             Map<String, SysDictResDto> dtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.SETTLEMENT_CYCLE.getType());
@@ -360,7 +402,7 @@ public class KwtTransportCommonService {
         if (redisLockUtil.tryLock(key)) {
             try {
                 KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
-                                .eq(KwtLogisticsOrder::getId, orderDto.getId())
+                        .eq(KwtLogisticsOrder::getId, orderDto.getId())
                 );
                 if (logisticsOrder == null) {
                     result.setCode(HttpStatus.GLOBAL_EXCEPTION_CODE);
@@ -909,7 +951,7 @@ public class KwtTransportCommonService {
                         loadings.add(new GoodsLoadingV1Param(e.getUnit(), e.getLoadAmount(), e.getUnloadAmount()));
                     });
                     //数据推送至贸易订单-更新总装卸货量
-                    HttpResult httpResult = tradeOrderInfoService.completeLogisticsOrderV1(LoginUserHolder.getUserId(), LoginUserHolder.getUserName(),logisticsOrder.getTOrderId(), loadings);
+                    HttpResult httpResult = tradeOrderInfoService.completeLogisticsOrderV1(LoginUserHolder.getUserId(), LoginUserHolder.getUserName(), logisticsOrder.getTOrderId(), loadings);
                     if (httpResult.getCode() != HttpStatus.SUCCESS_CODE) {
                         log.info("贸易订单手动完结订单异常,传递信息:{}{},返回信息:{}", logisticsOrder.getTOrderId(), loadings, JSONObject.toJSONString(httpResult));
                         throw new BusinessException("单据完结出现错误!" + httpResult.getMsg());
@@ -922,7 +964,7 @@ public class KwtTransportCommonService {
                     if (httpResult.getCode() != HttpStatus.SUCCESS_CODE) {
                         log.info("托运订单手动完结订单-完结订单,传递信息:{},返回信息:{}",
                                 "userId:" + LoginUserHolder.getUserId() +
-                                        "userName:" +LoginUserHolder.getUserName() +
+                                        "userName:" + LoginUserHolder.getUserName() +
                                         "id:" + logisticsOrder.getTOrderId() +
                                         "orderNo" + logisticsOrder.getTOrderNo(),
                                 JSONObject.toJSONString(httpResult))

+ 55 - 12
sckw-modules/sckw-transport/src/main/java/com/sckw/transport/service/operateService/KwtManagementLogisticsOrderService.java

@@ -78,6 +78,9 @@ public class KwtManagementLogisticsOrderService {
     @Autowired
     public KwtLogisticsOrderGoodsMapper logisticsOrderGoodsMapper;
 
+    @Autowired
+    public KwtLogisticsOrderAmountMapper logisticsOrderAmountMapper;
+
     @Autowired
     public KwtLogisticsOrderContractMapper logisticsOrderContractMapper;
 
@@ -439,10 +442,10 @@ public class KwtManagementLogisticsOrderService {
         KwtLogisticsOrderUnit unitTwo = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
                 .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderUnit::getLOrderId, orderId)
                 .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.TWO));
-        KwtLogisticsOrderAddress loadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+        List<KwtLogisticsOrderAddress> loadOrderAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                 .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderAddress::getLOrderId, orderId)
                 .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
-        KwtLogisticsOrderAddress unloadOrderAddress = logisticsOrderAddressMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
+        List<KwtLogisticsOrderAddress> unloadOrderAddress = logisticsOrderAddressMapper.selectList(new LambdaQueryWrapper<KwtLogisticsOrderAddress>()
                 .eq(StringUtils.isNotBlank(orderId), KwtLogisticsOrderAddress::getLOrderId, orderId)
                 .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.TWO));
         KwtLogisticsOrderGoods orderGoods = logisticsOrderGoodsMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderGoods>()
@@ -480,16 +483,56 @@ public class KwtManagementLogisticsOrderService {
         orderDetailVO.setPrice(logisticsOrder.getPrice() == null ? null : logisticsOrder.getPrice());
         orderDetailVO.setLoss(logisticsOrder.getLoss() == null ? null : logisticsOrder.getLoss());
         orderDetailVO.setDeduct(logisticsOrder.getGoodsPrice() == null ? null : logisticsOrder.getGoodsPrice());
-        orderDetailVO.setLoadName(loadOrderAddress.getName());
-        orderDetailVO.setLoadAddress(loadOrderAddress.getCityName());
-        orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
-        orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
-        orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
-        orderDetailVO.setUnloadName(unloadOrderAddress.getName());
-        orderDetailVO.setUnloadAddress(unloadOrderAddress.getCityName());
-        orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
-        orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
-        orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
+
+
+        List<LoadAddressVo> loadAddressList = new ArrayList<>();
+        loadOrderAddress.forEach(loadAddress -> {
+            LoadAddressVo vo = new LoadAddressVo();
+            vo.setLoadName(loadAddress.getName());
+            vo.setLoadAddress(loadAddress.getCityName());
+            vo.setLoadContacts(loadAddress.getContacts());
+            vo.setLoadPhone(loadAddress.getPhone());
+            vo.setLoadAddressDetail(loadAddress.getDetailAddress());
+            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
+                    .eq(KwtLogisticsOrderAmount::getLOrderId, loadAddress.getLOrderId())
+                    .eq(KwtLogisticsOrderAmount::getLAddressId, loadAddress.getId())
+                    .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
+            );
+            vo.setLoadAmount(orderAmount != null ? orderAmount.getLoadAmount() : new BigDecimal("0.00"));
+            loadAddressList.add(vo);
+
+        });
+        orderDetailVO.setLoadAddressList(loadAddressList);
+
+        List<UnLoadAddressVo> unloadAddressList = new ArrayList<>();
+        unloadOrderAddress.forEach(unloadAddress -> {
+            UnLoadAddressVo vo = new UnLoadAddressVo();
+            vo.setUnloadName(unloadAddress.getName());
+            vo.setUnloadAddress(unloadAddress.getCityName());
+            vo.setUnloadContacts(unloadAddress.getContacts());
+            vo.setUnloadPhone(unloadAddress.getPhone());
+            vo.setUnloadAddressDetail(unloadAddress.getDetailAddress());
+            KwtLogisticsOrderAmount orderAmount = logisticsOrderAmountMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderAmount>()
+                    .eq(KwtLogisticsOrderAmount::getLOrderId, unloadAddress.getLOrderId())
+                    .eq(KwtLogisticsOrderAmount::getLAddressId, unloadAddress.getId())
+                    .eq(KwtLogisticsOrderAmount::getDelFlag, 0)
+            );
+            vo.setUnloadAmount(orderAmount != null ? orderAmount.getUnloadAmount() : new BigDecimal("0.00"));
+            unloadAddressList.add(vo);
+
+        });
+        orderDetailVO.setUnloadAddressList(unloadAddressList);
+
+//        orderDetailVO.setLoadName(loadOrderAddress.getName());
+//        orderDetailVO.setLoadAddress(loadOrderAddress.getCityName());
+//        orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
+//        orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
+//        orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
+//        orderDetailVO.setUnloadName(unloadOrderAddress.getName());
+//        orderDetailVO.setUnloadAddress(unloadOrderAddress.getCityName());
+//        orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
+//        orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
+//        orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
         orderDetailVO.setSettlementCycle(logisticsOrder.getSettlementCycle() == null ? null : String.valueOf(logisticsOrder.getSettlementCycle()));
         if (logisticsOrder.getSettlementCycle() != null) {
             Map<String, SysDictResDto> dtoMap = remoteSystemService.queryDictMapByType(DictTypeEnum.SETTLEMENT_CYCLE.getType());