From 441e5e078b79d42a577d64b35dec6aea35563acb Mon Sep 17 00:00:00 2001 From: jinqiming <45981669@qq.com> Date: Wed, 2 Dec 2020 18:17:28 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E5=BA=8F=E5=88=97=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../flowable/ActDeModelController.java | 146 ++++++++++++++++++ .../flowable/FlowModelerController.java | 8 +- .../main/resources/static/ruoyi/js/ry-ui.js | 49 ++++++ .../resources/templates/flow/deployment.html | 26 ++-- .../main/resources/templates/flow/model.html | 15 +- .../resources/templates/system/model/add.html | 126 +++++++++++++++ .../templates/system/model/edit.html | 127 +++++++++++++++ .../templates/system/model/model.html | 127 +++++++++++++++ .../com/snow/common/enums/BusinessType.java | 4 + .../flowable/domain/DeploymentQueryDTO.java | 10 +- .../snow/flowable/domain/DeploymentVO.java | 36 +++-- .../service/FlowablePublishService.java | 7 + .../flowable/service/FlowableService.java | 4 +- .../impl/FlowablePublishServiceImpl.java | 32 +++- .../service/impl/FlowableServiceImpl.java | 66 ++++---- .../com/snow/system/domain/ActDeModel.java | 101 ++++++++++++ .../snow/system/mapper/ActDeModelMapper.java | 61 ++++++++ .../system/service/IActDeModelService.java | 64 ++++++++ .../service/impl/ActDeModelServiceImpl.java | 108 +++++++++++++ .../mapper/system/ActDeModelMapper.xml | 118 ++++++++++++++ 20 files changed, 1148 insertions(+), 87 deletions(-) create mode 100644 snow-admin/src/main/java/com/snow/web/controller/flowable/ActDeModelController.java create mode 100644 snow-admin/src/main/resources/templates/system/model/add.html create mode 100644 snow-admin/src/main/resources/templates/system/model/edit.html create mode 100644 snow-admin/src/main/resources/templates/system/model/model.html create mode 100644 snow-system/src/main/java/com/snow/system/domain/ActDeModel.java create mode 100644 snow-system/src/main/java/com/snow/system/mapper/ActDeModelMapper.java create mode 100644 snow-system/src/main/java/com/snow/system/service/IActDeModelService.java create mode 100644 snow-system/src/main/java/com/snow/system/service/impl/ActDeModelServiceImpl.java create mode 100644 snow-system/src/main/resources/mapper/system/ActDeModelMapper.xml diff --git a/snow-admin/src/main/java/com/snow/web/controller/flowable/ActDeModelController.java b/snow-admin/src/main/java/com/snow/web/controller/flowable/ActDeModelController.java new file mode 100644 index 0000000..e8973e7 --- /dev/null +++ b/snow-admin/src/main/java/com/snow/web/controller/flowable/ActDeModelController.java @@ -0,0 +1,146 @@ +package com.snow.web.controller.flowable; + +import java.util.List; + +import com.snow.flowable.service.impl.FlowablePublishServiceImpl; +import org.apache.shiro.authz.annotation.RequiresPermissions; +import org.flowable.engine.repository.Deployment; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.ui.ModelMap; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.ResponseBody; +import com.snow.common.annotation.Log; +import com.snow.common.enums.BusinessType; +import org.springframework.stereotype.Controller; +import com.snow.system.domain.ActDeModel; +import com.snow.system.service.IActDeModelService; +import com.snow.common.core.controller.BaseController; +import com.snow.common.core.domain.AjaxResult; +import com.snow.common.utils.poi.ExcelUtil; +import com.snow.common.core.page.TableDataInfo; + +/** + * 设计器modelController + * + * @author qimingjin + * @date 2020-12-01 + */ +@Controller +@RequestMapping("/system/model") +public class ActDeModelController extends BaseController +{ + private String prefix = "system/model"; + + @Autowired + private IActDeModelService actDeModelService; + + @Autowired + private FlowablePublishServiceImpl flowablePublishServiceImpl; + + @RequiresPermissions("system:model:view") + @GetMapping() + public String model() + { + return prefix + "/model"; + } + + /** + * 查询设计器model列表 + */ + @RequiresPermissions("system:model:list") + @PostMapping("/list") + @ResponseBody + public TableDataInfo list(ActDeModel actDeModel) + { + startPage(); + List list = actDeModelService.selectActDeModelList(actDeModel); + return getDataTable(list); + } + + /** + * 导出设计器model列表 + */ + @RequiresPermissions("system:model:export") + @Log(title = "设计器model", businessType = BusinessType.EXPORT) + @PostMapping("/export") + @ResponseBody + public AjaxResult export(ActDeModel actDeModel) + { + List list = actDeModelService.selectActDeModelList(actDeModel); + ExcelUtil util = new ExcelUtil(ActDeModel.class); + return util.exportExcel(list, "model"); + } + + /** + * 新增设计器model + */ + @GetMapping("/add") + public String add() + { + return prefix + "/add"; + } + + /** + * 新增保存设计器model + */ + @RequiresPermissions("system:model:add") + @Log(title = "设计器model", businessType = BusinessType.INSERT) + @PostMapping("/add") + @ResponseBody + public AjaxResult addSave(ActDeModel actDeModel) + { + return toAjax(actDeModelService.insertActDeModel(actDeModel)); + } + + /** + * 修改设计器model + */ + @GetMapping("/edit/{id}") + public String edit(@PathVariable("id") String id, ModelMap mmap) + { + ActDeModel actDeModel = actDeModelService.selectActDeModelById(id); + mmap.put("actDeModel", actDeModel); + return redirect("/modeler/index.html#/editor/"+id); + } + + /** + * 修改保存设计器model + */ + @RequiresPermissions("system:model:edit") + @Log(title = "设计器model", businessType = BusinessType.UPDATE) + @PostMapping("/edit") + @ResponseBody + public AjaxResult editSave(ActDeModel actDeModel) + { + return toAjax(actDeModelService.updateActDeModel(actDeModel)); + } + + /** + * 删除设计器model + */ + @RequiresPermissions("system:model:remove") + @Log(title = "设计器model", businessType = BusinessType.DELETE) + @PostMapping( "/remove") + @ResponseBody + public AjaxResult remove(String ids) + { + return toAjax(actDeModelService.deleteActDeModelByIds(ids)); + } + + + @Log(title = "发布流程", businessType = BusinessType.DEPLOYMENT) + @RequiresPermissions("system:model:deployment") + @PostMapping("/deployment") + @ResponseBody + public AjaxResult deployment(String id) + { + Deployment Deployment = flowablePublishServiceImpl.createBytesDeploymentByModelId(id); + if(Deployment==null){ + return AjaxResult.error("modelId不存在"); + } + return AjaxResult.success("发布成功"); + } +} diff --git a/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java b/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java index 9cd1317..e92a553 100644 --- a/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java +++ b/snow-admin/src/main/java/com/snow/web/controller/flowable/FlowModelerController.java @@ -26,7 +26,7 @@ import java.io.InputStream; import java.util.List; /** - * 财务支付宝流水Controller + * Controller * * @author snow * @date 2020-11-09 @@ -90,10 +90,8 @@ public class FlowModelerController extends BaseController @ResponseBody public TableDataInfo list(DeploymentQueryDTO deploymentQuery) { - - startPage(); - List deploymentList = flowableService.getDeploymentList(deploymentQuery); - return getDataTable(deploymentList); + PageModel deploymentList = flowableService.getDeploymentList(deploymentQuery); + return getFlowDataTable(deploymentList); } /** diff --git a/snow-admin/src/main/resources/static/ruoyi/js/ry-ui.js b/snow-admin/src/main/resources/static/ruoyi/js/ry-ui.js index cfed4ce..14348c6 100644 --- a/snow-admin/src/main/resources/static/ruoyi/js/ry-ui.js +++ b/snow-admin/src/main/resources/static/ruoyi/js/ry-ui.js @@ -1098,6 +1098,41 @@ var table = { } return url; }, + + // 弹出层全屏 + parentDetail: function ( id, width, height) { + var url = $.operate.detailUrl(id); + var title='设计器'; + //如果是移动端,就使用自适应大小弹窗 + if ($.common.isMobile()) { + width = 'auto'; + height = 'auto'; + } + if ($.common.isEmpty(title)) { + title = false; + } + if ($.common.isEmpty(url)) { + url = "/404.html"; + } + if ($.common.isEmpty(width)) { + width = 800; + } + if ($.common.isEmpty(height)) { + height = ($(window).height() - 50); + } + var index = parent.layer.open({ + type: 2, + area: [width + 'px', height + 'px'], + fix: false, + //不固定 + maxmin: true, + shade: 0.3, + title: '流程设计器', + content: url + + }); + layer.full(index); + }, // 删除信息 remove: function(id) { table.set(); @@ -1126,6 +1161,20 @@ var table = { $.operate.submit(url, "post", "json", data); }); }, + // 删除信息 + deployment: function(id) { + table.set(); + $.modal.confirm("确定发布该条" + table.options.modalName + "信息吗?", function() { + var url = $.common.isEmpty(id) ? table.options.deploymentUrl : table.options.deploymentUrl.replace("{id}", id); + if(table.options.type == table_type.bootstrapTreeTable) { + $.operate.get(url); + } else { + var data = { "id": id }; + $.operate.submit(url, "post", "json", data); + } + }); + + }, // 清空信息 clean: function() { table.set(); diff --git a/snow-admin/src/main/resources/templates/flow/deployment.html b/snow-admin/src/main/resources/templates/flow/deployment.html index a6dbb59..9c38e31 100644 --- a/snow-admin/src/main/resources/templates/flow/deployment.html +++ b/snow-admin/src/main/resources/templates/flow/deployment.html @@ -92,28 +92,28 @@ } }, - { + /* { field: 'processDefinitionVO', title: '流程定义key', formatter: function(value, row, index) { return value.key; } - }, - { + },*/ + /* { field: 'processDefinitionVO', title: '版本号', formatter: function(value, row, index) { return value.version; } - }, + },*/ - { + /* { field: 'processDefinitionVO', title: '文件名', formatter: function(value, row, index) { return value.resourceName; } - }, + },*/ { field: 'deploymentTime', title: '流程发布时间' @@ -128,14 +128,12 @@ title: '操作', align: 'center', formatter: function(value, row, index) { - console.log(JSON.stringify(row.processDefinitionVO)); - var processDefinition= row.processDefinitionVO; - // var getFlowPicture=prefix+'/getFlowPicture?id='+processDefinition.deploymentId+'&resourceName='+processDefinition.diagramResourceName; - var getXmlUrl=prefix+'/getXml?id='+processDefinition.deploymentId+'&resourceName='+processDefinition.resourceName; + + var getXmlUrl=prefix+'/getXml?id='+row.id+'&resourceName='; var actions = []; - actions.push('流程图 '); + /* actions.push('流程图 ');*/ + actions.push('流程图 '); actions.push('XML '); - /* actions.push('流程图 ');*/ actions.push('删除'); return actions.join(''); } @@ -148,9 +146,9 @@ * 预览XML * @param tableId */ - function previewXml(deploymentId,resourceName) { + function previewXml(deploymentId) { console.log(JSON.stringify(deploymentId)); - var preViewUrl=prefix+'/getFlowPicture?id='+deploymentId+'&resourceName='+resourceName; + var preViewUrl=prefix+'/getFlowPicture?id='+deploymentId+'&resourceName='; $.modal.openTab("预览流程图", preViewUrl); } diff --git a/snow-admin/src/main/resources/templates/flow/model.html b/snow-admin/src/main/resources/templates/flow/model.html index cbdca47..b486d6f 100644 --- a/snow-admin/src/main/resources/templates/flow/model.html +++ b/snow-admin/src/main/resources/templates/flow/model.html @@ -100,14 +100,13 @@ title: '操作', align: 'center', formatter: function(value, row, index) { - console.log(JSON.stringify(row.processDefinitionVO)); - var processDefinition= row.processDefinitionVO; - // var getFlowPicture=prefix+'/getFlowPicture?id='+processDefinition.deploymentId+'&resourceName='+processDefinition.diagramResourceName; - var getXmlUrl=prefix+'/getXml?id='+processDefinition.deploymentId+'&resourceName='+processDefinition.resourceName; + //var processDefinition= row.processDefinitionVO; + // var getXmlUrl=prefix+'/getXml?id='+processDefinition.deploymentId+'&resourceName='+processDefinition.resourceName; + var getXmlUrl=prefix+'/getXml?id='+row.id+'&resourceName='; var actions = []; - actions.push('流程图 '); + /* actions.push('流程图 ');*/ + actions.push('流程图 '); actions.push('XML '); - /* actions.push('流程图 ');*/ actions.push('删除'); return actions.join(''); } @@ -120,9 +119,9 @@ * 预览XML * @param tableId */ - function previewXml(deploymentId,resourceName) { + function previewXml(deploymentId) { console.log(JSON.stringify(deploymentId)); - var preViewUrl=prefix+'/getFlowPicture?id='+deploymentId+'&resourceName='+resourceName; + var preViewUrl=prefix+'/getFlowPicture?id='+deploymentId+'&resourceName='; $.modal.openTab("预览流程图", preViewUrl); } diff --git a/snow-admin/src/main/resources/templates/system/model/add.html b/snow-admin/src/main/resources/templates/system/model/add.html new file mode 100644 index 0000000..6cb4ca3 --- /dev/null +++ b/snow-admin/src/main/resources/templates/system/model/add.html @@ -0,0 +1,126 @@ + + + + + + + +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+
+
+ + + + + \ No newline at end of file diff --git a/snow-admin/src/main/resources/templates/system/model/edit.html b/snow-admin/src/main/resources/templates/system/model/edit.html new file mode 100644 index 0000000..eebbc30 --- /dev/null +++ b/snow-admin/src/main/resources/templates/system/model/edit.html @@ -0,0 +1,127 @@ + + + + + + + +
+
+ +
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+
+ + +
+
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ +
+
+
+ +
+ + 代码生成请选择字典属性 +
+
+
+ +
+ +
+
+
+
+ + + + + \ No newline at end of file diff --git a/snow-admin/src/main/resources/templates/system/model/model.html b/snow-admin/src/main/resources/templates/system/model/model.html new file mode 100644 index 0000000..931c713 --- /dev/null +++ b/snow-admin/src/main/resources/templates/system/model/model.html @@ -0,0 +1,127 @@ + + + + + + +
+
+
+
+
+
    +
  • + + +
  • +
  • + + +
  • + +
  • + + +
  • + +
  • +  搜索 +  重置 +
  • +
+
+
+
+ + +
+
+
+
+
+ + + + \ No newline at end of file diff --git a/snow-common/src/main/java/com/snow/common/enums/BusinessType.java b/snow-common/src/main/java/com/snow/common/enums/BusinessType.java index 5d423ea..3b71a0b 100644 --- a/snow-common/src/main/java/com/snow/common/enums/BusinessType.java +++ b/snow-common/src/main/java/com/snow/common/enums/BusinessType.java @@ -56,6 +56,10 @@ public enum BusinessType * 清空 */ CLEAN, + /** + * 发布 + */ + DEPLOYMENT, /** * 钉钉 */ diff --git a/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentQueryDTO.java b/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentQueryDTO.java index 3e02e14..32c2921 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentQueryDTO.java +++ b/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentQueryDTO.java @@ -11,7 +11,7 @@ import java.io.Serializable; * @create: 2020-11-20 21:44 **/ @Data -public class DeploymentQueryDTO implements Serializable { +public class DeploymentQueryDTO extends FlowBaseDTO implements Serializable { private String deploymentKeyLike; @@ -22,12 +22,4 @@ public class DeploymentQueryDTO implements Serializable { private String processDefinitionKeyLike; private String startUserId; - /** - * 初始页 - */ - private int firstResult=0; - /** - * 每页数 - */ - private int maxResults=10; } diff --git a/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java b/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java index ebc3120..ccd6271 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java +++ b/snow-flowable/src/main/java/com/snow/flowable/domain/DeploymentVO.java @@ -3,11 +3,13 @@ package com.snow.flowable.domain; import com.alibaba.fastjson.annotation.JSONField; import com.fasterxml.jackson.annotation.JsonFormat; import lombok.Data; +import org.flowable.common.engine.api.repository.EngineResource; import org.flowable.engine.repository.ProcessDefinition; import java.io.Serializable; import java.util.Date; import java.util.List; +import java.util.Map; /** * @program: snow @@ -18,28 +20,28 @@ import java.util.List; @Data public class DeploymentVO implements Serializable { private String id; - + /** + * 发布名称 + */ private String name; - + /** + * 发布时间 + */ @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") private Date deploymentTime; - + /** + * 分类 + */ private String category; - private String key; + /** + * 租户Id + */ + protected String tenantId; + /** + * 父节点 + */ + protected String parentDeploymentId; - private String derivedFrom; - - private String derivedFromRoot; - - private String tenantId; - - private String engineVersion; - - private ProcessDefinitionVO processDefinitionVO; - - private List processDefinitionVOList; - - private List modelVOList; } diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/FlowablePublishService.java b/snow-flowable/src/main/java/com/snow/flowable/service/FlowablePublishService.java index 09cacb0..b9a82eb 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/FlowablePublishService.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/FlowablePublishService.java @@ -49,4 +49,11 @@ public interface FlowablePublishService { * @return */ Deployment createBytesDeployment(DeploymentDTO deploymentDTO,byte[] bytes ); + + /** + * 根据modelId发布 + * @param id + * @return + */ + Deployment createBytesDeploymentByModelId(String id); } diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java b/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java index f6504ad..73328fe 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/FlowableService.java @@ -26,11 +26,11 @@ public interface FlowableService { PageModel getModelList(ModelDTO modelDTO); /** - * 查询发布列表 + * 查询发布列表(分页) * @param deploymentQueryDTO * @return */ - List getDeploymentList(DeploymentQueryDTO deploymentQueryDTO); + PageModel getDeploymentList(DeploymentQueryDTO deploymentQueryDTO); /** * 删除发布 diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowablePublishServiceImpl.java b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowablePublishServiceImpl.java index 1b6f7be..c4ef6dc 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowablePublishServiceImpl.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowablePublishServiceImpl.java @@ -4,15 +4,23 @@ import com.snow.common.utils.StringUtils; import com.snow.flowable.domain.ClassDeploymentDTO; import com.snow.flowable.domain.DeploymentDTO; import com.snow.flowable.service.FlowablePublishService; +import com.snow.system.domain.ActDeModel; +import com.snow.system.mapper.ActDeModelMapper; +import com.snow.system.service.IActDeModelService; import lombok.extern.slf4j.Slf4j; +import org.flowable.bpmn.model.BpmnModel; import org.flowable.common.engine.impl.util.IoUtil; import org.flowable.engine.RepositoryService; import org.flowable.engine.repository.Deployment; import org.flowable.engine.repository.DeploymentBuilder; +import org.flowable.ui.modeler.domain.Model; +import org.flowable.ui.modeler.service.ModelServiceImpl; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; +import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.util.Optional; import java.util.zip.ZipInputStream; /** @@ -38,6 +46,11 @@ public class FlowablePublishServiceImpl implements FlowablePublishService { @Autowired private RepositoryService repositoryService; + @Autowired + private IActDeModelService iActDeModelService; + + @Autowired + private ModelServiceImpl modelService; /** * class部署 @@ -102,7 +115,6 @@ public class FlowablePublishServiceImpl implements FlowablePublishService { @Override public Deployment createBytesDeployment(DeploymentDTO deploymentDTO, byte[] bytes) { Deployment deploy = repositoryService.createDeployment() - .tenantId(deploymentDTO.getTenantId()) .category(deploymentDTO.getCategory()) .name(deploymentDTO.getName()) .key(deploymentDTO.getKey()) @@ -111,5 +123,23 @@ public class FlowablePublishServiceImpl implements FlowablePublishService { return deploy; } + @Override + public Deployment createBytesDeploymentByModelId(String id) { + Model model = modelService.getModel(id); + BpmnModel bpmnModel = modelService.getBpmnModel(model); + if(StringUtils.isNull(model)){ + return null; + } + byte[] bpmnXML = modelService.getBpmnXML(model); + InputStream inputStream = new ByteArrayInputStream(bpmnXML); + DeploymentDTO deployModel = new DeploymentDTO(); + deployModel.setCategory("system_flow"); + deployModel.setName(model.getName()); + deployModel.setKey(model.getKey()); + //这个地方必须加.bpmn或者.bpmn20.xml后缀,不然数据不会生成act_re_procdef这个表的数据 + deployModel.setResourceName(model.getName()+".bpmn20.xml"); + Deployment deploy = createInputStreamDeployment(deployModel,inputStream); + return deploy; + } } diff --git a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java index ef77ebf..1a151e4 100644 --- a/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java +++ b/snow-flowable/src/main/java/com/snow/flowable/service/impl/FlowableServiceImpl.java @@ -125,8 +125,8 @@ public class FlowableServiceImpl implements FlowableService { } @Override - public List getDeploymentList(DeploymentQueryDTO deploymentQueryDTO) { - + public PageModel getDeploymentList(DeploymentQueryDTO deploymentQueryDTO) { + DeploymentQuery deploymentQuery = repositoryService.createDeploymentQuery(); if(!StringUtils.isEmpty(deploymentQueryDTO.getDeploymentNameLike())){ deploymentQuery.deploymentKeyLike(deploymentQueryDTO.getDeploymentNameLike()); @@ -140,28 +140,20 @@ public class FlowableServiceImpl implements FlowableService { if(!StringUtils.isEmpty(deploymentQueryDTO.getProcessDefinitionKeyLike())){ deploymentQuery.processDefinitionKeyLike(deploymentQueryDTO.getProcessDefinitionKeyLike()); } + long count = deploymentQuery.orderByDeploymenTime().desc(). + count(); List deployments = deploymentQuery.orderByDeploymenTime().desc(). - listPage(deploymentQueryDTO.getFirstResult(), deploymentQueryDTO.getMaxResults()); - List deploymentVOList = deployments.stream().map(t -> { + listPage(deploymentQueryDTO.getPageNum(), deploymentQueryDTO.getPageSize()); + List deploymentVoList = deployments.stream().map(t -> { DeploymentVO deploymentVO = new DeploymentVO(); - ProcessDefinitionQuery processDefinitionQuery = repositoryService.createProcessDefinitionQuery(); - processDefinitionQuery.deploymentId(t.getId()); - if (!StringUtils.isEmpty(deploymentQueryDTO.getStartUserId())) { - processDefinitionQuery.startableByUser(deploymentQueryDTO.getStartUserId()); - } - List processDefinitionList = processDefinitionQuery.active().list(); - List processDefinitionVOList = processDefinitionList.stream().map(processDefinition -> { - ProcessDefinitionVO processDefinitionVO = new ProcessDefinitionVO(); - BeanUtils.copyProperties(processDefinition, processDefinitionVO); - return processDefinitionVO; - }).collect(Collectors.toList()); - BeanUtils.copyProperties(t,deploymentVO); - deploymentVO.setProcessDefinitionVO(processDefinitionVOList.get(0)); - deploymentVO.setProcessDefinitionVOList(processDefinitionVOList); + BeanUtils.copyProperties(t, deploymentVO); return deploymentVO; }).collect(Collectors.toList()); - return deploymentVOList; + PageModel pageModel = new PageModel<> (); + pageModel.setTotalCount((int)count); + pageModel.setPagedRecords(deploymentVoList); + return pageModel; } @Override @@ -175,25 +167,37 @@ public class FlowableServiceImpl implements FlowableService { @Override public void getDeploymentSource(String id, String resourceName, String type,HttpServletResponse response) { try { - byte[] b = null; - if (type.equals("xml")) { - response.setHeader("Content-type", "text/xml;charset=UTF-8"); - InputStream inputStream = repositoryService.getResourceAsStream(id, resourceName); - b = IoUtil.readInputStream(inputStream, resourceName); - } else { - //todo 输出的有乱码,暂时没有解决办法 - response.setHeader("Content-Type", "image/png;charset=UTF-8"); - response.setCharacterEncoding("utf-8"); - InputStream inputStream = repositoryService.getResourceAsStream(id, resourceName); - b = IoUtil.readInputStream(inputStream, resourceName); - } + byte[] b = null; + if(StringUtils.isEmpty(resourceName)){ + List deploymentResourceNames = repositoryService.getDeploymentResourceNames(id); + if(type.equals("xml")){ + String xmlType=".xml"; + String bpmnType=".bpmn"; + resourceName = deploymentResourceNames.stream().filter(p -> (p.endsWith(xmlType) || p.endsWith(bpmnType))).findFirst().orElse(null); + }else { + String pngType=".png"; + resourceName = deploymentResourceNames.stream().filter(p -> p.endsWith(pngType)).findFirst().orElse(null); + } + } + if (type.equals("xml")) { + response.setHeader("Content-type", "text/xml;charset=UTF-8"); + InputStream inputStream = repositoryService.getResourceAsStream(id, resourceName); + b = IoUtil.readInputStream(inputStream, resourceName); + } else if(type.equals("png")){ + response.setHeader("Content-Type", "image/png;charset=UTF-8"); + response.setCharacterEncoding("utf-8"); + InputStream inputStream = repositoryService.getResourceAsStream(id, resourceName); + b = IoUtil.readInputStream(inputStream, resourceName); + } response.getOutputStream().write(b); + } catch (IOException e) { log.error("ApiFlowableModelResource-loadXmlByModelId:" + e); e.printStackTrace(); } } + @Override public ProcessInstance startProcessInstanceByKey(StartProcessDTO startProcessDTO) { ProcessInstance processInstance=null; diff --git a/snow-system/src/main/java/com/snow/system/domain/ActDeModel.java b/snow-system/src/main/java/com/snow/system/domain/ActDeModel.java new file mode 100644 index 0000000..5ad137b --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/domain/ActDeModel.java @@ -0,0 +1,101 @@ +package com.snow.system.domain; + +import java.util.Date; +import com.snow.common.annotation.Excel; +import com.fasterxml.jackson.annotation.JsonFormat; +import com.snow.common.core.domain.BaseEntity; +import lombok.Data; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.apache.commons.lang3.builder.ToStringStyle; + +/** + * 设计器model对象 act_de_model + * + * @author qimingjin + * @date 2020-12-01 + */ +@Data +public class ActDeModel extends BaseEntity +{ + private static final long serialVersionUID = 1L; + + + private String id; + + + @Excel(name = "模型名称") + private String name; + + + @Excel(name = "模型key") + private String modelKey; + + + @Excel(name = "描述") + private String description; + + + @Excel(name = "模型注解") + private String modelComment; + + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "创建时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date created; + + + @Excel(name = "创建人") + private String createdBy; + + + @JsonFormat(timezone = "GMT+8", pattern = "yyyy-MM-dd HH:mm:ss") + @Excel(name = "更新时间", width = 30, dateFormat = "yyyy-MM-dd") + private Date lastUpdated; + + + @Excel(name = "更新人") + private String lastUpdatedBy; + + + @Excel(name = "版本") + private Long version; + + + @Excel(name = "模型采用json格式") + private String modelEditorJson; + + + @Excel(name = "图片流") + private byte[] thumbnail; + + /** + * 详见:org.flowable.ui.modeler.domain.AbstractModel + */ + @Excel(name = "模型类型") + private Long modelType; + + + @Excel(name = "租户ID") + private String tenantId; + + + @Override + public String toString() { + return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE) + .append("id", getId()) + .append("name", getName()) + .append("modelKey", getModelKey()) + .append("description", getDescription()) + .append("modelComment", getModelComment()) + .append("created", getCreated()) + .append("createdBy", getCreatedBy()) + .append("lastUpdated", getLastUpdated()) + .append("lastUpdatedBy", getLastUpdatedBy()) + .append("version", getVersion()) + .append("modelEditorJson", getModelEditorJson()) + .append("thumbnail", getThumbnail()) + .append("modelType", getModelType()) + .append("tenantId", getTenantId()) + .toString(); + } +} diff --git a/snow-system/src/main/java/com/snow/system/mapper/ActDeModelMapper.java b/snow-system/src/main/java/com/snow/system/mapper/ActDeModelMapper.java new file mode 100644 index 0000000..f30458b --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/mapper/ActDeModelMapper.java @@ -0,0 +1,61 @@ +package com.snow.system.mapper; + +import java.util.List; +import com.snow.system.domain.ActDeModel; + +/** + * 设计器modelMapper接口 + * + * @author qimingjin + * @date 2020-12-01 + */ +public interface ActDeModelMapper +{ + /** + * 查询设计器model + * + * @param id 设计器modelID + * @return 设计器model + */ + public ActDeModel selectActDeModelById(String id); + + /** + * 查询设计器model列表 + * + * @param actDeModel 设计器model + * @return 设计器model集合 + */ + public List selectActDeModelList(ActDeModel actDeModel); + + /** + * 新增设计器model + * + * @param actDeModel 设计器model + * @return 结果 + */ + public int insertActDeModel(ActDeModel actDeModel); + + /** + * 修改设计器model + * + * @param actDeModel 设计器model + * @return 结果 + */ + public int updateActDeModel(ActDeModel actDeModel); + + /** + * 删除设计器model + * + * @param id 设计器modelID + * @return 结果 + */ + public int deleteActDeModelById(String id); + + /** + * 批量删除设计器model + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteActDeModelByIds(String[] ids); +} diff --git a/snow-system/src/main/java/com/snow/system/service/IActDeModelService.java b/snow-system/src/main/java/com/snow/system/service/IActDeModelService.java new file mode 100644 index 0000000..8d808fa --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/service/IActDeModelService.java @@ -0,0 +1,64 @@ +package com.snow.system.service; + +import java.util.List; +import com.snow.system.domain.ActDeModel; + +/** + * 设计器modelService接口 + * + * @author qimingjin + * @date 2020-12-01 + */ +public interface IActDeModelService +{ + /** + * 查询设计器model + * + * @param id 设计器modelID + * @return 设计器model + */ + public ActDeModel selectActDeModelById(String id); + + + public ActDeModel selectThumbnailById(String id); + + /** + * 查询设计器model列表 + * + * @param actDeModel 设计器model + * @return 设计器model集合 + */ + public List selectActDeModelList(ActDeModel actDeModel); + + /** + * 新增设计器model + * + * @param actDeModel 设计器model + * @return 结果 + */ + public int insertActDeModel(ActDeModel actDeModel); + + /** + * 修改设计器model + * + * @param actDeModel 设计器model + * @return 结果 + */ + public int updateActDeModel(ActDeModel actDeModel); + + /** + * 批量删除设计器model + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + public int deleteActDeModelByIds(String ids); + + /** + * 删除设计器model信息 + * + * @param id 设计器modelID + * @return 结果 + */ + public int deleteActDeModelById(String id); +} diff --git a/snow-system/src/main/java/com/snow/system/service/impl/ActDeModelServiceImpl.java b/snow-system/src/main/java/com/snow/system/service/impl/ActDeModelServiceImpl.java new file mode 100644 index 0000000..78a6320 --- /dev/null +++ b/snow-system/src/main/java/com/snow/system/service/impl/ActDeModelServiceImpl.java @@ -0,0 +1,108 @@ +package com.snow.system.service.impl; + +import java.util.List; + +import cn.hutool.core.io.IoUtil; +import org.apache.commons.io.IOUtils; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import com.snow.system.mapper.ActDeModelMapper; +import com.snow.system.domain.ActDeModel; +import com.snow.system.service.IActDeModelService; +import com.snow.common.core.text.Convert; + +/** + * 设计器modelService业务层处理 + * + * @author qimingjin + * @date 2020-12-01 + */ +@Service +public class ActDeModelServiceImpl implements IActDeModelService +{ + @Autowired + private ActDeModelMapper actDeModelMapper; + + + + /** + * 查询设计器model + * + * @param id 设计器modelID + * @return 设计器model + */ + @Override + public ActDeModel selectActDeModelById(String id) + { + return actDeModelMapper.selectActDeModelById(id); + } + + @Override + public ActDeModel selectThumbnailById(String id) { + ActDeModel actDeModel = actDeModelMapper.selectActDeModelById(id); + byte[] thumbnail = actDeModel.getThumbnail(); + //createBytesDeployment + // IOUtils. + return null; + } + + /** + * 查询设计器model列表 + * + * @param actDeModel 设计器model + * @return 设计器model + */ + @Override + public List selectActDeModelList(ActDeModel actDeModel) + { + return actDeModelMapper.selectActDeModelList(actDeModel); + } + + /** + * 新增设计器model + * + * @param actDeModel 设计器model + * @return 结果 + */ + @Override + public int insertActDeModel(ActDeModel actDeModel) + { + return actDeModelMapper.insertActDeModel(actDeModel); + } + + /** + * 修改设计器model + * + * @param actDeModel 设计器model + * @return 结果 + */ + @Override + public int updateActDeModel(ActDeModel actDeModel) + { + return actDeModelMapper.updateActDeModel(actDeModel); + } + + /** + * 删除设计器model对象 + * + * @param ids 需要删除的数据ID + * @return 结果 + */ + @Override + public int deleteActDeModelByIds(String ids) + { + return actDeModelMapper.deleteActDeModelByIds(Convert.toStrArray(ids)); + } + + /** + * 删除设计器model信息 + * + * @param id 设计器modelID + * @return 结果 + */ + @Override + public int deleteActDeModelById(String id) + { + return actDeModelMapper.deleteActDeModelById(id); + } +} diff --git a/snow-system/src/main/resources/mapper/system/ActDeModelMapper.xml b/snow-system/src/main/resources/mapper/system/ActDeModelMapper.xml new file mode 100644 index 0000000..0b4958e --- /dev/null +++ b/snow-system/src/main/resources/mapper/system/ActDeModelMapper.xml @@ -0,0 +1,118 @@ + + + + + + + + + + + + + + + + + + + + + + + select id, name, model_key, description, model_comment, created, created_by, last_updated, last_updated_by, version, model_editor_json, thumbnail, model_type, tenant_id from act_de_model + + + + + + + + insert into act_de_model + + id, + name, + model_key, + description, + model_comment, + created, + created_by, + last_updated, + last_updated_by, + version, + model_editor_json, + thumbnail, + model_type, + tenant_id, + + + #{id}, + #{name}, + #{modelKey}, + #{description}, + #{modelComment}, + #{created}, + #{createdBy}, + #{lastUpdated}, + #{lastUpdatedBy}, + #{version}, + #{modelEditorJson}, + #{thumbnail}, + #{modelType}, + #{tenantId}, + + + + + update act_de_model + + name = #{name}, + model_key = #{modelKey}, + description = #{description}, + model_comment = #{modelComment}, + created = #{created}, + created_by = #{createdBy}, + last_updated = #{lastUpdated}, + last_updated_by = #{lastUpdatedBy}, + version = #{version}, + model_editor_json = #{modelEditorJson}, + thumbnail = #{thumbnail}, + model_type = #{modelType}, + tenant_id = #{tenantId}, + + where id = #{id} + + + + delete from act_de_model where id = #{id} + + + + delete from act_de_model where id in + + #{id} + + + + \ No newline at end of file