| | |
| | | import com.vincent.rsf.server.api.utils.LocUtils; |
| | | import com.vincent.rsf.server.api.utils.SlaveProperties; |
| | | import com.vincent.rsf.server.manager.entity.*; |
| | | import com.vincent.rsf.server.manager.mapper.LocItemMapper; |
| | | import com.vincent.rsf.server.manager.service.*; |
| | | import com.vincent.rsf.server.manager.service.impl.LocServiceImpl; |
| | | import com.vincent.rsf.server.manager.utils.WarehouseLocationRetrievalUtil; |
| | | import com.vincent.rsf.server.system.constant.SerialRuleCode; |
| | | import com.vincent.rsf.server.manager.enums.LocStsType; |
| | | import com.vincent.rsf.server.system.entity.*; |
| | |
| | | @Autowired |
| | | private LocServiceImpl locService; |
| | | @Autowired |
| | | private LocItemService locItemService; |
| | | private LocItemMapper locItemMapper; |
| | | @Autowired |
| | | private SlaveProperties slaveProperties; |
| | | @Autowired |
| | |
| | | public InTaskMsgDto createInTask(TaskInParam param) { |
| | | |
| | | // 验证设备站点 |
| | | DeviceSite deviceSite = validateDeviceSite(param); |
| | | // DeviceSite deviceSite = validateDeviceSite(param); |
| | | |
| | | // 验证组拖状态 |
| | | WaitPakin waitPakin = validateWaitPakin(param.getBarcode()); |
| | |
| | | |
| | | // 创建并保存任务 |
| | | Task task = createTask(ruleCode, locNo.getLocNo(), waitPakin.getBarcode(), |
| | | deviceSite.getDeviceSite(), param.getSourceStaNo().toString(), param.getUser()); |
| | | null, param.getSourceStaNo().toString(), param.getUser()); |
| | | |
| | | // 更新库位状态 |
| | | updateLocStatus(task.getTargLoc(), waitPakin.getBarcode()); |
| | |
| | | /** |
| | | * 验证设备站点 |
| | | */ |
| | | private DeviceSite validateDeviceSite(TaskInParam param) { |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getSite, param.getSourceStaNo()) |
| | | .eq(DeviceSite::getType, param.getIoType())); |
| | | |
| | | if (Objects.isNull(deviceSite)) { |
| | | throw new CoolException("站点不存在!!"); |
| | | } |
| | | return deviceSite; |
| | | } |
| | | // private DeviceSite validateDeviceSite(TaskInParam param) { |
| | | // DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | // .eq(DeviceSite::getSite, param.getSourceStaNo()) |
| | | // .eq(DeviceSite::getType, param.getIoType())); |
| | | // |
| | | // if (Objects.isNull(deviceSite)) { |
| | | // throw new CoolException("站点不存在!!"); |
| | | // } |
| | | // return deviceSite; |
| | | // } |
| | | |
| | | /** |
| | | * 验证组拖状态 |
| | |
| | | * 更新库位状态 |
| | | */ |
| | | private void updateLocStatus(String locCode, String barcode) { |
| | | boolean updated = locService.update(new LambdaUpdateWrapper<Loc>() |
| | | .eq(Loc::getCode, locCode) |
| | | .set(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_S.type) |
| | | .set(Loc::getBarcode, barcode)); |
| | | Loc current = locService.getOne(new LambdaQueryWrapper<Loc>().eq(Loc::getCode, locCode)); |
| | | if (Objects.isNull(current)) { |
| | | throw new CoolException("库位预约失败!!"); |
| | | } |
| | | Loc update = new Loc(); |
| | | update.setId(current.getId()); |
| | | update.setVersion(current.getVersion()); |
| | | update.setUseStatus(LocStsType.LOC_STS_TYPE_S.type); |
| | | update.setBarcode(barcode); |
| | | boolean updated = locService.update(update, new LambdaUpdateWrapper<Loc>() |
| | | .eq(Loc::getId, current.getId())); |
| | | if (!updated) { |
| | | throw new CoolException("库位预约失败!!"); |
| | | } |
| | |
| | | * 更新组托状态 |
| | | */ |
| | | private void updateWaitPakinStatus(String barcode, Long loginUserId) { |
| | | boolean updated = waitPakinService.update(new LambdaUpdateWrapper<WaitPakin>() |
| | | .eq(WaitPakin::getBarcode, barcode) |
| | | .set(WaitPakin::getUpdateBy, loginUserId) |
| | | .set(WaitPakin::getCreateBy, loginUserId) |
| | | .set(WaitPakin::getIoStatus, PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val)); |
| | | WaitPakin current = waitPakinService.getOne(new LambdaQueryWrapper<WaitPakin>() |
| | | .eq(WaitPakin::getBarcode, barcode)); |
| | | if (Objects.isNull(current)) { |
| | | throw new CoolException("组托状态修改失败!!"); |
| | | } |
| | | WaitPakin update = new WaitPakin(); |
| | | update.setId(current.getId()); |
| | | update.setVersion(current.getVersion()); |
| | | update.setUpdateBy(loginUserId); |
| | | update.setCreateBy(loginUserId); |
| | | update.setIoStatus(PakinIOStatus.PAKIN_IO_STATUS_TASK_EXCE.val); |
| | | boolean updated = waitPakinService.update(update, new LambdaUpdateWrapper<WaitPakin>() |
| | | .eq(WaitPakin::getId, current.getId())); |
| | | |
| | | if (!updated) { |
| | | throw new CoolException("组托状态修改失败!!"); |
| | |
| | | // return locNo; |
| | | // } |
| | | @Override |
| | | public InTaskMsgDto getLocNoArea(TaskInParam param) throws Exception { |
| | | String matnr = null; |
| | | String batch = null; |
| | | List<WaitPakin> waitPakins = waitPakinService.list(new LambdaQueryWrapper<WaitPakin>().eq(WaitPakin::getBarcode, param.getBarcode())); |
| | | if (Cools.isEmpty(waitPakins) && param.getIoType().equals(TaskType.TASK_TYPE_IN.type)) { |
| | | throw new CoolException("未找到组托信息,请组托"); |
| | | } else if (!Cools.isEmpty(waitPakins)) { |
| | | matnr = waitPakins.get(0).getCode(); |
| | | batch = waitPakins.get(0).getCode(); |
| | | } |
| | | |
| | | DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(param.getSourceStaNo())); |
| | | if (Cools.isEmpty(deviceBind)) { |
| | | throw new CoolException("数据异常,请联系管理员===>库位规则未知"); |
| | | } |
| | | WarehouseAreas warehouseArea = warehouseAreasService.getById(deviceBind.getTypeId()); |
| | | if (Cools.isEmpty(warehouseArea)) { |
| | | throw new CoolException("未找到所属库区信息"); |
| | | } |
| | | LocTypeDto locTypeDto = new LocTypeDto(param); |
| | | InTaskMsgDto dto = null; |
| | | //根据立库类型获取获取库位 |
| | | if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_CRN.val)) { |
| | | //堆垛机 |
| | | dto = getLocNoCrn(param.getOrgLoc(), deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType()); |
| | | |
| | | } else if (warehouseArea.getType().equals(WarehType.WAREHOUSE_TYPE_FOUR_DIRECTIONS.val)) { |
| | | //四向库 |
| | | } else { |
| | | //CTU 库以及其它 |
| | | dto = getLocNoCtu(deviceBind, warehouseArea.getId(), param.getSourceStaNo(), matnr, batch, locTypeDto, 0, param.getIoType()); |
| | | } |
| | | return dto; |
| | | } |
| | | |
| | | @Override |
| | | public InTaskMsgDto getLocNo(TaskInParam param) throws Exception { |
| | | String matnr = null; |
| | | String batch = null; |
| | |
| | | matnr = waitPakins.get(0).getCode(); |
| | | batch = waitPakins.get(0).getCode(); |
| | | } |
| | | List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getSite, param.getSourceStaNo()) |
| | | .eq(DeviceSite::getType, param.getIoType()) |
| | | ); |
| | | if (Cools.isEmpty(deviceSites)) { |
| | | throw new CoolException("未找到站点路径信息"); |
| | | } |
| | | // List<DeviceSite> deviceSites = deviceSiteService.list(new LambdaQueryWrapper<DeviceSite>() |
| | | // .eq(DeviceSite::getSite, param.getSourceStaNo()) |
| | | // .eq(DeviceSite::getType, param.getIoType()) |
| | | // ); |
| | | // if (Cools.isEmpty(deviceSites)) { |
| | | // throw new CoolException("未找到站点路径信息"); |
| | | // } |
| | | DeviceBind deviceBind = deviceBindService.getById(LocUtils.getAreaType(param.getSourceStaNo())); |
| | | if (Cools.isEmpty(deviceBind)) { |
| | | throw new CoolException("数据异常,请联系管理员===>库位规则未知"); |
| | |
| | | //入库靠近摆放 |
| | | if (ioType == 1 && deviceBind.getBeSimilar().equals("1") && !Cools.isEmpty(matnr) && Cools.isEmpty(orgLoc)) { |
| | | if (nearRow != curRow) { |
| | | List<LocItem> locItems = locItemService.list(new LambdaQueryWrapper<LocItem>().eq(LocItem::getMatnrCode, matnr)); |
| | | List<LocItem> locItems = locItemMapper.selectList(new LambdaQueryWrapper<LocItem>().eq(LocItem::getMatnrCode, matnr)); |
| | | for (LocItem locItem : locItems) { |
| | | Loc loc1 = locService.getById(locItem.getLocId()); |
| | | if (LocUtils.isShallowLoc(loc1.getCode())) { |
| | |
| | | } |
| | | } |
| | | |
| | | // // 靠近摆放规则 --- 空托 //互通版 |
| | | // if (ioType == 10 && deviceBind.getEmptySimilar().equals("1")) { |
| | | // List<LocMast> locMasts = locMastService.selectList(new EntityWrapper<LocMast>() |
| | | // .eq("loc_sts", "D").ge("row1", sRow).le("row1", eRow).eq("whs_type", rowLastnoType.getType().longValue())); |
| | | // if (!locMasts.isEmpty()) { |
| | | // for (LocMast loc : locMasts) { |
| | | // if (Utils.isShallowLoc(slaveProperties, loc.getLocNo())) { |
| | | // continue; |
| | | // } |
| | | // String shallowLocNo = Utils.getShallowLoc(slaveProperties, loc.getLocNo()); |
| | | // // 检测目标库位是否为空库位 |
| | | // LocMast shallowLoc = locMastService.selectById(shallowLocNo); |
| | | // if (shallowLoc != null && shallowLoc.getLocSts().equals("O")) { |
| | | // if (VersionUtils.locMoveCheckLocTypeComplete(shallowLoc, locTypeDto)) { |
| | | // if (basCrnpService.checkSiteError(shallowLoc.getCrnNo(), true)) { |
| | | // locMast = shallowLoc; |
| | | // crnNo = locMast.getCrnNo(); |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | // } |
| | | //查找路径 |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getType, ioType) |
| | | .eq(DeviceSite::getSite, sourceStaNo) |
| | | .eq(DeviceSite::getChannel, channel).last("limit 1") |
| | | ); |
| | | if (Cools.isEmpty(deviceSite)) { |
| | | channel = 0; |
| | | } else { |
| | | inTaskMsgDto.setStaNo(deviceSite.getDeviceSite()); |
| | | |
| | | |
| | | if (loc != null) { |
| | | //查找路径 |
| | | boolean available = new WarehouseLocationRetrievalUtil().queryPathIsItAvailableInArea(sourceStaNo, loc.getAreaId().toString() ,loc.getBarcode(),"in"); |
| | | // DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | // .eq(DeviceSite::getType, ioType) |
| | | // .eq(DeviceSite::getSite, sourceStaNo) |
| | | // .eq(DeviceSite::getChannel, channel).last("limit 1") |
| | | // ); |
| | | if (!available) { |
| | | channel = 0; |
| | | loc = null; |
| | | } else { |
| | | inTaskMsgDto.setStaNo(sourceStaNo); |
| | | } |
| | | } |
| | | |
| | | //更新当前排 |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (loc != null) { |
| | | //查找路径 |
| | | boolean available = new WarehouseLocationRetrievalUtil().queryPathIsItAvailableInArea(sourceStaNo, loc.getAreaId().toString() ,loc.getBarcode(),"in"); |
| | | // DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | // .eq(DeviceSite::getType, ioType) |
| | | // .eq(DeviceSite::getSite, sourceStaNo) |
| | | // .eq(DeviceSite::getChannel, channel).last("limit 1") |
| | | // ); |
| | | if (!available) { |
| | | channel = 0; |
| | | loc = null; |
| | | } else { |
| | | inTaskMsgDto.setStaNo(sourceStaNo); |
| | | } |
| | | } |
| | | |
| | | //查询当前库位类型空库位 小于5个则locmast = null |
| | | List<Loc> locTypeLocMasts = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getUseStatus, LocStsType.LOC_STS_TYPE_O.type) |
| | |
| | | loc = loc2; |
| | | break; |
| | | } |
| | | |
| | | //查找路径 |
| | | DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | .eq(DeviceSite::getType, ioType) |
| | | .eq(DeviceSite::getSite, sourceStaNo) |
| | | .eq(!Objects.isNull(loc.getDeviceNo()), DeviceSite::getDeviceCode, loc.getDeviceNo()) |
| | | ); |
| | | if (Cools.isEmpty(deviceSite)) { |
| | | deviceNo = 0; |
| | | loc = null; |
| | | } else { |
| | | inTaskMsgDto.setStaNo(deviceSite.getDeviceSite()); |
| | | if (loc != null) { |
| | | //查找路径 |
| | | boolean available = new WarehouseLocationRetrievalUtil().queryPathIsItAvailableInArea(sourceStaNo, loc.getAreaId().toString() ,loc.getBarcode(),"in"); |
| | | // DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | // .eq(DeviceSite::getType, ioType) |
| | | // .eq(DeviceSite::getSite, sourceStaNo) |
| | | // .eq(DeviceSite::getChannel, channel).last("limit 1") |
| | | // ); |
| | | if (!available) { |
| | | deviceNo = 0; |
| | | loc = null; |
| | | } else { |
| | | inTaskMsgDto.setStaNo(sourceStaNo); |
| | | } |
| | | } |
| | | // DeviceSite deviceSite = deviceSiteService.getOne(new LambdaQueryWrapper<DeviceSite>() |
| | | // .eq(DeviceSite::getType, ioType) |
| | | // .eq(DeviceSite::getSite, sourceStaNo) |
| | | // .eq(!Objects.isNull(loc.getDeviceNo()), DeviceSite::getDeviceCode, loc.getDeviceNo()) |
| | | // ); |
| | | // if (Cools.isEmpty(deviceSite)) { |
| | | // deviceNo = 0; |
| | | // loc = null; |
| | | // } else { |
| | | // inTaskMsgDto.setStaNo(deviceSite.getDeviceSite()); |
| | | // } |
| | | // 递归查询 |
| | | if (Cools.isEmpty(loc) || !loc.getUseStatus().equals(LocStsType.LOC_STS_TYPE_O.type)) { |
| | | // 当前巷道无空库位时,递归调整至下一巷道,检索全部巷道无果后,跳出递归 |
| | |
| | | // return R.ok(JSONObject.toJSONString(params)); |
| | | } |
| | | } |
| | | |