fix: 修复入烘箱不创建第二条指令问题
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
package org.nl.acs.device_driver.two_conveyor.hongxiang_device;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
@@ -244,7 +245,31 @@ public class HongXiangConveyorDeviceDriver extends AbstractOpcDeviceDriver imple
|
||||
this.control(itemMap);
|
||||
}
|
||||
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个信号一起下发电气
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
public void writing(Map<String, Object> map) throws Exception {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.checkcontrol(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
//将扩展表中的字符串数据转换成集合
|
||||
@Override
|
||||
public List<String> getExtraDeviceCodes(String extraName) {
|
||||
String extraValue = (String) this.getDevice().getExtraValue().get(extraName);
|
||||
if (StrUtil.isEmpty(extraValue)) {
|
||||
|
||||
@@ -383,9 +383,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
notCreateInstMessage = "手动创建指令未下发电气信号原因->取货位:" + start_device_code + ",放货位:" + next_device_code + ",存在关联的同一列烘箱设备未关门!指令号:" + instruction.getInstruction_code();
|
||||
return false;
|
||||
}
|
||||
instruction.setInstruction_status("1");
|
||||
/*instruction.setInstruction_status("1");
|
||||
instruction.setUpdate_time(DateUtil.now());
|
||||
instructionService.update(instruction);
|
||||
instructionService.update(instruction);*/
|
||||
Device startDevice = deviceAppService.findDeviceByCode(start_device_code);
|
||||
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
|
||||
if (ObjectUtil.isEmpty(startDevice.getExtraValue().get("address"))) {
|
||||
@@ -410,8 +410,11 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
map.put("to_target", next_addr);
|
||||
map.put("to_task", instruction.getInstruction_code());
|
||||
map.put("to_command", "1");
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
try {
|
||||
this.writing(map);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
if (startdevice.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) startdevice.getDeviceDriver();
|
||||
hongXiangConveyorDeviceDriver.writing("to_open_door", "1");
|
||||
@@ -743,6 +746,28 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
return isClose;
|
||||
}
|
||||
|
||||
public String getToParam() {
|
||||
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + ".";
|
||||
}
|
||||
|
||||
/**
|
||||
* 多个信号一起下发电气
|
||||
*
|
||||
* @param map
|
||||
*/
|
||||
public void writing(Map<String, Object> map) throws Exception {
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
Map<String, Object> itemMap = new LinkedHashMap<>();
|
||||
map.forEach((key, value) -> {
|
||||
if (ObjectUtil.isNotEmpty(value)) {
|
||||
itemMap.put(getToParam() + key, value);
|
||||
}
|
||||
});
|
||||
if (ObjectUtil.isNotEmpty(itemMap)) {
|
||||
this.checkcontrol(itemMap);
|
||||
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap);
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void update_instruction_status() throws Exception {
|
||||
Date date = new Date();
|
||||
@@ -751,6 +776,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
|
||||
} else {
|
||||
this.instruction_update_time = date;
|
||||
Map map = new HashMap();
|
||||
//更改任务状态
|
||||
if (task > 0) {
|
||||
Instruction inst1 = checkInst();
|
||||
@@ -758,6 +784,7 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
if (StrUtil.equals(inst1.getInstruction_status(), "0")) {
|
||||
inst1.setInstruction_status("1");
|
||||
inst1.setExecute_device_code(this.device_code);
|
||||
inst1.setUpdate_time(DateUtil.now());
|
||||
instructionService.update(inst1);
|
||||
}
|
||||
}
|
||||
@@ -780,7 +807,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 1) {
|
||||
if (this.getNow_steps_type() == 2) {
|
||||
ArrayList list = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("to_command", "2");
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
@@ -809,7 +835,6 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
} else {
|
||||
if (this.getNow_steps_type() == 2) {
|
||||
ArrayList list = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("to_command", "2");
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
@@ -844,11 +869,11 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
HongXiangConveyorDeviceDriver hongXiangConveyorDeviceDriver;
|
||||
if (device.getDeviceDriver() instanceof HongXiangConveyorDeviceDriver) {
|
||||
hongXiangConveyorDeviceDriver = (HongXiangConveyorDeviceDriver) device.getDeviceDriver();
|
||||
hongXiangConveyorDeviceDriver.writing("to_close_door", "1");
|
||||
map.put("to_close_door", "1");
|
||||
hongXiangConveyorDeviceDriver.writing(map);
|
||||
}
|
||||
if (this.getNow_steps_type() == 3) {
|
||||
ArrayList list = new ArrayList();
|
||||
Map map = new HashMap();
|
||||
map.put("to_command", "3");
|
||||
list.add(map);
|
||||
this.writing(list);
|
||||
@@ -889,7 +914,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
int move = hongXiangConveyorDeviceDriver.getMove();
|
||||
if (mode == 1 && door == 1 && action == 1 && error1 == 0 && move == 0) {
|
||||
if (this.getNow_steps_type() == 4) {
|
||||
this.writing("to_command", "4");
|
||||
map.put("to_command", "4");
|
||||
this.writing(map);
|
||||
this.setNow_steps_type(5);
|
||||
} else {
|
||||
feedMessage = "未反馈电气信号原因:当前步骤不为允许放货(now_steps_type!=4)";
|
||||
@@ -916,7 +942,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
} else {
|
||||
if (this.getNow_steps_type() == 4) {
|
||||
this.writing("to_command", "4");
|
||||
map.put("to_command", "4");
|
||||
this.writing(map);
|
||||
this.setNow_steps_type(5);
|
||||
}
|
||||
}
|
||||
@@ -957,8 +984,9 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
int time = Integer.parseInt(taskDto.getOven_time());
|
||||
int hours = (time % (60 * 60 * 24)) / (60 * 60);
|
||||
int minutes = (time % (60 * 60)) / 60;
|
||||
hongXiangConveyorDeviceDriver.writing("to_time_house", String.valueOf(hours));
|
||||
hongXiangConveyorDeviceDriver.writing("to_time_min", String.valueOf(minutes));
|
||||
map.put("to_time_house", String.valueOf(hours));
|
||||
map.put("to_time_min", String.valueOf(minutes));
|
||||
hongXiangConveyorDeviceDriver.writing(map);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -984,7 +1012,8 @@ public class OvenGantryManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
|
||||
}
|
||||
|
||||
}
|
||||
this.writing("to_command", "5");
|
||||
map.put("to_command", "5");
|
||||
this.writing(map);
|
||||
this.setNow_steps_type(6);
|
||||
this.setNow_steps_type(0);
|
||||
try {
|
||||
|
||||
@@ -250,6 +250,14 @@ public interface InstructionService extends CommonService<InstructionMybatis> {
|
||||
void finishAndCreateNextInst(Instruction dto) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 完成并创建指令
|
||||
*
|
||||
* @param
|
||||
*/
|
||||
void finishAndCreateHXInst(Instruction dto) throws Exception;
|
||||
|
||||
|
||||
/**
|
||||
* 取消指令
|
||||
*
|
||||
|
||||
@@ -372,6 +372,13 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
if(regional(dto.getStart_device_code(), dto.getNext_device_code())){
|
||||
throw new BadRequestException(LangProcess.msg("error_regional_max"));
|
||||
}
|
||||
if(StrUtil.isNotEmpty(dto.getTask_code())){
|
||||
InstructionMybatis instructionMybatis = instructionMapper.selectList(Wrappers.lambdaQuery(InstructionMybatis.class)
|
||||
.eq(InstructionMybatis::getTask_code, dto.getTask_code())).get(0);
|
||||
if(ObjectUtil.isNotEmpty(instructionMybatis) && instructionMybatis.getStart_device_code().equals(dto.getStart_device_code())){
|
||||
return;
|
||||
}
|
||||
}
|
||||
String currentUsername = SecurityUtils.getCurrentNickName();
|
||||
String now = DateUtil.now();
|
||||
if (StrUtil.isEmpty(dto.getRoute_plan_code())) {
|
||||
@@ -868,11 +875,28 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
.one();
|
||||
// =0 则不用再次请求
|
||||
if (StrUtil.equals(task.getRequest_again(), "0")) {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
if(StrUtil.equals(task.getTask_type(),"8")){
|
||||
//中转为空
|
||||
if(StrUtil.isEmpty(task.getPut_device_code())){
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
} else {
|
||||
finishAndCreateNextInst(ConvertUtil.convert(entity, Instruction.class));
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
finishAndCreateHXInst(ConvertUtil.convert(entity, Instruction.class));
|
||||
} else if (StrUtil.equals(task.getPut_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
// finishAndCreateNextInst((Instruction) entity);
|
||||
finishAndCreateNextInst(ConvertUtil.convert(entity, Instruction.class));
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
} else {
|
||||
finishAndCreateNextInst(ConvertUtil.convert(entity, Instruction.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -897,10 +921,28 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
.one();
|
||||
// =0 则不用再次请求
|
||||
if (StrUtil.equals(task.getRequest_again(), "0")) {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
if(StrUtil.equals(task.getTask_type(),"8")){
|
||||
//中转为空
|
||||
if(StrUtil.isEmpty(task.getPut_device_code())){
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
} else {
|
||||
finishAndCreateNextInst(ConvertUtil.convert(ins, Instruction.class));
|
||||
}
|
||||
} else {
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
finishAndCreateHXInst(ConvertUtil.convert(ins, Instruction.class));
|
||||
} else if (StrUtil.equals(task.getPut_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
finishAndCreateNextInst(dto);
|
||||
if (StrUtil.equals(task.getNext_device_code(), instnextdevice)) {
|
||||
taskService.finish(task.getTask_id());
|
||||
} else {
|
||||
finishAndCreateNextInst(ConvertUtil.convert(ins, Instruction.class));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1001,6 +1043,69 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
public void finishAndCreateHXInst(Instruction dto) {
|
||||
dto = foramte(dto);
|
||||
String device_code = dto.getNext_device_code();
|
||||
Task task = taskService.getOne(Wrappers.lambdaQuery(Task.class).eq(Task::getTask_id, dto.getTask_id()));
|
||||
TaskDto acsTask = ConvertUtil.convert(task, TaskDto.class);
|
||||
|
||||
String next_device_code = acsTask.getPut_device_code();
|
||||
String start_device_code = dto.getNext_device_code();
|
||||
String start_point_code = null;
|
||||
String next_point_code = null;
|
||||
String start_device =
|
||||
deviceAppService
|
||||
.findDeviceByCode(start_device_code)
|
||||
.getDeviceDriverDefination()
|
||||
.getFitDeviceTypes()
|
||||
.get(0)
|
||||
.name();
|
||||
String next_device =
|
||||
deviceAppService
|
||||
.findDeviceByCode(next_device_code)
|
||||
.getDeviceDriverDefination()
|
||||
.getFitDeviceTypes()
|
||||
.get(0)
|
||||
.name();
|
||||
if (StrUtil.equals("storage", start_device)) {
|
||||
start_point_code = start_device_code + "-" + acsTask.getFrom_y() + "-" + acsTask.getFrom_z();
|
||||
} else {
|
||||
start_point_code = start_device_code;
|
||||
}
|
||||
if (StrUtil.equals("storage", next_device)) {
|
||||
next_point_code = next_device_code + "-" + acsTask.getTo_y() + "-" + acsTask.getTo_z();
|
||||
} else {
|
||||
next_point_code = next_device_code;
|
||||
}
|
||||
Instruction instdto = new Instruction();
|
||||
instdto.setInstruction_id(IdUtil.simpleUUID());
|
||||
instdto.setRoute_plan_code(acsTask.getRoute_plan_code());
|
||||
instdto.setRemark(acsTask.getRemark());
|
||||
instdto.setMaterial(acsTask.getMaterial());
|
||||
instdto.setQuantity(acsTask.getQuantity());
|
||||
instdto.setTask_id(acsTask.getTask_id());
|
||||
instdto.setTask_code(acsTask.getTask_code());
|
||||
instdto.setVehicle_code(acsTask.getVehicle_code());
|
||||
String now = DateUtil.now();
|
||||
instdto.setCreate_time(now);
|
||||
instdto.setCreate_by("auto");
|
||||
instdto.setStart_device_code(start_device_code);
|
||||
instdto.setNext_device_code(next_device_code);
|
||||
instdto.setStart_point_code(start_point_code);
|
||||
instdto.setNext_point_code(next_point_code);
|
||||
instdto.setPriority(acsTask.getPriority());
|
||||
instdto.setInstruction_status("0");
|
||||
instdto.setExecute_device_code(dto.getNext_device_code());
|
||||
try {
|
||||
this.create(instdto);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("完成并创建下一条指令", e.getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void cancel(String id) throws Exception {
|
||||
// flag= true时取消指令
|
||||
|
||||
@@ -118,6 +118,11 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
*/
|
||||
private CopyOnWriteArrayList<TaskDto> tasks = new CopyOnWriteArrayList<>();
|
||||
|
||||
/**
|
||||
* 烘箱任务类型
|
||||
*/
|
||||
private static final String TASK_TYPE = "8";
|
||||
|
||||
|
||||
@Override
|
||||
public PageInfo<TaskDto> queryAll(TaskQueryParam query, Pageable pageable) {
|
||||
@@ -447,7 +452,8 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
|
||||
@Override
|
||||
public List<TaskDto> queryTaskByDeviceCodeAndStatus(String device_code) {
|
||||
return Optional
|
||||
|
||||
List<TaskDto> collect = Optional
|
||||
.ofNullable(this.tasks)
|
||||
.orElse(new CopyOnWriteArrayList<>())
|
||||
.stream()
|
||||
@@ -455,6 +461,22 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
&& StrUtil.equals(task.getTask_status(), TaskStatusEnum.BUSY.getIndex()))
|
||||
.filter(task -> instructionService.findByTaskcodeAndStatus(task.getTask_code()) != null)
|
||||
.collect(Collectors.toList());
|
||||
if(CollUtil.isEmpty(collect)){
|
||||
tasks.forEach(
|
||||
task ->{
|
||||
if(TASK_TYPE.equals(task.getTask_type()) && StrUtil.isNotEmpty(task.getPut_device_code())){
|
||||
Instruction instruction = instructionService.findByDeviceCodeFromCache(task.getNext_device_code());
|
||||
if (ObjectUtil.isNotEmpty(instruction)) {
|
||||
if (StrUtil.equals(instruction.getStart_device_code(), device_code)) {
|
||||
collect.add(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
return collect;
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -534,7 +556,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
|
||||
String start_device_code = dto.getStart_device_code();
|
||||
String next_device_code = dto.getNext_device_code();
|
||||
String route_plan_code = dto.getRoute_plan_code();
|
||||
dto.setCreate_by(currentUsername);
|
||||
dto.setCreate_by(StrUtil.isNotEmpty(currentUsername) ? currentUsername : "LMS");
|
||||
dto.setUpdate_by(currentUsername);
|
||||
dto.setUpdate_time(now);
|
||||
dto.setCreate_time(now);
|
||||
|
||||
Reference in New Issue
Block a user