Commit 1c7a54a0 by 王衍超

Merge branch 'develop' of gitlab.beecode.cn:kunlun/xyst_dinas/xyst_dinas_backend into develop

parents 64dc61b7 fbbfe657
package com.beecode.inz.workflow.internal.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import com.beecode.bap.workflow.core.WorkflowBiztrait;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.workflow.core.StorageWorkflow;
import com.beecode.inz.workflow.config.TriggerAction;
import com.beecode.inz.workflow.config.WorkflowConfigurationDefinition;
import com.beecode.inz.workflow.dao.CommonDao;
import com.beecode.inz.workflow.entity.InzApprovalTask;
import com.beecode.inz.workflow.entity.InzBizProcess;
import com.beecode.inz.workflow.entity.UserAssignment;
import com.beecode.inz.workflow.process.FlowChartInfo;
import com.beecode.inz.workflow.process.NodeInfo;
import com.beecode.inz.workflow.process.StartNodeInfo;
import com.beecode.inz.workflow.service.BizTypeWorkflowConfigurationService;
import com.beecode.inz.workflow.service.FlowChartInfoService;
import com.beecode.inz.workflow.service.InzApprovalTaskService;
@Service
public class FlowChartInfoServiceImpl implements FlowChartInfoService{
@Autowired
private BizTypeWorkflowConfigurationService bizTypeWorkflowConfigurationService;
@Autowired
private CommonDao commonDao;
@Autowired
private InzApprovalTaskService inzApprovalTaskService;
@Override
public FlowChartInfo getFlowChartInfo(String bizTypeName, UUID bizDataid) {
WorkflowConfigurationDefinition config = bizTypeWorkflowConfigurationService.getBizTypeWorkflowConfigurationByBizTypeName(bizTypeName);
if(null == config){
return new FlowChartInfo();
}
String kClass = config.getBizTypeInfo().getkClassName();
KObject bizData = commonDao.load(kClass, bizDataid);
Assert.notNull(bizData,"param 'bizData' must not be null");
KObject bizProcessObj = bizData.get(WorkflowBiztrait.ATTR_BIZPROCESS);
if(null == bizProcessObj || bizProcessObj.isNull()){
return new FlowChartInfo();
}
InzBizProcess inzBizProcess = new InzBizProcess(bizProcessObj);
FlowChartInfo chartInfo = new FlowChartInfo();
List<NodeInfo> nodes = new ArrayList<>();
chartInfo.setNodes(nodes);
StorageWorkflow workflow = (StorageWorkflow)inzBizProcess.getProcessInstance().getWorkflow();
chartInfo.setTitle(workflow.getWorkflowDefinition().getTitle());
chartInfo.setId(inzBizProcess.getId());
chartInfo.setWorkflowState(inzBizProcess.getWorkflowState());
//
TriggerAction triggerAction = config.getTriggerCondition().findTriggerActionByName(inzBizProcess.getTriggerAction());
Date startTime = inzBizProcess.getSubmitTime();
UserAssignment submitActor = new UserAssignment(inzBizProcess.getSubmitter());
submitActor.setActorId(inzBizProcess.getSubmitter().getUuid("id"));
nodes.add(generateStartNode(triggerAction, submitActor, startTime));
List<InzApprovalTask> allTask = new ArrayList<>();
allTask.addAll( inzApprovalTaskService.listApprovedTask(inzBizProcess.getProcessInstance().getId()));
allTask.addAll( inzApprovalTaskService.listToDoTask(inzBizProcess.getProcessInstance().getId()));
allTask = inzApprovalTaskService.generateParenChildRelation(allTask);
for(int i = 0 , length = allTask.size() ; i < length ;i++) {
String nodeId = allTask.get(i).getWorkItem().getNodeId();
String name = allTask.get(i).getWorkItem().getWorkItemName();
// ExtensionNode extensionNode = allTask.get(i).getWorkItem().getTaskNode().getExtensionNode();
String type = "userTask";
// if(extensionNode instanceof UserTaskNode) {
// type = ((UserTaskNode)extensionNode).getTaskType();
// }
List<InzApprovalTask> tempTasks = new ArrayList<InzApprovalTask>();
tempTasks.add(allTask.get(i));
nodes.add(generateNodeInfo(nodeId,name,type, false,tempTasks));
}
return chartInfo;
}
private StartNodeInfo generateStartNode(TriggerAction triggerAction,UserAssignment submitActor, Date startTime){
StartNodeInfo info = new StartNodeInfo();
info.setStartTime(startTime);
info.setType("userTask");
info.setSubmitActor(submitActor);
info.setTriggerActionTitle(triggerAction.getTitle());
info.setId(UUID.randomUUID().toString());
info.setName("开始");
info.setLast(false);
return info;
}
private NodeInfo generateNodeInfo(String id,String name,String type,boolean isLast,List<InzApprovalTask> tasks){
NodeInfo info = new NodeInfo();
info.setId(id);
info.setName(name);
info.setType(type);
if(null == tasks || tasks.size() == 0){
return info;
}
info.setApprovalTasks(tasks);
info.setLast(isLast);
return info;
}
}
package com.beecode.inz.workflow.internal.service;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.UUID;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import com.beecode.bap.workflow.core.WorkflowBiztrait;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.workflow.core.StorageWorkflow;
import com.beecode.inz.workflow.config.TriggerAction;
import com.beecode.inz.workflow.config.WorkflowConfigurationDefinition;
import com.beecode.inz.workflow.dao.CommonDao;
import com.beecode.inz.workflow.entity.InzApprovalTask;
import com.beecode.inz.workflow.entity.InzBizProcess;
import com.beecode.inz.workflow.entity.UserAssignment;
import com.beecode.inz.workflow.process.FlowChartInfo;
import com.beecode.inz.workflow.process.NodeInfo;
import com.beecode.inz.workflow.process.StartNodeInfo;
import com.beecode.inz.workflow.service.BizTypeWorkflowConfigurationService;
import com.beecode.inz.workflow.service.FlowChartInfoService;
import com.beecode.inz.workflow.service.InzApprovalTaskService;
@Service
public class FlowChartInfoServiceImpl implements FlowChartInfoService{
@Autowired
private BizTypeWorkflowConfigurationService bizTypeWorkflowConfigurationService;
@Autowired
private CommonDao commonDao;
@Autowired
private InzApprovalTaskService inzApprovalTaskService;
@Override
public FlowChartInfo getFlowChartInfo(String bizTypeName, UUID bizDataid) {
WorkflowConfigurationDefinition config = bizTypeWorkflowConfigurationService.getBizTypeWorkflowConfigurationByBizTypeName(bizTypeName);
if(null == config){
return new FlowChartInfo();
}
String kClass = config.getBizTypeInfo().getkClassName();
KObject bizData = commonDao.load(kClass, bizDataid);
Assert.notNull(bizData,"param 'bizData' must not be null");
KObject bizProcessObj = bizData.get(WorkflowBiztrait.ATTR_BIZPROCESS);
if(null == bizProcessObj || bizProcessObj.isNull()){
return new FlowChartInfo();
}
InzBizProcess inzBizProcess = new InzBizProcess(bizProcessObj);
FlowChartInfo chartInfo = new FlowChartInfo();
List<NodeInfo> nodes = new ArrayList<>();
chartInfo.setNodes(nodes);
StorageWorkflow workflow = (StorageWorkflow)inzBizProcess.getProcessInstance().getWorkflow();
chartInfo.setTitle(workflow.getWorkflowDefinition().getTitle());
chartInfo.setId(inzBizProcess.getId());
chartInfo.setWorkflowState(inzBizProcess.getWorkflowState());
//
TriggerAction triggerAction = config.getTriggerCondition().findTriggerActionByName(inzBizProcess.getTriggerAction());
Date startTime = inzBizProcess.getSubmitTime();
UserAssignment submitActor = new UserAssignment(inzBizProcess.getSubmitter());
submitActor.setActorId(inzBizProcess.getSubmitter().getUuid("id"));
nodes.add(generateStartNode(triggerAction, submitActor, startTime));
List<InzApprovalTask> allTask = new ArrayList<>();
allTask.addAll( inzApprovalTaskService.listApprovedTask(inzBizProcess.getProcessInstance().getId()));
allTask.addAll( inzApprovalTaskService.listToDoTask(inzBizProcess.getProcessInstance().getId()));
allTask = inzApprovalTaskService.generateParenChildRelation(allTask);
for(int i = 0 , length = allTask.size() ; i < length ;i++) {
String nodeId = allTask.get(i).getWorkItem().getNodeId();
String name = allTask.get(i).getWorkItem().getWorkItemName();
// ExtensionNode extensionNode = allTask.get(i).getWorkItem().getTaskNode().getExtensionNode();
String type = "userTask";
// if(extensionNode instanceof UserTaskNode) {
// type = ((UserTaskNode)extensionNode).getTaskType();
// }
List<InzApprovalTask> tempTasks = new ArrayList<InzApprovalTask>();
tempTasks.add(allTask.get(i));
nodes.add(generateNodeInfo(nodeId,name,type, false,tempTasks));
}
return chartInfo;
}
private StartNodeInfo generateStartNode(TriggerAction triggerAction,UserAssignment submitActor, Date startTime){
StartNodeInfo info = new StartNodeInfo();
info.setStartTime(startTime);
info.setType("userTask");
info.setSubmitActor(submitActor);
info.setTriggerActionTitle(triggerAction.getTitle());
info.setId(UUID.randomUUID().toString());
info.setName("开始");
info.setLast(false);
return info;
}
private NodeInfo generateNodeInfo(String id,String name,String type,boolean isLast,List<InzApprovalTask> tasks){
NodeInfo info = new NodeInfo();
info.setId(id);
info.setName(name);
info.setType(type);
if(null == tasks || tasks.size() == 0){
return info;
}
info.setApprovalTasks(tasks);
info.setLast(isLast);
return info;
}
}
......@@ -83,10 +83,10 @@ public class InzWorkflowServiceImpl implements InzWorkflowService{
private CommonDao commonDao;
@Autowired
private StaffService staffService;
public BapContext bapContext;
@Autowired
private BapContext bapContext;
private StaffService staffService;
@Autowired
private BizTypeWorkflowConfigurationService bizTypeWorkflowConfigurationService;
......@@ -254,11 +254,11 @@ public class InzWorkflowServiceImpl implements InzWorkflowService{
KObject currentLoginStaff = null;
try {
currentLoginStaff = bapContext.getCurrentStaff();
// List<KObject> staffs = staffService.getByUsername("c_user_default");
// if(null == staffs || staffs.size()<=0){
// throw new Exception();
// }
// currentLoginStaff = staffs.get(0);
// List<KObject> staffs = staffService.getByUsername("c_user_default");
// if(null == staffs || staffs.size()<=0){
// throw new Exception();
// }
// currentLoginStaff = staffs.get(0);
} catch (Exception e) {
throw new WorkflowRuntimeException("获取当前登录用户失败!");
}
......
package com.beecode.inz.workflow.participant;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.bap.org.service.BapOrgDetailService;
import com.beecode.bap.staff.Staff;
import com.beecode.bap.staff.service.StaffService;
import com.beecode.bcp.authz.service.RoleService;
import com.beecode.bcp.core.Department;
import com.beecode.bcp.participant.core.Participant;
import com.beecode.bcp.participant.core.ParticipantStrategy;
import com.beecode.bcp.participant.core.User;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.fasterxml.jackson.databind.JsonNode;
/**
* 提交人所在单位及其上级单位(按照路径匹配)中
* 符合指定角色的职员,即为该参与者策略的策略者。
* 解释:
* 和提交人有直接或者间接上下级(向上)关系的
* @author jiaokai
*/
public class SubmitOrgPathAppointRoleParticipantStrategy implements ParticipantStrategy {
private static String PARAM_ROLES = "roles";
private static final String SUBMITTER_ID = "submitterId";
@Autowired
private RoleService roleService;
@Autowired
private StaffService staffService;
@Autowired
private BapOrgDetailService orgService;
@Override
public List<Participant> getParticipant(Map<String, Object> params) {
final List<Participant> participants = new ArrayList<>();
List<KObject> staffsAll = new ArrayList<>();
if(null != params.get(PARAM_ROLES)){
JsonNode rolesJson = JSONObjectUtils.toJson(params.get(PARAM_ROLES));
rolesJson.forEach((role)->{
UUID roleId = UUID.fromString(role.asText());
staffsAll.addAll( this.findStaffByRoleId(roleId));
});
}
UUID submitterId = UUID.fromString(params.get(SUBMITTER_ID).toString());
KObject submitterKObj = staffService.getById(submitterId);
UUID submitOrgId = submitterKObj.get(Staff.DEPARTMENT).getUuid(Department.PROP_ORG_ID);
Map<String, KObject> submitOrgDetail = orgService.getByOrgId(submitOrgId);
String submitOrgParents = submitOrgDetail.get("parents").getString();
for(KObject staff : staffsAll){
UUID staffOrgId = staff.get(Staff.DEPARTMENT).getUuid(Department.PROP_ORG_ID);
String keyIdStr = staffOrgId.toString().replaceAll("-", "").toUpperCase();
if(submitOrgParents.indexOf(keyIdStr)>=0){
participants.add(new User(staff.getUuid("id")));
}
}
return participants;
}
public List<KObject> findStaffByRoleId(UUID id) {
List<KObject> staffs = new ArrayList<>();
List<com.beecode.bcp.User> users = roleService.getUsers(id);
if (users != null && users.size() > 0) {
staffs = users.stream().map(com.beecode.bcp.User::getId).map(staffService::getByUserId).collect(Collectors.toList());
}
return staffs;
}
}
package com.beecode.inz.workflow.participant;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import com.beecode.bap.org.service.BapOrgDetailService;
import com.beecode.bap.staff.Staff;
import com.beecode.bap.staff.service.StaffService;
import com.beecode.bcp.authz.service.RoleService;
import com.beecode.bcp.core.Department;
import com.beecode.bcp.participant.core.Participant;
import com.beecode.bcp.participant.core.ParticipantStrategy;
import com.beecode.bcp.participant.core.User;
import com.beecode.bcp.type.KObject;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.fasterxml.jackson.databind.JsonNode;
/**
* 提交人所在单位及其上级单位(按照路径匹配)中
* 符合指定角色的职员,即为该参与者策略的策略者。
* 解释:
* 和提交人有直接或者间接上下级(向上)关系的
* @author jiaokai
*/
public class SubmitOrgPathAppointRoleParticipantStrategy implements ParticipantStrategy {
private static String PARAM_ROLES = "roles";
private static final String SUBMITTER_ID = "submitterId";
@Autowired
private RoleService roleService;
@Autowired
private StaffService staffService;
@Autowired
private BapOrgDetailService orgService;
@Override
public List<Participant> getParticipant(Map<String, Object> params) {
final List<Participant> participants = new ArrayList<>();
List<KObject> staffsAll = new ArrayList<>();
if(null != params.get(PARAM_ROLES)){
JsonNode rolesJson = JSONObjectUtils.toJson(params.get(PARAM_ROLES));
rolesJson.forEach((role)->{
UUID roleId = UUID.fromString(role.asText());
staffsAll.addAll( this.findStaffByRoleId(roleId));
});
}
UUID submitterId = UUID.fromString(params.get(SUBMITTER_ID).toString());
KObject submitterKObj = staffService.getById(submitterId);
UUID submitOrgId = submitterKObj.get(Staff.DEPARTMENT).getUuid(Department.PROP_ORG_ID);
Map<String, KObject> submitOrgDetail = orgService.getByOrgId(submitOrgId);
String submitOrgParents = submitOrgDetail.get("parents").getString();
for(KObject staff : staffsAll){
UUID staffOrgId = staff.get(Staff.DEPARTMENT).getUuid(Department.PROP_ORG_ID);
String keyIdStr = staffOrgId.toString().replaceAll("-", "").toUpperCase();
if(submitOrgParents.indexOf(keyIdStr)>=0){
participants.add(new User(staff.getUuid("id")));
}
}
return participants;
}
public List<KObject> findStaffByRoleId(UUID id) {
List<KObject> staffs = new ArrayList<>();
List<com.beecode.bcp.User> users = roleService.getUsers(id);
if (users != null && users.size() > 0) {
staffs = users.stream().map(com.beecode.bcp.User::getId).map(staffService::getByUserId).collect(Collectors.toList());
}
return staffs;
}
}
package com.beecode.inz.workflow.service;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.json.JSONObject;
import com.beecode.bcp.workflow.exception.WorkflowRuntimeException;
import com.beecode.inz.workflow.entity.InzApprovalTask;
public interface InzApprovalTaskService {
void completeTask(UUID taskId,int result,String suggestions) throws WorkflowRuntimeException;
void completeTask(UUID taskId,int result,String suggestions,Map<String,String> argus,String attribute1) throws WorkflowRuntimeException;
/**
* 根据流程查询已审批的任务列表
* 按照审批完成时间升序
*/
List<InzApprovalTask> listApprovedTask(UUID processInstanceId);
/**
* 根据流程查询待审批的任务列表
*/
List<InzApprovalTask> listToDoTask(UUID processInstanceId);
/**
* 根据流程查询所有任务(包含待审和已审)
* @param processInstanceId
* @return
*/
List<InzApprovalTask> listApprovalTask(UUID processInstanceId);
InzApprovalTask getInzApprovalTaskById(UUID id);
List<InzApprovalTask> generateParenChildRelation(List<InzApprovalTask> tasks);
JSONObject getLastTaskByBizDataId(UUID bizDataId);
}
package com.beecode.inz.workflow.service;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.json.JSONObject;
import com.beecode.bcp.workflow.exception.WorkflowRuntimeException;
import com.beecode.inz.workflow.entity.InzApprovalTask;
public interface InzApprovalTaskService {
void completeTask(UUID taskId,int result,String suggestions) throws WorkflowRuntimeException;
void completeTask(UUID taskId,int result,String suggestions,Map<String,String> argus,String attribute1) throws WorkflowRuntimeException;
/**
* 根据流程查询已审批的任务列表
* 按照审批完成时间升序
*/
List<InzApprovalTask> listApprovedTask(UUID processInstanceId);
/**
* 根据流程查询待审批的任务列表
*/
List<InzApprovalTask> listToDoTask(UUID processInstanceId);
/**
* 根据流程查询所有任务(包含待审和已审)
* @param processInstanceId
* @return
*/
List<InzApprovalTask> listApprovalTask(UUID processInstanceId);
InzApprovalTask getInzApprovalTaskById(UUID id);
List<InzApprovalTask> generateParenChildRelation(List<InzApprovalTask> tasks);
JSONObject getLastTaskByBizDataId(UUID bizDataId);
}
/**
*
*/
package com.beecode.inz.workflow.service;
import java.util.Map;
import org.springframework.lang.Nullable;
import com.beecode.bap.bill.Bill;
import com.beecode.bap.bill.WorkflowBillConstants;
import com.beecode.bap.bill.annotations.Autoparam;
import com.beecode.bcp.biz.BizServiceInterface;
import com.beecode.bcp.biz.Parameter;
/**
* @author huangkaibin
*
*/
@BizServiceInterface(WorkflowBillConstants.BIZ_WORKFLOW)
public interface WorkflowBillService {
String METHOD_SUBMIT = "submit";
String METHOD_APPROVE = "approve";
String METHOD_REJECT = "reject";
/**
* 提交单据到工作流
* @param bill 单据
* @param params 启动工作流的参数,可以传<code>null</code>
/**
*
*/
package com.beecode.inz.workflow.service;
import java.util.Map;
import org.springframework.lang.Nullable;
import com.beecode.bap.bill.Bill;
import com.beecode.bap.bill.WorkflowBillConstants;
import com.beecode.bap.bill.annotations.Autoparam;
import com.beecode.bcp.biz.BizServiceInterface;
import com.beecode.bcp.biz.Parameter;
/**
* @author huangkaibin
*
*/
@BizServiceInterface(WorkflowBillConstants.BIZ_WORKFLOW)
public interface WorkflowBillService {
String METHOD_SUBMIT = "submit";
String METHOD_APPROVE = "approve";
String METHOD_REJECT = "reject";
/**
* 提交单据到工作流
* @param bill 单据
* @param params 启动工作流的参数,可以传<code>null</code>
* @return 默认情况下提交给工作流后返回<code>null</code>,如果没有配置工作流,就调用{@link #approve(Bill)}方法并返回结果。o
*/
Object submit(@Autoparam Bill bill, @Nullable @Parameter(optional = true) Map<String, Object> params);
/**
* 工作流审批同意后执行的动作
* @param bill 单据
* @return 由业务决定具体返回内容
*/
Object approve(@Autoparam Bill bill);
/**
* 工作流审批拒绝后执行的动作
* @param bill 单据
* @return 由业务决定具体返回内容
*/
Object reject(@Autoparam Bill bill);
}
*/
Object submit(@Autoparam Bill bill, @Nullable @Parameter(optional = true) Map<String, Object> params);
/**
* 工作流审批同意后执行的动作
* @param bill 单据
* @return 由业务决定具体返回内容
*/
Object approve(@Autoparam Bill bill);
/**
* 工作流审批拒绝后执行的动作
* @param bill 单据
* @return 由业务决定具体返回内容
*/
Object reject(@Autoparam Bill bill);
}
package com.beecode.inz.workflow.web;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.bcp.workflow.exception.WorkflowRuntimeException;
import com.beecode.inz.workflow.pojo.InzApprovalTaskObj;
import com.beecode.inz.workflow.service.InzApprovalTaskService;
@RestController
public class InzApprovalTaskController {
@Autowired
private InzApprovalTaskService inzApprovalTaskService;
@RequestMapping(value = "/workflow/completedApprovalTasks", method = RequestMethod.POST)
public Object completeTask(@RequestBody String body){
JSONObject returnObj = new JSONObject();
returnObj.put("status", 200);
JSONObject bodyJson = new JSONObject(body);
UUID taskId = UUID.fromString(bodyJson.getString("taskId"));
int result = bodyJson.getInt("approvalAction");
String suggestions = bodyJson.optString("suggestions");
String attribute1 = bodyJson.optString("attribute1");
JSONObject extendAttribute = bodyJson.optJSONObject("extendAttribute");
Map<String,String> argus = new HashMap<>();
if(extendAttribute!=null){
Iterator<?> it = extendAttribute.keys();
while(it.hasNext()){
String key = (String) it.next();
//得到value的值
String value = extendAttribute.optString(key);
//System.out.println(value);
argus.put(key, value);
}
}
try {
inzApprovalTaskService.completeTask(taskId, result, suggestions,argus,attribute1);
}catch (WorkflowRuntimeException e) {
returnObj.put("status", 500);
returnObj.put("code", e.getMessage());
}
return JSONObjectUtils.toJson(returnObj.toString());
}
@RequestMapping(value = "/workflow/approvalTasks/{id}", method = RequestMethod.GET)
public Object getWorkflowDefinitionById(@PathVariable("id") String id) {
UUID taskId = UUID.fromString(id);
return new InzApprovalTaskObj(inzApprovalTaskService.getInzApprovalTaskById(taskId));
}
@RequestMapping(value = "/workflow/taks/bizid/{bizDataId}", method = RequestMethod.GET)
public Object getLastTaskByBizDataId(@PathVariable("bizDataId") UUID bizDataId) {
JSONObject result = inzApprovalTaskService.getLastTaskByBizDataId(bizDataId);
if(null == result){
result = new JSONObject();
result.put("code",500);
result.put("reason","找不到对应的工作流实例");
}else{
result.put("code",200);
}
return result.toString();
}
}
package com.beecode.inz.workflow.web;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.UUID;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;
import com.beecode.bcp.type.json.JSONObjectUtils;
import com.beecode.bcp.workflow.exception.WorkflowRuntimeException;
import com.beecode.inz.workflow.pojo.InzApprovalTaskObj;
import com.beecode.inz.workflow.service.InzApprovalTaskService;
@RestController
public class InzApprovalTaskController {
@Autowired
private InzApprovalTaskService inzApprovalTaskService;
@RequestMapping(value = "/workflow/completedApprovalTasks", method = RequestMethod.POST)
public Object completeTask(@RequestBody String body){
JSONObject returnObj = new JSONObject();
returnObj.put("status", 200);
JSONObject bodyJson = new JSONObject(body);
UUID taskId = UUID.fromString(bodyJson.getString("taskId"));
int result = bodyJson.getInt("approvalAction");
String suggestions = bodyJson.optString("suggestions");
String attribute1 = bodyJson.optString("attribute1");
JSONObject extendAttribute = bodyJson.optJSONObject("extendAttribute");
Map<String,String> argus = new HashMap<>();
if(extendAttribute!=null){
Iterator<?> it = extendAttribute.keys();
while(it.hasNext()){
String key = (String) it.next();
//得到value的值
String value = extendAttribute.optString(key);
//System.out.println(value);
argus.put(key, value);
}
}
try {
inzApprovalTaskService.completeTask(taskId, result, suggestions,argus,attribute1);
}catch (WorkflowRuntimeException e) {
returnObj.put("status", 500);
returnObj.put("code", e.getMessage());
}
return JSONObjectUtils.toJson(returnObj.toString());
}
@RequestMapping(value = "/workflow/approvalTasks/{id}", method = RequestMethod.GET)
public Object getWorkflowDefinitionById(@PathVariable("id") String id) {
UUID taskId = UUID.fromString(id);
return new InzApprovalTaskObj(inzApprovalTaskService.getInzApprovalTaskById(taskId));
}
@RequestMapping(value = "/workflow/taks/bizid/{bizDataId}", method = RequestMethod.GET)
public Object getLastTaskByBizDataId(@PathVariable("bizDataId") UUID bizDataId) {
JSONObject result = inzApprovalTaskService.getLastTaskByBizDataId(bizDataId);
if(null == result){
result = new JSONObject();
result.put("code",500);
result.put("reason","找不到对应的工作流实例");
}else{
result.put("code",200);
}
return result.toString();
}
}
<model>
<header>
<type>bcp.participant.Participant</type>
<package>com.beecode.inz.workflow.participant</package>
<name>CommonParticipant</name>
<title>普通审批参与者策略</title>
<tags></tags>
<description>支持按用户、部门、角色计算参与则,结果为职员</description>
</header>
<content>
<participation-strategy id='4fe95b1b-1a14-4af4-a57a-dc2f8abe4f54'>
<input title='职员'>
<name>staffs</name>
<description>json数组</description>
<type>string</type>
</input>
<input title='部门'>
<name>departments</name>
<description>json数组</description>
<type>string</type>
</input>
<input title='角色'>
<name>roles</name>
<description>json数组</description>
<type>string</type>
</input>
<implementation runtime='java' extension='com.beecode.inz.workflow.participant.CommomParticipantStrategy'></implementation>
</participation-strategy>
</content>
</model>
\ No newline at end of file
<model>
<header>
<type>bcp.participant.Participant</type>
<package>com.beecode.inz.workflow.participant</package>
<name>DepartmentPicByLevelParticipant</name>
<title>层级负责人审批</title>
<tags></tags>
<description></description>
</header>
<content>
<participation-strategy id='82fd946d-ec0e-4055-b507-8624e0c57556'>
<input title='提交人Id'>
<name>submitterId</name>
<description></description>
<type>string</type>
</input>
<input title='层级'>
<name>level</name>
<description></description>
<type>int</type>
</input>
<implementation runtime='java' extension='com.beecode.inz.workflow.participant.DepartmentPicByLevelParticipantStrategy'></implementation>
</participation-strategy>
</content>
</model>
\ No newline at end of file
<model>
<header>
<type>bcp.participant.Participant</type>
<package>com.beecode.inz.workflow.participant</package>
<name>FollowerMemberPicParticipant</name>
<title>团队负责人审批</title>
<tags></tags>
<description></description>
</header>
<content>
<participation-strategy id='76357756-6acd-40cb-b230-40e9f2f23bbc'>
<input title='业务类型标识'>
<name>bizTypeName</name>
<description></description>
<type>string</type>
</input>
<input title='业务数据Id'>
<name>bizDataId</name>
<description></description>
<type>uuid</type>
</input>
<implementation runtime='java' extension='com.beecode.inz.workflow.participant.FollowerMemberPicParticipantStrategy'></implementation>
</participation-strategy>
</content>
</model>
\ No newline at end of file
<model>
<header>
<type>bcp.participant.Participant</type>
<package>com.beecode.inz.workflow.participant</package>
<name>SubmitDeptPathAppointRoleParticipant</name>
<title>提交人所在部门路径上指定角色</title>
<tags></tags>
<description></description>
</header>
<content>
<participation-strategy id='11e95b1b-1a14-4af4-a57a-dc2f8abe4f54'>
<input title='提交人Id'>
<name>submitterId</name>
<description></description>
<type>string</type>
</input>
<input title='角色'>
<name>roles</name>
<description>json数组</description>
<type>string</type>
</input>
<implementation runtime='java' extension='com.beecode.inz.workflow.participant.SubmitDeptPathAppointRoleParticipantStrategy'></implementation>
</participation-strategy>
</content>
</model>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<model>
<header>
<type>inz.query.Query</type>
<package>com.beecode.inz.workflow.query</package>
<name>ApprovalTask</name>
<title>审批任务查询</title>
<description></description>
</header>
<content>
<customQuery id="857fbab8-2715-4723-8cf7-be4941ba44de">
<kclass>com.beecode.inz.workflow.datamodel.InzApprovalTask</kclass>
<dataProcessor>com.beecode.inz.workflow.query.InzApprovalTaskQueryDataProcessor</dataProcessor>
<innerScene title="待处理">
<id>0c4b92d3-040f-4390-b9c0-8f0747dd0f9c</id>
<javaImplement>com.beecode.inz.workflow.internal.scene.ToDoTask</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<innerScene title="已处理">
<id>aae59d63-4cc9-412b-a9d8-604ecf8bfa82</id>
<javaImplement>com.beecode.inz.workflow.internal.scene.ProcessedTask</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<field title="id">
<name>id</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="对象名称">
<name>bizObjectName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="业务类型标识">
<name>bizTypeName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='业务类型标题'>
<name>bizTypeTitle_v</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="业务数据id">
<name>bizDataId</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="收到审批时间">
<name>startTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="审批流程名称">
<name>startTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="结束时间">
<name>finishTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="任务名称">
<name>taskName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="任务标题">
<name>title</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="任务状态">
<name>taskState</name>
<type>int</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="任务参数">
<name>parameters</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="审批结果">
<name>result</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="审批意见">
<name>suggestion</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="流程定义标题">
<name>processInstance.workflow.workflowDefinition.title</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="流程实例id">
<name>processInstance.id</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="流程发起人标题">
<name>bizProcess.submitter.name</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="流程实例业务类型标识">
<name>bizProcess.bizTypeName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
</customQuery>
</content>
</model>
<model>
<header>
<type>inz.query.Query</type>
<package>com.beecode.inz.workflow.query</package>
<name>BizProcess</name>
<title>工作流业务流程查询</title>
<tags></tags>
<description></description>
</header>
<content>
<customQuery id='fa32de24-a3f8-4270-8c6b-7b537e9a119d'>
<kclass>com.beecode.inz.workflow.datamodel.InzBizProcess</kclass>
<dataProcessor>com.beecode.inz.workflow.query.InzBizProcessQueryDataProcessor</dataProcessor>
<innerScene title='进行中'>
<id>ecfb64aa-f7a7-46ea-a705-31cf9e4b7fe9</id>
<javaImplement>com.beecode.inz.workflow.internal.scene.UnderwayProcess</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<innerScene title='已结束'>
<id>d5373cb4-4b63-43c4-8a5b-16d3f8079e57</id>
<javaImplement>com.beecode.inz.workflow.internal.scene.FinishedProcess</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<field title='id'>
<name>id</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='数据模型标识'>
<name>kclass</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='对象名称'>
<name>bizObjectName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='业务类型标识'>
<name>bizTypeName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='业务类型标题'>
<name>bizTypeTitle_v</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='触发动作'>
<name>triggerAction_v</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='业务数据id'>
<name>bizDataId</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='工作流状态'>
<name>workflowState</name>
<type>int</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='提交人名称'>
<name>submitter.name</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='提交时间'>
<name>submitTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='流程最后流转时间'>
<name>processInstance.lastTransferTime</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='审批流程标题'>
<name>processInstance.workflow.workflowDefinition.title</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title="流程实例业务类型标识">
<name>bizProcess.bizTypeName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
</customQuery>
</content>
</model>
\ No newline at end of file
<model>
<header>
<type>inz.query.Query</type>
<package>com.beecode.inz.workflow.query</package>
<name>WorkflowDefinition</name>
<title>工作流定义查询</title>
<tags></tags>
<description></description>
</header>
<content>
<customQuery id='8e5dfb20-1b4e-4d6b-a44b-438ef6d09e91'>
<kclass>com.beecode.inz.workflow.datamodel.InzWorkflowDefinition</kclass>
<dataProcessor>com.beecode.inz.workflow.query.InzWorkflowDefinitionQueryDataProcessor</dataProcessor>
<innerScene title="使用中">
<id>0c4b92d3-040f-4390-b9c0-8f0747dd0f9c</id>
<javaImplement>com.beecode.inz.workflow.internal.scene.workflowdefinition.UsingScene</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<innerScene title="已停用">
<id>aae59d63-4cc9-412b-a9d8-604ecf8bfa82</id>
<javaImplement>com.beecode.inz.workflow.internal.scene.workflowdefinition.DisabledScene</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<innerScene title="已作废">
<id>aae59d63-4c11-412b-a9d8-114ecf8bfa11</id>
<javaImplement>com.beecode.inz.workflow.internal.scene.workflowdefinition.DiscardScene</javaImplement>
<defaultExecute></defaultExecute>
<hide></hide>
</innerScene>
<field title='id'>
<name>id</name>
<type>uuid</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='名称'>
<name>name</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='标题'>
<name>title</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='创建时间'>
<name>createTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='创建人名称'>
<name>creator.name</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='修改时间'>
<name>modifyTime</name>
<type>datetime</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='修改人名称'>
<name>modifier.name</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='流程定义版本'>
<name>definitionVersion</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='业务类型标识'>
<name>bizTypeName</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='工作流配置'>
<name>workflowConfig</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='流程定义内容'>
<name>definitionContent</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='触发动作'>
<name>triggerAction_v</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='业务类型标题'>
<name>bizTypeTitle_v</name>
<type>string</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
<field title='流程状态'>
<name>definitionState</name>
<type>int</type>
<ref>
<type></type>
<name></name>
</ref>
<description></description>
</field>
</customQuery>
</content>
</model>
\ No newline at end of file
<model>
<header>
<type>bcp.task.Task</type>
<package>com.beecode.inz.workflow.task</package>
<name>ApprovalTaskDefinition</name>
<title>审批任务定义</title>
<tags></tags>
<description></description>
</header>
<content>
<task-definition id='b2a081fe-dcc8-457d-b899-ae6739773095' type='com.beecode.inz.workflow.datamodel.InzApprovalTask' taskEventListener='com.beecode.inz.workflow.listener.TaskEventListenerImpl'>
<parameters>
<input title='业务对象名称'>
<name>bizObjectName</name>
<type>string</type>
<description></description>
</input>
<input title='业务数据id'>
<name>bizDataId</name>
<type>uuid</type>
<description></description>
</input>
<input title='业务类型标识'>
<name>bizTypeName</name>
<type>string</type>
<description></description>
</input>
<output title='审批结果'>
<name>result</name>
<type>int</type>
<description></description>
</output>
</parameters>
</task-definition>
</content>
</model>
\ No newline at end of file
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-participant">
<specification>1.0</specification>
<id>82fd946d-ec0e-4055-b507-8624e0c57556</id>
<name>com.beecode.inz.workflow.participant.DepartmentPicByLevelParticipant</name>
<title>层级负责人审批</title>
<define>bcp.participant</define>
<define-version>1.0</define-version>
<content>
<m:participation-strategy>
<m:input>
<m:name>submitterId</m:name>
<m:title>提交人Id</m:title>
<m:description></m:description>
<m:type>string</m:type>
</m:input>
<m:input>
<m:name>level</m:name>
<m:title>层级</m:title>
<m:description></m:description>
<m:type>int</m:type>
</m:input>
<m:implementation runtime="java">com.beecode.inz.workflow.participant.DepartmentPicByLevelParticipantStrategy</m:implementation>
</m:participation-strategy>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-participant">
<specification>1.0</specification>
<id>76357756-6acd-40cb-b230-40e9f2f23bbc</id>
<name>com.beecode.inz.workflow.participant.FollowerMemberPicParticipant</name>
<title>团队负责人审批</title>
<define>bcp.participant</define>
<define-version>1.0</define-version>
<content>
<m:participation-strategy>
<m:input>
<m:name>bizTypeName</m:name>
<m:title>业务类型标识</m:title>
<m:description></m:description>
<m:type>string</m:type>
</m:input>
<m:input>
<m:name>bizDataId</m:name>
<m:title>业务数据Id</m:title>
<m:description></m:description>
<m:type>uuid</m:type>
</m:input>
<m:implementation runtime="java">com.beecode.inz.workflow.participant.FollowerMemberPicParticipantStrategy</m:implementation>
</m:participation-strategy>
</content>
</metadata>
<?xml version="1.0" encoding="UTF-8"?>
<metadata xmlns="http://www.beecode.cn/schema/amino-metadata" xmlns:m="http://www.beecode.cn/schema/bcp-participant">
<specification>1.0</specification>
<id>11e95b1b-1a14-4af4-a57a-dc2f8abe4f54</id>
<name>com.beecode.inz.workflow.participant.SubmitDeptPathAppointRoleParticipant</name>
<title>提交人所在部门路径上指定角色</title>
<define>bcp.participant</define>
<define-version>1.0</define-version>
<content>
<m:participation-strategy>
<m:input>
<m:name>submitterId</m:name>
<m:title>提交人Id</m:title>
<m:description></m:description>
<m:type>string</m:type>
</m:input>
<m:input>
<m:name>roles</m:name>
<m:title>角色</m:title>
<m:description>json数组</m:description>
<m:type>string</m:type>
</m:input>
<m:implementation runtime="java">com.beecode.inz.workflow.participant.SubmitDeptPathAppointRoleParticipantStrategy</m:implementation>
</m:participation-strategy>
</content>
</metadata>
......@@ -190,9 +190,9 @@
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>bizProcess.submitter.name</m:name>
<m:title>流程发起人标题</m:title>
<m:type>uuid</m:type>
<m:name>bizProcess.bizTypeName</m:name>
<m:title>流程实例业务类型标识</m:title>
<m:type>string</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
......@@ -200,9 +200,9 @@
<m:desc></m:desc>
</m:field>
<m:field>
<m:name>bizProcess.bizTypeName</m:name>
<m:title>流程实例业务类型标识</m:title>
<m:type>string</m:type>
<m:name>bizProcess.id</m:name>
<m:title>流程实例业务id</m:title>
<m:type>uuid</m:type>
<m:ref>
<m:name></m:name>
<m:type></m:type>
......
......@@ -91,15 +91,19 @@ public class DinasTypeDaoImpl extends AbstractBaseDao implements DinasTypeDao, D
// detachedCriteria.add(Restrictions.eq("del", false));
// detachedCriteria.add(Restrictions.eq("station.id", stationId));
KClass bean = Amino.getStaticMetadataContext().getBean(ENTITY, KClass.class);
KClass bean = Amino.getStaticMetadataContext().getBean(STATION_DINAS_TYPE_DETAIL_ENTITY, KClass.class);
DetachedCriteria detachedCriteria = DetachedCriteria.forEntityName(bean.getName());
addRegionalCompanyFilter(detachedCriteria);
detachedCriteria.add(Restrictions.eq("del", false));
detachedCriteria.createAlias("stations","station");
detachedCriteria.add(Restrictions.eq("station.station.id", stationId));
detachedCriteria.createAlias("station","station");
detachedCriteria.add(Restrictions.eq("station.id", stationId));
detachedCriteria.add(Restrictions.eq("station.del", false));
detachedCriteria.addOrder(Order.desc("sortOrder"));
return (List<KObject>) template.findByCriteria(detachedCriteria);
List<KObject> byCriteria = (List<KObject>) template.findByCriteria(detachedCriteria);
ArrayList<KObject> dinasTypes = new ArrayList<>();
for (KObject byCriterion : byCriteria) {
dinasTypes.add(byCriterion.get("dinasType"));
}
return dinasTypes;
}
@Override
......
......@@ -26,9 +26,6 @@
</m:attribute>
<m:attribute>
<m:annotations>
<m:annotation>
<m:type>bcp.type.json.JsonIgnore</m:type>
</m:annotation>
</m:annotations>
<m:id>61699557-6afc-43c2-adeb-fecfeb844536</m:id>
<m:name>dinasType</m:name>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment