|
|
@ -58,6 +58,7 @@ import java.time.ZoneOffset; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.time.format.DateTimeFormatter; |
|
|
import java.util.ArrayList; |
|
|
import java.util.ArrayList; |
|
|
import java.util.List; |
|
|
import java.util.List; |
|
|
|
|
|
import java.util.concurrent.locks.ReentrantLock; |
|
|
|
|
|
|
|
|
@Slf4j |
|
|
@Slf4j |
|
|
public class IotDevicePowerOnAndOffDataJob { |
|
|
public class IotDevicePowerOnAndOffDataJob { |
|
|
@ -82,6 +83,8 @@ public class IotDevicePowerOnAndOffDataJob { |
|
|
return requestConfigBuilder; |
|
|
return requestConfigBuilder; |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
|
|
|
private static final ReentrantLock lock = new ReentrantLock(true); |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 当前索引日期后缀 |
|
|
* 当前索引日期后缀 |
|
|
*/ |
|
|
*/ |
|
|
@ -328,6 +331,7 @@ public class IotDevicePowerOnAndOffDataJob { |
|
|
GetIndexRequest exist = new GetIndexRequest(indicesName); |
|
|
GetIndexRequest exist = new GetIndexRequest(indicesName); |
|
|
// 先判断客户端是否存在 |
|
|
// 先判断客户端是否存在 |
|
|
try { |
|
|
try { |
|
|
|
|
|
lock.lock(); |
|
|
boolean exists = restHighLevelClient.indices().exists(exist, RequestOptions.DEFAULT); |
|
|
boolean exists = restHighLevelClient.indices().exists(exist, RequestOptions.DEFAULT); |
|
|
if (!exists) { |
|
|
if (!exists) { |
|
|
// 创建索引 |
|
|
// 创建索引 |
|
|
@ -387,6 +391,8 @@ public class IotDevicePowerOnAndOffDataJob { |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
e.printStackTrace(); |
|
|
e.printStackTrace(); |
|
|
|
|
|
}finally { |
|
|
|
|
|
lock.unlock(); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |