|
|
@ -1,18 +1,19 @@ |
|
|
|
package org.nl.modules.quartz.task; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONArray; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
|
import org.nl.acs.agv.server.dto.AgvDto; |
|
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
|
import org.nl.modules.mnt.websocket.MsgType; |
|
|
|
import org.nl.modules.mnt.websocket.SocketMsg; |
|
|
|
import org.nl.modules.mnt.websocket.WebSocketServer; |
|
|
|
import org.nl.acs.monitor.DeviceStageMonitor; |
|
|
|
import org.nl.acs.opc.Device; |
|
|
|
import org.nl.acs.opc.DeviceAppService; |
|
|
|
import org.nl.acs.opc.DeviceType; |
|
|
|
import org.springframework.beans.factory.annotation.Autowired; |
|
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
import java.util.Map; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
/** |
|
|
|
* 查询AGV设备状态 |
|
|
@ -25,52 +26,68 @@ public class ToAgvDevice { |
|
|
|
AcsToWmsService acsToWmsService; |
|
|
|
@Autowired |
|
|
|
AgvService agvService; |
|
|
|
@Autowired |
|
|
|
DeviceAppService deviceAppService; |
|
|
|
|
|
|
|
public void run() throws Exception { |
|
|
|
JSONObject json = new JSONObject(); |
|
|
|
Map<String, AgvDto> agv_map = agvService.findAllAgvFromCache(); |
|
|
|
|
|
|
|
JSONArray agv_rows = new JSONArray(); |
|
|
|
JSONObject row = new JSONObject(); |
|
|
|
|
|
|
|
for (AgvDto agvDto : agv_map.values()) { |
|
|
|
row.put("device_code", agvDto.getName()); |
|
|
|
row.put("energyLevel", agvDto.getEnergyLevel()); |
|
|
|
if (agvDto.getState().equals("UNKNOWN")) { |
|
|
|
row.put("status_name", "有任务"); |
|
|
|
row.put("flag", "1"); |
|
|
|
} |
|
|
|
if (agvDto.getState().equals("UNAVAILABLE")) { |
|
|
|
row.put("status_name", "网络异常"); |
|
|
|
row.put("flag", "1"); |
|
|
|
} |
|
|
|
if (agvDto.getState().equals("ERROR")) { |
|
|
|
row.put("status_name", "机器错误"); |
|
|
|
row.put("flag", "1"); |
|
|
|
JSONArray list = new JSONArray(); |
|
|
|
List<Device> devices = deviceAppService.findDevice(DeviceType.agv); |
|
|
|
if (ObjectUtil.isNotEmpty(devices)){ |
|
|
|
for (int i = 0; i < devices.size(); i++) { |
|
|
|
Device device = devices.get(i); |
|
|
|
if (device != null && device.getDeviceDriver() instanceof DeviceStageMonitor){ |
|
|
|
DeviceStageMonitor monitorService = (DeviceStageMonitor) device.getDeviceDriver(); |
|
|
|
JSONObject deviceStatusName = monitorService.getDeviceStatusName(); |
|
|
|
list.add(deviceStatusName); |
|
|
|
} |
|
|
|
} |
|
|
|
if (agvDto.getState().equals("IDLE")) { |
|
|
|
row.put("status_name", "空闲"); |
|
|
|
row.put("flag", "0"); |
|
|
|
} |
|
|
|
if (agvDto.getState().equals("EXECUTING")) { |
|
|
|
row.put("status_name", "运行中"); |
|
|
|
row.put("flag", "0"); |
|
|
|
} |
|
|
|
if (agvDto.getState().equals("CHARGING")) { |
|
|
|
row.put("status_name", "充电中"); |
|
|
|
row.put("flag", "0"); |
|
|
|
} |
|
|
|
row.put("transportOrder", agvDto.getTransportOrder()); |
|
|
|
row.put("positionX", agvDto.getPositionX()); |
|
|
|
row.put("positionY", agvDto.getPositionY()); |
|
|
|
row.put("positionAngle", agvDto.getPositionAngle()); |
|
|
|
agv_rows.add(row); |
|
|
|
} |
|
|
|
json.put("agv_rows", agv_rows); |
|
|
|
SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO); |
|
|
|
WebSocketServer.sendInfo(deviceInfo, "toAgvDevice_data"); |
|
|
|
acsToWmsService.feedbackAgv(list); |
|
|
|
|
|
|
|
|
|
|
|
// JSONObject json = new JSONObject();
|
|
|
|
// Map<String, AgvDto> agv_map = agvService.findAllAgvFromCache();
|
|
|
|
//
|
|
|
|
// JSONArray agv_rows = new JSONArray();
|
|
|
|
// JSONObject row = new JSONObject();
|
|
|
|
//
|
|
|
|
// for (AgvDto agvDto : agv_map.values()) {
|
|
|
|
// row.put("device_code", agvDto.getName());
|
|
|
|
// row.put("energyLevel", agvDto.getEnergyLevel());
|
|
|
|
// if (agvDto.getState().equals("UNKNOWN")) {
|
|
|
|
// row.put("status_name", "有任务");
|
|
|
|
// row.put("flag", "1");
|
|
|
|
// }
|
|
|
|
// if (agvDto.getState().equals("UNAVAILABLE")) {
|
|
|
|
// row.put("status_name", "网络异常");
|
|
|
|
// row.put("flag", "1");
|
|
|
|
// }
|
|
|
|
// if (agvDto.getState().equals("ERROR")) {
|
|
|
|
// row.put("status_name", "机器错误");
|
|
|
|
// row.put("flag", "1");
|
|
|
|
// }
|
|
|
|
// if (agvDto.getState().equals("IDLE")) {
|
|
|
|
// row.put("status_name", "空闲");
|
|
|
|
// row.put("flag", "0");
|
|
|
|
// }
|
|
|
|
// if (agvDto.getState().equals("EXECUTING")) {
|
|
|
|
// row.put("status_name", "运行中");
|
|
|
|
// row.put("flag", "0");
|
|
|
|
// }
|
|
|
|
// if (agvDto.getState().equals("CHARGING")) {
|
|
|
|
// row.put("status_name", "充电中");
|
|
|
|
// row.put("flag", "0");
|
|
|
|
// }
|
|
|
|
// row.put("transportOrder", agvDto.getTransportOrder());
|
|
|
|
// row.put("positionX", agvDto.getPositionX());
|
|
|
|
// row.put("positionY", agvDto.getPositionY());
|
|
|
|
// row.put("positionAngle", agvDto.getPositionAngle());
|
|
|
|
// agv_rows.add(row);
|
|
|
|
// }
|
|
|
|
// json.put("agv_rows", agv_rows);
|
|
|
|
// SocketMsg deviceInfo = new SocketMsg(json, MsgType.INFO);
|
|
|
|
// WebSocketServer.sendInfo(deviceInfo, "toAgvDevice_data");
|
|
|
|
|
|
|
|
// acsToWmsService.feedbackAgv(row);
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|