Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
D
device-back
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
1
议题
1
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
Matrix
device-back
Commits
16b2ca93
提交
16b2ca93
authored
9月 27, 2021
作者:
zhoushaopan
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
feat(装备模块,缓存模块): 新增了自定义注解,增加了装备的接口,完善缓存的维护,新增缓存更新接口
新增了自定义注解,增加了装备的接口,完善缓存的维护,新增缓存更新接口
上级
3aaf1260
全部展开
显示空白字符变更
内嵌
并排
正在显示
10 个修改的文件
包含
314 行增加
和
24 行删除
+314
-24
DeviceApplyController.java
...kj/dev/device/apply/controller/DeviceApplyController.java
+4
-3
UpdateCache.java
...config/src/main/java/com/tykj/dev/config/UpdateCache.java
+15
-0
DeviceLibraryController.java
...ev/device/library/controller/DeviceLibraryController.java
+30
-7
DeviceLibraryDao.java
.../tykj/dev/device/library/repository/DeviceLibraryDao.java
+17
-0
DeviceLibraryCacheService.java
...dev/device/library/service/DeviceLibraryCacheService.java
+2
-0
DeviceLibraryService.java
...tykj/dev/device/library/service/DeviceLibraryService.java
+171
-6
CacheLibraryServiceImpl.java
.../device/library/service/impl/CacheLibraryServiceImpl.java
+20
-1
DeviceLibraryServiceImpl.java
...device/library/service/impl/DeviceLibraryServiceImpl.java
+0
-0
DevideTask.java
...ain/java/com/tykj/dev/device/library/task/DevideTask.java
+7
-7
UpdateCacheAspect.java
...n/src/main/java/com/tykj/dev/union/UpdateCacheAspect.java
+48
-0
没有找到文件。
dev-apply/src/main/java/com/tykj/dev/device/apply/controller/DeviceApplyController.java
浏览文件 @
16b2ca93
...
...
@@ -112,8 +112,8 @@ public class DeviceApplyController {
@Autowired
private
PackingController
packingController
;
@Autowired
private
DeviceLibraryDao
deviceLibraryDao
;
//
@Autowired
//
private DeviceLibraryDao deviceLibraryDao;
@ApiOperation
(
value
=
"发起装备申请"
,
notes
=
"可以通过这个接口发起装备申请"
)
@PostMapping
(
"/addDeviceApplyBill"
)
...
...
@@ -500,7 +500,8 @@ public class DeviceApplyController {
seqs
.
addAll
(
DeviceSeqUtil
.
selectDeviceSeqs
(
r
.
getSeqInterval
()));
}
}
deviceLibraryDao
.
upDateSeqNumbersApplyTaskId
(
taskBto
.
getId
(),
seqs
);
// deviceLibraryDao.upDateSeqNumbersApplyTaskId(taskBto.getId(), seqs);
deviceLibraryService
.
upDateSeqNumbersApplyTaskId
(
taskBto
.
getId
(),
seqs
);
}
}
return
ResponseEntity
.
ok
(
"ok"
);
...
...
dev-config/src/main/java/com/tykj/dev/config/UpdateCache.java
0 → 100644
浏览文件 @
16b2ca93
package
com
.
tykj
.
dev
.
config
;
import
java.lang.annotation.*
;
/**
* UpdateCache注解
*
* @author zsp
*/
@Target
({
ElementType
.
METHOD
,
ElementType
.
FIELD
})
@Retention
(
RetentionPolicy
.
RUNTIME
)
@Documented
public
@interface
UpdateCache
{
String
type
()
default
""
;
}
dev-library/src/main/java/com/tykj/dev/device/library/controller/DeviceLibraryController.java
浏览文件 @
16b2ca93
...
...
@@ -867,7 +867,7 @@ public class DeviceLibraryController {
@ApiOperation
(
value
=
"修改装备的存放位置"
)
@PostMapping
(
"/updateDeviceLibraryLocation"
)
@CacheEvict
(
value
=
"devicesLibraryList"
,
key
=
"'device'"
,
allEntries
=
true
)
//
@CacheEvict(value = "devicesLibraryList",key = "'device'",allEntries = true)
public
void
updateDeviceLibraryLocation
(
@RequestBody
DeviceStorageLocation
deviceStorageLocation
){
DeviceLibrary
deviceLibrary
=
deviceLibraryService
.
getOne
(
deviceStorageLocation
.
getDevId
());
//添加修改存放装备位置
...
...
@@ -875,12 +875,12 @@ public class DeviceLibraryController {
DeviceLogDto
deviceLogDto
=
new
DeviceLogDto
(
deviceStorageLocation
.
getDevId
(),
"将存放位置改为"
+
deviceStorageLocation
.
getStorageLocation
(),
null
,
null
,
null
);
deviceLogService
.
addLog
(
deviceLogDto
);
deviceLibraryService
.
update
(
deviceLibrary
);
//异步去查询数据库
executor
.
execute
(
()->{
cacheLibraryService
.
getAllDeviceLibraryList
();
}
);
//
//异步去查询数据库
//
executor.execute(
//
()->{
//
cacheLibraryService.getAllDeviceLibraryList();
//
}
//
);
}
@ApiOperation
(
"根据装备id修改装备的序列号"
)
...
...
@@ -944,6 +944,29 @@ public class DeviceLibraryController {
return
deviceNewVoList
;
}
@ApiOperation
(
value
=
"查询可进行绑定的装备"
,
notes
=
"查询可进行绑定的装备"
)
@GetMapping
(
"/selectBindingDevice"
)
public
List
<
DeviceLibrary
>
selectBindingDevice
(){
List
<
DeviceLibrary
>
deviceLibraries
=
cacheLibraryService
.
getAllDeviceLibraryList
().
stream
()
.
filter
(
deviceLibrary
->
deviceLibrary
.
getPartParentId
()
==
null
).
collect
(
Collectors
.
toList
());
// cacheLibraryService.asyncUpdateCache();
return
deviceLibraries
;
}
@ApiOperation
(
value
=
"解除装备绑定"
,
notes
=
"解除装备绑定"
)
@GetMapping
(
"/relieveDevice/{deviceId}"
)
public
ResponseEntity
relieveDevice
(
@PathVariable
(
"deviceId"
)
Integer
deviceId
){
deviceLibraryService
.
relieveDevice
(
deviceId
);
return
ResponseEntity
.
ok
(
"解除成功"
);
}
@ApiOperation
(
value
=
"进行装备绑定"
,
notes
=
"进行装备绑定"
)
@PostMapping
(
"/bindingDevice"
)
public
ResponseEntity
bindingDevice
(
BindingDeviceVo
bindingDeviceVo
){
deviceLibraryService
.
bindingDevice
(
bindingDeviceVo
);
return
ResponseEntity
.
ok
(
"绑定成功"
);
}
/**
* 测试
*/
...
...
dev-library/src/main/java/com/tykj/dev/device/library/repository/DeviceLibraryDao.java
浏览文件 @
16b2ca93
...
...
@@ -191,5 +191,22 @@ public interface DeviceLibraryDao extends JpaRepository<DeviceLibrary, Integer>,
int
updateMatchingRange2
(
Integer
matchingRange
,
@Param
(
"deviceIds"
)
List
<
Integer
>
deviceIds
);
List
<
DeviceLibrary
>
findByModelAndIsPart
(
String
model
,
Integer
isPart
);
List
<
DeviceLibrary
>
findAllByPartParentId
(
Integer
partParentId
);
@Transactional
@Modifying
@Query
(
"update DeviceLibrary o set o.model = :newModel,o.packingId = :packingId where o.id in :deviceIds"
)
int
updateModelAndPackingId
(
@Param
(
"newModel"
)
String
newModel
,
@Param
(
"packingId"
)
Integer
packingId
,
@Param
(
"deviceIds"
)
List
<
Integer
>
deviceIds
);
@Transactional
@Modifying
@Query
(
"update DeviceLibrary o set o.packingId = :packingId where o.id in :deviceIds"
)
int
updatePackingId
(
@Param
(
"packingId"
)
Integer
packingId
,
@Param
(
"deviceIds"
)
List
<
Integer
>
deviceIds
);
}
dev-library/src/main/java/com/tykj/dev/device/library/service/DeviceLibraryCacheService.java
浏览文件 @
16b2ca93
...
...
@@ -26,4 +26,6 @@ public interface DeviceLibraryCacheService {
void
deletAllDeviceLibraryList
();
void
asyncUpdateCache
();
}
dev-library/src/main/java/com/tykj/dev/device/library/service/DeviceLibraryService.java
浏览文件 @
16b2ca93
package
com
.
tykj
.
dev
.
device
.
library
.
service
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
com.tykj.dev.device.library.subject.vo.BindingDeviceVo
;
import
com.tykj.dev.device.library.subject.vo.DeviceLibrarySelectVo
;
import
com.tykj.dev.device.library.subject.vo.DeviceStatisticsVo
;
import
org.springframework.data.domain.Page
;
import
org.springframework.data.domain.Pageable
;
import
org.springframework.data.domain.Sort
;
import
org.springframework.data.repository.query.Param
;
import
java.util.List
;
import
java.util.Map
;
...
...
@@ -206,11 +208,6 @@ public interface DeviceLibraryService {
*/
DeviceLibrary
findBySeqNumber
(
String
seqNumber
);
// /**
// *
// */
// List<DeviceLibrary> findByIds2(List<Integer> ids);
/**
* 得到所有的装备
*/
...
...
@@ -245,7 +242,8 @@ public interface DeviceLibraryService {
void
updateDevicesOwnUnit
(
List
<
Integer
>
deviceIds
);
/**
* @param
* @param localUnit 所在单位
* @param deviceIds 装备id的集合
*/
void
updateLocalAndOwn
(
String
localUnit
,
List
<
Integer
>
deviceIds
);
...
...
@@ -264,6 +262,173 @@ public interface DeviceLibraryService {
*/
List
<
DeviceLibrary
>
findDevicesByPacking
(
Integer
packing
);
/**
* 更新配用范围
* @param libraries 装备的集合
*/
void
updateMatchingRange
(
List
<
DeviceLibrary
>
libraries
);
/**
* 装备的解除
* @param deviceId 装备id
*/
void
relieveDevice
(
int
deviceId
);
/**
* 装备的绑定
* @param
*/
void
bindingDevice
(
BindingDeviceVo
bindingDeviceVo
);
/**
* 以下接口都为缓存做铺垫
*/
/**
* 更新设备序列号
* @param taskId 任务id
* @param seqNumbers 序列号的集合
*/
void
upDateSeqNumbersApplyTaskId
(
Integer
taskId
,
List
<
String
>
seqNumbers
);
List
<
DeviceLibrary
>
findAllByOwnUnit
(
String
ownUnit
);
List
<
DeviceLibrary
>
getAllByRfidCardId
(
String
rfidCardId
);
/**
* 根据装备id的集合更新装备的生命状态
* @param lifeStatus 生命状态
* @param idList 装备id的集合
* @return
*/
int
upDateLeftStatus
(
Integer
lifeStatus
,
@Param
(
"idList"
)
List
<
Integer
>
idList
);
/**
* 根据装备id的集合更新装备的生命状态
* @param lifeStatus 生命状态
* @param seqNumbers 装备序列号的集合
* @return 影响行数
*/
int
upDateSeqNumbersLeftStatus
(
Integer
lifeStatus
,
@Param
(
"seqNumbers"
)
List
<
String
>
seqNumbers
);
/**
* 根据装备id的集合更新装备的生命状态和lock
* @param lifeStatus 生命状态
* @param lock 是否解锁
* @param idList 装备id的集合
* @return 影响行数
*/
int
upDateLeftStatusAndLockStatus
(
Integer
lifeStatus
,
Integer
lock
,
@Param
(
"idList"
)
List
<
Integer
>
idList
);
/**
* 根据装备id的集合更新lock
* @param lock 解锁
* @param idList 装备id的集合
* @return 影响行数
*/
int
upDateLockStatus
(
Integer
lock
,
@Param
(
"idList"
)
List
<
Integer
>
idList
);
/**
* 根据装备id的集合更新生命状态和单位名称
* @param lifeStatus
* @param unitName
* @param lock
* @param idList
* @return 影响行数
*/
int
upDateLeftStatusAndUnitNameAndLockStatus
(
Integer
lifeStatus
,
String
unitName
,
Integer
lock
,
@Param
(
"idList"
)
List
<
Integer
>
idList
);
/**
* 根据装备的序列号的集合更新生命状态和单位名称和锁
* @param lifeStatus 生命状态
* @param unitName 单位名称
* @param lock 锁
* @param seqNumbers 装备序列号的集合
* @return 影响行数
*/
int
upDateSeqNumbersLeftStatusAndUnitNameAndLockStatus
(
Integer
lifeStatus
,
String
unitName
,
Integer
lock
,
@Param
(
"seqNumbers"
)
List
<
String
>
seqNumbers
);
/**
* 根据装备id的集合更新生命状态和所属单位
* @param lifeStatus 生命状态
* @param unitName 所属单位
* @param idList 装备id的集合
* @return 影响行数
*/
int
upDateLeftStatusAndOwnUnitName
(
Integer
lifeStatus
,
String
unitName
,
@Param
(
"idList"
)
List
<
Integer
>
idList
);
/**
* 根据装备id的集合更新RFID表面号
* @param idList 装备id的集合
* @return 影响行数
*/
int
upDateRfidSurfaceIdAsSeqNumber
(
@Param
(
"idList"
)
List
<
Integer
>
idList
);
/**
* 根据列装id更新名称
* @param name 名称
* @param packingId 列装id
* @return 影响行数
*/
int
upDateName
(
String
name
,
Integer
packingId
);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param packingId 列装id
* @return 影响函数
*/
int
upDateMatchingRange
(
Integer
matchingRange
,
Integer
packingId
);
/**
* 根据装备id更新生命状态
* @param lifeStatus 生命状态
* @param id 装备id
* @return
*/
int
batchUpdate
(
Integer
lifeStatus
,
Integer
id
);
/**
* 根据装备id更新生命状态
* @param lifeStatus 生命状态
* @param ids 装备id的集合
* @return
*/
int
batchUpdate2
(
Integer
lifeStatus
,
List
<
Integer
>
ids
);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param packingId 列装id
* @return 影响行数
*/
int
updateMatchingRange
(
Integer
matchingRange
,
Integer
packingId
);
/**
* 根据列装id更新配用范围
* @param matchingRange 配用范围
* @param deviceIds 装备id的集合
* @return 影响行数
*/
int
updateMatchingRange2
(
Integer
matchingRange
,
@Param
(
"deviceIds"
)
List
<
Integer
>
deviceIds
);
/**
* 更新型号和列装id
* @param newModel 新的型号
* @param packingId 列装id
* @param deviceIds 装备id集合
* @return 影响行数
*/
int
updateModelAndPackingId
(
String
newModel
,
Integer
packingId
,
List
<
Integer
>
deviceIds
);
/**
* 根据装备id的集合更新列装id
* @param packingId 列装id
* @param deviceIds 装备id的集合
* @return 影响行数
*/
int
updatePackingId
(
Integer
packingId
,
List
<
Integer
>
deviceIds
);
/**
* 查询所有装备
*/
List
<
DeviceLibrary
>
findAllDevices
();
}
dev-library/src/main/java/com/tykj/dev/device/library/service/impl/CacheLibraryServiceImpl.java
浏览文件 @
16b2ca93
...
...
@@ -3,7 +3,9 @@ package com.tykj.dev.device.library.service.impl;
import
com.tykj.dev.device.library.repository.DeviceLibraryDao
;
import
com.tykj.dev.device.library.service.DeviceLibraryCacheService
;
import
com.tykj.dev.device.library.subject.domin.DeviceLibrary
;
import
lombok.extern.slf4j.Slf4j
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.beans.factory.annotation.Qualifier
;
import
org.springframework.cache.annotation.CacheConfig
;
import
org.springframework.cache.annotation.CacheEvict
;
import
org.springframework.cache.annotation.CachePut
;
...
...
@@ -13,6 +15,7 @@ import org.springframework.stereotype.Service;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.concurrent.Executor
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
...
...
@@ -22,20 +25,26 @@ import java.util.stream.Collectors;
*/
@Service
@CacheConfig
(
cacheNames
=
"devicesLibraryList"
)
@Slf4j
public
class
CacheLibraryServiceImpl
implements
DeviceLibraryCacheService
{
@Autowired
private
DeviceLibraryDao
deviceLibraryDao
;
@Autowired
@Qualifier
(
"taskExecutor"
)
private
Executor
executor
;
// @Autowired
// private ConcurrentMapCacheManager mapCacheManager;
@Autowired
private
DeviceLibraryCacheService
deviceLibraryCacheService
;
@Override
@Cacheable
(
key
=
"'device'"
)
public
List
<
DeviceLibrary
>
getAllDeviceLibraryList
()
{
long
l
=
System
.
currentTimeMillis
();
long
start
=
System
.
currentTimeMillis
();
List
<
DeviceLibrary
>
all
=
deviceLibraryDao
.
findAll
();
log
.
info
(
"缓存时间:{}"
,
System
.
currentTimeMillis
()
-
start
);
return
all
;
}
...
...
@@ -63,4 +72,14 @@ public class CacheLibraryServiceImpl implements DeviceLibraryCacheService {
// List<DeviceLibrary> all = deviceLibraryDao.findAll();
// System.out.println("更新缓存时间"+(System.currentTimeMillis()-l));
}
@Override
@CacheEvict
(
key
=
"'device'"
,
allEntries
=
true
)
public
void
asyncUpdateCache
()
{
executor
.
execute
(()->{
deviceLibraryCacheService
.
getAllDeviceLibraryList
();
});
}
}
dev-library/src/main/java/com/tykj/dev/device/library/service/impl/DeviceLibraryServiceImpl.java
浏览文件 @
16b2ca93
差异被折叠。
点击展开。
dev-library/src/main/java/com/tykj/dev/device/library/task/DevideTask.java
浏览文件 @
16b2ca93
...
...
@@ -19,11 +19,11 @@ public class DevideTask {
@Autowired
DeviceLibraryCacheService
deviceLibraryCacheService
;
@Scheduled
(
cron
=
"30 * * * * ? "
)
private
void
signUpDeadline
()
{
log
.
info
(
"定时device更新缓存开始"
);
deviceLibraryCacheService
.
deletAllDeviceLibraryList
();
deviceLibraryCacheService
.
getAllDeviceLibraryList
();
log
.
info
(
"定时device更新缓存结束"
);
}
//
@Scheduled(cron = "30 * * * * ? ")
//
private void signUpDeadline() {
//
log.info("定时device更新缓存开始");
//
deviceLibraryCacheService.deletAllDeviceLibraryList();
//
deviceLibraryCacheService.getAllDeviceLibraryList();
//
log.info("定时device更新缓存结束");
//
}
}
dev-union/src/main/java/com/tykj/dev/union/UpdateCacheAspect.java
0 → 100644
浏览文件 @
16b2ca93
package
com
.
tykj
.
dev
.
union
;
import
com.tykj.dev.device.library.service.DeviceLibraryCacheService
;
import
com.tykj.dev.device.library.subject.vo.FileVo
;
import
com.tykj.dev.device.matching.service.MatchingDeviceBillService
;
import
com.tykj.dev.device.matching.subject.domin.MatchingDeviceBill
;
import
lombok.extern.slf4j.Slf4j
;
import
org.aspectj.lang.JoinPoint
;
import
org.aspectj.lang.annotation.AfterReturning
;
import
org.aspectj.lang.annotation.Aspect
;
import
org.aspectj.lang.annotation.Pointcut
;
import
org.springframework.beans.factory.annotation.Autowired
;
import
org.springframework.stereotype.Component
;
/**
* 增强更新缓存aop
*
* @author zsp
*/
@Slf4j
@Aspect
@Component
public
class
UpdateCacheAspect
{
/**
* 业务新状态
*/
@Autowired
private
DeviceLibraryCacheService
deviceLibraryCacheService
;
/**
* 更新缓存定义切入点
*/
@Pointcut
(
"@annotation(com.tykj.dev.config.UpdateCache)"
)
public
void
operationLog
()
{
}
/**
* 新增结果返回后触发
*/
@AfterReturning
(
pointcut
=
"operationLog()"
)
public
void
doAfterReturning
(
JoinPoint
point
)
{
log
.
info
(
"开始更新缓存"
);
deviceLibraryCacheService
.
asyncUpdateCache
();
}
}
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论