This commit is contained in:
2022-12-13 22:51:02 +08:00
parent 2bfb5c4e58
commit 65b13047d7
8 changed files with 192 additions and 155 deletions

View File

@@ -27,6 +27,7 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
@@ -152,9 +153,9 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
instructionService.update(inst1);
TaskDto taskDto = taskserver.findByCode(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)){
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("task_id", taskDto.getExt_task_id());
@@ -216,9 +217,9 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
this.finish_instruction(inst2);
//获取当前工单数量
TaskDto taskDto = taskserver.findByCode(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)){
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
String next_device_code = inst2.getNext_device_code();
Device device = appService.findDeviceByCode(next_device_code);
HfStationDeviceDriver hfStationDeviceDriver;
@@ -275,6 +276,7 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
//行架机械手申请任务
if (mode == 2 && move == 0 && task == 0 && !requireSucess) {
applyTask();
log.info("行架机械手开始申请任务");
}
}
@@ -307,21 +309,17 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
for (int i = 0; i < getDeviceCodeList.size(); i++) {
String startDeviceCode = getDeviceCodeList.get(i);
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtos)){
if (ObjectUtil.isNotEmpty(taskDtos)) {
TaskDto taskDto = taskDtos.get(0);
Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code());
instruction.setInstruction_status("1");
instruction.setUpdate_time(DateUtil.now());
instructionService.update(instruction);
int start_addrIndex = getDeviceCodeList.indexOf(instruction.getStart_device_code());
int next_addrIndex = putDeviceCodeList.indexOf(instruction.getNext_device_code());
writing("to_onset", String.valueOf(start_addrIndex + 1));
writing("to_target", String.valueOf(next_addrIndex + 1));
writing("to_task", instruction.getInstruction_code());
writing("to_command", "1");
this.sendSignalType(instruction);
this.setRequireSucess(true);
log.info("重新生成指令任务生成成功,指令号:{}", instruction.getInstruction_code());
return true;
}else {
} else {
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtoList)) {
task = taskDtoList.get(0);
@@ -362,20 +360,16 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
try {
instructionService.create(instdto);
log.info("就绪任务生成指令生成成功,指令号:{}", instdto.getInstruction_code());
} catch (Exception e) {
log.error("就绪任务生成指令生成失败,任务号:{}", task.getTask_code());
e.printStackTrace();
}
//创建指令后修改任务状态
task.setTask_status("1");
task.setUpdate_time(DateUtil.now());
taskserver.update(task);
//根据获取托盘信息返回的结果 得到对应抓取工位/放货工位设备编码所在的索引位置
int start_addrIndex = getDeviceCodeList.indexOf(start_device_code);
int next_addrIndex = putDeviceCodeList.indexOf(next_device_code);
writing("to_onset", String.valueOf(start_addrIndex + 1));
writing("to_target", String.valueOf(next_addrIndex + 1));
writing("to_task", instdto.getInstruction_code());
writing("to_command", "1");
this.sendSignalType(instdto);
this.setRequireSucess(true);
}
return true;
@@ -426,10 +420,33 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
}
public synchronized void sendSignalType(Instruction dto) {
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();
Device startDevice = appService.findDeviceByCode(start_device_code);
Device nextDevice = appService.findDeviceByCode(next_device_code);
this.isSetAddress(startDevice);
this.isSetAddress(nextDevice);
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
this.writing("to_onset", start_addr);
this.writing("to_target", next_addr);
this.writing("to_task", dto.getInstruction_code());
this.writing("to_command", "1");
}
//判断点位是否设置电气值
public void isSetAddress(Device device) {
if (ObjectUtil.isEmpty(device.getExtraValue().get("address"))) {
log.error("设备:{},未设置电气调度号!", device.getDevice_code());
throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!");
}
}
//将扩展表中的字符串数据转换成集合
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)){
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);

View File

@@ -27,6 +27,7 @@ import org.nl.acs.opc.DeviceAppServiceImpl;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.modules.common.exception.BadRequestException;
import org.nl.modules.wql.util.SpringContextHolder;
import org.openscada.opc.lib.da.Server;
import org.springframework.beans.factory.annotation.Autowired;
@@ -90,7 +91,6 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
int last_task2 = 0;
Boolean isonline = true;
//后工位申请任务请求标记
Boolean requireBackSucess = false;
@@ -151,14 +151,14 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
logServer.deviceExecuteLog(this.device_code, "", "", "信号status" + last_status + "->" + status);
}
if (move1 != last_move1) {
if (move1 == 0){
if (move1 == 0) {
this.setRequireHeadSucess(false);
}
logServer.deviceItemValue(this.device_code, "move1", String.valueOf(move1));
logServer.deviceExecuteLog(this.device_code, "", "", "信号move1" + last_move1 + "->" + move1);
}
if (move2 != last_move2) {
if (move2 == 0){
if (move2 == 0) {
this.setRequireBackSucess(false);
}
logServer.deviceItemValue(this.device_code, "move2", String.valueOf(move2));
@@ -186,19 +186,19 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
}
//前工位任务就绪->执行
if ( task1 > 0) {
if (task1 > 0) {
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
instructionService.update(inst1);
TaskDto taskDto = taskserver.findByCode(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)){
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("task_id",taskDto.getExt_task_id());
map.put("task_status","1");
map.put("task_id", taskDto.getExt_task_id());
map.put("task_status", "1");
array.add(map);
acsToWmsService.feedbackTaskStatusToWms(array);
}
@@ -210,23 +210,22 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
//前工位放货完成 任务完成
if (mode == 3 && action1 == 4 && move1 == 0 && task1 > 0) {
//inst_message
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
if (inst1 != null) {
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
finish_instruction(inst1);
JSONArray array = new JSONArray();
TaskDto taskDto = taskserver.findByCode(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)){
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONObject map = new JSONObject();
map.put("task_id",taskDto.getExt_task_id());
map.put("task_status","2");
map.put("finished_type","1");
map.put("task_id", taskDto.getExt_task_id());
map.put("task_status", "2");
map.put("finished_type", "1");
array.add(map);
acsToWmsService.feedbackTaskStatusToWms(array);
}
}
writing("to_command1", "0");
writing("to_onset1", "0");
writing("to_target1", "0");
@@ -243,13 +242,13 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
if (StrUtil.equals(inst2.getInstruction_status(), "0")) {
inst2.setInstruction_status("1");
instructionService.update(inst2);
TaskDto taskDto = taskserver.findByCode(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)){
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONArray array = new JSONArray();
JSONObject map = new JSONObject();
map.put("task_id",taskDto.getExt_task_id());
map.put("task_status","1");
map.put("task_id", taskDto.getExt_task_id());
map.put("task_status", "1");
array.add(map);
acsToWmsService.feedbackTaskStatusToWms(array);
}
@@ -266,18 +265,17 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
finish_instruction(inst2);
JSONArray array = new JSONArray();
TaskDto taskDto = taskserver.findByCode(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)){
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())){
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONObject map = new JSONObject();
map.put("task_id",taskDto.getExt_task_id());
map.put("task_status","2");
map.put("finished_type","1");
map.put("task_id", taskDto.getExt_task_id());
map.put("task_status", "2");
map.put("finished_type", "1");
array.add(map);
acsToWmsService.feedbackTaskStatusToWms(array);
}
}
writing("to_command2", "0");
writing("to_onset2", "0");
writing("to_target2", "0");
@@ -292,61 +290,61 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
String start_device_code = inst1.getStart_device_code();
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
HfStationDeviceDriver hfStationDeviceDriver;
if (startDevice.getDeviceDriver() instanceof HfStationDeviceDriver){
if (startDevice.getDeviceDriver() instanceof HfStationDeviceDriver) {
hfStationDeviceDriver = (HfStationDeviceDriver) startDevice.getDeviceDriver();
int move = hfStationDeviceDriver.getMove();
if (move == 1){
if (move == 1) {
this.writing("to_command1", "2");
} else {
log.warn("前工位取货位无货,取货位:{}",start_device_code);
log.warn("前工位取货位无货,取货位:{}", start_device_code);
}
}
}
//前工位放货时判断放货位光电信号
if (mode == 3 && action1 == 3 && move1 == 1 && task1 > 0){
if (mode == 3 && action1 == 3 && move1 == 1 && task1 > 0) {
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task1));
String next_device_code = inst1.getNext_device_code();
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code);
HfStationDeviceDriver hfStationDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof HfStationDeviceDriver){
if (nextDevice.getDeviceDriver() instanceof HfStationDeviceDriver) {
hfStationDeviceDriver = (HfStationDeviceDriver) nextDevice.getDeviceDriver();
int move = hfStationDeviceDriver.getMove();
if (move == 0){
this.writing("to_command1","3");
if (move == 0) {
this.writing("to_command1", "3");
} else {
log.warn("前工位放货位有货,放货位:{}",next_device_code);
log.warn("前工位放货位有货,放货位:{}", next_device_code);
}
}
}
//后工位取货时判断取货位光电信号
if (mode == 3 && action2 == 2 && move2 == 0 && task2 > 0){
if (mode == 3 && action2 == 2 && move2 == 0 && task2 > 0) {
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2));
String start_device_code = inst1.getStart_device_code();
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
HfStationDeviceDriver hfStationDeviceDriver;
if (startDevice.getDeviceDriver() instanceof HfStationDeviceDriver){
if (startDevice.getDeviceDriver() instanceof HfStationDeviceDriver) {
hfStationDeviceDriver = (HfStationDeviceDriver) startDevice.getDeviceDriver();
int move = hfStationDeviceDriver.getMove();
if (move == 1){
this.writing("to_command2","2");
if (move == 1) {
this.writing("to_command2", "2");
} else {
log.warn("后工位取货位无货,取货位:{}",start_device_code);
log.warn("后工位取货位无货,取货位:{}", start_device_code);
}
}
}
//后工位放货时判断放货位光电信号
if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0){
if (mode == 3 && action2 == 3 && move2 == 1 && task2 > 0) {
Instruction inst1 = instructionService.findByCodeFromCache(String.valueOf(task2));
String next_device_code = inst1.getNext_device_code();
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code);
HfStationDeviceDriver hfStationDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof HfStationDeviceDriver){
if (nextDevice.getDeviceDriver() instanceof HfStationDeviceDriver) {
hfStationDeviceDriver = (HfStationDeviceDriver) nextDevice.getDeviceDriver();
int move = hfStationDeviceDriver.getMove();
if (move == 0){
this.writing("to_command2","3");
if (move == 0) {
this.writing("to_command2", "3");
} else {
log.warn("后工位放货位有货,放货位:{}",next_device_code);
log.warn("后工位放货位有货,放货位:{}", next_device_code);
}
}
}
@@ -384,19 +382,19 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
//后工位申请任务
if (mode == 2 && move2 == 0 && action2 == 0 && !requireBackSucess) {
instruction_require2();
logServer.deviceExecuteLog(device_code,"",String.valueOf(task2),"move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireBackSucess:" + requireBackSucess);
logServer.deviceExecuteLog(device_code, "", String.valueOf(task2), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireBackSucess:" + requireBackSucess);
}
//前工位申请任务
if (mode == 2 && move2 == 0 && action2 == 0 && task2 == 0 && move1 == 0 && task1 > 0 && !requireHeadSucess) {
instruction_require();
logServer.deviceExecuteLog(device_code,"",String.valueOf(task1),"move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireHeadSucess:" + requireHeadSucess);
logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireHeadSucess:" + requireHeadSucess);
}
break;
case 3:
//前工位申请任务
if (mode == 3 && move2 == 1 && action2 == 1 && move1 == 0 && action1 == 0 && !requireHeadSucess) {
instruction_require();
logServer.deviceExecuteLog(device_code,"",String.valueOf(task1),"move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireHeadSucess:" + requireHeadSucess);
logServer.deviceExecuteLog(device_code, "", String.valueOf(task1), "move2:" + move2 + ",action2:" + action2 + ",move1:" + move1 + ",task2:" + task2 + ",requireHeadSucess:" + requireHeadSucess);
}
}
@@ -430,21 +428,16 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
for (int i = 0; i < getDeviceCodeList.size(); i++) {
String startDeviceCode = getDeviceCodeList.get(i);
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtos)){
if (ObjectUtil.isNotEmpty(taskDtos)) {
TaskDto taskDto = taskDtos.get(0);
Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code());
instruction.setInstruction_status("1");
instruction.setUpdate_time(DateUtil.now());
instructionService.update(instruction);
int start_addrIndex = getDeviceCodeList.indexOf(instruction.getStart_device_code());
int next_addrIndex = putDeviceCodeList.indexOf(instruction.getNext_device_code());
this.writing("to_onset1", String.valueOf(start_addrIndex + 1));
this.writing("to_target1", String.valueOf(next_addrIndex + 1));
this.writing("to_task1", instruction.getInstruction_code());
this.writing("to_command1", "1");
this.sendHeadSignalType(instruction);
requireHeadSucess = true;
return true;
}else {
} else {
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtoList)) {
task = taskDtoList.get(0);
@@ -494,14 +487,7 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
task.setTask_status("1");
task.setUpdate_time(DateUtil.now());
taskserver.update(task);
//根据查询的任务起始点位 得出取放工位的索引值 写入后工位电气中
int start_addrIndex = getDeviceCodeList.indexOf(start_device_code);
int next_addrIndex = putDeviceCodeList.indexOf(next_device_code);
this.writing("to_onset1", String.valueOf(start_addrIndex + 1));
this.writing("to_target1", String.valueOf(next_addrIndex + 1));
this.writing("to_task1", instdto.getInstruction_code());
this.writing("to_command1", "1");
this.sendHeadSignalType(instdto);
requireHeadSucess = true;
}
}
@@ -526,21 +512,16 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
for (int i = 0; i < getDeviceCodeList.size(); i++) {
String startDeviceCode = getDeviceCodeList.get(i);
List<TaskDto> taskDtos = taskserver.queryTaskByDeviceCodeAndStatus(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtos)){
if (ObjectUtil.isNotEmpty(taskDtos)) {
TaskDto taskDto = taskDtos.get(0);
Instruction instruction = instructionService.findByTaskcode(taskDto.getTask_code());
instruction.setInstruction_status("1");
instruction.setUpdate_time(DateUtil.now());
instructionService.update(instruction);
int start_addrIndex = getDeviceCodeList.indexOf(instruction.getStart_device_code());
int next_addrIndex = putDeviceCodeList.indexOf(instruction.getNext_device_code());
this.writing("to_onset1", String.valueOf(start_addrIndex + 1));
this.writing("to_target1", String.valueOf(next_addrIndex + 1));
this.writing("to_task1", instruction.getInstruction_code());
this.writing("to_command1", "1");
this.sendBackSignalType(instruction);
requireBackSucess = true;
return true;
}else {
} else {
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
if (ObjectUtil.isNotEmpty(taskDtoList)) {
task = taskDtoList.get(0);
@@ -589,20 +570,50 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
//创建指令后修改任务状态
task.setTask_status("1");
taskserver.update(task);
//根据查询的任务起始点位 得出取放工位的索引值 写入后工位电气中
int start_addrIndex = getDeviceCodeList.indexOf(start_device_code);
int next_addrIndex = putDeviceCodeList.indexOf(next_device_code);
this.writing("to_onset2", String.valueOf(start_addrIndex + 1));
this.writing("to_target2", String.valueOf(next_addrIndex + 1));
this.writing("to_task2", instdto.getInstruction_code());
this.writing("to_command2", "1");
requireBackSucess = true;
this.sendBackSignalType(instdto);
}
}
return true;
}
public synchronized void sendHeadSignalType(Instruction dto) {
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code);
this.isSetAddress(startDevice);
this.isSetAddress(nextDevice);
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
this.writing("to_onset1", start_addr);
this.writing("to_target1", next_addr);
this.writing("to_task1", dto.getInstruction_code());
this.writing("to_command1", "1");
}
public synchronized void sendBackSignalType(Instruction dto) {
String start_device_code = dto.getStart_device_code();
String next_device_code = dto.getNext_device_code();
Device startDevice = deviceAppservice.findDeviceByCode(start_device_code);
Device nextDevice = deviceAppservice.findDeviceByCode(next_device_code);
this.isSetAddress(startDevice);
this.isSetAddress(nextDevice);
String start_addr = startDevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
this.writing("to_onset2", start_addr);
this.writing("to_target2", next_addr);
this.writing("to_task2", dto.getInstruction_code());
this.writing("to_command2", "1");
}
//判断点位是否设置电气值
public void isSetAddress(Device device) {
if (ObjectUtil.isEmpty(device.getExtraValue().get("address"))) {
log.error("设备:{},未设置电气调度号!", device.getDevice_code());
throw new BadRequestException("设备:" + device.getDevice_code() + "未设置电气调度号!");
}
}
public boolean exe_error() {
if (this.error == 0) {
return true;
@@ -684,9 +695,9 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
}
//将扩展表中的字符串数组数据转换成集合
public List<String> getExtraDeviceCodes(String extraName){
public List<String> getExtraDeviceCodes(String extraName) {
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
if (StrUtil.isEmpty(extraValue)){
if (StrUtil.isEmpty(extraValue)) {
return new ArrayList<>();
}
String devicesString = extraValue.substring(1, extraValue.length() - 1);

View File

@@ -67,7 +67,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
DeviceAppService deviceAppService;
@Autowired
NDCAgvService ndcAgvService;
@Autowired
@Autowired
ParamService paramService;
@Autowired
RouteLineService routeLineService;
@@ -220,10 +220,11 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
@Override
public Instruction findByTaskcode(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
JSONObject json = wo.query("task_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
JSONObject json = wo.query("instruction_status = '0' and task_code ='" + code + "'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)) {
final Instruction obj = json.toJavaObject(Instruction.class);
return obj;
}
return null;
}
@@ -232,7 +233,7 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
public Instruction findByTaskcodeAndStatus(String code) {
WQLObject wo = WQLObject.getWQLObject("acs_instruction");
JSONObject json = wo.query("task_code ='" + code + "' and instruction_status = '0'").uniqueResult(0);
if (ObjectUtil.isNotEmpty(json)){
if (ObjectUtil.isNotEmpty(json)) {
final Instruction obj = json.toJavaObject(Instruction.class);
return obj;
}
@@ -326,20 +327,20 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
if (startdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) startdevice.getDeviceDriver();
cargoLiftConveyorDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver){
if (nextdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) nextdevice.getDeviceDriver();
standardCoveyorControlWithScannerDeviceDriver.writing(1,1);
standardCoveyorControlWithScannerDeviceDriver.writing(1, 1);
String address = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("address").toString();
if (StrUtil.isEmpty(address)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!");
if (StrUtil.isEmpty(address)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置电气调度号!");
}
String door = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("door").toString();
if (StrUtil.isEmpty(door)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!");
if (StrUtil.isEmpty(door)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置门!");
}
String floor = standardCoveyorControlWithScannerDeviceDriver.getExtraValue().get("floor").toString();
if (StrUtil.isEmpty(floor)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
if (StrUtil.isEmpty(floor)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置楼层!");
}
standardCoveyorControlWithScannerDeviceDriver.writing(2, Integer.parseInt(address));
standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.parseInt(task_code));
@@ -350,20 +351,20 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
if (startdevice.getDeviceDriver() instanceof StandardCoveyorControlWithScannerDeviceDriver) {
standardCoveyorControlWithScannerDeviceDriver = (StandardCoveyorControlWithScannerDeviceDriver) startdevice.getDeviceDriver();
standardCoveyorControlWithScannerDeviceDriver.writing(3, Integer.valueOf(dto.getInstruction_code()));
if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver){
if (nextdevice.getDeviceDriver() instanceof CargoLiftConveyorDeviceDriver) {
cargoLiftConveyorDeviceDriver = (CargoLiftConveyorDeviceDriver) nextdevice.getDeviceDriver();
cargoLiftConveyorDeviceDriver.writing(1,1);
cargoLiftConveyorDeviceDriver.writing(1, 1);
String address = cargoLiftConveyorDeviceDriver.getExtraValue().get("address").toString();
if (StrUtil.isEmpty(address)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置电气调度号!");
if (StrUtil.isEmpty(address)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置电气调度号!");
}
String door = cargoLiftConveyorDeviceDriver.getExtraValue().get("door").toString();
if (StrUtil.isEmpty(door)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置门!");
if (StrUtil.isEmpty(door)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置门!");
}
String floor = cargoLiftConveyorDeviceDriver.getExtraValue().get("floor").toString();
if (StrUtil.isEmpty(floor)){
throw new BadRequestException("设备:"+nextdevice.getDevice_code()+"未设置楼层!");
if (StrUtil.isEmpty(floor)) {
throw new BadRequestException("设备:" + nextdevice.getDevice_code() + "未设置楼层!");
}
cargoLiftConveyorDeviceDriver.writing(2, Integer.parseInt(address));
cargoLiftConveyorDeviceDriver.writing(3, Integer.parseInt(task_code));
@@ -386,12 +387,12 @@ public class InstructionServiceImpl implements InstructionService, ApplicationAu
RouteLineDto routeLineDto = shortPathsList.get(i);
String route_device = routeLineDto.getDevice_code();
String route_next_device = routeLineDto.getNext_device_code();
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())){
if (route_device.equals(dto.getStart_device_code()) && route_next_device.equals(dto.getNext_device_code())) {
route = routeLineDto;
break;
}
}
if (ObjectUtil.isEmpty(route)){
if (ObjectUtil.isEmpty(route)) {
throw new BadRequestException("未查询到相关路由!");
}
if (StrUtil.equals(route.getType(), "1")) {

View File

@@ -136,7 +136,7 @@ https://juejin.cn/post/6844903775631572999
<!--生产环境:打印控制台和输出到文件-->
<springProfile name="prod">
<root level="off">
<root level="error">
<appender-ref ref="asyncFileAppender"/>
<appender-ref ref="lokiAppender" />
</root>