| | |
| | | import org.springframework.transaction.annotation.Transactional; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.Date; |
| | | import java.util.List; |
| | | import java.util.Objects; |
| | | import java.util.stream.Collectors; |
| | |
| | | @Autowired |
| | | private LocService locService; |
| | | @Autowired |
| | | private LocItemService locItemService; |
| | | @Autowired |
| | | private TaskService taskService; |
| | | @Autowired |
| | | private TaskItemService taskItemService; |
| | | |
| | | |
| | | private BasStation checkStaStatus(String barcode, String sta) { |
| | |
| | | throw new CoolException("站点状态不为空闲"); |
| | | } |
| | | if (!Cools.isEmpty(basStation.getContainerType())) { |
| | | List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class); |
| | | List<Integer> longs1 = basStation.getContainerType(); |
| | | List<BasContainer> containers = basContainerService.list( |
| | | new LambdaQueryWrapper<BasContainer>() |
| | | .in(BasContainer::getContainerType, longs1) |
| | |
| | | throw new CoolException("站点状态不为空闲"); |
| | | } |
| | | |
| | | List<String> areaList = JSONObject.parseArray(basStation.getCrossZoneArea(), String.class); |
| | | if (!areaList.contains(area)) { |
| | | List<Integer> areaList = basStation.getCrossZoneArea(); |
| | | if (!areaList.contains(Integer.parseInt(area))) { |
| | | throw new CoolException("当前站点不支持目标库区"); |
| | | } |
| | | if (!Cools.isEmpty(basStation.getContainerType())) { |
| | | List<Long> longs1 = JSONObject.parseArray(basStation.getContainerType(), Long.class); |
| | | List<Integer> longs1 = basStation.getContainerType(); |
| | | List<BasContainer> containers = basContainerService.list( |
| | | new LambdaQueryWrapper<BasContainer>() |
| | | .in(BasContainer::getContainerType, longs1) |
| | |
| | | // throw new CoolException("该站点对应库区未找到库位"); |
| | | } |
| | | |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null); |
| | | String ruleCode = StringUtils.isBlank(param.getTaskNo()) ? |
| | | SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null) : param.getTaskNo(); |
| | | if (StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("编码错误:请确认编码「SYS_TASK_CODE」是否已生成!!"); |
| | | } |
| | |
| | | .setOrgSite(station.getStationName()) |
| | | .setBarcode(param.getContainerNo()) |
| | | .setTargSite(stationName) |
| | | .setTaskOrigin(StringUtils.isBlank(param.getTaskOrigin()) ? null : param.getTaskOrigin()) |
| | | .setCreateBy(loginUserId) |
| | | .setUpdateBy(loginUserId); |
| | | if (!taskService.save(task)) { |
| | |
| | | return R.ok(basStation); |
| | | } |
| | | |
| | | @Override |
| | | public R checkNonOrder(PdaGeneralParam param, Long loginUserId) { |
| | | |
| | | BasStation station = basStationService.getOne(new LambdaQueryWrapper<BasStation>() |
| | | .eq(BasStation::getStationName, param.getTransferStationNo())); |
| | | if (Objects.isNull(station) || !station.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type) ) { |
| | | throw new CoolException("目标站点不存在或站点不处于空库状态!!"); |
| | | } |
| | | |
| | | Loc loc = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, param.getLocNo())); |
| | | if (Objects.isNull(loc) || !loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_F.type) ) { |
| | | throw new CoolException("起点库位不存在或不处于在库状态!!"); |
| | | } |
| | | List<LocItem> itemParams = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getLocId, loc.getId())); |
| | | |
| | | if (itemParams.isEmpty()) { |
| | | throw new CoolException("起点库位库存明细为空,异常!!"); |
| | | } |
| | | Task task = new Task(); |
| | | String ruleCode = SerialRuleUtils.generateRuleCode(SerialRuleCode.SYS_TASK_CODE, null); |
| | | if (StringUtils.isBlank(ruleCode)) { |
| | | throw new CoolException("任务号不能为空!!"); |
| | | } |
| | | task.setOrgLoc(loc.getCode()) |
| | | .setTaskCode(ruleCode) |
| | | .setOrgLoc(loc.getCode()) |
| | | .setTargSite(station.getStationName()) |
| | | .setResource(TaskResouceType.TASK_RESOUCE_CHECK_TYPE.val) |
| | | .setTaskType(TaskType.TASK_TYPE_CHECK_OUT.type) |
| | | .setTaskStatus(TaskStsType.MISSION_INITIAL.id) |
| | | .setWarehType(WarehType.WAREHOUSE_TYPE_AGV.val) |
| | | .setBarcode(param.getContainerNo()) |
| | | .setCreateTime(new Date()) |
| | | .setUpdateBy(loginUserId) |
| | | .setUpdateTime(new Date()) |
| | | .setCreateBy(loginUserId) |
| | | .setBarcode(loc.getBarcode()); |
| | | |
| | | if (!taskService.save(task)) { |
| | | throw new CoolException("盘点任务生成失败!!"); |
| | | } |
| | | List<TaskItem> taskItems = new ArrayList<>(); |
| | | for (LocItem item : itemParams) { |
| | | TaskItem taskItem = new TaskItem(); |
| | | BeanUtils.copyProperties(item, taskItem); |
| | | taskItem.setTaskId(task.getId()) |
| | | .setAnfme(item.getAnfme()) |
| | | .setBatch(item.getBatch()) |
| | | .setUpdateBy(loginUserId) |
| | | .setSourceId(item.getLocId()) |
| | | .setSourceCode(item.getLocCode()) |
| | | .setSource(item.getId()) |
| | | .setUpdateTime(new Date()) |
| | | .setSplrBatch(item.getBatch()) |
| | | .setPlatWorkCode(item.getPlatWorkCode()) |
| | | .setPlatItemId(item.getPlatItemId()) |
| | | .setOrderType(OrderType.ORDER_IN.type) |
| | | .setWkType(Short.parseShort(OrderWorkType.ORDER_WORK_TYPE_OTHER_IN.type)); |
| | | taskItems.add(taskItem); |
| | | } |
| | | if (!taskItemService.saveBatch(taskItems)) { |
| | | throw new CoolException("任务明细保存失败!!"); |
| | | } |
| | | |
| | | loc.setUseStatus(LocStsType.LOC_STS_TYPE_R.type); |
| | | if (!locService.updateById(loc)) { |
| | | throw new CoolException("库位预约出库失败!!"); |
| | | } |
| | | return R.ok(); |
| | | } |
| | | |
| | | } |