@ -159,7 +159,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
* /
* /
@Override
@Override
@Transactional ( rollbackFor = Exception . class )
@Transactional ( rollbackFor = Exception . class )
public boolean completeTask ( CompleteTaskBo completeTaskBo ) {
public String completeTask ( CompleteTaskBo completeTaskBo ) {
try {
try {
// 获取任务ID并查询对应的流程任务和实例信息
// 获取任务ID并查询对应的流程任务和实例信息
Long taskId = completeTaskBo . getTaskId ( ) ;
Long taskId = completeTaskBo . getTaskId ( ) ;
@ -217,7 +217,7 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
}
}
//设置下一环节处理人
//设置下一环节处理人
setNextHandler ( ins . getId ( ) ) ;
setNextHandler ( ins . getId ( ) ) ;
return true ;
return String . valueOf ( ins . getId ( ) ) ;
} catch ( Exception e ) {
} catch ( Exception e ) {
log . error ( e . getMessage ( ) , e ) ;
log . error ( e . getMessage ( ) , e ) ;
throw new ServiceException ( e . getMessage ( ) ) ;
throw new ServiceException ( e . getMessage ( ) ) ;
@ -713,9 +713,9 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
Task task = taskService . getById ( taskId ) ;
Task task = taskService . getById ( taskId ) ;
FlowNode flowNode = getByNodeCode ( task . getNodeCode ( ) , task . getDefinitionId ( ) ) ;
FlowNode flowNode = getByNodeCode ( task . getNodeCode ( ) , task . getDefinitionId ( ) ) ;
if ( "addSignature" . equals ( taskOperation ) | | "reductionSignature" . equals ( taskOperation ) ) {
if ( "addSignature" . equals ( taskOperation ) | | "reductionSignature" . equals ( taskOperation ) ) {
if ( flowNode . getNodeRatio ( ) . compareTo ( BigDecimal . ZERO ) = = 0 ) {
// if (flowNode.getNodeRatio().compareTo(BigDecimal.ZERO) == 0) {
throw new ServiceException ( task . getNodeName ( ) + "不是会签节点!" ) ;
// throw new ServiceException(task.getNodeName() + "不是会签节点!");
}
// }
}
}
// 设置任务状态并执行对应的任务操作
// 设置任务状态并执行对应的任务操作
switch ( taskOperation ) {
switch ( taskOperation ) {
@ -864,7 +864,8 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
completeTaskBo . setTaskId ( taskId ) ;
completeTaskBo . setTaskId ( taskId ) ;
completeTaskBo . setMessageType ( List . of ( MessageTypeEnum . SYSTEM_MESSAGE . getCode ( ) ) ) ;
completeTaskBo . setMessageType ( List . of ( MessageTypeEnum . SYSTEM_MESSAGE . getCode ( ) ) ) ;
IFlwTaskService service = applicationContext . getBean ( IFlwTaskService . class ) ;
IFlwTaskService service = applicationContext . getBean ( IFlwTaskService . class ) ;
return service . completeTask ( completeTaskBo ) ;
service . completeTask ( completeTaskBo ) ;
return true ;
}
}
/ * *
/ * *
@ -880,4 +881,70 @@ public class FlwTaskServiceImpl implements IFlwTaskService {
. eq ( FlowNode : : getDefinitionId , definitionId ) ) ;
. eq ( FlowNode : : getDefinitionId , definitionId ) ) ;
}
}
@Override
public Boolean addSign ( Long instanceId ) {
try {
List < FlowTask > flowTasks = selectByInstId ( instanceId ) ;
FlowTask flowTask1 = flowTasks . getFirst ( ) ;
//判断是否有人员,进行加签
//获取当前任务的办理人
List < RemoteUserVo > currentTaskUser = currentTaskAllUser ( flowTask1 . getId ( ) ) ;
FlowTask flowTask = flowTaskMapper . selectById ( flowTask1 . getId ( ) ) ;
if ( ObjectUtil . isNull ( flowTask ) ) {
throw new ServiceException ( "流程任务不存在或任务已审批!" ) ;
}
Instance ins = insService . getById ( flowTask . getInstanceId ( ) ) ;
//根据配置的人员查询系统中的用户
Long definitionId = ins . getDefinitionId ( ) ;
String nodeCode = ins . getNodeCode ( ) ;
Integer nodeType = ins . getNodeType ( ) ;
List < String > permissionUser = this . flwTaskMapper . getPermissionFlag ( definitionId , nodeCode , nodeType ) ;
String first = permissionUser . getFirst ( ) ;
List < RemoteUserVo > totalUser = new ArrayList < > ( ) ;
if ( ! first . contains ( "${handler}" ) ) {
String [ ] split = first . split ( "@@" ) ;
for ( String handleFlag : split ) {
List < RemoteUserVo > remoteUserVos = flwTaskAssigneeService . fetchUsersByStorageId ( handleFlag ) ;
totalUser . addAll ( remoteUserVos ) ;
}
}
//比较差值
List < RemoteUserVo > different = totalUser . stream ( )
. filter ( user - > currentTaskUser . stream ( ) . noneMatch ( u - > u . getUserId ( ) . equals ( user . getUserId ( ) ) ) )
. toList ( ) ;
List < String > userIds = different . stream ( )
. map ( RemoteUserVo : : getUserId )
. distinct ( )
. map ( String : : valueOf )
. toList ( ) ;
//加签
if ( ObjectUtil . isNotEmpty ( userIds ) ) {
TaskOperationBo taskOperationBo = new TaskOperationBo ( ) ;
taskOperationBo . setUserIds ( userIds ) ;
taskOperationBo . setTaskId ( flowTask1 . getId ( ) ) ;
IFlwTaskService flwTaskService = applicationContext . getBean ( IFlwTaskService . class ) ;
flwTaskService . taskOperation ( taskOperationBo , "addSignature" ) ;
}
return true ;
} catch ( Exception e ) {
e . printStackTrace ( ) ;
log . error ( e . getMessage ( ) , e ) ;
return false ;
}
}
}
}