feat:()优化代码

dev.redis
sy200 2024-10-06 14:42:13 +08:00
parent 832da812c3
commit 0be090d11b
14 changed files with 83 additions and 69 deletions

View File

@ -13,11 +13,11 @@ public class AllFaultCacheService extends CacheAbsBacis {
@Override
public String keyPre() {
return "Allfault:info:";
return "AllFault:info:";
}
@Override
public String decode(String key) {
return key.replace("Allfault:info:", "");
return key.replace("AllFault:info:", "");
}
}

View File

@ -16,12 +16,12 @@ public class AllFenceCahceService extends CacheAbsBacis<String, FenceResp> {
@Override
public String keyPre() {
return "Allfence:info:";
return "AllFence:info:";
}
@Override
public String decode(String key) {
return key.replace("Allfence:info:", "");
return key.replace("AllFence:info:", "");
}
}

View File

@ -19,11 +19,11 @@ public class AllMessageValueCacheService extends CacheAbsBacis<String, MessageVa
@Override
public String keyPre() {
return "Allmessagevalue:info:";
return "AllMessagevalue:info:";
}
@Override
public String decode(String key) {
return key.replace("Allmessagevalue:info:", "");
return key.replace("AllMessagevalue:info:", "");
}
}

View File

@ -25,12 +25,12 @@ public class AllVehicleCacheService extends CacheAbsBacis<String, VehicleManageR
*/
@Override
public String keyPre() {
return "allvehicle:info:";
return "AllVehicle:info:";
}
@Override
public String decode(String key) {
return key.replace("allvehicle:info:", "");
return key.replace("AllVehicle:info:", "");
}
}

View File

@ -14,11 +14,11 @@ public class AllVehicleTypeCacheService extends CacheAbsBacis<String, VehicleTyp
@Override
public String keyPre() {
return "vehicleType:info:";
return "AllVehicleType:info:";
}
@Override
public String decode(String key) {
return key.replace("vehicleType:info:", "");
return key.replace("AllVehicleType:info:", "");
}
}

View File

@ -0,0 +1,24 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.CacheAbsBacis;
import com.muyu.domain.WarnRule;
/**
*
*/
public class AllWarnRuleCacheService extends CacheAbsBacis<String, WarnRule> {
@Override
public void clear() {
}
@Override
public String keyPre() {
return "AllWarnRule:info:";
}
@Override
public String decode(String key) {
return key.replace("AllWarnRule:info:", "");
}
}

View File

@ -0,0 +1,24 @@
package com.muyu.enterprise.cache;
import com.muyu.common.cache.CacheAbsBacis;
import com.muyu.domain.WarnStrategy;
/**
*
*/
public class AllWarnStrategyCacheService extends CacheAbsBacis<String, WarnStrategy> {
@Override
public void clear() {
}
@Override
public String keyPre() {
return "AllWarnStrategy:info:";
}
@Override
public String decode(String key) {
return key.replace("AllWarnStrategy:info:", "");
}
}

View File

@ -3,6 +3,8 @@ com.muyu.enterprise.cache.AllFenceCahceService
com.muyu.enterprise.cache.AllMessageValueCacheService
com.muyu.enterprise.cache.AllVehicleCacheService
com.muyu.enterprise.cache.AllVehicleTypeCacheService
com.muyu.enterprise.cache.AllWarnRuleCacheService
com.muyu.enterprise.cache.AllWarnStrategyCacheService
com.muyu.enterprise.cache.FaultCacheService
com.muyu.enterprise.cache.FenceCahceService
com.muyu.enterprise.cache.MessageTemplateCacheService

View File

@ -1,55 +0,0 @@
//package com.muyu.domain.req;
//
//import com.baomidou.mybatisplus.annotation.IdType;
//import com.baomidou.mybatisplus.annotation.TableId;
//import com.muyu.domain.Fence;
//import io.swagger.v3.oas.annotations.media.Schema;
//import io.swagger.v3.oas.annotations.tags.Tag;
//import lombok.AllArgsConstructor;
//import lombok.Builder;
//import lombok.Data;
//import lombok.NoArgsConstructor;
//
//import java.util.List;
//
//@Data
//@Builder
//@AllArgsConstructor
//@NoArgsConstructor
//@Tag(name = "查看绑定的围栏信息")
//public class HaveFence {
//
// /**
// * 主键
// */
// @Schema(type = "Long",description = "主键")
// @TableId(value = "id",type = IdType.AUTO)
// private Long id;
//
// /**
// * 围栏名称
// */
// @Schema(type = "String",description = "围栏名称")
// private String fenceName;
//
// /**
// * 坐标
// */
// @Schema(type = "String",description = "坐标")
// private String coordinates;
//
// /**
// * 描述
// */
// @Schema(type = "String",description = "描述")
// private String description;
//
// /**
// * 电子围栏列表
// */
// @Schema(type = "List<Fence>",description = "电子围栏列表")
// List<Fence> fenceList;
//
//
//
//}

View File

@ -148,7 +148,7 @@ public class ElectController extends BaseController {
@DeleteMapping("/delMoreFence")
@Operation(description = "批量删除电子围栏")
public Result delMore(@RequestBody List<Long> fenceIds){
// electService.delMoreFence(fenceIds);
//批量删除内容存到Redis
electService.removeBatchByIds(fenceIds);
return Result.success(null,"操作成功");
}

View File

@ -156,7 +156,7 @@ public class VehicleController extends BaseController {
/**
*
*/
@GetMapping("/addBoundFenceGroup")
@PostMapping("/addBoundFenceGroup")
@Operation(description = "车辆绑定围栏组")
public Result boundFenceGroup(
@Validated @RequestBody BoundFenceGroupReq boundFenceGroupReq){

View File

@ -4,6 +4,7 @@ import com.muyu.common.core.domain.Result;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.domain.WarnRule;
import com.muyu.enterprise.cache.AllWarnRuleCacheService;
import com.muyu.enterprise.cache.WarnRuleCacheService;
import com.muyu.enterprise.service.WarnRuleService;
import io.swagger.v3.oas.annotations.Operation;
@ -22,6 +23,10 @@ public class WarnRuleController {
@Autowired
private WarnRuleCacheService warnRuleCacheService;
//存列表
@Autowired
private AllWarnRuleCacheService allWarnRuleCacheServicel;
/**
*
* @return
@ -29,7 +34,11 @@ public class WarnRuleController {
@RequestMapping(path = "/ruleList",method = RequestMethod.POST)
@Operation(summary = "规则列表", description = "获取所有规则列表")
public Result<List<WarnRule>> ruleList(){
return Result.success(warnRuleService.list());
List<WarnRule> list = warnRuleService.list();
for (WarnRule warnRule : list) {
allWarnRuleCacheServicel.put(warnRule.getRuleName(),warnRule);
}
return Result.success(list);
}
/**

View File

@ -4,6 +4,7 @@ import com.muyu.common.core.domain.Result;
import com.muyu.common.security.utils.SecurityUtils;
import com.muyu.common.system.domain.LoginUser;
import com.muyu.domain.WarnStrategy;
import com.muyu.enterprise.cache.AllWarnStrategyCacheService;
import com.muyu.enterprise.cache.WarnStrategyCacheService;
import com.muyu.enterprise.service.WarnStrategyService;
import com.muyu.domain.req.WarnVehicleReq;
@ -26,6 +27,10 @@ public class WarnStrategyController {
@Autowired
private WarnStrategyCacheService warnStrategyCacheService;
//列表
@Autowired
private AllWarnStrategyCacheService allWarnStrategyCacheService;
/**
*
* @return
@ -33,7 +38,12 @@ public class WarnStrategyController {
@RequestMapping(path = "/strategyList",method = RequestMethod.POST)
@Operation(summary = "策略列表", description = "获取所有策略列表")
public Result<List<WarnStrategy>> strategyList() {
return Result.success(warnStrategyService.list());
List<WarnStrategy> list = warnStrategyService.list();
//存进Redis
for (WarnStrategy warnStrategy : list) {
allWarnStrategyCacheService.put(String.valueOf(warnStrategy.getWarnStrategyId()),warnStrategy);
}
return Result.success(list);
}
/**