代码修改
This commit is contained in:
@@ -1,55 +0,0 @@
|
|||||||
package org.nl.modules.system.rest;
|
|
||||||
|
|
||||||
import io.swagger.annotations.Api;
|
|
||||||
import io.swagger.annotations.ApiOperation;
|
|
||||||
import lombok.RequiredArgsConstructor;
|
|
||||||
import org.nl.modules.common.utils.PageUtil;
|
|
||||||
import org.nl.modules.logging.annotation.Log;
|
|
||||||
import org.nl.start.auto.run.AutoRunService;
|
|
||||||
import org.nl.start.auto.run.ThreadDto;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
|
||||||
import org.springframework.http.HttpStatus;
|
|
||||||
import org.springframework.http.ResponseEntity;
|
|
||||||
import org.springframework.web.bind.annotation.*;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author /
|
|
||||||
* 接口限流测试类
|
|
||||||
*/
|
|
||||||
@RestController
|
|
||||||
@RequestMapping("/api/autorun")
|
|
||||||
@Api(tags = "系统:查询自动线程")
|
|
||||||
@RequiredArgsConstructor
|
|
||||||
public class AutoRunController {
|
|
||||||
|
|
||||||
@Autowired
|
|
||||||
private AutoRunService autoRunService;
|
|
||||||
|
|
||||||
@ApiOperation("查询自动线程")
|
|
||||||
@Log("查询自动线程")
|
|
||||||
@GetMapping
|
|
||||||
public ResponseEntity<Object> query(Map map) throws Exception {
|
|
||||||
//List<ThreadDto> ThreadDtos = autoRunService.findByCondition(map);
|
|
||||||
List<ThreadDto> ThreadDtos = autoRunService.findAll();
|
|
||||||
return new ResponseEntity<>(PageUtil.toPage(ThreadDtos, ThreadDtos.size()), HttpStatus.OK);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Log("启动自动线程")
|
|
||||||
@ApiOperation("启动自动线程")
|
|
||||||
@PutMapping(value = "/start/{code}")
|
|
||||||
public ResponseEntity<Object> start(@PathVariable String code) {
|
|
||||||
autoRunService.startThread(code);
|
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Log("停止自动线程")
|
|
||||||
@ApiOperation("停止自动线程")
|
|
||||||
@PutMapping(value = "/stop/{code}")
|
|
||||||
public ResponseEntity<Object> execution(@PathVariable String code) {
|
|
||||||
autoRunService.stopThread(code);
|
|
||||||
return new ResponseEntity<>(HttpStatus.NO_CONTENT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,93 +0,0 @@
|
|||||||
|
|
||||||
package org.nl.start;
|
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
|
||||||
import cn.hutool.core.bean.copier.CopyOptions;
|
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
|
||||||
import lombok.Data;
|
|
||||||
import org.nl.modules.common.base.BaseEntity;
|
|
||||||
|
|
||||||
import javax.persistence.Column;
|
|
||||||
import javax.persistence.Entity;
|
|
||||||
import javax.persistence.Id;
|
|
||||||
import javax.persistence.Table;
|
|
||||||
import javax.validation.constraints.NotBlank;
|
|
||||||
import javax.validation.constraints.NotNull;
|
|
||||||
import java.io.Serializable;
|
|
||||||
import java.math.BigDecimal;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @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));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -9,8 +9,6 @@ import org.nl.modules.quartz.domain.QuartzJob;
|
|||||||
import org.nl.modules.quartz.repository.QuartzJobRepository;
|
import org.nl.modules.quartz.repository.QuartzJobRepository;
|
||||||
import org.nl.modules.quartz.utils.QuartzManage;
|
import org.nl.modules.quartz.utils.QuartzManage;
|
||||||
import org.nl.modules.system.service.impl.ParamServiceImpl;
|
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.wql.WQLCore;
|
import org.nl.wql.WQLCore;
|
||||||
import org.nl.wql.util.SpringContextHolder;
|
import org.nl.wql.util.SpringContextHolder;
|
||||||
import org.springframework.beans.BeansException;
|
import org.springframework.beans.BeansException;
|
||||||
@@ -35,9 +33,6 @@ import java.util.List;
|
|||||||
@Component
|
@Component
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class Init implements ApplicationRunner, BeanFactoryAware, ApplicationContextAware {
|
public class Init implements ApplicationRunner, BeanFactoryAware, ApplicationContextAware {
|
||||||
private final ApplicationAutoInitialExecuter applicationAutoInitialExecuter;
|
|
||||||
private final WebAutoInitialExecuter webAutoInitialExecuter;
|
|
||||||
|
|
||||||
private final QuartzJobRepository quartzJobRepository;
|
private final QuartzJobRepository quartzJobRepository;
|
||||||
private final QuartzManage quartzManage;
|
private final QuartzManage quartzManage;
|
||||||
|
|
||||||
@@ -47,9 +42,6 @@ public class Init implements ApplicationRunner, BeanFactoryAware, ApplicationCon
|
|||||||
private void init() throws Exception {
|
private void init() throws Exception {
|
||||||
//初始化WQL
|
//初始化WQL
|
||||||
initWql();
|
initWql();
|
||||||
//随线程启动
|
|
||||||
initApplicationAutoInitialExecuter();
|
|
||||||
initWebAutoInitialExecuter();
|
|
||||||
//初始化任务调度
|
//初始化任务调度
|
||||||
initQuartz();
|
initQuartz();
|
||||||
//用户岗位表【sys_users_roles】
|
//用户岗位表【sys_users_roles】
|
||||||
@@ -192,14 +184,6 @@ public class Init implements ApplicationRunner, BeanFactoryAware, ApplicationCon
|
|||||||
log.info("WQL初始化成功!");
|
log.info("WQL初始化成功!");
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initApplicationAutoInitialExecuter() throws Exception {
|
|
||||||
applicationAutoInitialExecuter.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initWebAutoInitialExecuter() throws Exception {
|
|
||||||
webAutoInitialExecuter.init();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run(ApplicationArguments args) throws Exception {
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
this.init();
|
this.init();
|
||||||
|
|||||||
@@ -1,102 +0,0 @@
|
|||||||
[交易说明]
|
|
||||||
交易名: 库区分页查询
|
|
||||||
所属模块:
|
|
||||||
功能简述:
|
|
||||||
版权所有:
|
|
||||||
表引用:
|
|
||||||
版本经历:
|
|
||||||
|
|
||||||
[数据库]
|
|
||||||
--指定数据库,为空采用默认值,默认为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
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,58 +0,0 @@
|
|||||||
[交易说明]
|
|
||||||
交易名: 按载具出库分页查询
|
|
||||||
所属模块:
|
|
||||||
功能简述:
|
|
||||||
版权所有:
|
|
||||||
表引用:
|
|
||||||
版本经历:
|
|
||||||
|
|
||||||
[数据库]
|
|
||||||
--指定数据库,为空采用默认值,默认为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
|
|
||||||
|
|
||||||
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
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);
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,6 +0,0 @@
|
|||||||
package org.nl.start.auto.initial;
|
|
||||||
|
|
||||||
//DeviceOpcProtocolRunable-----DeviceOpcSynchronizeAutoRun----AbstractAutoRunable-----AutoRunServiceImpl----- WebAutoInitialExecuter
|
|
||||||
public interface ApplicationAutoInitial {
|
|
||||||
void autoInitial() throws Exception;
|
|
||||||
}
|
|
||||||
@@ -1,41 +0,0 @@
|
|||||||
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());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,5 +0,0 @@
|
|||||||
package org.nl.start.auto.initial;
|
|
||||||
|
|
||||||
public interface WebAutoInitial {
|
|
||||||
void autoInitial() throws Exception;
|
|
||||||
}
|
|
||||||
@@ -1,33 +0,0 @@
|
|||||||
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();
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,104 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
@@ -1,217 +0,0 @@
|
|||||||
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.start.auto.initial.ApplicationAutoInitial;
|
|
||||||
import org.nl.wql.exception.WDKException;
|
|
||||||
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();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,15 +0,0 @@
|
|||||||
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");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,12 +0,0 @@
|
|||||||
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);
|
|
||||||
}
|
|
||||||
@@ -1,134 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,22 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
@@ -1,23 +0,0 @@
|
|||||||
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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user