Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
A
amos-boot-biz
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
项目统一框架
amos-boot-biz
Commits
7ff2de81
Commit
7ff2de81
authored
Mar 12, 2024
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.使用登记增加限制
parent
48b901aa
Show whitespace changes
Inline
Side-by-side
Showing
12 changed files
with
356 additions
and
26 deletions
+356
-26
ApplicationRunnerImpl.java
...va/com/yeejoin/amos/fas/config/ApplicationRunnerImpl.java
+1
-3
InstanceRuntimeData.java
...join/amos/boot/module/jg/api/dto/InstanceRuntimeData.java
+34
-0
CommonMapper.java
.../yeejoin/amos/boot/module/jg/api/mapper/CommonMapper.java
+2
-0
CommonMapper.xml
...-module-jg-api/src/main/resources/mapper/CommonMapper.xml
+11
-2
RedissonManager.java
...ejoin/amos/boot/module/jg/biz/config/RedissonManager.java
+68
-0
JgChangeRegistrationNameController.java
...jg/biz/controller/JgChangeRegistrationNameController.java
+1
-1
JgUseRegistrationController.java
...module/jg/biz/controller/JgUseRegistrationController.java
+3
-2
ApplicationRunnerImpl.java
...n/amos/boot/module/jg/biz/init/ApplicationRunnerImpl.java
+34
-0
ICommonService.java
...ejoin/amos/boot/module/jg/biz/service/ICommonService.java
+23
-0
CommonServiceImpl.java
...os/boot/module/jg/biz/service/impl/CommonServiceImpl.java
+85
-3
JgChangeRegistrationNameServiceImpl.java
...biz/service/impl/JgChangeRegistrationNameServiceImpl.java
+44
-7
JgUseRegistrationServiceImpl.java
...ule/jg/biz/service/impl/JgUseRegistrationServiceImpl.java
+50
-8
No files found.
amos-boot-module/amos-boot-module-biz/amos-boot-module-fas-biz/src/main/java/com/yeejoin/amos/fas/config/ApplicationRunnerImpl.java
View file @
7ff2de81
...
...
@@ -19,9 +19,7 @@ import org.springframework.stereotype.Component;
public
class
ApplicationRunnerImpl
implements
ApplicationRunner
{
@Autowired
private
IEquipmentHandlerService
equipmentHandlerService
;
@Autowired
private
IContingencyPlanService
contingencyPlanService
;
IC
@Override
public
void
run
(
ApplicationArguments
args
)
throws
Exception
{
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/java/com/yeejoin/amos/boot/module/jg/api/dto/InstanceRuntimeData.java
0 → 100644
View file @
7ff2de81
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jg
.
api
.
dto
;
import
lombok.AllArgsConstructor
;
import
lombok.Builder
;
import
lombok.Data
;
import
lombok.NoArgsConstructor
;
import
java.io.Serializable
;
/**
* @author Administrator
*/
@Data
@Builder
@AllArgsConstructor
@NoArgsConstructor
public
class
InstanceRuntimeData
implements
Serializable
{
/**
* 下一个执行节点id
*/
private
String
nextTaskId
;
/**
* 最近流程执行人
*/
private
String
promoter
;
/**
* 下一节点执行人
*/
private
String
nextExecuteUserIds
;
}
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/java/com/yeejoin/amos/boot/module/jg/api/mapper/CommonMapper.java
View file @
7ff2de81
...
...
@@ -29,6 +29,8 @@ public interface CommonMapper extends BaseMapper<EquipmentCategory> {
String
selectBusinessData
(
String
tableName
,
String
instanceId
);
String
selectPromoterData
(
String
tableName
,
String
instanceId
);
void
updateBusinessData
(
String
tableName
,
String
assignee
,
String
transferToUserIds
,
String
instanceId
,
String
nextTaskId
);
Map
<
String
,
Object
>
getUserPhone
(
String
name
,
String
companyCode
);
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-api/src/main/resources/mapper/CommonMapper.xml
View file @
7ff2de81
...
...
@@ -69,10 +69,11 @@
</select>
<select
id=
"selectBusinessData"
resultType=
"java.lang.String"
>
select transfer_to_user_ids
select
transfer_to_user_ids
from ${tableName}
where instance_id = #{instanceId}
</select>
</select>
<update
id=
"updateBusinessData"
>
update ${tableName}
...
...
@@ -89,5 +90,13 @@
and name = #{name}
AND is_delete = 0
</select>
<select
id=
"selectPromoterData"
resultType=
"java.lang.String"
>
select
promoter
from
${tableName}
where
instance_id = #{instanceId}
</select>
</mapper>
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/config/RedissonManager.java
0 → 100644
View file @
7ff2de81
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jg
.
biz
.
config
;
import
lombok.extern.slf4j.Slf4j
;
import
org.redisson.Redisson
;
import
org.redisson.api.RedissonClient
;
import
org.redisson.config.Config
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.boot.autoconfigure.condition.ConditionalOnProperty
;
import
org.springframework.context.annotation.Bean
;
import
org.springframework.context.annotation.Configuration
;
@Configuration
@Slf4j
public
class
RedissonManager
{
/**
* 集群环境使用-节点信息
*/
@Value
(
"${spring.redis.cluster.nodes:default}"
)
private
String
clusterNodes
;
/**
* 公共-密码
*/
@Value
(
"${spring.redis.password}"
)
private
String
password
;
/**
* 单机环境使用
*/
@Value
(
"${spring.redis.host:default}"
)
private
String
host
;
/**
* 单机环境使用
*/
@Value
(
"${spring.redis.port:default}"
)
private
String
port
;
/**
* 单机环境使用
*/
@Value
(
"${spring.redis.database:0}"
)
private
int
database
;
@Bean
@ConditionalOnProperty
(
name
=
"spring.redis.mode"
,
havingValue
=
"cluster"
)
public
RedissonClient
redissonClient
()
{
// 集群环境使用
Config
config
=
new
Config
();
config
.
useClusterServers
()
.
addNodeAddress
(
clusterNodes
.
split
(
","
))
.
setPassword
(
password
);
return
Redisson
.
create
(
config
);
}
@Bean
@ConditionalOnProperty
(
name
=
"spring.redis.mode"
,
havingValue
=
"singleton"
,
matchIfMissing
=
true
)
public
RedissonClient
redissonSingletonClient
()
{
// 单机环境使用
Config
config
=
new
Config
();
config
.
useSingleServer
().
setAddress
(
host
+
":"
+
port
).
setPassword
(
password
).
setDatabase
(
database
);
return
Redisson
.
create
(
config
);
}
}
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/controller/JgChangeRegistrationNameController.java
View file @
7ff2de81
...
...
@@ -87,7 +87,7 @@ public class JgChangeRegistrationNameController extends BaseController {
@PostMapping
(
value
=
"/withdraw"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"撤回"
,
notes
=
"撤回"
)
public
ResponseModel
<
Object
>
revocation
(
@RequestBody
JSONObject
map
)
{
jgChangeRegistrationNameService
.
revocation
(
String
.
valueOf
(
map
.
get
(
"instanceId"
)));
jgChangeRegistrationNameService
.
revocation
(
String
.
valueOf
(
map
.
get
(
"instanceId"
))
,
String
.
valueOf
(
map
.
get
(
"nextTaskId"
))
);
return
ResponseHelper
.
buildResponse
(
"ok"
);
}
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/controller/JgUseRegistrationController.java
View file @
7ff2de81
...
...
@@ -53,7 +53,8 @@ public class JgUseRegistrationController extends BaseController {
String
.
valueOf
(
map
.
get
(
"instanceId"
)),
String
.
valueOf
(
map
.
get
(
"operate"
)),
String
.
valueOf
(
map
.
get
(
"comment"
)),
String
.
valueOf
(
map
.
getOrDefault
(
"carNumber"
,
""
)));
String
.
valueOf
(
map
.
getOrDefault
(
"carNumber"
,
""
)),
String
.
valueOf
(
map
.
get
(
"nextTaskId"
)));
return
ResponseHelper
.
buildResponse
(
"ok"
);
}
...
...
@@ -62,7 +63,7 @@ public class JgUseRegistrationController extends BaseController {
@PostMapping
(
value
=
"/withdraw"
)
@ApiOperation
(
httpMethod
=
"POST"
,
value
=
"撤回"
,
notes
=
"撤回"
)
public
ResponseModel
<
Object
>
withdraw
(
@RequestBody
JSONObject
map
)
{
jgUseRegistrationServiceImpl
.
withdraw
(
String
.
valueOf
(
map
.
get
(
"instanceId"
)));
jgUseRegistrationServiceImpl
.
withdraw
(
String
.
valueOf
(
map
.
get
(
"instanceId"
))
,
String
.
valueOf
(
map
.
get
(
"nextTaskId"
))
);
return
ResponseHelper
.
buildResponse
(
"ok"
);
}
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/init/ApplicationRunnerImpl.java
0 → 100644
View file @
7ff2de81
package
com
.
yeejoin
.
amos
.
boot
.
module
.
jg
.
biz
.
init
;
import
com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper
;
import
com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration
;
import
com.yeejoin.amos.boot.module.jg.biz.service.impl.CommonServiceImpl
;
import
com.yeejoin.amos.boot.module.jg.biz.service.impl.JgUseRegistrationServiceImpl
;
import
com.yeejoin.amos.boot.module.ymt.api.enums.FlowStatusEnum
;
import
org.springframework.boot.ApplicationArguments
;
import
org.springframework.boot.ApplicationRunner
;
import
org.springframework.stereotype.Component
;
import
java.util.List
;
@Component
public
class
ApplicationRunnerImpl
implements
ApplicationRunner
{
private
JgUseRegistrationServiceImpl
useRegistrationService
;
private
CommonServiceImpl
commonService
;
public
ApplicationRunnerImpl
(
JgUseRegistrationServiceImpl
useRegistrationService
,
CommonServiceImpl
commonService
)
{
this
.
commonService
=
commonService
;
this
.
useRegistrationService
=
useRegistrationService
;
}
@Override
public
void
run
(
ApplicationArguments
args
)
{
// TODO 增加删除启动时, 完成时
List
<
JgUseRegistration
>
jgUseRegistrations
=
useRegistrationService
.
list
(
new
LambdaQueryWrapper
<
JgUseRegistration
>().
ne
(
JgUseRegistration:
:
getStatus
,
FlowStatusEnum
.
TO_BE_FINISHED
.
getName
()));
jgUseRegistrations
.
forEach
(
jgUseRegistration
->
{
commonService
.
saveExecuteFlowData2Redis
(
jgUseRegistration
.
getInstanceId
(),
useRegistrationService
.
buildInstanceRuntimeData
(
jgUseRegistration
));
});
}
}
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/ICommonService.java
View file @
7ff2de81
...
...
@@ -3,6 +3,7 @@ package com.yeejoin.amos.boot.module.jg.biz.service;
import
com.yeejoin.amos.boot.biz.common.bo.CompanyBo
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.module.jg.api.dto.InstanceRuntimeData
;
import
com.yeejoin.amos.boot.module.jg.api.dto.UseFlagParamDto
;
import
com.yeejoin.amos.boot.module.ymt.api.entity.EquipmentCategory
;
...
...
@@ -80,4 +81,26 @@ public interface ICommonService {
void
useFlagGenerate
(
UseFlagParamDto
useFlagParamDto
,
HttpServletResponse
response
);
Map
<
String
,
Object
>
getUserPhone
(
String
name
);
/**
* 执行流程时前置校验
* @param taskId 任务id
* @param instanceId 实例id
*/
void
checkForExecuteFlow
(
String
taskId
,
String
instanceId
);
/**
* 最新流程数据缓存
* @param instanceId 实例id
* @param instanceData 流程数据
*/
void
saveExecuteFlowData2Redis
(
String
instanceId
,
InstanceRuntimeData
instanceData
);
/**
* 撤回时校验
* @param taskId 任务id
* @param instanceId 实例id
*/
void
checkForRevocationFlow
(
String
taskId
,
String
instanceId
);
}
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/CommonServiceImpl.java
View file @
7ff2de81
...
...
@@ -57,6 +57,9 @@ import com.yeejoin.amos.feign.workflow.model.FlowTaskVo;
import
com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO
;
import
lombok.extern.slf4j.Slf4j
;
import
org.apache.commons.lang3.StringUtils
;
import
org.redisson.api.RBucket
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.annotation.Lazy
;
...
...
@@ -212,6 +215,9 @@ public class CommonServiceImpl implements ICommonService {
@Autowired
private
IJgTransferNoticeService
jgTransferNoticeService
;
@Autowired
RedissonClient
redissonClient
;
public
static
byte
[]
file2byte
(
File
file
)
{
try
{
FileInputStream
in
=
new
FileInputStream
(
file
);
...
...
@@ -954,7 +960,16 @@ public class CommonServiceImpl implements ICommonService {
String
instanceId
=
map
.
get
(
"instanceId"
).
toString
();
String
tableName
=
map
.
get
(
"tableName"
).
toString
();
String
assignee
=
map
.
get
(
"assignee"
).
toString
();
String
lockKey
=
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
// 流程执行前置校验
this
.
checkForExecuteFlow
(
taskId
,
instanceId
);
FlowTaskVo
flowTaskVo
=
new
FlowTaskVo
();
flowTaskVo
.
setTaskId
(
taskId
);
flowTaskVo
.
setAssignee
(
assignee
);
...
...
@@ -962,7 +977,7 @@ public class CommonServiceImpl implements ICommonService {
// 修改待办
List
<
TaskV2Model
>
result
=
Systemctl
.
taskV2Client
.
selectListByRelationId
(
instanceId
).
getResult
();
List
<
TaskV2Model
>
collect
=
result
.
stream
().
sorted
((
r1
,
r2
)
->
r2
.
getSequenceNbr
().
compareTo
(
r1
.
getSequenceNbr
())).
collect
(
Collectors
.
toList
());
if
(
collect
==
null
||
collect
.
size
()
==
0
)
{
if
(
collect
.
size
()
==
0
)
{
return
null
;
}
TaskV2Model
taskV2Model
=
collect
.
get
(
0
);
...
...
@@ -992,7 +1007,18 @@ public class CommonServiceImpl implements ICommonService {
id
=
ObjectUtils
.
isEmpty
(
id
)
?
assignee
:
id
+
","
+
assignee
;
// 修改业务数据
commonMapper
.
updateBusinessData
(
tableName
,
assignee
,
id
,
instanceId
,
nextTaskId
);
this
.
saveExecuteFlowData2Redis
(
instanceId
,
InstanceRuntimeData
.
builder
()
.
nextExecuteUserIds
(
assignee
)
.
nextTaskId
(
nextTaskId
)
.
promoter
(
commonMapper
.
selectPromoterData
(
tableName
,
instanceId
)).
build
());
return
Boolean
.
TRUE
;
}
finally
{
if
(
isLocked
){
lock
.
unlock
();
}
}
}
public
void
deleteTaskModel
(
String
id
)
{
...
...
@@ -1391,6 +1417,7 @@ public class CommonServiceImpl implements ICommonService {
return
workflowResultDtoList
;
}
@Override
public
List
<
LinkedHashMap
>
getCompanyUser
(
Long
companyId
)
{
FeignClientResult
result
=
privilegeFeginService
.
getCompanyUser
(
companyId
);
List
<
LinkedHashMap
>
list
=
(
List
<
LinkedHashMap
>)
result
.
getResult
();
...
...
@@ -1446,13 +1473,67 @@ public class CommonServiceImpl implements ICommonService {
/**
* 检查实际状态是否不等于期望状态
*
* @param latestStatus 业务最新状态
*/
public
void
checkExpectedStatus
(
String
latestStatus
)
{
public
void
checkExpectedStatus
(
String
latestStatus
)
{
String
expectedStatus
=
String
.
valueOf
(
FlowStatusEnum
.
TO_BE_PROCESSED
.
getCode
());
// 检查实际状态是否不等于期望状态
if
(!
expectedStatus
.
equals
(
latestStatus
))
{
throw
new
BadRequest
(
"当前业务状态已更新,请返回工作台后重新打开!"
);
}
}
public
static
String
buildJgExecuteLockKey
(
String
instanceId
)
{
return
"JG_INSTANCE_LOCK:"
+
instanceId
;
}
public
static
String
buildJgInstanceDataKey
(
String
instanceId
)
{
return
"JG_INSTANCE_DATA:"
+
instanceId
;
}
@Override
public
void
checkForExecuteFlow
(
String
taskId
,
String
instanceId
)
{
InstanceRuntimeData
instanceRuntimeData
=
getInstanceRuntimeData
(
instanceId
);
if
(
instanceRuntimeData
==
null
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
// 当前任务id与当前任务id不一致时,不让操作,解决老页面没关闭,但是流程已经被被人执行(通过、驳回、撤回),工作流未限制错误
String
currentTaskId
=
instanceRuntimeData
.
getNextTaskId
();
if
(!
taskId
.
equals
(
currentTaskId
))
{
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
// 当前流程已经被转办给其他人或者页面按钮问题导致的权限未控制
String
nextExecuteUserIds
=
instanceRuntimeData
.
getNextExecuteUserIds
();
if
(!
nextExecuteUserIds
.
contains
(
RequestContext
.
getExeUserId
()))
{
throw
new
BadRequest
(
"当前登录人无执行权限!"
);
}
}
private
InstanceRuntimeData
getInstanceRuntimeData
(
String
instanceId
)
{
RBucket
<
InstanceRuntimeData
>
rBucket
=
redissonClient
.
getBucket
(
CommonServiceImpl
.
buildJgInstanceDataKey
(
instanceId
));
return
rBucket
.
get
();
}
@Override
public
void
saveExecuteFlowData2Redis
(
String
instanceId
,
InstanceRuntimeData
instanceData
)
{
redissonClient
.
getBucket
(
CommonServiceImpl
.
buildJgInstanceDataKey
(
instanceId
)).
set
(
instanceData
);
}
@Override
public
void
checkForRevocationFlow
(
String
taskId
,
String
instanceId
)
{
InstanceRuntimeData
instanceRuntimeData
=
getInstanceRuntimeData
(
instanceId
);
if
(
instanceRuntimeData
==
null
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
// 当前任务id与当前任务id不一致时,不让操作,解决老页面没关闭,但是流程已经被被人执行(通过、驳回、撤回),工作流未限制错误
String
currentTaskId
=
instanceRuntimeData
.
getNextTaskId
();
if
(!
taskId
.
equals
(
currentTaskId
))
{
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
if
(!
instanceRuntimeData
.
getPromoter
().
equals
(
RequestContext
.
getExeUserId
())){
throw
new
BadRequest
(
"无权限执行该任务"
);
}
}
}
\ No newline at end of file
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/JgChangeRegistrationNameServiceImpl.java
View file @
7ff2de81
...
...
@@ -11,10 +11,7 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jg.api.dto.JgChangeRegistrationNameDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.TaskMessageDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.*
;
import
com.yeejoin.amos.boot.module.jg.api.entity.*
;
import
com.yeejoin.amos.boot.module.jg.api.enums.BusinessTypeEnum
;
import
com.yeejoin.amos.boot.module.jg.api.enums.WorkFlowStatusEnum
;
...
...
@@ -37,6 +34,8 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowBatchDTO;
import
com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO
;
import
com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO
;
import
com.yeejoin.amos.feign.workflow.model.TaskResultDTO
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.http.HttpStatus
;
...
...
@@ -48,6 +47,7 @@ import org.springframework.util.StringUtils;
import
org.typroject.tyboot.core.foundation.context.RequestContext
;
import
org.typroject.tyboot.core.foundation.utils.ValidationUtil
;
import
org.typroject.tyboot.core.rdbms.service.BaseService
;
import
org.typroject.tyboot.core.restful.exception.instance.BadRequest
;
import
org.typroject.tyboot.core.restful.utils.ResponseModel
;
import
java.util.*
;
...
...
@@ -107,6 +107,9 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
@Autowired
ICmWorkflowService
cmWorkflowService
;
@Autowired
private
RedissonClient
redissonClient
;
private
static
String
template
=
"来自企业(%s)的业务办理,【申请单号:%s】"
;
...
...
@@ -446,7 +449,15 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
}
public
void
revocation
(
String
instanceId
)
{
public
void
revocation
(
String
instanceId
,
String
taskId
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
commonService
.
checkForRevocationFlow
(
taskId
,
instanceId
);
// 执行流程
String
taskCode
=
FlowStatusEnum
.
TO_BE_FINISHED
.
getName
();
JgChangeRegistrationName
jgChangeRegistrationName
=
new
JgChangeRegistrationName
();
...
...
@@ -498,10 +509,19 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
public
void
flowExecute
(
Long
id
,
String
instanceId
,
String
operate
,
String
comment
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
JgChangeRegistrationName
jgChangeRegistrationName
=
this
.
getBaseMapper
().
selectById
(
id
);
String
taskId
=
jgChangeRegistrationName
.
getNextTaskId
();
//组装信息
// 流程执行时,状态及权限校验
commonService
.
checkForExecuteFlow
(
taskId
,
instanceId
);
// 组装信息
TaskResultDTO
dto
=
new
TaskResultDTO
();
dto
.
setResultCode
(
"approvalStatus"
);
dto
.
setTaskId
(
taskId
);
...
...
@@ -519,7 +539,14 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
ProcessTaskDTO
processTaskDTO
=
cmWorkflowService
.
completeOrReject
(
taskId
,
dto
,
operate
);
// 更新下一步执行人、创建待办
updateExecuteIds
(
instanceId
,
id
,
operate
,
processTaskDTO
);
}
finally
{
if
(
isLocked
){
lock
.
unlock
();
}
}
}
private
String
getNextUserOrgCode
(
String
operate
,
JgChangeRegistrationName
jgChangeRegistrationName
)
{
if
(
"0"
.
equals
(
operate
))
{
...
...
@@ -583,9 +610,19 @@ public class JgChangeRegistrationNameServiceImpl extends BaseService<JgChangeReg
// 更新代办
updateTaskModel
(
jgChangeRegistrationName
,
operate
);
}
// 保存redis最新流程数据
commonService
.
saveExecuteFlowData2Redis
(
jgChangeRegistrationName
.
getInstanceId
(),
this
.
buildInstanceRuntimeData
(
jgChangeRegistrationName
));
this
.
getBaseMapper
().
updateById
(
jgChangeRegistrationName
);
}
private
InstanceRuntimeData
buildInstanceRuntimeData
(
JgChangeRegistrationName
jgChangeRegistrationName
)
{
return
InstanceRuntimeData
.
builder
()
.
nextExecuteUserIds
(
jgChangeRegistrationName
.
getNextExecuteUserIds
())
.
promoter
(
jgChangeRegistrationName
.
getPromoter
())
.
nextTaskId
(
jgChangeRegistrationName
.
getNextTaskId
())
.
build
();
}
private
TaskV2Model
updateTaskModel
(
JgChangeRegistrationName
jgChangeRegistrationName
,
String
operate
)
{
Map
<
String
,
Object
>
params
=
new
HashMap
<>();
FlowStatusEnum
flowStatusEnum
=
this
.
getTaskStatus
(
operate
);
...
...
amos-boot-system-tzs/amos-boot-module-jg/amos-boot-module-jg-biz/src/main/java/com/yeejoin/amos/boot/module/jg/biz/service/impl/JgUseRegistrationServiceImpl.java
View file @
7ff2de81
...
...
@@ -13,10 +13,7 @@ import com.yeejoin.amos.boot.biz.common.entity.DataDictionary;
import
com.yeejoin.amos.boot.biz.common.service.impl.DataDictionaryServiceImpl
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.module.jg.api.dto.JgUseRegistrationDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.TaskMessageDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.TaskModelDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.WorkflowResultDto
;
import
com.yeejoin.amos.boot.module.jg.api.dto.*
;
import
com.yeejoin.amos.boot.module.jg.api.entity.JgRegistrationHistory
;
import
com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistration
;
import
com.yeejoin.amos.boot.module.jg.api.entity.JgUseRegistrationEq
;
...
...
@@ -40,6 +37,8 @@ import com.yeejoin.amos.feign.workflow.model.ActWorkflowStartDTO;
import
com.yeejoin.amos.feign.workflow.model.ProcessTaskDTO
;
import
com.yeejoin.amos.feign.workflow.model.TaskResultDTO
;
import
org.apache.commons.collections.CollectionUtils
;
import
org.redisson.api.RLock
;
import
org.redisson.api.RedissonClient
;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Service
;
...
...
@@ -100,6 +99,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
@Autowired
private
IdxBizJgFactoryInfoServiceImpl
idxBizJgFactoryInfoService
;
@Autowired
private
RedissonClient
redissonClient
;
public
Page
<
Map
<
String
,
Object
>>
getList
(
JgUseRegistrationDto
dto
,
Page
<
Map
<
String
,
Object
>>
page
,
List
<
String
>
roleIds
)
{
Page
<
Map
<
String
,
Object
>>
listPage
=
this
.
baseMapper
.
getListPage
(
page
,
dto
,
roleIds
);
return
listPage
;
...
...
@@ -403,7 +405,7 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
if
(!
ObjectUtils
.
isEmpty
(
instanceId
))
{
// 执行流程
flowExecute
(
jgUseRegistration
.
getSequenceNbr
(),
instanceId
,
"0"
,
""
,
""
);
flowExecute
(
jgUseRegistration
.
getSequenceNbr
(),
instanceId
,
"0"
,
""
,
""
,
String
.
valueOf
(
map
.
get
(
"nextTaskId"
))
);
}
}
else
{
ArrayList
<
TaskModelDto
>
list
=
new
ArrayList
<>();
...
...
@@ -555,9 +557,9 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
params
.
put
(
"model"
,
taskMessageDto
);
commonServiceImpl
.
updateTaskModel
(
params
);
}
commonServiceImpl
.
saveExecuteFlowData2Redis
(
jgUseRegistration
.
getInstanceId
(),
this
.
buildInstanceRuntimeData
(
jgUseRegistration
));
this
.
getBaseMapper
().
updateById
(
jgUseRegistration
);
return
jgUseRegistration
;
}
public
void
updateEsData
(
String
usePlace
,
JSONObject
dataMap
,
IdxBizJgOtherInfo
otherInfo
,
JgUseRegistration
jgUseRegistration
)
{
...
...
@@ -582,6 +584,14 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
tzsServiceFeignClient
.
commonUpdateEsDataByIds
(
objMap
);
}
public
InstanceRuntimeData
buildInstanceRuntimeData
(
JgUseRegistration
jgUseRegistration
)
{
return
InstanceRuntimeData
.
builder
()
.
nextExecuteUserIds
(
jgUseRegistration
.
getNextExecuteUserIds
())
.
promoter
(
jgUseRegistration
.
getPromoter
())
.
nextTaskId
(
jgUseRegistration
.
getNextTaskId
())
.
build
();
}
public
void
buildTask
(
JgUseRegistration
jgUseRegistration
,
WorkflowResultDto
workflowResultDto
)
{
// 代办消息
ArrayList
<
TaskModelDto
>
list
=
new
ArrayList
<>();
...
...
@@ -619,7 +629,17 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
public
void
flowExecute
(
Long
id
,
String
instanceId
,
String
operate
,
String
comment
,
String
carNumber
)
{
public
void
flowExecute
(
Long
id
,
String
instanceId
,
String
operate
,
String
comment
,
String
carNumber
,
String
nextTaskId
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
// 流程执行时,状态及权限校验
commonService
.
checkForExecuteFlow
(
nextTaskId
,
instanceId
);
JgUseRegistration
jgUseRegistration
=
this
.
getBaseMapper
().
selectById
(
id
);
// 组装信息
TaskResultDTO
dto
=
new
TaskResultDTO
();
...
...
@@ -647,10 +667,25 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
WorkflowResultDto
workflowResultDto
=
resultDto
.
get
(
0
);
updateData
(
jgUseRegistration
.
getSequenceNbr
(),
operate
,
workflowResultDto
,
Boolean
.
FALSE
,
carNumber
);
}
}
finally
{
if
(
isLocked
){
lock
.
unlock
();
}
}
}
public
void
withdraw
(
String
instanceId
)
{
public
void
withdraw
(
String
instanceId
,
String
nextTaskId
)
{
String
lockKey
=
CommonServiceImpl
.
buildJgExecuteLockKey
(
instanceId
);
RLock
lock
=
redissonClient
.
getLock
(
lockKey
);
boolean
isLocked
=
lock
.
tryLock
();
try
{
// 解决并发问题:多个人同时操作一个流程(并发执行通过、驳回、撤回)
if
(!
isLocked
){
throw
new
BadRequest
(
"当前流程已经被执行!"
);
}
// 撤回校验
commonServiceImpl
.
checkForRevocationFlow
(
nextTaskId
,
instanceId
);
JgUseRegistration
jgUseRegistration
=
new
JgUseRegistration
();
ReginParams
reginParams
=
JSONObject
.
parseObject
(
redisUtils
.
get
(
RedisKey
.
buildReginKey
(
RequestContext
.
getExeUserId
(),
RequestContext
.
getToken
())).
toString
(),
ReginParams
.
class
);
ProcessTaskDTO
processTaskDTO
=
cmWorkflowService
.
rollBack
(
instanceId
);
...
...
@@ -692,6 +727,13 @@ public class JgUseRegistrationServiceImpl extends BaseService<JgUseRegistrationD
}
// 撤回删除代办
commonServiceImpl
.
rollbackTask
(
instanceId
,
jsonObject
);
// redis流程实时数据更新
commonServiceImpl
.
saveExecuteFlowData2Redis
(
instanceId
,
this
.
buildInstanceRuntimeData
(
data
));
}
finally
{
if
(
isLocked
){
lock
.
unlock
();
}
}
}
public
void
deleteBatch
(
List
<
Long
>
ids
)
{
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment