|
|
@@ -22,6 +22,7 @@ import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.trade.purchase.order.enums.OrderTypeEnum;
|
|
|
import lombok.AllArgsConstructor;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springblade.client.entity.CorpsDesc;
|
|
|
import org.springblade.client.feign.ICorpsDescClient;
|
|
|
import org.springblade.client.feign.IGoodsDescClient;
|
|
|
@@ -54,6 +55,7 @@ import org.springblade.stock.feign.IStockGoodsClient;
|
|
|
import org.springblade.stock.vo.StockGoodsVO;
|
|
|
import org.springblade.system.user.entity.User;
|
|
|
import org.springblade.system.user.feign.IUserClient;
|
|
|
+import org.springframework.data.redis.core.RedisTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.math.BigDecimal;
|
|
|
@@ -72,6 +74,7 @@ import java.util.stream.Collectors;
|
|
|
*/
|
|
|
@Service
|
|
|
@AllArgsConstructor
|
|
|
+@Slf4j
|
|
|
public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, DeliveryItems> implements IDeliveryItemsService {
|
|
|
|
|
|
private IUserClient iUserClient;//获取用户信息
|
|
|
@@ -84,6 +87,7 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
private final IBusinessOverpaymentClient businessOverpaymentClient;
|
|
|
//获取客户信息
|
|
|
private final ICorpsDescClient corpsDescClient;
|
|
|
+ private final RedisTemplate<String, Object> redisTemplate;
|
|
|
@Override
|
|
|
public IPage<DeliveryItemsVO> selectDeliveryItemsPage(IPage<DeliveryItemsVO> page, DeliveryItemsVO deliveryItems) {
|
|
|
return page.setRecords(baseMapper.selectDeliveryItemsPage(page, deliveryItems));
|
|
|
@@ -375,8 +379,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
}
|
|
|
stockGoods.setUpdateTime(new Date());
|
|
|
stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
- R updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
- if (!updateStock.isSuccess()){
|
|
|
+ boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ if (!updateStock){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
return stockGoods;
|
|
|
@@ -428,8 +432,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
}
|
|
|
stockGoods.setUpdateTime(new Date());
|
|
|
stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
- R updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
- if (!updateStock.isSuccess()){
|
|
|
+ boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ if (!updateStock){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
return stockGoods;
|
|
|
@@ -481,8 +485,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
|
|
|
stockGoods.setUpdateTime(new Date());
|
|
|
stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
- R updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
- if (!updateStock.isSuccess()) {
|
|
|
+ boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ if (!updateStock) {
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
return stockGoods;
|
|
|
@@ -526,8 +530,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
stockGoods.setCntrNo(deliveryItems.getCntrNo());
|
|
|
stockGoods.setUpdateTime(new Date());
|
|
|
stockGoods.setUpdateUser(SecureUtil.getUserId());
|
|
|
- R updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
- if (!updateStock.isSuccess()) {
|
|
|
+ boolean updateStock = stockGoodsClient.updateStock(stockGoods);
|
|
|
+ if (!updateStock) {
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
return stockGoods;
|
|
|
@@ -796,8 +800,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
stock.setBalanceQuantity(stock.getInQuantity().subtract(stock.getOutQuantity()));//结余数量 减
|
|
|
//出库金额加
|
|
|
stock.setOutAmount(stock.getOutAmount().add((stock.getInAmount().divide(stock.getInQuantity(), 5, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP).multiply(deliveryItems.getActualQuantity())));
|
|
|
- R updateStock = stockGoodsClient.updateStock(stock);
|
|
|
- if (!updateStock.isSuccess()){
|
|
|
+ boolean updateStock = stockGoodsClient.updateStock(stock);
|
|
|
+ if (!updateStock){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
//新仓库添加库存
|
|
|
@@ -812,8 +816,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
serviceStock.setBalanceQuantity(serviceStock.getInQuantity().add(serviceStock.getOutQuantity()));//结余数量 加
|
|
|
//入库金额加
|
|
|
serviceStock.setInAmount(serviceStock.getInAmount().add((stock.getInAmount().divide(stock.getInQuantity(), 5, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP).multiply(deliveryItems.getActualQuantity())));
|
|
|
- R stockMessage = stockGoodsClient.updateStock(serviceStock);
|
|
|
- if (!stockMessage.isSuccess()){
|
|
|
+ boolean stockMessage = stockGoodsClient.updateStock(serviceStock);
|
|
|
+ if (!stockMessage){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
}
|
|
|
@@ -838,8 +842,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
//出库金额减
|
|
|
serviceStock.setOutAmount(serviceStock.getOutAmount().subtract((serviceStock.getInAmount().divide(serviceStock.getInQuantity(), 5, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP).multiply(deliveryItems.getActualQuantity())));
|
|
|
|
|
|
- R stockMessage = stockGoodsClient.updateStock(serviceStock);
|
|
|
- if (!stockMessage.isSuccess()){
|
|
|
+ boolean stockMessage = stockGoodsClient.updateStock(serviceStock);
|
|
|
+ if (!stockMessage){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
}
|
|
|
@@ -850,8 +854,8 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
//入库金额减
|
|
|
stock.setInAmount(stock.getInAmount().subtract((serviceStock.getInAmount().divide(serviceStock.getInQuantity(), 5, RoundingMode.HALF_UP)).setScale(2, RoundingMode.HALF_UP).multiply(deliveryItems.getActualQuantity())));
|
|
|
|
|
|
- R updateStock = stockGoodsClient.updateStock(stock);
|
|
|
- if (!updateStock.isSuccess()){
|
|
|
+ boolean updateStock = stockGoodsClient.updateStock(stock);
|
|
|
+ if (!updateStock){
|
|
|
throw new RuntimeException("更新库存总账失败");
|
|
|
}
|
|
|
}
|
|
|
@@ -900,4 +904,25 @@ public class DeliveryItemsServiceImpl extends ServiceImpl<DeliveryItemsMapper, D
|
|
|
}
|
|
|
return false;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 将Object转换成List类型
|
|
|
+ *
|
|
|
+ * @param obj Object对象
|
|
|
+ * @param clazz 数据类型
|
|
|
+ * @param <T> 泛型类型
|
|
|
+ * @return List类型
|
|
|
+ */
|
|
|
+ public static <T> List<T> castToList(Object obj, Class<T> clazz) {
|
|
|
+ List<T> resList = new ArrayList<>();
|
|
|
+ // 如果不是List<?>对象,是没有办法转换的
|
|
|
+ if (obj instanceof List<?>) {
|
|
|
+ for (Object o : (List<?>) obj) {
|
|
|
+ // 将对应的元素进行类型转换
|
|
|
+ resList.add(clazz.cast(o));
|
|
|
+ }
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
+ return resList;
|
|
|
+ }
|
|
|
}
|