|
|
@@ -15,7 +15,6 @@ import com.gubersail.admin.order.service.IOrderItemsService;
|
|
|
import com.gubersail.admin.order.service.IOrderRecordService;
|
|
|
import com.gubersail.admin.productLaunch.service.IProductLaunchService;
|
|
|
import com.gubersail.admin.ship.mapper.ShipMapper;
|
|
|
-import com.gubersail.admin.ship.service.IShipItemsRecordService;
|
|
|
import com.gubersail.admin.ship.service.IShipItemsService;
|
|
|
import com.gubersail.admin.ship.service.IShipService;
|
|
|
import com.gubersail.admin.stock.service.ITireStockDescService;
|
|
|
@@ -32,12 +31,10 @@ import com.gubersail.dealer.admin.api.history.entity.PjHistory;
|
|
|
import com.gubersail.dealer.admin.api.order.entity.OrderRecord;
|
|
|
import com.gubersail.dealer.admin.api.order.entity.PjOrder;
|
|
|
import com.gubersail.dealer.admin.api.order.entity.PjOrderItems;
|
|
|
-import com.gubersail.dealer.admin.api.order.vo.OrderVO;
|
|
|
import com.gubersail.dealer.admin.api.productLaunch.entity.PjProductLaunch;
|
|
|
import com.gubersail.dealer.admin.api.ship.dto.ShipItemsDTO;
|
|
|
import com.gubersail.dealer.admin.api.ship.entity.PjShip;
|
|
|
import com.gubersail.dealer.admin.api.ship.entity.PjShipItems;
|
|
|
-import com.gubersail.dealer.admin.api.ship.entity.ShipItemsRecord;
|
|
|
import com.gubersail.dealer.admin.api.ship.vo.ShipVO;
|
|
|
import com.gubersail.dealer.admin.api.stock.entity.TireStockDesc;
|
|
|
import com.gubersail.dealer.admin.api.storage.entity.PjStorageDesc;
|
|
|
@@ -60,8 +57,6 @@ import org.springframework.transaction.interceptor.TransactionAspectSupport;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.MathContext;
|
|
|
import java.math.RoundingMode;
|
|
|
-import java.time.LocalDateTime;
|
|
|
-import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@@ -95,13 +90,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
private final IUserClient userClient;
|
|
|
private final StorageDescMapper storageDescMapper;
|
|
|
|
|
|
- private final IShipItemsRecordService shipItemsRecordService;
|
|
|
-
|
|
|
/**
|
|
|
* 获取收发货订单详情
|
|
|
- *
|
|
|
- * @param ship
|
|
|
- * @return
|
|
|
*/
|
|
|
@Override
|
|
|
public ShipVO getMessageById(PjShip ship) {
|
|
|
@@ -139,9 +129,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
|
|
|
/**
|
|
|
* 保存订单信息
|
|
|
- *
|
|
|
- * @param shipVO
|
|
|
- * @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -242,13 +229,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
|
|
|
/**
|
|
|
* 出库完成
|
|
|
- *
|
|
|
- * @param shipVO
|
|
|
- * @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public R outboundCompleted(ShipVO shipVO) {
|
|
|
+ public R<PjShip> outboundCompleted(ShipVO shipVO) {
|
|
|
PjShip ship = new PjShip();
|
|
|
BeanUtil.copyProperties(shipVO, ship);
|
|
|
if (ObjectUtils.isNull(ship.getStorageId())) {
|
|
|
@@ -380,11 +364,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
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()));
|
|
|
- }
|
|
|
orderItems.setCostprie(orderItems.getCostprie().add(item.getCostprie()));
|
|
|
orderItems.setCostpriePrice(orderItems.getCostprie().divide(orderItems.getSendNum(), 2, RoundingMode.HALF_UP));
|
|
|
orderItems.setProfit(orderItems.getSubTotalMoney().subtract(orderItems.getCostprie()));
|
|
|
@@ -394,7 +373,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
orderItems.setRebatePrice(orderItems.getRebateCostprie().divide(orderItems.getSendNum(), 2, RoundingMode.HALF_UP));
|
|
|
orderItems.setRebateProfit(orderItems.getSubTotalMoney().subtract(orderItems.getRebateCostprie()));
|
|
|
|
|
|
- orderItems.setGoodsTotalShipAmount(orderItems.getSendNum().multiply(orderItems.getPrice()));
|
|
|
pjOrderItemsList.add(orderItems);
|
|
|
} else {
|
|
|
throw new RuntimeException("数据异常请联系管理员");
|
|
|
@@ -419,35 +397,26 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
orderItemsService.updateBatchById(pjOrderItemsList);
|
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
if (ObjectUtil.isNotEmpty(order)) {
|
|
|
- List<PjOrderItems> orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
- .eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjOrderItems::getIsDeleted, 0)
|
|
|
- .eq(PjOrderItems::getPid, order.getId()));
|
|
|
- if (!orderItemsList.isEmpty()) {
|
|
|
- if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
+ if (!pjOrderItemsList.isEmpty()) {
|
|
|
+ if ("已收货".equals(order.getStatus()) || "申请退货".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
}
|
|
|
//数量和
|
|
|
- BigDecimal goodsNum = orderItemsList.stream().map(PjOrderItems::getGoodsNum).filter(Objects::nonNull)
|
|
|
+ BigDecimal goodsNum = pjOrderItemsList.stream().map(PjOrderItems::getGoodsNum).filter(Objects::nonNull)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//发货数量和
|
|
|
- BigDecimal sendNum = orderItemsList.stream().map(PjOrderItems::getSendNum).filter(Objects::nonNull)
|
|
|
+ BigDecimal sendNum = pjOrderItemsList.stream().map(PjOrderItems::getSendNum).filter(Objects::nonNull)
|
|
|
.reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal goodsTotalShipAmount = orderItemsList.stream().map(PjOrderItems::getGoodsTotalShipAmount)
|
|
|
+ BigDecimal goodsTotalShipAmount = pjOrderItemsList.stream().map(PjOrderItems::getGoodsTotalShipAmount)
|
|
|
.filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
order.setGoodsTotalShipAmount(goodsTotalShipAmount);
|
|
|
order.setGoodsTotalShipNum(sendNum);
|
|
|
- order.setGrossProfit(orderItemsList.stream().map(PjOrderItems::getGrossProfit).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- order.setCost(orderItemsList.stream().map(PjOrderItems::getCostprie).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- order.setShipType(ship.getShipType());
|
|
|
- order.setLogisticsCorpId(ship.getLogisticsCorpId());
|
|
|
- order.setLogisticsCorpName(ship.getLogisticsCorpName());
|
|
|
- order.setExpressNo(ship.getExpressNo());
|
|
|
+ order.setGrossProfit(pjOrderItemsList.stream().map(PjOrderItems::getGrossProfit).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ order.setCost(pjOrderItemsList.stream().map(PjOrderItems::getCostprie).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
order.setVersion(order.getVersion() + 1);
|
|
|
if (goodsNum.compareTo(sendNum) == 0) {//数量等于发货数量修改销售订单状态
|
|
|
order.setDeliveryBusinesDate(new Date());
|
|
|
order.setStatus(OrderTypeEnum.SHIPED.getType());
|
|
|
- order.setXcxStatus(OrderTypeEnum.GOODSRECEIVED.getType());
|
|
|
orderMapper.updateById(order);
|
|
|
} else {
|
|
|
order.setStorageId(ship.getStorageId());
|
|
|
@@ -471,15 +440,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
ship.setUpdateUser(AuthUtil.getUserId());
|
|
|
ship.setUpdateTime(new Date());
|
|
|
ship.setVersion(Objects.isNull(ship.getVersion()) ? 1 : ship.getVersion() + 1);
|
|
|
-/* PjShip shipVersion = baseMapper.selectById(ship.getId());
|
|
|
- if (shipVersion != null && !shipVersion.getVersion().equals(ship.getVersion())) {
|
|
|
- throw new RuntimeException("数据已被修改,请返回列表重新操作!");
|
|
|
- }*/
|
|
|
baseMapper.updateById(ship);
|
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
// 保存订单明细
|
|
|
List<PjShipItems> itemsList = new ArrayList<>();
|
|
|
- List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
|
|
|
List<TireStockDesc> pjStockDescArrayList = new ArrayList<>();
|
|
|
if (CollectionUtils.isNotEmpty(shipVO.getShipItemsList())) {
|
|
|
List<Long> goodIds = shipVO.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
|
|
|
@@ -488,31 +452,13 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
.eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
.in(PjGoodsDesc::getId, goodIds));
|
|
|
//修改库存账
|
|
|
- String poNo = shipVO.getShipItemsList().stream().map(PjShipItems::getPoNo).filter(Objects::nonNull).distinct().collect(Collectors.joining(","));
|
|
|
LambdaQueryWrapper<TireStockDesc> stockLambdaQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
stockLambdaQueryWrapper
|
|
|
.eq(TireStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(TireStockDesc::getIsDeleted, 0)
|
|
|
.eq(TireStockDesc::getStorageId, ship.getStorageId())
|
|
|
- .eq(TireStockDesc::getSalesCompanyId, ship.getSalesCompanyId())
|
|
|
.in(TireStockDesc::getGoodsId, goodIds);
|
|
|
-// if (ObjectUtils.isNotNull(status) && "1".equals(status)) {
|
|
|
- if (ObjectUtils.isNotNull(ship.getWhetherFinancing()) && "1".equals(ship.getWhetherFinancing())) {
|
|
|
- stockLambdaQueryWrapper.apply("find_in_set(po_no,'" + poNo + "')");
|
|
|
- }
|
|
|
List<TireStockDesc> pjStockDescList = iStockDescService.list(stockLambdaQueryWrapper);
|
|
|
- LambdaQueryWrapper<TireStockDesc> lambdaQueryWrapper1 = new LambdaQueryWrapper<>();
|
|
|
- lambdaQueryWrapper1.eq(TireStockDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(TireStockDesc::getIsDeleted, 0)
|
|
|
- .eq(TireStockDesc::getSalesCompanyId, ship.getSalesCompanyId())
|
|
|
- .eq(TireStockDesc::getStorageId, order.getStorageId())
|
|
|
- .in(TireStockDesc::getGoodsId, goodIds);
|
|
|
- List<TireStockDesc> pjStockDescList1 = iStockDescService.list(lambdaQueryWrapper1);
|
|
|
- List<Long> srcItemIds = shipVO.getShipItemsList().stream().map(PjShipItems::getSrcItemId).distinct().collect(Collectors.toList());
|
|
|
- List<PjOrderItems> pjOrderItems = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
- .eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjOrderItems::getIsDeleted, 0)
|
|
|
- .in(PjOrderItems::getId, srcItemIds));
|
|
|
List<PjOrderItems> orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
.eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
.eq(PjOrderItems::getIsDeleted, 0)
|
|
|
@@ -530,30 +476,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if (ObjectUtil.isEmpty(goodsDesc)) {
|
|
|
throw new RuntimeException("商品数据异常");
|
|
|
}
|
|
|
- //管理批次号
|
|
|
- TireStockDesc 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.setRebateCostprie(new BigDecimal("0.00"));
|
|
|
- orderItems.setRebateProfit(new BigDecimal("0.00"));
|
|
|
- }
|
|
|
- orderItems.setSendNum(orderItems.getSendNum().subtract(item.getSendNum()));
|
|
|
- pjOrderItemsList.add(orderItems);
|
|
|
- } else {
|
|
|
- throw new RuntimeException("数据异常请联系管理员");
|
|
|
- }
|
|
|
List<PjOrderItems> pjOrderItemsList1 = orderItemsList.stream().filter(e -> e.getGoodsId().equals(item.getGoodsId())).collect(Collectors.toList());
|
|
|
if (!pjOrderItemsList1.isEmpty()) {
|
|
|
msg1.append(item.getGoodsName()).append(",");
|
|
|
@@ -571,8 +493,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
if (stockOne != null) {
|
|
|
stockOne.setBalanceQuantity(stockOne.getBalanceQuantity().add(item.getSendNum()));
|
|
|
- stockOne.setBalanceQuantityFinancing(stockOne.getBalanceQuantityFinancing().add(item.getSendNumFinancing()));
|
|
|
- stockOne.setBalanceQuantityHave(stockOne.getBalanceQuantityHave().add(item.getSendNumHave()));
|
|
|
stockOne.setStoreInventory(stockOne.getBalanceQuantity());
|
|
|
BigDecimal inventoryAmount = item.getSendNum().multiply(stockOne.getInventoryCostPrice());
|
|
|
BigDecimal rebateInventoryAmount = item.getSendNum().multiply(stockOne.getRebatePrice());
|
|
|
@@ -593,22 +513,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
throw new RuntimeException(res.getMsg());
|
|
|
}
|
|
|
shipItemsService.updateBatchById(itemsList);
|
|
|
- orderItemsService.updateBatchById(pjOrderItemsList);
|
|
|
ship.setNumberRows(shipVO.getShipItemsList().size());
|
|
|
-
|
|
|
- //修改任务发货数量
|
|
|
- PjShip rwShip = baseMapper.selectById(ship.getTaskId());
|
|
|
- if (ObjectUtils.isNotNull(rwShip)) {
|
|
|
- rwShip.setSendTotalNum(rwShip.getSendTotalNum().subtract(number));
|
|
|
- if (rwShip.getSendTotalNum().compareTo(rwShip.getGoodsTotalNum()) == 0) {
|
|
|
- rwShip.setStatusName("已完成");
|
|
|
- } else {
|
|
|
- rwShip.setStatusName("未完成");
|
|
|
- }
|
|
|
- rwShip.setUpdateUser(AuthUtil.getUserId());
|
|
|
- rwShip.setUpdateTime(new Date());
|
|
|
- baseMapper.updateById(rwShip);
|
|
|
- }
|
|
|
} else {
|
|
|
throw new RuntimeException("出库明细不能为空");
|
|
|
}
|
|
|
@@ -620,25 +525,11 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if (order1 != null && "待入库,已完成".contains(order1.getStatus())) {
|
|
|
throw new RuntimeException("已生成销售退货单据,撤销失败");
|
|
|
}
|
|
|
- if ("已收货".equals(order.getStatus()) || "退款请核".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
+ if ("已收货".equals(order.getStatus()) || "申请退货".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
}
|
|
|
- List<PjOrderItems> orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
- .eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjOrderItems::getIsDeleted, 0)
|
|
|
- .eq(PjOrderItems::getPid, order.getId()));
|
|
|
- if (!orderItemsList.isEmpty()) {
|
|
|
- //发货数量和
|
|
|
- BigDecimal sendNum = orderItemsList.stream().map(PjOrderItems::getSendNum).filter(Objects::nonNull)
|
|
|
- .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal goodsTotalShipAmount = orderItemsList.stream().map(PjOrderItems::getGoodsTotalShipAmount)
|
|
|
- .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- order.setGoodsTotalShipAmount(goodsTotalShipAmount);
|
|
|
- order.setGoodsTotalShipNum(sendNum);
|
|
|
- }
|
|
|
order.setDeliveryBusinesDate(null);
|
|
|
- order.setStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
- order.setXcxStatus(OrderTypeEnum.XSDFH.getType());
|
|
|
+ order.setStatus(OrderTypeEnum.GENERATED.getType());
|
|
|
order.setVersion(order.getVersion() + 1);
|
|
|
orderMapper.updateById(order);
|
|
|
} else {
|
|
|
@@ -653,13 +544,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
|
|
|
/**
|
|
|
* 入库完成
|
|
|
- *
|
|
|
- * @param shipVO
|
|
|
- * @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
- public R warehousingComplete(ShipVO shipVO) {
|
|
|
+ public R<PjShip> warehousingComplete(ShipVO shipVO) {
|
|
|
PjShip ship = new PjShip();
|
|
|
BeanUtil.copyProperties(shipVO, ship);
|
|
|
if (ship.getId() == null) {
|
|
|
@@ -748,10 +636,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
TireStockDesc stockDesc = new TireStockDesc();
|
|
|
stockDesc.setGoodsTypeId(goodsDesc.getGoodsTypeId());
|
|
|
if (ObjectUtils.isNotNull(goodsDesc.getGoodsTypeId())) {
|
|
|
- PjGoodsType goodsType = pjGoodsTypeList.stream().filter(e -> (e.getId() + "").equals(goodsDesc.getGoodsTypeId())).findFirst().orElse(null);
|
|
|
- if (goodsType != null) {
|
|
|
- stockDesc.setGoodsTypeName(goodsType.getCname());
|
|
|
- }
|
|
|
+ pjGoodsTypeList.stream().filter(e -> (e.getId() + "").equals(goodsDesc.getGoodsTypeId())).findFirst()
|
|
|
+ .ifPresent(goodsType -> stockDesc.setGoodsTypeName(goodsType.getCname()));
|
|
|
}
|
|
|
stockDesc.setGoodsId(goodsDesc.getId());
|
|
|
stockDesc.setCode(item.getGoodsNo());
|
|
|
@@ -955,9 +841,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
|
|
|
/**
|
|
|
* 退货入库完成
|
|
|
- *
|
|
|
- * @param shipVO
|
|
|
- * @return
|
|
|
*/
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@@ -1090,10 +973,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
@Override
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
public R revokeWarehousing(ShipVO shipVO) {
|
|
|
-/* PjShip shipVersion = baseMapper.selectById(ship.getId());
|
|
|
- if (shipVersion != null && !shipVersion.getVersion().equals(ship.getVersion())) {
|
|
|
- throw new RuntimeException("数据已被修改,请返回列表重新操作!");
|
|
|
- }*/
|
|
|
PjShip ship = new PjShip();
|
|
|
BeanUtil.copyProperties(shipVO, ship);
|
|
|
// 保存订单明细
|
|
|
@@ -1658,7 +1537,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
shipItemsService.saveOrUpdateBatch(shipVO.getShipItemsList());
|
|
|
ship.setNumberRows(shipVO.getShipItemsList().size());//行数
|
|
|
//明细总数量
|
|
|
- ship.setGoodsTotalNum(shipVO.getShipItemsList().stream().filter(e -> e.getGoodsNum() != null).map(PjShipItems::getGoodsNum).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
+ ship.setGoodsTotalNum(shipVO.getShipItemsList().stream().map(PjShipItems::getGoodsNum).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
}
|
|
|
baseMapper.updateById(ship);
|
|
|
return R.data(ship);
|
|
|
@@ -2107,13 +1986,10 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
if (rwShip == null) {
|
|
|
throw new RuntimeException("数据异常 请联系管理员");
|
|
|
}
|
|
|
- StringBuilder goodsNames = new StringBuilder();
|
|
|
-
|
|
|
//根据销售id获得销售明细数据
|
|
|
List<PjOrderItems> list = pjOrderItemsList.stream().filter(e -> e.getPid().equals(item.getOrdId())).collect(Collectors.toList());
|
|
|
if (ObjectUtil.isNotEmpty(list)) {
|
|
|
for (PjOrderItems e : list) {
|
|
|
- goodsNames.append(e.getGoodsName()).append(",");
|
|
|
//根据销售明细创建出库工单明细
|
|
|
PjShipItems shipItems = new PjShipItems();
|
|
|
BeanUtil.copyProperties(e, shipItems);
|
|
|
@@ -2139,11 +2015,12 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
|
|
|
//生成出库工单历史记录
|
|
|
saveHistory(item.getId(), OrderTypeEnum.TREATWAREHOUSING.getType());
|
|
|
+ //给角色为派工的人发送消息
|
|
|
+ /*
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
String formatted = now.format(formatter);
|
|
|
- //给角色为派工的人发送消息
|
|
|
- /*if (ObjectUtils.isNotNull(rwShip.getStockClerkId())) {
|
|
|
+ if (ObjectUtils.isNotNull(rwShip.getStockClerkId())) {
|
|
|
Message sendMessage = new Message();
|
|
|
sendMessage.setParameter(item.getId() + "");
|
|
|
sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
@@ -2327,7 +2204,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
throw new RuntimeException("数据异常请联系管理员");
|
|
|
}
|
|
|
//管理批次号
|
|
|
- TireStockDesc stockOne = null;
|
|
|
+ TireStockDesc stockOne;
|
|
|
if (ObjectUtil.isNotEmpty(goodsDesc.getWhether()) && "1".equals(goodsDesc.getWhether())) {
|
|
|
stockOne = pjStockDescList.stream()
|
|
|
.filter(e -> e.getGoodsId().equals(item.getGoodsId())
|
|
|
@@ -2437,7 +2314,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
BigDecimal goodsNum = pjOrderItemsList.stream().map(PjOrderItems::getReturnsNumber).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
//发货数量和
|
|
|
BigDecimal sendNum = pjOrderItemsList.stream().map(PjOrderItems::getSendNum).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
- BigDecimal amount = pjOrderItemsList.stream().map(PjOrderItems::getSubTotalMoney).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
if (ObjectUtil.isNotEmpty(order)) {
|
|
|
order.setVersion(order.getVersion() + 1);
|
|
|
@@ -2466,7 +2342,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
}
|
|
|
//生成出库工单历史记录
|
|
|
saveHistory(ship.getId(), OrderTypeEnum.OURTBOUND.getType());
|
|
|
- String status = sysClient.getParamService("whether.financing");
|
|
|
//融资流程
|
|
|
PjStorageDesc storageDesc = storageDescMapper.selectById(ship.getStorageId());
|
|
|
if (storageDesc == null) {
|
|
|
@@ -2539,7 +2414,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
throw new RuntimeException("商品数据异常");
|
|
|
}
|
|
|
//管理批次号
|
|
|
- TireStockDesc stockOne = null;
|
|
|
+ TireStockDesc stockOne;
|
|
|
if (ObjectUtil.isNotEmpty(goodsDesc.getWhether()) && "1".equals(goodsDesc.getWhether())) {
|
|
|
stockOne = pjStockDescList.stream()
|
|
|
.filter(e -> e.getGoodsId().equals(item.getGoodsId())
|
|
|
@@ -2652,7 +2527,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
|
|
|
//生成出库工单历史记录
|
|
|
saveHistory(ship.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
|
- String status = sysClient.getParamService("whether.financing");
|
|
|
//融资流程
|
|
|
PjStorageDesc storageDesc = storageDescMapper.selectById(ship.getStorageId());
|
|
|
if (storageDesc == null) {
|
|
|
@@ -2756,11 +2630,12 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
|
|
|
//生成入库工单历史记录
|
|
|
saveHistory(item.getId(), OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
|
+ //给角色为派工的人发送消息
|
|
|
+ /*
|
|
|
LocalDateTime now = LocalDateTime.now();
|
|
|
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
String formatted = now.format(formatter);
|
|
|
- //给角色为派工的人发送消息
|
|
|
- /*if (ObjectUtils.isNotNull(rwShip.getStockClerkId())) {
|
|
|
+ if (ObjectUtils.isNotNull(rwShip.getStockClerkId())) {
|
|
|
Message sendMessage = new Message();
|
|
|
sendMessage.setParameter(item.getId() + "");
|
|
|
sendMessage.setUserName(AuthUtil.getUserName());
|
|
|
@@ -2945,10 +2820,8 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
stockDesc.setSalesCompanyName(ship.getSalesCompanyName());
|
|
|
stockDesc.setGoodsTypeId(goodsDesc.getGoodsTypeId());
|
|
|
if (ObjectUtils.isNotNull(goodsDesc.getGoodsTypeId())) {
|
|
|
- PjGoodsType goodsType = pjGoodsTypeList.stream().filter(e -> (e.getId() + "").equals(goodsDesc.getGoodsTypeId())).findFirst().orElse(null);
|
|
|
- if (goodsType != null) {
|
|
|
- stockDesc.setGoodsTypeName(goodsType.getCname());
|
|
|
- }
|
|
|
+ pjGoodsTypeList.stream().filter(e -> (e.getId() + "").equals(goodsDesc.getGoodsTypeId())).findFirst()
|
|
|
+ .ifPresent(goodsType -> stockDesc.setGoodsTypeName(goodsType.getCname()));
|
|
|
}
|
|
|
stockDesc.setGoodsId(goodsDesc.getId());
|
|
|
stockDesc.setCode(item.getGoodsNo());
|
|
|
@@ -3396,7 +3269,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
} else {
|
|
|
rwShip.setStatusName("未完成");
|
|
|
}
|
|
|
- rwShip.setVersion(Objects.isNull(rwShip) ? 1 : rwShip.getVersion() + 1);
|
|
|
+ rwShip.setVersion(rwShip.getVersion() + 1);
|
|
|
rwShip.setUpdateUser(AuthUtil.getUserId());
|
|
|
rwShip.setUpdateTime(new Date());
|
|
|
baseMapper.updateById(rwShip);
|
|
|
@@ -3793,7 +3666,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
public R submitShip(ShipItemsDTO shipDTO) {
|
|
|
PjShip ship = new PjShip();
|
|
|
ship.setOrdNo(shipDTO.getOrdNo());
|
|
|
- ship.setOrdId(shipDTO.getId());
|
|
|
+ ship.setOrdId(shipDTO.getOrdId());
|
|
|
ship.setSrcOrdNo(shipDTO.getSrcOrdNo());
|
|
|
ship.setBsType(shipDTO.getBsType());
|
|
|
ship.setBizTypeName(shipDTO.getBizTypeName());
|
|
|
@@ -3807,11 +3680,7 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
TransactionAspectSupport.currentTransactionStatus().setRollbackOnly();
|
|
|
return R.fail(500, "生成系统编号失败");
|
|
|
}
|
|
|
- if (ship.getBizTypeName().equals(OrderTypeEnum.SHGD.getType())) {
|
|
|
- ship.setStatusName(OrderTypeEnum.TREATWAREHOUSING.getType());
|
|
|
- } else {
|
|
|
- ship.setStatusName(OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
|
- }
|
|
|
+ ship.setStatusName(OrderTypeEnum.TOBESHIPPEDOUT.getType());
|
|
|
ship.setBillno(billNo);
|
|
|
ship.setCreateTime(new Date());
|
|
|
ship.setCreateUser(AuthUtil.getUserId());
|
|
|
@@ -3820,12 +3689,6 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
baseMapper.insert(ship);
|
|
|
// 保存订单明细
|
|
|
if (CollectionUtils.isNotEmpty(shipDTO.getShipItemsList())) {
|
|
|
- List<PjProductLaunch> pjProductLaunchList = new ArrayList<>();
|
|
|
- List<Long> goodIds = shipDTO.getShipItemsList().stream().map(PjShipItems::getGoodsId).distinct().collect(Collectors.toList());
|
|
|
- List<PjGoodsDesc> pjGoodsDescList = goodsDescMapper.selectList(new LambdaQueryWrapper<PjGoodsDesc>()
|
|
|
- .eq(PjGoodsDesc::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjGoodsDesc::getIsDeleted, 0)
|
|
|
- .in(PjGoodsDesc::getId, goodIds));
|
|
|
List<PjShipItems> shipItemsList = new ArrayList<>();
|
|
|
shipDTO.getShipItemsList().forEach(item -> {
|
|
|
item.setCostprie(item.getSendNum().multiply(item.getCostpriePrice()));
|
|
|
@@ -3840,35 +3703,106 @@ public class ShipServiceImpl extends ServiceImpl<ShipMapper, PjShip> implements
|
|
|
ship.setNumberRows(shipDTO.getShipItemsList().size());
|
|
|
ship.setGoodsTotalNum(shipDTO.getShipItemsList().stream().map(PjShipItems::getGoodsNum).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
ship.setSendTotalNum(shipDTO.getShipItemsList().stream().map(PjShipItems::getSendNum).filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add));
|
|
|
- //查询所有上架商品
|
|
|
- LambdaQueryWrapper<PjProductLaunch> productLaunchQueryWrapper = new LambdaQueryWrapper<>();
|
|
|
- productLaunchQueryWrapper.eq(PjProductLaunch::getTenantId, AuthUtil.getTenantId())
|
|
|
- .eq(PjProductLaunch::getIsDeleted, 0)
|
|
|
- .isNull(PjProductLaunch::getSourceId)
|
|
|
- .in(PjProductLaunch::getGoodsId, goodIds);
|
|
|
- List<PjProductLaunch> productLaunch = productLaunchService.list(productLaunchQueryWrapper);
|
|
|
+ // 保存订单明细
|
|
|
+ List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
|
|
|
+ List<PjOrderItems> orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
+ .eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjOrderItems::getIsDeleted, 0)
|
|
|
+ .eq(PjOrderItems::getPid, shipDTO.getOrdId()));
|
|
|
+ BigDecimal number = new BigDecimal("0.00");
|
|
|
for (PjShipItems item : shipDTO.getShipItemsList()) {
|
|
|
- //获得商品
|
|
|
- PjGoodsDesc goodsDesc = pjGoodsDescList.stream().filter(e -> e.getId().equals(item.getGoodsId())).findFirst().orElse(null);
|
|
|
- if (ObjectUtil.isEmpty(goodsDesc)) {
|
|
|
- throw new RuntimeException("商品数据异常");
|
|
|
- }
|
|
|
- PjProductLaunch pjProductLaunches = productLaunch.stream()
|
|
|
- .filter(i -> i.getGoodsId().equals(goodsDesc.getId())).findFirst().orElse(null);
|
|
|
- //修改上架数量
|
|
|
- if (pjProductLaunches == null) {
|
|
|
- throw new RuntimeException("未查到商品:" + item.getGoodsName() + "上架数据");
|
|
|
+ number = number.add(item.getSendNum());
|
|
|
+ PjOrderItems orderItems = orderItemsList.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()));
|
|
|
+ }
|
|
|
+ orderItems.setGoodsTotalShipAmount(orderItems.getSendNum().multiply(orderItems.getPrice()));
|
|
|
+ pjOrderItemsList.add(orderItems);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("数据异常请联系管理员");
|
|
|
}
|
|
|
- pjProductLaunches.setInventory(pjProductLaunches.getInventory().subtract(item.getSendNum()));
|
|
|
- pjProductLaunchList.add(pjProductLaunches);
|
|
|
}
|
|
|
- R res = productLaunchService.updateBatchById(pjProductLaunchList);
|
|
|
- if (!res.isSuccess()) {
|
|
|
- throw new RuntimeException(res.getMsg());
|
|
|
+ orderItemsService.updateBatchById(pjOrderItemsList);
|
|
|
+ PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
+ if (ObjectUtil.isNotEmpty(order)) {
|
|
|
+ if (!orderItemsList.isEmpty()) {
|
|
|
+ if ("已收货".equals(order.getStatus()) || "申请退货".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
+ throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
+ }
|
|
|
+ //发货数量和
|
|
|
+ BigDecimal sendNum = orderItemsList.stream().map(PjOrderItems::getSendNum).filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal goodsTotalShipAmount = orderItemsList.stream().map(PjOrderItems::getGoodsTotalShipAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ order.setGoodsTotalShipAmount(goodsTotalShipAmount);
|
|
|
+ order.setGoodsTotalShipNum(sendNum);
|
|
|
+ order.setVersion(order.getVersion() + 1);
|
|
|
+ order.setStatus(OrderTypeEnum.GENERATED.getType());
|
|
|
+ order.setStorageId(ship.getStorageId());
|
|
|
+ order.setStorageName(ship.getStorageName());
|
|
|
+ orderMapper.updateById(order);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
baseMapper.updateById(ship);
|
|
|
return R.data(ship);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public R removeShip(Long id) {
|
|
|
+ if (id == null) {
|
|
|
+ throw new RuntimeException("缺少必要参数");
|
|
|
+ }
|
|
|
+ PjShip ship = this.getById(id);
|
|
|
+ if (ship == null) {
|
|
|
+ throw new RuntimeException("未查到出库单据");
|
|
|
+ }
|
|
|
+ List<PjShipItems> shipItemsList = shipItemsService.list(new LambdaQueryWrapper<PjShipItems>()
|
|
|
+ .eq(PjShipItems::getIsDeleted, 0)
|
|
|
+ .eq(PjShipItems::getPid, id));
|
|
|
+ if (!shipItemsList.isEmpty()) {
|
|
|
+ // 保存订单明细
|
|
|
+ List<PjOrderItems> pjOrderItemsList = new ArrayList<>();
|
|
|
+ List<PjOrderItems> orderItemsList = orderItemsService.list(new LambdaQueryWrapper<PjOrderItems>()
|
|
|
+ .eq(PjOrderItems::getTenantId, AuthUtil.getTenantId())
|
|
|
+ .eq(PjOrderItems::getIsDeleted, 0)
|
|
|
+ .eq(PjOrderItems::getPid, ship.getOrdId()));
|
|
|
+ BigDecimal number = new BigDecimal("0.00");
|
|
|
+ for (PjShipItems item : shipItemsList) {
|
|
|
+ number = number.add(item.getSendNum());
|
|
|
+ PjOrderItems orderItems = orderItemsList.stream().filter(e -> e.getId().equals(item.getSrcItemId())).findFirst().orElse(null);
|
|
|
+ if (orderItems != null) {
|
|
|
+ orderItems.setSendNum(orderItems.getSendNum().subtract(item.getSendNum()));
|
|
|
+ orderItems.setGoodsTotalShipAmount(orderItems.getSendNum().multiply(orderItems.getPrice()));
|
|
|
+ pjOrderItemsList.add(orderItems);
|
|
|
+ } else {
|
|
|
+ throw new RuntimeException("数据异常请联系管理员");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ orderItemsService.updateBatchById(pjOrderItemsList);
|
|
|
+ PjOrder order = orderMapper.selectById(ship.getOrdId());
|
|
|
+ if (ObjectUtil.isNotEmpty(order)) {
|
|
|
+ if (!pjOrderItemsList.isEmpty()) {
|
|
|
+ if ("已收货".equals(order.getStatus()) || "申请退货".equals(order.getStatus()) || "已取消".equals(order.getStatus())) {
|
|
|
+ throw new RuntimeException("单据已收货或申请售后中,操作失败");
|
|
|
+ }
|
|
|
+ //发货数量和
|
|
|
+ BigDecimal sendNum = pjOrderItemsList.stream().map(PjOrderItems::getSendNum).filter(Objects::nonNull)
|
|
|
+ .reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ BigDecimal goodsTotalShipAmount = pjOrderItemsList.stream().map(PjOrderItems::getGoodsTotalShipAmount)
|
|
|
+ .filter(Objects::nonNull).reduce(BigDecimal.ZERO, BigDecimal::add);
|
|
|
+ order.setGoodsTotalShipAmount(goodsTotalShipAmount);
|
|
|
+ order.setGoodsTotalShipNum(sendNum);
|
|
|
+ order.setVersion(order.getVersion() + 1);
|
|
|
+ order.setStatus("待发货");
|
|
|
+ orderMapper.updateById(order);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return R.data("操作成功");
|
|
|
+ }
|
|
|
+
|
|
|
}
|