|
|
@@ -3,9 +3,11 @@ package com.sckw.transport.service;
|
|
|
import cn.hutool.core.util.ArrayUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.sckw.core.common.enums.NumberConstant;
|
|
|
import com.sckw.core.common.enums.enums.DictTypeEnum;
|
|
|
+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.CollectionUtils;
|
|
|
@@ -32,6 +34,7 @@ import com.sckw.transport.model.dto.LogisticsOrderDTO;
|
|
|
import com.sckw.transport.model.dto.OrderCarDTO;
|
|
|
import com.sckw.transport.model.dto.OrderFinishDTO;
|
|
|
import com.sckw.transport.model.param.LogisticsConsignmentParam;
|
|
|
+import com.sckw.transport.model.vo.OrderFinishVO;
|
|
|
import jakarta.annotation.Resource;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.dubbo.config.annotation.DubboReference;
|
|
|
@@ -670,7 +673,7 @@ public class LogisticsConsignmentService {
|
|
|
*/
|
|
|
KwtLogisticsOrder kwtLogisticsOrder = kwtLogisticsOrderMapper.selectOne(new LambdaUpdateWrapper<KwtLogisticsOrder>()
|
|
|
.eq(KwtLogisticsOrder::getId, s));
|
|
|
- if (kwtLogisticsOrder == null || (!String.valueOf(LogisticsOrderEnum.PENDING_ORDER.getCode()).equals(kwtLogisticsOrder.getStatus()))) {
|
|
|
+ if (kwtLogisticsOrder == null || (!LogisticsOrderEnum.PENDING_ORDER.getStatus().equals(String.valueOf(kwtLogisticsOrder.getStatus())))) {
|
|
|
log.info("物流订单单据id:{}", s);
|
|
|
jsonObject.put("message", "单据状态异常或单据不存在");
|
|
|
jsonObject.put("status", HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
@@ -715,7 +718,7 @@ public class LogisticsConsignmentService {
|
|
|
} else {
|
|
|
throw new RuntimeException("完结订单-单据类型异常!");
|
|
|
}
|
|
|
- return null;
|
|
|
+ return HttpResult.ok("完结订单-成功");
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -725,9 +728,65 @@ public class LogisticsConsignmentService {
|
|
|
*/
|
|
|
private void sellOrderFinish(OrderFinishDTO orderFinishDTO) {
|
|
|
/** 订单完结 物流运单状态为【待派车】、【运输中】可操作*/
|
|
|
- /**完结拦截 必须车辆运单无正在运输中的单据才能完结*/
|
|
|
- /**完结订单 不做页面填写数量与数据库数量进行计算验证*/
|
|
|
-
|
|
|
+ /**完结拦截 必须车辆运单无正在运输中的单据才能完结 状态有 待接单之后已核弹之前的状态 都不能完结*/
|
|
|
+ /**完结订单 不做页面填写数量与数据库数量进行计算验证-直接获取页面填写数据进行保存处理*/
|
|
|
+ //物流订单id
|
|
|
+ String id = orderFinishDTO.getId();
|
|
|
+ KwtLogisticsOrder logisticsOrder = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .eq(KwtLogisticsOrder::getId, id));
|
|
|
+ if (logisticsOrder == null) {
|
|
|
+ throw new RuntimeException("采购订单-完结订单-物流单据不存在!");
|
|
|
+ }
|
|
|
+ /**订单状态验证*/
|
|
|
+ if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
|
|
|
+ && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
|
|
|
+ throw new RuntimeException("当前运单并不属于【待派车】,【运输中】状态");
|
|
|
+ }
|
|
|
+ /**完结拦截*/
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(CarWaybillEnum.PENDING_VEHICLE.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.EXIT_COMPLETED.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.WAIT_LOADING.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
|
|
|
+ int count = waybillOrderMapper.selectDataByLorderId(id, statusList);
|
|
|
+ if (count > NumberConstant.ZERO) {
|
|
|
+ throw new RuntimeException("检测您现在有运单正在执行中,该订单目前不可完结,请先将运单执行完毕");
|
|
|
+ }
|
|
|
+ /**单据完结修改状态以及数据*/
|
|
|
+ logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());
|
|
|
+ logisticsOrder.setLoadAmount(orderFinishDTO.getLoadAmount());
|
|
|
+ logisticsOrder.setUnloadAmount(orderFinishDTO.getUnloadAmount());
|
|
|
+ logisticsOrder.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ logisticsOrder.setUpdateTime(new Date());
|
|
|
+ logisticsOrder.setRemark(orderFinishDTO.getRemark());
|
|
|
+ kwtLogisticsOrderMapper.updateById(logisticsOrder);
|
|
|
+ KwtLogisticsOrderTrack track = new KwtLogisticsOrderTrack();
|
|
|
+ track.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ track.setLOrderId(logisticsOrder.getId());
|
|
|
+ track.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());
|
|
|
+ track.setCreateTime(new Date());
|
|
|
+ track.setRemark(orderFinishDTO.getRemark());
|
|
|
+ track.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ track.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ track.setUpdateTime(new Date());
|
|
|
+ kwtLogisticsOrderTrackMapper.insert(track);
|
|
|
+ /**单据完结修改Mongodb*/
|
|
|
+ SckwLogisticsOrder updateParam = new SckwLogisticsOrder();
|
|
|
+ updateParam.setLOrderId(Long.parseLong(id))
|
|
|
+ .setStatus(LogisticsOrderEnum.HAVE_FINISHED.getStatus())
|
|
|
+ .setUpdateBy(LoginUserHolder.getUserId())
|
|
|
+ .setUpdateByName(LoginUserHolder.getUserName())
|
|
|
+ .setUpdateTime(new Date())
|
|
|
+ .setLoadAmount(orderFinishDTO.getLoadAmount())
|
|
|
+ .setUnloadAmount(orderFinishDTO.getUnloadAmount())
|
|
|
+ ;
|
|
|
+ SckwBusSum busSum = new SckwBusSum();
|
|
|
+ busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
+ busSum.setMethod(2);
|
|
|
+ busSum.setObject(updateParam);
|
|
|
+ streamBridge.send("sckw-busSum", com.alibaba.fastjson2.JSON.toJSONString(busSum));
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -736,6 +795,99 @@ public class LogisticsConsignmentService {
|
|
|
* @param orderFinishDTO
|
|
|
*/
|
|
|
private void purchaseOrderFinish(OrderFinishDTO orderFinishDTO) {
|
|
|
+ /** 订单完结 物流运单状态为【待派车】、【运输中】可操作*/
|
|
|
+ /**完结拦截 必须车辆运单无正在运输中的单据才能完结 状态有 待接单之后已核弹之前的状态 都不能完结*/
|
|
|
+ /**完结订单 不做页面填写数量与数据库数量进行计算验证-直接获取页面填写数据进行保存处理*/
|
|
|
+ //物流订单id
|
|
|
+ String id = orderFinishDTO.getId();
|
|
|
+ KwtLogisticsOrder logisticsOrder = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .eq(KwtLogisticsOrder::getId, id));
|
|
|
+ if (logisticsOrder == null) {
|
|
|
+ throw new RuntimeException("采购订单-完结订单-物流单据不存在!");
|
|
|
+ }
|
|
|
+ /**订单状态验证*/
|
|
|
+ if (!LogisticsOrderEnum.WAIT_DELIVERY.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))
|
|
|
+ && !LogisticsOrderEnum.IN_TRANSIT.getStatus().equals(String.valueOf(logisticsOrder.getStatus()))) {
|
|
|
+ throw new RuntimeException("当前运单并不属于【待派车】,【运输中】状态");
|
|
|
+ }
|
|
|
+ /**完结拦截*/
|
|
|
+ List<Integer> statusList = new ArrayList<>();
|
|
|
+ statusList.add(CarWaybillEnum.PENDING_VEHICLE.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.EXIT_COMPLETED.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.WAIT_LOADING.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.COMPLETION_LOADING.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.WAIT_UNLOADING.getCode());
|
|
|
+ statusList.add(CarWaybillEnum.COMPLETION_UNLOADING.getCode());
|
|
|
+ int count = waybillOrderMapper.selectDataByLorderId(id, statusList);
|
|
|
+ if (count > NumberConstant.ZERO) {
|
|
|
+ throw new RuntimeException("检测您现在有运单正在执行中,该订单目前不可完结,请先将运单执行完毕");
|
|
|
+ }
|
|
|
+ /**单据完结修改状态以及数据*/
|
|
|
+ logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());
|
|
|
+ logisticsOrder.setLoadAmount(orderFinishDTO.getLoadAmount());
|
|
|
+ logisticsOrder.setUnloadAmount(orderFinishDTO.getUnloadAmount());
|
|
|
+ logisticsOrder.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ logisticsOrder.setUpdateTime(new Date());
|
|
|
+ logisticsOrder.setRemark(orderFinishDTO.getRemark());
|
|
|
+ kwtLogisticsOrderMapper.updateById(logisticsOrder);
|
|
|
+ KwtLogisticsOrderTrack track = new KwtLogisticsOrderTrack();
|
|
|
+ track.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
+ track.setLOrderId(logisticsOrder.getId());
|
|
|
+ track.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());
|
|
|
+ track.setCreateTime(new Date());
|
|
|
+ track.setRemark(orderFinishDTO.getRemark());
|
|
|
+ track.setCreateBy(LoginUserHolder.getUserId());
|
|
|
+ track.setUpdateBy(LoginUserHolder.getUserId());
|
|
|
+ track.setUpdateTime(new Date());
|
|
|
+ kwtLogisticsOrderTrackMapper.insert(track);
|
|
|
+ /**单据完结修改Mongodb*/
|
|
|
+ SckwLogisticsOrder updateParam = new SckwLogisticsOrder();
|
|
|
+ updateParam.setLOrderId(Long.parseLong(id))
|
|
|
+ .setStatus(LogisticsOrderEnum.HAVE_FINISHED.getStatus())
|
|
|
+ .setUpdateBy(LoginUserHolder.getUserId())
|
|
|
+ .setUpdateByName(LoginUserHolder.getUserName())
|
|
|
+ .setUpdateTime(new Date())
|
|
|
+ .setLoadAmount(orderFinishDTO.getLoadAmount())
|
|
|
+ .setUnloadAmount(orderFinishDTO.getUnloadAmount())
|
|
|
+ ;
|
|
|
+ SckwBusSum busSum = new SckwBusSum();
|
|
|
+ busSum.setBusSumType(BusinessTypeEnum.LOGISTICS_ORDER_TYPE.getName());
|
|
|
+ busSum.setMethod(2);
|
|
|
+ busSum.setObject(updateParam);
|
|
|
+ streamBridge.send("sckw-busSum", com.alibaba.fastjson2.JSON.toJSONString(busSum));
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 采购订单/销售订单-托运订单列表-订单完结-数据查询
|
|
|
+ *
|
|
|
+ * @param orderId 物流订单id
|
|
|
+ * @param type 1采购订单2销售订单
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public HttpResult selectOrderFinishVo(String orderId, String type) {
|
|
|
+ HttpResult httpResult = new HttpResult();
|
|
|
+ httpResult.setCode(HttpStatus.SUCCESS_CODE);
|
|
|
+ if (String.valueOf(NumberConstant.ONE).equals(type)) {
|
|
|
+ httpResult = selectOrderFinishData(orderId);
|
|
|
+ } else if (String.valueOf(NumberConstant.TWO).equals(type)) {
|
|
|
+ httpResult = selectOrderFinishData(orderId);
|
|
|
+ } else {
|
|
|
+ httpResult.setCode(HttpStatus.SUCCESS_CODE);
|
|
|
+ httpResult.setMsg("订单完结查询,类型错误!");
|
|
|
+ }
|
|
|
+ return httpResult;
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 采购订单/销售订单-托运订单列表-订单完结-数据查询
|
|
|
+ *
|
|
|
+ * @param orderId 物流订单id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ private HttpResult selectOrderFinishData(String orderId) {
|
|
|
+ HttpResult httpResult = new HttpResult();
|
|
|
+ OrderFinishVO orderFinishVO = kwtLogisticsOrderMapper.selectOrderFinishData(orderId);
|
|
|
+ httpResult.setData(orderFinishVO);
|
|
|
+ return httpResult;
|
|
|
}
|
|
|
}
|