| | |
| | | } |
| | | } |
| | | |
| | | |
| | | // 入库 应该根据工作档回去 |
| | | // this.runStaToLoc(locGroupList, staGroupList, staTaskMemo); |
| | | |
| | |
| | | private List<Loc> getAreaLocs(List<Integer> locGroupList, List<String> staGroupList, String memo) { |
| | | Integer startRow = Collections.min(locGroupList); |
| | | Integer endRow = Collections.max(locGroupList); |
| | | |
| | | // STA IDLE |
| | | // LambdaQueryWrapper<BasStation> idleWrapper = new LambdaQueryWrapper<BasStation>().eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type).in(BasStation::getStationName, staGroupList); |
| | | // List<BasStation> idleList = stationService.list(idleWrapper); |
| | | // if (Cools.isEmpty(idleList)) { |
| | | // return new ArrayList<>(); |
| | | // } |
| | | // Collections.shuffle(idleList); |
| | | |
| | | // LOC STOCK |
| | | LambdaQueryWrapper<Loc> stockWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type); |
| | |
| | | Collections.shuffle(stockList); |
| | | |
| | | return stockList; |
| | | //生成入库工作档 |
| | | // generateTask(idleList.get(0).getStationName(), stockList.get(0).getCode(), idleList.get(0).getBarcode()); |
| | | } |
| | | |
| | | |
| | | // 出库 |
| | | private void runLocToSta(List<Integer> locGroupList, List<String> staGroupList, String memo) { |
| | | Integer startRow = Collections.min(locGroupList); |
| | | Integer endRow = Collections.max(locGroupList); |
| | | |
| | | |
| | | // STA IDLE |
| | | LambdaQueryWrapper<BasStation> idleWrapper = new LambdaQueryWrapper<BasStation>().eq(BasStation::getUseStatus, LocStsType.LOC_STS_TYPE_O.type).in(BasStation::getStationName, staGroupList); |
| | | List<BasStation> idleList = stationService.list(idleWrapper); |
| | | if (Cools.isEmpty(idleList)) { |
| | | return; |
| | | } |
| | | Collections.shuffle(idleList); |
| | | |
| | | // LOC STOCK |
| | | LambdaQueryWrapper<Loc> stockWrapper = new LambdaQueryWrapper<Loc>().eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_F.type); |
| | | if (null != startRow) { |
| | | stockWrapper.ge(Loc::getRow, startRow); |
| | | } |
| | | if (null != endRow) { |
| | | stockWrapper.le(Loc::getRow, endRow); |
| | | } |
| | | List<Loc> stockList = locService.list(stockWrapper); |
| | | if (Cools.isEmpty(stockList)) { |
| | | return; |
| | | } |
| | | Collections.shuffle(stockList); |
| | | |
| | | |
| | | Loc loc = stockList.get(0); |
| | | List<LocItem> list = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId())); |
| | | LocToTaskParams param = new LocToTaskParams(); |
| | | param.setType(Constants.TASK_TYPE_OUT_STOCK); |
| | | param.setTarLoc(loc.getCode()); |
| | | param.setItems(list); |
| | | param.setSiteNo(idleList.get(0).getStationName()); |
| | | param.setMemo(memo); |
| | | //生成出库工作档 |
| | | try { |
| | | locItemService.generateTask(TaskResouceType.TASK_RESOUCE_STOCK_TYPE.val, param, getLoginUserId()); |
| | | } catch (Exception e) { |
| | | log.info("生成出库任务失败", e); |
| | | } |
| | | |
| | | } |
| | | |
| | | |
| | | // 移库 |
| | | private void runLocToLoc(List<Integer> locGroupList, String staTaskMemo) { |
| | |
| | | } |
| | | |
| | | } |
| | | |
| | | private void generateTask(String sourceStaNo, String locNo, String barcode) { |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null); |
| | | if (StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("编码错误:请确认编码「SYS_TASK_CODE」是否已生成!!"); |
| | | } |
| | | Task task = new Task(); |
| | | task.setTaskCode(ruleCode) |
| | | .setTaskStatus(TaskStsType.GENERATE_IN.id) |
| | | .setTaskType(TaskType.TASK_TYPE_IN.type) |
| | | .setResource(TaskResouceType.TASK_RESOUCE_PAKIN_TYPE.val) |
| | | .setTargLoc(locNo) |
| | | .setBarcode(barcode) |
| | | .setOrgSite(sourceStaNo) |
| | | .setCreateBy(6666L) |
| | | .setUpdateBy(6666L); |
| | | |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("任务保存失败!!"); |
| | | } |
| | | LambdaQueryWrapper<Matnr> wrapper = new LambdaQueryWrapper<>(); |
| | | wrapper.eq(Matnr::getStatus, 1); |
| | | wrapper.orderByAsc(Matnr::getUpdateTime); |
| | | List<Matnr> list = matnrService.page(new Page<>(1, 100), wrapper).getRecords(); |
| | | Collections.shuffle(list); |
| | | List<TaskItem> taskItems = new ArrayList<>(); |
| | | int i = 0; |
| | | for (Matnr item : list) { |
| | | if (i > 5) { |
| | | break; |
| | | } |
| | | TaskItem taskItem = new TaskItem(); |
| | | BeanUtils.copyProperties(item, taskItem); |
| | | taskItem.setTaskId(task.getId()) |
| | | .setOrderType(OrderType.ORDER_IN.type) |
| | | .setCreateBy(6666L) |
| | | .setUpdateBy(6666L) |
| | | .setExtendFields(item.getExtendFields()); |
| | | taskItems.add(taskItem); |
| | | item.setUpdateTime(new Date()); |
| | | matnrService.updateById(item); |
| | | i++; |
| | | } |
| | | taskItemService.saveBatch(taskItems); |
| | | } |
| | | |
| | | |
| | | public static List<String> getStaPrefixes(List<String> staGroupList) { |
| | | Set<String> rowSet = new HashSet<>(); |