|
@@ -2,15 +2,14 @@ package com.fjhx.wms.service.stock.impl;
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
-import com.alibaba.fastjson.JSONArray;
|
|
|
|
-import com.alibaba.fastjson.JSONObject;
|
|
|
|
|
|
+import com.alibaba.fastjson2.JSONArray;
|
|
|
|
+import com.alibaba.fastjson2.JSONObject;
|
|
import com.alibaba.fastjson2.JSONWriter;
|
|
import com.alibaba.fastjson2.JSONWriter;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
import com.fjhx.item.entity.product.po.ProductClassify;
|
|
import com.fjhx.item.entity.product.po.ProductClassify;
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
import com.fjhx.item.entity.product.po.ProductInfo;
|
|
-import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
|
|
import com.fjhx.item.service.product.ProductClassifyService;
|
|
import com.fjhx.item.service.product.ProductClassifyService;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
import com.fjhx.wms.entity.stock.bo.InOutBo;
|
|
import com.fjhx.wms.entity.stock.bo.InOutBo;
|
|
@@ -33,7 +32,6 @@ import com.fjhx.wms.utils.CodeEnum;
|
|
import com.obs.services.internal.ServiceException;
|
|
import com.obs.services.internal.ServiceException;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
import com.ruoyi.common.core.domain.BaseIdPo;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
import com.ruoyi.common.utils.wrapper.IWrapper;
|
|
-import com.ruoyi.common.utils.wrapper.SqlField;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
@@ -73,11 +71,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
wrapper.eq(Stock::getWarehouseId, dto.getId());
|
|
wrapper.eq(Stock::getWarehouseId, dto.getId());
|
|
// wrapper.like(Stock::getQuantity, dto.getKeyword());
|
|
// wrapper.like(Stock::getQuantity, dto.getKeyword());
|
|
String keyword = dto.getKeyword();
|
|
String keyword = dto.getKeyword();
|
|
- if(ObjectUtil.isNotEmpty(keyword)) {
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(keyword)) {
|
|
//根据 库存数量 产品自定义编码 产品名称 过滤
|
|
//根据 库存数量 产品自定义编码 产品名称 过滤
|
|
List<Long> productIds = productInfoService.listObject(ProductInfo::getId,
|
|
List<Long> productIds = productInfoService.listObject(ProductInfo::getId,
|
|
q -> q.like(ProductInfo::getCustomCode, keyword).or().like(ProductInfo::getName, keyword));
|
|
q -> q.like(ProductInfo::getCustomCode, keyword).or().like(ProductInfo::getName, keyword));
|
|
- wrapper.and(q->q.like(Stock::getQuantity,keyword).or().in(Stock::getProductId,productIds));
|
|
|
|
|
|
+ wrapper.and(q -> q.like(Stock::getQuantity, keyword).or().in(Stock::getProductId, productIds));
|
|
}
|
|
}
|
|
wrapper.in(Stock::getProductId, dto.getProductIds());
|
|
wrapper.in(Stock::getProductId, dto.getProductIds());
|
|
wrapper.eq("pi.definition", dto.getDefinition());
|
|
wrapper.eq("pi.definition", dto.getDefinition());
|
|
@@ -154,7 +152,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
|
|
BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
|
|
defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
|
|
defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
- item.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ item.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
});
|
|
});
|
|
}
|
|
}
|
|
|
|
|
|
@@ -179,7 +177,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
|
|
JSONObject json = ObjectUtil.isNotEmpty(victoriatouristJson) ? JSONObject.parseObject(victoriatouristJson) : new JSONObject();
|
|
String warehouseName = warehouseMap.get(json.getLong("warehouseId"));
|
|
String warehouseName = warehouseMap.get(json.getLong("warehouseId"));
|
|
json.put("warehouseName", warehouseName);
|
|
json.put("warehouseName", warehouseName);
|
|
- stockVo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ stockVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
}
|
|
}
|
|
return page;
|
|
return page;
|
|
}
|
|
}
|
|
@@ -191,11 +189,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
wrapper.eq(Stock::getWarehouseId, dto.getId());
|
|
wrapper.eq(Stock::getWarehouseId, dto.getId());
|
|
// wrapper.like(Stock::getQuantity, dto.getKeyword());
|
|
// wrapper.like(Stock::getQuantity, dto.getKeyword());
|
|
String keyword = dto.getKeyword();
|
|
String keyword = dto.getKeyword();
|
|
- if(ObjectUtil.isNotEmpty(keyword)) {
|
|
|
|
|
|
+ if (ObjectUtil.isNotEmpty(keyword)) {
|
|
//根据 库存数量 产品自定义编码 产品名称 过滤
|
|
//根据 库存数量 产品自定义编码 产品名称 过滤
|
|
List<Long> productIds = productInfoService.listObject(ProductInfo::getId,
|
|
List<Long> productIds = productInfoService.listObject(ProductInfo::getId,
|
|
q -> q.like(ProductInfo::getCustomCode, keyword).or().like(ProductInfo::getName, keyword));
|
|
q -> q.like(ProductInfo::getCustomCode, keyword).or().like(ProductInfo::getName, keyword));
|
|
- wrapper.and(q->q.like(Stock::getQuantity,keyword).or().in(Stock::getProductId,productIds));
|
|
|
|
|
|
+ wrapper.and(q -> q.like(Stock::getQuantity, keyword).or().in(Stock::getProductId, productIds));
|
|
}
|
|
}
|
|
wrapper.eq("pi.definition", dto.getDefinition());
|
|
wrapper.eq("pi.definition", dto.getDefinition());
|
|
wrapper.groupBy("s.product_id");
|
|
wrapper.groupBy("s.product_id");
|
|
@@ -211,7 +209,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
BigDecimal defectiveQuantity = stockVo.getDefectiveQuantity();
|
|
BigDecimal defectiveQuantity = stockVo.getDefectiveQuantity();
|
|
defectiveQuantity = defectiveQuantity == null ? BigDecimal.ZERO : defectiveQuantity;
|
|
defectiveQuantity = defectiveQuantity == null ? BigDecimal.ZERO : defectiveQuantity;
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
- stockVo.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ stockVo.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
}
|
|
}
|
|
|
|
|
|
//赋值产品名称
|
|
//赋值产品名称
|
|
@@ -239,7 +237,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
|
|
BigDecimal defectiveQuantity = json.getBigDecimal("defectiveQuantity");
|
|
defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
|
|
defectiveQuantity = ObjectUtil.isEmpty(defectiveQuantity) ? BigDecimal.ZERO : defectiveQuantity;
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
- item.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ item.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
});
|
|
});
|
|
|
|
|
|
//赋值产品分类
|
|
//赋值产品分类
|
|
@@ -394,6 +392,11 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
|
|
|
|
List<StockJournalDetails> stockJournalDetailsList = new ArrayList<>();
|
|
List<StockJournalDetails> stockJournalDetailsList = new ArrayList<>();
|
|
for (Stock stock : list) {
|
|
for (Stock stock : list) {
|
|
|
|
+ //忽略操作数量为0的记录 避免出现出入库记录为0的条目
|
|
|
|
+ if (BigDecimal.ZERO.compareTo(stock.getQuantity()) == 0) {
|
|
|
|
+ continue;
|
|
|
|
+ }
|
|
|
|
+
|
|
Stock oldStocks = stockMap.get(stock.getProductId());
|
|
Stock oldStocks = stockMap.get(stock.getProductId());
|
|
//如果库存不存在 就创建一条空库存
|
|
//如果库存不存在 就创建一条空库存
|
|
if (ObjectUtil.isEmpty(oldStocks)) {
|
|
if (ObjectUtil.isEmpty(oldStocks)) {
|
|
@@ -426,7 +429,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
frozenQuantity = frozenQuantity == null ? BigDecimal.ZERO : frozenQuantity;
|
|
frozenQuantity = frozenQuantity == null ? BigDecimal.ZERO : frozenQuantity;
|
|
frozenQuantity = frozenQuantity.add(stock.getQuantity());
|
|
frozenQuantity = frozenQuantity.add(stock.getQuantity());
|
|
json.put("frozenQuantity", frozenQuantity);
|
|
json.put("frozenQuantity", frozenQuantity);
|
|
- oldStocks.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ oldStocks.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
} else if (type == 4) {
|
|
} else if (type == 4) {
|
|
//维多利亚待出库操作次品库存
|
|
//维多利亚待出库操作次品库存
|
|
String victoriatouristJson = oldStocks.getVictoriatouristJson();
|
|
String victoriatouristJson = oldStocks.getVictoriatouristJson();
|
|
@@ -442,7 +445,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
throw new ServiceException("以下商品次品库存不足,无法出库:" + productInfo.getName());
|
|
throw new ServiceException("以下商品次品库存不足,无法出库:" + productInfo.getName());
|
|
}
|
|
}
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
json.put("defectiveQuantity", defectiveQuantity);
|
|
- oldStocks.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ oldStocks.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
} else {
|
|
} else {
|
|
throw new ServiceException("未知库存操作类型");
|
|
throw new ServiceException("未知库存操作类型");
|
|
}
|
|
}
|
|
@@ -482,7 +485,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
}
|
|
}
|
|
stock1.setQuantity(quantity.add(stock.getQuantity()));
|
|
stock1.setQuantity(quantity.add(stock.getQuantity()));
|
|
json.put("defectiveQuantity", defectiveQuantity.subtract(stock.getQuantity()));
|
|
json.put("defectiveQuantity", defectiveQuantity.subtract(stock.getQuantity()));
|
|
- stock1.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ stock1.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
updateById(stock1);
|
|
updateById(stock1);
|
|
}
|
|
}
|
|
|
|
|
|
@@ -521,7 +524,7 @@ public class StockServiceImpl extends ServiceImpl<StockMapper, Stock> implements
|
|
}
|
|
}
|
|
stock1.setQuantity(quantity.subtract(stock.getQuantity()));
|
|
stock1.setQuantity(quantity.subtract(stock.getQuantity()));
|
|
json.put("defectiveQuantity", defectiveQuantity.add(stock.getQuantity()));
|
|
json.put("defectiveQuantity", defectiveQuantity.add(stock.getQuantity()));
|
|
- stock1.setVictoriatouristJson(json.toJSONString(JSONWriter.Feature.WriteLongAsString));
|
|
|
|
|
|
+ stock1.setVictoriatouristJson(JSONObject.toJSONString(json, JSONWriter.Feature.WriteLongAsString));
|
|
updateById(stock1);
|
|
updateById(stock1);
|
|
}
|
|
}
|
|
|
|
|