|
|
@ -1,5 +1,7 @@ |
|
|
package com.gaotao.modules.check.service.impl; |
|
|
package com.gaotao.modules.check.service.impl; |
|
|
|
|
|
|
|
|
|
|
|
import com.gaotao.common.utils.DateUtil; |
|
|
|
|
|
import com.gaotao.common.utils.DateUtils; |
|
|
import com.gaotao.modules.check.entity.*; |
|
|
import com.gaotao.modules.check.entity.*; |
|
|
import com.gaotao.modules.check.mapper.CountAdjustmentMapper; |
|
|
import com.gaotao.modules.check.mapper.CountAdjustmentMapper; |
|
|
import com.gaotao.modules.check.service.CountAdjustmentService; |
|
|
import com.gaotao.modules.check.service.CountAdjustmentService; |
|
|
@ -9,7 +11,6 @@ import com.gaotao.modules.trans.entity.TransDetailSub; |
|
|
import com.gaotao.modules.trans.entity.TransNoControl; |
|
|
import com.gaotao.modules.trans.entity.TransNoControl; |
|
|
import com.gaotao.modules.trans.service.TransNoControlService; |
|
|
import com.gaotao.modules.trans.service.TransNoControlService; |
|
|
import com.gaotao.modules.trans.service.TransHeaderService; |
|
|
import com.gaotao.modules.trans.service.TransHeaderService; |
|
|
import com.gaotao.modules.warehouse.service.InventoryStockService; |
|
|
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
import org.springframework.stereotype.Service; |
|
|
import org.springframework.stereotype.Service; |
|
|
@ -17,6 +18,7 @@ import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.StringUtils; |
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.text.ParseException; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -51,9 +53,6 @@ public class CountAdjustmentServiceImpl implements CountAdjustmentService { |
|
|
|
|
|
|
|
|
@Autowired |
|
|
@Autowired |
|
|
private TransHeaderService transHeaderService; |
|
|
private TransHeaderService transHeaderService; |
|
|
|
|
|
|
|
|
@Autowired |
|
|
|
|
|
private InventoryStockService inventoryStockService; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 检查是否有需要系统处理的异常结果 - rqrq |
|
|
* 检查是否有需要系统处理的异常结果 - rqrq |
|
|
@ -266,17 +265,8 @@ public class CountAdjustmentServiceImpl implements CountAdjustmentService { |
|
|
seqNo++; |
|
|
seqNo++; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 减少库存 - rqrq |
|
|
|
|
|
inventoryStockService.reduceStockWithLock( |
|
|
|
|
|
item.getSite(), |
|
|
|
|
|
item.getWarehouseId(), |
|
|
|
|
|
item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), |
|
|
|
|
|
item.getLocationId(), |
|
|
|
|
|
item.getDiffQty().abs(), |
|
|
|
|
|
item.getWdr(), |
|
|
|
|
|
item.getEngChgLevel() |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
// 减少库存(允许负库存)- rqrq |
|
|
|
|
|
reduceStockAllowNegative(item); |
|
|
|
|
|
|
|
|
itemNo++; |
|
|
itemNo++; |
|
|
} |
|
|
} |
|
|
@ -331,17 +321,7 @@ public class CountAdjustmentServiceImpl implements CountAdjustmentService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// 增加库存 - rqrq |
|
|
// 增加库存 - rqrq |
|
|
inventoryStockService.updateStockWithLock( |
|
|
|
|
|
item.getSite(), |
|
|
|
|
|
item.getWarehouseId(), |
|
|
|
|
|
item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), |
|
|
|
|
|
item.getLocationId(), |
|
|
|
|
|
item.getWdr(), |
|
|
|
|
|
item.getDiffQty(), |
|
|
|
|
|
"N", |
|
|
|
|
|
item.getEngChgLevel() |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
addStockAllowCreate(item); |
|
|
|
|
|
|
|
|
itemNo++; |
|
|
itemNo++; |
|
|
} |
|
|
} |
|
|
@ -360,7 +340,11 @@ public class CountAdjustmentServiceImpl implements CountAdjustmentService { |
|
|
TransHeader header = new TransHeader(); |
|
|
TransHeader header = new TransHeader(); |
|
|
header.setSite(site); |
|
|
header.setSite(site); |
|
|
header.setTransNo(transNo); |
|
|
header.setTransNo(transNo); |
|
|
header.setTransDate(new Date()); |
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
header.setTransDate(DateUtil.getDate( DateUtil.getStringDate(new Date()))); |
|
|
|
|
|
} catch (ParseException e) { |
|
|
|
|
|
header.setTransDate(new Date()); |
|
|
|
|
|
} |
|
|
header.setTransTypeDb(transType); |
|
|
header.setTransTypeDb(transType); |
|
|
header.setWarehouseId(warehouseId); |
|
|
header.setWarehouseId(warehouseId); |
|
|
header.setUserId(username); |
|
|
header.setUserId(username); |
|
|
@ -368,9 +352,9 @@ public class CountAdjustmentServiceImpl implements CountAdjustmentService { |
|
|
header.setOrderRef1(countNo); // 关联盘点单号 - rqrq |
|
|
header.setOrderRef1(countNo); // 关联盘点单号 - rqrq |
|
|
header.setRemark(transType.equals("PK") ? "盘亏处理" : "盘盈处理"); |
|
|
header.setRemark(transType.equals("PK") ? "盘亏处理" : "盘盈处理"); |
|
|
header.setStatus("COMPLETED"); |
|
|
header.setStatus("COMPLETED"); |
|
|
header.setStatusDb("COMPLETED"); |
|
|
|
|
|
|
|
|
header.setStatusDb("C"); |
|
|
header.setEnterDate(new Date()); |
|
|
header.setEnterDate(new Date()); |
|
|
header.setIfsFlag("N"); |
|
|
|
|
|
|
|
|
header.setIfsFlag("Y"); |
|
|
return header; |
|
|
return header; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -426,6 +410,68 @@ public class CountAdjustmentServiceImpl implements CountAdjustmentService { |
|
|
return sub; |
|
|
return sub; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 减少库存(允许负库存)- rqrq |
|
|
|
|
|
* |
|
|
|
|
|
* <p><b>业务规则:</b></p> |
|
|
|
|
|
* <ul> |
|
|
|
|
|
* <li>如果库存不存在,先创建一个0库存记录</li> |
|
|
|
|
|
* <li>允许负库存,不检查库存是否足够</li> |
|
|
|
|
|
* </ul> |
|
|
|
|
|
*/ |
|
|
|
|
|
private void reduceStockAllowNegative(CountAdjustmentItem item) { |
|
|
|
|
|
BigDecimal reduceQty = item.getDiffQty().abs(); |
|
|
|
|
|
|
|
|
|
|
|
// 查询库存是否存在 - rqrq |
|
|
|
|
|
int count = countAdjustmentMapper.countInventoryStock( |
|
|
|
|
|
item.getSite(), item.getWarehouseId(), item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), item.getLocationId(), item.getWdr(), item.getEngChgLevel()); |
|
|
|
|
|
|
|
|
|
|
|
if (count == 0) { |
|
|
|
|
|
// 库存不存在,先创建0库存记录 - rqrq |
|
|
|
|
|
log.info("库存不存在,创建0库存记录 - rqrq,partNo={}, locationId={}", item.getPartNo(), item.getLocationId()); |
|
|
|
|
|
countAdjustmentMapper.insertZeroStock( |
|
|
|
|
|
item.getSite(), item.getWarehouseId(), item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), item.getLocationId(), item.getWdr(), item.getEngChgLevel()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 减少库存(允许负库存)- rqrq |
|
|
|
|
|
countAdjustmentMapper.reduceStock( |
|
|
|
|
|
item.getSite(), item.getWarehouseId(), item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), item.getLocationId(), item.getWdr(), item.getEngChgLevel(), reduceQty); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 增加库存 - rqrq |
|
|
|
|
|
* |
|
|
|
|
|
* <p><b>业务规则:</b></p> |
|
|
|
|
|
* <ul> |
|
|
|
|
|
* <li>如果库存不存在,先创建一个0库存记录</li> |
|
|
|
|
|
* <li>然后增加库存数量</li> |
|
|
|
|
|
* </ul> |
|
|
|
|
|
*/ |
|
|
|
|
|
private void addStockAllowCreate(CountAdjustmentItem item) { |
|
|
|
|
|
BigDecimal addQty = item.getDiffQty(); |
|
|
|
|
|
|
|
|
|
|
|
// 查询库存是否存在 - rqrq |
|
|
|
|
|
int count = countAdjustmentMapper.countInventoryStock( |
|
|
|
|
|
item.getSite(), item.getWarehouseId(), item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), item.getLocationId(), item.getWdr(), item.getEngChgLevel()); |
|
|
|
|
|
|
|
|
|
|
|
if (count == 0) { |
|
|
|
|
|
// 库存不存在,先创建0库存记录 - rqrq |
|
|
|
|
|
log.info("库存不存在,创建0库存记录 - rqrq,partNo={}, locationId={}", item.getPartNo(), item.getLocationId()); |
|
|
|
|
|
countAdjustmentMapper.insertZeroStock( |
|
|
|
|
|
item.getSite(), item.getWarehouseId(), item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), item.getLocationId(), item.getWdr(), item.getEngChgLevel()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 增加库存 - rqrq |
|
|
|
|
|
countAdjustmentMapper.addStock( |
|
|
|
|
|
item.getSite(), item.getWarehouseId(), item.getPartNo(), |
|
|
|
|
|
item.getBatchNo(), item.getLocationId(), item.getWdr(), item.getEngChgLevel(), addQty); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 更新标签数量 - rqrq |
|
|
* 更新标签数量 - rqrq |
|
|
* |
|
|
* |
|
|
|