find()预警缓存

dev.yang
Yueng 2024-10-10 14:25:30 +08:00
parent 7d0d0418c6
commit ecd84b4672
3 changed files with 46 additions and 1 deletions

View File

@ -0,0 +1,27 @@
package com.muyu.enterprise.cache.warn;
import com.muyu.common.cache.CacheAbsBasic;
import com.muyu.domain.WarnStrategy;
import com.muyu.domain.resp.CarFenceResp;
import java.util.List;
/**
*
* @Authoryang
* @Packagecom.muyu.cache
* @Projectcloud-server-8
* @nameVehicleCacheService
* @Date2024/9/30 11:50
*/
public class VehicleCacheWarnService extends CacheAbsBasic<String, List<WarnStrategy>> {
@Override
public String keyPre() {
return "WarnStrategy:info:";
}
@Override
public String decode(String key) {
return key.replace("vehicle:info:","");
}
}

View File

@ -6,3 +6,4 @@ com.muyu.enterprise.cache.faultCode.VehicleCacheFaultCodeAddService
com.muyu.enterprise.cache.fence.VehicleCacheFenceService com.muyu.enterprise.cache.fence.VehicleCacheFenceService
com.muyu.enterprise.cache.fence.VehicleCacheFenceAddService com.muyu.enterprise.cache.fence.VehicleCacheFenceAddService
com.muyu.enterprise.cache.fault.VehicleCacheFaultService com.muyu.enterprise.cache.fault.VehicleCacheFaultService
com.muyu.enterprise.cache.warn.VehicleCacheWarnService

View File

@ -3,11 +3,15 @@ package com.muyu.server.service.impl;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.muyu.common.core.utils.StringUtils; import com.muyu.common.core.utils.StringUtils;
import com.muyu.domain.CarInformation;
import com.muyu.domain.CarType; import com.muyu.domain.CarType;
import com.muyu.domain.WarnStrategy; import com.muyu.domain.WarnStrategy;
import com.muyu.domain.req.WarnStrategyReq; import com.muyu.domain.req.WarnStrategyReq;
import com.muyu.enterprise.cache.warn.VehicleCacheWarnService;
import com.muyu.server.mapper.WarnStrategyMapper; import com.muyu.server.mapper.WarnStrategyMapper;
import com.muyu.server.service.CarInformationService;
import com.muyu.server.service.WarnStrategyService; import com.muyu.server.service.WarnStrategyService;
import lombok.AllArgsConstructor;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
@ -23,10 +27,14 @@ import java.util.List;
* @Date2024/9/20 7:29 * @Date2024/9/20 7:29
*/ */
@Service @Service
@AllArgsConstructor
public class WarnStrategyServiceImpl public class WarnStrategyServiceImpl
extends ServiceImpl<WarnStrategyMapper, WarnStrategy> extends ServiceImpl<WarnStrategyMapper, WarnStrategy>
implements WarnStrategyService { implements WarnStrategyService {
private final CarInformationService carInformationService;
private final VehicleCacheWarnService vehicleCacheWarnService;
/** /**
* *
* *
@ -62,7 +70,16 @@ public class WarnStrategyServiceImpl
if (StringUtils.isNotNull(warnStrategy.getMsgId())){ if (StringUtils.isNotNull(warnStrategy.getMsgId())){
queryWrapper.eq(WarnStrategy::getMsgId, warnStrategy.getMsgId()); queryWrapper.eq(WarnStrategy::getMsgId, warnStrategy.getMsgId());
} }
return this.list(queryWrapper); List<WarnStrategy> list = this.list(queryWrapper);
list.forEach(warnStrategy1 -> {
List<CarInformation> list1 = carInformationService
.list(new LambdaQueryWrapper<CarInformation>()
.eq(CarInformation::getCarInformationType, warnStrategy1.getCarTypeId()));
list1.forEach(carInformation -> {
vehicleCacheWarnService.put(vehicleCacheWarnService.keyPre()+carInformation.getCarInformationVIN(),list);
});
});
return list;
} }
/** /**