Commit 521db54d by tiger

Merge branch 'v1.0.1' into Branch_v1.0.1_kome

# Conflicts:
#	platform-process/pom.xml
#	platform-process/src/main/resources/application.properties_standalone
2 parents 136c43e2 2a6f1ef6
Showing 32 changed files with 454 additions and 87 deletions
...@@ -10,3 +10,4 @@ ...@@ -10,3 +10,4 @@
*.name *.name
/platform-process-api/*.factorypath /platform-process-api/*.factorypath
/platform-process/*.path_IS_UNDEFINED /platform-process/*.path_IS_UNDEFINED
/platform-process/logs/platform-process/*.log
...@@ -11,12 +11,6 @@ import javax.persistence.Transient; ...@@ -11,12 +11,6 @@ import javax.persistence.Transient;
@Table(name = "sop_inst_node") @Table(name = "sop_inst_node")
public class SopInstNode { public class SopInstNode {
public static final byte NODE_SKIP_FALSE = 0;
public static final byte NODE_SKIP_TRUE = 1;
public static final int NODE_STATUS_DELETED = 0;
public static final int NODE_STATUS_NORMAL = 1;
/** /**
* 实例节点id * 实例节点id
*/ */
......
...@@ -7,9 +7,6 @@ import javax.persistence.Table; ...@@ -7,9 +7,6 @@ import javax.persistence.Table;
@Table(name = "sop_tpl_node") @Table(name = "sop_tpl_node")
public class SopTplNode { public class SopTplNode {
public static final byte NODE_SKIPABLE_NO = 0;
public static final byte NODE_SKIPABLE_YES = 1;
/** /**
* 节点id * 节点id
*/ */
......
...@@ -54,11 +54,13 @@ public class SopCustomerSearch extends Page { ...@@ -54,11 +54,13 @@ public class SopCustomerSearch extends Page {
/** /**
* 进入sop旅程时间-开始 * 进入sop旅程时间-开始
* yyyy-MM-dd HH:mm:ss
*/ */
private String sopJourneyEnterTimeBegin; private String sopJourneyEnterTimeBegin;
/** /**
* 进入sop旅程时间-结束 * 进入sop旅程时间-结束
* yyyy-MM-dd HH:mm:ss
*/ */
private String sopJourneyEnterTimeEnd; private String sopJourneyEnterTimeEnd;
} }
package cn.com.glsx.process.modules.model.enums;
public enum SopInstNodeSkipEnum {
FALSE("不跳过节点", (byte)0), TRUE("跳过节点", (byte)1);
private String name;
private byte value;
SopInstNodeSkipEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopInstNodeStatusEnum {
DELETED("停用", 0), NORMAL("启用", 1);
private String name;
private int value;
SopInstNodeStatusEnum(String name, int value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopTplNodeSkipableEnum {
NO("不可跳过节点", (byte)0), YES("可跳过节点", (byte)1);
private String name;
private byte value;
SopTplNodeSkipableEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
package cn.com.glsx.process.modules.model.enums;
public enum SopTplSingletonEnum {
FALSE("多实例", (byte)0), TRUE("单实例", (byte)1);
private String name;
private byte value;
SopTplSingletonEnum(String name, byte value) {
this.name = name;
this.value = value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public byte getValue() {
return value;
}
public void setValue(byte value) {
this.value = value;
}
}
<?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent> <parent>
<groupId>cn.com.glsx</groupId> <groupId>cn.com.glsx</groupId>
<artifactId>platform-process-server</artifactId> <artifactId>platform-process-server</artifactId>
...@@ -20,8 +18,7 @@ ...@@ -20,8 +18,7 @@
<artifactId>rest-admin-context</artifactId> <artifactId>rest-admin-context</artifactId>
</dependency> </dependency>
<!-- 接入微服务组件联盟 配置、注册、网关、链路、监控等 <!-- 接入微服务组件联盟 配置、注册、网关、链路、监控等 ,单体应用无需引入(logback-spring.xml与logstash相关内容需要注释掉)-->
,单体应用无需引入(logback-spring.xml与logstash相关内容需要注释掉)-->
<dependency> <dependency>
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
<artifactId>rest-admin-alliance</artifactId> <artifactId>rest-admin-alliance</artifactId>
...@@ -38,6 +35,10 @@ ...@@ -38,6 +35,10 @@
<groupId>log4j</groupId> <groupId>log4j</groupId>
<artifactId>log4j</artifactId> <artifactId>log4j</artifactId>
</exclusion> </exclusion>
<exclusion>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</exclusion>
</exclusions> </exclusions>
</dependency> </dependency>
...@@ -154,40 +155,6 @@ ...@@ -154,40 +155,6 @@
<groupId>com.glsx</groupId> <groupId>com.glsx</groupId>
<artifactId>rest-admin-office</artifactId> <artifactId>rest-admin-office</artifactId>
</dependency> </dependency>
<!-- servlet 依赖 . -->
<dependency>
<groupId> javax.servlet </groupId>
<artifactId> javax.servlet-api </artifactId>
<scope> provided </scope>
</dependency>
<!--
JSTL ( JSP Standard Tag Library , JSP 标准标签库 ) 是一个不断完善的开放源代码的 JSP 标
签库,是由 apache 的 jakarta 小组来维护的。 JSTL 只能运行在支持 JSP1.2 和 Servlet2.3 规范的容器上,
如 tomcat4.x 。在 JSP 2.0 中也是作为标准支持的。
不然报异常信息:
javax.servlet.ServletException: Circular view path [/helloJsp]: would
dispatch back to the current handler URL [/helloJsp] again. Check your
ViewResolver
setup! (Hint: This may be the result of an unspecified view, due to default
view name
generation.)
-->
<dependency>
<groupId> javax.servlet </groupId>
<artifactId> jstl </artifactId>
</dependency>
<!-- tomcat 的支持 .-->
<dependency>
<groupId> org.springframework.boot </groupId>
<artifactId> spring-boot-starter-tomcat </artifactId>
<scope> provided </scope>
</dependency>
<dependency>
<groupId> org.apache.tomcat.embed </groupId>
<artifactId> tomcat-embed-jasper </artifactId>
<scope> provided </scope>
</dependency>
</dependencies> </dependencies>
<build> <build>
......
package cn.com.glsx; package cn.com.glsx;
import static java.time.ZoneId.of; import static java.time.ZoneId.of;
import static java.util.TimeZone.getTimeZone; import static java.util.TimeZone.getTimeZone;
...@@ -26,10 +27,11 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil; ...@@ -26,10 +27,11 @@ import cn.com.glsx.process.job.xxljob.core.SopXxlJobUtil;
@EnableDubbo @EnableDubbo
@EnableRestAdmin @EnableRestAdmin
@EnableDiscoveryClient @EnableDiscoveryClient
@EnableFeignClients(basePackages = { "cn.com.glsx.*.api", "cn.com.glsx.process.modules.client" }) @EnableFeignClients(basePackages = { "cn.com.glsx.*.api"})
@SpringBootApplication @SpringBootApplication
@EnableAspectJAutoProxy @EnableAspectJAutoProxy
@EnableTransactionManagement @EnableTransactionManagement
// @PropertySource("application.properties_standalone")
public class Application implements CommandLineRunner { public class Application implements CommandLineRunner {
public static void main(String[] args) { public static void main(String[] args) {
......
package cn.com.glsx.process.common.sysenum;
import com.glsx.plat.exception.SystemMessage;
/**
* 试驾服务错误码
*
* @author zhouhaibao
*/
public enum ResultEnum {
PARAM_ERROR(1001, "参数错误"),
FEIGN_REQUEST_ERROR(1002, "feign请求异常"),
DATA_HANDLE_ERROR(1003, "数据处理异常");
private final Integer code;
private final String message;
ResultEnum(Integer code, String message) {
this.code = code;
this.message = message;
}
ResultEnum(SystemMessage systemMessage) {
this.code = systemMessage.getCode();
this.message = systemMessage.getMsg();
}
public Integer getCode() {
return code;
}
public String getMessage() {
return message;
}
}
package cn.com.glsx.process.exception;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import com.glsx.plat.exception.SystemMessage;
import lombok.Getter;
import lombok.Setter;
/**
* @author payu
*/
@Setter
@Getter
public class AdminException extends RuntimeException {
private int errorCode;
private String message;
public AdminException() {
}
public AdminException(String message) {
super(message);
this.errorCode = SystemMessage.FAILURE.getCode();
this.message = message;
}
public AdminException(int errorCode, String message) {
super(message);
this.errorCode = errorCode;
this.message = message;
}
public AdminException(ResultEnum resultEnum) {
this.errorCode = resultEnum.getCode();
this.message = resultEnum.getMessage();
}
public AdminException(Throwable cause) {
super(cause);
}
public AdminException(String message, Throwable cause) {
super(message, cause);
}
}
package cn.com.glsx.process.exception;
import com.alibaba.excel.exception.ExcelDataConvertException;
import com.glsx.plat.core.web.R;
import com.glsx.plat.exception.ExceptionLevel;
import com.glsx.plat.exception.GlobalRExceptionHandler;
import lombok.extern.slf4j.Slf4j;
import org.apache.ibatis.binding.BindingException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
/**
* 全局异常处理
*
* @author payu
*/
@Slf4j
@RestControllerAdvice
public class AdminExceptionHandler extends GlobalRExceptionHandler {
@ExceptionHandler(AdminException.class)
public R handleAdminException(AdminException e) {
return R.error(e.getErrorCode(),e.getMessage());
}
/**
* Mybatis BindingException
*
* @param e
* @return
*/
@ExceptionHandler(BindingException.class)
public R handleBindingException(BindingException e) {
return R.error(e.getMessage());
}
@ExceptionHandler(ExcelDataConvertException.class)
public R handleExcelDataConvertException(ExcelDataConvertException e) {
return R.error(e.getMessage());
}
@Override
protected void saveException(Exception e, ExceptionLevel level) {
super.saveException(e, level);
}
}
...@@ -218,7 +218,18 @@ public class SopXxlJobUtil { ...@@ -218,7 +218,18 @@ public class SopXxlJobUtil {
} }
// 隐藏任务执行: // 隐藏任务执行:
String jobBusId = jobBusId(sop.getInst(), node); String jobBusId = jobBusId(sop.getInst(), node);
XxlJobUtil.trigger(jobBusId);
// 前置节点,后置节点
Pair<Set<Integer>, Set<Integer>> linkPair = sop.getInstLinkMap().get(node.getNodeId());
SopInstNodeParam params = new SopInstNodeParam();
params.setInstId(node.getInstId());
params.setNodeId(node.getNodeId());
params.setPreIds(linkPair.getKey());
params.setNextIds(linkPair.getValue());
String paramJson = JSONUtil.toJsonStr(params);
XxlJobUtil.trigger(jobBusId, paramJson);
log.info("【{}】手动触发隐藏任务:{} - {}", jobBusId, node.getNodeName(), node.getNodeCron()); log.info("【{}】手动触发隐藏任务:{} - {}", jobBusId, node.getNodeName(), node.getNodeCron());
list.add(node.getNodeName()); list.add(node.getNodeName());
} }
......
...@@ -142,10 +142,10 @@ public class XxlJobUtil { ...@@ -142,10 +142,10 @@ public class XxlJobUtil {
* @param buskey 业务key * @param buskey 业务key
* @return {@link String} * @return {@link String}
**/ **/
public static String trigger(String buskey) { public static String trigger(String buskey, String params) {
XxlJobInfo byBusKey = findByBusKey(buskey); XxlJobInfo byBusKey = findByBusKey(buskey);
if (byBusKey != null) { if (byBusKey != null) {
return doPost(adminAddresses + ADD_AND_START_URL + "?id=" + byBusKey.getId(), null, String.class); return doPost(adminAddresses + ADD_AND_START_URL + "?id=" + byBusKey.getId(), params, String.class);
} }
return null; return null;
} }
......
...@@ -26,7 +26,6 @@ import cn.com.glsx.process.modules.sop.execute.SopNodeType; ...@@ -26,7 +26,6 @@ import cn.com.glsx.process.modules.sop.execute.SopNodeType;
import cn.com.glsx.process.util.JacksonUtils; import cn.com.glsx.process.util.JacksonUtils;
import cn.hutool.core.lang.Pair; import cn.hutool.core.lang.Pair;
import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.ObjectUtil;
import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
@Slf4j @Slf4j
...@@ -38,10 +37,14 @@ public class SopInstNodeExecuteJobHandler { ...@@ -38,10 +37,14 @@ public class SopInstNodeExecuteJobHandler {
@XxlJob(SopXxlJobUtil.SOP_NODE_EXECUTE_JOB_ID) @XxlJob(SopXxlJobUtil.SOP_NODE_EXECUTE_JOB_ID)
public void handler(String param1) throws Exception { public void handler(String param1) throws Exception {
String json = XxlJobHelper.getJobParam(); String json = ObjectUtil.defaultIfNull(XxlJobHelper.getJobParam(), param1);
SopInstNodeParam param = JSONUtil.toBean(json, SopInstNodeParam.class); SopInstNodeParam param = JacksonUtils.fromJson(json, SopInstNodeParam.class);
SopXxlJobUtil.log(log, "【执行Sop节点】{}", param); SopXxlJobUtil.log(log, "【执行Sop节点】{}", param);
if (param == null) {
SopXxlJobUtil.log(log, "【执行Sop节点】任务启动参数为空!!!");
return;
}
SopStruct sop = sopService.loadSop(param.getInstId()); SopStruct sop = sopService.loadSop(param.getInstId());
......
package cn.com.glsx.process.modules.controller; package cn.com.glsx.process.modules.controller;
import java.util.Map; import java.util.Map;
import java.util.Objects;
import javax.annotation.Resource; import javax.annotation.Resource;
...@@ -76,10 +77,14 @@ public class SopInstController extends BaseController { ...@@ -76,10 +77,14 @@ public class SopInstController extends BaseController {
return sopInstService.customerDetail(search); return sopInstService.customerDetail(search);
} }
@Operation(summary = "根据id查询SOP门店模板实例详情", description = "根据id查询SOP门店模板实例详情") @Operation(summary = "根据id查询SOP门店模板实例详情(无快照信息)", description = "根据id查询SOP门店模板实例详情(无快照信息)")
@GetMapping("/{instId}") @GetMapping("/{instId}")
public SopInstDTO findById(@PathVariable("instId") String instId) { public SopInstDTO findById(@PathVariable("instId") String instId) {
return sopInstService.findById(instId); SopInstDTO instDTO = sopInstService.findById(instId);
if (Objects.nonNull(instDTO)) {
instDTO.setInstSnapshot(null);
}
return instDTO;
} }
@Operation(summary = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)", description = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)") @Operation(summary = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)", description = "更新SOP门店模板实例初始参数里的门店自定义参数(关联活动)")
......
...@@ -10,8 +10,11 @@ import org.springframework.web.bind.annotation.RestController; ...@@ -10,8 +10,11 @@ import org.springframework.web.bind.annotation.RestController;
import com.glsx.plat.core.annotation.ResponseResultBody; import com.glsx.plat.core.annotation.ResponseResultBody;
import com.glsx.plat.core.web.R; import com.glsx.plat.core.web.R;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import cn.com.glsx.process.job.xxljob.core.XxlJobInfo; import cn.com.glsx.process.job.xxljob.core.XxlJobInfo;
import cn.com.glsx.process.job.xxljob.core.XxlJobUtil; import cn.com.glsx.process.job.xxljob.core.XxlJobUtil;
import cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler;
import cn.com.glsx.process.modules.service.UserDemoService; import cn.com.glsx.process.modules.service.UserDemoService;
import io.swagger.v3.oas.annotations.Operation; import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag; import io.swagger.v3.oas.annotations.tags.Tag;
...@@ -26,6 +29,8 @@ public class TestXXLJobController { ...@@ -26,6 +29,8 @@ public class TestXXLJobController {
@Autowired @Autowired
private UserDemoService userDemoService; private UserDemoService userDemoService;
@Autowired
private SopInstNodeExecuteJobHandler nodeExecutor;
@GetMapping("/jobtest") @GetMapping("/jobtest")
@Operation(summary = "动态任务添加", description = "动态任务添加") @Operation(summary = "动态任务添加", description = "动态任务添加")
...@@ -44,8 +49,7 @@ public class TestXXLJobController { ...@@ -44,8 +49,7 @@ public class TestXXLJobController {
@PostMapping("/jobtestupdate") @PostMapping("/jobtestupdate")
@Operation(summary = "动态任务更新", description = "动态任务更新") @Operation(summary = "动态任务更新", description = "动态任务更新")
public void updatetest(@RequestParam(value = "cron", required = false) String cron, public void updatetest(@RequestParam(value = "cron", required = false) String cron, @RequestParam("id") String id,
@RequestParam("id") String id,
@RequestParam(value = "executorParam", required = false) String executorParam, @RequestParam(value = "executorParam", required = false) String executorParam,
@RequestParam(value = "jobDesc", required = false) String jobDesc, @RequestParam(value = "jobDesc", required = false) String jobDesc,
@RequestParam(value = "triggerStatus", required = false) Integer triggerStatus) { @RequestParam(value = "triggerStatus", required = false) Integer triggerStatus) {
...@@ -79,7 +83,7 @@ public class TestXXLJobController { ...@@ -79,7 +83,7 @@ public class TestXXLJobController {
@PostMapping("/trigger") @PostMapping("/trigger")
@Operation(summary = "动态任务触发", description = "动态任务触发") @Operation(summary = "动态任务触发", description = "动态任务触发")
public void trigger(@RequestParam("id") String id) { public void trigger(@RequestParam("id") String id) {
XxlJobUtil.trigger(id); XxlJobUtil.trigger(id, null);
} }
@PostMapping("/findBybusKey") @PostMapping("/findBybusKey")
...@@ -91,6 +95,16 @@ public class TestXXLJobController { ...@@ -91,6 +95,16 @@ public class TestXXLJobController {
@PostMapping("/testJava") @PostMapping("/testJava")
@Operation(summary = "测试java", description = "动态任务触发") @Operation(summary = "测试java", description = "动态任务触发")
public R testJava(@RequestParam("busKey") String busKey) throws Exception { public R testJava(@RequestParam("busKey") String busKey) throws Exception {
if (true) {
throw new AdminException(ResultEnum.PARAM_ERROR);
}
return R.ok().data(userDemoService.testJava(busKey)); return R.ok().data(userDemoService.testJava(busKey));
} }
@PostMapping("/testExecutor")
@Operation(summary = "测试Executor", description = "动态任务触发")
public R testNodeExecutor(@RequestParam("json") String json) throws Exception {
nodeExecutor.handler(json);
return R.ok();
}
} }
...@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelIgnore; ...@@ -5,6 +5,7 @@ import com.alibaba.excel.annotation.ExcelIgnore;
import com.alibaba.excel.annotation.ExcelProperty; import com.alibaba.excel.annotation.ExcelProperty;
import java.util.Date; import java.util.Date;
import java.util.Objects;
/** /**
* *
...@@ -75,6 +76,10 @@ public class SopCustomerExcelDTO { ...@@ -75,6 +76,10 @@ public class SopCustomerExcelDTO {
} }
public int getSopJourneyDays() { public int getSopJourneyDays() {
if (Objects.isNull(sopJourneyEnterTime)) {
return 0;
}
Date now = new Date(); Date now = new Date();
long nowTime = now.getTime(); long nowTime = now.getTime();
long enterTime = sopJourneyEnterTime.getTime(); long enterTime = sopJourneyEnterTime.getTime();
...@@ -103,7 +108,10 @@ public class SopCustomerExcelDTO { ...@@ -103,7 +108,10 @@ public class SopCustomerExcelDTO {
} }
public int getSopJourneyStageDays() { public int getSopJourneyStageDays() {
// TODO 注意空指针 if (Objects.isNull(sopJourneyStageEnterTime)) {
return 0;
}
Date now = new Date(); Date now = new Date();
long nowTime = now.getTime(); long nowTime = now.getTime();
long enterTime = sopJourneyStageEnterTime.getTime(); long enterTime = sopJourneyStageEnterTime.getTime();
......
...@@ -10,10 +10,6 @@ import org.springframework.context.annotation.Configuration; ...@@ -10,10 +10,6 @@ import org.springframework.context.annotation.Configuration;
@Configuration @Configuration
public class RabbitConfig { public class RabbitConfig {
public static final String DATA_REPORT_QUEUE_NAME = "dataReport_queue";
public static final String DATA_REPORT_EXCHANGE_NAME = "dataReport_exchange";
public static final String DATA_REPORT_TOPIC = "dataReport.#";
//声明topic交换机 //声明topic交换机
@Bean @Bean
public TopicExchange topicExchange() { public TopicExchange topicExchange() {
...@@ -23,18 +19,18 @@ public class RabbitConfig { ...@@ -23,18 +19,18 @@ public class RabbitConfig {
@Bean(name = "dataReportQueue") @Bean(name = "dataReportQueue")
public Queue dataReportQueue() { public Queue dataReportQueue() {
return new Queue(DATA_REPORT_QUEUE_NAME, true); return new Queue(RabbitMQConstants.DATA_REPORT_QUEUE_NAME, true);
} }
@Bean(name = "dataReportTopicExchange") @Bean(name = "dataReportTopicExchange")
public TopicExchange dataReportTopicExchange() { public TopicExchange dataReportTopicExchange() {
return new TopicExchange(DATA_REPORT_EXCHANGE_NAME); return new TopicExchange(RabbitMQConstants.DATA_REPORT_EXCHANGE_NAME);
} }
@Bean @Bean
public Binding bindingDataReport(@Qualifier("dataReportQueue") Queue dataReportQueue, public Binding bindingDataReport(@Qualifier("dataReportQueue") Queue dataReportQueue,
@Qualifier("dataReportTopicExchange") TopicExchange dataReportTopicExchange) { @Qualifier("dataReportTopicExchange") TopicExchange dataReportTopicExchange) {
return BindingBuilder.bind(dataReportQueue).to(dataReportTopicExchange).with(DATA_REPORT_TOPIC); return BindingBuilder.bind(dataReportQueue).to(dataReportTopicExchange).with(RabbitMQConstants.DATA_REPORT_TOPIC);
} }
......
...@@ -4,4 +4,10 @@ public interface RabbitMQConstants { ...@@ -4,4 +4,10 @@ public interface RabbitMQConstants {
String TOPIC_EXCHANGE_PLATFORM_PROCESS = "sop.platform-process"; String TOPIC_EXCHANGE_PLATFORM_PROCESS = "sop.platform-process";
String ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE = "sop_inst.inst_param.custom_data.update"; String ROUTING_KEY_SOP_INST_INST_PARAM_CUSTOM_DATA_UPDATE = "sop_inst.inst_param.custom_data.update";
//上报给cdp的相关信息常量(cdp那边固定)
String DATA_REPORT_QUEUE_NAME = "dataReport_queue";
String DATA_REPORT_EXCHANGE_NAME = "dataReport_exchange";
String DATA_REPORT_TOPIC = "dataReport.#";
String DATA_REPORT_ROUTING_KEY = "dataReport.customer.event";
} }
...@@ -29,6 +29,13 @@ public class JavaExecutor implements SopNodeExecutor { ...@@ -29,6 +29,13 @@ public class JavaExecutor implements SopNodeExecutor {
JSONObject paramMap = JSON.parseObject(nodeContent); JSONObject paramMap = JSON.parseObject(nodeContent);
String javacode = paramMap.get("source") + ""; String javacode = paramMap.get("source") + "";
// if (StringUtils.isNotEmpty(javacode)) {
// javacode = javacode
// .replace("console.info(", "console.info(\"" + mcgWebScoketCode + "\", \"" + httpSessionId + "\", \"" + flowId + "\", ")
// .replace("console.success(", "console.success(\"" + mcgWebScoketCode + "\", \"" + httpSessionId + "\", \"" + flowId + "\", ")
// .replace("console.error(", "console.error(\"" + mcgWebScoketCode + "\", \"" + httpSessionId + "\", \"" + flowId + "\", ");
// }
// java参数处理,执行java // java参数处理,执行java
DynamicEngine de = DynamicEngine.getInstance(); DynamicEngine de = DynamicEngine.getInstance();
...@@ -48,6 +55,7 @@ public class JavaExecutor implements SopNodeExecutor { ...@@ -48,6 +55,7 @@ public class JavaExecutor implements SopNodeExecutor {
return instance; return instance;
} catch (Exception e) { } catch (Exception e) {
SopXxlJobUtil.log(log, "【{}】{}", getClass().getSimpleName(), e.getMessage(), e); SopXxlJobUtil.log(log, "【{}】{}", getClass().getSimpleName(), e.getMessage(), e);
e.printStackTrace();
} }
return null; return null;
......
...@@ -24,6 +24,7 @@ import java.util.Map; ...@@ -24,6 +24,7 @@ import java.util.Map;
import javax.sql.DataSource; import javax.sql.DataSource;
import org.apache.commons.dbutils.DbUtils; import org.apache.commons.dbutils.DbUtils;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
...@@ -124,8 +125,10 @@ public abstract class AbstractConnect { ...@@ -124,8 +125,10 @@ public abstract class AbstractConnect {
int total=0; int total=0;
String[] split = sql.split(";"); String[] split = sql.split(";");
for (String s : split) { for (String s : split) {
if(StringUtils.isNotEmpty(s)) {
int i = dbConnect.executeUpdate(s, para); int i = dbConnect.executeUpdate(s, para);
total=total+i; total = total + i;
}
} }
return total; return total;
} }
......
...@@ -51,6 +51,7 @@ public class ControllerDisTasksDemo { ...@@ -51,6 +51,7 @@ public class ControllerDisTasksDemo {
multiValueMap.add("requestList[0].stageName", SopHelper.getValueFromJsonString(nodeParam, "stage")); multiValueMap.add("requestList[0].stageName", SopHelper.getValueFromJsonString(nodeParam, "stage"));
multiValueMap.add("requestList[0].sopId", sopInst.getInstId()); multiValueMap.add("requestList[0].sopId", sopInst.getInstId());
multiValueMap.add("requestList[0].enterJourneyDays",SopHelper.getValueFromJsonString(nodeParam, "day"));
multiValueMap.add("requestList[0].taskType", SopHelper.getValueFromJsonString(nodeParam, "taskType")); multiValueMap.add("requestList[0].taskType", SopHelper.getValueFromJsonString(nodeParam, "taskType"));
......
...@@ -53,7 +53,7 @@ public class ControllerFoundInsDemo { ...@@ -53,7 +53,7 @@ public class ControllerFoundInsDemo {
CustomerInfo customerInfo = new CustomerInfo(); CustomerInfo customerInfo = new CustomerInfo();
customerInfo.setVin(key); customerInfo.setVin(key);
if(stringObjectMap.get(key)!=null) { if(stringObjectMap.get(key)!=null) {
customerInfo.setArrivalDate(DateFormatUtils.formatUTC(Long.parseLong(s), "yyyy-mm-dd mm:ss")); customerInfo.setArrivalDate(DateFormatUtils.format(Long.parseLong(s), "yyyy-MM-dd HH:mm:ss"));
} }
result.add(customerInfo); result.add(customerInfo);
} }
...@@ -65,4 +65,5 @@ public class ControllerFoundInsDemo { ...@@ -65,4 +65,5 @@ public class ControllerFoundInsDemo {
return JSONArray.parseArray(JSONObject.toJSONString(result)); return JSONArray.parseArray(JSONObject.toJSONString(result));
} }
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.process.modules.sop.java.example;
import com.alibaba.fastjson.JSONObject;
import java.io.*;
import java.util.HashMap;
import java.util.Map;
/**
* java文件转化为可执行的节点内容
*
*/
public class JavaFileToString {
public static void main(String[] args) {
StringBuilder javaCodeBuilder = new StringBuilder();
try (BufferedReader reader = new BufferedReader(new FileReader("F:\\360MoveData\\Users\\11\\Desktop\\企微SAAS\\2023\\09\\sop\\platform-process-server\\platform-process\\src\\main\\java\\cn\\com\\glsx\\process\\modules\\sop\\java\\example\\ControllerHttpDemo.java"))) {
String line;
while (true) {
try {
if (!((line = reader.readLine()) != null)) break;
} catch (IOException e) {
throw new RuntimeException(e);
}
javaCodeBuilder.append(line).append(System.lineSeparator());
}
} catch (FileNotFoundException e) {
throw new RuntimeException(e);
} catch (IOException e) {
throw new RuntimeException(e);
}
String javaCode = javaCodeBuilder.toString();
Map<String,String> stringMap=new HashMap<>();
stringMap.put("source",javaCode);
// 读取Java文件内容
System.out.println("转化后结果"+ JSONObject.toJSONString(stringMap));
}
}
package cn.com.glsx.process.util; package cn.com.glsx.process.util;
import cn.com.glsx.process.common.sysenum.ResultEnum;
import cn.com.glsx.process.exception.AdminException;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.glsx.plat.exception.ResultException; import com.fasterxml.jackson.databind.node.ObjectNode;
import com.glsx.plat.exception.SystemMessage;
import lombok.experimental.UtilityClass; import lombok.experimental.UtilityClass;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.util.HashMap; import java.util.LinkedHashMap;
import java.util.Map;
@UtilityClass @UtilityClass
public class SopTplParamHandler { public class SopTplParamHandler {
...@@ -24,7 +25,7 @@ public class SopTplParamHandler { ...@@ -24,7 +25,7 @@ public class SopTplParamHandler {
JsonNode rootNode = objectMapper.readTree(tplParam); JsonNode rootNode = objectMapper.readTree(tplParam);
return processNode(rootNode); return processNode(rootNode);
} catch (Exception e) { } catch (Exception e) {
throw ResultException.create(SystemMessage.DATA_HANDLE_ERROR.getCode(), "参数转json对象异常"); throw new AdminException(ResultEnum.DATA_HANDLE_ERROR.getCode(), "参数转json对象异常");
} }
} }
...@@ -33,13 +34,18 @@ public class SopTplParamHandler { ...@@ -33,13 +34,18 @@ public class SopTplParamHandler {
return null; return null;
} }
HashMap map = JSON.parseObject(paramJson, HashMap.class); try {
map.put("merchantId", merchantId); JsonNode jsonNode = objectMapper.readTree(paramJson);
return JSON.toJSONString(map); ObjectNode objectNode = (ObjectNode) jsonNode;
objectNode.put("merchantId", merchantId);
return objectNode.toString();
} catch (JsonProcessingException e) {
throw new AdminException(ResultEnum.DATA_HANDLE_ERROR.getCode(), "参数转json对象异常");
}
} }
private String processNode(JsonNode node) { private String processNode(JsonNode node) {
Map<String, Object> map = new HashMap<>(); LinkedHashMap<String, Object> map = new LinkedHashMap<>();
for (JsonNode childNode : node) { for (JsonNode childNode : node) {
String key = childNode.path("paramKey").asText(); String key = childNode.path("paramKey").asText();
...@@ -57,7 +63,7 @@ public class SopTplParamHandler { ...@@ -57,7 +63,7 @@ public class SopTplParamHandler {
break; break;
case "Map": case "Map":
// 解析Map类型的默认值 // 解析Map类型的默认值
Map<String, Object> defaultValueMap = objectMapper.convertValue(defaultValueNode, HashMap.class); LinkedHashMap<String, Object> defaultValueMap = objectMapper.convertValue(defaultValueNode, LinkedHashMap.class);
map.put(key, defaultValueMap); map.put(key, defaultValueMap);
break; break;
// 其他数据类型的解析 // 其他数据类型的解析
......
...@@ -9,7 +9,7 @@ logging.path=/data/java_log/jetty/${spring.application.name}/${spring.applicatio ...@@ -9,7 +9,7 @@ logging.path=/data/java_log/jetty/${spring.application.name}/${spring.applicatio
#spring.cloud.nacos.discovery.enabled=false #spring.cloud.nacos.discovery.enabled=false
#spring.cloud.nacos.discovery.instance-enabled=false #spring.cloud.nacos.discovery.instance-enabled=false
spring.cloud.nacos.config.server-addr=192.168.0.63:8868 spring.cloud.nacos.config.server-addr=192.168.3.239:8868
spring.cloud.nacos.config.group=platform spring.cloud.nacos.config.group=platform
spring.cloud.nacos.config.prefix=${spring.application.name} spring.cloud.nacos.config.prefix=${spring.application.name}
......
...@@ -56,7 +56,7 @@ ...@@ -56,7 +56,7 @@
ORDER BY si.inst_status DESC, si.create_time DESC ORDER BY si.inst_status DESC, si.create_time DESC
</select> </select>
<select id="selectByCustomData" resultType="cn.com.glsx.process.modules.entity.SopInst"> <select id="selectByCustomData" resultMap="BaseResultMap">
SELECT SELECT
<include refid="Base_Column_List"/> <include refid="Base_Column_List"/>
FROM sop_inst FROM sop_inst
......
package cn.com.glsx;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler;
import cn.com.glsx.process.modules.service.SopService;
import lombok.extern.slf4j.Slf4j;
@SpringBootTest(classes = Application.class)
@Slf4j
public class AppDemo2 {
@Autowired
private SopService sopService;
@Autowired
private SopInstNodeExecuteJobHandler job;
@Test
public void test() {
// String instId = "xblc174";
// SopStruct sop = sopService.loadSop(instId);
// System.out.println(JSONUtil.toJsonStr(sop));
}
@Test
public void testNode() {
try {
String json = "{\"preIds\":[2],\"finishedIds\":[2],\"instId\":\"xblc174\",\"nextIds\":[9],\"nodeId\":12}";
job.handler(json);
} catch (Exception e) {
e.printStackTrace();
}
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.test.service; package cn.com.glsx.test.service;
import lombok.extern.slf4j.Slf4j; import org.junit.jupiter.api.Test;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest; import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import cn.com.glsx.Application; import cn.com.glsx.Application;
import cn.com.glsx.process.job.xxljob.impl.SopInstNodeExecuteJobHandler;
import cn.com.glsx.process.modules.model.SopStruct; import cn.com.glsx.process.modules.model.SopStruct;
import cn.com.glsx.process.modules.service.SopService; import cn.com.glsx.process.modules.service.SopService;
import cn.hutool.json.JSONUtil; import cn.hutool.json.JSONUtil;
import lombok.extern.slf4j.Slf4j;
/** /**
* 测试spring cloud 服务调用方式 * 测试spring cloud 服务调用方式
*/ */
@RunWith(SpringJUnit4ClassRunner.class)
@SpringBootTest(classes = Application.class) @SpringBootTest(classes = Application.class)
@Slf4j @Slf4j
public class TestSopService { public class TestSopService {
...@@ -23,6 +21,9 @@ public class TestSopService { ...@@ -23,6 +21,9 @@ public class TestSopService {
@Autowired @Autowired
private SopService sopService; private SopService sopService;
@Autowired
private SopInstNodeExecuteJobHandler job;
@Test @Test
public void test() { public void test() {
String instId = "xblc7"; String instId = "xblc7";
...@@ -30,5 +31,16 @@ public class TestSopService { ...@@ -30,5 +31,16 @@ public class TestSopService {
System.out.println(JSONUtil.toJsonStr(sop)); System.out.println(JSONUtil.toJsonStr(sop));
} }
@Test
public void testNode() {
try {
String json = "{\"preIds\":[2],\"finishedIds\":[2],\"instId\":\"xblc172\",\"nextIds\":[9],\"nodeId\":12}";
job.handler(json);
} catch (Exception e) {
e.printStackTrace();
}
}
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!