From c8119c5bd00e9a8d53bee909f10bd0d8479f3ecf Mon Sep 17 00:00:00 2001 From: lgh0010 <1746689524@qq.com> Date: Sun, 20 Mar 2022 00:12:04 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BD=A6=E8=BE=86=E9=87=8D=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../basic/controller/VehicleController.java | 14 +++++++ .../com/mt/wms/empty/task/ScheduledTask.java | 38 +++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java index 45b4f93..c5e91a2 100644 --- a/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java +++ b/6.program/wms-basic/src/main/java/com/mt/wms/basic/controller/VehicleController.java @@ -1,11 +1,14 @@ package com.mt.wms.basic.controller; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.mt.wms.basic.params.VehicleParam; import com.mt.wms.basic.params.VehicleQueryParam; import com.mt.wms.basic.service.VehicleService; import com.mt.wms.basic.vo.VehicleVo; import com.mt.wms.core.base.BaseController; import com.mt.wms.core.constants.CommonConstant; +import com.mt.wms.core.dal.entity.VehicleInfo; +import com.mt.wms.core.dal.service.VehicleInfoServiceBiz; import com.mt.wms.core.params.IdParam; import com.mt.wms.core.utils.IDGenerator; import com.mt.wms.core.validator.groups.AddGroup; @@ -40,6 +43,8 @@ public class VehicleController extends BaseController { @Autowired private VehicleService vehicleService; + @Autowired + private VehicleInfoServiceBiz vehicleInfoServiceBiz; @PostMapping(value = "get") @ApiOperation(value = "获取车辆信息") private R get(@Validated @RequestBody IdParam idParam) { @@ -82,4 +87,13 @@ public class VehicleController extends BaseController { return successful(IDGenerator.gen("CL", "yyyyMMddHHmm", 2, "VEHICLE_CODE")); } + private R reset(){ + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper().eq(VehicleInfo.STATUS, 1)); + for (VehicleInfo vehicleInfo:vehicleInfoList + ) { + vehicleInfo.setStatus(0); + vehicleInfoServiceBiz.updateById(vehicleInfo); + } + return successful("操作成功,车辆状态已重置为空闲!"); + } } diff --git a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java index b1d08fd..647477a 100644 --- a/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java +++ b/6.program/wms-empty/src/main/java/com/mt/wms/empty/task/ScheduledTask.java @@ -423,6 +423,15 @@ public class ScheduledTask extends BaseService { } + //监听车辆是否在线 + public void listenVehicleOnline() throws IOException { + List vehicleInfoList = vehicleInfoServiceBiz.list(new QueryWrapper() + .eq(VehicleInfo.STATUS, 2)); + for (VehicleInfo vehicleInfo:vehicleInfoList + ) { + + } + } /** * 获取变量值 * @param nameSpace nameSpace前缀 @@ -465,4 +474,33 @@ public class ScheduledTask extends BaseService { } return Double.valueOf(JSONObject.parseObject(result).get("result").toString()); } + + private Boolean rgvOnline(Long vehicleId) throws IOException { + VehicleInfo vehicleInfo = vehicleInfoServiceBiz.getById(vehicleId); + // TODO: 2022/3/19 小车的命名空间 + String identifier=null; + if (vehicleId==1){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS."; + } + if (vehicleId==2){ + identifier="S7-1200 station_2.Boutique.DB500_PLCToWCS.Platform4ToWCS."; + } + Map json = new HashMap(); + json.put("nameSpace", 6); + json.put("plcName", "plc1"); + json.put("identifier",identifier+"Online"); + String result = null; + try { + result = HttpClient.httpPost("http://192.168.6.51:8009/opcua/read", JSON.toJSONString(json)); + } catch (IOException e) { + e.printStackTrace(); + logger.info("获取小车1当前是否在线失败"); + } + Boolean aBoolean = Boolean.valueOf(JSONObject.parseObject(result).get("result").toString()); + if (!aBoolean){ + webSocketServer.sendtoAll(vehicleInfo.getVehicleName()+"当前不在线,请人工确认车辆状态,如不能恢复未在线状态,请尽快手动移动车辆到轨道尽头,以避免车辆阻碍任务执行!"); + return false; + } + return true; + } }