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
6b349ca3
Commit
6b349ca3
authored
Jul 21, 2023
by
suhuiguang
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
1.增加并发锁
parent
9ca5203f
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
102 additions
and
17 deletions
+102
-17
BizCommonConstant.java
...in/amos/boot/module/tcm/api/common/BizCommonConstant.java
+5
-0
IRegUnitInfoService.java
.../boot/module/tcm/flc/api/service/IRegUnitInfoService.java
+6
-0
AmosTcmApplication.java
...iz/src/main/java/com/yeejoin/amos/AmosTcmApplication.java
+2
-0
RegUnitInfoController.java
.../module/tcm/flc/biz/controller/RegUnitInfoController.java
+21
-2
RegUnitInfoServiceImpl.java
...dule/tcm/flc/biz/service/impl/RegUnitInfoServiceImpl.java
+51
-8
UnitInfoServiceImpl.java
.../module/tcm/flc/biz/service/impl/UnitInfoServiceImpl.java
+17
-7
No files found.
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-api/src/main/java/com/yeejoin/amos/boot/module/tcm/api/common/BizCommonConstant.java
View file @
6b349ca3
...
...
@@ -23,4 +23,9 @@ public interface BizCommonConstant {
*/
String
UNIT_TYPE_LIST_REDIS_KEY
=
"UNIT_TYPE_LIST_REDIS_KEY"
;
/**
* 所有字典缓存
*/
String
TCM_ALL_DATA_DICT_REDIS_KEY
=
"TCM_ALL_DATA_DICT_REDIS_KEY"
;
}
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-api/src/main/java/com/yeejoin/amos/boot/module/tcm/flc/api/service/IRegUnitInfoService.java
View file @
6b349ca3
...
...
@@ -73,4 +73,10 @@ public interface IRegUnitInfoService {
RegUnitInfoDto
adminInfo
(
String
unitCode
);
String
submit
(
Long
pageId
,
String
taskId
,
String
planInstanceId
,
String
topic
,
String
tableName
,
Map
<
String
,
Object
>
objectMap
)
throws
Exception
;
List
<
DataDictionary
>
getChildList
(
String
type
,
String
group
);
void
setAllDataDictionaryList
();
List
<
DataDictionary
>
getDictionaryWithTreeFillId
(
String
type
);
}
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/AmosTcmApplication.java
View file @
6b349ca3
...
...
@@ -138,6 +138,8 @@ public class AmosTcmApplication {
unitInfoService
.
getAllRegionTree
();
//5.企业类型放redis缓存(依赖1)
regUnitInfoService
.
setAndGetUnitTypeList
();
//6.许可项目放redis缓存
regUnitInfoService
.
setAllDataDictionaryList
();
}
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/flc/biz/controller/RegUnitInfoController.java
View file @
6b349ca3
...
...
@@ -2,11 +2,14 @@ package com.yeejoin.amos.boot.module.tcm.flc.biz.controller;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSONObject
;
import
com.baomidou.mybatisplus.core.conditions.query.QueryWrapper
;
import
com.yeejoin.amos.boot.biz.common.bo.ReginParams
;
import
com.yeejoin.amos.boot.biz.common.controller.BaseController
;
import
com.yeejoin.amos.boot.biz.common.entity.DataDictionary
;
import
com.yeejoin.amos.boot.biz.common.utils.Menu
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisKey
;
import
com.yeejoin.amos.boot.biz.common.utils.RedisUtils
;
import
com.yeejoin.amos.boot.biz.common.utils.TreeParser
;
import
com.yeejoin.amos.boot.module.tcm.flc.api.dto.RegUnitInfoDto
;
import
com.yeejoin.amos.boot.module.tcm.flc.api.service.IRegUnitInfoService
;
import
com.yeejoin.amos.feign.privilege.Privilege
;
...
...
@@ -135,7 +138,6 @@ public class RegUnitInfoController extends BaseController {
}
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/unit-type/list"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"单位类型列表"
,
notes
=
"单位类型列表"
)
public
ResponseModel
<
List
<
DataDictionary
>>
unitTypeList
()
{
...
...
@@ -144,7 +146,24 @@ public class RegUnitInfoController extends BaseController {
}
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/child-list"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据字典类型type和desc查询字典列表"
,
notes
=
"根据字典类型type和desc查询字典列表"
)
public
ResponseModel
<
List
<
DataDictionary
>>
getChildList
(
@RequestParam
(
value
=
"type"
)
String
type
,
@RequestParam
(
value
=
"group"
)
String
group
)
{
return
ResponseHelper
.
buildResponse
(
iRegUnitInfoService
.
getChildList
(
type
,
group
));
}
@TycloudOperation
(
needAuth
=
false
,
ApiLevel
=
UserType
.
AGENCY
)
@GetMapping
(
value
=
"/dataDictionaryIdFillMenu"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"根据字典类型查询字典,id为SequenceNbr"
,
notes
=
"根据字典类型查询字典,id为SequenceNbr"
)
public
ResponseModel
<
List
<
DataDictionary
>>
getDictionaryWithTreeFillId
(
@RequestParam
String
type
)
{
return
ResponseHelper
.
buildResponse
(
iRegUnitInfoService
.
getDictionaryWithTreeFillId
(
type
));
}
// @TycloudOperation(ApiLevel = UserType.AGENCY, needAuth = false)
@TycloudOperation
(
ApiLevel
=
UserType
.
AGENCY
,
needAuth
=
false
)
@GetMapping
(
value
=
"/management-unit/tree"
)
@ApiOperation
(
httpMethod
=
"GET"
,
value
=
"管辖机构树"
,
notes
=
"管辖机构树"
)
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/flc/biz/service/impl/RegUnitInfoServiceImpl.java
View file @
6b349ca3
...
...
@@ -47,15 +47,12 @@ import org.apache.logging.log4j.Logger;
import
org.springframework.beans.BeanUtils
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.context.ApplicationContext
;
import
org.springframework.mock.web.MockMultipartFile
;
import
org.springframework.scheduling.annotation.Async
;
import
org.springframework.scheduling.annotation.EnableScheduling
;
import
org.springframework.scheduling.annotation.Scheduled
;
import
org.springframework.stereotype.Service
;
import
org.springframework.transaction.annotation.Transactional
;
import
org.springframework.transaction.support.TransactionSynchronization
;
import
org.springframework.transaction.support.TransactionSynchronizationManager
;
import
org.springframework.util.StopWatch
;
import
org.springframework.web.client.RestTemplate
;
import
org.springframework.web.multipart.MultipartFile
;
...
...
@@ -147,7 +144,7 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
private
boolean
isUgp
;
@Autowired
private
ApplicationContext
applicationContext
;
DataDictionaryServiceImpl
dataDictionaryService
;
@Override
@Transactional
(
rollbackFor
=
Exception
.
class
)
...
...
@@ -443,21 +440,67 @@ public class RegUnitInfoServiceImpl extends BaseService<RegUnitInfoDto, RegUnitI
@Override
public
List
<
DataDictionary
>
getUnitTypeList
()
{
return
iDataDictionaryService
.
getByType
(
DICT_TYPE_UNIT_TYPE
);
return
this
.
setAndGetUnitTypeList
(
);
}
public
List
<
DataDictionary
>
setAndGetUnitTypeList
()
{
List
<
DataDictionary
>
dataDictionaries
;
// 先从Redis缓存中获取值
if
(
redisUtil
.
hasKey
(
BizCommonConstant
.
UNIT_TYPE_LIST_REDIS_KEY
)){
dataDictionaries
=
JSONObject
.
parseArray
(
redisUtil
.
get
(
BizCommonConstant
.
UNIT_TYPE_LIST_REDIS_KEY
).
toString
(),
DataDictionary
.
class
);
}
else
{
dataDictionaries
=
iDataDictionaryService
.
getByType
(
DICT_TYPE_UNIT_TYPE
);
redisUtil
.
set
(
BizCommonConstant
.
UNIT_TYPE_LIST_REDIS_KEY
,
JSONObject
.
toJSONString
(
dataDictionaries
));
return
dataDictionaries
;
}
// 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库
synchronized
(
this
){
if
(
redisUtil
.
hasKey
(
BizCommonConstant
.
UNIT_TYPE_LIST_REDIS_KEY
)){
dataDictionaries
=
JSONObject
.
parseArray
(
redisUtil
.
get
(
BizCommonConstant
.
UNIT_TYPE_LIST_REDIS_KEY
).
toString
(),
DataDictionary
.
class
);
}
else
{
dataDictionaries
=
iDataDictionaryService
.
getByType
(
DICT_TYPE_UNIT_TYPE
);
redisUtil
.
set
(
BizCommonConstant
.
UNIT_TYPE_LIST_REDIS_KEY
,
JSONObject
.
toJSONString
(
dataDictionaries
));
}
}
return
dataDictionaries
;
}
@Override
public
List
<
DataDictionary
>
getChildList
(
String
type
,
String
group
)
{
List
<
DataDictionary
>
dictionaries
=
this
.
initAllDataDictionaryList
();
return
dictionaries
.
stream
().
parallel
().
filter
(
d
->
d
.
getType
().
equals
(
type
)
&&
d
.
getTypeDesc
().
equals
(
group
)).
collect
(
Collectors
.
toList
());
}
@Override
public
void
setAllDataDictionaryList
(){
this
.
initAllDataDictionaryList
();
}
@Override
public
List
<
DataDictionary
>
getDictionaryWithTreeFillId
(
String
type
)
{
List
<
DataDictionary
>
dictionaries
=
this
.
initAllDataDictionaryList
();
return
dictionaries
.
stream
().
parallel
().
filter
(
d
->
d
.
getType
().
equals
(
type
)).
collect
(
Collectors
.
toList
());
}
private
List
<
DataDictionary
>
initAllDataDictionaryList
()
{
List
<
DataDictionary
>
dictionaries
;
// 使用双重检查锁定
if
(
redisUtil
.
hasKey
(
BizCommonConstant
.
TCM_ALL_DATA_DICT_REDIS_KEY
))
{
String
json
=
redisUtil
.
get
(
BizCommonConstant
.
TCM_ALL_DATA_DICT_REDIS_KEY
).
toString
();
dictionaries
=
JSONObject
.
parseArray
(
json
,
DataDictionary
.
class
);
return
dictionaries
;
}
synchronized
(
this
)
{
if
(
redisUtil
.
hasKey
(
BizCommonConstant
.
TCM_ALL_DATA_DICT_REDIS_KEY
))
{
String
json
=
redisUtil
.
get
(
BizCommonConstant
.
TCM_ALL_DATA_DICT_REDIS_KEY
).
toString
();
dictionaries
=
JSONObject
.
parseArray
(
json
,
DataDictionary
.
class
);
}
else
{
dictionaries
=
dataDictionaryService
.
list
();
redisUtil
.
set
(
BizCommonConstant
.
TCM_ALL_DATA_DICT_REDIS_KEY
,
JSONObject
.
toJSONString
(
dictionaries
));
}
}
return
dictionaries
;
}
@Override
public
Collection
getManagementUnitTree
(
String
orgCode
)
{
...
...
amos-boot-system-tzs/amos-boot-module-tcm/amos-boot-module-tcm-biz/src/main/java/com/yeejoin/amos/boot/module/tcm/flc/biz/service/impl/UnitInfoServiceImpl.java
View file @
6b349ca3
...
...
@@ -651,17 +651,27 @@ public class UnitInfoServiceImpl extends BaseService<UnitInfoDto, UnitInfo, Unit
return
result
;
}
public
Collection
<
RegionModel
>
getAllRegionTree
(){
Collection
<
RegionModel
>
result
=
null
;
if
(
redisUtil
.
hasKey
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
)){
result
=
JSONObject
.
parseArray
(
redisUtil
.
get
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
).
toString
(),
RegionModel
.
class
);
}
else
{
result
=
Systemctl
.
regionClient
.
queryForTree
(
null
).
getResult
();
redisUtil
.
set
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
,
JSONObject
.
toJSONString
(
result
));
public
Collection
<
RegionModel
>
getAllRegionTree
()
{
Collection
<
RegionModel
>
result
;
// 先从Redis缓存中获取值
if
(
redisUtil
.
hasKey
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
))
{
result
=
JSONObject
.
parseArray
(
redisUtil
.
get
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
).
toString
(),
RegionModel
.
class
);
return
result
;
}
// 在同步块内再次检查缓存,以避免多个线程同时查不到缓存时重复查询数据库
synchronized
(
this
)
{
if
(
redisUtil
.
hasKey
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
))
{
result
=
JSONObject
.
parseArray
(
redisUtil
.
get
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
).
toString
(),
RegionModel
.
class
);
}
else
{
result
=
Systemctl
.
regionClient
.
queryForTree
(
null
).
getResult
();
redisUtil
.
set
(
BizCommonConstant
.
REGION_TREE_REDIS_KEY
,
JSONObject
.
toJSONString
(
result
));
}
}
return
result
;
}
/**
* 去区域树中level多余空格
* @param result
...
...
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