新增采购单

This commit is contained in:
jinqiming 2021-01-14 19:12:16 +08:00
parent 297202ffde
commit ba7efd1e01
12 changed files with 154 additions and 14 deletions

View File

@ -1,5 +1,6 @@
package com.snow.web.controller.flowable;
import com.google.common.collect.Lists;
import com.snow.common.annotation.Log;
import com.snow.common.core.controller.BaseController;
import com.snow.common.core.domain.AjaxResult;
@ -59,6 +60,7 @@ public class ActDeModelController extends BaseController
public TableDataInfo list(ActDeModel actDeModel)
{
startPage();
actDeModel.setModelTypeList(Lists.newArrayList(ActDeModel.MODEL_TYPE_BPMN,ActDeModel.MODEL_TYPE_DECISION_TABLE));
List<ActDeModel> list = actDeModelService.selectActDeModelList(actDeModel);
return getDataTable(list);
}
@ -155,10 +157,10 @@ public class ActDeModelController extends BaseController
@RequiresPermissions("system:model:deployment")
@PostMapping("/deployment")
@ResponseBody
public AjaxResult deployment(String id)
public AjaxResult deployment(String id,Integer type)
{
Deployment Deployment = flowablePublishServiceImpl.createBytesDeploymentByModelId(id);
if(Deployment==null){
String deploymentId = flowablePublishServiceImpl.deploymentByModelId(id, type);
if(deploymentId==null){
return AjaxResult.error("modelId不存在");
}
return AjaxResult.success("发布成功");

View File

@ -1162,15 +1162,16 @@ var table = {
$.operate.submit(url, "post", "json", data);
});
},
// 删除信息
deployment: function(id) {
// 发布信息
deployment: function(id,type) {
console.log("=======>"+type);
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 };
var data = { "id": id ,"type":type};
$.operate.submit(url, "post", "json", data);
}
});

View File

@ -125,7 +125,7 @@
formatter: function(value, row, index) {
var actions = [];
actions.push('<a class="btn btn-success btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.parentDetail(\'' + row.id + '\')"><i class="fa fa-edit"></i>编辑模型</a> ');
actions.push('<a class="btn btn-warning btn-xs ' + deploymentFlag + '" href="javascript:void(0)" onclick="$.operate.deployment(\'' + row.id + '\')"><i class="fa fa-dashboard"></i>发布</a> ');
actions.push('<a class="btn btn-warning btn-xs ' + deploymentFlag + '" href="javascript:void(0)" onclick="$.operate.deployment(\'' + row.id + '\','+row.modelType+')"><i class="fa fa-dashboard"></i>发布</a> ');
actions.push('<a class="btn btn-info btn-xs ' + exportXmlFlag + '" href="javascript:void(0)" onclick="getXmlUrl(\'' + row.id + '\')"><i class="fa fa-expand"></i>导出</a> ');
actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.id + '\')"><i class="fa fa-remove"></i>删除</a>');
return actions.join('');

View File

@ -0,0 +1,55 @@
package com.snow.flowable;
import com.google.common.collect.Maps;
import com.snow.JunitTestApplication;
import com.snow.common.json.JSON;
import lombok.extern.slf4j.Slf4j;
import org.flowable.dmn.api.*;
import org.flowable.dmn.engine.DmnEngineConfiguration;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.util.List;
import java.util.Map;
/**
* @author qimingjin
* @Title:
* @Description:
* @date 2021/1/14 16:31
*/
@Slf4j
public class DMNServiceTests extends JunitTestApplication {
@Autowired
private DmnRuleService dmnRuleService;
@Autowired
private DmnEngineConfiguration dmnEngineConfiguration;
@Autowired
private DmnHistoryService dmnHistoryService;
@Autowired
private DmnManagementService dmnManagementService;
@Test
public void executeDecisionTest(){
ExecuteDecisionBuilder variable = dmnRuleService.createExecuteDecisionBuilder().variable("", "");
Map<String,Object> paramMap=Maps.newHashMap();
paramMap.put("manager","网二");
paramMap.put("zjl","张三");
paramMap.put("rs","李四");
Map<String, Object> result = dmnRuleService.createExecuteDecisionBuilder()
.decisionKey("testKey")
.variables(paramMap)
.variable("money", "50")
.executeWithSingleResult();
List<DmnHistoricDecisionExecution> testKey = dmnHistoryService.createHistoricDecisionExecutionQuery().decisionKey("testKey")
.orderByEndTime()
.desc()
.list();
log.info(com.alibaba.fastjson.JSON.toJSONString(testKey));
}
}

View File

@ -26,7 +26,7 @@ public class DeploymentTests extends JunitTestApplication {
@Test
public void createClassDeployment() throws Exception{
InputStream in = new BufferedInputStream(new FileInputStream("D:\\ChromeCoreDownloads\\snow_leave.bpmn20.xml"));
// InputStream in = new BufferedInputStream(new FileInputStream("D:\\ChromeCoreDownloads\\snow_leave.bpmn20.xml"));
DeploymentDTO classDeploymentDTO=new DeploymentDTO();
// classDeploymentDTO.setKey("snow_leave");
classDeploymentDTO.setName("请假流程");
@ -34,7 +34,8 @@ public class DeploymentTests extends JunitTestApplication {
classDeploymentDTO.setResourceName("请假流程");
// classDeploymentDTO.setTenantId("snow");
// classDeploymentDTO.setClassPathResource("D:\\modeler\\leave.bpmn20.xml");
Deployment classDeployment = flowAblePublishService.createInputStreamDeployment(classDeploymentDTO,in);
log.info("发布结果:{}",JSON.toJSONString(classDeployment));
// Deployment classDeployment = flowAblePublishService.createInputStreamDeployment(classDeploymentDTO,in);
flowAblePublishService.deploymentByModelId("054863dc-5629-11eb-802b-040e3c9c6b2f",4);
// log.info("发布结果:{}",JSON.toJSONString(classDeployment));
}
}

View File

@ -38,6 +38,8 @@ public class FlowableConfig {
configuration.setTransactionManager(transactionManager);
configuration.setDatabaseSchemaUpdate("false");
configuration.setAsyncExecutorActivate(true);
//开启历史数据异步保存
configuration.setAsyncHistoryEnabled(true);
configuration.setProcessDiagramGenerator(customProcessDiagramGenerator);
//修改id生成器
configuration.setIdGenerator(new FlowIdGenerator());

View File

@ -32,4 +32,9 @@ public class DeploymentDTO implements Serializable {
* 文件名
*/
private String resourceName;
/**
* 发布类型
*/
private Integer deploymentType;
}

View File

@ -56,4 +56,13 @@ public interface FlowablePublishService {
* @return
*/
Deployment createBytesDeploymentByModelId(String id);
/**
* 根据模型ID发布
* @param id
* @param deploymentType
* @return
*/
String deploymentByModelId(String id,int deploymentType);
}

View File

@ -1,12 +1,19 @@
package com.snow.flowable.service.impl;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
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 lombok.extern.slf4j.Slf4j;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.common.engine.impl.util.IoUtil;
import org.flowable.dmn.api.DmnDeployment;
import org.flowable.dmn.api.DmnRepositoryService;
import org.flowable.dmn.model.DmnDefinition;
import org.flowable.editor.dmn.converter.DmnJsonConverter;
import org.flowable.engine.RepositoryService;
import org.flowable.engine.repository.Deployment;
import org.flowable.engine.repository.DeploymentBuilder;
@ -15,6 +22,7 @@ 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.IOException;
import java.io.InputStream;
import java.util.zip.ZipInputStream;
@ -46,6 +54,14 @@ public class FlowablePublishServiceImpl implements FlowablePublishService {
@Autowired
private ModelServiceImpl modelService;
@Autowired
private ObjectMapper objectMapper;
@Autowired
private DmnRepositoryService dmnRepositoryService;
/**
* class部署
* @return
@ -136,4 +152,32 @@ public class FlowablePublishServiceImpl implements FlowablePublishService {
return deploy;
}
@Override
public String deploymentByModelId(String id, int deploymentType) {
Model model = modelService.getModel(id);
if(StringUtils.isNull(model)){
return null;
}
try {
if(deploymentType==ActDeModel.MODEL_TYPE_DECISION_TABLE){
JsonNode editorJsonNode = objectMapper.readTree(model.getModelEditorJson());
DmnJsonConverter dmnJsonConverter=new DmnJsonConverter();
DmnDefinition dmnDefinition = dmnJsonConverter.convertToDmn(editorJsonNode, model.getId(), model.getVersion(), null);
DmnDeployment deploy = dmnRepositoryService.createDeployment()
.name(model.getName())
.addDmnModel(model.getName()+".dmn",dmnDefinition)
.category("system_dmn")
.deploy();
return deploy.getId();
}else if(deploymentType==ActDeModel.MODEL_TYPE_BPMN){
Deployment deployment = createBytesDeploymentByModelId(id);
return deployment.getId();
}
return null;
} catch (IOException e) {
log.error("DeploymentByModelId is fail",e.getMessage());
throw new RuntimeException("发布流程失败");
}
}
}

View File

@ -35,6 +35,7 @@ import org.flowable.bpmn.model.*;
import org.flowable.bpmn.model.Process;
import org.flowable.common.engine.impl.identity.Authentication;
import org.flowable.common.engine.impl.util.IoUtil;
import org.flowable.dmn.api.DmnRepositoryService;
import org.flowable.engine.*;
import org.flowable.engine.history.HistoricActivityInstance;
import org.flowable.engine.history.HistoricProcessInstance;
@ -99,6 +100,7 @@ public class FlowableServiceImpl implements FlowableService {
@Autowired
private RepositoryService repositoryService;
@Autowired
private HistoryService historyService;
@ -111,9 +113,6 @@ public class FlowableServiceImpl implements FlowableService {
@Autowired
private ExpressionServiceImpl expressionService;
@Resource
private SysUserMapper sysUserMapper;
@Autowired
private ModelServiceImpl modelService;
@ -148,7 +147,7 @@ public class FlowableServiceImpl implements FlowableService {
model.setCreatedBy(actDeModel.getCreatedBy());
model.setKey(actDeModel.getModelKey());
model.setModelType(actDeModel.getModelType().intValue());
model.setVersion(1);
model.setVersion(actDeModel.getVersion().intValue());
model.setModelEditorJson(editorNode.toString());
modelService.saveModel(model);
}

View File

@ -1,6 +1,8 @@
package com.snow.system.domain;
import java.util.Date;
import java.util.List;
import com.snow.common.annotation.Excel;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.snow.common.core.domain.BaseEntity;
@ -78,6 +80,19 @@ public class ActDeModel extends BaseEntity
@Excel(name = "租户ID")
private String tenantId;
private List modelTypeList;
public static final int MODEL_TYPE_BPMN = 0;
public static final int MODEL_TYPE_FORM = 2;
public static final int MODEL_TYPE_APP = 3;
public static final int MODEL_TYPE_DECISION_TABLE = 4;
public static final int MODEL_TYPE_CMMN = 5;
public static final int MODEL_TYPE_DECISION_SERVICE = 6;
@Override
public String toString() {

View File

@ -40,6 +40,13 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
<if test="modelEditorJson != null and modelEditorJson != ''"> and model_editor_json = #{modelEditorJson}</if>
<if test="modelType != null "> and model_type = #{modelType}</if>
<if test="tenantId != null and tenantId != ''"> and tenant_id = #{tenantId}</if>
<if test="modelTypeList != null and modelTypeList.size()>0">
and model_type IN
<foreach item="item" index="index" collection="modelTypeList" open="(" separator="," close=")">
#{item}
</foreach>
</if>
</where>
</select>