| | |
| | | import com.vincent.rsf.server.api.entity.dto.ContainerWaveDto; |
| | | import com.vincent.rsf.server.api.service.PdaOutStockService; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.TaskStsType; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.stereotype.Service; |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import javax.annotation.Resource; |
| | | import java.math.BigDecimal; |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | |
| | | if (null == task){ |
| | | throw new CoolException("未找到容器号对应任务"); |
| | | } |
| | | if (task.getTaskStatus().equals(TaskStsType.COMPLETE_OUT.id)){ |
| | | throw new CoolException("当前状态为不可拣货状态"); |
| | | } |
| | | ArrayList<ContainerWaveDto> containerWaveDtos = new ArrayList<>(); |
| | | List<TaskItem> taskItems = taskItemService.list(new LambdaQueryWrapper<TaskItem>().eq(TaskItem::getTaskId, task.getId())); |
| | | for (TaskItem taskItem : taskItems) { |
| | |
| | | AsnOrderItem orderItem = asnOrderItemService.getOne(new LambdaQueryWrapper<AsnOrderItem>() |
| | | .eq(AsnOrderItem::getAsnId, asnOrder.getId()) |
| | | .eq(AsnOrderItem::getMatnrCode, taskItem.getMatnrCode()) |
| | | .eq(AsnOrderItem::getBatch, taskItem.getBatch()) |
| | | .eq(AsnOrderItem::getSplrBatch, taskItem.getBatch()) |
| | | ); |
| | | if (null != orderItem){ |
| | | list.add(orderItem); |
| | |
| | | |
| | | return R.ok(containerWaveDtos); |
| | | } |
| | | |
| | | @Override |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public R saveWavePick(List<ContainerWaveDto> containerWaveDtos) { |
| | | if (null == containerWaveDtos || containerWaveDtos.size() <= 0){ |
| | | return R.error("参数错误"); |
| | | } |
| | | Task task = taskService.getById(containerWaveDtos.get(0).getTaskItem().getTaskId()); |
| | | if (null == task){ |
| | | return R.error("未找到托盘对应的任务"); |
| | | } |
| | | |
| | | for (ContainerWaveDto containerWaveDto : containerWaveDtos) { |
| | | //做一次校验,判断前端所有出库数量是否超过本托出库数量 |
| | | double sum = containerWaveDto.getAsnOrderItems().stream().mapToDouble(AsnOrderItem::getDemandQty).sum(); |
| | | BigDecimal total = new BigDecimal(String.valueOf(sum)); |
| | | BigDecimal anfme = new BigDecimal(containerWaveDto.getTaskItem().getAnfme().toString()); |
| | | if (!anfme.equals(total)){ |
| | | throw new CoolException("播种数量不等于容器出库数量,请检查"); |
| | | } |
| | | for (AsnOrderItem orderItem : containerWaveDto.getAsnOrderItems()) { |
| | | BigDecimal num = new BigDecimal(orderItem.getWorkQty().toString()).subtract(new BigDecimal(orderItem.getQty().toString())); |
| | | BigDecimal orderDemandQty = new BigDecimal(orderItem.getDemandQty().toString()); |
| | | if (num.compareTo(orderDemandQty) < 0){ |
| | | throw new CoolException("播种数量大于单据出库数量,请检查"); |
| | | } |
| | | orderItem.setQty(new BigDecimal(orderItem.getQty().toString()).add(orderDemandQty).doubleValue()); |
| | | if (!asnOrderItemService.updateById(orderItem)){ |
| | | throw new CoolException("单据明细更新失败"); |
| | | } |
| | | } |
| | | } |
| | | |
| | | task.setTaskStatus(TaskStsType.COMPLETE_OUT.id); |
| | | if (!taskService.updateById(task)){ |
| | | throw new CoolException("任务状态更新失败"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | } |