Commit 86ff61e9 authored by yanzg's avatar yanzg

表结构修改

parent d909b18e
package com.yanzuoguang.redis.level;
import com.yanzuoguang.redis.PlanLevelNamespaceDefault;
import com.yanzuoguang.redis.vo.PlanLevelType;
import com.yanzuoguang.util.helper.StringHelper;
import org.springframework.stereotype.Component;
/**
* 程序级别
*
* @author 颜佐光
*/
@Component
public class PlanLevelNamespaceProgram implements PlanLevelNamespaceDefault {
private final PlanLevelNamespaceServerIp planLevelNamespaceServerIp;
private final PlanLevelNamespaceApplication planLevelNamespaceApplication;
public PlanLevelNamespaceProgram(PlanLevelNamespaceServerIp planLevelNamespaceServerIp, PlanLevelNamespaceApplication planLevelNamespaceApplication) {
this.planLevelNamespaceServerIp = planLevelNamespaceServerIp;
this.planLevelNamespaceApplication = planLevelNamespaceApplication;
}
@Override
public String getLevelNamespace() {
return StringHelper.getId(
planLevelNamespaceServerIp.getLevelNamespace(),
planLevelNamespaceApplication.getLevelNamespace()
);
}
@Override
public PlanLevelType getLevel() {
return PlanLevelType.Program;
}
}
package com.yanzuoguang.redis.level;
import com.yanzuoguang.redis.PlanLevelNamespaceDefault;
import com.yanzuoguang.redis.vo.PlanLevelType;
import com.yanzuoguang.util.helper.UrlHelper;
import org.springframework.stereotype.Component;
/**
* 服务器Ip级别
*
* @author 颜佐光
*/
@Component
public class PlanLevelNamespaceServerIp implements PlanLevelNamespaceDefault {
@Override
public String getLevelNamespace() {
return UrlHelper.getIp();
}
@Override
public PlanLevelType getLevel() {
return PlanLevelType.ServerIp;
}
}
......@@ -32,15 +32,11 @@ public class PlanConsumer {
* @param channel 连接频道
*/
public void plan(String json, Message message, Channel channel) {
try {
mqService.basicHandle(message,channel,json,content->{
PlanInfo<String> timeNew = JsonHelper.deserialize(json, new TypeReference<PlanInfo<String>>() {
});
// 获取运行的任务
planService.runPlan(timeNew);
} catch (Exception ex) {
ex.printStackTrace();
} finally {
mqService.basicAck(message, channel);
}
});
}
}
......@@ -15,14 +15,6 @@ public enum PlanLevelType {
* SpringBoot同Application.Name 级别
*/
Application("Application", 1),
/**
* 同一个程序级别
*/
ServerIp("ServerIp", 2),
/**
* 同一个程序级别
*/
Program("Program", 3),
/**
* 自定义级别,
* 自定义需要任务实现 PlanLevelNamespace 接口,
......@@ -45,7 +37,7 @@ public enum PlanLevelType {
* @param name 名称
* @param id id
*/
private PlanLevelType(String name, int id) {
PlanLevelType(String name, int id) {
this.name = name;
this.id = id;
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment