Commit cc8fbfd7 authored by jichao's avatar jichao

查询城市室外温度,改为每隔3小时查询一次

parent ea86d043
package org.rcisoft.business.mainte.adaptive.dao; package org.rcisoft.business.mainte.adaptive.dao;
import org.apache.ibatis.annotations.Insert; import org.apache.ibatis.annotations.*;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.ResultType;
import org.apache.ibatis.annotations.Select;
import org.rcisoft.business.mainte.adaptive.entity.BusTemperature; import org.rcisoft.business.mainte.adaptive.entity.BusTemperature;
import org.rcisoft.business.mainte.adaptive.vo.Params; import org.rcisoft.business.mainte.adaptive.vo.Params;
import org.springframework.stereotype.Repository; import org.springframework.stereotype.Repository;
...@@ -37,4 +34,10 @@ public interface BusTemperatureRepository { ...@@ -37,4 +34,10 @@ public interface BusTemperatureRepository {
@ResultType(Integer.class) @ResultType(Integer.class)
Integer batchSaveBusTemperature(List<BusTemperature> list); Integer batchSaveBusTemperature(List<BusTemperature> list);
@Delete("<script><foreach collection=\"list\" item=\"item\" open=\"\" close=\"\" separator=\";\">" +
"delete from bus_temperature where TM=#{item.tm} and CODE=#{item.code}" +
"</foreach></script>")
@ResultType(Integer.class)
Integer batchDeleteBusTemperature(List<BusTemperature> list);
} }
...@@ -188,7 +188,8 @@ public class AdaptiveServiceImpl implements AdaptiveService { ...@@ -188,7 +188,8 @@ public class AdaptiveServiceImpl implements AdaptiveService {
cityCodeList.forEach(s -> { cityCodeList.forEach(s -> {
saveList.addAll(this.fromWeather(s)); saveList.addAll(this.fromWeather(s));
}); });
//3.将所有的结果插入bus_temperature表(批量) //3.先根据结果,删除已经存在的数据,再将所有的结果插入bus_temperature表(批量)
Integer d = busTemperatureRepository.batchDeleteBusTemperature(saveList);
Integer i = busTemperatureRepository.batchSaveBusTemperature(saveList); Integer i = busTemperatureRepository.batchSaveBusTemperature(saveList);
return new PersistModel(i); return new PersistModel(i);
} }
......
...@@ -15,9 +15,9 @@ public class AdaptiveTask { ...@@ -15,9 +15,9 @@ public class AdaptiveTask {
private AdaptiveService adaptiveServiceImpl; private AdaptiveService adaptiveServiceImpl;
/** /**
* 每天0点5分执行,查询所有项目中存在的城市,未来24小时的温度 * 每间隔3小时的第5分钟执行,查询所有项目中存在的城市,未来24小时的温度
*/ */
@Scheduled(cron = "0 5 0 * * ?") @Scheduled(cron = "0 5 */3 * * ?")
public void temperature () { public void temperature () {
adaptiveServiceImpl.temperature(); adaptiveServiceImpl.temperature();
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment