|
@@ -3,15 +3,18 @@ package com.zfire.mall.manager.logic.k3;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.IdWorker;
|
|
|
import com.zfire.mall.manager.bean.k3.KingDeeOtherStockInAdd;
|
|
|
import com.zfire.mall.manager.bean.k3.KingDeeOtherStockOutAdd;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeeOtherStockIn;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeeOtherStockInItem;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeeOtherStockOut;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeeOtherStockOutItem;
|
|
|
+import com.zfire.mall.manager.exception.RemoteServiceException;
|
|
|
+import com.zfire.mall.manager.logic.stock.StockCommonLogic;
|
|
|
+import com.zfire.mall.manager.plus.entity.*;
|
|
|
import com.zfire.mall.manager.plus.service.KingDeeOtherStockOutItemService;
|
|
|
import com.zfire.mall.manager.plus.service.KingDeeOtherStockOutService;
|
|
|
+import com.zfire.mall.manager.plus.service.StockService;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
+
|
|
|
+import java.util.List;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -19,10 +22,16 @@ public class K3OtherStockOutLogic {
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
- KingDeeOtherStockOutService kingDeeOtherStockInService;
|
|
|
+ KingDeeOtherStockOutService kingDeeOtherStockOutService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ KingDeeOtherStockOutItemService kingDeeOtherStockOutItemService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StockService stockService;
|
|
|
|
|
|
@Autowired
|
|
|
- KingDeeOtherStockOutItemService kingDeeOtherStockInItemService;
|
|
|
+ StockCommonLogic stockCommonLogic;
|
|
|
|
|
|
public void add(KingDeeOtherStockOutAdd kingDeeOtherStockOutAdd) {
|
|
|
kingDeeOtherStockOutAdd.setId(IdWorker.getIdStr());
|
|
@@ -33,7 +42,7 @@ public class K3OtherStockOutLogic {
|
|
|
kingDeeOtherStockOutItem.setBillNo(kingDeeOtherStockOutAdd.getId());
|
|
|
}
|
|
|
|
|
|
- kingDeeOtherStockInItemService.saveBatch(kingDeeOtherStockOutAdd.getKingDeeOtherStockOutItems());
|
|
|
+ kingDeeOtherStockOutItemService.saveBatch(kingDeeOtherStockOutAdd.getKingDeeOtherStockOutItems());
|
|
|
|
|
|
}
|
|
|
|
|
@@ -41,20 +50,48 @@ public class K3OtherStockOutLogic {
|
|
|
|
|
|
kingDeeOtherStockOutAdd.updateById();
|
|
|
|
|
|
- kingDeeOtherStockInItemService.lambdaUpdate().eq(KingDeeOtherStockOutItem::getBillNo,kingDeeOtherStockOutAdd.getBillNo())
|
|
|
+ kingDeeOtherStockOutItemService.lambdaUpdate().eq(KingDeeOtherStockOutItem::getBillNo,kingDeeOtherStockOutAdd.getBillNo())
|
|
|
.remove();
|
|
|
|
|
|
for (KingDeeOtherStockOutItem kingDeeOtherStockOutItem : kingDeeOtherStockOutAdd.getKingDeeOtherStockOutItems()) {
|
|
|
kingDeeOtherStockOutItem.setBillNo(kingDeeOtherStockOutAdd.getId());
|
|
|
}
|
|
|
|
|
|
- kingDeeOtherStockInItemService.saveBatch(kingDeeOtherStockOutAdd.getKingDeeOtherStockOutItems());
|
|
|
+ kingDeeOtherStockOutItemService.saveBatch(kingDeeOtherStockOutAdd.getKingDeeOtherStockOutItems());
|
|
|
}
|
|
|
|
|
|
public void examine(String billNo, String cancelStatus) {
|
|
|
- KingDeeOtherStockOut kingDeeOtherStockOut = kingDeeOtherStockInService.getById(billNo);
|
|
|
+ KingDeeOtherStockOut kingDeeOtherStockOut = kingDeeOtherStockOutService.getById(billNo);
|
|
|
|
|
|
kingDeeOtherStockOut.setCancelStatus(cancelStatus);
|
|
|
kingDeeOtherStockOut.updateById();
|
|
|
+
|
|
|
+ List<KingDeeOtherStockOutItem> kingDeeOtherStockOutItems = kingDeeOtherStockOutItemService.lambdaQuery()
|
|
|
+ .eq(KingDeeOtherStockOutItem::getBillNo, billNo).list();
|
|
|
+ for (KingDeeOtherStockOutItem kingDeeOtherStockOutItem : kingDeeOtherStockOutItems) {
|
|
|
+ this.stockSub(kingDeeOtherStockOut,kingDeeOtherStockOutItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void stockSub(KingDeeOtherStockOut kingDeeOtherStockOut, KingDeeOtherStockOutItem kingDeeOtherStockOutItem) {
|
|
|
+
|
|
|
+ Stock stock = stockService.lambdaQuery().eq(Stock::getStockId, kingDeeOtherStockOutItem.getStockId())
|
|
|
+ .eq(Stock::getMaterialId, kingDeeOtherStockOutItem.getMaterialId()).last("limit 1").one();
|
|
|
+
|
|
|
+ if (stock == null)
|
|
|
+ throw new RemoteServiceException(kingDeeOtherStockOutItem.getMaterialName()+"该物料没有库存,不能退库");
|
|
|
+
|
|
|
+
|
|
|
+ stockCommonLogic.stockAccLog("其他出库减少库存",stock,kingDeeOtherStockOutItem.getQty(),kingDeeOtherStockOutItem.getBillNo(),false,"其他出库单");
|
|
|
+
|
|
|
+ stock.setStockQty(stock.getStockQty().subtract(kingDeeOtherStockOutItem.getQty()));
|
|
|
+
|
|
|
+ if (stock.getStockQty().doubleValue() < 1)
|
|
|
+ throw new RemoteServiceException(kingDeeOtherStockOutItem.getMaterialName()+"该物料没有库存,不能退库");
|
|
|
+
|
|
|
+ stock.updateById();
|
|
|
+
|
|
|
}
|
|
|
}
|