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,7 +153,7 @@ 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());
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONArray array = new JSONArray();
@@ -216,7 +217,7 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
if (StrUtil.equals(inst2.getInstruction_status(), "1")) {
this.finish_instruction(inst2);
//获取当前工单数量
TaskDto taskDto = taskserver.findByCode(inst2.getTask_code());
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();
@@ -275,6 +276,7 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
//行架机械手申请任务
if (mode == 2 && move == 0 && task == 0 && !requireSucess) {
applyTask();
log.info("行架机械手开始申请任务");
}
}
@@ -313,13 +315,9 @@ public class HfGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver imp
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 {
List<TaskDto> taskDtoList = taskserver.queryTaskByDeviceCode(startDeviceCode);
@@ -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,6 +420,29 @@ 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);

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;
@@ -192,7 +192,7 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
inst1.setInstruction_status("1");
instructionService.update(inst1);
TaskDto taskDto = taskserver.findByCode(inst1.getTask_code());
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONArray array = new JSONArray();
@@ -215,7 +215,7 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
if (StrUtil.equals(inst1.getInstruction_status(), "1")) {
finish_instruction(inst1);
JSONArray array = new JSONArray();
TaskDto taskDto = taskserver.findByCode(inst1.getTask_code());
TaskDto taskDto = taskserver.findByCodeFromCache(inst1.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONObject map = new JSONObject();
@@ -226,7 +226,6 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
acsToWmsService.feedbackTaskStatusToWms(array);
}
}
writing("to_command1", "0");
writing("to_onset1", "0");
writing("to_target1", "0");
@@ -243,7 +242,7 @@ 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());
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONArray array = new JSONArray();
@@ -266,7 +265,7 @@ 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());
TaskDto taskDto = taskserver.findByCodeFromCache(inst2.getTask_code());
if (ObjectUtil.isNotEmpty(taskDto)) {
if (StrUtil.isNotEmpty(taskDto.getExt_task_id())) {
JSONObject map = new JSONObject();
@@ -277,7 +276,6 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
acsToWmsService.feedbackTaskStatusToWms(array);
}
}
writing("to_command2", "0");
writing("to_onset2", "0");
writing("to_target2", "0");
@@ -436,12 +434,7 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
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 {
@@ -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;
}
}
@@ -532,12 +518,7 @@ public class HfTwoRGVDeviceDriver extends AbstractOpcDeviceDriver implements Dev
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 {
@@ -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;

View File

@@ -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);
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;
}

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>

View File

@@ -2,6 +2,6 @@ ENV = 'production'
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇Nginx 配置
# 接口地址,注意协议,如果你没有配置 ssl需要将 https 改为 http
VUE_APP_BASE_API = 'http://47.97.157.227:8010'
VUE_APP_BASE_API = 'http://127.0.0.1:8010'
# 如果接口是 http 形式, wss 需要改为 ws
VUE_APP_WS_API = 'ws://47.97.157.227:8010'
VUE_APP_WS_API = 'ws://127.0.0.1:8010'

View File

@@ -53,7 +53,7 @@
<el-row>
<el-col :span="8">
<el-form-item label="电气调度号" label-width="150px">
<el-input v-model="form.OPCServer" />
<el-input v-model="form.address" />
</el-form-item>
</el-col>
</el-row>
@@ -263,7 +263,8 @@ export default {
apply_empty: [],
manual_create_task: true,
is_pickup: true,
is_release: true
is_release: true,
address: ''
},
rules: {}
}

View File

@@ -87,15 +87,15 @@
<el-form-item label="当前设备名称" prop="device_code">
<el-select
ref="test"
v-model="form.device_code"
filterable
ref="test"
clearable
multiple
reserveKeyword
@change="change"
reserve-keyword
placeholder="请选择"
style="width: 370px;"
@change="change"
>
<el-option
v-for="item in deviceList"
@@ -111,7 +111,7 @@
v-model="form.next_device_code"
filterable
clearable
reserveKeyword
reserve-keyword
multiple
placeholder="请选择"
style="width: 370px;"
@@ -313,6 +313,13 @@ export default {
this.form.next_device_code = Array.of(data.form.next_device_code.split('').join(''))
return true
},
[CRUD.HOOK.beforeSubmit](data) {
if (this.crud.status.edit === 1) {
this.form.device_code = data.form.device_code.join('')
this.form.next_device_code = data.form.next_device_code.join('')
}
return true
},
// 改变状态
changeEnabled(data) {
var msg = '停用'

View File

@@ -2,6 +2,6 @@ ENV = 'production'
# 如果使用 Nginx 代理后端接口,那么此处需要改为 '/',文件查看 Docker 部署篇Nginx 配置
# 接口地址,注意协议,如果你没有配置 ssl需要将 https 改为 http
VUE_APP_BASE_API = 'http://47.97.157.227:8010'
VUE_APP_BASE_API = 'http://127.0.0.1:8011'
# 如果接口是 http 形式, wss 需要改为 ws
VUE_APP_WS_API = 'ws://47.97.157.227:8010'
VUE_APP_WS_API = 'ws://127.0.0.1:8011'