|
|
@@ -14,11 +14,13 @@ import com.sckw.core.exception.BusinessException;
|
|
|
import com.sckw.core.model.enums.CarWaybillEnum;
|
|
|
import com.sckw.core.model.enums.LogisticsOrderEnum;
|
|
|
import com.sckw.core.model.page.PageResult;
|
|
|
-import com.sckw.core.utils.*;
|
|
|
+import com.sckw.core.utils.CollectionUtils;
|
|
|
+import com.sckw.core.utils.IdWorker;
|
|
|
+import com.sckw.core.utils.RegularUtils;
|
|
|
+import com.sckw.core.utils.StringUtils;
|
|
|
import com.sckw.core.web.constant.HttpStatus;
|
|
|
import com.sckw.core.web.context.LoginUserHolder;
|
|
|
import com.sckw.core.web.response.HttpResult;
|
|
|
-import com.sckw.excel.utils.DateUtil;
|
|
|
import com.sckw.excel.utils.ValidUtil;
|
|
|
import com.sckw.fleet.api.RemoteFleetService;
|
|
|
import com.sckw.fleet.api.model.vo.RTruckVo;
|
|
|
@@ -49,7 +51,6 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.text.ParseException;
|
|
|
import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
@@ -147,16 +148,16 @@ public class AcceptCarriageOrderService {
|
|
|
}
|
|
|
KwtLogisticsOrder order = new KwtLogisticsOrder();
|
|
|
if (!bo.getIsFullDose()) {
|
|
|
- Long amount = bo.getAmount();
|
|
|
- Long carryingCapacity = bo.getCarryingCapacity();
|
|
|
- if (carryingCapacity > amount) {
|
|
|
+ BigDecimal amount = bo.getAmount();
|
|
|
+ BigDecimal carryingCapacity = bo.getCarryingCapacity();
|
|
|
+ if (carryingCapacity.compareTo(amount) < 0) {
|
|
|
log.error("运订单分包托运-可分配量分配错误:{}", bo.getLOrderId());
|
|
|
throw new RuntimeException("可分配量分配错误");
|
|
|
}
|
|
|
if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
|
|
|
throw new RuntimeException("不是全量分配时,分配量不能为空!");
|
|
|
}
|
|
|
- order.setAmount(new BigDecimal(bo.getCarryingCapacity()));
|
|
|
+ order.setAmount(bo.getCarryingCapacity());
|
|
|
order.setUnit(bo.getCarryingCapacityUnit());
|
|
|
} else {
|
|
|
order.setAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
@@ -216,7 +217,7 @@ public class AcceptCarriageOrderService {
|
|
|
insertSubcontractLogisticsOrderAddress(bo, orderId, logisticsOrder);
|
|
|
insertLogisticsOrderTrack(bo, orderId, orderStatus);
|
|
|
//修改上级分配量以及可分配量委托量等
|
|
|
- logisticsOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(new BigDecimal(bo.getCarryingCapacity())));
|
|
|
+ logisticsOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(bo.getCarryingCapacity()));
|
|
|
logisticsOrderMapper.updateById(logisticsOrder);
|
|
|
//修改父级mongodb数据
|
|
|
//更新mongodb
|
|
|
@@ -228,7 +229,8 @@ public class AcceptCarriageOrderService {
|
|
|
lOrder.setUpdateTime(order.getUpdateTime());
|
|
|
lOrder.setUpdateBy(order.getUpdateBy());
|
|
|
lOrder.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
- lOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(new BigDecimal(bo.getCarryingCapacity()))); //rabbitMq业务汇总数据发送/消费对象
|
|
|
+ lOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(bo.getCarryingCapacity()));
|
|
|
+ //rabbitMq业务汇总数据发送/消费对象
|
|
|
SckwBusSum busSum = new SckwBusSum();
|
|
|
//业务汇总类型
|
|
|
busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
@@ -266,13 +268,13 @@ public class AcceptCarriageOrderService {
|
|
|
if (ArrayUtil.isEmpty(bo.getCarryingCapacity())) {
|
|
|
throw new RuntimeException("不是全量分配时,分配量不能为空!");
|
|
|
}
|
|
|
- logisticsOrder.setAmount(new BigDecimal(bo.getCarryingCapacity()));
|
|
|
+ logisticsOrder.setAmount(bo.getCarryingCapacity());
|
|
|
logisticsOrder.setUnit(bo.getCarryingCapacityUnit());
|
|
|
logisticsOrder.setCarryingCapacity(bo.getCarryingCapacity());
|
|
|
} else {
|
|
|
- logisticsOrder.setAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
- logisticsOrder.setSubcontractAmount(new BigDecimal(NumberConstant.ZERO));
|
|
|
- logisticsOrder.setCarryingCapacity(0L);
|
|
|
+ logisticsOrder.setAmount(new BigDecimal("0.00"));
|
|
|
+ logisticsOrder.setSubcontractAmount(new BigDecimal("0.00"));
|
|
|
+ logisticsOrder.setCarryingCapacity(new BigDecimal("0.00"));
|
|
|
}
|
|
|
logisticsOrder.setLoss(bo.getLoss() == null ? null : bo.getLoss());
|
|
|
logisticsOrder.setLossUnit(bo.getLossUnit());
|
|
|
@@ -522,7 +524,7 @@ public class AcceptCarriageOrderService {
|
|
|
order.setPrice(new BigDecimal(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(new BigDecimal(bo.getCarryingCapacity()));
|
|
|
+ order.setAmount(bo.getCarryingCapacity());
|
|
|
order.setBillingMode(bo.getBillingMode());
|
|
|
order.setLoss(bo.getLoss());
|
|
|
// order.setLossUnit(bo.getLossUnit());
|
|
|
@@ -886,6 +888,23 @@ public class AcceptCarriageOrderService {
|
|
|
List<String> stringList = StringUtils.splitStrToList(stopOrderTakingDTO.getIds(), ",", String.class);
|
|
|
List<Long> wOrderIds = logisticsOrderCirculateMapper.selectEntityBylOrderIdAndOrderIds(stopOrderTakingDTO.getLOrderId(), stringList);
|
|
|
List<JSONObject> list = new ArrayList<>(stringList.size());
|
|
|
+ String type = stopOrderTakingDTO.getType();
|
|
|
+ if (String.valueOf(NumberConstant.TWO).equals(type)){
|
|
|
+ acceptStopDocumentCommit(stopOrderTakingDTO,list,wOrderIds);
|
|
|
+ }else if (String.valueOf(NumberConstant.ONE).equals(type)){
|
|
|
+ consignStopDocumentCommit(stopOrderTakingDTO,list,wOrderIds);
|
|
|
+ }else {
|
|
|
+ return HttpResult.error("单据类型错误!");
|
|
|
+ }
|
|
|
+ return HttpResult.ok(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 托运订单-设置停止接单
|
|
|
+ * @param stopOrderTakingDTO
|
|
|
+ */
|
|
|
+ private void consignStopDocumentCommit(StopOrderTakingDTO stopOrderTakingDTO,List<JSONObject> list,List<Long> wOrderIds) {
|
|
|
+
|
|
|
if (CollectionUtils.isNotEmpty(wOrderIds)) {
|
|
|
wOrderIds.forEach(wOrderId -> {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
@@ -897,10 +916,55 @@ public class AcceptCarriageOrderService {
|
|
|
} else {
|
|
|
logisticsOrderCirculateMapper.update(null, new LambdaUpdateWrapper<KwtLogisticsOrderCirculate>()
|
|
|
.set(KwtLogisticsOrderCirculate::getStatus, NumberConstant.ONE)
|
|
|
- .eq(KwtLogisticsOrderCirculate::getWOrderId, wOrderId));
|
|
|
+ .set(KwtLogisticsOrderCirculate::getUpdateBy,LoginUserHolder.getUserId())
|
|
|
+ .set(KwtLogisticsOrderCirculate::getUpdateTime,new Date())
|
|
|
+ .eq(KwtLogisticsOrderCirculate::getWOrderId, wOrderId)
|
|
|
+ );
|
|
|
// /**更新MongoDB*/
|
|
|
SckwWaybillOrder order = new SckwWaybillOrder();
|
|
|
order.setStatus(NumberConstant.ONE);
|
|
|
+ order.setUpdateTime(new Date());
|
|
|
+ order.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
+ order.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ SckwBusSum busSum = new SckwBusSum();
|
|
|
+ busSum.setBusSumType(BusinessTypeEnum.WAYBILL_ORDER_TYPE.getName());
|
|
|
+ busSum.setMethod(NumberConstant.TWO);
|
|
|
+ busSum.setObject(order);
|
|
|
+ streamBridge.send("sckw-busSum", com.alibaba.fastjson2.JSON.toJSONString(busSum));
|
|
|
+ jsonObject.put("status", HttpStatus.SUCCESS_CODE);
|
|
|
+ jsonObject.put("message", "停止接单成功");
|
|
|
+ }
|
|
|
+ list.add(jsonObject);
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承运订单设置停止接单
|
|
|
+ * @param stopOrderTakingDTO
|
|
|
+ */
|
|
|
+ private void acceptStopDocumentCommit(StopOrderTakingDTO stopOrderTakingDTO,List<JSONObject> list,List<Long> wOrderIds) {
|
|
|
+ if (CollectionUtils.isNotEmpty(wOrderIds)) {
|
|
|
+ wOrderIds.forEach(wOrderId -> {
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("wOrderId", wOrderId);
|
|
|
+ KwtWaybillOrder waybillOrder = waybillOrderMapper.selectOne(new LambdaUpdateWrapper<KwtWaybillOrder>().eq(KwtWaybillOrder::getId, wOrderId));
|
|
|
+ if (waybillOrder == null) {
|
|
|
+ jsonObject.put("status", HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
+ jsonObject.put("message", "单据不存在或者单据异常");
|
|
|
+ } else {
|
|
|
+ logisticsOrderCirculateMapper.update(null, new LambdaUpdateWrapper<KwtLogisticsOrderCirculate>()
|
|
|
+ .set(KwtLogisticsOrderCirculate::getStatus, NumberConstant.ONE)
|
|
|
+ .set(KwtLogisticsOrderCirculate::getUpdateBy,LoginUserHolder.getUserId())
|
|
|
+ .set(KwtLogisticsOrderCirculate::getUpdateTime,new Date())
|
|
|
+ .eq(KwtLogisticsOrderCirculate::getWOrderId, wOrderId)
|
|
|
+ );
|
|
|
+// /**更新MongoDB*/
|
|
|
+ SckwWaybillOrder order = new SckwWaybillOrder();
|
|
|
+ order.setStatus(NumberConstant.ONE);
|
|
|
+ order.setUpdateTime(new Date());
|
|
|
+ order.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
+ order.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
SckwBusSum busSum = new SckwBusSum();
|
|
|
busSum.setBusSumType(BusinessTypeEnum.WAYBILL_ORDER_TYPE.getName());
|
|
|
busSum.setMethod(NumberConstant.TWO);
|
|
|
@@ -912,7 +976,6 @@ public class AcceptCarriageOrderService {
|
|
|
list.add(jsonObject);
|
|
|
});
|
|
|
}
|
|
|
- return HttpResult.ok(list);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -976,7 +1039,7 @@ public class AcceptCarriageOrderService {
|
|
|
orderTrack.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
orderTrack.setUpdateTime(new Date());
|
|
|
waybillOrderTrackMapper.insert(orderTrack);
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
waybillOrderTrack.setUpdateTime(new Date());
|
|
|
waybillOrderTrack.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
waybillOrderTrackMapper.updateById(waybillOrderTrack);
|
|
|
@@ -1245,8 +1308,8 @@ public class AcceptCarriageOrderService {
|
|
|
orderDetailVO.setUnloadAddressDetail(unloadOrderAddress.getDetailAddress());
|
|
|
orderDetailVO.setSettlementCycle(logisticsOrder.getSettlementCycle() == null ? null : String.valueOf(logisticsOrder.getSettlementCycle()));
|
|
|
orderDetailVO.setBillingMode(logisticsOrder.getBillingMode());
|
|
|
- orderDetailVO.setScheduleStartTime(logisticsOrder.getStartTime() == null ? null : DateUtil.getDateTime(logisticsOrder.getStartTime()));
|
|
|
- orderDetailVO.setScheduleEndTime(logisticsOrder.getEndTime() == null ? null : DateUtil.getDateTime(logisticsOrder.getEndTime()));
|
|
|
+ orderDetailVO.setScheduleStartTime(logisticsOrder.getStartTime() == null ? null : logisticsOrder.getStartTime());
|
|
|
+ orderDetailVO.setScheduleEndTime(logisticsOrder.getEndTime() == null ? null : logisticsOrder.getEndTime());
|
|
|
orderDetailVO.setPerformanceAmount(logisticsOrder.getLoadAmount() == null ? null : String.valueOf(logisticsOrder.getLoadAmount()));
|
|
|
return HttpResult.ok(orderDetailVO);
|
|
|
}
|
|
|
@@ -1269,7 +1332,7 @@ public class AcceptCarriageOrderService {
|
|
|
* @return
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public HttpResult addOrder(AddOrderDTO orderDTO) throws ParseException {
|
|
|
+ public HttpResult addOrder(AddOrderDTO orderDTO) {
|
|
|
HttpResult httpResult = ValidUtil.serviceValid(orderDTO);
|
|
|
if (!String.valueOf(HttpStatus.SUCCESS_CODE).equals(String.valueOf(httpResult.getCode()))) {
|
|
|
return HttpResult.error(httpResult.getMsg());
|
|
|
@@ -1336,6 +1399,7 @@ public class AcceptCarriageOrderService {
|
|
|
goods.setLOrderNo(lOrderNo);
|
|
|
// goods.setGoodsId();
|
|
|
goods.setGoodsName(orderDTO.getGoodsName());
|
|
|
+ goods.setGoodsType(orderDTO.getGoodsType());
|
|
|
goods.setStatus(NumberConstant.ZERO);
|
|
|
goods.setCreateBy(LoginUserHolder.getUserId());
|
|
|
goods.setCreateTime(new Date());
|
|
|
@@ -1448,7 +1512,7 @@ public class AcceptCarriageOrderService {
|
|
|
order.setUpdateByName(LoginUserHolder.getUserName());
|
|
|
order.setUpdateTime(new Date());
|
|
|
order.setWOrderNo(lOrderNo);
|
|
|
- order.setCarryingCapacity(orderDTO.getAmount().longValue());
|
|
|
+ order.setCarryingCapacity(orderDTO.getAmount());
|
|
|
order.setBillingMode(orderDTO.getBillingMode());
|
|
|
SckwBusSum busSum = new SckwBusSum();
|
|
|
busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
@@ -1596,7 +1660,7 @@ public class AcceptCarriageOrderService {
|
|
|
* @param orderStatus 订单状态
|
|
|
* @param lOrderNo 主体订单编号
|
|
|
*/
|
|
|
- private void saveLogisticsOrder(AddOrderDTO orderDTO, Long lOrderId, Integer orderStatus, String lOrderNo) throws ParseException {
|
|
|
+ private void saveLogisticsOrder(AddOrderDTO orderDTO, Long lOrderId, Integer orderStatus, String lOrderNo) {
|
|
|
KwtLogisticsOrder order = new KwtLogisticsOrder();
|
|
|
order.setId(lOrderId);
|
|
|
order.setEntId(LoginUserHolder.getEntId());
|
|
|
@@ -1614,10 +1678,10 @@ public class AcceptCarriageOrderService {
|
|
|
order.setLossUnit(orderDTO.getLossUnit());
|
|
|
order.setGoodsPrice(orderDTO.getGoodsPrice() == null ? null : orderDTO.getGoodsPrice());
|
|
|
order.setGoodsPriceUnit(orderDTO.getGoodsPriceUnit());
|
|
|
- order.setStartTime(org.apache.commons.lang3.StringUtils.isBlank(orderDTO.getStartTime()) ?
|
|
|
- null : DateUtil.stringPatchingStartToDateTime(orderDTO.getStartTime()));
|
|
|
- order.setEndTime(org.apache.commons.lang3.StringUtils.isBlank(orderDTO.getEndTime()) ?
|
|
|
- null : DateUtil.stringPatchingEndToDateTime(orderDTO.getEndTime()));
|
|
|
+ order.setStartTime(org.apache.commons.lang3.ObjectUtils.isEmpty(orderDTO.getStartTime()) ?
|
|
|
+ null : orderDTO.getStartTime());
|
|
|
+ order.setEndTime(org.apache.commons.lang3.ObjectUtils.isEmpty(orderDTO.getEndTime()) ?
|
|
|
+ null : orderDTO.getEndTime());
|
|
|
BigDecimal decimal = new BigDecimal(NumberConstant.ZERO);
|
|
|
order.setSubcontractAmount(decimal);
|
|
|
order.setEntrustAmount(decimal);
|