| | |
| | | import java.math.BigDecimal; |
| | | import java.util.*; |
| | | import java.util.stream.Collectors; |
| | | import java.util.Date; |
| | | |
| | | @Service |
| | | public class PdaOutStockServiceImpl implements PdaOutStockService { |
| | |
| | | TaskItem item = taskItemService.getById(taskItem.getId()); |
| | | //判断是否允许超收,不允许超收添加拒收判断 |
| | | if (!Objects.isNull(config)) { |
| | | LocItemWorking serviceOne = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getFieldsIndex, item.getFieldsIndex())); |
| | | TaskItem serviceOne = taskItemService.getOne(new LambdaQueryWrapper<TaskItem>() |
| | | .eq(TaskItem::getTaskId, task.getId()) |
| | | .eq(TaskItem::getFieldsIndex, item.getFieldsIndex())); |
| | | if (Objects.isNull(serviceOne)) { |
| | | throw new CoolException("缓存数据丢失!!"); |
| | | } |
| | | LocItemWorking workItem = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() |
| | | .eq(LocItemWorking::getTaskId, task.getId()) |
| | | .eq(LocItemWorking::getFieldsIndex, item.getFieldsIndex())); |
| | | if (Objects.isNull(workItem)) { |
| | | throw new CoolException("缓存数据丢失!!"); |
| | | } |
| | | Double v1 = Math.round((workItem.getAnfme() - serviceOne.getQty()) * 1000000) / 1000000.0; |
| | | //不管是否允许超收,都需判断是否超出库存范围 |
| | | if (taskItem.getAnfme().compareTo(serviceOne.getAnfme()) > 0) { |
| | | if (taskItem.getAnfme().compareTo(v1) > 0) { |
| | | throw new CoolException("拣货数量超出当前票号库存数量!!"); |
| | | } |
| | | |
| | | if (!Boolean.parseBoolean(config.getVal())) { |
| | | Double v = Math.round((item.getQty() + taskItem.getAnfme()) * 1000000) / 1000000.0; |
| | | if (item.getAnfme().compareTo(v) < 0.0) { |
| | |
| | | if (!taskItemService.updateById(item)) { |
| | | throw new CoolException("状态完成失败!!"); |
| | | } |
| | | |
| | | // 扣减库位明细库存(与出库完成逻辑保持一致) |
| | | if (StringUtils.isNotBlank(task.getOrgLoc())) { |
| | | LocItem locItem = locItemService.getOne(new LambdaQueryWrapper<LocItem>() |
| | | .eq(LocItem::getLocCode, task.getOrgLoc()) |
| | | .eq(LocItem::getMatnrId, item.getMatnrId()) |
| | | .eq(StringUtils.isNotBlank(item.getBatch()), LocItem::getBatch, item.getBatch()) |
| | | .eq(StringUtils.isNotBlank(item.getFieldsIndex()), LocItem::getFieldsIndex, item.getFieldsIndex())); |
| | | |
| | | if (Objects.nonNull(locItem)) { |
| | | // 使用实际拣货数量(taskItem.getAnfme())扣减库位明细 |
| | | Double newAnfme = Math.round((locItem.getAnfme() - taskItem.getAnfme()) * 1000000) / 1000000.0; |
| | | |
| | | if (newAnfme.compareTo(0.0) <= 0) { |
| | | // 数量小于等于0,删除库位明细 |
| | | locItemService.removeById(locItem.getId()); |
| | | } else { |
| | | // 更新库位明细数量 |
| | | locItem.setAnfme(newAnfme) |
| | | .setUpdateBy(SystemAuthUtils.getLoginUserId()) |
| | | .setUpdateTime(new Date()); |
| | | if (!locItemService.updateById(locItem)) { |
| | | throw new CoolException("库位明细数量扣减失败!!"); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | StockItem stockItem = new StockItem(); |
| | | BeanUtils.copyProperties(item, stockItem); |
| | | //taskItem为上报数据 |
| | |
| | | throw new CoolException("任务明细修改失败"); |
| | | } |
| | | LocItemWorking oldOne = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() |
| | | .eq(LocItemWorking::getTaskId, byId.getTaskId()) |
| | | .eq(LocItemWorking::getMatnrCode, byId.getMatnrCode()) |
| | | .eq(LocItemWorking::getFieldsIndex, byId.getFieldsIndex())); |
| | | if (Objects.isNull(oldOne)) { |
| | | throw new CoolException("明细不存在或已出库!!"); |
| | | } |
| | | LocItemWorking one = locItemWorkingService.getOne(new LambdaQueryWrapper<LocItemWorking>() |
| | | .eq(LocItemWorking::getMatnrCode, byId.getMatnrCode()) |
| | | .eq(LocItemWorking::getTaskId, byId.getTaskId()) |
| | | .eq(LocItemWorking::getMatnrCode, byId.getMatnrCode()) |
| | | .eq(LocItemWorking::getFieldsIndex, uuid)); |
| | | if (Objects.isNull(one)) { |
| | | throw new CoolException("明细不存在或已出库!!"); |