|
@@ -40,33 +40,37 @@ public class OpcTask {
|
|
|
*/
|
|
|
@Scheduled(fixedDelay = 100000)
|
|
|
public void addAndDelItems() {
|
|
|
- RedisUtils.setString(RedisKeyConstants.redis_opc_update_flag, "1");
|
|
|
- List<String> list = RedisUtils.getList(RedisKeyConstants.redis_opc_wait_add_list, 0, -1);
|
|
|
- if (!CollectionUtils.isEmpty(list)) {
|
|
|
- List<String> uniqueStr = list.stream().distinct().collect(Collectors.toList());
|
|
|
- if (!CollectionUtils.isEmpty(uniqueStr)) {
|
|
|
- List<RemoteOpc> remoteOpcList = OpcDAClient.addGroupAndItems(findAllItems(uniqueStr));
|
|
|
- if(!CollectionUtils.isEmpty(remoteOpcList)){
|
|
|
- remoteOpcMapper.updateBatch(remoteOpcList);
|
|
|
- // log.info("添加新点位:" + uniqueStr);
|
|
|
+ log.info("启动追加");
|
|
|
+ String ok = RedisUtils.getString(RedisKeyConstants.redis_ok);
|
|
|
+ if (StringUtils.isBlank(ok)) {
|
|
|
+ RedisUtils.setString(RedisKeyConstants.redis_opc_update_flag, "1");
|
|
|
+ List<String> list = RedisUtils.getList(RedisKeyConstants.redis_opc_wait_add_list, 0, -1);
|
|
|
+ if (!CollectionUtils.isEmpty(list)) {
|
|
|
+ List<String> uniqueStr = list.stream().distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(uniqueStr)) {
|
|
|
+ List<RemoteOpc> remoteOpcList = OpcDAClient.addGroupAndItems(findAllItems(uniqueStr));
|
|
|
+ if (!CollectionUtils.isEmpty(remoteOpcList)) {
|
|
|
+ remoteOpcMapper.updateBatch(remoteOpcList);
|
|
|
+ // log.info("添加新点位:" + uniqueStr);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
- }
|
|
|
- RedisUtils.del(RedisKeyConstants.redis_opc_wait_add_list);
|
|
|
+ RedisUtils.del(RedisKeyConstants.redis_opc_wait_add_list);
|
|
|
|
|
|
- List<String> removeList = RedisUtils.getList(RedisKeyConstants.redis_opc_wait_remove_list, 0, -1);
|
|
|
- if (!CollectionUtils.isEmpty(removeList)) {
|
|
|
- List<RemoteOpc> remoteOpcList = findAllItems(removeList);
|
|
|
- if (!CollectionUtils.isEmpty(remoteOpcList)) {
|
|
|
- List<RemoteOpc> uniqueStr = remoteOpcList.stream().distinct().collect(Collectors.toList());
|
|
|
- if (!CollectionUtils.isEmpty(uniqueStr)) {
|
|
|
- OpcDAClient.removeItems(remoteOpcList.stream().collect(Collectors.groupingBy(RemoteOpc::getLine)));
|
|
|
- log.info("移除点位:" + removeList);
|
|
|
+ List<String> removeList = RedisUtils.getList(RedisKeyConstants.redis_opc_wait_remove_list, 0, -1);
|
|
|
+ if (!CollectionUtils.isEmpty(removeList)) {
|
|
|
+ List<RemoteOpc> remoteOpcList = findAllItems(removeList);
|
|
|
+ if (!CollectionUtils.isEmpty(remoteOpcList)) {
|
|
|
+ List<RemoteOpc> uniqueStr = remoteOpcList.stream().distinct().collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(uniqueStr)) {
|
|
|
+ OpcDAClient.removeItems(remoteOpcList.stream().collect(Collectors.groupingBy(RemoteOpc::getLine)));
|
|
|
+ log.info("移除点位:" + removeList);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
+ RedisUtils.del(RedisKeyConstants.redis_opc_wait_remove_list);
|
|
|
+ RedisUtils.del(RedisKeyConstants.redis_opc_update_flag);
|
|
|
}
|
|
|
- RedisUtils.del(RedisKeyConstants.redis_opc_wait_remove_list);
|
|
|
- RedisUtils.del(RedisKeyConstants.redis_opc_update_flag);
|
|
|
}
|
|
|
|
|
|
|