Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
8eca049f
提交
8eca049f
authored
10月 21, 2021
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(装备模块): 构建条件构造器
构建条件构造器
上级
dd0485c6
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
82 行增加
和
3 行删除
+82
-3
DeviceLibraryController.java
...ev/device/library/controller/DeviceLibraryController.java
+3
-3
DeviceLibraryService.java
...tykj/dev/device/library/service/DeviceLibraryService.java
+2
-0
DeviceLibraryServiceImpl.java
...device/library/service/impl/DeviceLibraryServiceImpl.java
+77
-0
没有找到文件。
dev-library/src/main/java/com/tykj/dev/device/library/controller/DeviceLibraryController.java
浏览文件 @
8eca049f
...
...
@@ -425,7 +425,7 @@ public class DeviceLibraryController {
@ApiOperation
(
value
=
"模糊查询日常管理装备父子分页"
,
notes
=
"可以通过这个接口查询装备列表"
)
@PostMapping
(
"/core/feature/summary/daily"
)
public
ResponseEntity
selectDailyDevicePage
(
@RequestBody
DeviceLibrarySelectVo
deviceLibrarySelectVo
)
{
public
ResponseEntity
selectDailyDevicePage
(
@RequestBody
DeviceLibrarySelectVo
deviceLibrarySelectVo
){
Boolean
hasModelDim
=
deviceLibrarySelectVo
.
getModelDim
()!=
null
;
Boolean
hasNameDim
=
deviceLibrarySelectVo
.
getNameDim
()!=
null
;
Boolean
hasSeqDim
=
deviceLibrarySelectVo
.
getSeqDim
()!=
null
;
...
...
@@ -438,8 +438,8 @@ public class DeviceLibraryController {
Boolean
hasTypeDim
=
deviceLibrarySelectVo
.
getTypeDim
()
!=
null
;
Map
<
String
,
Object
>
map
=
new
HashMap
<>();
List
<
DeviceLibrary
>
resultList
=
deviceLibraryService
.
getList
(
deviceLibrarySelectVo
);
//
List<DeviceLibrary> resultList = deviceLibraryService.getList(deviceLibrarySelectVo);
List
<
DeviceLibrary
>
resultList
=
deviceLibraryService
.
getAlldevList
(
deviceLibrarySelectVo
);
resultList
.
forEach
(
DeviceLibrary:
:
setConfigName
);
if
(
hasModelDim
||
hasLifeStatusDim
||
hasLocationUnitDim
||
hasNameDim
||
hasOwnUnitDim
||
hasSeqDim
)
{
resultList
=
resultList
.
stream
().
filter
(
deviceLibrary
->
{
...
...
dev-library/src/main/java/com/tykj/dev/device/library/service/DeviceLibraryService.java
浏览文件 @
8eca049f
...
...
@@ -483,4 +483,6 @@ public interface DeviceLibraryService {
* 更新装备的状态 正式和试用
*/
void
updateTry
(
List
<
DeviceLibrary
>
deviceLibraries
);
List
<
DeviceLibrary
>
getAlldevList
(
DeviceLibrarySelectVo
deviceLibrarySelectVo
);
}
dev-library/src/main/java/com/tykj/dev/device/library/service/impl/DeviceLibraryServiceImpl.java
浏览文件 @
8eca049f
package
com
.
tykj
.
dev
.
device
.
library
.
service
.
impl
;
import
cn.hutool.core.util.ObjectUtil
;
import
com.github.wenhao.jpa.PredicateBuilder
;
import
com.github.wenhao.jpa.Specifications
;
import
com.tykj.dev.blockcha.subject.entity.BcHash
;
...
...
@@ -24,6 +25,7 @@ import com.tykj.dev.device.user.subject.service.UserPublicService;
import
com.tykj.dev.device.user.util.UserUtils
;
import
com.tykj.dev.misc.exception.ApiException
;
import
com.tykj.dev.misc.utils.*
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.cache.annotation.Cacheable
;
import
org.springframework.data.domain.Page
;
...
...
@@ -36,6 +38,7 @@ import org.springframework.stereotype.Service;
import
javax.persistence.Transient
;
import
java.lang.reflect.Field
;
import
java.lang.reflect.Method
;
import
java.util.*
;
import
java.util.concurrent.CompletableFuture
;
import
java.util.function.Function
;
...
...
@@ -47,6 +50,7 @@ import static java.util.stream.Collectors.groupingBy;
* @author dengdiyi
*/
@Service
@Slf4j
public
class
DeviceLibraryServiceImpl
implements
DeviceLibraryService
{
@Autowired
...
...
@@ -1035,6 +1039,26 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
});
}
@Override
public
List
<
DeviceLibrary
>
getAlldevList
(
DeviceLibrarySelectVo
deviceLibrarySelectVo
)
{
List
<
DeviceLibrary
>
deviceLibraryList
=
cacheLibraryService
.
getAllDeviceLibraryList
();
List
<
Integer
>
status
=
new
ArrayList
<>(
Arrays
.
asList
(
2
,
11
,
14
));
String
currentUserUnitName
=
userUtils
.
getCurrentUserUnitName
();
deviceLibraryList
=
deviceLibraryList
.
stream
().
filter
(
deviceLibrary
->
deviceLibrary
.
getOwnUnit
().
equals
(
currentUserUnitName
)
&&
deviceLibrary
.
getLocationUnit
().
equals
(
currentUserUnitName
))
.
filter
(
deviceLibrary
->
status
.
contains
(
deviceLibrary
.
getLifeStatus
())
)
.
collect
(
Collectors
.
toList
());
List
list
=
null
;
try
{
long
l
=
System
.
currentTimeMillis
();
list
=
filterFields
(
deviceLibraryList
,
deviceLibrarySelectVo
);
log
.
info
(
"过滤时间为:{}"
+(
System
.
currentTimeMillis
()-
l
));
}
catch
(
Exception
e
)
{
e
.
printStackTrace
();
}
return
list
;
}
// @Override
// @UpdateCache
// public int updatePartParentId(List<Integer> deviceIds) {
...
...
@@ -1211,5 +1235,58 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
private
List
<
DeviceStatisticsVo
>
selectByName
(
String
name
,
List
<
DeviceStatisticsVo
>
deviceStatisticsVos
)
{
return
deviceStatisticsVos
.
stream
().
filter
(
deviceStatisticsVo
->
deviceStatisticsVo
.
getName
().
equals
(
name
)).
collect
(
Collectors
.
toList
());
}
private
List
<
DeviceLibrary
>
getAllDevww
(
DeviceLibrarySelectVo
deviceLibrarySelectVo
)
throws
Exception
{
List
<
DeviceLibrary
>
deviceLibraryList
=
cacheLibraryService
.
getAllDeviceLibraryList
();
long
l
=
System
.
currentTimeMillis
();
List
<
DeviceLibrary
>
list
=
filterFields
(
deviceLibraryList
,
deviceLibrarySelectVo
);
log
.
info
(
"过滤时间为:{}"
,(
System
.
currentTimeMillis
()-
l
));
return
list
;
}
public
List
<
DeviceLibrary
>
filterFields
(
List
<
DeviceLibrary
>
list
,
DeviceLibrarySelectVo
params
)
throws
Exception
{
Method
[]
methods
=
params
.
getClass
().
getMethods
();
// getUserName getPassWord
List
<
Method
>
useMethods
=
Arrays
.
stream
(
methods
).
filter
(
method
->
!
method
.
getName
().
equals
(
"getClass"
)
&&
method
.
getName
().
startsWith
(
"get"
)).
collect
(
Collectors
.
toList
());
// Map<String,Object> filterFields = new HashMap<>();
//获取参数不为空的集合 如 username = "张三",password = "123456" age = "null"
Set
<
String
>
nameMethods
=
new
HashSet
<>();
for
(
DeviceLibrary
deviceLibrary
:
list
)
{
for
(
Method
declaredField
:
deviceLibrary
.
getClass
().
getDeclaredMethods
())
{
nameMethods
.
add
(
declaredField
.
getName
());
}
}
for
(
Method
useMethod
:
useMethods
)
{
Object
invoke
=
params
.
getClass
().
getMethod
(
useMethod
.
getName
()).
invoke
(
params
);
//判断是否为空
if
(
ObjectUtil
.
isNotNull
(
invoke
))
{
if
(
invoke
instanceof
ArrayList
){
if
(((
ArrayList
<?>)
invoke
).
size
()
==
3
){
list
=
list
;
}
}
else
{
if
(
nameMethods
.
contains
(
useMethod
.
getName
()))
{
list
=
list
.
stream
().
filter
(
deviceLibrary1
->
{
try
{
Object
invoke1
=
deviceLibrary1
.
getClass
().
getMethod
(
useMethod
.
getName
())
.
invoke
(
deviceLibrary1
);
//判断是不是同一个
if
(
ObjectUtil
.
equal
(
invoke
,
invoke1
)
||
ObjectUtil
.
contains
(
invoke1
,
invoke
))
{
return
true
;
}
}
catch
(
Exception
e
)
{
}
return
false
;
}).
collect
(
Collectors
.
toList
());
}
}
}
}
return
list
;
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论