模板调整

This commit is contained in:
xy
2024-11-28 16:30:05 +08:00
parent 0c2954b8ba
commit b5267c24f4
2 changed files with 4 additions and 4 deletions

View File

@@ -39,7 +39,6 @@ public class AccessApplicationRunner implements ApplicationRunner {
private final DictTreeFeignClient dictTreeFeignClient; private final DictTreeFeignClient dictTreeFeignClient;
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
ExecutorService executor = Executors.newFixedThreadPool(10);
private static final long ACCESS_TIME = 60L; private static final long ACCESS_TIME = 60L;
@Override @Override
@@ -49,6 +48,7 @@ public class AccessApplicationRunner implements ApplicationRunner {
log.info("系统重启,所有符合条件的装置全部接入!"); log.info("系统重启,所有符合条件的装置全部接入!");
List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getOnlineDev(); List<CsEquipmentDeliveryPO> list = csEquipmentDeliveryService.getOnlineDev();
if (CollUtil.isNotEmpty(list)) { if (CollUtil.isNotEmpty(list)) {
ExecutorService executor = Executors.newFixedThreadPool(10);
// 将任务平均分配给10个子列表 // 将任务平均分配给10个子列表
List<List<CsEquipmentDeliveryPO>> subLists = new ArrayList<>(); List<List<CsEquipmentDeliveryPO>> subLists = new ArrayList<>();
int partitionSize = list.size() / 10; int partitionSize = list.size() / 10;
@@ -57,7 +57,6 @@ public class AccessApplicationRunner implements ApplicationRunner {
int end = (i == 9) ? list.size() : start + partitionSize; int end = (i == 9) ? list.size() : start + partitionSize;
subLists.add(list.subList(start, end)); subLists.add(list.subList(start, end));
} }
// 创建一个ExecutorService来处理这些任务 // 创建一个ExecutorService来处理这些任务
List<Future<Void>> futures = new ArrayList<>(); List<Future<Void>> futures = new ArrayList<>();
// 提交任务给线程池执行 // 提交任务给线程池执行
@@ -81,10 +80,10 @@ public class AccessApplicationRunner implements ApplicationRunner {
} }
// 关闭ExecutorService // 关闭ExecutorService
executor.shutdown(); executor.shutdown();
scheduler.shutdown();
} }
}; };
scheduler.schedule(task,ACCESS_TIME,TimeUnit.SECONDS); scheduler.schedule(task,ACCESS_TIME,TimeUnit.SECONDS);
scheduler.shutdown();
} }
public void accessDev(List<CsEquipmentDeliveryPO> list) { public void accessDev(List<CsEquipmentDeliveryPO> list) {

View File

@@ -65,6 +65,7 @@ public class StatServiceImpl implements IStatService {
dataArrayParam.setId(appAutoDataMessage.getId()); dataArrayParam.setId(appAutoDataMessage.getId());
dataArrayParam.setDid(appAutoDataMessage.getDid()); dataArrayParam.setDid(appAutoDataMessage.getDid());
dataArrayParam.setCldId(appAutoDataMessage.getMsg().getClDid()); dataArrayParam.setCldId(appAutoDataMessage.getMsg().getClDid());
dataArrayParam.setIdx(appAutoDataMessage.getMsg().getDsNameIdx());
List<AppAutoDataMessage.DataArray> list = appAutoDataMessage.getMsg().getDataArray(); List<AppAutoDataMessage.DataArray> list = appAutoDataMessage.getMsg().getDataArray();
//获取监测点id //获取监测点id
String lineId = null; String lineId = null;
@@ -113,7 +114,7 @@ public class StatServiceImpl implements IStatService {
default: default:
break; break;
} }
String key = AppRedisKey.DEV_MODEL.concat(dataArrayParam.getId() + dataArrayParam.getDid() + dataArrayParam.getCldId() + dataArrayParam.getStatMethod()); String key = AppRedisKey.DEV_MODEL.concat(dataArrayParam.getId() + dataArrayParam.getDid() + dataArrayParam.getCldId() + dataArrayParam.getStatMethod() + dataArrayParam.getIdx());
Object object = redisUtil.getObjectByKey(key); Object object = redisUtil.getObjectByKey(key);
List<CsDataArray> dataArrayList; List<CsDataArray> dataArrayList;
if (Objects.isNull(object)){ if (Objects.isNull(object)){