Browse Source

#水位调度任务执行

zhongwei
yang_shj 4 months ago
parent
commit
a919638092
  1. 4
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java
  2. 7
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java
  3. 38
      hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

4
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/ScheduledApplication.java

@ -21,11 +21,11 @@ import javax.annotation.Resource;
@Resource @Resource
public class ScheduledApplication extends SpringBootServletInitializer { public class ScheduledApplication extends SpringBootServletInitializer {
public static void main(String[] args) { public static void main(String[] args) {
BladeApplication.run("hzims-scheduled", ScheduledApplication.class, args); BladeApplication.run("hzims-scheduled-ysj", ScheduledApplication.class, args);
} }
@Override @Override
protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) { protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled", ScheduledApplication.class); return BladeApplication.createSpringApplicationBuilder(builder, "hzims-scheduled-ysj", ScheduledApplication.class);
} }
} }

7
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/scheduled/RealTargetScheduledTask.java

@ -110,9 +110,10 @@ public class RealTargetScheduledTask {
/** /**
* 水利-站点水位数据 * 水利-站点水位数据
*/ */
@XxlJob(LOAD_WATER_LEVEL) //@XxlJob(LOAD_WATER_LEVEL)
//@Scheduled(cron = "0/40 * * * * ? ") @Scheduled(cron = "0/40 * * * * ? ")
public ReturnT<String> loadWaterLevel(String param) { public ReturnT<String> loadWaterLevel() {
String param = "";
if (Func.isBlank(param)) { if (Func.isBlank(param)) {
param = DateUtil.format(new Date(), "yyyy-MM"); param = DateUtil.format(new Date(), "yyyy-MM");
} }

38
hzims-service/hzims-scheduled/src/main/java/com/hnac/hzims/scheduled/service/operation/home/impl/RealTargetServiceImpl.java

@ -545,7 +545,28 @@ public class RealTargetServiceImpl implements RealTargetService {
List<WaterLevelVo> list = new CopyOnWriteArrayList<>(); List<WaterLevelVo> list = new CopyOnWriteArrayList<>();
CountDownLatch countDownLatch = new CountDownLatch(modelList.size()); CountDownLatch countDownLatch = new CountDownLatch(modelList.size());
for(HzimsAnalyzeModelStationEntity item : modelList){ for(HzimsAnalyzeModelStationEntity item : modelList){
pool.submit(() -> { pool.execute(() -> {
this.queryWaterLeve(list,item);
countDownLatch.countDown();
});
}
try {
log.error("load_water_level :等待线程执行");
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
}
log.error("load_water_level :线程执行结束");
redisTemplate.opsForValue().set(loadwater_level_key,list);
}
/**
* 水位数据查询
* @param list
* @param item
*/
private void queryWaterLeve(List<WaterLevelVo> list,HzimsAnalyzeModelStationEntity item) {
try{ try{
List<MultiAnalyzeCodePO> multiAnalyzeCodePOList=new ArrayList<>(); List<MultiAnalyzeCodePO> multiAnalyzeCodePOList=new ArrayList<>();
MultiAnalyzeCodePO multiAnalyzeCodePO=new MultiAnalyzeCodePO(); MultiAnalyzeCodePO multiAnalyzeCodePO=new MultiAnalyzeCodePO();
@ -573,23 +594,10 @@ public class RealTargetServiceImpl implements RealTargetService {
waterLevelVo.setRearCurveMap(rearCurveMap); waterLevelVo.setRearCurveMap(rearCurveMap);
list.add(waterLevelVo); list.add(waterLevelVo);
} }
log.error("load_water_level : 线程执行完成 {}", item.getInstanceCode()); log.error("load_water_level : 小节线程执行完成 {}", item.getInstanceCode());
countDownLatch.countDown();
} catch (Exception exception) { } catch (Exception exception) {
log.error("load_water_level_error : 线程执行失败 {}", exception.getMessage()); log.error("load_water_level_error : 线程执行失败 {}", exception.getMessage());
countDownLatch.countDown();
}
});
}
try {
log.error("load_water_level :等待线程执行");
countDownLatch.await();
} catch (InterruptedException e) {
e.printStackTrace();
Thread.currentThread().interrupt();
} }
log.error("load_water_level :线程执行完成");
redisTemplate.opsForValue().set(loadwater_level_key,list);
} }
/** /**

Loading…
Cancel
Save