Browse Source

add:报警信息和任务申请异常通知

master
耿宝印 2 months ago
parent
commit
43d8d78a36
  1. 1
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/agv/server/impl/XianGongAgvServiceImpl.java
  2. 65
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java
  3. 19
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java
  4. 69
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java
  5. 17
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/xg/service/impl/XgToAcsServiceImpl.java
  6. 28
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java
  7. 3
      nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java
  8. 163
      nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateYkInst.java

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

@ -116,6 +116,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
String path = "/terminate";
JSONObject reqParam = new JSONObject();
reqParam.put("id", instCode);
reqParam.put("disableVehicle",false);
return xgHttpUtil.sendPostRequest(path, reqParam);
}

65
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/conveyor/appearance_inspection_scannner_conveyor/AppearanceInspectionScannerConveyorDeviceDriver.java

@ -44,6 +44,7 @@ import org.nl.common.utils.SecurityUtils;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.nl.system.service.param.ISysParamService;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
@ -73,6 +74,7 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
private final DeviceAssignedService deviceAssignedService = SpringContextHolder.getBean(DeviceAssignedService.class);
private final AcsToHkService acsToHkService = SpringContextHolder.getBean(AcsToHkService.class);
private final ISysParamService sysParamService = SpringContextHolder.getBean(ISysParamService.class);
private static final Lock LOCK = new ReentrantLock();
@ -182,6 +184,16 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
*/
private long requireTimeOut = 3000L;
/**
* 任务申请失败通知时间
*/
private long errorRequireTime = System.currentTimeMillis();
/**
* 任务申请失败请求间隔时间
*/
private long errorRequireTimeOut = 60000L;
/**
* 设备异常标记
*/
@ -260,6 +272,21 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
this.requireSuccess = false;
this.withStationRequireSuccess = false;
}
if (this.error != this.lastError && this.error != 0) {
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")){
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: " + ErrorEnum.getLabel(this.error));
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
if (this.mode != this.lastMode) {
this.requireSuccess = false;
}
@ -432,6 +459,10 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
}
}
private boolean isErrorTimeValid(long errorCurrentTimeMillis) {
return errorCurrentTimeMillis - this.errorRequireTime >= this.errorRequireTimeOut;
}
/**
* 申请托盘入库任务
*/
@ -461,6 +492,23 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
if (response.isSuccess()) {
this.writing(ItemProtocol.TO_COMMAND.getKey(), CommandEnum.COMMAND_6.getValue());
this.requireSuccess = true;
} else {
if (isErrorTimeValid(currentTimeMillis)) {
this.errorRequireTime = currentTimeMillis;
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")){
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "申请任务失败! 请求参数: " + request + "响应信息: " + response.getMessage());
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("1")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
}
}
@ -486,6 +534,23 @@ public class AppearanceInspectionScannerConveyorDeviceDriver extends AbstractOpc
if (response.isSuccess()) {
this.writing(ItemProtocol.TO_COMMAND.getKey(), CommandEnum.COMMAND_7.getValue());
this.requireSuccess = true;
} else {
if (isErrorTimeValid(currentTimeMillis)) {
this.errorRequireTime = currentTimeMillis;
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")){
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "申请任务失败! 请求参数: " + request + "响应信息: " + response.getMessage());
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("1")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
}
}

19
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/stacker/double_stacker/StandardStackerDeviceDriver.java

@ -33,6 +33,7 @@ import org.nl.common.utils.SecurityUtils;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.nl.system.service.param.ISysParamService;
import java.util.*;
import java.util.concurrent.TimeUnit;
@ -67,6 +68,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
private final DeviceAppService deviceAppService = SpringContextHolder.getBean(DeviceAppService.class);
private final TaskService taskService = SpringContextHolder.getBean(TaskService.class);
private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsService.class);
private final ISysParamService sysParamService = SpringContextHolder.getBean(ISysParamService.class);
private static final Lock LOCK = new ReentrantLock();
@ -499,6 +501,23 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
return;
}
}
if ((this.back_Zerror != this.lastBack_Zerror && this.back_Zerror != 0) || (this.front_Zerror != this.lastFront_Zerror && this.front_Zerror != 0)) {
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")){
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "设备" + this.currentDeviceCode + "报警, 报警信息: 前叉 " + ErrorEnum.getDesc(this.front_Zerror) + ", 后叉 " + ErrorEnum.getDesc(this.back_Zerror));
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("2")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
this.stackerNum = Optional.ofNullable(this.getExtraValue().get("stackerNum"))
.map(Object::toString)
.map(Integer::parseInt)

69
nladmin-system/nlsso-server/src/main/java/org/nl/acs/device/driver/station/with_station/WithStationDeviceDriver.java

@ -23,6 +23,7 @@ import org.nl.acs.task.service.dto.TaskDto;
import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto;
import org.nl.system.service.param.ISysParamService;
import java.util.LinkedHashMap;
import java.util.List;
@ -41,6 +42,7 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
private final TaskService taskServer = SpringContextHolder.getBean(TaskService.class);
private final AcsToWmsService acsToWmsService = SpringContextHolder.getBean(AcsToWmsServiceImpl.class);
private final LuceneExecuteLogService logServer = SpringContextHolder.getBean(LuceneExecuteLogService.class);
private final ISysParamService sysParamService = SpringContextHolder.getBean(ISysParamService.class);
/**
* 请求标记
@ -53,10 +55,20 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
private String device_code = null;
/**
* 请求时间
* 任务请求时间
*/
private long requireTime = System.currentTimeMillis();
/**
* 任务申请失败通知时间
*/
private long errorRequireTime = System.currentTimeMillis();
/**
* 任务申请失败请求间隔时间
*/
private long errorRequireTimeOut = 60000L;
/**
* 请求间隔时间
*/
@ -66,6 +78,10 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
return currentTimeMillis - this.requireTime >= this.requireTimeOut;
}
private boolean isErrorTimeValid(long errorCurrentTimeMillis) {
return errorCurrentTimeMillis - this.errorRequireTime >= this.errorRequireTimeOut;
}
@Override
public void execute() {
this.device_code = this.getDeviceCode();
@ -122,6 +138,23 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
if (response.isSuccess()) {
appearanceInspectionScannerConveyorDeviceDriver.setWithStationRequireSuccess(true);
this.requireSuccess = true;
} else {
if (isErrorTimeValid(currentTimeMillis)) {
this.errorRequireTime = currentTimeMillis;
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")){
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "申请任务失败! 请求参数: " + request + "响应信息: " + response.getMessage());
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("1")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
break;
} else {
@ -146,6 +179,23 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
this.requireSuccess = true;
appearanceInspectionScannerConveyorDeviceDriver.setWithStationRequireSuccess(true);
appearanceInspectionScannerConveyorDeviceDriver2.setWithStationRequireSuccess(true);
} else {
if (isErrorTimeValid(currentTimeMillis)) {
this.errorRequireTime = currentTimeMillis;
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")){
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "申请任务失败! 请求参数: " + request + "响应信息: " + response.getMessage());
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("1")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
break;
}
@ -164,6 +214,23 @@ public class WithStationDeviceDriver extends AbstractOpcDeviceDriver implements
if (response.isSuccess()) {
appearanceInspectionScannerConveyorDeviceDriver.setWithStationRequireSuccess(true);
this.requireSuccess = true;
} else {
if (isErrorTimeValid(currentTimeMillis)) {
this.errorRequireTime = currentTimeMillis;
String notifyValue = Optional.ofNullable(sysParamService.findByCode("is_notify"))
.map(notify -> notify.getValue())
.orElse("0");
if (notifyValue.equals("1")){
JSONObject dataParam = new JSONObject();
dataParam.put("msg", "申请任务失败! 请求参数: " + request + "响应信息: " + response.getMessage());
CommonRequest<JSONObject> requestParam = CommonRequest.<JSONObject>builder()
.service("ErrorInfo")
.type("1")
.data(dataParam)
.build();
acsToWmsService.apply(requestParam);
}
}
}
break;
}

17
nladmin-system/nlsso-server/src/main/java/org/nl/acs/ext/xg/service/impl/XgToAcsServiceImpl.java

@ -35,18 +35,18 @@ import java.util.Map;
@Slf4j
public class XgToAcsServiceImpl implements XgToAcsService {
private final static Map<String, Map<String,String>> BLOCK_POS_XY = new HashMap<>();
private final static Map<String, Map<String, String>> BLOCK_POS_XY = new HashMap<>();
@Autowired
private AcsToHkService acsToHkService;
//TODO 需要现场确定区域对应坐标
static {
BLOCK_POS_XY.put("Block1", MapOf.of("X1","213000","Y1","205457","X3","215000","Y3","205457"));
BLOCK_POS_XY.put("Block2", MapOf.of("X1","210000","Y1","205457","X3","212000","Y3","205457"));
BLOCK_POS_XY.put("Block3", MapOf.of("X1","207000","Y1","205457","X3","209000","Y3","205457"));
BLOCK_POS_XY.put("Block4", MapOf.of("X1","204000","Y1","205457","X3","206000","Y3","205457"));
BLOCK_POS_XY.put("Block5", MapOf.of("X1","201000","Y1","205457","X3","203000","Y3","205457"));
BLOCK_POS_XY.put("Block1", MapOf.of("X1", "213000", "Y1", "205457", "X3", "215000", "Y3", "205457"));
BLOCK_POS_XY.put("Block2", MapOf.of("X1", "210000", "Y1", "205457", "X3", "212000", "Y3", "205457"));
BLOCK_POS_XY.put("Block3", MapOf.of("X1", "207000", "Y1", "205457", "X3", "209000", "Y3", "205457"));
BLOCK_POS_XY.put("Block4", MapOf.of("X1", "204000", "Y1", "205457", "X3", "206000", "Y3", "205457"));
BLOCK_POS_XY.put("Block5", MapOf.of("X1", "201000", "Y1", "205457", "X3", "203000", "Y3", "205457"));
}
@Override
@ -101,6 +101,11 @@ public class XgToAcsServiceImpl implements XgToAcsService {
resp.put("message", "ok");
return resp;
} else {
if (blockUnifiedResponse.getMessage() != null && blockUnifiedResponse.getMessage().contains("重复封锁")) {
resp.put("code", 200);
resp.put("message", "ok");
return resp;
}
resp.put("code", 400);
resp.put("message", "CTU活动区域未封禁,不允许进入该区域!");
return resp;

28
nladmin-system/nlsso-server/src/main/java/org/nl/acs/instruction/service/impl/InstructionServiceImpl.java

@ -1380,14 +1380,19 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
@Override
public Instruction findByCodeFromCache(String code) {
Iterator<Instruction> it = instructions.iterator();
while (it.hasNext()) {
Instruction inst = it.next();
if (StrUtil.equals(code, inst.getInstruction_code())) {
return inst;
}
}
return null;
return Optional.ofNullable(this.instructions).orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_code().equals(code))
.findFirst()
.orElse(null);
// Iterator<Instruction> it = instructions.iterator();
// while (it.hasNext()) {
// Instruction inst = it.next();
// if (StrUtil.equals(code, inst.getInstruction_code())) {
// return inst;
// }
// }
// return null;
}
@Override
@ -2295,8 +2300,11 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
return Optional.ofNullable(this.instructions)
.orElse(new CopyOnWriteArrayList<>())
.stream()
.filter(inst -> inst.getInstruction_status().equals(InstructionStatusEnum.READY.getIndex()))
.filter(inst -> inst.getVehicle_code().equals(vehicleCode))
.filter(Objects::nonNull)
.filter(inst ->
Objects.equals(inst.getInstruction_status(), InstructionStatusEnum.READY.getIndex()) &&
Objects.equals(inst.getVehicle_code(), vehicleCode)
)
.findFirst().orElse(null);
}

3
nladmin-system/nlsso-server/src/main/java/org/nl/acs/task/enums/TaskTypeEnum.java

@ -16,7 +16,8 @@ public enum TaskTypeEnum {
*/
Stacker_Task("1", "1", "堆垛机任务"),
AGV_TASK("2", "2", "AGV任务"),
CTU_TASK("3", "3", "CTU任务");
CTU_TASK("3", "3", "CTU任务"),
YK_TASK("4", "4", "呆料转移任务");
/**

163
nladmin-system/nlsso-server/src/main/java/org/nl/system/service/quartz/task/AutoCreateYkInst.java

@ -0,0 +1,163 @@
package org.nl.system.service.quartz.task;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ObjectUtils;
import org.nl.acs.common.base.CommonFinalParam;
import org.nl.acs.device.device.service.DeviceAppService;
import org.nl.acs.instruction.domain.Instruction;
import org.nl.acs.instruction.enums.InstructionStatusEnum;
import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.route.service.RouteLineService;
import org.nl.acs.route.service.dto.RouteLineDto;
import org.nl.acs.task.enums.InstTypeEnum;
import org.nl.acs.task.enums.TaskStatusEnum;
import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.Arrays;
import java.util.List;
/**
* 自动创建AGV指令
*/
@Slf4j
@Component
public class AutoCreateYkInst {
@Autowired
private TaskService taskService;
@Autowired
private InstructionService instructionService;
@Autowired
private RouteLineService routeLineService;
@Autowired
private DeviceAppService deviceAppService;
/**
* 根据任务状态创建指令生成下一条指令
* 创建指令前需要判断是否条件具备起始位置是否有货目标位置是否有货
*/
public void run() throws Exception {
List<TaskDto> list = taskService.findReadyByTaskType(TaskTypeEnum.YK_TASK.getCode());
for (int i = 0; i < list.size(); i++) {
TaskDto acsTask = list.get(i);
String taskid = acsTask.getTask_id();
String taskcode = acsTask.getTask_code();
String task_type = acsTask.getTask_type();
String vehiclecode = acsTask.getVehicle_code();
String storage_task_type = acsTask.getStorage_task_type();
String priority = acsTask.getPriority();
String is_send = acsTask.getIs_send();
String start_device_code = acsTask.getStart_device_code();
String start_point_code = acsTask.getStart_point_code();
String put_device_code = acsTask.getPut_device_code();
String put_point_code = acsTask.getPut_point_code();
String next_device_code = acsTask.getNext_device_code();
String next_point_code = acsTask.getNext_point_code();
String start_point_code2 = acsTask.getStart_point_code2();
String start_device_code2 = acsTask.getStart_device_code2();
String next_point_code2 = acsTask.getNext_point_code2();
String next_device_code2 = acsTask.getNext_device_code2();
String route_plan_code = acsTask.getRoute_plan_code();
String vehicleType = acsTask.getVehicle_type();
String agv_system_type = acsTask.getAgv_system_type();
String start_height = acsTask.getStart_height();
String next_height = acsTask.getNext_height();
if (StrUtil.equals(is_send, "0")) {
continue;
}
//校验路由关系
List<RouteLineDto> shortPathsList = routeLineService.getShortPathLines(start_device_code, next_device_code, route_plan_code);
if (ObjectUtils.isEmpty(shortPathsList)) {
acsTask.setRemark("路由不通无法生成指令");
taskService.updateByCodeFromCache(acsTask);
continue;
}
if (!StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.ONE) && !StrUtil.equals(shortPathsList.get(0).getType(), CommonFinalParam.TWO)) {
continue;
}
RouteLineDto routeLineDto = shortPathsList.get(0);
String path = routeLineDto.getPath();
String type = routeLineDto.getType();
String[] str = path.split("->");
List<String> pathlist = Arrays.asList(str);
int index = 0;
for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) {
index = m + 1;
break;
}
}
next_device_code = pathlist.get(index);
if (StrUtil.equals(deviceAppService.findDeviceTypeByCode(next_device_code), "storage")) {
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_type(InstTypeEnum.STACKER_TASK.getCode());
instdto.setInstruction_id(IdUtil.simpleUUID());
instdto.setRoute_plan_code(route_plan_code);
instdto.setRemark(acsTask.getRemark());
instdto.setMaterial(acsTask.getMaterial());
instdto.setQuantity(acsTask.getQuantity());
instdto.setTask_id(taskid);
instdto.setTask_code(taskcode);
instdto.setVehicle_code(vehiclecode);
String now = DateUtil.now();
instdto.setCreate_time(now);
instdto.setCreate_by(SecurityUtils.getCurrentNickName());
instdto.setStart_device_code(start_device_code);
instdto.setStart_point_code(start_point_code);
instdto.setPut_device_code(put_device_code);
instdto.setPut_point_code(put_point_code);
instdto.setNext_device_code(next_device_code);
instdto.setNext_point_code(next_point_code);
instdto.setStart_point_code2(start_point_code2);
instdto.setStart_device_code2(start_device_code2);
instdto.setNext_point_code2(next_point_code2);
instdto.setNext_device_code2(next_device_code2);
instdto.setPriority(priority);
instdto.setInstruction_status(InstructionStatusEnum.READY.getIndex());
instdto.setExecute_device_code(start_point_code);
instdto.setVehicle_type(vehicleType);
instdto.setAgv_system_type(agv_system_type);
instdto.setStart_height(start_height);
instdto.setNext_height(next_height);
try {
instructionService.create(instdto);
} catch (Exception e) {
acsTask.setRemark("指令创建失败:" + e.getMessage());
taskService.updateByCodeFromCache(acsTask);
}
//创建指令后修改任务状态
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskService.update(acsTask);
}
}
}
Loading…
Cancel
Save