init project

This commit is contained in:
ldj_willow
2022-07-06 18:32:05 +08:00
parent 87ed66116e
commit e0498895f2
750 changed files with 68267 additions and 0 deletions

View File

@@ -0,0 +1,89 @@
package org.nl.start;
import lombok.Data;
import cn.hutool.core.bean.BeanUtil;
import io.swagger.annotations.ApiModelProperty;
import cn.hutool.core.bean.copier.CopyOptions;
import org.nl.base.BaseEntity;
import javax.persistence.*;
import javax.validation.constraints.*;
import java.math.BigDecimal;
import java.io.Serializable;
/**
* @description /
* @author ldjun
* @date 2021-01-13
**/
@Entity
@Data
@Table(name="sys_code_ruledetail")
public class CodeRuledetail extends BaseEntity implements Serializable {
@Id
@Column(name = "id")
@ApiModelProperty(value = "id")
private String id;
@Column(name = "type",nullable = false)
@NotBlank
@ApiModelProperty(value = "type")
private String type;
@Column(name = "init_value")
@ApiModelProperty(value = "init_value")
private String init_value;
@Column(name = "current_value")
@ApiModelProperty(value = "current_value")
private String current_value;
@Column(name = "max_value")
@ApiModelProperty(value = "max_value")
private String max_value;
@Column(name = "step")
@ApiModelProperty(value = "step")
private String step;
@Column(name = "fillchar")
@ApiModelProperty(value = "fillchar")
private String fillchar;
@Column(name = "format")
@ApiModelProperty(value = "format")
private String format;
@Column(name = "length")
@ApiModelProperty(value = "length")
private BigDecimal length;
@Column(name = "sort_num",nullable = false)
@NotNull
@ApiModelProperty(value = "sort_num")
private BigDecimal sort_num;
@Column(name = "remark")
@ApiModelProperty(value = "remark")
private String remark;
@Column(name = "rule_id",nullable = false)
@NotBlank
@ApiModelProperty(value = "rule_id")
private String rule_id;
@Column(name = "is_active",nullable = false)
@NotBlank
@ApiModelProperty(value = "is_active")
private String is_active;
@Column(name = "is_delete",nullable = false)
@NotBlank
@ApiModelProperty(value = "is_delete")
private String is_delete;
public void copy(CodeRuledetail source){
BeanUtil.copyProperties(source,this, CopyOptions.create().setIgnoreNullValue(true));
}
}

View File

@@ -0,0 +1,217 @@
package org.nl.start;
import cn.hutool.core.util.StrUtil;
import com.alibaba.druid.pool.DruidDataSource;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.nl.modules.mnt.util.DataTypeEnum;
import org.nl.modules.quartz.domain.QuartzJob;
import org.nl.modules.quartz.repository.QuartzJobRepository;
import org.nl.modules.quartz.utils.QuartzManage;
import org.nl.modules.system.service.impl.ParamServiceImpl;
import org.nl.start.auto.initial.ApplicationAutoInitialExecuter;
import org.nl.start.auto.initial.WebAutoInitialExecuter;
import org.nl.utils.SpringContextHolder;
import org.nl.wql.WQLCore;
import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.BeanFactoryAware;
import org.springframework.beans.factory.support.BeanDefinitionBuilder;
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;
import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.List;
/**
* 随项目启动模块
*/
@Slf4j
@Component
@RequiredArgsConstructor
public class Init implements ApplicationRunner, BeanFactoryAware, ApplicationContextAware {
private final ApplicationAutoInitialExecuter applicationAutoInitialExecuter;
private final WebAutoInitialExecuter webAutoInitialExecuter;
private final QuartzJobRepository quartzJobRepository;
private final QuartzManage quartzManage;
private final DefaultListableBeanFactory beanFactory;
private void init() throws Exception {
//初始化WQL
initWql();
//随线程启动
initApplicationAutoInitialExecuter();
initWebAutoInitialExecuter();
//初始化任务调度
initQuartz();
//用户岗位表【sys_users_roles】
System.out.println("项目启动成功!");
}
private void initOracle(){
String jdbcUrl = "jdbc:oracle:thin:@10.16.1.30:1521:xrrun";
String userName = "erp";
String password = "erp";
DruidDataSource druidDataSource = new DruidDataSource();
String className;
try {
className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
} catch (SQLException e) {
throw new RuntimeException("Get class name error: =" + jdbcUrl);
}
if (StrUtil.isEmpty(className)) {
DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
if (null == dataTypeEnum) {
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
}
druidDataSource.setDriverClassName(dataTypeEnum.getDriver());
} else {
druidDataSource.setDriverClassName(className);
}
druidDataSource.setUrl(jdbcUrl);
druidDataSource.setUsername(userName);
druidDataSource.setPassword(password);
// 配置获取连接等待超时的时间
druidDataSource.setMaxWait(3000);
// 配置初始化大小、最小、最大
druidDataSource.setInitialSize(5);
druidDataSource.setMinIdle(5);
druidDataSource.setMaxActive(10);
// 如果链接出现异常则直接判定为失败而不是一直重试
druidDataSource.setBreakAfterAcquireFailure(true);
try {
druidDataSource.init();
} catch (SQLException e) {
log.error("Exception during pool initialization", e);
throw new RuntimeException(e.getMessage());
}
System.out.println("oracle连接成功");
}
private void initDataSource1() {
String IS_CONNECT_ERP = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("IS_CON_ERP_ORACLE").getValue();
if (!StrUtil.equals("1", IS_CONNECT_ERP)) return;
String jdbcUrl = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("ERP_ORACLE_URL").getValue();
String userName = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("ERP_ORACLE_USER").getValue();
String password = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("ERP_ORACLE_PWD").getValue();
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DruidDataSource.class);
String className;
try {
className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
} catch (SQLException e) {
throw new RuntimeException("Get class name error: =" + jdbcUrl);
}
if (StrUtil.isEmpty(className)) {
DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
if (null == dataTypeEnum) {
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
}
builder.addPropertyValue("driverClassName", dataTypeEnum.getDriver());
} else {
builder.addPropertyValue("driverClassName", className);
}
builder.addPropertyValue("url", jdbcUrl);
builder.addPropertyValue("username", userName);
builder.addPropertyValue("password", password);
// 配置获取连接等待超时的时间
builder.addPropertyValue("maxWait", "3000");
// 配置初始化大小、最小、最大
builder.addPropertyValue("initialSize", "5");
builder.addPropertyValue("minIdle", "5");
builder.addPropertyValue("maxActive", "10");
// 如果链接出现异常则直接判定为失败而不是一直重试
builder.addPropertyValue("breakAfterAcquireFailure", "true");
beanFactory.registerBeanDefinition("dataSource1", builder.getBeanDefinition());
}
public void initDataSource2() {
String IS_CONNECT_ERP = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("IS_CON_ERP_SQLSERVER").getValue();
if (!StrUtil.equals("1", IS_CONNECT_ERP)) return;
String jdbcUrl = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("ERP_SQLSERVER_URL").getValue();
String userName = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("ERP_SQLSERVER_USER").getValue();
String password = SpringContextHolder.getBean(ParamServiceImpl.class).findByCode("ERP_SQLSERVER_PWD").getValue();
BeanDefinitionBuilder builder = BeanDefinitionBuilder.rootBeanDefinition(DruidDataSource.class);
String className;
try {
className = DriverManager.getDriver(jdbcUrl.trim()).getClass().getName();
} catch (SQLException e) {
throw new RuntimeException("Get class name error: =" + jdbcUrl);
}
if (StrUtil.isEmpty(className)) {
DataTypeEnum dataTypeEnum = DataTypeEnum.urlOf(jdbcUrl);
if (null == dataTypeEnum) {
throw new RuntimeException("Not supported data type: jdbcUrl=" + jdbcUrl);
}
builder.addPropertyValue("driverClassName", dataTypeEnum.getDriver());
} else {
builder.addPropertyValue("driverClassName", className);
}
builder.addPropertyValue("url", jdbcUrl);
builder.addPropertyValue("username", userName);
builder.addPropertyValue("password", password);
// 配置获取连接等待超时的时间
builder.addPropertyValue("maxWait", "3000");
// 配置初始化大小、最小、最大
builder.addPropertyValue("initialSize", "5");
builder.addPropertyValue("minIdle", "5");
builder.addPropertyValue("maxActive", "10");
// 如果链接出现异常则直接判定为失败而不是一直重试
builder.addPropertyValue("breakAfterAcquireFailure", "true");
beanFactory.registerBeanDefinition("dataSource2", builder.getBeanDefinition());
}
private void initQuartz() {
log.info("--------------------注入定时任务---------------------");
List<QuartzJob> quartzJobs = quartzJobRepository.findByIsPauseIsFalse();
quartzJobs.forEach(quartzManage::addJob);
log.info("--------------------定时任务注入完成---------------------");
}
private void initWql() throws Exception {
WQLCore.ROOT = "org.nl";
WQLCore.init();
log.info("WQL初始化成功!");
}
private void initApplicationAutoInitialExecuter() throws Exception {
applicationAutoInitialExecuter.init();
}
private void initWebAutoInitialExecuter() throws Exception {
webAutoInitialExecuter.init();
}
@Override
public void run(ApplicationArguments args) throws Exception {
this.init();
}
@Override
public void setBeanFactory(BeanFactory beanFactory1) throws BeansException {
}
@Override
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
}
}

View File

@@ -0,0 +1,102 @@
[交易说明]
交易名: 库区分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.import_date1 TYPEAS s_string
输入.import_date2 TYPEAS s_string
输入.import_date3 TYPEAS s_string
输入.begin_time TYPEAS s_string
输入.end_time TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
QUERY
SELECT
*
FROM
KIND
WHERE
UPDATED_DATE > to_date(输入.import_date1,'yyyy-mm-dd HH24:MI:SS')
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "2"
QUERY
SELECT
*
FROM
ITEM
WHERE
(UPDATED_DATE > to_date(输入.import_date2,'yyyy-mm-dd HH24:MI:SS')
OR
CREATE_DATE > to_date(输入.import_date2,'yyyy-mm-dd HH24:MI:SS')
)
ENDSELECT
ENDQUERY
ENDIF
IF 输入.flag = "3"
QUERY
SELECT
pp.*
FROM
PURCHASE pp
WHERE 1=1
OPTION 输入.import_date3 <> ""
(pp.UPDATED_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
OR
pp.CREATE_DATE > to_date(输入.import_date3,'yyyy-mm-dd HH24:MI:SS')
)
ENDOPTION
OPTION 输入.begin_time <> ""
pp.CREATE_DATE >= to_date(输入.begin_time,'yyyy-mm-dd HH24:MI:SS')
ENDOPTION
OPTION 输入.end_time <> ""
pp.CREATE_DATE <= to_date(输入.end_time,'yyyy-mm-dd HH24:MI:SS')
ENDOPTION
ENDSELECT
ENDQUERY
ENDIF

View File

@@ -0,0 +1,58 @@
[交易说明]
交易名: 按载具出库分页查询
所属模块:
功能简述:
版权所有:
表引用:
版本经历:
[数据库]
--指定数据库为空采用默认值默认为db.properties中列出的第一个库
[IO定义]
#################################################
## 表字段对应输入参数
#################################################
输入.flag TYPEAS s_string
输入.barcode TYPEAS s_string
[临时表]
--这边列出来的临时表就会在运行期动态创建
[临时变量]
--所有中间过程变量均可在此处定义
[业务过程]
##########################################
# 1、输入输出检查 #
##########################################
##########################################
# 2、主过程前处理 #
##########################################
##########################################
# 3、业务主过程 #
##########################################
IF 输入.flag = "1"
PAGEQUERY
SELECT
*
FROM
V_JM_BarCodeForAGV
WHERE
1 = 1
OPTION 输入.barcode <> ""
barcode like 输入.barcode
ENDOPTION
ENDSELECT
ENDPAGEQUERY
ENDIF

View File

@@ -0,0 +1,38 @@
package org.nl.start;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.nl.wql.WQL;
import org.nl.wql.WQLCore;
import org.nl.wql.core.bean.ResultBean;
import org.nl.wql.core.bean.WQLObject;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.HashMap;
@Slf4j
@Component
public class WQlStart implements ApplicationRunner {
@Override
public void run(ApplicationArguments args) throws Exception {
System.out.println("通过实现ApplicationRunner接口在spring boot项目启动后打印参数");
String[] sourceArgs = args.getSourceArgs();
/*for (String arg : sourceArgs) {
System.out.print(arg + " ");
}*/
WQLCore.defalutDBName = "dataSource";
WQLCore.init();
log.info("WQL初始化成功!");
System.out.println(11);
}
}

View File

@@ -0,0 +1,6 @@
package org.nl.start.auto.initial;
//DeviceOpcProtocolRunable-----DeviceOpcSynchronizeAutoRun----AbstractAutoRunable-----AutoRunServiceImpl----- WebAutoInitialExecuter
public interface ApplicationAutoInitial {
void autoInitial() throws Exception;
}

View File

@@ -0,0 +1,41 @@
package org.nl.start.auto.initial;
import org.nl.modules.system.service.ParamService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Component
public class ApplicationAutoInitialExecuter {
@Autowired(required = false)
List<ApplicationAutoInitial> applicationAutoInitial;
@Autowired
ParamService paramService;
//是否启动
private final static boolean IS_AUTO_THREAD_CODE = true;
public void init() throws Exception {
if (!IS_AUTO_THREAD_CODE) {
return;
}
List services = this.getApplicationAutoInitialService();
Iterator it = services.iterator();
while (it.hasNext()) {
ApplicationAutoInitial service = (ApplicationAutoInitial) it.next();
service.autoInitial();
}
}
private List<ApplicationAutoInitial> getApplicationAutoInitialService() {
return (List) (this.applicationAutoInitial != null && this.applicationAutoInitial.size() != 0
? this.applicationAutoInitial
: new ArrayList());
}
}

View File

@@ -0,0 +1,5 @@
package org.nl.start.auto.initial;
public interface WebAutoInitial {
void autoInitial() throws Exception;
}

View File

@@ -0,0 +1,33 @@
package org.nl.start.auto.initial;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
@Component
@Lazy(false)
public class WebAutoInitialExecuter {
@Autowired(required = false)
List<WebAutoInitial> webAutoInitial;
private List<WebAutoInitial> getWebAutoInitialService() {
return (List) (this.webAutoInitial != null && this.webAutoInitial.size() != 0
? this.webAutoInitial
: new ArrayList());
}
public void init() throws Exception {
List services = this.getWebAutoInitialService();
Iterator arg1 = services.iterator();
while (arg1.hasNext()) {
WebAutoInitial service = (WebAutoInitial) arg1.next();
service.autoInitial();
}
}
}

View File

@@ -0,0 +1,104 @@
package org.nl.start.auto.run;
import lombok.extern.slf4j.Slf4j;
import java.util.Date;
@Slf4j
public abstract class AbstractAutoRunnable implements Runnable {
private ThreadStatusEnum status;
private Date startTime;
private Date stopTime;
private String stopMessage;
private ThreadUsedStatusEnum usedStatus;
@Override
public void run() {
this.setStatus(ThreadStatusEnum.run);
this.setStartTime(new Date());
this.setStopMessage("");
String true_clear = "执行完毕";
try {
this.before();
//子类该方法是个死循环
this.autoRun();
this.setStopMessage(true_clear);
} catch (Throwable arg5) {
log.warn("", arg5);
// this.setStopMessage(ExceptionUtlEx.getSimpleTrace(arg5));
} finally {
this.setStopTime(new Date());
this.setStatus(ThreadStatusEnum.stop);
this.after();
}
}
public void before() throws Exception {
}
public void after() {
}
public void stop() {
this.after();
}
public Boolean getForbidStop() {
return Boolean.valueOf(false);
}
public Boolean getForbidDisable() {
return Boolean.valueOf(false);
}
public abstract String getCode();
public abstract String getName();
public String getDescription() {
return this.getName();
}
public abstract void autoRun() throws Exception;
public ThreadStatusEnum getStatus() {
return this.status;
}
public void setStatus(ThreadStatusEnum status) {
this.status = status;
}
public Date getStartTime() {
return this.startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getStopTime() {
return this.stopTime;
}
public void setStopTime(Date stopTime) {
this.stopTime = stopTime;
}
public String getStopMessage() {
return this.stopMessage;
}
public void setStopMessage(String stopMessage) {
this.stopMessage = stopMessage;
}
public ThreadUsedStatusEnum getUsedStatus() {
return this.usedStatus;
}
public void setUsedStatus(ThreadUsedStatusEnum usedStatus) {
this.usedStatus = usedStatus;
}
}

View File

@@ -0,0 +1,16 @@
package org.nl.start.auto.run;
import java.util.List;
import java.util.Map;
public interface AutoRunService {
void startThread(String arg0);
void stopThread(String arg0);
ThreadDto findByCode(String arg0, String arg1);
List<ThreadDto> findAll();
List<ThreadDto> findByCondition(Map whereJson);
}

View File

@@ -0,0 +1,217 @@
package org.nl.start.auto.run;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.StrUtil;
import lombok.extern.slf4j.Slf4j;
import org.nl.exception.WDKException;
import org.nl.start.auto.initial.ApplicationAutoInitial;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
@Service
@Slf4j
public class AutoRunServiceImpl implements AutoRunService, ApplicationAutoInitial {
@Autowired(required = false)
private List<AbstractAutoRunnable> abstractAutoRunnableList;
private List<String> autoRun_code_index = new ArrayList();
private List<Thread> threads = new ArrayList();
private List<AbstractAutoRunnable> thread_autoRun = new ArrayList();
private List<String> thread_code_index = new ArrayList();
@Override
public synchronized void startThread(String threadCode) {
Thread thread = this.getThreadByCode(threadCode);
if (thread == null) {
throw new WDKException("线程不存在");
} else if (thread.isAlive()) {
throw new WDKException("已运行的无法开启运行");
} else {
int index = this.thread_code_index.indexOf(threadCode);
thread = new Thread(this.getRunablebyCode(threadCode));
this.threads.set(index, thread);
thread.start();
}
}
@Override
public synchronized void stopThread(String threadCode) {
Thread thread = this.getThreadByCode(threadCode);
if (thread == null) {
throw new WDKException("线程不存在");
} else if (!thread.isAlive()) {
throw new WDKException("已停止的无法再次停止");
} else {
AbstractAutoRunnable runable = this.getRunablebyCode(threadCode);
runable.stop();
thread.stop();
thread.interrupt();
try {
thread.join();
} catch (InterruptedException arg4) {
arg4.printStackTrace();
}
runable.setStopMessage("人工停止");
runable.setStopTime(new Date());
}
}
private Thread getThreadByCode(String code) {
int index = this.thread_code_index.indexOf(code);
return index < 0 ? null : (Thread) this.threads.get(index);
}
private AbstractAutoRunnable getRunablebyCode(String code) {
int index = this.thread_code_index.indexOf(code);
return index < 0 ? null : (AbstractAutoRunnable) this.thread_autoRun.get(index);
}
@Override
public List<ThreadDto> findAll() {
ArrayList list = new ArrayList();
List list2 = this.getAllAutoThread();
Iterator arg2 = list2.iterator();
AbstractAutoRunnable t;
ThreadDto e;
while (arg2.hasNext()) {
t = (AbstractAutoRunnable) arg2.next();
if (ThreadUsedStatusEnum.unUsed.equals(t.getUsedStatus())) {
e = new ThreadDto();
BeanUtil.copyProperties(t, e, true);
list.add(e);
}
}
arg2 = this.thread_autoRun.iterator();
while (arg2.hasNext()) {
t = (AbstractAutoRunnable) arg2.next();
e = new ThreadDto();
BeanUtil.copyProperties(t, e, true);
Thread thread = this.getThreadByCode(t.getCode());
e.setCode(t.getCode());
e.setName(t.getName());
e.setThread_alive(Boolean.valueOf(thread.isAlive()));
e.setThread_name(thread.getName());
e.setThread_id(thread.getId() + "");
e.setThread_state(thread.getState().toString());
list.add(e);
}
return list;
}
@Override
public List<ThreadDto> findByCondition(Map whereJson) {
List ori_threads = this.findAll();
ArrayList return_threads = new ArrayList();
if (CollectionUtil.isEmpty(whereJson)) {
return ori_threads;
} else {
Iterator it = ori_threads.iterator();
while (it.hasNext()) {
ThreadDto thread = (ThreadDto) it.next();
Map<String, Object> properties = BeanUtil.beanToMap(thread);
Iterator<Map.Entry<String, Object>> entries = whereJson.entrySet().iterator();
while (entries.hasNext()) {
Map.Entry<String, Object> entry = entries.next();
String column = entry.getKey();
String value = (String) entry.getValue();
if (properties.containsKey(column)) {
String propert = (String) properties.get(column);
if (!StrUtil.isEmpty(propert)
&& propert.contains(value)) {
return_threads.add(thread);
}
}
}
}
return return_threads;
}
}
@Override
public ThreadDto findByCode(String thread_code, String thread_id) {
List ori_threads = this.findAll();
Iterator arg3 = ori_threads.iterator();
ThreadDto thread;
do {
if (!arg3.hasNext()) {
return null;
}
thread = (ThreadDto) arg3.next();
} while (!StrUtil.equals(thread.getCode(), thread_code)
|| !StrUtil.equals(thread.getThread_id(), thread_id));
return thread;
}
private List<AbstractAutoRunnable> getAllAutoThread() {
return (List) (this.abstractAutoRunnableList != null && this.abstractAutoRunnableList.size() != 0
? this.abstractAutoRunnableList
: new LinkedList());
}
@Override
public void autoInitial() throws Exception {
List<AbstractAutoRunnable> list = this.getAllAutoThread();
Iterator it = list.iterator();
AbstractAutoRunnable t;
while (it.hasNext()) {
t = (AbstractAutoRunnable) it.next();
t.setUsedStatus(ThreadUsedStatusEnum.unUsed);
String a;
if (StrUtil.isEmpty(t.getCode())) {
a = "code 因为空而未加载";
log.warn(a);
t.setStopMessage(a);
this.autoRun_code_index.add(t.getCode());
} else if (this.autoRun_code_index.contains(t.getCode())) {
a = String.format("code:%s 因为重复而未加载", new Object[]{t.getCode()});
log.warn(a);
t.setStopMessage(a);
this.autoRun_code_index.add(t.getCode());
} else {
t.setUsedStatus(ThreadUsedStatusEnum.used);
this.thread_autoRun.add(t);
this.autoRun_code_index.add(t.getCode());
}
}
it = this.thread_autoRun.iterator();
while (it.hasNext()) {
t = (AbstractAutoRunnable) it.next();
this.threads.add(new Thread(t));
this.thread_code_index.add(t.getCode());
}
for (int i = 0; i < this.threads.size(); ++i) {
Thread thread = (Thread) this.threads.get(i);
AbstractAutoRunnable runnable = (AbstractAutoRunnable) this.thread_autoRun.get(i);
if (runnable.getForbidStop().booleanValue()) {
thread.start();
} else if (SystemConfig.thread_auto_run.booleanValue() && (!DevelopConfig.develop.booleanValue()
|| !DevelopConfig.thread_auto_run_force_stop.contains(this.thread_code_index.get(i)))) {
thread.start();
}
}
}
}

View File

@@ -0,0 +1,15 @@
package org.nl.start.auto.run;
import java.util.ArrayList;
import java.util.List;
public class DevelopConfig {
//@DictionaryItem(description = "开发的选项只有当开发为true的时候才生效")
public static Boolean develop = Boolean.valueOf(true);
//@DictionaryItem(description = "强制关闭的自启动线程")
public static List<String> thread_auto_run_force_stop = new ArrayList();
static {
thread_auto_run_force_stop.add("TaskFeedbackAutoRun");
}
}

View File

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

View File

@@ -0,0 +1,134 @@
package org.nl.start.auto.run;
import java.util.Date;
public class ThreadDto {
private String code;
private String name;
private String description;
private ThreadStatusEnum status;
private ThreadUsedStatusEnum usedStatus;
private Date startTime;
private Date stopTime;
private String stopMessage;
private Boolean thread_alive;
private String thread_name;
private String thread_id;
private String thread_state;
private Boolean forbidStop = Boolean.valueOf(false);
private Boolean forbidDisable = Boolean.valueOf(false);
public String getCode() {
return this.code;
}
public void setCode(String code) {
this.code = code;
}
public String getName() {
return this.name;
}
public void setName(String name) {
this.name = name;
}
public String getDescription() {
return this.description;
}
public void setDescription(String description) {
this.description = description;
}
public ThreadStatusEnum getStatus() {
return this.status;
}
public void setStatus(ThreadStatusEnum status) {
this.status = status;
}
public ThreadUsedStatusEnum getUsedStatus() {
return this.usedStatus;
}
public void setUsedStatus(ThreadUsedStatusEnum usedStatus) {
this.usedStatus = usedStatus;
}
public Date getStartTime() {
return this.startTime;
}
public void setStartTime(Date startTime) {
this.startTime = startTime;
}
public Date getStopTime() {
return this.stopTime;
}
public void setStopTime(Date stopTime) {
this.stopTime = stopTime;
}
public String getStopMessage() {
return this.stopMessage;
}
public void setStopMessage(String stopMessage) {
this.stopMessage = stopMessage;
}
public Boolean getThread_alive() {
return this.thread_alive;
}
public void setThread_alive(Boolean thread_alive) {
this.thread_alive = thread_alive;
}
public String getThread_name() {
return this.thread_name;
}
public void setThread_name(String thread_name) {
this.thread_name = thread_name;
}
public String getThread_id() {
return this.thread_id;
}
public void setThread_id(String thread_id) {
this.thread_id = thread_id;
}
public String getThread_state() {
return this.thread_state;
}
public void setThread_state(String thread_state) {
this.thread_state = thread_state;
}
public Boolean getForbidStop() {
return this.forbidStop;
}
public void setForbidStop(Boolean forbidStop) {
this.forbidStop = forbidStop;
}
public Boolean getForbidDisable() {
return this.forbidDisable;
}
public void setForbidDisable(Boolean forbidDisable) {
this.forbidDisable = forbidDisable;
}
}

View File

@@ -0,0 +1,22 @@
package org.nl.start.auto.run;
public enum ThreadStatusEnum {
create("创建", 1), run("运行", 2), stop("停止", 3);
private String description;
private int order;
private ThreadStatusEnum(String name, int order) {
this.description = name;
this.order = order;
}
public String description() {
return this.description;
}
public int getOrder() {
return this.order;
}
}

View File

@@ -0,0 +1,23 @@
package org.nl.start.auto.run;
public enum ThreadUsedStatusEnum {
used("使用", 1), unUsed("未使用", 2);
private String description;
private int order;
private ThreadUsedStatusEnum(String name, int order) {
this.description = name;
this.order = order;
}
public String description() {
return this.description;
}
public int getOrder() {
return this.order;
}
}