From 62a12b37c1c76a6bae0be1bcafe0c6bf181dcac3 Mon Sep 17 00:00:00 2001 From: 75349 <753495441@qq.com> Date: Thu, 15 Dec 2022 09:53:40 +0800 Subject: [PATCH] =?UTF-8?q?1.=E5=A2=9E=E5=8A=A0=E7=BB=86=E8=8A=82=E5=A4=84?= =?UTF-8?q?=E7=90=86=202.=E5=88=A0=E9=99=A4=E6=97=A0=E6=95=88=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../mysql/controller/BaseChainController.java | 4 ++ .../mysql/controller/BaseNodeController.java | 10 +-- .../controller/BaseTemplateController.java | 11 ++- .../mysql/handler/MybatisHandler.java | 2 - .../mysql/model/baseChain/BaseChainVO.java | 28 ++++++++ .../model/baseTemplate/BaseTemplateVO.java | 37 ++++++++++ .../liteflow/mysql/model/node/BaseNodeVO.java | 71 +++++++++++++++++++ .../mysql/service/BaseChainService.java | 2 + .../mysql/service/BaseNodeService.java | 2 + .../mysql/service/BaseTemplateService.java | 2 + .../service/impl/BaseChainServiceImpl.java | 34 ++++++++- .../service/impl/BaseNodeServiceImpl.java | 23 +++++- .../service/impl/BaseTemplateServiceImpl.java | 11 +++ .../mysql/util/ConditionConstants.java | 6 -- 14 files changed, 223 insertions(+), 20 deletions(-) create mode 100644 src/main/java/com/example/liteflow/mysql/model/baseChain/BaseChainVO.java create mode 100644 src/main/java/com/example/liteflow/mysql/model/baseTemplate/BaseTemplateVO.java create mode 100644 src/main/java/com/example/liteflow/mysql/model/node/BaseNodeVO.java delete mode 100644 src/main/java/com/example/liteflow/mysql/util/ConditionConstants.java diff --git a/src/main/java/com/example/liteflow/mysql/controller/BaseChainController.java b/src/main/java/com/example/liteflow/mysql/controller/BaseChainController.java index 3b5d2cb..cb49cff 100644 --- a/src/main/java/com/example/liteflow/mysql/controller/BaseChainController.java +++ b/src/main/java/com/example/liteflow/mysql/controller/BaseChainController.java @@ -31,4 +31,8 @@ public class BaseChainController { return baseChainService.executeChain(chainName); } + @GetMapping("/getChainList") + public CommonResult getChainList() { + return baseChainService.getChainList(); + } } diff --git a/src/main/java/com/example/liteflow/mysql/controller/BaseNodeController.java b/src/main/java/com/example/liteflow/mysql/controller/BaseNodeController.java index c204da0..088ce91 100644 --- a/src/main/java/com/example/liteflow/mysql/controller/BaseNodeController.java +++ b/src/main/java/com/example/liteflow/mysql/controller/BaseNodeController.java @@ -4,10 +4,7 @@ import com.example.liteflow.mysql.model.CommonResult; import com.example.liteflow.mysql.model.node.CreateNodeFrom; import com.example.liteflow.mysql.service.BaseNodeService; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -28,4 +25,9 @@ public class BaseNodeController { return baseNodeService.createNode(createNodeFrom); } + + @GetMapping("/getNodeList") + public CommonResult getNodeList() { + return baseNodeService.getNodeList(); + } } diff --git a/src/main/java/com/example/liteflow/mysql/controller/BaseTemplateController.java b/src/main/java/com/example/liteflow/mysql/controller/BaseTemplateController.java index a92f280..283f220 100644 --- a/src/main/java/com/example/liteflow/mysql/controller/BaseTemplateController.java +++ b/src/main/java/com/example/liteflow/mysql/controller/BaseTemplateController.java @@ -2,14 +2,9 @@ package com.example.liteflow.mysql.controller; import com.example.liteflow.mysql.model.CommonResult; import com.example.liteflow.mysql.model.baseTemplate.CreateTemplateFrom; -import com.example.liteflow.mysql.model.node.CreateNodeFrom; -import com.example.liteflow.mysql.service.BaseNodeService; import com.example.liteflow.mysql.service.BaseTemplateService; import lombok.extern.slf4j.Slf4j; -import org.springframework.web.bind.annotation.PostMapping; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; +import org.springframework.web.bind.annotation.*; import javax.annotation.Resource; @@ -30,4 +25,8 @@ public class BaseTemplateController { return baseTemplateService.createTemplate(createTemplateFrom); } + @GetMapping("/getTemplateList") + public CommonResult getTemplateList() { + return baseTemplateService.getTemplateList(); + } } diff --git a/src/main/java/com/example/liteflow/mysql/handler/MybatisHandler.java b/src/main/java/com/example/liteflow/mysql/handler/MybatisHandler.java index 25092d7..577efef 100644 --- a/src/main/java/com/example/liteflow/mysql/handler/MybatisHandler.java +++ b/src/main/java/com/example/liteflow/mysql/handler/MybatisHandler.java @@ -16,14 +16,12 @@ import java.time.LocalDateTime; public class MybatisHandler implements MetaObjectHandler { @Override public void insertFill(MetaObject metaObject) { - log.info("start insert .. "); this.setFieldValByName("creatorTime", LocalDateTime.now(), metaObject); // this.setFieldValByName("lastModifyTime", LocalDateTime.now(), metaObject); } @Override public void updateFill(MetaObject metaObject) { - log.info("start update .. "); this.setFieldValByName("lastModifyTime", LocalDateTime.now(), metaObject); } } diff --git a/src/main/java/com/example/liteflow/mysql/model/baseChain/BaseChainVO.java b/src/main/java/com/example/liteflow/mysql/model/baseChain/BaseChainVO.java new file mode 100644 index 0000000..44b7711 --- /dev/null +++ b/src/main/java/com/example/liteflow/mysql/model/baseChain/BaseChainVO.java @@ -0,0 +1,28 @@ +package com.example.liteflow.mysql.model.baseChain; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author: 陈韦龙 + * @date: 2022年12月15日 09:12 + */ +@Data +public class BaseChainVO { + private String id; + + private String templateId; + + private String templateName; + + private String chainName; + + private String elData; + + private Integer enableMark = 1; + + private LocalDateTime creatorTime; + + private LocalDateTime lastModifyTime; +} diff --git a/src/main/java/com/example/liteflow/mysql/model/baseTemplate/BaseTemplateVO.java b/src/main/java/com/example/liteflow/mysql/model/baseTemplate/BaseTemplateVO.java new file mode 100644 index 0000000..d8e0924 --- /dev/null +++ b/src/main/java/com/example/liteflow/mysql/model/baseTemplate/BaseTemplateVO.java @@ -0,0 +1,37 @@ +package com.example.liteflow.mysql.model.baseTemplate; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author: 陈韦龙 + * @date: 2022年12月15日 09:28 + */ +@Data +public class BaseTemplateVO { + /** + * 主键 + */ + private String id; + + /** + * 模板名称 + */ + private String templateName; + + /** + * 有效状态:1-有效;0无效 + */ + private Integer enableMark = 1; + + /** + * 创建时间 + */ + private LocalDateTime creatorTime; + + /** + * 修改时间 + */ + private LocalDateTime lastModifyTime; +} diff --git a/src/main/java/com/example/liteflow/mysql/model/node/BaseNodeVO.java b/src/main/java/com/example/liteflow/mysql/model/node/BaseNodeVO.java new file mode 100644 index 0000000..b096eb1 --- /dev/null +++ b/src/main/java/com/example/liteflow/mysql/model/node/BaseNodeVO.java @@ -0,0 +1,71 @@ +package com.example.liteflow.mysql.model.node; + +import lombok.Data; + +import java.time.LocalDateTime; + +/** + * @author: 陈韦龙 + * @date: 2022年12月15日 09:23 + */ +@Data +public class BaseNodeVO { + /** + * 主键 + */ + private String id; + /** + * 节点在规则引擎中的Id + */ + private String nodeId; + /** + * 所属模板id + */ + private String templateId; + /** + * 所属模板名称 + */ + private String templateName; + /** + * 节点名称 + */ + private String nodeName; + + /** + * 节点对应类名 + */ + private String nodeClass; + + /** + * 节点类型 + */ + private String nodeType; + + /** + * 节点规则 + */ + private String nodeRole; + /** + * 节点对应输出节点id + */ + private String nodeContentId; + /** + * 节点内容 + */ + private String nodeContent; + + /** + * 有效状态:1-有效;0无效 + */ + private Integer enableMark = 1; + + /** + * 创建时间 + */ + private LocalDateTime creatorTime; + + /** + * 修改时间 + */ + private LocalDateTime lastModifyTime; +} diff --git a/src/main/java/com/example/liteflow/mysql/service/BaseChainService.java b/src/main/java/com/example/liteflow/mysql/service/BaseChainService.java index 04549a5..d06d42d 100644 --- a/src/main/java/com/example/liteflow/mysql/service/BaseChainService.java +++ b/src/main/java/com/example/liteflow/mysql/service/BaseChainService.java @@ -20,4 +20,6 @@ public interface BaseChainService extends IService { void initMainChain(); CommonResult executeChain(String chainName); + + CommonResult getChainList(); } diff --git a/src/main/java/com/example/liteflow/mysql/service/BaseNodeService.java b/src/main/java/com/example/liteflow/mysql/service/BaseNodeService.java index ea54aa3..8bd764d 100644 --- a/src/main/java/com/example/liteflow/mysql/service/BaseNodeService.java +++ b/src/main/java/com/example/liteflow/mysql/service/BaseNodeService.java @@ -18,4 +18,6 @@ public interface BaseNodeService extends IService { CommonResult updateNode(UpdateNodeFrom updateNodeFrom); BaseNodeEntity getByNodeId(String nodeId); + + CommonResult getNodeList(); } diff --git a/src/main/java/com/example/liteflow/mysql/service/BaseTemplateService.java b/src/main/java/com/example/liteflow/mysql/service/BaseTemplateService.java index 7bec0cc..46703f8 100644 --- a/src/main/java/com/example/liteflow/mysql/service/BaseTemplateService.java +++ b/src/main/java/com/example/liteflow/mysql/service/BaseTemplateService.java @@ -20,4 +20,6 @@ public interface BaseTemplateService extends IService { boolean updateTemplate(UpdateTemplateFrom updateTemplateFrom); List getNotExistsChain(); + + CommonResult getTemplateList(); } diff --git a/src/main/java/com/example/liteflow/mysql/service/impl/BaseChainServiceImpl.java b/src/main/java/com/example/liteflow/mysql/service/impl/BaseChainServiceImpl.java index e419113..b20943b 100644 --- a/src/main/java/com/example/liteflow/mysql/service/impl/BaseChainServiceImpl.java +++ b/src/main/java/com/example/liteflow/mysql/service/impl/BaseChainServiceImpl.java @@ -1,7 +1,9 @@ package com.example.liteflow.mysql.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.util.ObjectUtil; +import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; @@ -14,6 +16,7 @@ import com.example.liteflow.mysql.enums.NodeEnum; import com.example.liteflow.mysql.mapper.BaseChainMapper; import com.example.liteflow.mysql.model.BaseCenter; import com.example.liteflow.mysql.model.CommonResult; +import com.example.liteflow.mysql.model.baseChain.BaseChainVO; import com.example.liteflow.mysql.service.BaseChainService; import com.example.liteflow.mysql.service.BaseNodeService; import com.example.liteflow.mysql.service.BaseTemplateService; @@ -22,6 +25,7 @@ import com.yomahub.liteflow.builder.el.LiteFlowChainELBuilder; import com.yomahub.liteflow.core.FlowExecutor; import com.yomahub.liteflow.flow.FlowBus; import com.yomahub.liteflow.flow.LiteflowResponse; +import com.yomahub.liteflow.flow.element.Chain; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; @@ -138,6 +142,7 @@ public class BaseChainServiceImpl extends ServiceImpl nodeList = baseNodeService.list(nodeQueryWrapper); - templateAndNodeMap.put(template, nodeList); + if (CollUtil.isNotEmpty(nodeList)) { + templateAndNodeMap.put(template, nodeList); + } }); + log.info("templateAndNodeMap size = {}", templateAndNodeMap.size()); for (Map.Entry> entry : templateAndNodeMap.entrySet()) { BaseTemplateEntity templateEntity = entry.getKey(); String templateName = templateEntity.getTemplateName(); @@ -294,6 +302,10 @@ public class BaseChainServiceImpl extends ServiceImpl generateCostCenterTestData() { List list = new ArrayList<>(); BaseCenter costCenter = new BaseCenter(); + costCenter.setSectionClassification("测试无匹配项"); + list.add(costCenter); + + costCenter = new BaseCenter(); costCenter.setSectionClassification("成本科目"); costCenter.setBusinessType("货代"); costCenter.setSalesman("仓干配物流部(物流)"); @@ -323,6 +335,26 @@ public class BaseChainServiceImpl extends ServiceImpl chainNameList = FlowBus.getChainMap().values().stream() + .map(Chain::getChainId).collect(Collectors.toList()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(BaseChainEntity::getChainName, chainNameList); + List chainList = this.list(queryWrapper); + List baseChainVOList = chainList.stream().map(chain -> { + BaseChainVO baseChainVO = BeanUtil.toBean(chain, BaseChainVO.class); + String templateId = chain.getTemplateId(); + if (StrUtil.isNotBlank(templateId)) { + BaseTemplateEntity template = baseTemplateService.getById(templateId); + String templateName = template.getTemplateName(); + baseChainVO.setTemplateName(templateName); + } + return baseChainVO; + }).collect(Collectors.toList()); + return CommonResult.success(baseChainVOList); + } } diff --git a/src/main/java/com/example/liteflow/mysql/service/impl/BaseNodeServiceImpl.java b/src/main/java/com/example/liteflow/mysql/service/impl/BaseNodeServiceImpl.java index 530b2a4..f1d99ae 100644 --- a/src/main/java/com/example/liteflow/mysql/service/impl/BaseNodeServiceImpl.java +++ b/src/main/java/com/example/liteflow/mysql/service/impl/BaseNodeServiceImpl.java @@ -6,6 +6,7 @@ import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.liteflow.mysql.entity.BaseNodeEntity; @@ -14,17 +15,21 @@ import com.example.liteflow.mysql.enums.EnableMarkEnum; import com.example.liteflow.mysql.enums.NodeEnum; import com.example.liteflow.mysql.model.CommonResult; import com.example.liteflow.mysql.model.OutputFrom; +import com.example.liteflow.mysql.model.node.BaseNodeVO; import com.example.liteflow.mysql.model.node.CreateNodeFrom; import com.example.liteflow.mysql.model.node.UpdateNodeFrom; import com.example.liteflow.mysql.model.role.Role; import com.example.liteflow.mysql.service.BaseNodeService; import com.example.liteflow.mysql.mapper.BaseNodeMapper; import com.example.liteflow.mysql.service.BaseTemplateService; +import com.yomahub.liteflow.flow.FlowBus; +import com.yomahub.liteflow.flow.element.Node; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Service; import javax.annotation.Resource; import java.util.List; +import java.util.stream.Collectors; /** * @author 75349 @@ -64,7 +69,7 @@ public class BaseNodeServiceImpl extends ServiceImpl nodeIdList = FlowBus.getNodeMap().values().stream().map(Node::getId).collect(Collectors.toList()); + LambdaQueryWrapper queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(BaseNodeEntity::getNodeId, nodeIdList); + List nodeList = this.list(queryWrapper); + List baseNodeVOList = nodeList.stream().map(node -> { + BaseNodeVO baseNodeVO = BeanUtil.toBean(node, BaseNodeVO.class); + String templateId = node.getTemplateId(); + BaseTemplateEntity template = baseTemplateService.getById(templateId); + String templateName = template.getTemplateName(); + baseNodeVO.setTemplateName(templateName); + return baseNodeVO; + }).collect(Collectors.toList()); + return CommonResult.success(baseNodeVOList); + } } diff --git a/src/main/java/com/example/liteflow/mysql/service/impl/BaseTemplateServiceImpl.java b/src/main/java/com/example/liteflow/mysql/service/impl/BaseTemplateServiceImpl.java index dda39da..55e4a17 100644 --- a/src/main/java/com/example/liteflow/mysql/service/impl/BaseTemplateServiceImpl.java +++ b/src/main/java/com/example/liteflow/mysql/service/impl/BaseTemplateServiceImpl.java @@ -1,10 +1,12 @@ package com.example.liteflow.mysql.service.impl; +import cn.hutool.core.bean.BeanUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.example.liteflow.mysql.entity.BaseTemplateEntity; import com.example.liteflow.mysql.model.CommonResult; +import com.example.liteflow.mysql.model.baseTemplate.BaseTemplateVO; import com.example.liteflow.mysql.model.baseTemplate.CreateTemplateFrom; import com.example.liteflow.mysql.model.baseTemplate.UpdateTemplateFrom; import com.example.liteflow.mysql.service.BaseTemplateService; @@ -14,6 +16,7 @@ import org.springframework.stereotype.Service; import javax.smartcardio.CommandAPDU; import java.util.List; +import java.util.stream.Collectors; /** * @author 75349 @@ -51,6 +54,14 @@ public class BaseTemplateServiceImpl extends ServiceImpl getNotExistsChain() { return this.baseMapper.getNotExistsChain(); } + + @Override + public CommonResult getTemplateList() { + List templateList = this.list(); + List baseTemplateVOS = templateList.stream() + .map(template -> BeanUtil.toBean(template, BaseTemplateVO.class)).collect(Collectors.toList()); + return CommonResult.success(baseTemplateVOS); + } } diff --git a/src/main/java/com/example/liteflow/mysql/util/ConditionConstants.java b/src/main/java/com/example/liteflow/mysql/util/ConditionConstants.java deleted file mode 100644 index 1b21b6e..0000000 --- a/src/main/java/com/example/liteflow/mysql/util/ConditionConstants.java +++ /dev/null @@ -1,6 +0,0 @@ -package com.example.liteflow.mysql.util; - -public interface ConditionConstants { - - -}