|
|
@@ -596,18 +596,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if ("1".equals(goodsDesc.getWhether()) && ObjectUtils.isNull(item.getDot())) {
|
|
|
throw new RuntimeException("商品:" + goodsDesc.getCname() + ",请求选择批次号");
|
|
|
}
|
|
|
-
|
|
|
- PjOrderItems orderItems = pjOrderItems.stream().filter(e -> e.getId().equals(item.getSrcItemId())).findFirst().orElse(null);
|
|
|
- if (orderItems != null) {
|
|
|
- if (orderItems.getGoodsNum().compareTo(orderItems.getSendNum().add(item.getSendNum())) < 0) {
|
|
|
- throw new RuntimeException(orderItems.getGoodsName() + "剩余应发货数量" + orderItems.getGoodsNum().subtract(orderItems.getSendNum()));
|
|
|
- } else {
|
|
|
- orderItems.setSendNum(orderItems.getSendNum().add(item.getSendNum()));
|
|
|
- }
|
|
|
- pjOrderItemsList.add(orderItems);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("数据异常请联系管理员");
|
|
|
- }
|
|
|
//管理批次号
|
|
|
PjStockDesc stockOne = null;
|
|
|
if (ObjectUtil.isNotEmpty(goodsDesc.getWhether()) && "1".equals(goodsDesc.getWhether())) {
|
|
|
@@ -637,6 +625,21 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
System.err.println("商品:" + goodsDesc.getCname());
|
|
|
throw new RuntimeException("商品:" + goodsDesc.getCname() + "未查到库存账");
|
|
|
}
|
|
|
+ PjOrderItems orderItems = pjOrderItems.stream().filter(e -> e.getId().equals(item.getSrcItemId())).findFirst().orElse(null);
|
|
|
+ if (orderItems != null) {
|
|
|
+ if (ObjectUtils.isNull(orderItems.getCostprie()) || new BigDecimal("0.00").compareTo(orderItems.getCostprie()) == 0) {
|
|
|
+ orderItems.setCostprie(stockOne.getInventoryCostPrice().multiply(orderItems.getGoodsNum()));
|
|
|
+ orderItems.setGrossProfit(item.getSubTotalMoney().subtract(orderItems.getCostprie()));
|
|
|
+ }
|
|
|
+ if (orderItems.getGoodsNum().compareTo(orderItems.getSendNum().add(item.getSendNum())) < 0) {
|
|
|
+ throw new RuntimeException(orderItems.getGoodsName() + "剩余应发货数量" + orderItems.getGoodsNum().subtract(orderItems.getSendNum()));
|
|
|
+ } else {
|
|
|
+ orderItems.setSendNum(orderItems.getSendNum().add(item.getSendNum()));
|
|
|
+ }
|
|
|
+ pjOrderItemsList.add(orderItems);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("数据异常请联系管理员");
|
|
|
+ }
|
|
|
}
|
|
|
if (!msg.isEmpty()) {
|
|
|
throw new RuntimeException("商品:" + msg + "库存不足,出库失败");
|
|
|
@@ -714,6 +717,25 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
ship.setUpdateUser(AuthUtil.getUserId());
|
|
|
ship.setUpdateTime(new Date());
|
|
|
baseMapper.updateById(ship);
|
|
|
+ PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
+ if (ObjectUtil.isNotEmpty(order)) {
|
|
|
+ PjOrder order1 = orderMapper.selectOne(new LambdaQueryWrapper<PjOrder>()
|
|
|
+ .eq(PjOrder::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjOrder::getIsDeleted, 0)
|
|
|
+ .eq(PjOrder::getSrcNo, order.getOrdNo()));
|
|
|
+ if (order1 != null && "待入库,已完成".contains(order1.getStatus())) {
|
|
|
+ throw new RuntimeException("已生成销售退货单据,撤销失败");
|
|
|
+ }
|
|
|
+ if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
+ throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
+ }
|
|
|
+ order.setStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
+ order.setXcxStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
+ order.setDeliveryBusinesDate(null);
|
|
|
+ orderMapper.updateById(order);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("数据异常请联系管理员");
|
|
|
+ }
|
|
|
|
|
|
// 保存订单明细
|
|
|
if (CollectionUtils.isNotEmpty(ship.getShipItemsList())) {
|
|
|
@@ -733,6 +755,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
.eq(PjStockDesc::getStorageId, ship.getStorageId())
|
|
|
.in(PjStockDesc::getGoodsId, goodIds);
|
|
|
List<PjStockDesc> pjStockDescList = iStockDescService.list(lambdaQueryWrapper);
|
|
|
+ LambdaQueryWrapper<PjStockDesc> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
+ lambdaQueryWrapper1.eq(PjStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjStockDesc::getIsDeleted, 0)
|
|
|
+ .eq(PjStockDesc::getSalesCompanyId, ship.getSalesCompanyId())
|
|
|
+ .eq(PjStockDesc::getStorageId, order.getStorageId())
|
|
|
+ .in(PjStockDesc::getGoodsId, goodIds);
|
|
|
+ List<PjStockDesc> pjStockDescList1 = iStockDescService.list(lambdaQueryWrapper1);
|
|
|
List<Long> srcItemIds = ship.getShipItemsList().stream().map(PjShipItems::getSrcItemId).distinct().collect(Collectors.toList());
|
|
|
List<PjOrderItems> pjOrderItems = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
.eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
@@ -749,8 +778,28 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
BigDecimal number = new BigDecimal("0.00");
|
|
|
for (PjShipItems item : ship.getShipItemsList()) {
|
|
|
number = number.add(item.getSendNum());
|
|
|
+ //获得商品
|
|
|
+ PjGoodsDesc goodsDesc = pjGoodsDescList.stream().filter(e -> e.getId().equals(item.getGoodsId())).findFirst().orElse(null);
|
|
|
+ if (ObjectUtil.isEmpty(goodsDesc)) {
|
|
|
+ throw new RuntimeException("商品数据异常");
|
|
|
+ }
|
|
|
+ //管理批次号
|
|
|
+ PjStockDesc stockOne1 = null;
|
|
|
+ if (ObjectUtil.isNotEmpty(goodsDesc.getWhether()) && "1".equals(goodsDesc.getWhether())) {
|
|
|
+ stockOne1 = pjStockDescList1.stream()
|
|
|
+ .filter(e -> e.getGoodsId().equals(item.getGoodsId())
|
|
|
+ && e.getDot().equals(item.getDot())).findFirst().orElse(null);
|
|
|
+ } else {
|
|
|
+ stockOne1 = pjStockDescList1.stream()
|
|
|
+ .filter(e -> e.getGoodsId().equals(item.getGoodsId())
|
|
|
+ && ObjectUtils.isNull(e.getDot())).findFirst().orElse(null);
|
|
|
+ }
|
|
|
PjOrderItems orderItems = pjOrderItems.stream().filter(e -> e.getId().equals(item.getSrcItemId())).findFirst().orElse(null);
|
|
|
if (orderItems != null) {
|
|
|
+ if (stockOne1 == null) {
|
|
|
+ orderItems.setCostprie(new BigDecimal("0.00"));
|
|
|
+ orderItems.setGrossProfit(new BigDecimal("0.00"));
|
|
|
+ }
|
|
|
orderItems.setSendNum(orderItems.getSendNum().subtract(item.getSendNum()));
|
|
|
pjOrderItemsList.add(orderItems);
|
|
|
} else {
|
|
|
@@ -760,11 +809,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if (!pjOrderItemsList1.isEmpty()) {
|
|
|
msg1.append(item.getGoodsName()).append(",");
|
|
|
}
|
|
|
- //获得商品
|
|
|
- PjGoodsDesc goodsDesc = pjGoodsDescList.stream().filter(e -> e.getId().equals(item.getGoodsId())).findFirst().orElse(null);
|
|
|
- if (ObjectUtil.isEmpty(goodsDesc)) {
|
|
|
- throw new RuntimeException("商品数据异常");
|
|
|
- }
|
|
|
//管理批次号
|
|
|
PjStockDesc stockOne = null;
|
|
|
if (ObjectUtil.isNotEmpty(goodsDesc.getWhether()) && "1".equals(goodsDesc.getWhether())) {
|
|
|
@@ -817,19 +861,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
baseMapper.updateById(rwShip);
|
|
|
}
|
|
|
}
|
|
|
- PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
- if (ObjectUtil.isNotEmpty(order)) {
|
|
|
- if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
- throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
- }
|
|
|
- order.setStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
- order.setXcxStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
- order.setDeliveryBusinesDate(null);
|
|
|
- orderMapper.updateById(order);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("数据异常请联系管理员");
|
|
|
- }
|
|
|
-
|
|
|
//生成出库工单历史记录
|
|
|
saveHistory(ship.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
|
|
|
|
@@ -1189,9 +1220,9 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
.filter(i -> i.getGoodsId().equals(goodsDesc.getId())).findFirst().orElse(null);
|
|
|
//修改上架数量
|
|
|
if (pjProductLaunches != null) {
|
|
|
- if (ObjectUtils.isNotNull(pjProductLaunches.getInventory())){
|
|
|
+ if (ObjectUtils.isNotNull(pjProductLaunches.getInventory())) {
|
|
|
pjProductLaunches.setInventory(pjProductLaunches.getInventory().add(item.getSendNum()));
|
|
|
- }else{
|
|
|
+ } else {
|
|
|
pjProductLaunches.setInventory(item.getSendNum());
|
|
|
}
|
|
|
pjProductLaunchList.add(pjProductLaunches);
|
|
|
@@ -1610,6 +1641,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
if (ObjectUtil.isNotEmpty(order)) {
|
|
|
+ PjOrder order1 = orderMapper.selectOne(new LambdaQueryWrapper<PjOrder>()
|
|
|
+ .eq(PjOrder::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjOrder::getIsDeleted, 0)
|
|
|
+ .eq(PjOrder::getSrcNo, order.getOrdNo()));
|
|
|
+ if (order1 != null && "待出库,已完成".contains(order1.getStatus())) {
|
|
|
+ throw new RuntimeException("已生成采购退货单据,撤销失败");
|
|
|
+ }
|
|
|
order.setStatus(OrderTypeEnum.GOODSRECEIVED.getType());
|
|
|
order.setXcxStatus(OrderTypeEnum.GOODSRECEIVED.getType());
|
|
|
order.setDeliveryBusinesDate(null);
|
|
|
@@ -1985,6 +2023,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R outboundWorkOrderReturns(String ids) {
|
|
|
List<Long> shipIds = Func.toLongList(ids);
|
|
|
List<PjShip> pjShipList = baseMapper.selectList(new LambdaQueryWrapper<PjShip>()
|
|
|
@@ -1998,7 +2038,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
pjOrderItemsList = orderItemsService.list(new QueryWrapper<PjOrderItems>()
|
|
|
.in("pid", ordIds)
|
|
|
.eq("is_deleted", 0)
|
|
|
- .apply("goods_num != send_num")
|
|
|
+ .apply("returns_number != send_num")
|
|
|
.eq("tenant_id", AuthUtil.getTenantId()));
|
|
|
}
|
|
|
List<OrderRecord> orderRecordList = new ArrayList<>();
|
|
|
@@ -2075,6 +2115,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
}
|
|
|
item.setNumberRows(list.size());
|
|
|
+ item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
}
|
|
|
|
|
|
//修改出库任务状态
|
|
|
@@ -2142,11 +2183,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
this.saveOrUpdateBatch(rwShipList);
|
|
|
shipItemsService.saveOrUpdateBatch(shipItemsList);
|
|
|
-
|
|
|
+ this.saveOrUpdateBatch(pjShips);
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R outboundCompletedReturns(PjShip ship) {
|
|
|
ship.setStatusName(OrderTypeEnum.OURTBOUND.getType());
|
|
|
if (ObjectUtils.isNull(ship.getStorageId())) {
|
|
|
@@ -2341,7 +2384,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
.eq(PjOrderItems::getPid, ship.getOrdId());
|
|
|
List<PjOrderItems> itemsList = orderItemsService.list(itemsLambdaQueryWrapper);
|
|
|
//数量和
|
|
|
- BigDecimal goodsNum = itemsList.stream().map(PjOrderItems::getGoodsNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal goodsNum = itemsList.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//发货数量和
|
|
|
BigDecimal sendNum = itemsList.stream().map(PjOrderItems::getSendNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
@@ -2376,6 +2419,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R revokeOutboundCompletedReturns(PjShip ship) {
|
|
|
ship.setStatusName(OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
|
ship.setUpdateUser(AuthUtil.getUserId());
|
|
|
@@ -2538,6 +2583,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R generateWarehousingReturns(String ids) {
|
|
|
List<Long> shipIds = Func.toLongList(ids);
|
|
|
List<PjShip> pjShipList = baseMapper.selectList(new LambdaQueryWrapper<PjShip>()
|
|
|
@@ -2551,7 +2598,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
pjOrderItemsList = orderItemsService.list(new QueryWrapper<PjOrderItems>()
|
|
|
.in("pid", ordIds)
|
|
|
.eq("is_deleted", 0)
|
|
|
- .apply("goods_num != send_num")
|
|
|
+ .apply("returns_number != send_num")
|
|
|
.eq("tenant_id", AuthUtil.getTenantId()));
|
|
|
}
|
|
|
List<OrderRecord> orderRecordList = new ArrayList<>();
|
|
|
@@ -2621,6 +2668,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
shipItemsList.add(shipItems);
|
|
|
}
|
|
|
item.setNumberRows(list.size());
|
|
|
+ item.setSendTotalNum(list.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO,BigDecimal::add));
|
|
|
}
|
|
|
|
|
|
//修改入库任务状态
|
|
|
@@ -2688,10 +2736,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
this.saveOrUpdateBatch(rwShipList);
|
|
|
shipItemsService.saveOrUpdateBatch(shipItemsList);
|
|
|
+ this.saveOrUpdateBatch(pjShips);
|
|
|
return R.success("操作成功");
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R warehousingCompleteReturns(PjShip ship) {
|
|
|
if (ship.getId() == null) {
|
|
|
// 获取系统编号
|
|
|
@@ -2845,7 +2896,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
stockDesc.setUpdateUser(AuthUtil.getUserId());
|
|
|
stockDesc.setBalanceQuantity(stockOne.getBalanceQuantity().add(item.getSendNum()));
|
|
|
stockDesc.setStoreInventory(stockDesc.getBalanceQuantity());
|
|
|
- stockDesc.setInventoryAmount(item.getSendNum().multiply(item.getPrice()));
|
|
|
+ stockDesc.setInventoryAmount(item.getCostprie());
|
|
|
stockDesc.setInventoryAmount(stockDesc.getInventoryAmount().add(stockOne.getInventoryAmount()));
|
|
|
if (stockDesc.getBalanceQuantity().compareTo(new BigDecimal("0")) != 0) {
|
|
|
stockDesc.setInventoryCostPrice(stockDesc.getInventoryAmount().divide(stockDesc.getBalanceQuantity(), MathContext.DECIMAL32).setScale(2, RoundingMode.HALF_UP));
|
|
|
@@ -2927,7 +2978,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
.eq(PjOrderItems::getPid, ship.getOrdId());
|
|
|
List<PjOrderItems> itemsList = orderItemsService.list(itemsLambdaQueryWrapper);
|
|
|
//数量和
|
|
|
- BigDecimal goodsNum = itemsList.stream().map(PjOrderItems::getGoodsNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal goodsNum = itemsList.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//发货数量和
|
|
|
BigDecimal sendNum = itemsList.stream().map(PjOrderItems::getSendNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
@@ -2957,6 +3008,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R revokeWarehousingReturns(PjShip ship) {
|
|
|
// 保存订单明细
|
|
|
BigDecimal number = new BigDecimal("0.00");
|
|
|
@@ -3128,6 +3181,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @GlobalTransactional(rollbackFor = Exception.class, timeoutMills = 12000000)
|
|
|
public R revokeWorkOrderReturns(String ids) {
|
|
|
List<Long> shipIds = Func.toLongList(ids);
|
|
|
for (Long id : shipIds) {
|