bladex审批流流程图配置和后端代码1.指定到⼈
@Override
@Transactional(rollbackFor = Exception.class)
// @GlobalTransactional
public boolean startProcess(ProcessPurchaseOrder bean) {
//是否启动流程
boolean isStartProcess = false;
//是否新增数据
boolean isAdd = false;
if (bean != null) {
if (Func.ProcessInstanceId())) {
isStartProcess = true;
}
if (Func.Id())) {
isAdd = true;
}
//更新业务数据
if (isAdd) {
Date now = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(now);
if(Func.OrderNumber())){
bean.TenantId(),"purchaseOrder",dateStr,dateStr,5));
}
//第⼀次发起保存数据到采购订单表和订单详情表
save(bean);
//采购订单明细进⼊明细表
PurchaseOrderDetail(), OrderNumber());
} else {
updateById(bean);
//从新发起修改采购订单详细表1.先删除以前的数据,2.从新插⼊新的订单详情
OrderNumber());
PurchaseOrderDetail(), OrderNumber());
}
//更新附件信息
oaAttachmentService.Attachments(),Id(),ProcessInstanceId(),TenantId(),"purchaseOrder"); }
//除了茶叶原物料都⾛主管经理审批
bean.setChanges("01");
System.out.println("urchaseType=================="+PurchaseType());
//茶叶原物料价格没有变动只⾛主管审批
PurchaseType().equals("茶叶") || PurchaseType().equals("原物料")){
if (null != PurchaseOrderDetail() && PurchaseOrderDetail().size() > 0) {
for (ProcessPurchaseOrderDetail processPurchaseOrderDetail : PurchaseOrderDetail()) {
System.out.println("PriceChange()====" + PriceChange());
if (PriceChange().equals("1")) {//01价格有变动 02没有变动
bean.setChanges("01");
break;
}else{
bean.setChanges("02");
}
}
}
}
//获取发起⼈部门id
Long curDeptId = CreateDept());
//获取经理职位
Long managerUser=null;
String TenantId(), "经理");
List<User>UserListByRoleIdAndDeptId(roleId,String.valueOf(curDeptId),false);
if(!Func.isEmpty(users)){
(0).getId();
}
log.info("获取经理职位roleId====="+roleId+"------users========================"+users);
//获取部门总监
String TenantId(), "总监");
List<User>UserListByRoleIdAndDeptId(majorRoleId,String.valueOf(curDeptId),true);
Long generalManager=null;
if(null!=majordomoUsers && majordomoUsers.size()>0){
generalManager =(0).getId();
}
log.info("获取总监majorRoleId===="+majorRoleId+"-----majordomoUsers========================"+majordomoUsers);
//获取总经理
String PostId("总经理",TenantId());
List<User>UserListByPostId(companyBossPostId);//总经理不属于某个部门,不⽤根据部门id查询
Long companyBoss=null;
if(null!=companyBossUsers && companyBossUsers.size()>0){
(0).getId();
}
log.info("获取总经理companyBossPostId====="+companyBossPostId+"-------companyBossUsers===
====================="+companyBossUsers);
//上级主管
roleId = TenantId(),"主管");
boolean isManager = Func.UserRole())&&UserRole().contains("主管")?true:false;
Long lastManagerUserId = null;
if(isManager){
users = UserListByRoleIdAndDeptId(roleId,String.valueOf(curDeptId),UserId());
lastManagerUserId = Func.isEmpty(users)?(0).getId();
}
/**
* 判断条件
*/
//如果发起⼈是总监或者经理不是部门最⾼领导没有的职位跳过经理职位
if(null!=managerUser){
User().getUserId().longValue()==managerUser.longValue()){
managerUser=null;//经理
}
}
//跳过总监
if(null!=generalManager){
//跳过总监
User().getUserId().longValue()==generalManager.longValue()){
//跳过经理
managerUser=null;//经理
//跳过总监职位
generalManager=null;
}
}
Kv variables =ateKV(curDeptId,"采购订单",OrderNumber(),ApplicantName(),CcUser(),CcUserName())
.set("taskUser", User().getUserId().toString()))
.set("category", Category())//申请类型
.set("changes", Changes())//价格是否变动
.set("managerSkip", Func.isEmpty(managerUser))
.set("managerUser",TaskUser(String.valueOf(managerUser==null ? "" : managerUser)))//经理
.set("generalManagerSkip", Func.isEmpty(generalManager))
.set("generalManager",TaskUser(String.valueOf(generalManager==null ? "" : generalManager)))//总监
.set("companyBossSkip",Func.isEmpty(companyBoss))
.set("companyBossUser", TaskUser(String.valueOf(companyBoss==null ? "" : companyBoss)))//总经理
.set("lastManagerSkip",Func.isEmpty(lastManagerUserId))
.set("lastManagerUser",TaskUser(String.valueOf(lastManagerUserId)));
//开启流程
if (isStartProcess) {
String businessTable = BusinessTable(ProcessConstant.PURCHASE_ORDER_KEY);//获取表名
R<BladeFlow> result = flowClient.ProcessDefinitionId(), BusinessKey(businessTable, String.Id())), variables); if (result.isSuccess()) {
log.debug("流程已启动,流程ID:" + Data().getProcessInstanceId());
// 返回流程id写⼊leave
bean.Data().getProcessInstanceId());
updateById(bean);
} else {
throw new ServiceException("开启流程失败");
}
} else {
//开启流程 TaskId ProcessInstanceId
if(!Func.Flow())&&!Func.Flow().getTaskId())&&!Func.ProcessInstanceId())){
spring启动流程面试回答variables.put(ProcessConstant.PASS_KEY, true);
Flow().getTaskId(),ProcessInstanceId(),Flow().getComment(),variables);
}
}
return true;
}
//2.指定到⾓⾊
/*
* Copyright (c) 2018-2028, Chill Zhuang All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
*
* Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* Neither the name of the dreamlu developer nor the names of its
* contributors may be used to endorse or promote products derived from
* this software without specific prior written permission.
* Author: Chill 庄骞 (smallchill@163)
*/
package org.springblade.desk.management.service.impl;
import com.alibaba.fastjson.JSONObject;
import lombok.AllArgsConstructor;
slf4j.Slf4j;
import ption.ServiceException;
import p.base.BaseServiceImpl;
import secure.utils.AuthUtil;
import ool.api.R;
import ool.support.Kv;
import ool.utils.Func;
import org.springblade.stant.AuthorityConstant;
import org.springblade.ity.OaAuthorityManagement;
import org.springblade.desk.management.mapper.OaAuthorityManagementMapper;
import org.springblade.desk.management.service.IOaAuthorityManagementService;
import org.springblade.desk.service.impl.AdjustPriceDetailServiceImpl;
import org.springblade.desk.service.impl.OaSerialServiceImpl;
import org.springblade.desk.utils.DeptUserUtil;
import org.springblade.desk.utils.DeskUtil;
import org.onstant.ProcessConstant;
import org.ntity.BladeFlow;
import org.feign.IFlowClient;
import org.utils.FlowUtil;
import org.utils.TaskUtil;
import org.springblade.ity.User;
import org.springframework.stereotype.Service;
import ansaction.annotation.Transactional;
SimpleDateFormat;
import java.util.Date;
import java.util.List;
/**
* 权限申请单
*
* @author pei
*/
@Slf4j
@Service
@AllArgsConstructor
public class OaAuthorityManagementServiceImpl extends BaseServiceImpl<OaAuthorityManagementMapper, OaAuthorityManagement> implements IOaAuthorityManagementService { private IFlowClient flowClient;
private OaSerialServiceImpl oaSerialService;
private AdjustPriceDetailServiceImpl adjustPriceDetailServiceImpl;
private DeptUserUtil deptUserUtil;
@Override
@Transactional(rollbackFor = Exception.class)
public boolean startProcess(OaAuthorityManagement bean) {
log.info("权限申请单开启流程bean============="+bean);
//是否启动流程
boolean isStartProcess = false;
//是否新增数据
boolean isAdd = false;
if(bean!=null){
if(Func.ProcessInstanceId())){
isStartProcess = true;
}
if(Func.Id())){
isAdd = true;
bean.TenantId());
}
//更新业务数据
if(isAdd){
Date now = new Date();
SimpleDateFormat format = new SimpleDateFormat("yyyyMMdd");
String dateStr = format.format(now);
if(Func.AuthorityManagementNumber())){
bean.TenantId(),"OaAuthorityManagement",dateStr,dateStr,5));
}
}
if(Func.ObjIfo())){
//将系统权限数据转换成string保存⼊库
String str= ObjIfo());
bean.setApplicationSystemValue(str);
}
saveOrUpdate(bean);
}
Long curDeptId = CreateDept());
/
/获取主管
Long managerUser=null;
String TenantId(), "主管");
List<User> UserListByRoleIdAndDeptId(roleId,String.valueOf(curDeptId),UserId());
if(!Func.isEmpty(users)){
(0).getId();
}
log.info("获取主管职位roleId====="+roleId+"------users========================"+users);
//获取it部门审批⼈
//1.根据部门名称获取部门id IT部
String deptId= TenantId(),AuthorityConstant.IT_DEPT_NAME);
String TenantId(), AuthorityConstant.IT_ROLE_NAME);
List<User>UserListByRoleIdAndDeptId(itRoleId,String.valueOf(deptId));
log.info("获取it部门审批⼈itRoleUsers================="+itRoleUsers);
Long itRoleManager=null;
if(null!=itRoleUsers && itRoleUsers.size()>0){
itRoleManager =(0).getId();
}
boolean isManager = Func.UserRole())&&UserRole().contains("主管")?true:false;
// 启动流程
Kv variables =ateKV(curDeptId,"权限申请单",AuthorityManagementNumber(),ApplicationSystem()+","+Remark(),CcUser(),CcUserName()) .
set("taskUser", User().getUserId().toString()))
.set("managerSkip", Func.isEmpty(managerUser))
.set("managerUser",TaskUser(String.valueOf(managerUser==null ? "" : managerUser)))//主管
.set("itRoleManager",AuthorityConstant.IT_ROLE_NAME);//IT审批⼈(⾓⾊名称)
//启动流程 isStartProcess
if (isStartProcess) {//先不开启流程
String businessTable = BusinessTable(ProcessConstant.OA_AUTHORITY_MANAGEMENT);
R<BladeFlow> result = flowClient.ProcessDefinitionId(), BusinessKey(businessTable, String.Id())), variables);
if (result.isSuccess()) {
log.debug("流程已启动,流程ID:" + Data().getProcessInstanceId());
// 返回流程id写⼊业务表中
bean.Data().getProcessInstanceId());
updateById(bean);
} else {
throw new ServiceException("开启流程失败");
}
}
else{
if(!Func.Flow())&&!Func.Flow().getTaskId())&&!Func.ProcessInstanceId())){
variables.put(ProcessConstant.PASS_KEY, true);
Flow().getTaskId(),ProcessInstanceId(),Flow().getComment(),variables);
}
}
return true;
}
}
package org.springblade.stant;
/**
* 2021-01-08
*/
public interface AuthorityConstant {
/
**
* 部门名称
*/
String IT_DEPT_NAME="IT部";
/**
* IT部门⾓⾊
*/
String IT_ROLE_NAME="IT系统权限";
}
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论