|
@ -13,6 +13,7 @@ import net.sf.json.JSONArray; |
|
|
import net.sf.json.JSONObject; |
|
|
import net.sf.json.JSONObject; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.apache.commons.lang3.ObjectUtils; |
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
import org.nl.acs.agv.server.AgvService; |
|
|
|
|
|
import org.nl.acs.agv.server.dto.AgvDto; |
|
|
import org.nl.acs.agv.server.impl.AgvServiceImpl; |
|
|
import org.nl.acs.agv.server.impl.AgvServiceImpl; |
|
|
import org.nl.acs.device.service.DeviceService; |
|
|
import org.nl.acs.device.service.DeviceService; |
|
|
import org.nl.acs.device.service.dto.DeviceDto; |
|
|
import org.nl.acs.device.service.dto.DeviceDto; |
|
@ -60,6 +61,7 @@ public class NdxyHandServiceImpl implements NdxyHandService { |
|
|
private final PasswordEncoder passwordEncoder; |
|
|
private final PasswordEncoder passwordEncoder; |
|
|
private final DeviceService deviceService; |
|
|
private final DeviceService deviceService; |
|
|
private final DeviceAppService deviceAppService; |
|
|
private final DeviceAppService deviceAppService; |
|
|
|
|
|
private final AgvService agvService; |
|
|
InstructionService instructionService = null; |
|
|
InstructionService instructionService = null; |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -853,5 +855,132 @@ public class NdxyHandServiceImpl implements NdxyHandService { |
|
|
return jo; |
|
|
return jo; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public JSONObject point2(Map<String, String> param) { |
|
|
|
|
|
// 返回值
|
|
|
|
|
|
JSONObject resultJSON = new JSONObject(); |
|
|
|
|
|
|
|
|
|
|
|
// 参数校验
|
|
|
|
|
|
String region = param.get("region"); |
|
|
|
|
|
if (StrUtil.isEmpty(region)) { |
|
|
|
|
|
resultJSON.put("code", "0"); |
|
|
|
|
|
resultJSON.put("desc", "所属区域不能为空"); |
|
|
|
|
|
return resultJSON; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 设备数组
|
|
|
|
|
|
JSONArray acsDevice; |
|
|
|
|
|
|
|
|
|
|
|
// 根据区域不同处理
|
|
|
|
|
|
switch (region) { |
|
|
|
|
|
case "1": |
|
|
|
|
|
// 查询灭菌前设备
|
|
|
|
|
|
acsDevice = WQLObject |
|
|
|
|
|
.getWQLObject("acs_device") |
|
|
|
|
|
.query("device_code IN ('F5', 'F4', 'F3', 'F6', '1041')", "seq_num, device_name") |
|
|
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
break; |
|
|
|
|
|
case "2": |
|
|
|
|
|
// 查询灭菌后设备
|
|
|
|
|
|
acsDevice = WQLObject |
|
|
|
|
|
.getWQLObject("acs_device") |
|
|
|
|
|
.query("device_code IN ('B5', 'B4', 'B3', 'B6', '1042')", "seq_num, device_name") |
|
|
|
|
|
.getResultJSONArray(0); |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
resultJSON.put("code", "0"); |
|
|
|
|
|
resultJSON.put("desc", "所属区域错误"); |
|
|
|
|
|
return resultJSON; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 返回数组
|
|
|
|
|
|
JSONArray result = new JSONArray(); |
|
|
|
|
|
|
|
|
|
|
|
// 遍历设备数组获取设备状态
|
|
|
|
|
|
for (Object o : acsDevice) { |
|
|
|
|
|
// 根据设备编码查询缓存的设备实例
|
|
|
|
|
|
JSONObject device = (JSONObject) o; |
|
|
|
|
|
String deviceCode = device.getString("device_code"); |
|
|
|
|
|
Device deviceObj = deviceAppService.findDeviceByCode(deviceCode); |
|
|
|
|
|
|
|
|
|
|
|
// 设备状态对象,默认为红灯
|
|
|
|
|
|
JSONObject deviceStatus = new JSONObject(); |
|
|
|
|
|
deviceStatus.put("device_id", device.getString("device_id")); |
|
|
|
|
|
deviceStatus.put("device_code", deviceCode); |
|
|
|
|
|
deviceStatus.put("device_name", device.getString("device_name")); |
|
|
|
|
|
deviceStatus.put("status", "2"); |
|
|
|
|
|
deviceStatus.put("seq_num", device.getString("seq_num")); |
|
|
|
|
|
|
|
|
|
|
|
if (ObjectUtil.isNotEmpty(deviceObj)) { |
|
|
|
|
|
// 获取驱动
|
|
|
|
|
|
NdxySpecialDeviceDriver driver = (NdxySpecialDeviceDriver) deviceObj.getDeviceDriver(); |
|
|
|
|
|
|
|
|
|
|
|
// 只有在设备为空且无故障无选择的情况下才是绿灯
|
|
|
|
|
|
int hasGoods = driver.getHasGoods();// 是否有货
|
|
|
|
|
|
int error = driver.getError();// 是否故障
|
|
|
|
|
|
int actoin = driver.getActoin();// 是否允许取放
|
|
|
|
|
|
if (hasGoods == 0 && error == 0 && actoin == 1) { |
|
|
|
|
|
deviceStatus.put("status", "1"); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 添加进返回数组
|
|
|
|
|
|
result.add(deviceStatus); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 返回
|
|
|
|
|
|
resultJSON.put("code", "1"); |
|
|
|
|
|
resultJSON.put("desc", "查询成功"); |
|
|
|
|
|
resultJSON.put("result", result); |
|
|
|
|
|
return resultJSON; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
|
public JSONObject queryagvStatus() { |
|
|
|
|
|
// 获取所有AGV对象
|
|
|
|
|
|
Map<String, AgvDto> agvMap = agvService.findAllAgvFromCache(); |
|
|
|
|
|
|
|
|
|
|
|
// 返回数组
|
|
|
|
|
|
JSONArray result = new JSONArray(); |
|
|
|
|
|
|
|
|
|
|
|
// 遍历所有agv
|
|
|
|
|
|
for (AgvDto agv : agvMap.values()) { |
|
|
|
|
|
// 状态对象
|
|
|
|
|
|
JSONObject agvStatus = new JSONObject(); |
|
|
|
|
|
agvStatus.put("car_no", agv.getName()); |
|
|
|
|
|
String state = agv.getState(); |
|
|
|
|
|
String status; |
|
|
|
|
|
switch (state) { |
|
|
|
|
|
case "UNAVAILABLE": |
|
|
|
|
|
status = "通信超时或者已断开连接"; |
|
|
|
|
|
break; |
|
|
|
|
|
case "ERROR": |
|
|
|
|
|
status = "错误状态"; |
|
|
|
|
|
agvStatus.put("error", agv.getErrorBuf()); |
|
|
|
|
|
break; |
|
|
|
|
|
case "IDLE": |
|
|
|
|
|
status = "空闲状态"; |
|
|
|
|
|
break; |
|
|
|
|
|
case "EXECUTING": |
|
|
|
|
|
status = "正在执行运单"; |
|
|
|
|
|
break; |
|
|
|
|
|
case "CHARGING": |
|
|
|
|
|
status = "正在充电"; |
|
|
|
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
status = "未知状态"; |
|
|
|
|
|
} |
|
|
|
|
|
agvStatus.put("status", status); |
|
|
|
|
|
agvStatus.put("electricity", agv.getEnergyLevel()); |
|
|
|
|
|
|
|
|
|
|
|
// 添加进返回数组
|
|
|
|
|
|
result.add(agvStatus); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
JSONObject resultJSON = new JSONObject(); |
|
|
|
|
|
resultJSON.put("code", "1"); |
|
|
|
|
|
resultJSON.put("desc", "查询成功"); |
|
|
|
|
|
resultJSON.put("result", result); |
|
|
|
|
|
return resultJSON; |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|