自动化定时任务
parent
a04d840f98
commit
e542587200
|
|
@ -40,6 +40,11 @@ import java.util.stream.Collectors;
|
||||||
@Component("rollerAutoTask")
|
@Component("rollerAutoTask")
|
||||||
public class RollerAutoTask {
|
public class RollerAutoTask {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 优化:统一使用SLF4J日志(JDK 8兼容)
|
||||||
|
*/
|
||||||
|
private static final Logger log = LoggerFactory.getLogger(RollerAutoTask.class);
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ISysAgriInfoService agriInfoService;
|
private ISysAgriInfoService agriInfoService;
|
||||||
|
|
||||||
|
|
@ -64,21 +69,26 @@ public class RollerAutoTask {
|
||||||
@Resource
|
@Resource
|
||||||
private StringRedisTemplate stringRedisTemplate;
|
private StringRedisTemplate stringRedisTemplate;
|
||||||
|
|
||||||
/**
|
|
||||||
* 优化:统一使用SLF4J日志(JDK 8兼容)
|
|
||||||
*/
|
|
||||||
private static final Logger log = LoggerFactory.getLogger(RollerAutoTask.class);
|
|
||||||
|
|
||||||
|
|
||||||
@Value("${spring.mqtt.dtu-ctl-lock-ttl}")
|
@Value("${spring.mqtt.dtu-ctl-lock-ttl}")
|
||||||
private int dtuCtlLockTTL;
|
private int dtuCtlLockTTL;
|
||||||
|
|
||||||
|
// ========== 常量定义(新增) ==========
|
||||||
|
private static final int WORK_MODE_AUTO = 1; // 自动模式
|
||||||
|
private static final int NOT_DELETED = 0; // 未删除
|
||||||
|
private static final String LOCK_PREFIX = "lock:";
|
||||||
|
private static final String AUTO_MODE = "auto_mode";
|
||||||
|
private static final String CREATE_BY = "条件控制";
|
||||||
|
private static final int OP_SOURCE = 3; // 操作来源:条件控制
|
||||||
|
private static final int LOCK_ACQUIRED = 1; // 是否获取锁
|
||||||
|
|
||||||
public void checkAutoTerm() {
|
public void checkAutoTerm() {
|
||||||
|
|
||||||
// 查询自动模式的大棚
|
// 查询自动模式的大棚
|
||||||
List<SysAgriInfo> agriInfos = agriInfoService.lambdaQuery()
|
List<SysAgriInfo> agriInfos = agriInfoService.lambdaQuery()
|
||||||
.select(SysAgriInfo::getImei, SysAgriInfo::getAgriName)
|
.select(SysAgriInfo::getImei, SysAgriInfo::getAgriName)
|
||||||
.eq(SysAgriInfo::getWorkMode, 1)
|
.eq(SysAgriInfo::getWorkMode, WORK_MODE_AUTO)
|
||||||
.eq(SysAgriInfo::getIsDeleted, 0)
|
.eq(SysAgriInfo::getIsDeleted, NOT_DELETED)
|
||||||
.list();
|
.list();
|
||||||
if (CollectionUtils.isEmpty(agriInfos)) return;
|
if (CollectionUtils.isEmpty(agriInfos)) return;
|
||||||
// 取imei集合
|
// 取imei集合
|
||||||
|
|
@ -188,14 +198,6 @@ public class RollerAutoTask {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 公共常量(可抽取到常量类)
|
|
||||||
*/
|
|
||||||
private static final String LOCK_PREFIX = "lock:";
|
|
||||||
private static final String AUTO_MODE = "auto_mode";
|
|
||||||
private static final String CREATE_BY = "条件控制";
|
|
||||||
private static final int OP_SOURCE = 3; // 操作来源:条件控制
|
|
||||||
private static final int LOCK_ACQUIRED = 1; // 是否获取锁
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 发送开指令
|
* 发送开指令
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue