fix: 日志更新,取消任务和指令、创建人、配置文件线程数搞大

This commit is contained in:
2024-07-19 13:26:19 +08:00
parent f971c83141
commit 6babb1980c
25 changed files with 238 additions and 88 deletions

View File

@@ -740,10 +740,21 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
String inst_code = requestParam.getString("task_code");
Instruction instructionDto = instructionService.findByCodeFromCache(inst_code);
if (ObjectUtil.isEmpty(instructionDto)) {
LuceneLogDto logDto = LuceneLogDto.builder()
.content("请求失败,未找到指令!" )
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
throw new BadRequestException("请求失败,未找到指令!");
}
String address = requestParam.getString("address");
if (StrUtil.isBlank(address)) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(instructionDto.getCarno())
.content("请求失败,地址为空!" )
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
throw new BadRequestException("请求失败,地址为空!");
}
if (address.contains("IN") || address.contains("WAIT")) {
@@ -755,6 +766,12 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
deviceCodeNow = address.substring(0, address.length() - 5);
}
if (ObjectUtil.isEmpty(deviceAppService.findDeviceByCode(deviceCodeNow))) {
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(instructionDto.getCarno())
.content("设备号 " + deviceCodeNow + " 不存在!")
.build();
logDto.setLog_level(4);
luceneExecuteLogService.deviceExecuteLog(logDto);
throw new BadRequestException("设备号 " + deviceCodeNow + " 不存在!");
}
//一楼诺宝agv
@@ -802,6 +819,7 @@ public class XianGongAgvServiceImpl implements XianGongAgvService {
map.put("message", "允许叉车放货!" + "点位" + newPointCode);
log.info("允许仙工AGV放货设备号 - {}", newPointCode);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(instructionDto.getCarno())
.content("叉车允许放货" + "新点位:" + newPointCode + map )
.build();
logDto.setLog_level(4);

View File

@@ -366,6 +366,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
this.writing(list);
message = null;
vehicle_code = null;
inst_message = null;
}
@@ -420,7 +421,7 @@ public class BeltConveyorDeviceDriver extends AbstractOpcDeviceDriver implements
this.writing(list1);
this.requireSucess = true;
} else {
this.iserror = false;
this.iserror = true;
message = "申请空托盘出入库出错,返回参数:" + jo;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)

View File

@@ -39,8 +39,6 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
public void checkcontrol(Map<String, Object> itemValues) throws Exception {
CompletableFuture<String> future = CompletableFuture.supplyAsync(() -> {
try {
Group group = opcServerService.getServer(this.getOpcServer());
Map<String, Object> write = new HashMap();
@@ -116,7 +114,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
}
if (check) {
return "";
return ;
}
if (i > 0) {
@@ -133,20 +131,7 @@ public class AbstractOpcDeviceDriver extends AbstractDeviceDriver implements Opc
Thread.currentThread().interrupt();
throw new IllegalStateException("Interrupted", e);
}
});
try {
String result = future.get(2, TimeUnit.SECONDS); // 设置超时时间为2秒
System.out.println(result);
} catch (CompletionException e) {
Throwable cause = e.getCause();
if (cause instanceof TimeoutException) {
System.out.println("Operation timed out");
} else {
throw e; // rethrow other exceptions
}
} catch (Exception e) {
throw new RuntimeException(e);
}
}

View File

@@ -274,6 +274,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
this.writing(list);
message=null;
vehicle_code=null;
inst_message = null;
}
@@ -379,7 +380,7 @@ public class BoxStorageOutConveyorDeviceDriver extends AbstractOpcDeviceDriver i
luceneExecuteLogService.deviceExecuteLog(logDto2);
this.requireSucess = true;
} else {
this.iserror = false;
this.iserror = true;
message = "二楼到一楼输送线申请行架任务报错,返回参数:" + jo;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)

View File

@@ -194,7 +194,8 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
if (move != 0 && task > 0) {
if (null!=inst) {
inst_message = "指令号:" + inst.getInstruction_code() + " " + inst.getStart_point_code() + "->" + inst.getNext_point_code();
} update_instruction_status();
}
update_instruction_status();
}
} catch (Exception var17) {
var17.printStackTrace();
@@ -298,6 +299,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
this.writing(list);
message = null;
vehicle_code = null;
inst_message = null;
}
@@ -390,7 +392,7 @@ public class BoxSubvolumesConveyorDeviceDriver extends AbstractOpcDeviceDriver i
requireSucess = true;
}else {
message = "申请AGV任务报错,参数,接口返回:" + jo;
this.iserror = false;
this.iserror = true;
}
}

View File

@@ -330,6 +330,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
this.writing(list);
message=null;
inst_message = null;
}
private void applyLaStrangulationAndLabeling(int mode) {
@@ -368,7 +369,7 @@ public class FinishedProductOutBindLableDeviceDriver extends AbstractOpcDeviceDr
packagePLCData(jo.getString("data"), mode);
requireSucess = true;
} else {
this.iserror = false;
this.iserror = true;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请捆扎失败,接口返回:" + response)

View File

@@ -18,6 +18,7 @@ import org.nl.acs.device.service.impl.DeviceExtraServiceImpl;
import org.nl.acs.device_driver.DeviceDriver;
import org.nl.acs.device_driver.FeedLmsRealFailed;
import org.nl.acs.device_driver.RouteableDeviceDriver;
import org.nl.acs.device_driver.conveyor.belt_conveyor.BeltConveyorDeviceDriver;
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
import org.nl.acs.enums.StorageTypeEnum;
@@ -325,6 +326,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
this.writing(list);
message = null;
vehicle_code = null;
inst_message = null;
}
@@ -418,9 +420,28 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
requireSucess = false;
return true;
}
//关联站点判断
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
beltConveyorDeviceDriver = (BeltConveyorDeviceDriver) nextDevice.getDeviceDriver();
//判断对接位和关联站点光电信号
getDeviceCodeList = beltConveyorDeviceDriver.getExtraDeviceCodes("link_device_code");
if (CollUtil.isNotEmpty(getDeviceCodeList)) {
String linkDeviceCode = getDeviceCodeList.get(0);
Device linkDevice = deviceAppService.findDeviceByCode(linkDeviceCode);
BeltConveyorDeviceDriver linkDeviceDriver;
if (linkDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {
linkDeviceDriver = (BeltConveyorDeviceDriver) linkDevice.getDeviceDriver();
if ((beltConveyorDeviceDriver.getMode() == 0 || beltConveyorDeviceDriver.getMove() == 1) || (linkDeviceDriver.getMode() == 0 || linkDeviceDriver.getMove() == 1)) {
this.message = "DDJ对接位或关联输送线存在正在移动的货物或者未联机";
requireSucess = false;
return true;
}
}
Device startdevice = deviceAppservice.findDeviceByCode(start_device_code);
Device nextdevice = deviceAppservice.findDeviceByCode(next_device_code);
}
}
String next_point_code;
if (StrUtil.equals(deviceAppservice.findDeviceTypeByCode(next_device_code), "storage")) {
next_point_code = taskdto.getTo_x() + "-" + taskdto.getTo_y() + "-" + taskdto.getTo_z();
@@ -457,7 +478,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
taskdto.setTask_status(TaskStatusEnum.BUSY.getIndex());
taskserver.update(taskdto);
requireSucess = true;
String next_addr = nextdevice.getExtraValue().get("address").toString();
String next_addr = nextDevice.getExtraValue().get("address").toString();
List list = new ArrayList();
Map map = new HashMap();
@@ -610,7 +631,7 @@ public class FoldDiscSiteDeviceDriver extends AbstractOpcDeviceDriver implements
this.writing(list1);
this.requireSucess = true;
} else {
this.iserror = false;
this.iserror = true;
message = "申请空托盘出入库报错,接口返回:" + jo;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)

View File

@@ -447,6 +447,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
this.writing(list2);
requireSucess = true;
} else {
this.iserror = true;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请高度等级,返回参数:" + response)
@@ -508,6 +509,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
this.writing(list1);
this.requireSucess = true;
} else {
this.iserror = true;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("申请退货入库,返回参数:" + response)
@@ -541,6 +543,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
message = null;
vehicle_code = null;
hand_barcode = null;
inst_message = null;
}
@@ -618,7 +621,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
this.writing(list1);
this.requireSucess = true;
} else {
this.iserror = false;
this.iserror = true;
message = "申请空托盘出入库报错,返回参数:" + jo;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
@@ -683,7 +686,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
this.writing(list1);
requireSucess = true;
} else {
this.iserror = false;
this.iserror = true;
LuceneLogDto logDto2 = LuceneLogDto.builder()
.device_code(device_code)
.content("木箱、子卷入库申请入库任务,返回参数:" + response)
@@ -856,6 +859,7 @@ public class ConveyorWithScannerWeightDeviceDriver extends AbstractOpcDeviceDriv
requireSucess = false;
return true;
}
//关联站点判断
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
BeltConveyorDeviceDriver beltConveyorDeviceDriver;
if (nextDevice.getDeviceDriver() instanceof BeltConveyorDeviceDriver) {

View File

@@ -286,7 +286,7 @@ public class UnBoxLableConveyorDeviceDriver extends AbstractOpcDeviceDriver impl
}else {
message = "木箱开盖报错,返回参数:" + jo;
this.iserror = false;
this.iserror = true;
}

View File

@@ -164,7 +164,6 @@ public class BoxPackageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
@Override
public void execute() {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();

View File

@@ -136,7 +136,6 @@ public class BoxStorageManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
@Override
public void execute() {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();

View File

@@ -152,7 +152,6 @@ public class ReturnGoodManipulatorDeviceDriver extends AbstractOpcDeviceDriver i
@Override
public void execute() {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();

View File

@@ -147,7 +147,6 @@ public class TrappedManipulatorManipulatorDeviceDriver extends AbstractOpcDevice
@Override
public void execute() {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();

View File

@@ -167,7 +167,6 @@ public class VolumeTwoManipulatorManipulatorDeviceDriver extends AbstractOpcDevi
@Override
public void execute() {
String message = null;
try {
device_code = this.getDeviceCode();
mode = this.itemProtocol.getMode();

View File

@@ -632,7 +632,8 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
instructionService.update(instruction0);
return false;
}
return true;
//异常后上个动作命令是取货完成也要下发信号
return false;
}
@@ -875,7 +876,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
//放货完成
if (forkCargo == 0) {
//取货中或者取货完成(分入库出库)
if ("1".equals(instructionErro.getExecute_code()) || "2".equals(instructionErro.getExecute_code())) {
if ("1".equals(instructionErro.getExecute_code()) ) {
List list = new ArrayList();
String startDeviceCode = instructionErro.getStart_device_code();
Device startDeviceError = deviceAppService.findDeviceByCode(startDeviceCode);
@@ -889,7 +890,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
}
}
//放货中报警
if ("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) {
if (("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) || "2".equals(instructionErro.getExecute_code())) {
List list = new ArrayList();
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.conveyor.name())) {
pakagePLCData(list, instructionErro.getTo_x(), instructionErro.getTo_y(), instructionErro.getTo_z(), "2", instructionErro.getInstruction_code());
@@ -903,7 +904,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
//出库报警
if (startDevice.getDeviceDriver() instanceof StandardStorageDeviceDriver) {
//取货报警
if ("1".equals(instructionErro.getExecute_code()) || "2".equals(instructionErro.getExecute_code())) {
if ("1".equals(instructionErro.getExecute_code()) ) {
List list = new ArrayList();
if (StrUtil.equals(startDevice.getDevice_type(), DeviceType.storage.name())) {
pakagePLCData(list, instructionErro.getFrom_x(), instructionErro.getFrom_y(), instructionErro.getFrom_z(), "1", instructionErro.getInstruction_code());
@@ -914,7 +915,7 @@ public class StandardStackerDeviceDriver extends AbstractOpcDeviceDriver impleme
message = "one_message19";
}
//放货中报警
if ("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) {
if (("3".equals(instructionErro.getExecute_code()) && forkCargo == 2) || "2".equals(instructionErro.getExecute_code())) {
String next_device_code = instructionErro.getNext_device_code();
Device nextDevice = deviceAppService.findDeviceByCode(next_device_code);
List list = new ArrayList();

View File

@@ -421,8 +421,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
dto.setCompound_inst_data(task.getCompound_task_data());
}
}
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : dto.getStart_device_code()+":自动创建");
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : dto.getStart_device_code()+":自动创建");
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setStart_parent_code(task.getStart_parent_code());
@@ -599,8 +599,8 @@ public class InstructionServiceImpl extends CommonServiceImpl<InstructionMapper,
dto.setCompound_inst_data(task.getCompound_task_data());
}
}
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : "admin");
dto.setCreate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : dto.getStart_device_code()+"手动创建");
dto.setUpdate_by(ObjectUtil.isNotEmpty(currentUsername) ? currentUsername : dto.getStart_device_code()+"手动创建");
dto.setUpdate_time(now);
dto.setCreate_time(now);
dto.setStart_parent_code(task.getStart_parent_code());

View File

@@ -101,6 +101,13 @@ public class TaskController {
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("取消任务和指令")
@PostMapping(value = "/cancelAndInst/{id}")
public ResponseEntity<Object> cancelAndInst(@RequestBody String id) throws Exception {
taskService.cancelAndInst(id);
return new ResponseEntity<>(HttpStatus.OK);
}
@Log("手动创建指令")
@PostMapping(value = "/createInst/{id}")
public ResponseEntity<Object> createInst(@RequestBody String id) throws Exception {

View File

@@ -303,6 +303,16 @@ public interface TaskService extends CommonService<Task> {
void cancel(String ids) throws Exception;
/**
* 取消任务和指令
*
* @param ids
* @throws Exception
*/
void cancelAndInst(String ids) throws Exception;
/**
* 手动创建指令
*

View File

@@ -881,6 +881,38 @@ public class TaskServiceImpl extends CommonServiceImpl<TaskMapper, Task> impleme
}
}
@Override
@Transactional(rollbackFor = Exception.class)
public void cancelAndInst(String id) throws Exception {
TaskDto entity = this.findById(id);
if (entity == null) {
throw new BadRequestException(LangProcess.msg("error_sysAuth"));
}
InstructionDto instdto = instructionService.findByTaskid(id, "instruction_status <2 ");
if (instdto != null) {
instructionService.cancel(instdto.getInstruction_id());
}
String currentUsername = SecurityUtils.getCurrentNickName();
String now = DateUtil.now();
entity.setUpdate_time(now);
entity.setUpdate_by(currentUsername);
entity.setTask_status(TaskStatusEnum.CANCEL.getIndex());
Task task = ConvertUtil.convert(entity, Task.class);
taskMapper.updateById(task);
//移除任务缓存信息
this.removeByCodeFromCache(entity.getTask_code());
//反馈上位系统任务状态
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()))) {
this.markComplete(entity);
}
}
@Override
public Instruction createInst(String ids) throws Exception {

View File

@@ -51,7 +51,7 @@ spring:
monitorInterval: 8
tomcatTp: # tomcat webserver 线程池配置
threadPoolAliasName: tomcat 线程池 # 线程池别名,可选
corePoolSize: 10
corePoolSize: 30
maximumPoolSize: 50
keepAliveTime: 60
runTimeout: 10000
@@ -60,8 +60,8 @@ spring:
- threadPoolName: dtpExecutor1 # 线程池名称,必填
threadPoolAliasName: core_thread # 线程池别名,可选
executorType: common # 线程池类型 common、eager、ordered、scheduled、priority默认 common
corePoolSize: 10 # 核心线程数默认1
maximumPoolSize: 30 # 最大线程数默认cpu核数
corePoolSize: 30 # 核心线程数默认1
maximumPoolSize: 50 # 最大线程数默认cpu核数
queueCapacity: 1024 # 队列容量默认1024
queueType: VariableLinkedBlockingQueue # 任务队列查看源码QueueTypeEnum枚举类默认VariableLinkedBlockingQueue
rejectedHandlerType: CallerRunsPolicy # 拒绝策略查看RejectedTypeEnum枚举类默认AbortPolicy