|
@@ -19,16 +19,14 @@ import com.fjhx.file.utils.ObsFileUtil;
|
|
|
import com.fjhx.item.entity.product.bo.ProductAnalysisBo;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoDto;
|
|
|
import com.fjhx.item.entity.product.dto.ProductInfoSelectDto;
|
|
|
-import com.fjhx.item.entity.product.po.ProductAvailableRecord;
|
|
|
-import com.fjhx.item.entity.product.po.ProductClassify;
|
|
|
-import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
-import com.fjhx.item.entity.product.po.ProductInfoEhsdExcel;
|
|
|
+import com.fjhx.item.entity.product.po.*;
|
|
|
import com.fjhx.item.entity.product.vo.ProductInfoVo;
|
|
|
import com.fjhx.item.enums.ProductAvailableRecordType;
|
|
|
import com.fjhx.item.mapper.product.ProductInfoMapper;
|
|
|
import com.fjhx.item.service.product.ProductAvailableRecordService;
|
|
|
import com.fjhx.item.service.product.ProductClassifyService;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
+import com.fjhx.item.service.product.ProductStockInfoService;
|
|
|
import com.fjhx.item.util.CodeEnum;
|
|
|
import com.fjhx.item.util.excel.util.ExcelUtil;
|
|
|
import com.fjhx.tenant.entity.dict.dto.DictTenantDataSelectDto;
|
|
@@ -79,6 +77,8 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
private ProductAvailableRecordService productAvailableRecordService;
|
|
|
@Autowired
|
|
|
private ISysDeptService sysDeptService;
|
|
|
+ @Autowired
|
|
|
+ private ProductStockInfoService productStockInfoService;
|
|
|
|
|
|
@Override
|
|
|
public Page<ProductInfoVo> getPage(ProductInfoSelectDto dto) {
|
|
@@ -299,21 +299,34 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
*/
|
|
|
@DSTransactional
|
|
|
@Override
|
|
|
- public synchronized void editAvailableQuantity(List<InOutBo> inOutList, InOutType inOutType, Long businessId, ProductAvailableRecordType businessType) {
|
|
|
+ public synchronized void editAvailableQuantity(List<InOutBo> inOutList, InOutType inOutType, Long businessId, ProductAvailableRecordType businessType, Long companyId) {
|
|
|
+
|
|
|
List<Long> pIds = inOutList.stream().map(InOutBo::getProductId).collect(Collectors.toList());
|
|
|
if (ObjectUtil.isEmpty(pIds)) {
|
|
|
return;
|
|
|
}
|
|
|
- Map<Long, ProductInfo> productInfoMap = this.mapKEntity(ProductInfo::getId, q -> q.in(ProductInfo::getId, pIds));
|
|
|
+ //获取合同归属归属的物料可用库存
|
|
|
+ Map<Long, ProductStockInfo> availableQuantityMap = productStockInfoService.mapKEntity(ProductStockInfo::getId, q -> q
|
|
|
+ .in(ProductStockInfo::getProductId, pIds)
|
|
|
+ .eq(ProductStockInfo::getCompanyId, companyId)
|
|
|
+ );
|
|
|
|
|
|
List<ProductAvailableRecord> availableRecordList = new ArrayList<>();
|
|
|
for (InOutBo inOutBo : inOutList) {
|
|
|
- ProductInfo productInfo = productInfoMap.get(inOutBo.getProductId());
|
|
|
+ ProductStockInfo productStockInfo = availableQuantityMap.get(inOutBo.getProductId());
|
|
|
+ if (ObjectUtil.isEmpty(productStockInfo)) {
|
|
|
+ productStockInfo = new ProductStockInfo();
|
|
|
+ productStockInfo.setAvailableQuantity(BigDecimal.ZERO);
|
|
|
+ productStockInfo.setCompanyId(companyId);
|
|
|
+ productStockInfo.setProductId(inOutBo.getProductId());
|
|
|
+ productStockInfoService.save(productStockInfo);
|
|
|
+ availableQuantityMap.put(inOutBo.getProductId(), productStockInfo);
|
|
|
+ }
|
|
|
|
|
|
BigDecimal availableQuantityNew;
|
|
|
BigDecimal edQuantity = inOutBo.getQuantity();
|
|
|
|
|
|
- BigDecimal availableQuantity = productInfo.getAvailableQuantity();
|
|
|
+ BigDecimal availableQuantity = productStockInfo.getAvailableQuantity();
|
|
|
|
|
|
if (inOutType.equals(InOutType.IN)) {
|
|
|
availableQuantityNew = availableQuantity.add(inOutBo.getQuantity());
|
|
@@ -327,20 +340,23 @@ public class ProductInfoServiceImpl extends ServiceImpl<ProductInfoMapper, Produ
|
|
|
throw new ServiceException("未知类型");
|
|
|
}
|
|
|
|
|
|
- this.update(q -> q
|
|
|
- .eq(ProductInfo::getId, productInfo.getId())
|
|
|
- .set(ProductInfo::getAvailableQuantity, availableQuantityNew)
|
|
|
+ Long productStockInfoId = productStockInfo.getId();
|
|
|
+ productStockInfoService.update(q -> q
|
|
|
+ .eq(ProductStockInfo::getId, productStockInfoId)
|
|
|
+ .set(ProductStockInfo::getAvailableQuantity, availableQuantityNew)
|
|
|
.set(BasePo::getUpdateTime, new Date())
|
|
|
.set(BasePo::getUpdateUser, SecurityUtils.getUserId())
|
|
|
);
|
|
|
|
|
|
//保存操作记录
|
|
|
ProductAvailableRecord productAvailableRecord = new ProductAvailableRecord();
|
|
|
- productAvailableRecord.setBeforeQuantity(productInfo.getAvailableQuantity());
|
|
|
+ productAvailableRecord.setBeforeQuantity(productStockInfo.getAvailableQuantity());
|
|
|
productAvailableRecord.setAfterQuantity(availableQuantityNew);
|
|
|
productAvailableRecord.setEditQuantity(edQuantity);
|
|
|
productAvailableRecord.setBusinessId(businessId);
|
|
|
productAvailableRecord.setBusinessType(businessType.getType());
|
|
|
+ productAvailableRecord.setProductId(inOutBo.getProductId());
|
|
|
+ productAvailableRecord.setCompanyId(companyId);
|
|
|
|
|
|
availableRecordList.add(productAvailableRecord);
|
|
|
}
|