提交 16b2ca93 authored 作者: zhoushaopan's avatar zhoushaopan

feat(装备模块,缓存模块): 新增了自定义注解,增加了装备的接口,完善缓存的维护,新增缓存更新接口

新增了自定义注解,增加了装备的接口,完善缓存的维护,新增缓存更新接口
上级 3aaf1260
......@@ -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");
......
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 "";
}
......@@ -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("绑定成功");
}
/**
* 测试
*/
......
......@@ -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);
}
......@@ -26,4 +26,6 @@ public interface DeviceLibraryCacheService {
void deletAllDeviceLibraryList();
void asyncUpdateCache();
}
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();
}
......@@ -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();
});
}
}
......@@ -5,12 +5,16 @@ import com.github.wenhao.jpa.Specifications;
import com.tykj.dev.blockcha.subject.entity.BcHash;
import com.tykj.dev.blockcha.subject.service.BlockChainUtil;
import com.tykj.dev.config.TaskBeanConfig;
import com.tykj.dev.config.UpdateCache;
import com.tykj.dev.config.base.DeviceLifeStatus;
import com.tykj.dev.device.library.controller.CacheLibraryController;
import com.tykj.dev.device.library.repository.DeviceLibraryDao;
import com.tykj.dev.device.library.service.DeviceLibraryCacheService;
import com.tykj.dev.device.library.service.DeviceLibraryService;
import com.tykj.dev.device.library.service.DeviceLogService;
import com.tykj.dev.device.library.subject.Dto.DeviceLogDto;
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 com.tykj.dev.device.library.utils.DeviceNumberUtils;
......@@ -61,7 +65,14 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Autowired
private DeviceLibraryCacheService cacheLibraryService;
@Autowired
private DeviceLogService deviceLogService;
@Autowired
private DeviceLibraryCacheService deviceLibraryCacheService;
@Override
@UpdateCache
public DeviceLibrary addEntity(DeviceLibrary deviceLibraryEntity) {
DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity);
CompletableFuture.runAsync(()->{
......@@ -550,7 +561,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Override
public Map<Integer, DeviceLibrary> getAllDeviceMap() {
List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
// List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
List<DeviceLibrary> libraries = cacheLibraryService.getAllDeviceLibraryList();
libraries.forEach(DeviceLibrary::setConfigName);
return libraries.stream().collect(Collectors.toMap(DeviceLibrary::getId, Function.identity()));
}
......@@ -560,7 +572,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
*/
@Override
public Map<String, DeviceLibrary> getAllDeviceSeqMap() {
List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
// List<DeviceLibrary> libraries = deviceLibraryDao.findAll();
List<DeviceLibrary> libraries = cacheLibraryService.getAllDeviceLibraryList();
List<String> seqs = new ArrayList<>();
Iterator<DeviceLibrary> iterator = libraries.iterator();
while (iterator.hasNext()){
......@@ -606,11 +619,13 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void updateLifeStatus(Integer lifeStatus,Integer id) {
deviceLibraryDao.batchUpdate(lifeStatus,id);
}
@Override
@UpdateCache
public void updateLifeStatus2(Integer lifeStatus, List<Integer> ids) {
deviceLibraryDao.batchUpdate2(lifeStatus,ids);
}
......@@ -630,7 +645,8 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
@Cacheable()
public List<DeviceLibrary> getAllDeviceList(DeviceLibrarySelectVo deviceLibrarySelectVo) {
long l = System.currentTimeMillis();
List<DeviceLibrary> all = deviceLibraryDao.findAll();
// List<DeviceLibrary> all = deviceLibraryDao.findAll();
List<DeviceLibrary> all = cacheLibraryService.getAllDeviceLibraryList();
System.out.println("查询时间为"+(System.currentTimeMillis()-l));
return all;
}
......@@ -675,6 +691,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void batchUpdateDevices(String oldModel,String newModel) {
deviceLibraryDao.batchUpdateDevices(oldModel,newModel);
}
......@@ -742,11 +759,13 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void updateDevicesOwnUnit(List<Integer> deviceIds) {
deviceLibraryDao.updateDevicesOwnUnit(deviceIds);
}
@Override
@UpdateCache
public void updateLocalAndOwn(String localUnit,List<Integer> deviceIds) {
deviceLibraryDao.updateDevicesOwnUnit(localUnit,deviceIds);
}
......@@ -787,12 +806,158 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void updateMatchingRange(List<DeviceLibrary> libraries) {
}
@Override
@UpdateCache
public void relieveDevice(int deviceId) {
Integer currentUserId = userUtils.getCurrentUserId();
//根据装备id查询附件
List<DeviceLibrary> deviceLibraries = deviceLibraryDao.findAllByPartParentId(deviceId);
deviceLibraries.forEach(deviceLibrary -> {
deviceLibrary.setPartParentId(null);
update(deviceLibrary);
//添加日志
String remark = "该装备进行解绑";
DeviceLogDto deviceLogDto = new DeviceLogDto(deviceId, remark, null,currentUserId,null);
deviceLogService.addLog(deviceLogDto);
});
}
@Override
@UpdateCache
public void bindingDevice(BindingDeviceVo bindingDeviceVo) {
Integer currentUserId = userUtils.getCurrentUserId();
//查询需要绑定的装备的型号和被绑定的装备的型号
DeviceLibrary originDev = deviceLibraryDao.findById(bindingDeviceVo.getOriginDeviceId()).get();
DeviceLibrary toDev = deviceLibraryDao.findById(bindingDeviceVo.getToDeviceId()).get();
if (!originDev.getModel().equals(toDev.getModel())){
//型号进行修改
List<DeviceLibrary> libraries = deviceLibraryDao.findAllByPartParentId(originDev.getId());
libraries.forEach(deviceLibrary -> {
deviceLibrary.setModel(toDev.getModel());
update(deviceLibrary);
});
String remark = "由于需要进行装备的绑定,原来型号修改为"+toDev.getModel();
DeviceLogDto deviceLogDto = new DeviceLogDto(toDev.getId(), remark, null,currentUserId,null);
deviceLogService.addLog(deviceLogDto);
}
originDev.setModel(toDev.getModel());
originDev.setPartParentId(toDev.getId());
update(originDev);
//添加日志
String remark = "原装备和"+toDev.getName()+"的装备进行绑定";
DeviceLogDto deviceLogDto = new DeviceLogDto(toDev.getId(), remark, null,currentUserId,null);
deviceLogService.addLog(deviceLogDto);
}
@Override
@UpdateCache
public void upDateSeqNumbersApplyTaskId(Integer taskId, List<String> seqNumbers) {
deviceLibraryDao.upDateSeqNumbersApplyTaskId(taskId,seqNumbers);
}
@Override
public List<DeviceLibrary> findAllByOwnUnit(String ownUnit) {
return deviceLibraryDao.findAllByOwnUnit(ownUnit);
}
@Override
public List<DeviceLibrary> getAllByRfidCardId(String rfidCardId) {
return deviceLibraryDao.getAllByRfidCardId(rfidCardId);
}
@Override
public int upDateLeftStatus(Integer lifeStatus, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatus(lifeStatus,idList);
}
@Override
public int upDateSeqNumbersLeftStatus(Integer lifeStatus, List<String> seqNumbers) {
return deviceLibraryDao.upDateSeqNumbersLeftStatus(lifeStatus,seqNumbers);
}
@Override
public int upDateLeftStatusAndLockStatus(Integer lifeStatus, Integer lock, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatusAndLockStatus(lifeStatus,lock,idList);
}
@Override
public int upDateLockStatus(Integer lock, List<Integer> idList) {
return deviceLibraryDao.upDateLockStatus(lock,idList);
}
@Override
public int upDateLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus, String unitName, Integer lock, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatusAndUnitNameAndLockStatus(lifeStatus,unitName,lock,idList);
}
@Override
public int upDateSeqNumbersLeftStatusAndUnitNameAndLockStatus(Integer lifeStatus, String unitName, Integer lock, List<String> seqNumbers) {
return deviceLibraryDao.upDateSeqNumbersLeftStatusAndUnitNameAndLockStatus(lifeStatus,unitName,lock,seqNumbers);
}
@Override
public int upDateLeftStatusAndOwnUnitName(Integer lifeStatus, String unitName, List<Integer> idList) {
return deviceLibraryDao.upDateLeftStatusAndOwnUnitName(lifeStatus,unitName,idList);
}
@Override
public int upDateRfidSurfaceIdAsSeqNumber(List<Integer> idList) {
return deviceLibraryDao.upDateRfidSurfaceIdAsSeqNumber(idList);
}
@Override
public int upDateName(String name, Integer packingId) {
return deviceLibraryDao.upDateName(name,packingId);
}
@Override
public int upDateMatchingRange(Integer matchingRange, Integer packingId) {
return deviceLibraryDao.upDateMatchingRange(matchingRange,packingId);
}
@Override
public int batchUpdate(Integer lifeStatus, Integer id) {
return deviceLibraryDao.batchUpdate(lifeStatus,id);
}
@Override
public int batchUpdate2(Integer lifeStatus, List<Integer> ids) {
return deviceLibraryDao.batchUpdate2(lifeStatus,ids);
}
@Override
public int updateMatchingRange(Integer matchingRange, Integer packingId) {
return deviceLibraryDao.updateMatchingRange(matchingRange,packingId);
}
@Override
public int updateMatchingRange2(Integer matchingRange, List<Integer> deviceIds) {
return deviceLibraryDao.updateMatchingRange2(matchingRange,deviceIds);
}
@Override
public int updateModelAndPackingId(String newModel, Integer packingId, List<Integer> deviceIds) {
return deviceLibraryDao.updateModelAndPackingId(newModel,packingId,deviceIds);
}
@Override
public int updatePackingId(Integer packingId, List<Integer> deviceIds) {
return deviceLibraryDao.updatePackingId(packingId,deviceIds);
}
@Override
public List<DeviceLibrary> findAllDevices() {
return cacheLibraryService.getAllDeviceLibraryList();
}
@Override
@UpdateCache
public DeviceLibrary update(DeviceLibrary deviceLibraryEntity) {
DeviceLibrary deviceLibrary = deviceLibraryDao.save(deviceLibraryEntity);
CompletableFuture.runAsync(()->blockChainUtil.appendHash(JacksonUtil.toJSon(deviceLibrary),deviceLibrary.getRecordId()),TaskBeanConfig.getThreadPoolTaskScheduler());
......@@ -811,6 +976,7 @@ public class DeviceLibraryServiceImpl implements DeviceLibraryService {
}
@Override
@UpdateCache
public void delete(Integer id) {
deviceLibraryDao.deleteById(id);
}
......
......@@ -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更新缓存结束");
// }
}
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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论