|
@@ -2,6 +2,7 @@ package com.fjhx.wms.service.stock.impl;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.util.ObjectUtil;
|
|
|
+import com.baomidou.dynamic.datasource.annotation.DSTransactional;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
@@ -47,6 +48,8 @@ public class StockJournalDetailsServiceImpl extends ServiceImpl<StockJournalDeta
|
|
|
private StockJournalService stockJournalService;
|
|
|
@Autowired
|
|
|
private StockJournalDetailsEditRecordService stockJournalDetailsEditRecordService;
|
|
|
+ @Autowired
|
|
|
+ private StockWaitDetailsService stockWaitDetailsService;
|
|
|
|
|
|
@Override
|
|
|
public Page<StockJournalDetailsVo> getPage(StockJournalSelectDto dto) {
|
|
@@ -145,11 +148,12 @@ public class StockJournalDetailsServiceImpl extends ServiceImpl<StockJournalDeta
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 流水数量修正
|
|
|
+ * 维多利亚流水数量修正
|
|
|
*/
|
|
|
+ @DSTransactional
|
|
|
@Override
|
|
|
- public synchronized void editQuantity(StockJournalDetails dto){
|
|
|
- Assert.notEmpty(dto.getId(),"流水明细id不能为空");
|
|
|
+ public synchronized void editQuantity(StockJournalDetails dto) {
|
|
|
+ Assert.notEmpty(dto.getId(), "流水明细id不能为空");
|
|
|
StockJournalDetails stockJournalDetails = getById(dto.getId());
|
|
|
|
|
|
//保存操作记录
|
|
@@ -162,16 +166,49 @@ public class StockJournalDetailsServiceImpl extends ServiceImpl<StockJournalDeta
|
|
|
|
|
|
//修改库存
|
|
|
StockJournal stockJournal = stockJournalService.getById(stockJournalDetails.getStockJournalId());
|
|
|
- BigDecimal subtract = stockJournalDetails.getQuantity().subtract(dto.getQuantity());
|
|
|
+ BigDecimal subtract;
|
|
|
+ if (stockJournal.getOpType() == 1) {
|
|
|
+ subtract = dto.getQuantity().subtract(stockJournalDetails.getQuantity());
|
|
|
+ } else if (stockJournal.getOpType() == 2) {
|
|
|
+ subtract = stockJournalDetails.getQuantity().subtract(dto.getQuantity());
|
|
|
+ } else {
|
|
|
+ throw new ServiceException("未知流水操作类型");
|
|
|
+ }
|
|
|
boolean update = stockService.update(q -> q
|
|
|
.eq(Stock::getProductId, stockJournalDetails.getProductId())
|
|
|
.eq(Stock::getWarehouseId, stockJournal.getWarehouseId())
|
|
|
- .setSql("quantity = quantity + " + subtract)
|
|
|
+ .setSql("victoriatourist_json = JSON_SET(victoriatourist_json,'$.frozenQuantity',ifnull(json_unquote(victoriatourist_json -> '$.frozenQuantity'), 0) + "+subtract+")")
|
|
|
+ );
|
|
|
+ if (!update) {
|
|
|
+ throw new ServiceException("操作失败请重试");
|
|
|
+ }
|
|
|
+ //修改待出入库数据
|
|
|
+ Long businessDetailsId = stockJournalDetails.getBusinessDetailsId();
|
|
|
+ Assert.notEmpty(businessDetailsId,"无法关联入库信息,操作失败");
|
|
|
+ StockWaitDetails stockWaitDetails = stockWaitDetailsService.getById(businessDetailsId);
|
|
|
+ Assert.notEmpty(stockWaitDetails,"无法查询到关联待入库信息,操作失败");
|
|
|
+ StockWait stockWait = stockWaitService.getById(stockWaitDetails.getStockWaitId());
|
|
|
+
|
|
|
+ boolean update1 = stockWaitDetailsService.update(q -> q
|
|
|
+ .eq(StockWaitDetails::getId, stockWaitDetails.getId())
|
|
|
+ .setSql("receipt_quantity = receipt_quantity+"+subtract)
|
|
|
);
|
|
|
- if (!update){
|
|
|
+ if (!update1) {
|
|
|
throw new ServiceException("操作失败请重试");
|
|
|
}
|
|
|
|
|
|
+ if (stockWait.getStatus()!=3) {
|
|
|
+ if (stockWaitDetails.getQuantity().compareTo(stockWaitDetails.getReceiptQuantity()) <= 0) {
|
|
|
+ //完全入库
|
|
|
+ stockWait.setStatus(2);
|
|
|
+ } else {
|
|
|
+ //部分入库
|
|
|
+ stockWait.setStatus(1);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ stockWaitService.updateById(stockWait);
|
|
|
+
|
|
|
stockJournalDetails.setQuantity(dto.getQuantity());
|
|
|
this.updateById(stockJournalDetails);
|
|
|
}
|