Browse Source

rev:代码优化

master
涂强 7 months ago
parent
commit
5168c04dc3
  1. 2
      acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java
  2. 90
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java
  3. 3
      acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

2
acs/nladmin-system/src/main/java/org/nl/acs/AcsConfig.java

@ -56,4 +56,6 @@ public interface AcsConfig {
String MAXSENDTASKTIME = "maxSendTaskTime";
//指令下发立库
String INSTSENDLK = "instSendLk";
//接口延迟时间
String LAZYTIME = "lazyTime";
}

90
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/basedriver/agv/xg_agv/XgagvDeviceDriver.java

@ -8,6 +8,7 @@ import com.alibaba.fastjson.JSONObject;
import lombok.Data;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.acs.AcsConfig;
import org.nl.acs.device.device_driver.standard_inspect.ReadUtil;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
@ -138,6 +139,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
int flag = 0;
//任务号
String order = "";
boolean requireSucess = false;
@Override
public Device getDevice() {
@ -188,6 +190,14 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
new LuceneLogDto(this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.device_code, ItemProtocol.to_home_relocation, this.last_home_relocation, this.home_relocation));
}
if (DO8 != last_DO8) {
this.setRequireSucess(true);
luceneExecuteLogService.deviceExecuteLog(
new LuceneLogDto(this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.device_code, ItemProtocol.to_home_relocation, this.last_home_relocation, this.home_relocation));
}
if (stop != last_stop) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
@ -269,11 +279,8 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
}
} else {
order = inst.getTask_code();
TaskDto task = taskserver.findByCodeFromCache(inst.getTask_code());
Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
Device next_device = deviceAppService.findDeviceByCode(inst.getNext_device_code());
int start_device_code = Integer.parseInt(start_device.getAddress());
int next_device_code = Integer.parseInt(next_device.getAddress());
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver;
//指令状态就绪
@ -285,12 +292,12 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
String next_addr = next_device.getExtraValue().get("address").toString();
String line_code = start_addr + next_addr;
int to_line_code = Integer.parseInt(line_code);
inst.setInstruction_status("1");
if ("A4".equals(inst.getStart_device_code())) {
inst.setExecute_status("1");
} else {
inst.setExecute_status("3");
}
inst.setInstruction_status("1");
instructionService.update(inst);
writing("to_locate_correct", 1);
writing("to_reclaim_control", 1);
@ -353,6 +360,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
last_angle = angle;
last_x = x;
last_y = y;
last_DO8 = DO8;
}
@ -367,7 +375,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
.device_code(device_code)
.content("下发信号" + this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.device_code + "." + key + "value:" + value)
.build();
luceneExecuteLogService.deviceExecuteLog(resplogDto);
ReadUtil.write(itemMap, server);
}
@ -447,12 +455,14 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
.status_code(String.valueOf(resp.getStatus()))
.build();
luceneExecuteLogService.deviceExecuteLog(resplogDto);
JSONObject json = JSONObject.parseObject(resp.body());
log.info("feedAgvTaskStatus----返回参数{}", json.toString());
if (resp.getStatus() == 200) {
inst.setInstruction_status("1");
log.info("feedAgvTaskStatus----返回参数{}", jo.toString());
inst.setExecute_status("2");
instructionService.update(inst);
//结束任务
//结束任务finish_instruction
finish_instruction(inst);
} else {
@ -528,7 +538,6 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
// inst.setInstruction_status("1");
// inst.setExecute_status("4");
// instructionService.update(inst);
inst.setInstruction_status("1");
inst.setExecute_status("4");
instructionService.update(inst);
//结束任务
@ -641,11 +650,6 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
}
public boolean feedAgvAction(String type) throws Exception {
Date date = new Date();
if (date.getTime() - this.instruction_require_time.getTime() < (long) this.instruction_require_time_out) {
log.trace("触发时间因为小于{}毫秒,而被无视", this.instruction_require_time_out);
return false;
} else {
if (StrUtil.equals(type, "5")) {
JSONArray ja = new JSONArray();
JSONObject jo = new JSONObject();
@ -661,7 +665,21 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
.method("feedAgvTaskStatus")
.build();
luceneExecuteLogService.deviceExecuteLog(reqlogDto);
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
HttpResponse resp = null;
try {
resp = acsToWmsService.feedAgvTaskStatus(ja);
if (resp.getStatus() == 200) {
writing("to_di_height", 0);
JSONObject jo1 = JSONObject.parseObject(resp.body());
log.info("feedAgvTaskStatus----返回参数{}", jo1.toString());
} else {
JSONObject jo1 = JSONObject.parseObject(resp.body());
log.info("feedAgvTaskStatus----返回参数{}", jo1.toString());
}
} catch (Exception e) {
JSONObject jo1 = JSONObject.parseObject(resp.body());
log.info("feedAgvTaskStatus----返回参数{}", jo1.toString());
}
LuceneLogDto resplogDto = LuceneLogDto.builder()
.device_code(device_code)
.content("返回参数:" + resp.body())
@ -670,11 +688,6 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
.status_code(String.valueOf(resp.getStatus()))
.build();
luceneExecuteLogService.deviceExecuteLog(resplogDto);
if (resp.getStatus() == 200) {
writing("to_di_height", 0);
} else {
}
} else if (StrUtil.equals(type, "6")) {
JSONArray ja = new JSONArray();
JSONObject jo = new JSONObject();
@ -683,12 +696,37 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
jo.put("vehicle_code", "");
jo.put("task_code", "");
ja.add(jo);
HttpResponse resp = acsToWmsService.feedAgvTaskStatus(ja);
if (resp.getStatus() == 200) {
writing("to_di_low", 0);
} else {
LuceneLogDto reqlogDto = LuceneLogDto.builder()
.device_code(device_code)
.content("请求参数:" + jo)
.requestparam("请求参数:" + jo)
.method("feedAgvTaskStatus")
.build();
luceneExecuteLogService.deviceExecuteLog(reqlogDto);
HttpResponse resp = null;
try {
resp = acsToWmsService.feedAgvTaskStatus(ja);
if (resp.getStatus() == 200) {
writing("to_di_low", 0);
JSONObject jo1 = JSONObject.parseObject(resp.body());
log.info("feedAgvTaskStatus----返回参数{}", jo1.toString());
} else {
JSONObject jo1 = JSONObject.parseObject(resp.body());
log.info("feedAgvTaskStatus----返回参数{}", jo1.toString());
}
} catch (Exception e) {
JSONObject jo1 = JSONObject.parseObject(resp.body());
log.info("feedAgvTaskStatus----返回参数{}", jo1.toString());
}
LuceneLogDto resplogDto = LuceneLogDto.builder()
.device_code(device_code)
.content("返回参数:" + resp.body())
.responseparam("返回参数:" + resp.body())
.method("feedAgvTaskStatus")
.status_code(String.valueOf(resp.getStatus()))
.build();
luceneExecuteLogService.deviceExecuteLog(resplogDto);
} else if (StrUtil.equals(type, "7")) {
JSONArray ja = new JSONArray();
JSONObject jo = new JSONObject();
@ -704,7 +742,7 @@ public class XgagvDeviceDriver extends AbstractOpcDeviceDriver implements Device
}
}
}
return true;
}
}

3
acs/nladmin-system/src/main/java/org/nl/acs/ext/wms/service/impl/AcsToWmsServiceImpl.java

@ -545,7 +545,8 @@ public class AcsToWmsServiceImpl implements AcsToWmsService {
.body(String.valueOf(from))
.execute();
System.out.println(result);
log.info("feedAgvTaskStatus----返回参数{}", result);
JSONObject jo = JSONObject.parseObject(result.body());
log.info("feedAgvTaskStatus----返回参数{}", jo.toString());
} catch (Exception e) {
String msg = e.getMessage();
//网络不通

Loading…
Cancel
Save