Browse Source

更新

master
gengby 2 years ago
parent
commit
bdd016c441
  1. 7
      acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
  2. 20
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java
  3. 1
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java
  4. 1
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/led/MaGangLedDeviceDriver.java
  5. 5
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java
  6. 49
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java
  7. 6
      acs/nladmin-system/src/main/resources/config/application-prod.yml
  8. 2
      acs/nladmin-system/src/main/resources/config/application.yml

7
acs/nladmin-system/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java

@ -348,7 +348,6 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
ja.add(joi3); ja.add(joi3);
} }
} }
System.out.println(ja.toString());
return ja; return ja;
} }
@ -455,20 +454,22 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) { if (StrUtil.equals(paramService.findByCode(AcsConfig.FORKAGV).getValue(), "1")) {
String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue(); String agvurl = paramService.findByCode(AcsConfig.AGVURL).getValue();
String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue(); String agvport = paramService.findByCode(AcsConfig.AGVPORT).getValue();
agvurl = agvurl + ":" + agvport + "/blockGroupStatus"; agvurl = agvurl + ":" + agvport + "/blockGroupStatus";
log.info("获取互斥组参数:{},请求路径:{}", String.valueOf(param), agvurl);
try { try {
HttpResponse result = HttpRequest.get(agvurl) HttpResponse result = HttpRequest.get(agvurl)
.body(String.valueOf(param))//表单内容 .body(String.valueOf(param))//表单内容
.timeout(20000)//超时,毫秒 .timeout(20000)//超时,毫秒
.execute(); .execute();
String body = result.body(); String body = result.body();
if (StrUtil.isNotEmpty(body)){ if (StrUtil.isNotEmpty(body)) {
JSONArray jsonArray = JSONArray.parseArray(result.body()); JSONArray jsonArray = JSONArray.parseArray(result.body());
log.info("获取互斥组参数:{},请求路径:{},响应参数{}", String.valueOf(param), agvurl, String.valueOf(jsonArray));
return jsonArray; return jsonArray;
} }
return null; return null;
} catch (Exception e) { } catch (Exception e) {
log.info("获取互斥组参数:{},请求路径:{},响应参数{}", String.valueOf(param), agvurl, e.getMessage());
return null; return null;
} }

20
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java

@ -23,15 +23,19 @@ public class ItemProtocol {
public ItemProtocol(MaGangAgvDeviceDriver driver) { public ItemProtocol(MaGangAgvDeviceDriver driver) {
this.driver = driver; this.driver = driver;
} }
public int getStatus() { public int getStatus() {
return this.getOpcIntegerValue(item_status); return this.getOpcIntegerValue(item_status);
} }
public int getType() { public int getType() {
return this.getOpcIntegerValue(item_type); return this.getOpcIntegerValue(item_type);
} }
public int getX_coordinate() { public int getX_coordinate() {
return this.getOpcIntegerValue(item_x_coordinate); return this.getOpcIntegerValue(item_x_coordinate);
} }
public int getY_coordinate() { public int getY_coordinate() {
return this.getOpcIntegerValue(item_y_coordinate); return this.getOpcIntegerValue(item_y_coordinate);
} }
@ -52,19 +56,19 @@ public class ItemProtocol {
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_status, "AGV状态", "DB620.W0")); list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
list.add(new ItemDto(item_type, "AGV任务类型", "DB620.W2")); list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB620.W4")); list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4"));
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB620.W6")); list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6"));
return list; return list;
} }
public static List<ItemDto> getWriteableItemDtos() { public static List<ItemDto> getWriteableItemDtos() {
ArrayList list = new ArrayList(); ArrayList list = new ArrayList();
list.add(new ItemDto(item_status, "AGV状态", "DB620.W0")); list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
list.add(new ItemDto(item_type, "AGV任务类型", "DB620.W2")); list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB620.W4")); list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4"));
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB620.W6")); list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6"));
return list; return list;
} }

1
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java

@ -117,6 +117,7 @@ public class MaGangAgvDeviceDriver extends AbstractOpcDeviceDriver implements De
Map<String, Object> itemMap = new HashMap<String, Object>(); Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, value); itemMap.put(to_command, value);
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value);
} }

1
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/led/MaGangLedDeviceDriver.java

@ -114,6 +114,7 @@ public class MaGangLedDeviceDriver extends AbstractOpcDeviceDriver implements De
Map<String, Object> itemMap = new HashMap<String, Object>(); Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, value); itemMap.put(to_command, value);
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value);
} }

5
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/maGang/MaGangConveyorDeviceDriver.java

@ -258,12 +258,13 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
public void writing(int command) { public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.basedriver.standard_conveyor_control_with_scanner.ItemProtocol.item_to_command; + "." + ItemProtocol.item_to_command;
String opcservcerid = this.getDevice().getOpc_server_id(); String opcservcerid = this.getDevice().getOpc_server_id();
Server server = ReadUtil.getServer(opcservcerid); Server server = ReadUtil.getServer(opcservcerid);
Map<String, Object> itemMap = new HashMap<String, Object>(); Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command); itemMap.put(to_command, command);
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, String.valueOf(command));
} }
public void writing(int type, int command) { public void writing(int type, int command) {
@ -277,6 +278,7 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
log.info("设备:" + device_code + ",下发PLC信号" + to_command + ",value:" + command); log.info("设备:" + device_code + ",下发PLC信号" + to_command + ",value:" + command);
} }
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, String.valueOf(command));
} }
public void writing(String type, String value) { public void writing(String type, String value) {
@ -287,6 +289,7 @@ public class MaGangConveyorDeviceDriver extends AbstractOpcDeviceDriver implemen
Map<String, Object> itemMap = new HashMap<String, Object>(); Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(param, value); itemMap.put(param, value);
ReadUtil.write(itemMap, server); ReadUtil.write(itemMap, server);
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), param, value);
} }
@Override @Override

49
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AgvToAcsServiceImpl.java

@ -9,7 +9,6 @@ import org.nl.acs.device_driver.maGang.MaGangConveyorDeviceDriver;
import org.nl.acs.ext.wms.service.AgvToAcsService; import org.nl.acs.ext.wms.service.AgvToAcsService;
import org.nl.acs.instruction.service.InstructionService; import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.dto.Instruction; import org.nl.acs.instruction.service.dto.Instruction;
import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.Device; import org.nl.acs.opc.Device;
import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppService;
import org.nl.modules.common.exception.BadRequestException; import org.nl.modules.common.exception.BadRequestException;
@ -25,7 +24,6 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
private final DeviceAppService deviceAppService; private final DeviceAppService deviceAppService;
private final InstructionService instructionService; private final InstructionService instructionService;
private final DeviceExecuteLogService logService;
@Override @Override
public Map<String, Object> waitpointRequest(JSONObject param) { public Map<String, Object> waitpointRequest(JSONObject param) {
@ -33,15 +31,18 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
String inst_code = param.getString("task_code"); String inst_code = param.getString("task_code");
//站点 //站点
String address = param.getString("address"); String address = param.getString("address");
//车号 log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address);
String vehicle_code = param.getString("device_code");
String deviceCode = RouteUtil.getDeviceCode(address); String deviceCode = RouteUtil.getDeviceCode(address);
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code); Instruction instructionDto = instructionService.findByCodeFromCache(inst_code);
if (ObjectUtil.isEmpty(instructionDto)) { if (ObjectUtil.isEmpty(instructionDto)) {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:指令任务号不存在! 指令号:" + inst_code); log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "指令任务号不存在或指令已取消或者指令已完成!");
throw new BadRequestException("请求失败,指令任务号不存在!"); throw new BadRequestException("指令任务号不存在或指令已取消或者指令已完成!");
} }
Device device = deviceAppService.findDeviceByCode(deviceCode); Device device = deviceAppService.findDeviceByCode(deviceCode);
if (ObjectUtil.isEmpty(device)) {
log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "设备号:'" + deviceCode + "'有误,请检查!");
throw new BadRequestException("设备号:'" + deviceCode + "'有误,请检查!");
}
MaGangConveyorDeviceDriver maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver(); MaGangConveyorDeviceDriver maGangConveyorDeviceDriver = (MaGangConveyorDeviceDriver) device.getDeviceDriver();
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("status", 200); map.put("status", 200);
@ -49,55 +50,55 @@ public class AgvToAcsServiceImpl implements AgvToAcsService {
//取货点等待 //取货点等待
if (address.contains("INGET")) { if (address.contains("INGET")) {
//告诉设备请求取货 //告诉设备请求取货
maGangConveyorDeviceDriver.writing(4); maGangConveyorDeviceDriver.writing("to_command", "4");
//判断是否满足取货条件 //判断是否满足取货条件
if (maGangConveyorDeviceDriver.getMove() == 1 && maGangConveyorDeviceDriver.getAction() == 1) { if (maGangConveyorDeviceDriver.getMove() == 1 && maGangConveyorDeviceDriver.getAction() == 1) {
//满足响应成功 //满足响应成功
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map));
return map; return map;
} else { } else {
//不满足抛异常 //不满足抛异常
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货前-取货点无货!"); log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "不满足取货条件: move = 1 && action = 1");
throw new BadRequestException("请求失败,取货前-取货点无货!"); throw new BadRequestException("请求失败,不满足取货条件: move = 1 && action = 1");
} }
}//取货完成等待 }//取货完成等待
else if (address.contains("OUTGET")) { else if (address.contains("OUTGET")) {
//取货完成以后判断取货点是否有货 //取货完成以后判断取货点是否有货
if (maGangConveyorDeviceDriver.getMove() == 0) { if (maGangConveyorDeviceDriver.getMove() == 0) {
//无货告诉设备取货完成 //无货告诉设备取货完成
maGangConveyorDeviceDriver.writing(2); maGangConveyorDeviceDriver.writing("to_command", "2");
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map));
return map; return map;
} else { } else {
//有货抛异常 //有货抛异常
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:取货完成后-取货点有货!"); log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "请求失败,取货完成后: move = 1!");
throw new BadRequestException("请求失败,取货完成后-取货点有货!"); throw new BadRequestException("请求失败,取货完成后: move = 1!");
} }
}//放货前等待 }//放货前等待
else if (address.contains("INPUT")) { else if (address.contains("INPUT")) {
//告诉设备请求放货 //告诉设备请求放货
maGangConveyorDeviceDriver.writing(5); maGangConveyorDeviceDriver.writing("to_command", "5");
//判断是否满足放货信号 //判断是否满足放货信号
if (maGangConveyorDeviceDriver.getMove() == 0 && maGangConveyorDeviceDriver.getAction() == 2) { if (maGangConveyorDeviceDriver.getMove() == 0 && maGangConveyorDeviceDriver.getAction() == 2) {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map));
return map; return map;
} else { } else {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货前-放货点有货!"); log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "放货前不满足放货条件: move = 0 && action = 2!");
throw new BadRequestException("请求失败,放货前-放货点有货!"); throw new BadRequestException("请求失败,放货前不满足放货条件: move = 0 && action = 2!");
} }
}//放货完成等待 }//放货完成等待
else if (address.contains("OUTPUT")) { else if (address.contains("OUTPUT")) {
//放货完成后判断放货点是否有货 //放货完成后判断放货点是否有货
if (maGangConveyorDeviceDriver.getMove() == 1) { if (maGangConveyorDeviceDriver.getMove() == 1) {
maGangConveyorDeviceDriver.writing(3); maGangConveyorDeviceDriver.writing("to_command", "3");
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求成功-响应参数:" + map.toString()); log.info("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},响应参数:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, String.valueOf(map));
return map; return map;
} else { } else {
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:放货完成后-放货点无货!"); log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "放货完成后: move = 0 !");
throw new BadRequestException("请求失败,放货完成后-放货点无货!"); throw new BadRequestException("请求失败,放货完成后: move = 0!");
} }
} }
logService.deviceExecuteLog(deviceCode, vehicle_code, inst_code, "请求路径:api/agv/waitpointRequest,请求参数:" + param.toString() + ",请求失败-原因:请求失败,地址有误! 地址:" + address); log.error("请求等待点,请求路径:{},请求参数:{},指令号:{},站点:{},请求失败:{}", "api/agv/waitpointRequest", String.valueOf(param), inst_code, address, "请求失败,地址:'" + address + "'->有误!");
throw new BadRequestException("请求失败,地址有误!"); throw new BadRequestException("请求失败,地址:'" + address + "'->有误!");
} }
} }

6
acs/nladmin-system/src/main/resources/config/application-prod.yml

@ -6,9 +6,9 @@ spring:
druid: druid:
db-type: com.alibaba.druid.pool.DruidDataSource db-type: com.alibaba.druid.pool.DruidDataSource
driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy driverClassName: net.sf.log4jdbc.sql.jdbcapi.DriverSpy
url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:nmd_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true url: jdbc:log4jdbc:mysql://${DB_HOST:127.0.0.1}:${DB_PORT:3306}/${DB_NAME:magang_acs}?serverTimezone=Asia/Shanghai&characterEncoding=utf8&useSSL=false&useOldAliasMetadataBehavior=true
username: ${DB_USER:root} username: ${DB_USER:root}
password: ${DB_PWD:123456} password: ${DB_PWD:123}
# 初始连接数 # 初始连接数
initial-size: 5 initial-size: 5
# 最小连接数 # 最小连接数
@ -154,4 +154,4 @@ loki:
systemName: acs systemName: acs
agvToAcs: agvToAcs:
addr: http://127.0.0.1:8010 addr: http://192.168.0.214:8010

2
acs/nladmin-system/src/main/resources/config/application.yml

@ -2,7 +2,7 @@ spring:
freemarker: freemarker:
check-template-location: false check-template-location: false
profiles: profiles:
active: dev active: prod
jackson: jackson:
time-zone: GMT+8 time-zone: GMT+8
data: data:

Loading…
Cancel
Save