| | |
| | | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; |
| | | import com.vincent.rsf.framework.common.Cools; |
| | | import com.vincent.rsf.server.api.entity.enums.OrderType; |
| | | import com.vincent.rsf.server.api.entity.enums.TaskStsType; |
| | | import com.vincent.rsf.framework.common.R; |
| | | import com.vincent.rsf.framework.exception.CoolException; |
| | | import com.vincent.rsf.server.api.entity.enums.TaskType; |
| | | import com.vincent.rsf.server.api.utils.LocUtils; |
| | | import com.vincent.rsf.server.manager.controller.params.GenerateTaskParams; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.enums.PakinIOStatus; |
| | |
| | | @Autowired |
| | | private LocItemService locItemService; |
| | | |
| | | @Autowired |
| | | private DeviceBindService deviceBindService; |
| | | @Autowired |
| | | private WarehouseAreasService warehouseAreasService; |
| | | |
| | | |
| | | /** |
| | | * @param |
| | |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(Integer.valueOf(deviceSite.getSite()))); |
| | | if (Cools.isEmpty(deviceBind)) { |
| | | throw new CoolException("库位规则未知"); |
| | | } |
| | | WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId()); |
| | | if (Cools.isEmpty(warehouseArea)) { |
| | | throw new CoolException("未找到所属库区信息"); |
| | | } |
| | | |
| | | /**获取库位*/ |
| | | String targetLoc = LocManageUtil.getTargetLoc(warehouseArea.getId()); |
| | | if (Cools.isEmpty(targetLoc)) { |
| | | throw new CoolException("该站点对应库区未找到库位"); |
| | | } |
| | | /**获取组拖*/ |
| | | List<Long> ids = waitPakin.getWaitPakins().stream().map(WaitPakin::getId).collect(Collectors.toList()); |
| | | List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>() |
| | |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id.shortValue()) |
| | | .setTaskType(TaskType.TASK_TYPE_IN.type.shortValue()) |
| | | .setTargLoc(LocManageUtil.getTargetLoc()) |
| | | .setTargLoc(targetLoc) |
| | | .setBarcode(pakin.getBarcode()) |
| | | .setTargSite(deviceSite.getDeviceCode()) |
| | | .setOrgSite(deviceSite.getSite()) |
| | | .setTargSite(deviceSite.getDeviceSite()) |
| | | .setCreateBy(loginUserId) |
| | | .setUpdateBy(loginUserId); |
| | | |
| | | if (!Objects.isNull(waitPakin.getSiteId()) && waitPakin.getSiteId() > 0) { |
| | | DeviceSite site = deviceSiteService.getById(waitPakin.getSiteId()); |
| | | task.setTargSite(site.getSite() + ""); |
| | | } else { |
| | | task.setTargSite(LocManageUtil.getTargetSite()); |
| | | } |
| | | if (!Objects.isNull(waitPakin.getLocCode()) && StringUtils.isNotBlank(waitPakin.getLocCode())) { |
| | | List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, waitPakin.getLocCode())); |
| | | // if (!locs.isEmpty()) { |
| | | // throw new CoolException("库位错误:相同库位应只一条") |
| | | // } |
| | | Loc loc = locs.stream().findFirst().get(); |
| | | task.setTargSite(loc.getCode()); |
| | | } else { |
| | | task.setTargSite(LocManageUtil.getTargetSite()); |
| | | } |
| | | // if (!Objects.isNull(waitPakin.getSiteId()) && waitPakin.getSiteId() > 0) { |
| | | // DeviceSite site = deviceSiteService.getById(waitPakin.getSiteId()); |
| | | // task.setTargSite(site.getSite() + ""); |
| | | // } else { |
| | | // task.setTargSite(LocManageUtil.getTargetSite()); |
| | | // } |
| | | // if (!Objects.isNull(waitPakin.getLocCode()) && StringUtils.isNotBlank(waitPakin.getLocCode())) { |
| | | // List<Loc> locs = locService.list(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, waitPakin.getLocCode())); |
| | | //// if (!locs.isEmpty()) { |
| | | //// throw new CoolException("库位错误:相同库位应只一条") |
| | | //// } |
| | | // Loc loc = locs.stream().findFirst().get(); |
| | | // task.setTargSite(loc.getCode()); |
| | | // } else { |
| | | // task.setTargSite(LocManageUtil.getTargetSite()); |
| | | // } |
| | | |
| | | if (!this.save(task)) { |
| | | throw new CoolException("任务保存失败!!"); |
| | |
| | | if (!locService.update(new LambdaUpdateWrapper<Loc>().set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type).in(Loc::getCode, locCodes))) { |
| | | throw new CoolException("库位状态修改失败!!"); |
| | | } |
| | | if (!this.update(new LambdaUpdateWrapper<Task>().set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { |
| | | if (!this.update(new LambdaUpdateWrapper<Task>().in(Task::getId, list).set(Task::getTaskStatus, TaskStsType.UPDATED_IN.id))) { |
| | | throw new CoolException("任务状态修改失败!!"); |
| | | } |
| | | } |
| | |
| | | * @time 2025/4/15 15:28 |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | void saveLocItem(List<TaskItem> items, Long taskId) throws Exception { |
| | | public void saveLocItem(List<TaskItem> items, Long taskId) throws Exception { |
| | | Task task = this.getById(taskId); |
| | | if (Objects.isNull(task)) { |
| | | throw new CoolException("任务不存在!!"); |
| | |
| | | * @return |
| | | */ |
| | | @Transactional(rollbackFor = Exception.class) |
| | | void saveStockItems(List<TaskItem> items, WaitPakinItem order) throws Exception { |
| | | public void saveStockItems(List<TaskItem> items, WaitPakinItem order) throws Exception { |
| | | Stock stock = new Stock(); |
| | | // if (!Objects.isNull(order.getPoCode()) && StringUtils.isNotBlank(order.getPoCode())) { |
| | | // Purchase purchase = purchaseService.getOne(new LambdaQueryWrapper<Purchase>().eq(Purchase::getCode, order.getPoCode())); |