| | |
| | | import com.zy.asrs.common.utils.HttpHandler; |
| | | import com.zy.asrs.framework.common.Cools; |
| | | import com.zy.asrs.framework.common.SnowflakeIdWorker; |
| | | import com.zy.asrs.framework.exception.CoolException; |
| | | import com.zy.asrs.wcs.core.domain.dto.MatDto; |
| | | import com.zy.asrs.wcs.core.domain.dto.RedisMapDto; |
| | | import com.zy.asrs.wcs.core.domain.dto.StaDto; |
| | | import com.zy.asrs.wcs.core.entity.*; |
| | | import com.zy.asrs.wcs.core.kernel.AnalyzeService; |
| | | import com.zy.asrs.wcs.core.model.MapNode; |
| | | import com.zy.asrs.wcs.core.model.enums.DeviceCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.MotionStsType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskCtgType; |
| | | import com.zy.asrs.wcs.core.model.enums.TaskStsType; |
| | | import com.zy.asrs.wcs.core.model.enums.*; |
| | | import com.zy.asrs.wcs.core.service.*; |
| | | import com.zy.asrs.wcs.core.utils.RedisUtil; |
| | | import com.zy.asrs.wcs.core.utils.ShuttleDispatcher; |
| | |
| | | @Autowired |
| | | private BasConveyorStaService basConveyorStaService; |
| | | @Autowired |
| | | private BasConveyorPathService basConveyorPathService; |
| | | @Autowired |
| | | private BasLedService basLedService; |
| | | @Autowired |
| | | private DeviceBarcodeService deviceBarcodeService; |
| | | |
| | | /** |
| | | * 组托 |
| | |
| | | BasConveyor basConveyor = basConveyorService.getOne(new LambdaQueryWrapper<BasConveyor>().eq(BasConveyor::getDeviceId, devp.getId()).eq(BasConveyor::getHostId, devp.getHostId())); |
| | | // 遍历入库口 |
| | | for (StaDto inSta : JSON.parseArray(basConveyor.getInSta(), StaDto.class)) { |
| | | BasConveyorSta basConveyorSta = basConveyorStaService.selectBySiteNo(inSta.getStaNo().toString()); |
| | | if(basConveyorSta == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 获取入库站信息 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, devp.getId().intValue()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(inSta.getStaNo()); |
| | |
| | | ) { |
| | | |
| | | // 获取条码扫描仪信息 |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, inSta.getBarcode()); |
| | | BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, basConveyorSta.getBarcodeId().intValue()); |
| | | if (barcodeThread == null) { |
| | | continue; |
| | | } |
| | |
| | | Integer code = jsonObject.getInteger("code"); |
| | | if (code.equals(200)) { |
| | | StartupDto dto = jsonObject.getObject("data", StartupDto.class); |
| | | devpThread.writeWorkSta(staProtocol.getSiteId(), dto.getWorkNo().shortValue(), dto.getStaNo().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | |
| | | //获取输送路径 |
| | | BasConveyorPath conveyorPath = basConveyorPathService.getOne(new LambdaQueryWrapper<BasConveyorPath>() |
| | | .eq(BasConveyorPath::getTypeNo, TaskCtgType.IN.val()) |
| | | .eq(BasConveyorPath::getDeviceId, devp.getId()) |
| | | .eq(BasConveyorPath::getStnNo, staProtocol.getSiteId())); |
| | | if (conveyorPath == null) { |
| | | News.error("输送路径不存在"); |
| | | }else { |
| | | devpThread.writeWorkSta(staProtocol.getSiteId(), dto.getWorkNo().shortValue(), conveyorPath.getDeviceStn().shortValue()); |
| | | devpThread.setPakMk(staProtocol.getSiteId(), false); |
| | | } |
| | | }else { |
| | | if (ledThread != null) { |
| | | String errorMsg = jsonObject.getString("msg"); |
| | |
| | | mapNode.setNo(object.getString("row") + "-" + object.getString("bay")); |
| | | mapNode.setXBase(object.getInteger("refx")); |
| | | mapNode.setYBase(object.getInteger("refy")); |
| | | |
| | | if(mapNode.getValue() == MapNodeType.CONVEYOR.id) { |
| | | //输送线,判断小车是否可走 |
| | | if (object.containsKey("conveyorHasGo")) { |
| | | if(object.getBoolean("conveyorHasGo")) { |
| | | //小车可走 |
| | | mapNode.setValue(MapNodeType.CONVEYOR_CAR_GO.id); |
| | | } |
| | | } |
| | | } |
| | | |
| | | nodes.add(mapNode); |
| | | } |
| | | |
| | |
| | | //存在空缺节点,自动补足 |
| | | for (int i = defaultBay; i < node.getBay(); i++) { |
| | | MapNode mapNode = new MapNode(); |
| | | mapNode.setValue(-1); |
| | | mapNode.setValue(MapNodeType.DISABLE.id); |
| | | mapNode.setTop(1000); |
| | | mapNode.setBottom(1000); |
| | | mapNode.setLeft(1000); |
| | |
| | | ArrayList<ArrayList<MapNode>> lists = entry.getValue();//获取地图 |
| | | |
| | | MapNode mapNode = new MapNode(); |
| | | mapNode.setValue(-1); |
| | | mapNode.setValue(MapNodeType.DISABLE.id); |
| | | mapNode.setTop(1000); |
| | | mapNode.setBottom(1000); |
| | | mapNode.setLeft(1000); |
| | |
| | | // 解析入库工作档 |
| | | public synchronized void analyzeInBoundTask() { |
| | | for (Task task : taskService.selectWaitAnalyzeInBoundTask()) { |
| | | BasConveyorSta basConveyorSta = basConveyorStaService.getOne(new LambdaQueryWrapper<BasConveyorSta>().eq(BasConveyorSta::getSiteNo, task.getDestSite())); |
| | | if (basConveyorSta == null) { |
| | | continue; |
| | | } |
| | | BasConveyor basConveyor = basConveyorService.getById(basConveyorSta.getConveyorId()); |
| | | if (basConveyor == null) { |
| | | continue; |
| | | } |
| | | // DeviceBarcode deviceBarcode = deviceBarcodeService.getById(basConveyorSta.getBarcodeId()); |
| | | // if (deviceBarcode == null) { |
| | | // continue; |
| | | // } |
| | | // BarcodeThread barcodeThread = (BarcodeThread) SlaveConnection.get(SlaveType.Barcode, Integer.parseInt(deviceBarcode.getDeviceId())); |
| | | // if (barcodeThread == null) { |
| | | // continue; |
| | | // } |
| | | // if (!barcodeThread.getBarcode().equals(task.getZpallet())) { |
| | | // continue; |
| | | // } |
| | | if (Cools.isEmpty(basConveyorSta.getTaskNo())){ |
| | | continue; |
| | | } |
| | | if (!basConveyorSta.getTaskNo().toString().equals(task.getTaskNo())){ |
| | | continue; |
| | | } |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue()); |
| | | if (devpThread == null) { |
| | | continue; |
| | | } |
| | | StaProtocol staProtocol = devpThread.getStation().get(basConveyorSta.getSiteNo()); |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } |
| | | if (!(staProtocol.isAutoing() |
| | | && staProtocol.isLoading() |
| | | && staProtocol.isInEnable())) { |
| | | continue; |
| | | } |
| | | |
| | | |
| | | if (Cools.isEmpty(task.getShuttleNo())) { |
| | | //分配小车 |
| | | //搜索空闲车 |
| | |
| | | if (motionList.isEmpty()) { |
| | | continue; |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()), task.getHostId()); |
| | | |
| | | // 更新工作主档 |
| | | task.setTaskSts(TaskStsType.ANALYZE_INBOUND.sts); // 工作状态 |
| | |
| | | continue; |
| | | } |
| | | |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, originStaObj.getConveyorId().intValue()); |
| | | BasConveyor basConveyor = basConveyorService.getById(originStaObj.getConveyorId()); |
| | | if(basConveyor == null) { |
| | | continue; |
| | | } |
| | | |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue()); |
| | | StaProtocol staProtocol = devpThread.getStation().get(Integer.parseInt(task.getOriginSite()));//源站 |
| | | StaProtocol staProtocol1 = devpThread.getStation().get(Integer.parseInt(task.getDestSite()));//目标站 |
| | | if (staProtocol == null || staProtocol1 == null) { |
| | | // StaProtocol staProtocol1 = devpThread.getStation().get(Integer.parseInt(task.getDestSite()));//目标站 |
| | | if (staProtocol == null) { |
| | | continue; |
| | | } else { |
| | | staProtocol = staProtocol.clone(); |
| | | staProtocol1 = staProtocol1.clone(); |
| | | // staProtocol1 = staProtocol1.clone(); |
| | | } |
| | | |
| | | // 判断堆垛机出库站状态 |
| | | if (staProtocol.isAutoing() && !staProtocol.isLoading() && staProtocol.getWorkNo() == 0 && staProtocol.isOutEnable()) { |
| | | if (!(staProtocol1.isAutoing() && !staProtocol1.isLoading() && staProtocol1.getWorkNo() == 0 && staProtocol1.isOutEnable())) { |
| | | continue; |
| | | } |
| | | // if (!(staProtocol1.isAutoing() && !staProtocol1.isLoading() && staProtocol1.getWorkNo() == 0 && staProtocol1.isOutEnable())) { |
| | | // continue; |
| | | // } |
| | | |
| | | // //同库位组校验 |
| | | // List<String> outerLoc = Utils.getGroupOuterLoc(wrkMast.getSourceLocNo()); |
| | |
| | | log.error("出库 ===>> 暂时没有空闲小车, 任务号={}", task.getTaskNo()); |
| | | continue; |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()), task.getHostId()); |
| | | |
| | | // 更新工作主档 |
| | | task.setTaskSts(TaskStsType.ANALYZE_OUTBOUND.sts); // 工作状态 |
| | |
| | | } |
| | | |
| | | // generate motion list |
| | | List<Motion> motionList = analyzeService.generateMotion(task); |
| | | List<Motion> motionList = analyzeService.generateShuttleMoveMotion(task); |
| | | if (motionList.isEmpty()) { |
| | | continue; |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()), task.getHostId()); |
| | | |
| | | // 更新工作主档 |
| | | task.setTaskSts(TaskStsType.ANALYZE_MOVE.sts); // 工作状态 |
| | |
| | | * 四向穿梭车电量检测 ===>> 发起充电 |
| | | */ |
| | | public synchronized void loopShuttleCharge() { |
| | | // 获取充电桩库位类型 |
| | | LocCtg locCtg = locCtgService.getOne(new LambdaQueryWrapper<LocCtg>() |
| | | .eq(LocCtg::getFlag, "CHARGE") |
| | | .eq(LocCtg::getStatus, 1)); |
| | | if (locCtg == null) { |
| | | return; |
| | | } |
| | | |
| | | //获取充电任务类型 |
| | | TaskCtg taskCtg = taskCtgService.getOne(new LambdaQueryWrapper<TaskCtg>() |
| | | .eq(TaskCtg::getFlag, String.valueOf(TaskCtgType.CHARGE)) |
| | |
| | | //搜索小车当前楼层充电桩 |
| | | ArrayList<Loc> allChargeLoc = new ArrayList<>(); |
| | | List<Loc> list1 = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLocCtg, locCtg.getId()) |
| | | .eq(Loc::getLocSts, LocStsType.C.val()) |
| | | .eq(Loc::getStatus, 1) |
| | | .eq(Loc::getLev, lev)); |
| | | if (!list1.isEmpty()) { |
| | |
| | | |
| | | //搜索其他楼层充电桩 |
| | | List<Loc> list2 = locService.list(new LambdaQueryWrapper<Loc>() |
| | | .eq(Loc::getLocCtg, locCtg.getId()) |
| | | .eq(Loc::getLocSts, LocStsType.C.val()) |
| | | .eq(Loc::getStatus, 1) |
| | | .notIn(Loc::getLev, lev)); |
| | | if (!list2.isEmpty()) { |
| | |
| | | News.error("保存{}号四向穿梭车充电任务失败!!!", device.getDeviceNo()); |
| | | continue; |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()), task.getHostId()); |
| | | |
| | | task.setTaskSts(TaskStsType.ANALYZE_CHARGE.sts); |
| | | if (!taskService.save(task)) { |
| | |
| | | News.error("保存{}号四向穿梭车迁移任务失败!!!", device.getDeviceNo()); |
| | | continue; |
| | | } |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo())); |
| | | motionService.batchInsert(motionList, task.getUuid(), Integer.valueOf(task.getTaskNo()), task.getHostId()); |
| | | |
| | | task.setTaskSts(TaskStsType.ANALYZE_MOVE.sts); |
| | | |
| | |
| | | .eq(BasLed::getDeviceId, ledDevice.getId())); |
| | | List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class); |
| | | |
| | | BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue()); |
| | | if (basConveyor == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue()); |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue()); |
| | | // 命令集合 |
| | | List<LedCommand> commands = new ArrayList<>(); |
| | | // 工作档集合 |
| | |
| | | .eq(BasLed::getDeviceId, ledDevice.getId())); |
| | | List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class); |
| | | |
| | | BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId().intValue()); |
| | | if (basConveyor == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue()); |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue()); |
| | | // 命令集合 |
| | | boolean reset = true; |
| | | for (Integer staNo : staArr) { |
| | |
| | | .eq(BasLed::getDeviceId, ledDevice.getId())); |
| | | List<Integer> staArr = JSON.parseArray(led.getSta(), Integer.class); |
| | | |
| | | BasConveyor basConveyor = basConveyorService.getById(led.getConveyorId()); |
| | | if (basConveyor == null) { |
| | | continue; |
| | | } |
| | | |
| | | // 获取输送线plc线程 |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, led.getConveyorId().intValue()); |
| | | DevpThread devpThread = (DevpThread) SlaveConnection.get(SlaveType.Conveyor, basConveyor.getDeviceId().intValue()); |
| | | // 命令集合 |
| | | boolean reset = true; |
| | | for (Integer staNo : staArr) { |