Skip to content
切换导航条
切换导航条
当前项目
正在载入...
登录
孙克
/
smf-core
转到一个项目
切换导航栏
切换导航栏固定状态
项目
群组
代码片段
帮助
项目
活动
版本库
流水线
图表
问题
0
合并请求
0
维基
网络
创建新的问题
作业
提交
问题看板
文件
提交
网络
比较
分支
标签
Commit ccabc300
由
LN
编写于
2021-10-13 14:50:15 +0800
浏览文件
选项
浏览文件
标签
下载
电子邮件补丁
差异文件
1.接口权限验证功能调整
2.工单查询bug修改 3.增加策略出库获取库存接口
1 个父辈
46844897
隐藏空白字符变更
内嵌
并排
正在显示
26 个修改的文件
包含
451 行增加
和
105 行删除
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
src/main/java/com/neotel/smfcore/common/utils/PermissionInitUtil.java
src/main/java/com/neotel/smfcore/common/utils/QueryHelp.java
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
src/main/java/com/neotel/smfcore/core/order/rest/OrderController.java
src/main/java/com/neotel/smfcore/core/order/rest/bean/dto/OrderDto.java
src/main/java/com/neotel/smfcore/core/order/rest/bean/query/OrderQueryCondition.java
src/main/java/com/neotel/smfcore/core/order/service/po/LiteOrder.java
src/main/java/com/neotel/smfcore/core/storage/bean/InventoryItem.java
src/main/java/com/neotel/smfcore/core/storage/rest/LabelController.java
src/main/java/com/neotel/smfcore/core/storage/rest/MaterialController.java
src/main/java/com/neotel/smfcore/core/storage/rest/StorageController.java
src/main/java/com/neotel/smfcore/core/storage/rest/StoragePosController.java
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
src/main/java/com/neotel/smfcore/core/system/rest/TaskController.java
src/main/java/com/neotel/smfcore/security/config/ElPermissionConfig.java
src/main/java/com/neotel/smfcore/security/rest/GroupController.java
src/main/java/com/neotel/smfcore/security/rest/MenuController.java
src/main/java/com/neotel/smfcore/security/rest/RoleController.java
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
src/main/java/com/neotel/smfcore/security/service/dao/impl/MenuDaoImpl.java
src/main/java/com/neotel/smfcore/security/service/manager/IGroupManager.java
src/main/java/com/neotel/smfcore/security/service/manager/IMenuManager.java
src/main/java/com/neotel/smfcore/security/service/manager/impl/GroupManagerImpl.java
src/main/java/com/neotel/smfcore/security/service/manager/impl/MenuManagerImpl.java
src/main/java/com/neotel/smfcore/security/service/po/Menu.java
src/main/java/com/neotel/smfcore/common/init/DataInitManager.java
查看文件 @
ccabc30
package
com
.
neotel
.
smfcore
.
common
.
init
;
import
com.neotel.smfcore.common.utils.PermissionInitUtil
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.UserCodeUtil
;
import
com.neotel.smfcore.core.system.service.manager.IDataLogManager
;
...
...
@@ -32,6 +33,8 @@ import java.util.concurrent.TimeUnit;
@Component
public
class
DataInitManager
{
public
static
Set
<
String
>
allPermissionSet
;
@Autowired
IUserManager
userManager
;
@Autowired
...
...
@@ -45,6 +48,8 @@ public class DataInitManager {
@Autowired
IDataLogManager
dataLogManager
;
@Autowired
PermissionInitUtil
annotationUtil
;
@PostConstruct
public
void
DataInit
()
{
...
...
@@ -98,6 +103,7 @@ public class DataInitManager {
initTask
();
allPermissionSet
=
annotationUtil
.
initPermission
();
}
catch
(
Exception
exception
)
{
log
.
error
(
"初始化环境出错..."
+
exception
.
toString
());
}
...
...
@@ -132,7 +138,7 @@ public class DataInitManager {
pMenu
=
menuManager
.
saveMenu
(
pMenu
);
list
.
add
(
pMenu
);
list
.
addAll
(
createSubPerMenus
(
pMenu
));
//
list.addAll(createSubPerMenus(pMenu));
if
(
subMenus
.
length
>
0
)
{
int
i
=
0
;
...
...
@@ -145,41 +151,41 @@ public class DataInitManager {
subm
.
setPid
(
pMenu
.
getId
());
subm
=
menuManager
.
saveMenu
(
subm
);
list
.
add
(
subm
);
list
.
addAll
(
createSubPerMenus
(
subm
));
//
list.addAll(createSubPerMenus(subm));
}
}
return
list
;
}
private
List
<
Menu
>
createSubPerMenus
(
Menu
menu
)
{
List
<
Menu
>
list
=
new
ArrayList
<>();
//如果是list结尾的,默认前缀菜单
Map
<
String
,
String
[]>
defaultMenus
=
new
HashMap
<>();
defaultMenus
.
put
(
"boxkanban"
,
new
String
[]{
"boxkanban:info"
,
"boxkanban:list"
});
defaultMenus
.
put
(
"sensorShelf"
,
new
String
[]{
"sensorShelf:putIn"
});
defaultMenus
.
put
(
"menu"
,
new
String
[]{
"menu:edit"
,
"menu:del"
,
"menu:add"
});
defaultMenus
.
put
(
"user"
,
new
String
[]{});
defaultMenus
.
put
(
"role"
,
new
String
[]{});
String
per
=
menu
.
getPermission
().
replace
(
":list"
,
""
);
String
menuName
=
menu
.
getTitle
().
replace
(
"管理"
,
""
);
if
(!
defaultMenus
.
containsKey
(
per
))
{
defaultMenus
.
put
(
per
,
new
String
[]{
per
});
// return list;
}
String
[]
subPers
=
defaultMenus
.
get
(
per
);
if
(
subPers
.
length
<=
0
)
{
// subPers = new String[]{per + ":edit", per + ":del", per + ":add"};
subPers
=
new
String
[]{
per
+
":manager"
};
}
for
(
String
subPer
:
subPers
)
{
String
title
=
"权限_"
+
menuName
+
"_"
+
subPer
;
Menu
subperMenu
=
menuManager
.
save
(
Menu
.
CreatePerMenu
(
subPer
,
title
,
menu
.
getId
()));
list
.
add
(
subperMenu
);
}
return
list
;
}
//
private List<Menu> createSubPerMenus(Menu menu) {
//
List<Menu> list = new ArrayList<>();
//
//如果是list结尾的,默认前缀菜单
//
Map<String, String[]> defaultMenus = new HashMap<>();
//
defaultMenus.put("boxkanban",new String[]{"boxkanban:info","boxkanban:list"});
//
defaultMenus.put("sensorShelf",new String[]{"sensorShelf:putIn"});
//
defaultMenus.put("menu", new String[]{"menu:edit", "menu:del", "menu:add"});
//
defaultMenus.put("user",new String[]{});
//
defaultMenus.put("role",new String[]{});
//
//
String per = menu.getPermission().replace(":list", "");
//
String menuName = menu.getTitle().replace("管理", "");
//
if (!defaultMenus.containsKey(per)) {
//
defaultMenus.put(per,new String[]{per});
//
//
return list;
//
}
//
String[] subPers = defaultMenus.get(per);
//
if (subPers.length <= 0) {
//
//
subPers = new String[]{per + ":edit", per + ":del", per + ":add"};
//
subPers = new String[]{per+":manager" };
//
}
//
for (String subPer :
//
subPers) {
//
String title="权限_"+menuName+"_"+subPer;
//
Menu subperMenu = menuManager.save(Menu.CreatePerMenu(subPer, title, menu.getId()));
//
list.add(subperMenu);
//
}
//
return list;
//
}
private
Set
<
String
>
MenuInitNew
()
{
...
...
@@ -197,9 +203,9 @@ public class DataInitManager {
//出库:工单,查找出库
Menu
poutOut
=
Menu
.
CreatePMenu
(
"物料管理"
,
20
,
"order"
,
2
,
"workOrder"
);
Menu
menuOrder
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"workOrder"
,
"工单出库"
,
1
,
"workOrder"
,
"neolight/workOrder/index"
,
""
,
0
,
"workOrder"
);
Menu
menuOut
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"
menu:lis
t"
,
"查找出库"
,
1
,
"singleOuput"
,
"neolight/singleOuput/index"
,
""
,
0
,
"export1"
);
Menu
celueOut
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"
menu:lis
t"
,
"策略出库"
,
1
,
"tacticsOuput"
,
"neolight/tacticsOuput/index"
,
""
,
0
,
"workOrder"
);
Menu
groupOut
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"
menu:lis
t"
,
"物料分组"
,
1
,
"labelOuput"
,
"neolight/labelOuput/index"
,
""
,
0
,
"export1"
);
Menu
menuOut
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"
checkOu
t"
,
"查找出库"
,
1
,
"singleOuput"
,
"neolight/singleOuput/index"
,
""
,
0
,
"export1"
);
Menu
celueOut
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"
tacticsOupu
t"
,
"策略出库"
,
1
,
"tacticsOuput"
,
"neolight/tacticsOuput/index"
,
""
,
0
,
"workOrder"
);
Menu
groupOut
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"
labelOupu
t"
,
"物料分组"
,
1
,
"labelOuput"
,
"neolight/labelOuput/index"
,
""
,
0
,
"export1"
);
celueOut
.
setHidden
(
true
);
groupOut
.
setHidden
(
true
);
menus
.
addAll
(
createMenus
(
poutOut
,
menuOrder
,
menuOut
,
celueOut
,
groupOut
));
...
...
@@ -210,8 +216,8 @@ public class DataInitManager {
Menu
menuStoragePos
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"storagePos:list"
,
"库位管理"
,
1
,
"storagePos"
,
"storagePos/storagePos/index"
,
""
,
0
,
"tree-table"
);
Menu
menuMenu
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"menu:list"
,
"菜单管理"
,
1
,
"menu"
,
"system/menu/index"
,
""
,
0
,
"menu"
);
Menu
sysSetting
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"barcode"
,
"条码设置"
,
1
,
"barcodeSetting"
,
"system/barcodeSetting/index"
,
""
,
0
,
"database"
);
Menu
outSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"outSetting"
,
"出库策略"
,
1
,
"outSetting"
,
"system/outSetting/index"
,
""
,
0
,
"
system
"
);
Menu
sysSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"sysSetting"
,
"系统设置"
,
1
,
"sysSetting"
,
"system/sysSetting/index"
,
""
,
0
,
"sys
tem
"
);
Menu
outSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"outSetting"
,
"出库策略"
,
1
,
"outSetting"
,
"system/outSetting/index"
,
""
,
0
,
"
outSetting
"
);
Menu
sysSet
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"sysSetting"
,
"系统设置"
,
1
,
"sysSetting"
,
"system/sysSetting/index"
,
""
,
0
,
"sys
Setting
"
);
menuMenu
.
setHidden
(
true
);
outSet
.
setHidden
(
true
);
sysSet
.
setHidden
(
true
);
...
...
@@ -228,7 +234,7 @@ public class DataInitManager {
//日志管理:物料日志
Menu
pMenuLog
=
Menu
.
CreatePMenu
(
"日志管理"
,
30
,
"log"
,
2
,
"log"
);
Menu
menuLog
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"taskLog
:list
"
,
"物料日志"
,
1
,
"taskLog"
,
"neolight/taskLog/index"
,
""
,
0
,
"education"
);
Menu
menuLog
=
new
Menu
(
new
ArrayList
<
Menu
>(),
1
,
"taskLog"
,
"物料日志"
,
1
,
"taskLog"
,
"neolight/taskLog/index"
,
""
,
0
,
"education"
);
menus
.
addAll
(
createMenus
(
pMenuLog
,
menuLog
));
//用户管理:用户管理,角色管理
...
...
src/main/java/com/neotel/smfcore/common/utils/PermissionInitUtil.java
0 → 100644
查看文件 @
ccabc30
package
com
.
neotel
.
smfcore
.
common
.
utils
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.collect.Lists
;
import
com.neotel.smfcore.security.service.manager.IMenuManager
;
import
com.neotel.smfcore.security.service.po.Menu
;
import
io.swagger.annotations.ApiOperation
;
import
lombok.Data
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Value
;
import
org.springframework.core.io.Resource
;
import
org.springframework.core.io.ResourceLoader
;
import
org.springframework.core.io.support.ResourcePatternResolver
;
import
org.springframework.core.io.support.ResourcePatternUtils
;
import
org.springframework.core.type.AnnotationMetadata
;
import
org.springframework.core.type.MethodMetadata
;
import
org.springframework.core.type.classreading.CachingMetadataReaderFactory
;
import
org.springframework.core.type.classreading.MetadataReader
;
import
org.springframework.core.type.classreading.MetadataReaderFactory
;
import
org.springframework.security.access.prepost.PreAuthorize
;
import
org.springframework.stereotype.Component
;
import
org.springframework.web.bind.annotation.*
;
import
java.util.*
;
/**
* @Author weiwenbin
* @Date 2020/5/14 下午5:31
*/
@Component
@Slf4j
public
class
PermissionInitUtil
{
@Autowired
private
ResourceLoader
resourceLoader
;
@Autowired
private
IMenuManager
menuManager
;
private
static
final
String
VALUE
=
"value"
;
public
Set
<
String
>
initPermission
()
{
Set
<
String
>
permissionSet
=
new
HashSet
<>();
try
{
List
<
Menu
>
menus
=
menuManager
.
findAll
();
menus
.
forEach
(
menu
->
{
// if (!menu.getType().equals(2)) {
permissionSet
.
add
(
menu
.
getPermission
());
if
(
menu
.
getPermission
().
contains
(
":"
))
{
String
[]
array
=
menu
.
getPermission
().
split
(
":"
);
if
(
array
.
length
>=
1
)
{
permissionSet
.
add
(
array
[
0
]);
}
}
// }
});
List
<
String
>
perList
=
new
ArrayList
<>();
Map
<
String
,
TBPer
>
allAddTagAnnotationUrl
=
getAllAddTagAnnotationUrl
(
"classpath*:com/neotel/smfcore/**/*.class"
,
PreAuthorize
.
class
);
for
(
TBPer
tb
:
allAddTagAnnotationUrl
.
values
())
{
for
(
String
per
:
tb
.
getCheckList
())
{
if
(!
perList
.
contains
(
per
))
{
per
.
replace
(
'\''
,
' '
).
trim
();
perList
.
add
(
per
);
}
}
}
log
.
info
(
"共加载到【"
+
perList
.
size
()
+
"】条权限"
);
for
(
String
hasP
:
perList
)
{
if
(
permissionSet
.
contains
(
hasP
))
{
}
else
{
String
[]
array
=
hasP
.
split
(
":"
);
if
(
array
.
length
>=
1
&&
permissionSet
.
contains
(
array
[
0
]))
{
}
else
{
log
.
info
(
"未找到权限【"
+
hasP
+
"】"
);
}
}
}
}
catch
(
Exception
ex
)
{
log
.
error
(
ex
.
getMessage
());
}
return
permissionSet
;
}
/**
* 获取指定包下所有添加了执行注解的方法信息
* @param classPath 包名
* @param tagAnnotationClass 指定注解类型
* @param <T>
* @return
* @throws Exception
*/
public
<
T
>
Map
<
String
,
TBPer
>
getAllAddTagAnnotationUrl
(
String
classPath
,
Class
<
T
>
tagAnnotationClass
)
throws
Exception
{
Map
<
String
,
TBPer
>
resMap
=
new
HashMap
<>();
ResourcePatternResolver
resolver
=
ResourcePatternUtils
.
getResourcePatternResolver
(
resourceLoader
);
MetadataReaderFactory
metaReader
=
new
CachingMetadataReaderFactory
(
resourceLoader
);
Resource
[]
resources
=
resolver
.
getResources
(
classPath
);
for
(
org
.
springframework
.
core
.
io
.
Resource
r
:
resources
)
{
try
{
MetadataReader
reader
=
metaReader
.
getMetadataReader
(
r
);
resMap
=
resolveClass
(
reader
,
resMap
,
tagAnnotationClass
);
}
catch
(
Exception
ex
){
log
.
error
(
"resolveClass "
+
r
.
getFilename
()+
" 出错:"
+
ex
.
toString
());
}
}
return
resMap
;
}
private
<
T
>
Map
<
String
,
TBPer
>
resolveClass
(
MetadataReader
reader
,
Map
<
String
,
TBPer
>
resMap
,
Class
<
T
>
tagAnnotationClass
)
throws
Exception
{
String
tagAnnotationClassCanonicalName
=
tagAnnotationClass
.
getCanonicalName
();
String
describeClassCanonicalName
=
ApiOperation
.
class
.
getCanonicalName
();
//获取注解元数据
AnnotationMetadata
annotationMetadata
=
reader
.
getAnnotationMetadata
();
//获取类中RequestMapping注解的属性
Map
<
String
,
Object
>
annotationAttributes
=
annotationMetadata
.
getAnnotationAttributes
(
RequestMapping
.
class
.
getCanonicalName
());
//若类无RequestMapping注解
if
(
annotationAttributes
==
null
)
return
resMap
;
//获取RequestMapping注解的value
String
[]
pathParents
=
(
String
[])
annotationAttributes
.
get
(
VALUE
);
if
(
0
==
pathParents
.
length
)
return
resMap
;
//获取RequestMapping注解的value
String
pathParent
=
pathParents
[
0
];
//获取当前类中已添加要扫描注解的方法
Set
<
MethodMetadata
>
annotatedMethods
=
annotationMetadata
.
getAnnotatedMethods
(
tagAnnotationClassCanonicalName
);
for
(
MethodMetadata
annotatedMethod
:
annotatedMethods
)
{
//获取当前方法中要扫描注解的属性
Map
<
String
,
Object
>
targetAttr
=
annotatedMethod
.
getAnnotationAttributes
(
tagAnnotationClassCanonicalName
);
//获取当前方法中要xxxMapping注解的属性
Map
<
String
,
Object
>
mappingAttr
=
getPathByMethod
(
annotatedMethod
);
if
(
mappingAttr
==
null
)
{
continue
;
}
String
[]
childPath
=
(
String
[])
mappingAttr
.
get
(
VALUE
);
if
(
targetAttr
==
null
||
childPath
==
null
||
childPath
.
length
==
0
)
{
continue
;
}
String
path
=
pathParent
+
childPath
[
0
];
try
{
Map
<
String
,
Object
>
desccribeAttr
=
annotatedMethod
.
getAnnotationAttributes
(
describeClassCanonicalName
);
String
desc
=
(
String
)
desccribeAttr
.
get
(
VALUE
);
List
<
String
>
tList
=
new
ArrayList
<>();
String
targetChildAttr
=
(
String
)
targetAttr
.
get
(
VALUE
);
String
targetStr
=
targetChildAttr
;
if
(
targetStr
.
contains
(
"@el.check"
))
{
int
endIndex
=
targetStr
.
length
()
-
2
;
targetStr
=
targetStr
.
substring
(
11
,
endIndex
);
String
[]
targetArray
=
targetStr
.
split
(
"','"
);
tList
=
Lists
.
newArrayList
(
targetArray
);
}
boolean
isHas
=
resMap
.
containsKey
(
path
);
if
(
isHas
)
{
// throw new Exception("重复定义了相同的映射关系");
log
.
error
(
"重复定义了相同的映射关系:"
+
path
);
continue
;
}
TBPer
tbPer
=
new
TBPer
();
tbPer
.
setPath
(
path
);
tbPer
.
setDescribe
(
desc
);
tbPer
.
setCheckList
(
tList
);
resMap
.
put
(
path
,
tbPer
);
}
catch
(
Exception
ex
)
{
log
.
error
(
"解析 path="
+
path
+
" 出错: "
+
ex
.
toString
());
}
}
return
resMap
;
}
private
Map
<
String
,
Object
>
getPathByMethod
(
MethodMetadata
annotatedMethod
)
{
Map
<
String
,
Object
>
annotationAttributes
=
annotatedMethod
.
getAnnotationAttributes
(
GetMapping
.
class
.
getCanonicalName
());
if
(
annotationAttributes
!=
null
&&
annotationAttributes
.
get
(
VALUE
)
!=
null
)
{
if
(
ObjectUtil
.
isEmpty
(
annotationAttributes
.
get
(
VALUE
))){
annotationAttributes
.
put
(
VALUE
,
new
String
[]{
"/get"
});
}
return
annotationAttributes
;
}
annotationAttributes
=
annotatedMethod
.
getAnnotationAttributes
(
PostMapping
.
class
.
getCanonicalName
());
if
(
annotationAttributes
!=
null
&&
annotationAttributes
.
get
(
VALUE
)
!=
null
)
{
if
(
ObjectUtil
.
isEmpty
(
annotationAttributes
.
get
(
VALUE
))){
annotationAttributes
.
put
(
VALUE
,
new
String
[]{
"/post"
});
}
return
annotationAttributes
;
}
annotationAttributes
=
annotatedMethod
.
getAnnotationAttributes
(
DeleteMapping
.
class
.
getCanonicalName
());
if
(
annotationAttributes
!=
null
&&
annotationAttributes
.
get
(
VALUE
)
!=
null
)
{
if
(
ObjectUtil
.
isEmpty
(
annotationAttributes
.
get
(
VALUE
))){
annotationAttributes
.
put
(
VALUE
,
new
String
[]{
"/delete"
});
}
return
annotationAttributes
;
}
annotationAttributes
=
annotatedMethod
.
getAnnotationAttributes
(
PutMapping
.
class
.
getCanonicalName
());
if
(
annotationAttributes
!=
null
&&
annotationAttributes
.
get
(
VALUE
)
!=
null
)
{
if
(
ObjectUtil
.
isEmpty
(
annotationAttributes
.
get
(
VALUE
))){
annotationAttributes
.
put
(
VALUE
,
new
String
[]{
"/put"
});
}
return
annotationAttributes
;
}
annotationAttributes
=
annotatedMethod
.
getAnnotationAttributes
(
RequestMapping
.
class
.
getCanonicalName
());
return
annotationAttributes
;
}
@Data
public
class
TBPer
{
String
path
;
String
describe
;
List
<
String
>
checkList
;
}
}
src/main/java/com/neotel/smfcore/common/utils/QueryHelp.java
查看文件 @
ccabc30
...
...
@@ -88,7 +88,8 @@ public class QueryHelp {
case
NIN:
if
(
CollUtil
.
isNotEmpty
((
Collection
<
Object
>)
val
))
{
//criteria = criteria.and(attributeName).nin((Collection<Object>) val);
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
nin
(
val
));
Object
[]
array
=
((
Collection
<
Object
>)
val
).
toArray
();
allCriteria
.
add
(
Criteria
.
where
(
attributeName
).
nin
(
array
));
}
break
;
case
NE:
...
...
src/main/java/com/neotel/smfcore/core/device/util/DataCache.java
查看文件 @
ccabc30
package
com
.
neotel
.
smfcore
.
core
.
device
.
util
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.google.common.base.Strings
;
import
com.google.common.collect.Lists
;
import
com.google.common.collect.Maps
;
...
...
@@ -364,9 +365,16 @@ public class DataCache {
/**
* 获取库存信息,key 为 PN
*/
public
Map
<
String
,
InventoryItem
>
getAllInventory
(){
public
Map
<
String
,
InventoryItem
>
getAllInventory
(
List
<
String
>
storageIds
){
Map
<
String
,
Storage
>
allStorages
=
getAllStorage
();
return
getInventory
(
allStorages
.
values
());
List
<
Storage
>
storages
=
Lists
.
newArrayList
();
for
(
Storage
storage
:
allStorages
.
values
())
{
if
(
storageIds
.
contains
(
storage
.
getId
())){
storages
.
add
(
storage
);
}
}
return
getInventory
(
storages
);
}
/**
...
...
@@ -377,16 +385,21 @@ public class DataCache {
for
(
Storage
storage
:
storageList
)
{
Map
<
String
,
InventoryItem
>
storageInventory
=
getStorageInventory
(
storage
.
getCid
());
for
(
InventoryItem
storageInventoryItem
:
storageInventory
.
values
()){
storageInventoryItem
.
setStorageName
(
storage
.
getName
());
String
partNumber
=
storageInventoryItem
.
getPartNumber
();
InventoryItem
pnInventoryItem
=
resultMap
.
get
(
storageInventoryItem
.
getPartNumber
());
if
(
pnInventoryItem
==
null
){
pnInventoryItem
=
new
InventoryItem
();
pnInventoryItem
.
setStorageName
(
storageInventoryItem
.
getStorageName
());
}
else
{
pnInventoryItem
.
setStorageName
(
""
);
}
pnInventoryItem
.
setPartNumber
(
partNumber
);
pnInventoryItem
.
setStockCount
(
pnInventoryItem
.
getStockCount
()
+
storageInventoryItem
.
getStockCount
());
pnInventoryItem
.
setLockCount
(
pnInventoryItem
.
getLockCount
()
+
storageInventoryItem
.
getLockCount
());
pnInventoryItem
.
setStockReel
(
pnInventoryItem
.
getStockReel
()
+
storageInventoryItem
.
getStockReel
());
pnInventoryItem
.
setLockReel
(
pnInventoryItem
.
getLockReel
()
+
storageInventoryItem
.
getLockReel
());
resultMap
.
put
(
partNumber
,
pnInventoryItem
);
}
}
...
...
src/main/java/com/neotel/smfcore/core/order/rest/OrderController.java
查看文件 @
ccabc30
...
...
@@ -172,21 +172,24 @@ public class OrderController {
public
PageData
<
OrderDto
>
query
(
OrderQueryCondition
criteria
,
Pageable
pageable
)
{
User
user
=
userManager
.
findByUserName
(
SecurityUtils
.
getCurrentUsername
());
if
(
user
!=
null
)
{
//数据权限
//数据权限
查找没有权限的组列表
if
(!
user
.
getIsAdmin
())
{
Set
<
String
>
groupIds
=
user
.
getGroups
();
List
<
String
>
groupNames
=
Lists
.
newArrayList
();
if
(!
ObjectUtils
.
isEmpty
(
groupIds
))
{
for
(
String
groupId
:
groupIds
)
{
Group
group
=
groupManager
.
get
(
groupId
);
groupNames
.
add
(
group
.
getGroupName
());
List
<
String
>
excludeSources
=
Lists
.
newArrayList
();
List
<
Group
>
groups
=
groupManager
.
findAll
();
for
(
Group
group
:
groups
)
{
if
(
groupIds
.
contains
(
group
.
getId
())){
continue
;
}
excludeSources
.
add
(
group
.
getGroupName
());
}
//都没有权限,返回空
if
(
ObjectUtils
.
isEmpty
(
groupNames
))
{
return
new
PageData
<>(
Lists
.
newArrayList
(),
0
);
}
criteria
.
setSourceList
(
groupNames
);
// //都没有权限,返回空
// if (ObjectUtils.isEmpty(groupNames)) {
// return new PageData<>(Lists.newArrayList(), 0);
// }
criteria
.
setExcludeSourceList
(
excludeSources
);
}
}
Query
query
=
QueryHelp
.
getQuery
(
criteria
);
...
...
@@ -273,7 +276,7 @@ public class OrderController {
@ApiOperation
(
"工单详情"
)
@GetMapping
(
"/detial"
)
@PreAuthorize
(
"@el.check('
o
rder:detial')"
)
@PreAuthorize
(
"@el.check('
workO
rder:detial')"
)
@AnonymousAccess
public
OrderDto
detial
(
@RequestParam
(
required
=
false
)
String
id
,
@RequestParam
(
required
=
false
)
String
orderNo
)
{
...
...
src/main/java/com/neotel/smfcore/core/order/rest/bean/dto/OrderDto.java
查看文件 @
ccabc30
...
...
@@ -79,7 +79,7 @@ public class OrderDto implements Serializable {
private
List
<
OrderItemDto
>
orderItems
;
@ApiModelProperty
(
"建议出仓时间"
)
private
Date
sdate
;
private
Date
sdate
=
new
Date
()
;
@ApiModelProperty
(
"创建时间"
)
...
...
src/main/java/com/neotel/smfcore/core/order/rest/bean/query/OrderQueryCondition.java
查看文件 @
ccabc30
...
...
@@ -19,6 +19,8 @@ public class OrderQueryCondition {
@QueryCondition
(
type
=
QueryCondition
.
Type
.
IN
,
propName
=
"source"
)
private
List
<
String
>
sourceList
;
@QueryCondition
(
type
=
QueryCondition
.
Type
.
NIN
,
propName
=
"source"
)
private
List
<
String
>
excludeSourceList
;
//状态,0=所有,1=已关闭,2=未关闭
private
Integer
status
;
...
...
src/main/java/com/neotel/smfcore/core/order/service/po/LiteOrder.java
查看文件 @
ccabc30
...
...
@@ -86,7 +86,7 @@ public class LiteOrder extends BasePo implements Serializable {
/**
* 建议出仓时间
*/
private
Date
sdate
;
private
Date
sdate
=
new
Date
()
;
/**
* 结束当前的任务
...
...
src/main/java/com/neotel/smfcore/core/storage/bean/InventoryItem.java
查看文件 @
ccabc30
package
com
.
neotel
.
smfcore
.
core
.
storage
.
bean
;
import
lombok.Getter
;
import
lombok.Setter
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* 库存
*/
@Getter
@Setter
public
class
InventoryItem
{
/**
...
...
@@ -39,6 +47,10 @@ public class InventoryItem {
* 即将过期的盘数(2个小时内)
*/
private
int
willExireReel
=
0
;
/**
* 设备名称
*/
private
String
StorageName
=
""
;
public
String
getPartNumber
()
{
return
partNumber
;
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/LabelController.java
查看文件 @
ccabc30
...
...
@@ -43,7 +43,7 @@ public class LabelController {
@ApiOperation
(
"返回全部的标签"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('label
:list')"
)
// @PreAuthorize("@el.check('storagePos
:list')")
public
ResponseEntity
<
Object
>
query
()
{
Query
query
=
new
Query
();
List
<
Label
>
labels
=
labelManager
.
findByQuery
(
query
);
...
...
@@ -52,7 +52,7 @@ public class LabelController {
@ApiOperation
(
"新增标签"
)
@PostMapping
@PreAuthorize
(
"@el.check('
label:add
')"
)
@PreAuthorize
(
"@el.check('
storagePos:list
')"
)
public
ResponseEntity
<
Object
>
create
(
@RequestBody
LabelDto
labelDto
)
{
Label
resources
=
labelMapper
.
toEntity
(
labelDto
);
resources
=
labelManager
.
saveLabel
(
resources
);
...
...
@@ -62,7 +62,7 @@ public class LabelController {
@ApiOperation
(
"修改标签"
)
@PutMapping
@PreAuthorize
(
"@el.check('
label:edi
t')"
)
@PreAuthorize
(
"@el.check('
storagePos:lis
t')"
)
public
ResponseEntity
<
Object
>
update
(
@RequestBody
LabelDto
labelDto
)
{
Label
resources
=
labelMapper
.
toEntity
(
labelDto
);
if
(
resources
.
getId
()
==
null
)
{
...
...
@@ -74,7 +74,7 @@ public class LabelController {
@ApiOperation
(
"删除标签"
)
@DeleteMapping
@PreAuthorize
(
"@el.check('
label:del
')"
)
@PreAuthorize
(
"@el.check('
storagePos:list
')"
)
public
ResponseEntity
<
Object
>
delete
(
@RequestBody
Set
<
String
>
ids
)
{
Set
<
Group
>
menuSet
=
new
HashSet
<>();
for
(
String
id
:
ids
)
{
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/MaterialController.java
查看文件 @
ccabc30
...
...
@@ -25,17 +25,18 @@ import java.util.Map;
@Slf4j
@RestController
@RequiredArgsConstructor
@Api
(
tags
=
"物料管理:策略出库
,分组出库
"
)
@Api
(
tags
=
"物料管理:策略出库"
)
@RequestMapping
(
"api/material"
)
public
class
MaterialController
{
@Autowired
private
DataCache
dataCache
;
@ApiOperation
(
"策略出库获取库存
信息
"
)
@ApiOperation
(
"策略出库获取库存"
)
@GetMapping
(
value
=
"/inventory"
)
@PreAuthorize
(
"el.check('tacticsOuput')"
)
public
ResponseEntity
<
List
<
InventoryItem
>>
inventory
(
InventoryQueryCriteria
criteria
)
{
Map
<
String
,
InventoryItem
>
inventoryItemMap
=
dataCache
.
getAllInventory
();
Map
<
String
,
InventoryItem
>
inventoryItemMap
=
dataCache
.
getAllInventory
(
criteria
.
getStorageIdList
()
);
List
<
InventoryItem
>
list
=
Lists
.
newArrayList
(
inventoryItemMap
.
values
());
return
new
ResponseEntity
<>(
list
,
HttpStatus
.
OK
);
}
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/StorageController.java
查看文件 @
ccabc30
...
...
@@ -109,7 +109,7 @@ public class StorageController {
}
@ApiOperation
(
"根据组权限返回所有料仓"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('storage:list')"
)
//
@PreAuthorize("@el.check('storage:list')")
public
List
<
StorageSearchDto
>
query
()
{
String
userId
=
SecurityUtils
.
getCurrentUserId
();
User
user
=
userManager
.
get
(
userId
);
...
...
src/main/java/com/neotel/smfcore/core/storage/rest/StoragePosController.java
查看文件 @
ccabc30
...
...
@@ -75,7 +75,7 @@ public class StoragePosController {
@ApiOperation
(
"查询库位"
)
@GetMapping
@PreAuthorize
(
"@el.check('storage:list')"
)
@PreAuthorize
(
"@el.check('storage
Pos
:list')"
)
public
PageData
<
StoragePosDto
>
query
(
StoragePosQueryCriteria
criteria
,
Pageable
pageable
){
Query
query
=
QueryHelp
.
getQuery
(
criteria
);
PageData
<
StoragePos
>
pages
=
storagePosManager
.
findByPage
(
query
,
pageable
);
...
...
@@ -86,7 +86,7 @@ public class StoragePosController {
@ApiOperation
(
"删除指定料仓所有库位"
)
@PutMapping
(
"/removeAllPos"
)
@PreAuthorize
(
"@el.check('storage:edit')"
)
@PreAuthorize
(
"@el.check('storage
Pos
:edit')"
)
public
ResultBean
clearAllPos
(
@RequestBody
Map
<
String
,
String
>
map
)
{
String
cid
=
""
;
if
(
map
.
containsKey
(
"cid"
)){
...
...
@@ -115,7 +115,7 @@ public class StoragePosController {
@ApiOperation
(
"清空指定料仓所有库位"
)
@PutMapping
(
"/clearStoragePos"
)
@PreAuthorize
(
"@el.check('storage:edit')"
)
@PreAuthorize
(
"@el.check('storage
Pos
:edit')"
)
public
ResultBean
clearStoragePos
(
@RequestBody
Map
<
String
,
String
>
map
)
{
String
cid
=
""
;
if
(
map
.
containsKey
(
"cid"
)){
...
...
@@ -154,7 +154,7 @@ public class StoragePosController {
@ApiOperation
(
"清空指定库位"
)
@PutMapping
(
"/clearPos"
)
@PreAuthorize
(
"@el.check('storage:edit')"
)
@PreAuthorize
(
"@el.check('storage
Pos
:edit')"
)
public
ResultBean
clearPos
(
@RequestBody
HashMap
<
String
,
String
>
map
)
{
if
(
map
.
containsKey
(
"posName"
))
{
String
posName
=
map
.
get
(
"posName"
);
...
...
@@ -184,7 +184,7 @@ public class StoragePosController {
@ApiOperation
(
"启用禁用库位"
)
@PutMapping
(
"/enabledPos"
)
@PreAuthorize
(
"@el.check('storage:edit')"
)
@PreAuthorize
(
"@el.check('storage
Pos
:edit')"
)
public
ResultBean
enabledPos
(
@RequestBody
StoragePosEnabledDto
enabledDto
)
{
if
(
enabledDto
.
getId
()==
null
){
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
...
...
@@ -205,7 +205,7 @@ public class StoragePosController {
@ApiOperation
(
"修改库位"
)
@PutMapping
@PreAuthorize
(
"@el.check('storage:edit')"
)
@PreAuthorize
(
"@el.check('storage
Pos
:edit')"
)
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
StoragePosSaveDto
saveDto
)
{
if
(
saveDto
.
getId
()==
null
){
throw
new
ValidateException
(
"smfcode.valueCanotNull"
,
"{0}不能为空"
,
new
String
[]{
"ID"
}
);
...
...
@@ -237,7 +237,7 @@ public class StoragePosController {
// }
@ApiOperation
(
"删除库位"
)
@DeleteMapping
@PreAuthorize
(
"@el.check('storage:del')"
)
@PreAuthorize
(
"@el.check('storage
Pos
:del')"
)
public
ResponseEntity
<
Object
>
delete
(
@RequestBody
Set
<
String
>
ids
)
{
for
(
String
id
:
ids
)
{
...
...
@@ -251,7 +251,7 @@ public class StoragePosController {
@ApiOperation
(
"查找出库列表"
)
@GetMapping
(
"/find"
)
@PreAuthorize
(
"@el.check('
storage:lis
t')"
)
@PreAuthorize
(
"@el.check('
checkOu
t')"
)
public
PageData
<
StoragePosDto
>
storagePosFind
(
StoragePosFindCriteria
criteria
,
Pageable
pageable
,
HttpServletRequest
request
){
if
(
criteria
.
getStorageId
()!=
null
&&
criteria
.
getStorageId
().
equals
(
"0"
)){
criteria
.
setStorageId
(
null
);
...
...
src/main/java/com/neotel/smfcore/core/system/rest/SettingsController.java
查看文件 @
ccabc30
...
...
@@ -99,7 +99,7 @@ public class SettingsController {
@ApiOperation
(
"获取系统设置信息"
)
@GetMapping
(
"sysSettings"
)
@PreAuthorize
(
"@el.check('sysSetting
s
')"
)
@PreAuthorize
(
"@el.check('sysSetting')"
)
public
SysSettingsDto
getSysSettings
()
{
Settings
settings
=
dataCache
.
getSettings
();
...
...
@@ -113,7 +113,7 @@ public class SettingsController {
@ApiOperation
(
"修改系统设置信息"
)
@PutMapping
(
"sysSettings"
)
@PreAuthorize
(
"@el.check('sysSetting
s
')"
)
@PreAuthorize
(
"@el.check('sysSetting')"
)
public
ResultBean
updateSysSettings
(
@Validated
@RequestBody
SysSettingsDto
sysSettingsDto
)
{
dataCache
.
updateCache
(
Constants
.
CACHE_StopOut
,
sysSettingsDto
.
isStopOut
());
dataCache
.
updateCache
(
Constants
.
CACHE_StopJob
,
sysSettingsDto
.
isStopJob
());
...
...
@@ -124,7 +124,7 @@ public class SettingsController {
@ApiOperation
(
"获取出库策略信息"
)
@GetMapping
(
"checkoutSettings"
)
@PreAuthorize
(
"@el.check('outSetting
s
')"
)
@PreAuthorize
(
"@el.check('outSetting')"
)
public
Map
<
String
,
String
>
getCheckOutSettings
()
{
String
outSet
=
dataCache
.
getCache
(
Constants
.
CACHE_CheckOutType
);
Map
<
String
,
String
>
map
=
new
HashMap
<>();
...
...
@@ -134,7 +134,7 @@ public class SettingsController {
@ApiOperation
(
"修改出库策略"
)
@PutMapping
(
"checkoutSettings"
)
@PreAuthorize
(
"@el.check('outSetting
s
')"
)
@PreAuthorize
(
"@el.check('outSetting')"
)
public
ResultBean
update
(
@Validated
@RequestBody
String
type
)
{
// String type=map.get("checkOutType");
dataCache
.
updateCache
(
Constants
.
CACHE_CheckOutType
,
type
);
...
...
src/main/java/com/neotel/smfcore/core/system/rest/TaskController.java
查看文件 @
ccabc30
...
...
@@ -67,7 +67,7 @@ public class TaskController {
@ApiOperation
(
"查询出入库日志"
)
@GetMapping
(
"/history"
)
@PreAuthorize
(
"@el.check('task
:list
')"
)
@PreAuthorize
(
"@el.check('task
Log
')"
)
public
PageData
<
TaskDto
>
query
(
TaskQueryCondition
criteria
,
Pageable
pageable
)
{
String
un_End
=
"UN_END"
;
boolean
unEnd
=
false
;
...
...
@@ -88,7 +88,7 @@ public class TaskController {
@ApiOperation
(
"获取某个分组队列中的任务"
)
@GetMapping
(
"/{groupId}"
)
@PreAuthorize
(
"@el.check('task
:inQueue','task:list
')"
)
@PreAuthorize
(
"@el.check('task
Log
')"
)
public
List
<
TaskDto
>
groupTask
(
@PathVariable
String
groupId
){
if
(
groupId
!=
null
&&
groupId
.
equals
(
"-1"
)){
groupId
=
""
;
...
...
@@ -102,7 +102,7 @@ public class TaskController {
@ApiOperation
(
"获取队列中的任务"
)
@GetMapping
@PreAuthorize
(
"@el.check('task
:inQueue','task:list
')"
)
@PreAuthorize
(
"@el.check('task
Log
')"
)
public
List
<
TaskDto
>
filterTask
(
TaskQueryCondition
criteria
,
HttpServletRequest
request
){
String
groupId
=
criteria
.
getGroupId
();
String
[]
cids
=
criteria
.
getCids
();
...
...
@@ -160,7 +160,8 @@ public class TaskController {
@ApiOperation
(
"取消任务"
)
@DeleteMapping
@PreAuthorize
(
"@el.check('task:cancel')"
)
// @PreAuthorize("@el.check('task:cancel')")
@PreAuthorize
(
"@el.check('taskLog')"
)
public
ResponseEntity
<
Object
>
cancel
(
@RequestBody
Set
<
String
>
ids
){
for
(
String
taskId
:
ids
)
{
taskService
.
cancelTask
(
taskId
);
...
...
src/main/java/com/neotel/smfcore/security/config/ElPermissionConfig.java
查看文件 @
ccabc30
package
com
.
neotel
.
smfcore
.
security
.
config
;
import
com.neotel.smfcore.common.init.DataInitManager
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
lombok.extern.slf4j.Slf4j
;
...
...
@@ -12,10 +13,10 @@ import java.util.stream.Collectors;
@Slf4j
@Service
(
value
=
"el"
)
public
class
ElPermissionConfig
{
public
Boolean
check
(
String
...
permissions
){
public
Boolean
check
(
String
...
permissions
)
{
//超级管理员
if
(
SecurityUtils
.
getCurrentUsername
().
equals
(
Constants
.
SUPER_USERNAME
))
{
if
(
SecurityUtils
.
getCurrentUsername
().
equals
(
Constants
.
SUPER_USERNAME
))
{
return
true
;
}
...
...
@@ -23,14 +24,31 @@ public class ElPermissionConfig {
List
<
String
>
elPermissions
=
SecurityUtils
.
getCurrentUser
().
getAuthorities
().
stream
().
map
(
GrantedAuthority:
:
getAuthority
).
collect
(
Collectors
.
toList
());
// 判断当前用户的所有权限是否包含接口上定义的权限
boolean
result
=
elPermissions
.
contains
(
"admin"
)
||
Arrays
.
stream
(
permissions
).
anyMatch
(
elPermissions:
:
contains
);
String
msg
=
""
;
boolean
result
=
elPermissions
.
contains
(
"admin"
)
||
Arrays
.
stream
(
permissions
).
anyMatch
(
elPermissions:
:
contains
);
String
msg
=
""
;
for
(
String
str
:
permissions
)
{
msg
+=
str
+
","
;
msg
+=
str
+
","
;
}
if
(!
result
){
log
.
info
(
"username["
+
SecurityUtils
.
getCurrentUsername
()+
"] 对 ["
+
msg
+
"]无访问权限"
);
if
(!
result
)
{
//未找到匹配项,分割后匹配
for
(
String
per
:
permissions
)
{
if
(!
DataInitManager
.
allPermissionSet
.
contains
(
per
))
{
String
[]
perArray
=
per
.
split
(
":"
);
if
(
perArray
.
length
>
1
)
{
String
newper
=
perArray
[
0
];
if
(
elPermissions
.
contains
(
newper
))
{
result
=
true
;
}
}
}
}
}
if
(!
result
)
{
log
.
info
(
"username["
+
SecurityUtils
.
getCurrentUsername
()
+
"] 对 ["
+
msg
+
"]无访问权限"
);
}
return
result
;
}
...
...
src/main/java/com/neotel/smfcore/security/rest/GroupController.java
查看文件 @
ccabc30
...
...
@@ -60,7 +60,6 @@ public class GroupController {
@ApiOperation
(
"导出分组数据"
)
@GetMapping
(
value
=
"/download"
)
@PreAuthorize
(
"@el.check('menu:list')"
)
public
void
download
(
HttpServletResponse
response
,
GroupQueryCriteria
criteria
)
throws
Exception
{
Query
query
=
QueryHelp
.
getQuery
(
criteria
);
groupManager
.
download
(
groupManager
.
findByQuery
(
query
),
response
);
...
...
@@ -68,7 +67,6 @@ public class GroupController {
@GetMapping
@ApiOperation
(
"查询组列表"
)
// @PreAuthorize("@el.check('groups:list')")
public
PageData
<
GroupDto
>
query
(
GroupQueryCriteria
criteria
,
Pageable
pageable
)
throws
Exception
{
Query
query
=
QueryHelp
.
getQuery
(
criteria
);
PageData
<
Group
>
groups
=
groupManager
.
findByPage
(
query
,
pageable
);
...
...
@@ -77,7 +75,7 @@ public class GroupController {
@ApiOperation
(
"返回全部的分组"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('group
:list')"
)
// @PreAuthorize("@el.check('storage
:list')")
public
ResponseEntity
<
Object
>
query
()
{
Query
query
=
new
Query
();
List
<
Group
>
groups
=
groupManager
.
findByQuery
(
query
);
...
...
@@ -85,7 +83,7 @@ public class GroupController {
}
@ApiOperation
(
"料架分组界面的组列表"
)
@GetMapping
(
value
=
"/lightGroups"
)
@PreAuthorize
(
"@el.check('
group:list
')"
)
@PreAuthorize
(
"@el.check('
sensorShelf
')"
)
public
ResponseEntity
<
Object
>
lightGroup
()
{
Query
query
=
new
Query
();
List
<
Group
>
groups
=
groupManager
.
findByQuery
(
query
);
...
...
@@ -107,7 +105,7 @@ public class GroupController {
@ApiOperation
(
"新增分组"
)
@PostMapping
@PreAuthorize
(
"@el.check('
group:add
')"
)
@PreAuthorize
(
"@el.check('
storage:list
')"
)
public
ResponseEntity
<
Object
>
create
(
@RequestBody
GroupDto
groupDto
)
{
Group
resources
=
groupMapper
.
toEntity
(
groupDto
);
resources
=
groupManager
.
saveGroup
(
resources
);
...
...
@@ -129,7 +127,7 @@ public class GroupController {
@ApiOperation
(
"修改分组"
)
@PutMapping
@PreAuthorize
(
"@el.check('
group:edi
t')"
)
@PreAuthorize
(
"@el.check('
storage:lis
t')"
)
public
ResponseEntity
<
Object
>
update
(
@RequestBody
GroupDto
groupDto
)
{
Group
resources
=
groupMapper
.
toEntity
(
groupDto
);
if
(
resources
.
getId
()
==
null
)
{
...
...
@@ -145,7 +143,7 @@ public class GroupController {
@ApiOperation
(
"删除分组"
)
@DeleteMapping
@PreAuthorize
(
"@el.check('
group:del
')"
)
@PreAuthorize
(
"@el.check('
storage:list
')"
)
public
ResponseEntity
<
Object
>
delete
(
@RequestBody
Set
<
String
>
ids
)
{
Set
<
Group
>
menuSet
=
new
HashSet
<>();
for
(
String
id
:
ids
)
{
...
...
src/main/java/com/neotel/smfcore/security/rest/MenuController.java
查看文件 @
ccabc30
...
...
@@ -16,12 +16,14 @@
package
com
.
neotel
.
smfcore
.
security
.
rest
;
import
cn.hutool.core.collection.CollectionUtil
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.annotation.QueryCondition
;
import
com.neotel.smfcore.common.bean.PageData
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.common.utils.Constants
;
import
com.neotel.smfcore.common.utils.QueryHelp
;
import
com.neotel.smfcore.common.utils.SecurityUtils
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
com.neotel.smfcore.security.annotation.AnonymousAccess
;
import
com.neotel.smfcore.security.rest.bean.dto.MenuDto
;
import
com.neotel.smfcore.security.rest.bean.mapstruct.MenuMapper
;
...
...
@@ -96,16 +98,21 @@ public class MenuController {
//
@ApiOperation
(
"返回全部的菜单"
)
@GetMapping
(
value
=
"/lazy"
)
@PreAuthorize
(
"@el.check('menu:list','role
s
:list')"
)
public
ResponseEntity
<
Object
>
query
(
@RequestParam
String
pid
)
{
@PreAuthorize
(
"@el.check('menu:list','role:list')"
)
public
ResponseEntity
<
Object
>
query
(
@RequestParam
String
pid
,
HttpServletRequest
servletRequest
)
{
List
<
Menu
>
menus
=
menuManager
.
getMenusByPid
(
pid
);
Locale
locale
=
servletRequest
.
getLocale
();
for
(
Menu
menu
:
menus
)
{
menu
.
UpdateTitle
(
locale
);
}
List
<
MenuDto
>
dtos
=
menuMapper
.
toDto
(
menus
);
return
new
ResponseEntity
<>(
dtos
,
HttpStatus
.
OK
);
}
@ApiOperation
(
"根据菜单ID返回所有子节点ID,包含自身ID"
)
@GetMapping
(
value
=
"/child"
)
@PreAuthorize
(
"@el.check('menu:list','role
s
:list')"
)
@PreAuthorize
(
"@el.check('menu:list','role:list')"
)
public
ResponseEntity
<
Object
>
child
(
@RequestParam
String
id
)
{
Set
<
Menu
>
menuSet
=
new
HashSet
<>();
List
<
Menu
>
menuList
=
menuManager
.
getMenusByPid
(
id
);
...
...
src/main/java/com/neotel/smfcore/security/rest/RoleController.java
查看文件 @
ccabc30
...
...
@@ -58,7 +58,7 @@ public class RoleController {
@ApiImplicitParam
(
name
=
"id"
,
value
=
"角色的ID"
,
required
=
true
)
})
@GetMapping
(
value
=
"/{id}"
)
@PreAuthorize
(
"@el.check('role
s
:list')"
)
@PreAuthorize
(
"@el.check('role:list')"
)
public
RoleDto
query
(
@PathVariable
String
id
){
RoleDto
dto
=
roleMapper
.
toDto
(
roleManager
.
get
(
id
));
return
dto
;
...
...
@@ -75,7 +75,7 @@ public class RoleController {
@ApiOperation
(
"返回全部的角色"
)
@GetMapping
(
value
=
"/all"
)
@PreAuthorize
(
"@el.check('role
s
:list','user:add','user:edit')"
)
@PreAuthorize
(
"@el.check('role:list','user:add','user:edit')"
)
public
List
<
RoleDto
>
query
(){
Query
query
=
new
Query
();
// query.with(Sort.by(Sort.Direction.ASC,"levle"));
...
...
@@ -84,7 +84,7 @@ public class RoleController {
@ApiOperation
(
"查询角色"
)
@GetMapping
@PreAuthorize
(
"@el.check('role
s
:list')"
)
@PreAuthorize
(
"@el.check('role:list')"
)
public
PageData
<
RoleDto
>
query
(
RoleQueryCriteria
criteria
,
Pageable
pageable
){
Query
query
=
QueryHelp
.
getQuery
(
criteria
);
PageData
<
Role
>
rolePageData
=
roleManager
.
findByPage
(
query
,
pageable
);
...
...
@@ -95,7 +95,7 @@ public class RoleController {
@ApiOperation
(
"新增角色"
)
@PostMapping
@PreAuthorize
(
"@el.check('role
s
:add')"
)
@PreAuthorize
(
"@el.check('role:add')"
)
public
ResponseEntity
<
Object
>
create
(
@Validated
@RequestBody
RoleDto
roleDto
)
{
Role
resources
=
roleMapper
.
toEntity
(
roleDto
);
roleManager
.
saveRole
(
resources
);
...
...
@@ -104,7 +104,7 @@ public class RoleController {
@ApiOperation
(
"修改角色"
)
@PutMapping
@PreAuthorize
(
"@el.check('role
s
:edit')"
)
@PreAuthorize
(
"@el.check('role:edit')"
)
public
ResponseEntity
<
Object
>
update
(
@Validated
@RequestBody
RoleDto
roleDto
)
{
Role
resources
=
roleMapper
.
toEntity
(
roleDto
);
Role
role
=
roleManager
.
get
(
resources
.
getId
());
...
...
@@ -118,7 +118,7 @@ public class RoleController {
@ApiOperation
(
"修改角色菜单"
)
@PutMapping
(
value
=
"/menu"
)
@PreAuthorize
(
"@el.check('role
s
:edit')"
)
@PreAuthorize
(
"@el.check('role:edit')"
)
public
ResponseEntity
<
Object
>
updateMenu
(
@RequestBody
RoleDto
roleDto
)
{
Role
resources
=
roleMapper
.
toEntity
(
roleDto
);
if
(
resources
.
getId
()
==
null
)
{
...
...
@@ -141,7 +141,7 @@ public class RoleController {
@ApiOperation
(
"删除角色"
)
@DeleteMapping
@PreAuthorize
(
"@el.check('role
s
:del')"
)
@PreAuthorize
(
"@el.check('role:del')"
)
public
ResponseEntity
<
Object
>
delete
(
@RequestBody
Set
<
String
>
ids
)
{
List
<
Role
>
roles
=
new
ArrayList
<
Role
>();
...
...
src/main/java/com/neotel/smfcore/security/service/UserDetailsServiceImpl.java
查看文件 @
ccabc30
...
...
@@ -117,8 +117,21 @@ public class UserDetailsServiceImpl implements UserDetailsService {
.
collect
(
Collectors
.
toList
());
}
List
<
Menu
>
menus
=
menuManager
.
findPermissionByRoleId
(
user
.
getRoleId
());
permissions
=
menus
.
stream
().
filter
(
menu
->
StringUtils
.
isNotBlank
(
menu
.
getPermission
()))
.
map
(
Menu:
:
getPermission
).
collect
(
Collectors
.
toSet
());
for
(
Menu
menu
:
menus
)
{
if
(
StringUtils
.
isNotBlank
(
menu
.
getPermission
()))
{
permissions
.
add
(
menu
.
getPermission
());
if
(
menu
.
getPermission
().
contains
(
":"
))
{
String
[]
array
=
menu
.
getPermission
().
split
(
":"
);
if
(
array
.
length
>=
1
)
{
permissions
.
add
(
array
[
0
]);
}
}
}
}
// permissions = menus.stream().filter(menu -> StringUtils.isNotBlank(menu.getPermission()))
// .map(Menu::getPermission).collect(Collectors.toSet());
return
permissions
.
stream
().
map
(
SimpleGrantedAuthority:
:
new
)
.
collect
(
Collectors
.
toList
());
}
...
...
src/main/java/com/neotel/smfcore/security/service/dao/impl/MenuDaoImpl.java
查看文件 @
ccabc30
...
...
@@ -5,6 +5,8 @@ import com.neotel.smfcore.security.service.dao.IMenuDao;
import
com.neotel.smfcore.security.service.dao.IRoleDao
;
import
com.neotel.smfcore.security.service.po.Menu
;
import
com.neotel.smfcore.security.service.po.User
;
import
org.springframework.data.mongodb.core.query.Criteria
;
import
org.springframework.data.mongodb.core.query.Query
;
import
org.springframework.stereotype.Service
;
import
java.util.List
;
...
...
@@ -21,6 +23,9 @@ public class MenuDaoImpl extends AbstractBaseDao implements IMenuDao {
@Override
public
List
<
Menu
>
findByPid
(
String
pid
)
{
return
super
.
findListByCondition
(
new
String
[]
{
"pid"
},
new
String
[]
{
pid
});
Query
query
=
new
Query
();
query
.
addCriteria
(
Criteria
.
where
(
"pid"
).
is
(
pid
));
query
.
addCriteria
(
Criteria
.
where
(
"type"
).
ne
(
2
));
return
super
.
findByQuery
(
query
);
}
}
src/main/java/com/neotel/smfcore/security/service/manager/IGroupManager.java
查看文件 @
ccabc30
...
...
@@ -2,6 +2,7 @@ package com.neotel.smfcore.security.service.manager;
import
com.neotel.smfcore.common.base.IBaseManager
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.core.storage.service.po.Label
;
import
com.neotel.smfcore.security.service.po.Group
;
import
javax.servlet.http.HttpServletResponse
;
...
...
@@ -9,6 +10,8 @@ import java.io.IOException;
import
java.util.List
;
public
interface
IGroupManager
extends
IBaseManager
<
Group
>
{
List
<
Group
>
findAll
();
Group
getByGroupName
(
String
groupName
);
Group
saveGroup
(
Group
resources
)
throws
ValidateException
;
...
...
src/main/java/com/neotel/smfcore/security/service/manager/IMenuManager.java
查看文件 @
ccabc30
...
...
@@ -3,6 +3,7 @@ package com.neotel.smfcore.security.service.manager;
import
com.neotel.smfcore.common.base.IBaseManager
;
import
com.neotel.smfcore.common.exception.ValidateException
;
import
com.neotel.smfcore.core.storage.service.po.Label
;
import
com.neotel.smfcore.security.rest.bean.dto.MenuDto
;
import
com.neotel.smfcore.security.rest.bean.vo.MenuVo
;
import
com.neotel.smfcore.security.service.po.Menu
;
...
...
@@ -16,6 +17,7 @@ import java.util.Set;
public
interface
IMenuManager
extends
IBaseManager
<
Menu
>
{
List
<
Menu
>
findAll
();
/**
* 根据角色ID获取菜单
* @param roleId
...
...
src/main/java/com/neotel/smfcore/security/service/manager/impl/GroupManagerImpl.java
查看文件 @
ccabc30
...
...
@@ -35,6 +35,11 @@ public class GroupManagerImpl implements IGroupManager {
IUserManager
userManager
;
@Override
public
List
<
Group
>
findAll
()
{
return
groupDao
.
findAll
();
}
@Override
public
Group
getByGroupName
(
String
groupName
){
return
groupDao
.
findOneByCondition
(
new
String
[]{
"groupName"
},
new
String
[]{
groupName
});
}
...
...
src/main/java/com/neotel/smfcore/security/service/manager/impl/MenuManagerImpl.java
查看文件 @
ccabc30
...
...
@@ -70,6 +70,11 @@ public class MenuManagerImpl implements IMenuManager {
}
@Override
public
List
<
Menu
>
findAll
()
{
return
menuDao
.
findAll
();
}
@Override
public
List
<
Menu
>
findByRoleId
(
String
roleId
)
{
Role
role
=
roleManager
.
get
(
roleId
);
if
(
role
!=
null
){
...
...
src/main/java/com/neotel/smfcore/security/service/po/Menu.java
查看文件 @
ccabc30
...
...
@@ -17,12 +17,14 @@ package com.neotel.smfcore.security.service.po;
import
cn.hutool.core.util.ObjectUtil
;
import
com.neotel.smfcore.common.base.BasePo
;
import
com.neotel.smfcore.core.language.util.MessageUtils
;
import
lombok.*
;
import
org.springframework.data.mongodb.core.mapping.Document
;
import
java.io.Serializable
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Locale
;
import
java.util.Objects
;
/**
...
...
@@ -181,4 +183,11 @@ public class Menu extends BasePo implements Serializable {
}
return
titleKey
;
}
public
void
UpdateTitle
(
Locale
locale
)
{
String
oldName
=
ObjectUtil
.
isNotEmpty
(
getComponentName
())?
getComponentName
():
getTitle
();
String
titleKey
=
getTitleKey
();
String
title
=
MessageUtils
.
getText
(
GetMsgKey
(),
locale
,
oldName
);
setTitle
(
title
);
}
}
编写
预览
支持
Markdown
格式
附加文件
你添加了
0
人
到此讨论。请谨慎行事。
Finish editing this message first!
Cancel
请
注册
或
登录
后发表评论