no message
parent
f4d01455be
commit
c17dc3c01b
|
|
@ -56,6 +56,7 @@ public class TaskServiceImpl implements TaskService {
|
|||
private final PickDetailRepository pickDetailRepository;
|
||||
private final InventoryLogService inventoryLogService;
|
||||
private final StockRepository stockRepository;
|
||||
|
||||
@Override
|
||||
public Map<String, Object> queryAll(TaskQueryCriteria criteria, Pageable pageable) {
|
||||
Page<Task> page = taskRepository.findAll((root, criteriaQuery, criteriaBuilder) -> QueryHelp.getPredicate(root, criteria, criteriaBuilder), pageable);
|
||||
|
|
@ -147,49 +148,40 @@ public class TaskServiceImpl implements TaskService {
|
|||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public synchronized void pickConfirm(Long taskId, double pickedQuantity) {
|
||||
if (taskId > 0) {
|
||||
TaskDto taskDto = findById(taskId);
|
||||
Task task = taskMapper.toEntity(taskDto);//Dto转实体
|
||||
if (task.getPlanQty() > task.getMoveQty()) {
|
||||
PickDetail pickDetail = task.getPickDetail();
|
||||
task.setMoveQty(pickedQuantity);
|
||||
task.setTaskStatus(BizStatus.FINISH);
|
||||
taskRepository.save(task);
|
||||
Inventory inv = inventoryRepository.findById(task.getInvId()).get();
|
||||
if (inv != null) {
|
||||
ItemKey itemKey = inv.getItemKey();
|
||||
Item item = itemKey.getItem();
|
||||
Dept dept = item.getDept();
|
||||
double srcQty = inv.getQuantity();
|
||||
inv.setQuantity(inv.getQuantity() - pickedQuantity);
|
||||
inv.setQueuedQty(inv.getQueuedQty() - pickedQuantity);
|
||||
inventoryRepository.save(inv);
|
||||
if (inv.getQuantity() <= 0) {
|
||||
inventoryRepository.delete(inv);
|
||||
}
|
||||
Stock stock = inv.getStock();
|
||||
stock.setStatus(BaseStatus.FREE);
|
||||
stockRepository.save(stock);
|
||||
//添加库存日志
|
||||
inventoryLogService.storeInventoryLog(BizStatus.PICK_DOWN, BizStatus.REDUCE, task.getPickDetail().getPo(), task.getItemKey(), task.getSrcPoint(), task.getDstPoint(), task.getSrcStock(), task.getDstStock(), srcQty, pickedQuantity, BizStatus.PICK, task.getId(), inv.getId(), "");
|
||||
|
||||
//刷新出库明细上的拣货数量
|
||||
pickDetail.setPickedQty(pickDetail.getPickedQty() + pickedQuantity);
|
||||
if (pickDetail.getOrderQty().equals(pickDetail.getPickedQty())) {
|
||||
pickDetail.setStatus(BizStatus.PICK_ALL);
|
||||
} else if (pickDetail.getAllocatedQty() > 0 && pickDetail.getOrderQty() - pickDetail.getPickedQty() > 0) {
|
||||
pickDetail.setStatus(BizStatus.PICKUP);
|
||||
}
|
||||
pickDetailRepository.save(pickDetail);
|
||||
|
||||
} else {
|
||||
throw new BadRequestException("未找到库存相应记录!");
|
||||
TaskDto taskDto = findById(taskId);
|
||||
Task task = taskMapper.toEntity(taskDto);//Dto转实体
|
||||
if (task.getPlanQty() > task.getMoveQty()) {
|
||||
PickDetail pickDetail = task.getPickDetail();
|
||||
task.setMoveQty(pickedQuantity);
|
||||
task.setTaskStatus(BizStatus.FINISH);
|
||||
taskRepository.save(task);
|
||||
Inventory inv = inventoryRepository.findById(task.getInvId()).get();
|
||||
if (inv != null) {
|
||||
inv.setQuantity(inv.getQuantity() - pickedQuantity);
|
||||
inv.setQueuedQty(inv.getQueuedQty() - pickedQuantity);
|
||||
inventoryRepository.save(inv);
|
||||
if (inv.getQuantity() <= 0) {
|
||||
inventoryRepository.delete(inv);
|
||||
}
|
||||
}
|
||||
Stock stock = inv.getStock();
|
||||
stock.setStatus(BaseStatus.FREE);
|
||||
stockRepository.save(stock);
|
||||
//添加库存日志
|
||||
inventoryLogService.storeInventoryLog(BizStatus.PICK_DOWN, BizStatus.REDUCE, task.getPickDetail().getPo(), task.getItemKey(), task.getSrcPoint(), task.getDstPoint(), task.getSrcStock(), task.getDstStock(), inv.getQuantity(), pickedQuantity, BizStatus.PICK, task.getId(), inv.getId(), "");
|
||||
|
||||
} else {
|
||||
throw new BadRequestException("参数错误或为空");
|
||||
|
||||
}
|
||||
//刷新出库明细上的拣货数量
|
||||
pickDetail.setPickedQty(pickDetail.getPickedQty() + pickedQuantity);
|
||||
if (pickDetail.getOrderQty().equals(pickDetail.getPickedQty())) {
|
||||
pickDetail.setStatus(BizStatus.PICK_ALL);
|
||||
} else if (pickDetail.getAllocatedQty() > 0 && pickDetail.getOrderQty() - pickDetail.getPickedQty() > 0) {
|
||||
pickDetail.setStatus(BizStatus.PICKUP);
|
||||
}
|
||||
pickDetailRepository.save(pickDetail);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
Loading…
Reference in New Issue