Explorar el Código

2023年6月15日12:38:29

纪新园 hace 2 años
padre
commit
35e586eb11

+ 1 - 1
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/controller/DeliveryController.java

@@ -142,7 +142,7 @@ public class DeliveryController extends BladeController {
 		redisClient.basicData("all");
 		List<CorpsDesc> corpsDescList = castToList(redisTemplate.opsForValue().get("corps"), CorpsDesc.class);
 		List<User> userList = castToList(redisTemplate.opsForValue().get("user"), User.class);
-		List<StorageDesc> storageDescList = castToList(redisTemplate.opsForValue().get("storageDesc"), StorageDesc.class);
+		List<StorageDesc> storageDescList = castToList(redisTemplate.opsForValue().get("storageType"), StorageDesc.class);
 
 		if (CollectionUtils.isNotEmpty(pages.getRecords())){
 			pages.getRecords().forEach(item ->{

+ 1 - 1
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/IDeliveryItemsService.java

@@ -83,6 +83,6 @@ public interface IDeliveryItemsService extends IService<DeliveryItems> {
 	 */
 	boolean submitPay(Long id);
 
-	StockGoods receivingInventory(String tradeType, Long id, OrderItems e);
+	StockGoods receivingInventory(StockGoods stock, OrderItems e);
 
 }

+ 38 - 62
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/impl/DeliveryItemsServiceImpl.java

@@ -222,6 +222,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 		List<StockGoods> stockGoodsList = castToList(redisTemplate.opsForValue().get("stockGoods"), StockGoods.class);
 
 		if (CollectionUtils.isNotEmpty(collect)) {
+			List<DeliveryItems> deliveryItemsList1 = new ArrayList<>();
+			List<StockGoods> stockGoodsList1 = new ArrayList<>();
 			for (DeliveryItems deliveryItems : collect) {
 				if (deliveryItems.getItemId() == null) {
 					throw new RuntimeException("发货明细中商品id不能为空");
@@ -234,11 +236,11 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 				if (deliveryItems.getId() == null) {
 					deliveryItems.setCreateUser(SecureUtil.getUserId());
 					deliveryItems.setCreateTime(new Date());
-					baseMapper.insert(deliveryItems);
+//					baseMapper.insert(deliveryItems);
 				} else {
 					deliveryItems.setUpdateTime(new Date());
 					deliveryItems.setUpdateUser(SecureUtil.getUserId());
-					baseMapper.updateById(deliveryItems);
+//					baseMapper.updateById(deliveryItems);
 				}
 				StockGoods stockGoods = null;
 				StockGoodsVO stock = null;
@@ -270,10 +272,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 					// 发货
 					if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.DELIVER.getType())) {
 						// 更新库存账
-						stockGoods = this.deliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, null);
+						stockGoods = this.deliverGoods(delivery.getTradeType(), stock, deliveryItems, null);
 						// 撤销发货
 					} else if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.REPEAL.getType())) {
-						stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, null);
+						stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock, deliveryItems, null);
 					} else {
 						//新增库存账
 						throw new RuntimeException("库存为空");
@@ -284,10 +286,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 						// 发货
 						if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.DELIVER.getType())) {
 							// 更新库存账
-							stockGoods = this.deliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, delivery.getDeliveryType());
+							stockGoods = this.deliverGoods(delivery.getTradeType(), stock, deliveryItems, delivery.getDeliveryType());
 							// 撤销发货
 						} else if (stock != null && delivery.getDeliveryType().equals(DeliveryEnum.REPEAL.getType())) {
-							stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock.getId(), deliveryItems, delivery.getDeliveryType());
+							stockGoods = this.revocationDeliverGoods(delivery.getTradeType(), stock, deliveryItems, delivery.getDeliveryType());
 						} else {
 							//新增库存账
 							throw new RuntimeException("库存为空");
@@ -331,8 +333,12 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 						}
 					}
 				}
-				baseMapper.updateById(deliveryItems);
+				stockGoodsList1.add(stockGoods);
+				deliveryItemsList1.add(deliveryItems);
+//				baseMapper.updateById(deliveryItems);
 			}
+			stockGoodsClient.updateStockList(stockGoodsList1);
+			this.saveOrUpdateBatch(deliveryItemsList1);
 		}
 		if (CollectionUtils.isNotEmpty(itemsList)) {
 			itemsList.forEach(item -> {
@@ -437,19 +443,13 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 	 * 发货减少库存账
 	 *
 	 * @param tradeType     单据类型 进口、出口、国内
-	 * @param stockId       库存账id
+	 * @param stockGoods       库存账id
 	 * @param deliveryItems 货物明细信息
 	 */
-	public StockGoods deliverGoods(String tradeType, Long stockId, DeliveryItems deliveryItems, Integer deliveryType) {
-		//查询库存账
-		R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
-		if (!stockById.isSuccess()) {
-			throw new RuntimeException("查询库存账出错");
-		}
-		if (stockById.getData() == null) {
+	public StockGoods deliverGoods(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems, Integer deliveryType) {
+		if (stockGoods == null) {
 			throw new RuntimeException("库存账不存在");
 		}
-		StockGoods stockGoods = stockById.getData();
 		//判断出库数量和结余数量的大小
 		if (stockGoods.getBalanceQuantity().compareTo(deliveryItems.getActualQuantity()) < 0) {
 			throw new RuntimeException("当前结余数量为:" + stockGoods.getBalanceQuantity() + "小于发货数量,发货数量为:" + deliveryItems.getActualQuantity());
@@ -463,7 +463,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 				stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getArrivalQuantity()));//结余数量 减
 				stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().add(deliveryItems.getActualQuantity()).subtract(deliveryItems.getArrivalQuantity()));//可用数量 减
 				stockGoods.setLockingQuantity(stockGoods.getLockingQuantity().subtract(deliveryItems.getActualQuantity()));//锁定数量 减
-				stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().subtract(deliveryItems.getPurchaseAmount()));
+				stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().subtract(deliveryItems.getPurchaseTotalAmount()));
 			} else {
 				stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getArrivalQuantity()));//结余数量 减
 				stockGoods.setSurplusRouteQuantity(stockGoods.getSurplusRouteQuantity().add(deliveryItems.getActualQuantity()).subtract(deliveryItems.getArrivalQuantity()));//可用数量 减
@@ -494,12 +494,12 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 			//stockGoods.setLockingVolumn(stockGoods.getLockingVolumn().subtract(deliveryItems.getBillWeight()));//锁定码单重量
 			stockGoods.setBalanceVolumn(stockGoods.getBalanceVolumn().subtract(deliveryItems.getBillWeight()));//结余码单重量
 		}
-		stockGoods.setUpdateTime(new Date());
-		stockGoods.setUpdateUser(SecureUtil.getUserId());
-		boolean updateStock = stockGoodsClient.updateStock(stockGoods);
+		stockGoods.setUpdateTime(new Date());/*boolean updateStock = stockGoodsClient.updateStock(stockGoods);
 		if (!updateStock) {
 			throw new RuntimeException("更新库存总账失败");
-		}
+		}*/
+		stockGoods.setUpdateUser(SecureUtil.getUserId());
+
 		return stockGoods;
 	}
 
@@ -507,19 +507,13 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 	 * 撤销发货
 	 *
 	 * @param tradeType     单据类型 进口、出口、国内
-	 * @param stockId       库存账id
+	 * @param stockGoods       库存账id
 	 * @param deliveryItems 货物明细信息
 	 */
-	public StockGoods revocationDeliverGoods(String tradeType, Long stockId, DeliveryItems deliveryItems, Integer deliveryType) {
-		//查询库存账
-		R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
-		if (!stockById.isSuccess()) {
-			throw new RuntimeException("查询库存账出错");
-		}
-		if (stockById.getData() == null) {
+	public StockGoods revocationDeliverGoods(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems, Integer deliveryType) {
+		if (stockGoods == null) {
 			throw new RuntimeException("库存账不存在");
 		}
-		StockGoods stockGoods = stockById.getData();
 		//判断出库数量和结余数量的大小
 		if (stockGoods.getOutQuantity().compareTo(deliveryItems.getActualQuantity()) < 0) {
 			throw new RuntimeException("当前可减少出库数量为:" + stockGoods.getOutQuantity() + "小于发货数量,发货数量为:" + deliveryItems.getActualQuantity());
@@ -530,7 +524,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 				&& "1".equals(sysClient.getParamService("synchronous"))) {
 				stockGoods.setLockingQuantity(stockGoods.getLockingQuantity().add(deliveryItems.getActualQuantity()));//锁定数量 加
 				stockGoods.setSurplusRouteQuantity(stockGoods.getBalanceQuantity().subtract(stockGoods.getLockingQuantity()));//可用数量 加
-				stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().add(deliveryItems.getPurchaseAmount()));
+				stockGoods.setBalanceAmount(stockGoods.getBalanceAmount().add(deliveryItems.getPurchaseTotalAmount()));
 			}
 		} else {
 			stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().subtract(deliveryItems.getArrivalQuantity()));//结余数量 加
@@ -562,10 +556,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 		}
 		stockGoods.setUpdateTime(new Date());
 		stockGoods.setUpdateUser(SecureUtil.getUserId());
-		boolean updateStock = stockGoodsClient.updateStock(stockGoods);
+		/*boolean updateStock = stockGoodsClient.updateStock(stockGoods);
 		if (!updateStock) {
 			throw new RuntimeException("更新库存总账失败");
-		}
+		}*/
 		return stockGoods;
 	}
 
@@ -573,16 +567,12 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 	 * 撤销收货
 	 *
 	 * @param tradeType     单据类型 进口、出口、国内
-	 * @param stockId       库存账id
+	 * @param stockGoods       库存账id
 	 * @param deliveryItems 货物明细信息
 	 */
-	public StockGoods cancelStock(String tradeType, Long stockId, DeliveryItems deliveryItems) {
-		//查询库存账
-		R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
-		if (!stockById.isSuccess()) {
-			throw new RuntimeException("查询库存账出错");
-		}
-		if (stockById.getData() == null) {
+	public StockGoods cancelStock(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems) {
+
+		if (stockGoods == null) {
 			throw new RuntimeException("库存账不存在");
 		}
 		BigDecimal actualQuantity = new BigDecimal("0.00");
@@ -594,7 +584,6 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 		BigDecimal invoiceWeight = deliveryItems.getInvoiceWeight() == null ? new BigDecimal("0") : deliveryItems.getInvoiceWeight();
 		BigDecimal billWeight = deliveryItems.getBillWeight() == null ? new BigDecimal("0") : deliveryItems.getBillWeight();
 
-		StockGoods stockGoods = stockById.getData();
 		if (!tradeType.equals(OrderTypeEnum.DOMESTIC.getType())) {
 			if (actualQuantity.compareTo(stockGoods.getInQuantity()) > 0) {
 				throw new SecurityException("操作数量大于入库数量,禁止操作");
@@ -632,10 +621,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 
 		stockGoods.setUpdateTime(new Date());
 		stockGoods.setUpdateUser(SecureUtil.getUserId());
-		boolean updateStock = stockGoodsClient.updateStock(stockGoods);
+		/*boolean updateStock = stockGoodsClient.updateStock(stockGoods);
 		if (!updateStock) {
 			throw new RuntimeException("更新库存总账失败");
-		}
+		}*/
 		return stockGoods;
 	}
 
@@ -644,20 +633,13 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 	 * 收货单新增库存账
 	 *
 	 * @param tradeType     单据类型 进口、出口、国内
-	 * @param stockId       库存账id
+	 * @param stockGoods       库存账
 	 * @param deliveryItems 货物明细信息
 	 */
-	public StockGoods receiving(String tradeType, Long stockId, DeliveryItems deliveryItems) {
-		//查询库存账
-		R<StockGoods> stockById = stockGoodsClient.getStockById(stockId);
-		if (!stockById.isSuccess()) {
-			throw new RuntimeException("查询库存账出错");
-		}
-		if (stockById.getData() == null) {
+	public StockGoods receiving(String tradeType, StockGoods stockGoods, DeliveryItems deliveryItems) {
+		if (stockGoods == null) {
 			throw new RuntimeException("库存账不存在");
 		}
-
-		StockGoods stockGoods = stockById.getData();
 		if (!tradeType.equals(OrderTypeEnum.DOMESTIC.getType())) {
 			stockGoods.setInQuantity(stockGoods.getInQuantity().add(deliveryItems.getActualQuantity()));//入库数量 加
 			stockGoods.setBalanceQuantity(stockGoods.getBalanceQuantity().add(deliveryItems.getActualQuantity()));//结余数量 加
@@ -1100,16 +1082,10 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
 	}
 
 	@Override
-	public StockGoods receivingInventory(String tradeType, Long id, OrderItems e) {
-		//查询库存账
-		R<StockGoods> stockById = stockGoodsClient.getStockById(id);
-		if (!stockById.isSuccess()) {
-			throw new RuntimeException("查询库存账出错");
-		}
-		if (stockById.getData() == null) {
+	public StockGoods receivingInventory(StockGoods stockGoods, OrderItems e) {
+		if (stockGoods == null) {
 			throw new RuntimeException("库存账不存在");
 		}
-		StockGoods stockGoods = stockById.getData();
 
 		if (stockGoods.getLockingQuantity().compareTo(e.getOrderQuantity()) < 0) {
 			throw new RuntimeException(stockGoods.getCode() + "更新库存总账失败,锁定库存不足");

+ 18 - 16
blade-service/blade-deliver-goods/src/main/java/org/springblade/deliver/goods/service/impl/DeliveryServiceImpl.java

@@ -815,12 +815,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 				|| "681169".equals(AuthUtil.getTenantId())) {
 				R<List<OrderItems>> r = iOrderItemsClient.selectList(select.getSrcId());
 				if (r.isSuccess() && ObjectUtils.isNotNull(r.getData())) {
-					//从缓存中获得库存
-					List<StockGoods> stockGoodsList1 = castToList(redisTemplate.opsForValue().get("stockGoods"), StockGoods.class);
-					if (stockGoodsList1.size() == 0) {
-						stockGoodsList1 = stockGoodsClient.selectStockGoodsAll();
-					}
-					List<StockGoods> finalStockGoodsList1 = stockGoodsList1;
+					List<StockGoods> finalStockGoodsList1 = stockGoodsList;
 					List<StockGoods> stockGoodsList2 = new ArrayList<>();
 					r.getData().forEach(e -> {
 						//实际库存有没有库存
@@ -843,14 +838,14 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 						if (ObjectUtils.isNotNull(sysClient.getParamService("inventory")) && "1".equals(sysClient.getParamService("inventory"))) {
 							//修改库存单 只修改库存  添加库存在上边
 							if (stock != null) {
-								StockGoods stockGoods = iDeliveryItemsService.receivingInventory(select.getTradeType(), stock.getId(), e);
+								StockGoods stockGoods = iDeliveryItemsService.receivingInventory(stock, e);
 								stockGoodsList2.add(stockGoods);
 							}
 						} else {
 							if (stock == null) {
 								throw new SecurityException("更新库存失败,未找到库存");
 							} else {
-								StockGoods stockGoods = iDeliveryItemsService.receivingInventory(select.getTradeType(), stock.getId(), e);
+								StockGoods stockGoods = iDeliveryItemsService.receivingInventory(stock, e);
 								stockGoodsList2.add(stockGoods);
 							}
 						}
@@ -954,7 +949,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 					}
 					//修改库存单
 					else {
-						StockGoods receiving = iDeliveryItemsService.receiving(select.getTradeType(), stock.getId(), e);
+						StockGoods receiving = iDeliveryItemsService.receiving(select.getTradeType(), stock, e);
 						//更新收货单明细库存
 						e.setInventoryNumber(receiving.getSurplusRouteQuantity());
 						e.setInWeight(receiving.getInWeight());
@@ -972,7 +967,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 						}
 						//修改库存单
 						else {
-							StockGoods receiving = iDeliveryItemsService.receiving(select.getTradeType(), stock.getId(), e);
+							StockGoods receiving = iDeliveryItemsService.receiving(select.getTradeType(), stock, e);
 							//更新收货单明细库存
 							e.setInventoryNumber(receiving.getSurplusRouteQuantity());
 							e.setInWeight(receiving.getInWeight());
@@ -982,7 +977,7 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 						if (stock == null) {
 							throw new SecurityException("更新库存失败,未找到库存");
 						} else {
-							StockGoods receiving = iDeliveryItemsService.receiving(select.getTradeType(), stock.getId(), e);
+							StockGoods receiving = iDeliveryItemsService.receiving(select.getTradeType(), stock, e);
 							stockGoodsList1.add(receiving);
 						}
 					}
@@ -1195,7 +1190,9 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 		List<StockGoods> stockGoodsList = castToList(redisTemplate.opsForValue().get("stockGoods"), StockGoods.class);
 		if (CollectionUtils.isNotEmpty(deliveryItemsList)) {
 			List<BusinessOverpaymentItem> list = new ArrayList<>();
-			deliveryItemsList.forEach(e -> {
+			List<StockGoods> stockGoodsList1 = new ArrayList<>();
+			List<DeliveryItems> deliveryItemsList1 = new ArrayList<>();
+			for(DeliveryItems e :deliveryItemsList){
 				if ("681169".equals(AuthUtil.getTenantId())) {
 					// ===================撤回益付款逻辑=========================
 					if (e.getPurchaseQuantity().compareTo(e.getActualQuantity()) > 0) {
@@ -1280,16 +1277,21 @@ public class DeliveryServiceImpl extends ServiceImpl<DeliveryMapper, Delivery> i
 				//达沃特新需求-禅道860中体现-国内-采购确认-不增加库存
 				if (!"GN".equals(delivery.getTradeType())) {
 					//更新stock库存数量
-					StockGoods stockGoods = iDeliveryItemsService.cancelStock(delivery.getTradeType(), stock.getId(), e);
+					StockGoods stockGoods = iDeliveryItemsService.cancelStock(delivery.getTradeType(), stock, e);
 					e.setInventoryNumber(stockGoods.getSurplusRouteQuantity());
 					e.setInWeight(stockGoods.getInWeight());
+					stockGoodsList1.add(stockGoods);
 				} else {
-					iDeliveryItemsService.cancelStock(delivery.getTradeType(), stock.getId(), e);
+					StockGoods stockGoods = iDeliveryItemsService.cancelStock(delivery.getTradeType(), stock, e);
+					stockGoodsList1.add(stockGoods);
 				}
 
 				//更新库存内容
-				iDeliveryItemsService.updateById(e);
-			});
+//				iDeliveryItemsService.updateById(e);
+				deliveryItemsList1.add(e);
+			}
+			iDeliveryItemsService.updateBatchById(deliveryItemsList1);
+			stockGoodsClient.updateStockList(stockGoodsList1);
 			if ("681169".equals(AuthUtil.getTenantId())) {
 				Long corpId = select.getCorpId();
 				// ===================撤回添加益付款逻辑=========================

+ 2 - 0
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/BidingAgentServiceImpl.java

@@ -47,6 +47,8 @@ public class BidingAgentServiceImpl extends ServiceImpl<BidingAgentMapper, Bidin
 				item.setCreateUser(SecureUtil.getUserId());
 				item.setCreateTime(new Date());
 				item.setPid(pid);
+				item.setNonEditable(null);
+				item.setStatus(0);
 				baseMapper.insert(item);
 			}else {//不为空 修改
 				item.setTenantId(SecureUtil.getTenantId());

+ 5 - 1
blade-service/blade-purchase-sales/src/main/java/org/springblade/purchase/sales/service/impl/BidingItemsServiceImpl.java

@@ -103,8 +103,12 @@ public class BidingItemsServiceImpl extends ServiceImpl<BidingItemsMapper, Bidin
 			//获得标书明细
 			List<BidingItems> bidingItemsList = baseMapper.selectListByPid(pid);
 			for (BidingItems bidingItems : bidingItemsList) {
-				if (list.stream().noneMatch(e -> e.getId().equals(bidingItems.getId()))) {
+				if (list.stream().anyMatch(e -> ObjectUtils.isNotNull(e.getId()) && !bidingItems.getId().equals(e.getId()))) {
 					list.add(bidingItems);
+				}else if (list.stream().anyMatch(e -> ObjectUtils.isNull(e.getId()))) {
+					list.add(bidingItems);
+				}else{
+					continue;
 				}
 			}
 //			list.addAll(bidingItemsList);