Merge remote-tracking branch 'origin/master'

This commit is contained in:
2023-12-06 18:36:17 +08:00
15 changed files with 194 additions and 43 deletions

View File

@@ -9,7 +9,6 @@ import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.core.annotation.Order; import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
/** /**
* 随项目启动模块 * 随项目启动模块
*/ */
@@ -17,7 +16,12 @@ import org.springframework.stereotype.Component;
@Component @Component
@RequiredArgsConstructor @RequiredArgsConstructor
@Order(50) @Order(50)
//@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "prod") /**
* Demo class
*@ConditionalOnProperty(value = "spring.profiles.active",havingValue = "prod")
* @author zhoujj
* @date 2023/12/06
*/
public class AcsInit implements ApplicationRunner { public class AcsInit implements ApplicationRunner {
private final ApplicationAutoInitialExecuter applicationAutoInitialExecuter; private final ApplicationAutoInitialExecuter applicationAutoInitialExecuter;
private final WebAutoInitialExecuter webAutoInitialExecuter; private final WebAutoInitialExecuter webAutoInitialExecuter;

View File

@@ -23,6 +23,12 @@ import java.util.Map;
@RequestMapping("/api/autorun") @RequestMapping("/api/autorun")
@Api(tags = "系统:查询自动线程") @Api(tags = "系统:查询自动线程")
@RequiredArgsConstructor @RequiredArgsConstructor
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public class AutoRunController { public class AutoRunController {
@Autowired @Autowired
@@ -32,7 +38,6 @@ public class AutoRunController {
@Log("查询自动线程") @Log("查询自动线程")
@GetMapping @GetMapping
public ResponseEntity<Object> query(Map map) throws Exception { public ResponseEntity<Object> query(Map map) throws Exception {
//List<ThreadDto> ThreadDtos = autoRunService.findByCondition(map);
List<ThreadDto> ThreadDtos = autoRunService.findAll(); List<ThreadDto> ThreadDtos = autoRunService.findAll();
return new ResponseEntity<>(PageUtil.toPage(ThreadDtos, ThreadDtos.size()), HttpStatus.OK); return new ResponseEntity<>(PageUtil.toPage(ThreadDtos, ThreadDtos.size()), HttpStatus.OK);
} }

View File

@@ -1,6 +1,18 @@
package org.nl.acs.auto.initial; package org.nl.acs.auto.initial;
//DeviceOpcProtocolRunable-----DeviceOpcSynchronizeAutoRun----AbstractAutoRunable-----AutoRunServiceImpl----- WebAutoInitialExecuter /**
* Demo class
*
*
* @author zhoujj
* @date 2023/12/06
* //DeviceOpcProtocolRunable-----DeviceOpcSynchronizeAutoRun----AbstractAutoRunable-----AutoRunServiceImpl----- WebAutoInitialExecuter
*
*/
public interface ApplicationAutoInitial { public interface ApplicationAutoInitial {
/**
*
* @throws Exception
*/
void autoInitial() throws Exception; void autoInitial() throws Exception;
} }

View File

@@ -7,7 +7,12 @@ import org.springframework.stereotype.Component;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
@Component @Component
public class ApplicationAutoInitialExecuter { public class ApplicationAutoInitialExecuter {
/** /**
@@ -15,7 +20,11 @@ public class ApplicationAutoInitialExecuter {
*/ */
@Autowired(required = false) @Autowired(required = false)
List<ApplicationAutoInitial> applicationAutoInitial; List<ApplicationAutoInitial> applicationAutoInitial;
//是否启动 /**
*
* 是否启动
*
*/
private final static boolean IS_AUTO_THREAD_CODE = true; private final static boolean IS_AUTO_THREAD_CODE = true;
public void init() throws Exception { public void init() throws Exception {

View File

@@ -1,5 +1,14 @@
package org.nl.acs.auto.initial; package org.nl.acs.auto.initial;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public interface WebAutoInitial { public interface WebAutoInitial {
/**
*
* @throws Exception
*/
void autoInitial() throws Exception; void autoInitial() throws Exception;
} }

View File

@@ -10,6 +10,12 @@ import java.util.List;
@Component @Component
@Lazy(false) @Lazy(false)
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public class WebAutoInitialExecuter { public class WebAutoInitialExecuter {
@Autowired(required = false) @Autowired(required = false)
List<WebAutoInitial> webAutoInitial; List<WebAutoInitial> webAutoInitial;

View File

@@ -5,6 +5,12 @@ import lombok.extern.slf4j.Slf4j;
import java.util.Date; import java.util.Date;
@Slf4j @Slf4j
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public abstract class AbstractAutoRunnable implements Runnable { public abstract class AbstractAutoRunnable implements Runnable {
private ThreadStatusEnum status; private ThreadStatusEnum status;
private Date startTime; private Date startTime;
@@ -26,8 +32,6 @@ public abstract class AbstractAutoRunnable implements Runnable {
this.setStopMessage(true_clear); this.setStopMessage(true_clear);
} catch (Throwable arg5) { } catch (Throwable arg5) {
log.warn("", arg5); log.warn("", arg5);
System.out.println(arg5.getMessage());
// this.setStopMessage(ExceptionUtlEx.getSimpleTrace(arg5));
} finally { } finally {
this.setStopTime(new Date()); this.setStopTime(new Date());
this.setStatus(ThreadStatusEnum.stop); this.setStatus(ThreadStatusEnum.stop);
@@ -53,15 +57,25 @@ public abstract class AbstractAutoRunnable implements Runnable {
public Boolean getForbidDisable() { public Boolean getForbidDisable() {
return Boolean.valueOf(false); return Boolean.valueOf(false);
} }
/**
*getCode
* @return Code
*/
public abstract String getCode(); public abstract String getCode();
/**
*getName
* @return Name
*/
public abstract String getName(); public abstract String getName();
public String getDescription() { public String getDescription() {
return this.getName(); return this.getName();
} }
/**
*autoRun
* @return autoRun
* @throws
*/
public abstract void autoRun() throws Exception; public abstract void autoRun() throws Exception;
public ThreadStatusEnum getStatus() { public ThreadStatusEnum getStatus() {

View File

@@ -2,17 +2,57 @@ package org.nl.acs.auto.run;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public interface AutoRunService { public interface AutoRunService {
/**
* 开始线程
*
* @param arg0 条件
* @return /
*/
void startThread(String arg0); void startThread(String arg0);
/**
* 结束线程
*
* @param arg0 条件
* @return /
*/
void stopThread(String arg0); void stopThread(String arg0);
/**
* 通过编号查找
*
* @param arg0 条件
* @param arg1 条件
* @return /
*/
ThreadDto findByCode(String arg0, String arg1); ThreadDto findByCode(String arg0, String arg1);
/**
* 查找全部
*
*
* @return /
*/
List<ThreadDto> findAll(); List<ThreadDto> findAll();
/**
* 通过条件得到
*
* @param whereJson 条件
* @return /
*/
List<ThreadDto> findByCondition(Map whereJson); List<ThreadDto> findByCondition(Map whereJson);
/**
* 通过编码得到线程
*
* @param code 条件
* @return /
*/
Thread getThreadByCode(String code); Thread getThreadByCode(String code);
} }

View File

@@ -20,14 +20,31 @@ import java.util.*;
*/ */
@Service @Service
@Slf4j @Slf4j
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public class AutoRunServiceImpl implements AutoRunService, ApplicationAutoInitial { public class AutoRunServiceImpl implements AutoRunService, ApplicationAutoInitial {
@Autowired(required = false) @Autowired(required = false)
private List<AbstractAutoRunnable> abstractAutoRunnableList; private List<AbstractAutoRunnable> abstractAutoRunnableList;
private List<AbstractAutoRunnable> thread_autoRun = new ArrayList(); // 线程类 /**
private List<String> autoRun_code_index = new ArrayList(); // key * 线程类
private List<Thread> threads = new ArrayList(); // 运行线程 */
private List<String> thread_code_index = new ArrayList(); // key private List<AbstractAutoRunnable> thread_autoRun = new ArrayList();
/**
* key
*/
private List<String> autoRun_code_index = new ArrayList();
/**
* 运行线程
*/
private List<Thread> threads = new ArrayList();
/**
* key
*/
private List<String> thread_code_index = new ArrayList();
@Override @Override
public synchronized void startThread(String threadCode) { public synchronized void startThread(String threadCode) {
Thread thread = this.getThreadByCode(threadCode); Thread thread = this.getThreadByCode(threadCode);

View File

@@ -2,11 +2,20 @@ package org.nl.acs.auto.run;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public class DevelopConfig { public class DevelopConfig {
//@DictionaryItem(description = "开发的选项只有当开发为true的时候才生效") /**
* 开发的选项只有当开发为true的时候才生效
*/
public static Boolean develop = Boolean.valueOf(true); public static Boolean develop = Boolean.valueOf(true);
//@DictionaryItem(description = "强制关闭的自启动线程") /**
* 强制关闭的自启动线程
*/
public static List<String> thread_auto_run_force_stop = new ArrayList(); public static List<String> thread_auto_run_force_stop = new ArrayList();
static { static {

View File

@@ -30,8 +30,12 @@ import java.util.Date;
import java.util.List; import java.util.List;
import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString; import static org.nl.acs.agv.server.impl.NDCAgvServiceImpl.Bytes2HexString;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
@Slf4j @Slf4j
@Component @Component
public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable { public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
@@ -62,11 +66,11 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
public OneNDCSocketConnectionAutoRun() { public OneNDCSocketConnectionAutoRun() {
this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut); this.recordTime = new Date((new Date()).getTime() - (long) this.recordTimeOut);
} }
@Override
public String getCode() { public String getCode() {
return OneNDCSocketConnectionAutoRun.class.getSimpleName(); return OneNDCSocketConnectionAutoRun.class.getSimpleName();
} }
@Override
public String getName() { public String getName() {
return "NDC在线连接"; return "NDC在线连接";
} }
@@ -112,7 +116,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp)); bs.append(temp < 16 ? bs1.append(Integer.toHexString(temp)) : Integer.toHexString(temp));
} }
//System.out.println("收到请求参数:" + bs);
boolean flag = false; boolean flag = false;
if (arr[8] * 256 + arr[9] == 0x73) { if (arr[8] * 256 + arr[9] == 0x73) {
byte[] data = null; byte[] data = null;
@@ -219,12 +222,6 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
System.out.println("Agv链接异常"); System.out.println("Agv链接异常");
log.info("Agv链接异常"); log.info("Agv链接异常");
log.error("agv连接出现异常:{}", e); log.error("agv连接出现异常:{}", e);
// logServer.deviceExecuteLog("1", "", "", "agv异常" + e.getMessage());
// logServer.deviceExecuteLog("1", "", "", "agv异常" + e);
// LuceneLogDto logDto = new LuceneLogDto();
// logDto.setContent("agv异常" + e.getMessage());
// logDto.setDevice_code("1001");
// luceneExecuteLogService.deviceExecuteLog(logDto);
if (ObjectUtil.isNotEmpty(s)) { if (ObjectUtil.isNotEmpty(s)) {
s.close(); s.close();
} }

View File

@@ -1,12 +1,25 @@
package org.nl.acs.auto.run; package org.nl.acs.auto.run;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public class SystemConfig { public class SystemConfig {
//@DictionaryItem(description = "当前系统编码与其他系统通信对接的时候需要用到此编码") /**
* 当前系统编码与其他系统通信对接的时候需要用到此编码
*/
public static String system_code = "wcs10"; public static String system_code = "wcs10";
// @DictionaryItem(description = "默认用户密码") /**
* 默认用户密码
*/
public static String default_password = "1"; public static String default_password = "1";
// @DictionaryItem(description = "默认序列创建初始值") /**
* 默认序列创建初始值
*/
public static Integer sequence_initial_value = Integer.valueOf(1); public static Integer sequence_initial_value = Integer.valueOf(1);
//@DictionaryItem(description = "主线程是否自动开启选项") /**
* 主线程是否自动开启选项
*/
public static Boolean thread_auto_run = Boolean.valueOf(true); public static Boolean thread_auto_run = Boolean.valueOf(true);
} }

View File

@@ -1,7 +1,12 @@
package org.nl.acs.auto.run; package org.nl.acs.auto.run;
import java.util.Date; import java.util.Date;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public class ThreadDto { public class ThreadDto {
private String code; private String code;

View File

@@ -1,6 +1,12 @@
package org.nl.acs.auto.run; package org.nl.acs.auto.run;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public enum ThreadStatusEnum { public enum ThreadStatusEnum {
//create 创建
create("创建", 1), run("运行", 2), stop("停止", 3); create("创建", 1), run("运行", 2), stop("停止", 3);
private String description; private String description;

View File

@@ -1,7 +1,12 @@
package org.nl.acs.auto.run; package org.nl.acs.auto.run;
/**
* Demo class
*
* @author zhoujj
* @date 2023/12/06
*/
public enum ThreadUsedStatusEnum { public enum ThreadUsedStatusEnum {
//used 使用
used("使用", 1), unUsed("未使用", 2); used("使用", 1), unUsed("未使用", 2);
private String description; private String description;