|
|
@@ -23,6 +23,7 @@ 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;
|
|
|
@@ -34,7 +35,8 @@ import com.sckw.product.api.dubbo.GoodsInfoService;
|
|
|
import com.sckw.product.api.model.KwpGoods;
|
|
|
import com.sckw.stream.model.SckwBusSum;
|
|
|
import com.sckw.system.api.RemoteSystemService;
|
|
|
-import com.sckw.system.api.model.dto.res.SysDictResDto;
|
|
|
+import com.sckw.system.api.RemoteUserService;
|
|
|
+import com.sckw.system.api.model.dto.res.*;
|
|
|
import com.sckw.transport.dao.*;
|
|
|
import com.sckw.transport.model.*;
|
|
|
import com.sckw.transport.model.dto.OrderFinishDTO;
|
|
|
@@ -81,6 +83,9 @@ public class AcceptCarriageOrderService {
|
|
|
@DubboReference(version = "2.0.0", group = "design", check = false, timeout = 6000)
|
|
|
RemoteContractService remoteContractService;
|
|
|
|
|
|
+ @DubboReference(version = "2.0.0", group = "design", check = false, timeout = 6000)
|
|
|
+ RemoteUserService remoteUserService;
|
|
|
+
|
|
|
@Resource
|
|
|
private StreamBridge streamBridge;
|
|
|
|
|
|
@@ -96,9 +101,6 @@ public class AcceptCarriageOrderService {
|
|
|
@Autowired
|
|
|
private KwtWaybillOrderTrackMapper waybillOrderTrackMapper;
|
|
|
|
|
|
- @Autowired
|
|
|
- private KwtWaybillOrderTicketMapper waybillOrderTicketMapper;
|
|
|
-
|
|
|
@Autowired
|
|
|
public KwtLogisticsOrderGoodsMapper kwtLogisticsOrderGoodsMapper;
|
|
|
|
|
|
@@ -155,6 +157,15 @@ public class AcceptCarriageOrderService {
|
|
|
log.error("订单id查找失败:{},订单编号:{}", bo.getOrderId(), bo.getLOrderNo());
|
|
|
throw new RuntimeException("单据错误,数据不存在");
|
|
|
}
|
|
|
+ //todo 校验当前登录角色是否具有4P物流角色
|
|
|
+ EntCacheResDto entCacheResDto = remoteSystemService.queryEntCacheById(LoginUserHolder.getEntId());
|
|
|
+ if (entCacheResDto == null) {
|
|
|
+ log.info("承运订单-分包托运 用户id:{}", LoginUserHolder.getUserId());
|
|
|
+ throw new RuntimeException("企业信息查询异常");
|
|
|
+ }
|
|
|
+ if (!entCacheResDto.getEntTypes().contains(String.valueOf(NumberConstant.THREE))) {
|
|
|
+ throw new RuntimeException("当前用户企业不具有分包功能权限!");
|
|
|
+ }
|
|
|
KwtLogisticsOrder order = new KwtLogisticsOrder();
|
|
|
if (!bo.getIsFullDose()) {
|
|
|
Long amount = bo.getAmount();
|
|
|
@@ -218,14 +229,14 @@ public class AcceptCarriageOrderService {
|
|
|
throw new RuntimeException("生成物流托运合同异常");
|
|
|
}
|
|
|
insertSubcontractLogisticsGoods(bo, lOrderNo, orderId);
|
|
|
- insertSubcontractLogisticsOrder(bo, lOrderNo, order, orderId, pids,orderStatus);
|
|
|
+ insertSubcontractLogisticsOrder(bo, lOrderNo, order, orderId, pids, orderStatus);
|
|
|
insertSubcontractLogisticsOrderContract(bo, orderId);
|
|
|
insertSubcontractLogisticsOrderUnit(bo, orderId);
|
|
|
insertSubcontractLogisticsOrderAddress(bo, orderId, logisticsOrder);
|
|
|
- insertLogisticsOrderTrack(bo, orderId,orderStatus);
|
|
|
+ insertLogisticsOrderTrack(bo, orderId, orderStatus);
|
|
|
//修改上级分配量以及可分配量委托量等
|
|
|
logisticsOrder.setSubcontractAmount(logisticsOrder.getSubcontractAmount().add(new BigDecimal(bo.getCarryingCapacity())));
|
|
|
- subcontractSendMongoDB(lOrderNo, orderId, bo, logisticsOrder,orderStatus);
|
|
|
+ subcontractSendMongoDB(lOrderNo, orderId, bo, logisticsOrder, orderStatus);
|
|
|
return HttpResult.ok();
|
|
|
}
|
|
|
|
|
|
@@ -237,7 +248,7 @@ public class AcceptCarriageOrderService {
|
|
|
* @param bo 页面传输实体
|
|
|
* @param kwtLogisticsOrder 物流订单数据(上一级)
|
|
|
*/
|
|
|
- private void subcontractSendMongoDB(String lOrderNo, Long orderId, SubcontractConsignmentDTO bo, KwtLogisticsOrder kwtLogisticsOrder,Integer orderStatus) {
|
|
|
+ private void subcontractSendMongoDB(String lOrderNo, Long orderId, SubcontractConsignmentDTO bo, KwtLogisticsOrder kwtLogisticsOrder, Integer orderStatus) {
|
|
|
SckwLogisticsOrder logisticsOrder = new SckwLogisticsOrder();
|
|
|
logisticsOrder.setStatus(String.valueOf(orderStatus));
|
|
|
logisticsOrder.setLOrderId(orderId);
|
|
|
@@ -344,7 +355,7 @@ public class AcceptCarriageOrderService {
|
|
|
* @param bo
|
|
|
* @param orderId
|
|
|
*/
|
|
|
- private void insertLogisticsOrderTrack(SubcontractConsignmentDTO bo, Long orderId,Integer orderStatus) {
|
|
|
+ private void insertLogisticsOrderTrack(SubcontractConsignmentDTO bo, Long orderId, Integer orderStatus) {
|
|
|
KwtLogisticsOrderTrack entity = new KwtLogisticsOrderTrack();
|
|
|
entity.setId(new IdWorker(NumberConstant.ONE).nextId());
|
|
|
entity.setLOrderId(orderId);
|
|
|
@@ -478,7 +489,7 @@ public class AcceptCarriageOrderService {
|
|
|
*/
|
|
|
private void insertSubcontractLogisticsOrder(SubcontractConsignmentDTO bo, String lOrderNo,
|
|
|
KwtLogisticsOrder order,
|
|
|
- Long orderId, String pids,Integer orderStatus) {
|
|
|
+ Long orderId, String pids, Integer orderStatus) {
|
|
|
order.setId(orderId);
|
|
|
order.setEntId(LoginUserHolder.getEntId());
|
|
|
order.setTOrderId(order.getTOrderId());
|
|
|
@@ -746,8 +757,9 @@ public class AcceptCarriageOrderService {
|
|
|
*/
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public HttpResult stopDocumentCommit(StopOrderTakingDTO stopOrderTakingDTO) {
|
|
|
- List<Long> wOrderIds = logisticsOrderCirculateMapper.selectEntityBylOrderIdAndOrderIds(stopOrderTakingDTO.getLOrderId(), stopOrderTakingDTO.getIds());
|
|
|
- List<JSONObject> list = new ArrayList<>(stopOrderTakingDTO.getIds().size());
|
|
|
+ List<String> stringList = StringUtils.splitStrToList(stopOrderTakingDTO.getIds(), ",", String.class);
|
|
|
+ List<Long> wOrderIds = logisticsOrderCirculateMapper.selectEntityBylOrderIdAndOrderIds(stopOrderTakingDTO.getLOrderId(), stringList);
|
|
|
+ List<JSONObject> list = new ArrayList<>(stringList.size());
|
|
|
if (CollectionUtils.isNotEmpty(wOrderIds)) {
|
|
|
wOrderIds.forEach(wOrderId -> {
|
|
|
JSONObject jsonObject = new JSONObject();
|
|
|
@@ -782,7 +794,7 @@ public class AcceptCarriageOrderService {
|
|
|
for (String id : ids) {
|
|
|
result.put("id", id);
|
|
|
KwtWaybillOrder waybillOrder = waybillOrderMapper.selectOne(new LambdaUpdateWrapper<KwtWaybillOrder>()
|
|
|
- .eq(KwtWaybillOrder::getId, id).eq(KwtWaybillOrder::getType, NumberConstant.ONE));
|
|
|
+ .eq(KwtWaybillOrder::getId, Long.parseLong(id)).eq(KwtWaybillOrder::getType, NumberConstant.ONE));
|
|
|
if (waybillOrder == null) {
|
|
|
result.put("status", HttpStatus.GLOBAL_EXCEPTION_CODE);
|
|
|
result.put("message", "单据不存在");
|
|
|
@@ -806,7 +818,7 @@ public class AcceptCarriageOrderService {
|
|
|
.eq(KwtLogisticsOrder::getId, logisticsOrder.getId()));
|
|
|
waybillOrderMapper.update(null, new LambdaUpdateWrapper<KwtWaybillOrder>()
|
|
|
.eq(KwtWaybillOrder::getType, NumberConstant.ONE)
|
|
|
- .eq(KwtWaybillOrder::getId, id)
|
|
|
+ .eq(KwtWaybillOrder::getId, Long.parseLong(id))
|
|
|
.set(KwtWaybillOrder::getStatus, CarWaybillEnum.REVOKED.getCode())
|
|
|
.set(KwtWaybillOrder::getUpdateBy, LoginUserHolder.getUserId())
|
|
|
.set(KwtWaybillOrder::getUpdateTime, new Date()));
|
|
|
@@ -904,8 +916,9 @@ public class AcceptCarriageOrderService {
|
|
|
|
|
|
/**
|
|
|
* 承运订单-分包托运-完结订单-修改本身数据
|
|
|
- * @param logisticsOrder 本身物流订单数据
|
|
|
- * @param orderFinishDTO 页面传递数据
|
|
|
+ *
|
|
|
+ * @param logisticsOrder 本身物流订单数据
|
|
|
+ * @param orderFinishDTO 页面传递数据
|
|
|
*/
|
|
|
private void updateDataByItself(KwtLogisticsOrder logisticsOrder, OrderFinishDTO orderFinishDTO) {
|
|
|
logisticsOrder.setStatus(LogisticsOrderEnum.HAVE_FINISHED.getCode());
|
|
|
@@ -944,8 +957,9 @@ public class AcceptCarriageOrderService {
|
|
|
|
|
|
/**
|
|
|
* 承运订单-分包托运-完结订单-修改分包订单
|
|
|
+ *
|
|
|
* @param orderFinishDTO
|
|
|
- * @param orderId 分包物流订单id
|
|
|
+ * @param orderId 分包物流订单id
|
|
|
*/
|
|
|
private void updateDataBySubset(OrderFinishDTO orderFinishDTO, String orderId) {
|
|
|
KwtLogisticsOrder kwtLogisticsOrder = kwtLogisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
@@ -981,4 +995,92 @@ public class AcceptCarriageOrderService {
|
|
|
streamBridge.send("sckw-busSum", com.alibaba.fastjson2.JSON.toJSONString(busSum));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承运订单-获取撤销驳回原因
|
|
|
+ *
|
|
|
+ * @param id 物流订单id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public HttpResult getCancelReason(String id) {
|
|
|
+ KwtLogisticsOrderTrack track = logisticsOrderTrackMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderTrack>()
|
|
|
+ .eq(KwtLogisticsOrderTrack::getLOrderId, Long.parseLong(id))
|
|
|
+ .eq(KwtLogisticsOrderTrack::getStatus, LogisticsOrderEnum.SEND_BACK.getCode()));
|
|
|
+ return HttpResult.ok(track == null ? null : track.getRemark());
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 承运订单-分包托运-订单详情
|
|
|
+ *
|
|
|
+ * @param id 物流订单id
|
|
|
+ * @return
|
|
|
+ */
|
|
|
+ public HttpResult subcontractConsignmentOrderDetail(String id) {
|
|
|
+ KwtLogisticsOrder logisticsOrder = logisticsOrderMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrder>()
|
|
|
+ .eq(KwtLogisticsOrder::getId, Long.parseLong(id))
|
|
|
+ /**.eq(KwtLogisticsOrder::getEntId, LoginUserHolder.getEntId())*/);
|
|
|
+ if (logisticsOrder == null) {
|
|
|
+ log.info("查无单据 物流订单id:{}", id);
|
|
|
+ throw new RuntimeException("查无单据");
|
|
|
+ }
|
|
|
+ KwtLogisticsOrderContract contract = kwtLogisticsOrderContractMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderContract>()
|
|
|
+ .eq(StringUtils.isNotBlank(Long.parseLong(id)), KwtLogisticsOrderContract::getLOrderId, Long.parseLong(id)));
|
|
|
+ KwtLogisticsOrderUnit unitOne = logisticsOrderUnitMapper.selectOne(new LambdaQueryWrapper<KwtLogisticsOrderUnit>()
|
|
|
+ .eq(StringUtils.isNotBlank(Long.parseLong(id)), KwtLogisticsOrderUnit::getLOrderId, Long.parseLong(id))
|
|
|
+ .eq(KwtLogisticsOrderUnit::getUnitType, NumberConstant.ONE));
|
|
|
+ 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>()
|
|
|
+ .eq(StringUtils.isNotBlank(Long.parseLong(id)), KwtLogisticsOrderAddress::getLOrderId, Long.parseLong(id))
|
|
|
+ .eq(KwtLogisticsOrderAddress::getAddressType, NumberConstant.ONE));
|
|
|
+ KwtLogisticsOrderAddress unloadOrderAddress = logisticsOrderAddressMapper.selectOne(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>()
|
|
|
+ .eq(StringUtils.isNotBlank(logisticsOrder.getId()), KwtLogisticsOrderGoods::getLOrderId, logisticsOrder.getId()));
|
|
|
+ OrderDetailVO orderDetailVO = new OrderDetailVO();
|
|
|
+ orderDetailVO.setId(String.valueOf(logisticsOrder.getId()));
|
|
|
+ if (contract != null) {
|
|
|
+ orderDetailVO.setContractId(contract.getContractId() == null ? null : String.valueOf(contract.getContractId()));
|
|
|
+ //todo 接口调用合同服务查询合同信息
|
|
|
+ List<Long> list = new ArrayList<>(NumberConstant.SIXTEEN);
|
|
|
+ list.add(contract.getContractId());
|
|
|
+ Map<Long, ContractCommonInfoResDto> contractBaseInfo = remoteContractService.queryContractBaseInfo(list);
|
|
|
+ if (CollectionUtils.isNotEmpty(contractBaseInfo) && !ObjectUtils.isEmpty(contractBaseInfo.get(contract.getContractId()))) {
|
|
|
+ orderDetailVO.setContractName(contractBaseInfo.get(contract.getContractId()).getContactName());
|
|
|
+ orderDetailVO.setContractNo(contractBaseInfo.get(contract.getContractId()).getContractCode());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (unitOne != null) {
|
|
|
+ orderDetailVO.setConsignCompany(unitOne.getFirmName());
|
|
|
+ orderDetailVO.setConsignContacts(unitOne.getContacts());
|
|
|
+ orderDetailVO.setConsignPhone(unitOne.getPhone());
|
|
|
+ orderDetailVO.setCollectionCompany(unitOne.getFirmName());
|
|
|
+ }
|
|
|
+ if (unitTwo != null) {
|
|
|
+ orderDetailVO.setCarrierCompany(unitTwo.getFirmName());
|
|
|
+ orderDetailVO.setCarrierContacts(unitTwo.getContacts());
|
|
|
+ orderDetailVO.setCarrierPhone(unitTwo.getPhone());
|
|
|
+ }
|
|
|
+ orderDetailVO.setGoodsName(orderGoods == null ? null : orderGoods.getGoodsName());
|
|
|
+ orderDetailVO.setNumber(logisticsOrder.getAmount() == null ? null : String.valueOf(logisticsOrder.getAmount()));
|
|
|
+ orderDetailVO.setPrice(logisticsOrder.getPrice() == null ? null : String.valueOf(logisticsOrder.getPrice()));
|
|
|
+ orderDetailVO.setLoss(logisticsOrder.getLoss() == null ? null : String.valueOf(logisticsOrder.getLoss()));
|
|
|
+ orderDetailVO.setDeduct(logisticsOrder.getGoodsPrice() == null ? null : String.valueOf(logisticsOrder.getGoodsPrice()));
|
|
|
+ orderDetailVO.setLoadAddress(loadOrderAddress.getName());
|
|
|
+ orderDetailVO.setLoadContacts(loadOrderAddress.getContacts());
|
|
|
+ orderDetailVO.setLoadPhone(loadOrderAddress.getPhone());
|
|
|
+ orderDetailVO.setLoadAddressDetail(loadOrderAddress.getDetailAddress());
|
|
|
+ orderDetailVO.setUnloadAddress(unloadOrderAddress.getName());
|
|
|
+ orderDetailVO.setUnloadContacts(unloadOrderAddress.getContacts());
|
|
|
+ orderDetailVO.setUnloadPhone(unloadOrderAddress.getPhone());
|
|
|
+ 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.setPerformanceAmount(logisticsOrder.getLoadAmount() == null ? null : String.valueOf(logisticsOrder.getLoadAmount()));
|
|
|
+ return HttpResult.ok(orderDetailVO);
|
|
|
+ }
|
|
|
}
|