|
|
@@ -3,23 +3,23 @@ package com.sckw.transport.handler;
|
|
|
|
|
|
import com.sckw.core.common.enums.enums.ErrorCodeEnum;
|
|
|
import com.sckw.core.exception.BusinessPlatfromException;
|
|
|
+import com.sckw.core.model.constant.Global;
|
|
|
import com.sckw.core.model.enums.AddressTypeEnum;
|
|
|
import com.sckw.core.model.enums.CarWaybillV1Enum;
|
|
|
import com.sckw.order.api.model.OrderDetailVo;
|
|
|
-import com.sckw.transport.model.KwtLogisticsOrder;
|
|
|
-import com.sckw.transport.model.KwtWaybillOrder;
|
|
|
-import com.sckw.transport.model.KwtWaybillOrderSubtask;
|
|
|
-import com.sckw.transport.model.KwtWaybillOrderTicket;
|
|
|
+import com.sckw.transport.model.*;
|
|
|
import com.sckw.transport.model.param.WaybillOrderUnloadParam;
|
|
|
import com.sckw.transport.repository.KwtWaybillOrderSubtaskRepository;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.*;
|
|
|
-import java.util.function.Function;
|
|
|
-import java.util.stream.Collectors;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Objects;
|
|
|
+import java.util.Optional;
|
|
|
|
|
|
/**
|
|
|
* Author: donglang
|
|
|
@@ -69,7 +69,7 @@ public class UnloadingHandler extends AbstractWaybillOrderHandler<WaybillOrderUn
|
|
|
|
|
|
//按照装货量计算:推送到已完成状态
|
|
|
if (orderDetailVo.getChargeType() == 1) {
|
|
|
- this.targetStatus = CarWaybillV1Enum.WAIT_UNLOADING.getCode();
|
|
|
+ this.targetStatus = Global.NUMERICAL_ONE;
|
|
|
//1.计算净装货量
|
|
|
BigDecimal loadAmount = getLoadAmount(param);
|
|
|
|
|
|
@@ -80,7 +80,10 @@ public class UnloadingHandler extends AbstractWaybillOrderHandler<WaybillOrderUn
|
|
|
updateTradeOrder(logisticsOrder, loadAmount, subtask);
|
|
|
|
|
|
} else if (orderDetailVo.getChargeType() == 2) {
|
|
|
- this.targetStatus = CarWaybillV1Enum.COMPLETION_LOADING.getCode();
|
|
|
+ if (param.getUnloadAmount() == null || StringUtils.isBlank(param.getUnloadUrl())) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.PARAM_ERROR, "卸货净重和卸货凭证不能为空!");
|
|
|
+ }
|
|
|
+ this.targetStatus = Global.NUMERICAL_ONE;
|
|
|
//按照卸货量计算:推送到已卸货状态,更新子运单卸货净重
|
|
|
KwtWaybillOrderSubtask subtask = getWaybillSubtask(waybill.getId());
|
|
|
subtask.setUnloadAmount(param.getUnloadAmount());
|
|
|
@@ -158,12 +161,43 @@ public class UnloadingHandler extends AbstractWaybillOrderHandler<WaybillOrderUn
|
|
|
|
|
|
@Override
|
|
|
protected Integer getStatus() {
|
|
|
- return Optional.ofNullable(this.targetStatus)
|
|
|
- .orElse(CarWaybillV1Enum.COMPLETION_LOADING.getCode());
|
|
|
+ if (this.targetStatus == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.SYSTEM_ERROR, "[卸货]计算方式为空!");
|
|
|
+ }
|
|
|
+ return Objects.equals(this.targetStatus, Global.NUMERICAL_ONE) ? CarWaybillV1Enum.WAIT_UNLOADING.getCode()
|
|
|
+ : CarWaybillV1Enum.COMPLETION_LOADING.getCode();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected String getRemark(WaybillOrderUnloadParam param, KwtWaybillOrder waybillOrder) {
|
|
|
- return "司机[" + waybillOrder.getDriverName() + "]已上传卸货凭证";
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 重写 createNodeTrace,生成两条轨迹记录
|
|
|
+ */
|
|
|
+ protected void createNodeTrace(WaybillOrderUnloadParam param, KwtWaybillOrder waybillOrder) {
|
|
|
+ if (this.targetStatus == null) {
|
|
|
+ throw new BusinessPlatfromException(ErrorCodeEnum.SYSTEM_ERROR, "[卸货]计算方式为空!");
|
|
|
+ }
|
|
|
+ if (this.targetStatus == Global.NUMERICAL_ONE) {
|
|
|
+ // 第一条:卸货已完成
|
|
|
+ KwtWaybillOrderNode node1 = getWaybillOrderNode(param, waybillOrder);
|
|
|
+ node1.setRemark("司机[" + waybillOrder.getDriverName() + "]已卸货");
|
|
|
+ node1.setOrderStatus(CarWaybillV1Enum.COMPLETION_LOADING.getCode());
|
|
|
+ waybillOrderNodeRepository.save(node1);
|
|
|
+ log.info("记录【卸货】节点轨迹成功,节点ID:{}", node1.getId());
|
|
|
+
|
|
|
+ // 第二条:运单完成
|
|
|
+ KwtWaybillOrderNode node2 = getWaybillOrderNode(param, waybillOrder);
|
|
|
+ node2.setRemark("运单[" + waybillOrder.getId() + "]已完成");
|
|
|
+ waybillOrderNodeRepository.save(node2);
|
|
|
+ log.info("记录【完成】节点轨迹成功,节点ID:{}", node2.getId());
|
|
|
+ } else {
|
|
|
+ KwtWaybillOrderNode node = getWaybillOrderNode(param, waybillOrder);
|
|
|
+ node.setRemark("司机[" + waybillOrder.getDriverName() + "]已上传卸货凭证");
|
|
|
+ waybillOrderNodeRepository.save(node);
|
|
|
+ log.info("记录【卸货】节点轨迹成功,节点ID:{}", node.getId());
|
|
|
+ }
|
|
|
}
|
|
|
}
|