|
@@ -11,23 +11,18 @@ import com.zfire.mall.manager.bean.k3.*;
|
|
|
import com.zfire.mall.manager.bean.stock.KingDeePurchaseStockInAdd;
|
|
|
import com.zfire.mall.manager.commonmapper.manage.TransferMapper;
|
|
|
import com.zfire.mall.manager.constant.KingDeeCons;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeePurchaseOrder;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeePurchaseOrderItem;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeePurchaseStockIn;
|
|
|
-import com.zfire.mall.manager.plus.entity.KingDeePurchaseStockInItem;
|
|
|
-import com.zfire.mall.manager.plus.service.KingDeePurchaseOrderItemService;
|
|
|
-import com.zfire.mall.manager.plus.service.KingDeePurchaseOrderService;
|
|
|
-import com.zfire.mall.manager.plus.service.KingDeePurchaseStockInItemService;
|
|
|
-import com.zfire.mall.manager.plus.service.KingDeePurchaseStockInService;
|
|
|
+import com.zfire.mall.manager.logic.stock.StockCommonLogic;
|
|
|
+import com.zfire.mall.manager.plus.entity.*;
|
|
|
+import com.zfire.mall.manager.plus.service.*;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
+import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Arrays;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.math.BigDecimal;
|
|
|
+import java.util.*;
|
|
|
|
|
|
@Service
|
|
|
@Slf4j
|
|
@@ -45,6 +40,12 @@ public class K3PurchaseStockInLogic {
|
|
|
@Autowired
|
|
|
TransferMapper transferMapper;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ StockService stockService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ StockCommonLogic stockCommonLogic;
|
|
|
+
|
|
|
|
|
|
// public void allSync(String orgId, String orgNumber, String startTime, String endTime) throws Exception {
|
|
|
// // 调用入库单接口
|
|
@@ -156,10 +157,56 @@ public class K3PurchaseStockInLogic {
|
|
|
kingDeePurchaseStockInItemService.saveBatch(kingDeePurchaseStockInAdd.getKingDeePurchaseStockInItem());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
public void examine(String billNo, String cancelStatus) {
|
|
|
KingDeePurchaseStockIn kingDeePurchaseStockIn = kingDeePurchaseStockInService.getById(billNo);
|
|
|
|
|
|
kingDeePurchaseStockIn.setCancelStatus(cancelStatus);
|
|
|
kingDeePurchaseStockIn.updateById();
|
|
|
+
|
|
|
+ List<KingDeePurchaseStockInItem> kingDeePurchaseStockInItems = kingDeePurchaseStockInItemService.lambdaQuery().eq(KingDeePurchaseStockInItem::getBillNo, billNo).list();
|
|
|
+
|
|
|
+ for (KingDeePurchaseStockInItem kingDeePurchaseStockInItem : kingDeePurchaseStockInItems) {
|
|
|
+
|
|
|
+ stockAdd(kingDeePurchaseStockIn,kingDeePurchaseStockInItem);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ public void stockAdd(KingDeePurchaseStockIn kingDeePurchaseStockIn,KingDeePurchaseStockInItem kingDeePurchaseStockInItem) {
|
|
|
+
|
|
|
+ Stock stock = stockService.lambdaQuery().eq(Stock::getStockId, kingDeePurchaseStockInItem.getStockId())
|
|
|
+ .eq(Stock::getMaterialId, kingDeePurchaseStockInItem.getMaterialId()).last("limit 1").one();
|
|
|
+
|
|
|
+ if (stock == null){
|
|
|
+ stock = new Stock();
|
|
|
+
|
|
|
+ stock.setStockQty(BigDecimal.ZERO);
|
|
|
+ stock.setSyncTime(new Date());
|
|
|
+ stock.setStockId(kingDeePurchaseStockInItem.getStockId());
|
|
|
+ stock.setMaterialId(kingDeePurchaseStockInItem.getMaterialId());
|
|
|
+ stock.setSupplyOrgId(kingDeePurchaseStockInItem.getSupplyOrgId());
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ stockCommonLogic.stockAccLog("采购入库单增加库存",stock,kingDeePurchaseStockInItem.getRealQty(),kingDeePurchaseStockIn.getBillNo(),true,"采购入库单");
|
|
|
+
|
|
|
+ stock.setStockQty(kingDeePurchaseStockInItem.getRealQty());
|
|
|
+ stock.insert();
|
|
|
+
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ stockCommonLogic.stockAccLog("采购入库单增加库存",stock,kingDeePurchaseStockInItem.getRealQty(),kingDeePurchaseStockIn.getBillNo(),true,"采购入库单");
|
|
|
+
|
|
|
+ stock.setStockQty(kingDeePurchaseStockInItem.getRealQty().add(stock.getStockQty()));
|
|
|
+ stock.updateById();
|
|
|
+
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
}
|