rev:更改补空料框流程

This commit is contained in:
2026-03-16 15:16:27 +08:00
parent 744ca6539d
commit 02028fc54b
8 changed files with 249 additions and 154 deletions

View File

@@ -275,7 +275,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
(byte) 0X00, (byte) 0X6D, (byte) 0X00, (byte) 0X6D,
(byte) 0X00, (byte) 0X06, (byte) 0X00, (byte) 0X06,
(byte) indexhigh, (byte) indexlow, (byte) indexhigh, (byte) indexlow,
(byte) 0X01, (byte) 0X10, (byte) 0X01, (byte) 0X12,
(byte) phasehigh, (byte) phaselow (byte) phasehigh, (byte) phaselow
}; };
@@ -368,7 +368,7 @@ public class NDCAgvServiceImpl implements NDCAgvService {
log.info("下发AGV充电任务--{}", str1); log.info("下发AGV充电任务--{}", str1);
try { try {
// OneNDCSocketConnectionAutoRun.write(b); TwoNDCSocketConnectionAutoRun.write(b);
} catch (Exception e) { } catch (Exception e) {
log.error("下发充电任务失败{}{}", e, e.getMessage()); log.error("下发充电任务失败{}{}", e, e.getMessage());
} }

View File

@@ -17,6 +17,7 @@ import org.nl.acs.instruction.service.InstructionService;
import org.nl.acs.instruction.service.impl.InstructionServiceImpl; import org.nl.acs.instruction.service.impl.InstructionServiceImpl;
import org.nl.acs.log.service.DeviceExecuteLogService; import org.nl.acs.log.service.DeviceExecuteLogService;
import org.nl.acs.opc.DeviceAppService; import org.nl.acs.opc.DeviceAppService;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.config.lucene.service.dto.LuceneLogDto;
@@ -162,7 +163,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
//任务号 //任务号
int ikey = arr[26] * 256 + arr[27]; int ikey = arr[26] * 256 + arr[27];
//站点号 //站点号
int agvaddr = arr[18] * 256 + arr[19]; int agvaddr = arr[24] * 256 + arr[25];
//车号 //车号
int carno = arr[20]; int carno = arr[20];
//充电桩站点号 //充电桩站点号
@@ -406,6 +407,7 @@ public class TwoNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
dos.flush(); dos.flush();
} catch (Exception e1) { } catch (Exception e1) {
e1.printStackTrace(); e1.printStackTrace();
throw new BadRequestException("下发数据失败:" + e.getMessage());
} }
} }

View File

@@ -42,7 +42,7 @@ import org.nl.system.service.param.ISysParamService;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.Map; import java.util.*;
/** /**
@@ -107,7 +107,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
*/ */
int ikey = arr[26] * 256 + arr[27]; int ikey = arr[26] * 256 + arr[27];
//站点号 //站点号
agvaddr = arr[18] * 256 + arr[19]; agvaddr = arr[24] * 256 + arr[25];
//车号 //车号
int carno = arr[20]; int carno = arr[20];
Instruction inst = null; Instruction inst = null;
@@ -231,11 +231,20 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
standardOrdinarySiteDeviceDriver.setOption(0); standardOrdinarySiteDeviceDriver.setOption(0);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 0) { boolean flag = Optional.ofNullable(standardInspectSiteDeviceDriver.getExtraValue().get("ignore_pickup_check")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
if (standardInspectSiteDeviceDriver.getMove() != 0 && !flag) {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode()) .device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data) .content("AGV到达取货点1,反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else if (flag) {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("AGV到达取货点1,反馈:" + data)
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -320,23 +329,27 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
standardOrdinarySiteDeviceDriver.setIndex(index); standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst); standardOrdinarySiteDeviceDriver.setInst(inst);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); // standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { // Map<String, Object> map = new HashMap<>();
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); // map.put("to_command", 100);
LuceneLogDto logDto = LuceneLogDto.builder() // try {
.device_code(this.getDeviceCode()) // standardInspectSiteDeviceDriver.writing(map);
.content("agvphase:" + phase + "反馈:" + data) // } catch (Exception e) {
.build(); // LuceneLogDto logDto = LuceneLogDto.builder()
logDto.setLog_level(4); // .device_code(this.getDeviceCode())
luceneExecuteLogService.deviceExecuteLog(logDto); // .content("AGV取货点1取货完成反馈失败,失败原因:" + e.getMessage())
} else { // .build();
LuceneLogDto logDto = LuceneLogDto.builder() // logDto.setLog_level(4);
.device_code(this.getDeviceCode()) // luceneExecuteLogService.deviceExecuteLog(logDto);
.content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + "工作模式为" + standardInspectSiteDeviceDriver.getMode() + ", 取货完成不允许离开") // return;
.build(); // }
logDto.setLog_level(4); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
luceneExecuteLogService.deviceExecuteLog(logDto); LuceneLogDto logDto = LuceneLogDto.builder()
} .device_code(this.getDeviceCode())
.content("AGV取货点1取货完成,反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else { } else {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
@@ -404,7 +417,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode()) .device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data) .content("AGV到达放货点1反馈:" + data)
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -479,23 +492,33 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
standardOrdinarySiteDeviceDriver.setIndex(index); standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst); standardOrdinarySiteDeviceDriver.setInst(inst);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); if (StrUtil.isEmpty(inst.getStart_device_code2())) {
if (standardInspectSiteDeviceDriver.getMove() != 0) { Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); if (start_device != null && start_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
LuceneLogDto logDto = LuceneLogDto.builder() //如果是两点任务 当AGV放货完成的时候给起点反馈放货完成
.device_code(this.getDeviceCode()) StandardInspectSiteDeviceDriver start_standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) start_device.getDeviceDriver();
.content("agvphase:" + phase + "反馈:" + data) Map<String, Object> map = new HashMap<>();
.build(); map.put("to_command", 100);
logDto.setLog_level(4); try {
luceneExecuteLogService.deviceExecuteLog(logDto); start_standardInspectSiteDeviceDriver.writing(map);
} else { } catch (Exception e) {
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode()) .device_code(this.getDeviceCode())
.content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + ", 放货完成不允许离开") .content("AGV取货点1放货完成反馈失败,失败原因:" + e.getMessage())
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
return;
}
}
} }
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("AGV放货点1放货完成反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else { } else {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
@@ -564,11 +587,20 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
standardOrdinarySiteDeviceDriver.setOption(0); standardOrdinarySiteDeviceDriver.setOption(0);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() != 0) { boolean flag = Optional.ofNullable(standardInspectSiteDeviceDriver.getExtraValue().get("ignore_pickup_check")).map(Object::toString).map(Boolean::parseBoolean).orElse(false);
if (standardInspectSiteDeviceDriver.getMove() != 0 && !flag) {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode()) .device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data) .content("AGV到达取货点2反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else if (flag) {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("AGV到达取货点2反馈:" + data)
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -652,23 +684,14 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
standardOrdinarySiteDeviceDriver.setIndex(index); standardOrdinarySiteDeviceDriver.setIndex(index);
standardOrdinarySiteDeviceDriver.setInst(inst); standardOrdinarySiteDeviceDriver.setInst(inst);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) { LuceneLogDto logDto = LuceneLogDto.builder()
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); .device_code(this.getDeviceCode())
LuceneLogDto logDto = LuceneLogDto.builder() .content("AGV取货点2取货完成反馈:" + data)
.device_code(this.getDeviceCode()) .build();
.content("agvphase:" + phase + "反馈:" + data) logDto.setLog_level(4);
.build(); luceneExecuteLogService.deviceExecuteLog(logDto);
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + "工作模式为" + standardInspectSiteDeviceDriver.getMode() + ", 取货完毕,不允许离开")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
}
} else { } else {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
@@ -735,7 +758,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode()) .device_code(this.getDeviceCode())
.content("agvphase:" + phase + "反馈:" + data) .content("AGV到达放货点2反馈:" + data)
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
@@ -806,25 +829,32 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
standardOrdinarySiteDeviceDriver.setOption(0); standardOrdinarySiteDeviceDriver.setOption(0);
} else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { } else if (device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) device.getDeviceDriver(); Device start_device = deviceAppService.findDeviceByCode(inst.getStart_device_code());
if (standardInspectSiteDeviceDriver.getMove() != 0) { if (start_device != null && start_device.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver){
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); //如果是两点任务 当AGV放货完成的时候给起点反馈放货完成
LuceneLogDto logDto = LuceneLogDto.builder() StandardInspectSiteDeviceDriver start_standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) start_device.getDeviceDriver();
.device_code(this.getDeviceCode()) Map<String, Object> map = new HashMap<>();
.content("agvphase:" + phase + "反馈:" + data) map.put("to_command", 100);
.build(); try {
logDto.setLog_level(4); start_standardInspectSiteDeviceDriver.writing(map);
luceneExecuteLogService.deviceExecuteLog(logDto); } catch (Exception e) {
} else { LuceneLogDto logDto = LuceneLogDto.builder()
LuceneLogDto logDto = LuceneLogDto.builder() .device_code(this.getDeviceCode())
.device_code(this.getDeviceCode()) .content("AGV取货点1放货完成反馈失败,失败原因:" + e.getMessage())
.content("设备:" + device.getDevice_code() + "光电信号为" + standardInspectSiteDeviceDriver.getMove() + ", 放货完成不允许离开") .build();
.build(); logDto.setLog_level(4);
logDto.setLog_level(4); luceneExecuteLogService.deviceExecuteLog(logDto);
luceneExecuteLogService.deviceExecuteLog(logDto); return;
}
} }
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(this.getDeviceCode())
.content("AGV放货点2放货完成反馈:" + data)
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
} else { } else {
data = ndcAgvService.sendAgvOneModeInst(phase, index, 0); data = ndcAgvService.sendAgvOneModeInst(phase, index, 0);
LuceneLogDto logDto = LuceneLogDto.builder() LuceneLogDto logDto = LuceneLogDto.builder()
@@ -879,49 +909,43 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
//自动充电的车号
String is_atuo_car = ISysParamService.findByCode(AcsConfig.IS_ATUO_CAR).getValue();
//当前上报的车号 //当前上报的车号
String now_car = String.valueOf(this.agvaddr); //是否开启自动充电
//如果配置的车号是诺宝车号 String is_atuo_electric = ISysParamService.findByCode(AcsConfig.IS_ATUO_ELECTRIC).getValue();
if (now_car.equals(is_atuo_car)) { log.info("接收agv上报信息,is_atuo_electric" + is_atuo_electric);
//是否开启自动充电 if ("1".equals(is_atuo_electric)) {
String is_atuo_electric = ISysParamService.findByCode(AcsConfig.IS_ATUO_ELECTRIC).getValue(); String electric_begin = ISysParamService.findByCode(AcsConfig.ELECTRIC_BEGIN).getValue();
log.info("接收agv上报信息,is_atuo_electric" + is_atuo_electric); String[] begins = electric_begin.split(":");
if ("1".equals(is_atuo_electric)) { String electric_end = ISysParamService.findByCode(AcsConfig.ELECTRIC_END).getValue();
String electric_begin = ISysParamService.findByCode(AcsConfig.ELECTRIC_BEGIN).getValue(); String[] ends = electric_end.split(":");
String[] begins = electric_begin.split(":"); // 定义时间段
String electric_end = ISysParamService.findByCode(AcsConfig.ELECTRIC_END).getValue(); LocalTime startTime = LocalTime.of(Integer.parseInt(begins[0]), Integer.parseInt(begins[1])); // 上午8点
String[] ends = electric_end.split(":"); LocalTime endTime = LocalTime.of(Integer.parseInt(ends[0]), Integer.parseInt(ends[1])); // 晚上22点
// 定义时间 // 获取当前时间
LocalTime startTime = LocalTime.of(Integer.parseInt(begins[0]), Integer.parseInt(begins[1])); // 上午8点 LocalTime now = LocalTime.now();
LocalTime endTime = LocalTime.of(Integer.parseInt(ends[0]), Integer.parseInt(ends[1])); // 晚上22点 // 判断当前时间是否在时间段内
// 获取当前时间 boolean isInRange = !now.isBefore(startTime) && !now.isAfter(endTime);
LocalTime now = LocalTime.now(); int electric = 0;
// 判断当前时间是否在时间段内 //早上8-22点
boolean isInRange = !now.isBefore(startTime) && !now.isAfter(endTime); if (isInRange) {
int electric = 0; electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC).getValue());
//早上8-22点 } else {
if (isInRange) { electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC2).getValue());
electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC).getValue()); }
if (electric_qty > 0 && electric_qty < electric) {
log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.agvaddr, electric_qty, electric);
//判断是否已下发充电任务
Dict dict1 = dictService.getDictByName3("station", String.valueOf(this.agvaddr), null);
if (ObjectUtil.isNotEmpty(dict1)) {
log.info("当前车辆{}已分配充电桩{},退出后续判断", this.agvaddr, dict1.getPara1());
} else { } else {
electric = Integer.parseInt(ISysParamService.findByCode(AcsConfig.ELECTRIC2).getValue()); //未下发,判断是否有空闲充电桩
} Dict dict = dictService.getDictByName2("station");
if (electric_qty > 0 && electric_qty < electric) { if (ObjectUtil.isNotEmpty(dict)) {
log.info("当前车辆{}电量为{}低于{},开始判断是否需要充电!", this.agvaddr, electric_qty, electric); ndcAgvService.charge(String.valueOf(this.agvaddr));
//判断是否已下发充电任务 isCharge = true;
Dict dict1 = dictService.getDictByName3("station", String.valueOf(this.agvaddr), null);
if (ObjectUtil.isNotEmpty(dict1)) {
log.info("当前车辆{}已分配充电桩{},退出后续判断", this.agvaddr, dict1.getPara1());
} else { } else {
//未下发,判断是否有空闲充电桩 log.info("当前车辆{}电量为{}低于{},但无空闲充电桩!", this.agvaddr, electric_qty, electric);
Dict dict = dictService.getDictByName2("station");
if (ObjectUtil.isNotEmpty(dict)) {
ndcAgvService.charge(String.valueOf(this.agvaddr));
isCharge = true;
} else {
log.info("当前车辆{}电量为{}低于{},但无空闲充电桩!", this.agvaddr, electric_qty, electric);
}
} }
} }
} }
@@ -1005,9 +1029,7 @@ public class AgvNdcTwoDeviceDriver extends AbstractDeviceDriver implements Devic
.build(); .build();
logDto.setLog_level(4); logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
if (StrUtil.equals(inst.getAgv_system_type(), "2")) { TwoNDCSocketConnectionAutoRun.write(data);
TwoNDCSocketConnectionAutoRun.write(data);
}
} }
} }

View File

@@ -46,7 +46,7 @@ public class ItemProtocol {
setIsonline(true); setIsonline(true);
return value; return value;
} }
return 0; return -1;
} }
public static List<ItemDto> getReadableItemDtos() { public static List<ItemDto> getReadableItemDtos() {

View File

@@ -18,6 +18,7 @@ import org.nl.acs.task.enums.AgvSystemTypeEnum;
import org.nl.acs.task.enums.TaskTypeEnum; import org.nl.acs.task.enums.TaskTypeEnum;
import org.nl.acs.task.service.TaskService; import org.nl.acs.task.service.TaskService;
import org.nl.acs.task.service.dto.TaskDto; import org.nl.acs.task.service.dto.TaskDto;
import org.nl.common.exception.BadRequestException;
import org.nl.config.SpringContextHolder; import org.nl.config.SpringContextHolder;
import org.nl.config.lucene.service.LuceneExecuteLogService; import org.nl.config.lucene.service.LuceneExecuteLogService;
import org.nl.config.lucene.service.dto.LuceneLogDto; import org.nl.config.lucene.service.dto.LuceneLogDto;
@@ -114,7 +115,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.log_level(4) .log_level(4)
.content("信号: move由" + this.last_mode + "->" + this.mode) .content("信号: move由" + this.last_move + "->" + this.move)
.build()); .build());
} }
@@ -122,7 +123,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder() luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder()
.device_code(device_code) .device_code(device_code)
.log_level(4) .log_level(4)
.content("信号: mix_code由" + this.last_mode + "->" + this.mode) .content("信号: mix_code由" + this.last_mix_code + "->" + this.mix_code)
.build()); .build());
} }
@@ -211,10 +212,17 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
instructionService.cancelInstAndTaskByDeviceCode(this.device_code); instructionService.cancelInstAndTaskByDeviceCode(this.device_code);
} catch (Exception e) { } catch (Exception e) {
this.message = "取消指令和任务时出现异常"; this.message = "取消指令和任务时出现异常";
Map<String, Object> map = new HashMap<>();
map.put("to_command", 400);
this.writing(map);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
return; return;
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("to_command", 200); map.put("to_command", 300);
this.writing(map); this.writing(map);
this.requireSuccess = true; this.requireSuccess = true;
} }
@@ -252,7 +260,16 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
taskService.create(taskDto); taskService.create(taskDto);
} catch (Exception e) { } catch (Exception e) {
this.message = "创建任务时出现异常"; this.message = "创建任务时出现异常";
return; LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(this.device_code + "创建任务异常:" + Arrays.toString(e.getStackTrace()))
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("to_command", 200); map.put("to_command", 200);
@@ -275,7 +292,16 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
taskService.create(taskDto); taskService.create(taskDto);
} catch (Exception e) { } catch (Exception e) {
this.message = "创建任务时出现异常"; this.message = "创建任务时出现异常";
return; LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(this.device_code + "创建任务异常:" + Arrays.toString(e.getStackTrace()))
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("to_command", 200); map.put("to_command", 200);
@@ -289,31 +315,40 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
private void createXLKBKTask() { private void createXLKBKTask() {
List<String> cxBkDeviceList = this.getExtraDeviceCodes("cxBkDeviceList"); List<String> cxBkDeviceList = this.getExtraDeviceCodes("cxBkDeviceList");
if (CollectionUtils.isEmpty(cxBkDeviceList)) { if (CollectionUtils.isEmpty(cxBkDeviceList)) {
this.message = "未配置产线补空设备"; this.message = "未配置产线补空终点设备设备";
return; return;
} }
String startDeviceCode = null; String nextDeviceCode = null;
for (int i = 0; i < cxBkDeviceList.size(); i++) { for (int i = 0; i < cxBkDeviceList.size(); i++) {
String cxBkDeviceCode = cxBkDeviceList.get(i); String cxBkDeviceCode = cxBkDeviceList.get(i);
Device cxBkDevice = deviceAppService.findDeviceByCode(cxBkDeviceCode); Device cxBkDevice = deviceAppService.findDeviceByCode(cxBkDeviceCode);
if (cxBkDevice != null && cxBkDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { if (cxBkDevice != null && cxBkDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) cxBkDevice.getDeviceDriver(); StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) cxBkDevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() > 0) { if (standardInspectSiteDeviceDriver.getMove() == 0 && standardInspectSiteDeviceDriver.getMode() > 0) {
startDeviceCode = cxBkDeviceCode; nextDeviceCode = cxBkDeviceCode;
break; break;
} }
} }
} }
if (startDeviceCode == null) { if (nextDeviceCode == null) {
this.message = "未找到符合条件的起点设备"; this.message = "未找到符合条件的起点设备";
return; return;
} }
TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), startDeviceCode, this.device_code); TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), this.device_code, nextDeviceCode);
try { try {
taskService.create(taskDto); taskService.create(taskDto);
} catch (Exception e) { } catch (Exception e) {
this.message = "创建任务时出现异常"; this.message = "创建任务时出现异常";
return; LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(this.device_code + "创建任务异常:" + Arrays.toString(e.getStackTrace()))
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("to_command", 200); map.put("to_command", 200);
@@ -334,6 +369,15 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
for (int i = 0; i < rgBkDeviceList.size(); i++) { for (int i = 0; i < rgBkDeviceList.size(); i++) {
String rgBkDeviceCode = rgBkDeviceList.get(i); String rgBkDeviceCode = rgBkDeviceList.get(i);
Device rgBkDevice = deviceAppService.findDeviceByCode(rgBkDeviceCode); Device rgBkDevice = deviceAppService.findDeviceByCode(rgBkDeviceCode);
TaskDto satrtTaskDto = taskService.findByStartCode(rgBkDeviceCode);
if (ObjectUtil.isNotEmpty(satrtTaskDto)) {
continue;
}
TaskDto endTaskDto = taskService.findByNextCode(this.device_code);
if (ObjectUtil.isNotEmpty(endTaskDto)) {
break;
}
if (rgBkDevice != null && rgBkDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) { if (rgBkDevice != null && rgBkDevice.getDeviceDriver() instanceof StandardInspectSiteDeviceDriver) {
StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) rgBkDevice.getDeviceDriver(); StandardInspectSiteDeviceDriver standardInspectSiteDeviceDriver = (StandardInspectSiteDeviceDriver) rgBkDevice.getDeviceDriver();
if (standardInspectSiteDeviceDriver.getMove() > 0) { if (standardInspectSiteDeviceDriver.getMove() > 0) {
@@ -348,6 +392,7 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
} }
TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), startDeviceCode, this.device_code); TaskDto taskDto = this.packageTaskDto(TaskTypeEnum.TWO_AGV_Task.getIndex(), startDeviceCode, this.device_code);
try { try {
Thread.sleep(10000);
taskService.create(taskDto); taskService.create(taskDto);
} catch (Exception e) { } catch (Exception e) {
this.message = "创建任务时出现异常"; this.message = "创建任务时出现异常";
@@ -420,7 +465,16 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
taskService.create(taskDto); taskService.create(taskDto);
} catch (Exception e) { } catch (Exception e) {
this.message = "创建任务时出现异常"; this.message = "创建任务时出现异常";
return; LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content(this.device_code + "创建任务异常:" + Arrays.toString(e.getStackTrace()))
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
try {
Thread.sleep(3000);
} catch (InterruptedException ex) {
}
} }
Map<String, Object> map = new HashMap<>(); Map<String, Object> map = new HashMap<>();
map.put("to_command", 200); map.put("to_command", 200);
@@ -473,10 +527,18 @@ public class StandardInspectSiteDeviceDriver extends AbstractOpcDeviceDriver imp
this.checkcontrol(itemMap); this.checkcontrol(itemMap);
} catch (Exception e) { } catch (Exception e) {
this.message = "下发信号时出现异常"; this.message = "下发信号时出现异常";
luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号 " + itemMap + "失败, 原因: " + Arrays.toString(e.getStackTrace()))); luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder()
return; .device_code(device_code)
.log_level(4)
.content("下发信号:" + itemMap + "失败, 原因:" + e.getMessage())
.build());
throw new BadRequestException(e.getMessage());
} }
luceneExecuteLogService.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号 " + itemMap + "成功")); luceneExecuteLogService.deviceExecuteLog(LuceneLogDto.builder()
.device_code(device_code)
.log_level(4)
.content("下发信号:" + itemMap + "成功")
.build());
} }
} }

View File

@@ -461,7 +461,7 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
} }
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) { if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "2")) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
ndcAgvService.sendAgvInstToNDC( dto); ndcAgvService.sendAgvInstToNDC(dto);
} }
//判断是否是仙工AGV //判断是否是仙工AGV
if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) { if (StrUtil.equals(paramService.findByCode(AcsConfig.AGVTYPE).getValue(), "3")) {
@@ -636,18 +636,27 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
dto.setSend_status("1"); dto.setSend_status("1");
} }
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) { } else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.One_NDC_System_Type.getIndex())) {
//一楼agv任务创建运单序列 log.warn("下发AGV指令数据," + "指令号:" + dto.getInstruction_code() + ",AGV系统类型:" + dto.getAgv_system_type());
HttpResponse response = xiangGongAgvService.sendOrderSequencesToXZ(dto); try {
if (ObjectUtils.isEmpty(response) || response.getStatus() != 200) { ndcAgvService.sendAgvInstToNDC(dto);
dto.setSend_status("2");
} else {
dto.setSend_status("1"); dto.setSend_status("1");
} catch (Exception e) {
dto.setSend_status("2");
dto.setRemark(e.getMessage());
e.printStackTrace();
log.warn("下发AGV指令异常:" + e);
LuceneLogDto logDto1 = LuceneLogDto.builder()
.device_code(start_device_code)
.content("下发AGV指令异常")
.build();
logDto1.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto1);
} }
} else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex())) { } else if (dto.getAgv_system_type().equals(AgvSystemTypeEnum.Two_NDC_System_Type.getIndex())) {
NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class); NDCAgvService ndcAgvService = SpringContextHolder.getBean(NDCAgvService.class);
log.warn("下发AGV指令数据," + "指令号:" + dto.getInstruction_code() + ",AGV系统类型:" + dto.getAgv_system_type()); log.warn("下发AGV指令数据," + "指令号:" + dto.getInstruction_code() + ",AGV系统类型:" + dto.getAgv_system_type());
try { try {
ndcAgvService.sendAgvInstToNDC( dto); ndcAgvService.sendAgvInstToNDC(dto);
dto.setSend_status("1"); dto.setSend_status("1");
} catch (Exception e) { } catch (Exception e) {
dto.setSend_status("2"); dto.setSend_status("2");

View File

@@ -1040,7 +1040,7 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
this.feedWmsTaskStatus(entity); this.feedWmsTaskStatus(entity);
//关闭仙工运单序列 //关闭仙工运单序列
if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) { if (StrUtil.equals(task.getTask_type(), TaskTypeEnum.Standard_AGV_Task.getCode()) && (StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.One_NDC_System_Type.getCode()) || StrUtil.equals(task.getAgv_system_type(), AgvSystemTypeEnum.XG_System_Type.getCode()))) {
this.markComplete(entity); //this.markComplete(entity);
} }
} }

View File

@@ -48,7 +48,7 @@ public class AutoCreateInst {
* 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货 * 创建指令前需要判断是否条件具备:起始位置是否有货、目标位置是否有货
*/ */
public void run() throws Exception { public void run() throws Exception {
log.info("自动生成指令"+DateUtil.now()); log.info("自动生成指令" + DateUtil.now());
TaskService taskserver = SpringContextHolder.getBean(TaskService.class); TaskService taskserver = SpringContextHolder.getBean(TaskService.class);
InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class); InstructionService instructionService = SpringContextHolder.getBean(InstructionService.class);
RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class); RouteLineService routeLineService = SpringContextHolder.getBean(RouteLineService.class);
@@ -115,7 +115,7 @@ public class AutoCreateInst {
boolean flag = false; boolean flag = false;
for (int m = 0; m < pathlist.size(); m++) { for (int m = 0; m < pathlist.size(); m++) {
if (pathlist.get(m).equals(start_device_code)) { if (pathlist.get(m).equals(start_device_code)) {
if("1".equals(acsTask.getTask_type()) && !pathlist.get(m+1).equals(next_device_code)){ if ("1".equals(acsTask.getTask_type()) && !pathlist.get(m + 1).equals(next_device_code)) {
flag = true; flag = true;
break; break;
} }
@@ -174,7 +174,7 @@ public class AutoCreateInst {
instdto.setNext_height(next_height); instdto.setNext_height(next_height);
instdto.setAgv_action_type(agvActionType); instdto.setAgv_action_type(agvActionType);
try { try {
instructionService.create(instdto); instructionService.create(instdto);
} catch (Exception e) { } catch (Exception e) {
acsTask.setRemark(e.getMessage()); acsTask.setRemark(e.getMessage());
taskserver.updateByCodeFromCache(acsTask); taskserver.updateByCodeFromCache(acsTask);
@@ -186,11 +186,11 @@ public class AutoCreateInst {
luceneExecuteLogService.deviceExecuteLog(logDto); luceneExecuteLogService.deviceExecuteLog(logDto);
continue; continue;
} }
//创建指令后修改任务状态 //创建指令后修改任务状态
acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex()); acsTask.setTask_status(TaskStatusEnum.BUSY.getIndex());
acsTask.setUpdate_time(DateUtil.now()); acsTask.setUpdate_time(DateUtil.now());
acsTask.setRemark(" "); acsTask.setRemark(" ");
taskserver.update(acsTask); taskserver.update(acsTask);
} }
} }