Browse Source

纽迪希亚ECN-ACS系统变更

master
张江玮 2 years ago
parent
commit
f29b6c12f5
  1. 1
      hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java
  2. 26
      hd/nladmin-system/src/main/java/org/nl/hand/andxy/rest/NdxyHandController.java
  3. 18
      hd/nladmin-system/src/main/java/org/nl/hand/andxy/service/NdxyHandService.java
  4. 129
      hd/nladmin-system/src/main/java/org/nl/hand/andxy/service/impl/NdxyHandServiceImpl.java
  5. 29
      hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java

1
hd/nladmin-system/src/main/java/org/nl/acs/agv/server/dto/AgvDto.java

@ -159,4 +159,5 @@ public class AgvDto implements Serializable {
*/
private String w;
private String errorBuf;
}

26
hd/nladmin-system/src/main/java/org/nl/hand/andxy/rest/NdxyHandController.java

@ -6,6 +6,8 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.nl.annotation.Log;
import org.nl.annotation.rest.AnonymousPostMapping;
import org.nl.hand.andxy.service.NdxyHandService;
@ -153,4 +155,28 @@ public class NdxyHandController {
return new ResponseEntity<>(HandService.createTask2(whereJson), HttpStatus.OK);
}
/**
* 根据区域查询灭菌前后状态
*
* @param param String region 1灭菌前 \ 2灭菌后
* @return 设备状态数组
*/
@PostMapping("/point2")
@Log("根据区域查询灭菌前后状态")
@ApiOperation("根据区域查询灭菌前后状态")
public ResponseEntity<JSONObject> point2(@RequestBody Map<String, String> param) {
return new ResponseEntity<>(HandService.point2(param), HttpStatus.OK);
}
/**
* 查询AGV状态
*
* @return AGV状态数组
*/
@PostMapping("/queryagvStatus")
@Log("查询AGV状态")
@ApiOperation("查询AGV状态")
public ResponseEntity<JSONObject> queryagvStatus() {
return new ResponseEntity<>(HandService.queryagvStatus(), HttpStatus.OK);
}
}

18
hd/nladmin-system/src/main/java/org/nl/hand/andxy/service/NdxyHandService.java

@ -2,6 +2,9 @@
package org.nl.hand.andxy.service;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import java.util.Map;
/**
@ -112,4 +115,19 @@ public interface NdxyHandService {
Map<String, Object> queryMaterial();
Map<String, Object> createTask2(Map<String, String> whereJson);
/**
* 根据区域查询灭菌前后状态
*
* @param param String region 1灭菌前 \ 2灭菌后
* @return 设备状态数组
*/
JSONObject point2(Map<String, String> param);
/**
* 查询AGV状态
*
* @return AGV状态数组
*/
JSONObject queryagvStatus();
}

129
hd/nladmin-system/src/main/java/org/nl/hand/andxy/service/impl/NdxyHandServiceImpl.java

@ -13,6 +13,7 @@ import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
import org.apache.commons.lang3.ObjectUtils;
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.device.service.DeviceService;
import org.nl.acs.device.service.dto.DeviceDto;
@ -60,6 +61,7 @@ public class NdxyHandServiceImpl implements NdxyHandService {
private final PasswordEncoder passwordEncoder;
private final DeviceService deviceService;
private final DeviceAppService deviceAppService;
private final AgvService agvService;
InstructionService instructionService = null;
@ -853,5 +855,132 @@ public class NdxyHandServiceImpl implements NdxyHandService {
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;
}
}

29
hd/nladmin-system/src/main/java/org/nl/start/auto/run/NDCSocketConnectionAutoRun.java

@ -2465,11 +2465,35 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
}
//上报异常
else if (phase == 0x67) {
if (arr[18] * 256 + arr[19] == 0) {
AgvDto dto = null;
Map<String, AgvDto> map = AgvService.findAllAgvFromCache();
// carno = arr[18] * 256 + arr[19];
if (map.containsKey(String.valueOf(carno))) {
dto = map.get(String.valueOf(carno));
} else {
dto = new AgvDto();
}
dto.setName(String.valueOf(carno));
if (agvaddr == 0) {
dto.setState("IDLE");
} else {
StringBuffer errbs = new StringBuffer();
for (int i = 0; i < ERROR.length; i++) {
if (((agvaddr) & (1 << i)) > 0)
errbs.append("," + ERROR[i]);
//反馈故障
}
String errorStr = errbs.toString();
// 去除字符串头部逗号
if (errorStr.length() > 0) {
errorStr = errorStr.substring(1);
}
dto.setState("ERROR");
dto.setErrorBuf(errorStr);
AgvService.updateAgvFromCache(dto);
}
} else {
@ -3583,6 +3607,7 @@ public class NDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//反馈故障
}
dto.setState("ERROR");
dto.setErrorBuf(errbs.toString());
acsToWmsService.feedbackAgvStatus(String.valueOf(carno), String.valueOf(ikey), "error");
}
}

Loading…
Cancel
Save