1、作物蒸腾量定时计算任务修改逻辑,以保证数据源准确性;2、修改null值bug。
|  |  |  | 
|---|
|  |  |  | List<VoWeatherMaxMinTmp> tmps = this.sv.selectYesterdayMaxMinTemperature(vo.weatherId) ; | 
|---|
|  |  |  | if(tmps != null && tmps.size() > 0){ | 
|---|
|  |  |  | VoWeatherMaxMinTmp voMmTmp = tmps.get(0);//只能有一条记录 | 
|---|
|  |  |  | Double et0 = this.calculateEt0(yesterday_ymd, vo, voWeather, voMmTmp, factor) ;//计算蒸腾数据 | 
|---|
|  |  |  | Integer count = this.saveEt0(yesterday_ymd, vo, voWeather, voMmTmp, factor, et0) ; | 
|---|
|  |  |  | if(voMmTmp != null && voMmTmp.maxAirTemperature != null && voMmTmp.minAirTemperature != null){ | 
|---|
|  |  |  | Double et0 = this.calculateEt0(yesterday_ymd, vo, voWeather, voMmTmp, factor) ;//计算蒸腾数据 | 
|---|
|  |  |  | this.saveEt0(yesterday_ymd, vo, voWeather, voMmTmp, factor, et0) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | public List<VoWeatherMaxMinTmp> selectYesterdayMaxMinTemperature(Long weatherId) throws Exception{ | 
|---|
|  |  |  | String ymd = DateTime.yesterday_yyyy_MM_dd(Integer.parseInt(DateTime.yyyy()), Integer.parseInt(DateTime.MM()), Integer.parseInt(DateTime.dd())) ; //昨天 | 
|---|
|  |  |  | int[] ymdGrp = DateTime.yyyy_MM_dd_2_ymdGroup(ymd) ; | 
|---|
|  |  |  | String yesterday = DateTime.lastXDay_yyyy_MM_dd(1) ; //昨天 | 
|---|
|  |  |  | // String yesterday = DateTime.yesterday_yyyy_MM_dd(Integer.parseInt(DateTime.yyyy()), Integer.parseInt(DateTime.MM()), Integer.parseInt(DateTime.dd())) ; //昨天 | 
|---|
|  |  |  | int[] ymdGrp = DateTime.yyyy_MM_dd_2_ymdGroup(yesterday) ; | 
|---|
|  |  |  | Long startId = IDLongGenerator.generateOneDayStartId(ymdGrp[0], ymdGrp[1], ymdGrp[2]) ; | 
|---|
|  |  |  | Long endId = IDLongGenerator.generateOneDayEndId(ymdGrp[0], ymdGrp[1], ymdGrp[2]) ; | 
|---|
|  |  |  | return this.rmWeatherHistoryDao.selectMaxMinTemperature(weatherId, startId, endId); | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.dy.common.multiDataSource.DataSourceContext; | 
|---|
|  |  |  | import com.dy.common.schedulerTask.TaskJob; | 
|---|
|  |  |  | import com.dy.common.springUtil.SpringContextUtil; | 
|---|
|  |  |  | import com.dy.pipIrrGlobal.util.Org; | 
|---|
|  |  |  | import com.dy.pipIrrModel.modelCalculate.ModelCalculator; | 
|---|
|  |  |  | import org.apache.logging.log4j.LogManager; | 
|---|
|  |  |  | import org.apache.logging.log4j.Logger; | 
|---|
|  |  |  | import org.quartz.JobDataMap; | 
|---|
|  |  |  | import org.quartz.JobExecutionContext; | 
|---|
|  |  |  | import org.quartz.JobExecutionException; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | import java.util.List; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | /** | 
|---|
|  |  |  | * @Author: liurunyu | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private static Logger log = LogManager.getLogger(CalculateJob.class.getName()) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private String orgTag ; | 
|---|
|  |  |  | private List<Org.OrgVo> orgList ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void execute(JobExecutionContext ctx) throws JobExecutionException { | 
|---|
|  |  |  | JobDataMap jobDataMap = ctx.getJobDetail().getJobDataMap() ; | 
|---|
|  |  |  | if(jobDataMap != null){ | 
|---|
|  |  |  | orgTag = (String)jobDataMap.get(ModelListener.orgKey) ; | 
|---|
|  |  |  | orgList = (List<Org.OrgVo>)jobDataMap.get(ModelListener.orgListKey) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(orgTag == null){ | 
|---|
|  |  |  | if(orgList == null){ | 
|---|
|  |  |  | return ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | DataSourceContext.set(orgTag);//设置数据源 | 
|---|
|  |  |  | ModelCalculator bean = (ModelCalculator)SpringContextUtil.getBean(ModelCalculator.selfBeanName); | 
|---|
|  |  |  | if(bean != null){ | 
|---|
|  |  |  | bean.execute(); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | for(Org.OrgVo vo : orgList){ | 
|---|
|  |  |  | DataSourceContext.set(vo.tag);//设置数据源 | 
|---|
|  |  |  | ModelCalculator bean = (ModelCalculator)SpringContextUtil.getBean(ModelCalculator.selfBeanName); | 
|---|
|  |  |  | if(bean != null){ | 
|---|
|  |  |  | bean.execute(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | @Component | 
|---|
|  |  |  | public class ModelListener extends OrgListenerSupport implements ApplicationListener<ApplicationReadyEvent> { | 
|---|
|  |  |  |  | 
|---|
|  |  |  | protected static final String orgKey = "tag" ; | 
|---|
|  |  |  | protected static final String orgListKey = "tagList" ; | 
|---|
|  |  |  | private static final String JobName = "modelCalculateJob" ; | 
|---|
|  |  |  | private static final String JobGroupName = "modelCalculateGroup" ; | 
|---|
|  |  |  | private static final Integer ThreadPoolMaxCount = 1 ;//线程池线程最大个数 | 
|---|
|  |  |  | 
|---|
|  |  |  | List<Org.OrgVo> orgList = Org.OrgList ; | 
|---|
|  |  |  | if(orgList != null && orgList.size() >0){ | 
|---|
|  |  |  | SchedulerTaskSupport.setThreadPoolPro(ThreadPoolMaxCount * orgList.size(), ThreadPoolPriority); | 
|---|
|  |  |  | for(Org.OrgVo vo : orgList){ | 
|---|
|  |  |  | HashMap<String , Object> jobDataMap    = new HashMap<String , Object>() ; | 
|---|
|  |  |  | jobDataMap.put(orgKey, vo.tag) ; | 
|---|
|  |  |  | SchedulerTaskSupport.addDailyJob(JobName + vo.tag, JobGroupName, CalculateJob.class, jobDataMap, startHour, startMinute ) ; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | HashMap<String , Object> jobDataMap    = new HashMap<String , Object>() ; | 
|---|
|  |  |  | jobDataMap.put(orgListKey,orgList) ; | 
|---|
|  |  |  | SchedulerTaskSupport.addDailyJob(JobName, JobGroupName, CalculateJob.class, jobDataMap, startHour, startMinute ) ; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|