| | |
| | | package com.vincent.rsf.server.manager.service.impl; |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.controller.erp.params.TaskInParam; |
| | | import com.vincent.rsf.server.api.entity.dto.InTaskMsgDto; |
| | |
| | | private BasStationService basStationService; |
| | | @Autowired |
| | | private LocItemWorkingService locItemWorkingService; |
| | | @Autowired |
| | | private CheckDiffService checkDiffService; |
| | | @Autowired |
| | | private CheckDiffItemService checkDiffItemService; |
| | | |
| | | |
| | | /** |
| | |
| | | @Synchronized |
| | | @Transactional(rollbackFor = Exception.class) |
| | | public synchronized void generateTask(Short resouce, LocToTaskParams map, Long loginUserId) throws Exception { |
| | | if (Objects.isNull(map.getSiteNo())) { |
| | | throw new CoolException("站点不能为空!"); |
| | | } |
| | | // if (Objects.isNull(map.getSiteNo())) { |
| | | // throw new CoolException("站点不能为空!"); |
| | | // } |
| | | if (Objects.isNull(map.getItems()) || map.getItems().isEmpty()) { |
| | | throw new CoolException("明细不能为空!"); |
| | | } |
| | |
| | | throw new CoolException("库位状态更新失败!!"); |
| | | } |
| | | |
| | | //增加对备货单得判断 |
| | | //增加对备货单的判断 |
| | | Integer taskStatus = resouce.equals(TaskResouceType.TASK_RESOUCE_STOCK_UP.val) |
| | | ? TaskStsType.MISSION_INITIAL.id:TaskStsType.MISSION_INITIAL.id; |
| | | |
| | |
| | | .setUpdateTime(new Date()) |
| | | .setTaskStatus(taskStatus) |
| | | .setBarcode(loc.getBarcode()) |
| | | .setTargSiteArea(map.getTargSiteAreaList()) |
| | | .setTargSiteAreaNow(map.getTargSiteAreaNow()) |
| | | .setMemo(map.getMemo()); |
| | | |
| | | List<LocItem> locItems = this.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, key)); |
| | |
| | | throw new CoolException("主任务关联失败!!"); |
| | | } |
| | | } |
| | | locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId())); |
| | | |
| | | List<TaskItem> taskItems = new ArrayList<>(); |
| | | listMap.get(key).forEach(item -> { |
| | | TaskItem taskItem = new TaskItem(); |
| | |
| | | throw new CoolException("库存信息修改失败!!"); |
| | | } |
| | | |
| | | if (taskItem.getAnfme() > 0) { |
| | | LocItemWorking itemWorking = new LocItemWorking(); |
| | | BeanUtils.copyProperties(taskItem, itemWorking); |
| | | itemWorking.setTaskId(task.getId()) |
| | | .setQty(0.0) |
| | | .setLocId(loc.getId()) |
| | | .setLocItemId(locItem.getId()) |
| | | .setType("out") |
| | | .setLocCode(loc.getCode()); |
| | | |
| | | if (!locItemWorkingService.save(itemWorking)) { |
| | | throw new CoolException("临时库存更新失败!!"); |
| | | } |
| | | } |
| | | }); |
| | | |
| | | locItemWorkingService.remove(new LambdaQueryWrapper<LocItemWorking>().eq(LocItemWorking::getTaskId, task.getId())); |
| | | |
| | | List<LocItemWorking> workings = new ArrayList<>(); |
| | | for (LocItem item : locItems) { |
| | | LocItemWorking working = new LocItemWorking(); |
| | | BeanUtils.copyProperties(item, working); |
| | | working.setId(null) |
| | | .setTaskId(task.getId()) |
| | | .setLocItemId(item.getId()) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()); |
| | | workings.add(working); |
| | | } |
| | | |
| | | if (!locItemWorkingService.saveBatch(workings)) { |
| | | throw new CoolException("临时库存更新失败!!"); |
| | | } |
| | | |
| | | if (!taskItemService.saveBatch(taskItems)) { |
| | | throw new CoolException("任务明细生成失败!!"); |
| | | } |
| | | |
| | | // 无单盘点:提取出库时即生成盘点差异单,便于 PDA 按差异单校验 |
| | | if (map.getType().equals(Constants.TASK_TYPE_OUT_CHECK)) { |
| | | Date now = new Date(); |
| | | double sumAnfme = taskItems.stream().mapToDouble(ti -> ti.getAnfme() != null ? ti.getAnfme() : 0).sum(); |
| | | CheckDiff checkDiff = new CheckDiff(); |
| | | checkDiff.setOrderCode(task.getTaskCode()) |
| | | .setOrderId(null) |
| | | .setCheckType(0) |
| | | .setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_INIT.val) |
| | | .setAnfme(sumAnfme) |
| | | .setCheckQty(0D) |
| | | .setStatus(1) |
| | | .setDeleted(0) |
| | | .setTenantId(task.getTenantId()) |
| | | .setCreateBy(loginUserId) |
| | | .setCreateTime(now) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(now); |
| | | if (loc.getAreaId() != null) { |
| | | checkDiff.setAreaId(loc.getAreaId()).setAreaName(loc.getAreaId$()); |
| | | } |
| | | if (!checkDiffService.save(checkDiff)) { |
| | | throw new CoolException("无单盘点差异单创建失败!!"); |
| | | } |
| | | List<CheckDiffItem> diffItems = new ArrayList<>(); |
| | | for (TaskItem ti : taskItems) { |
| | | CheckDiffItem diffItem = new CheckDiffItem(); |
| | | diffItem.setCheckId(checkDiff.getId()) |
| | | .setOrderCode(task.getTaskCode()) |
| | | .setTaskId(task.getId()) |
| | | .setTaskItemId(ti.getId()) |
| | | .setBarcode(task.getBarcode()) |
| | | .setAnfme(ti.getAnfme() != null ? ti.getAnfme() : 0D) |
| | | .setCheckQty(ti.getAnfme() != null ? ti.getAnfme() : 0D) |
| | | .setMatnrCode(ti.getMatnrCode()) |
| | | .setMaktx(ti.getMaktx()) |
| | | .setBatch(ti.getBatch()) |
| | | .setSpec(ti.getSpec()) |
| | | .setModel(ti.getModel()) |
| | | .setExceStatus(CheckDiffExceStatus.CHECK_DIFF_EXCE_STATUS_INIT.val) |
| | | .setStatus(1) |
| | | .setDeleted(0) |
| | | .setTenantId(task.getTenantId()) |
| | | .setCreateBy(loginUserId) |
| | | .setCreateTime(now) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(now); |
| | | diffItems.add(diffItem); |
| | | } |
| | | if (!checkDiffItemService.saveBatch(diffItems)) { |
| | | throw new CoolException("无单盘点差异明细创建失败!!"); |
| | | } |
| | | taskItemService.update(new LambdaUpdateWrapper<TaskItem>() |
| | | .set(TaskItem::getSourceCode, task.getTaskCode()) |
| | | .eq(TaskItem::getTaskId, task.getId())); |
| | | } |
| | | }); |
| | | } |
| | | |