您的位置:首页 > 其它

静态页生成

2016-01-25 16:07 351 查看
<task:scheduled-tasks>//applicationContext.xml文件里面配置定时的类和方法以及定时的时间
<task:scheduled ref="initializationJob" method="initStaticData"   cron="0 0/30 * * * ?"/>
<task:scheduled ref="cartJob"
method="cleanupExpired"   cron="0 0 0 * * ?"/>
<task:scheduled ref="orderJob"
method="cleanupExpired"   cron="0 0/9 * * * ?"/>
<task:scheduled ref="backupJob"
method="backupData"  cron="0 0 1 * * ?"/>
<task:scheduled ref="packageJob"
method="syncPackageData"  cron="0 0 2 * * ?"/>
<task:scheduled ref="hospitalJob"
method="syncHospitalData" cron="0 0 3 * * ?"/>
<task:scheduled ref="hospitalCenterJob"
method="hospitalCenterData"    cron="0 0 15 * * ?"/>
<task:scheduled ref="packagesCenterJob"
method="packagesCenterData"    cron="0 0 15 * * ?"/>
</task:scheduled-tasks>

package com.service.job;

import org.springframework.beans.factory.annotation.Autowired;

import org.springframework.stereotype.Service;

import com.service.freemarker.FreemarkerStaticService;

/**

 * 系统初始化 定时任务 主要用来初始化机构详情页

 * 

 * @author chenxi

 * @since 2015-1-18

 * @version 1.0

 */

@Service

public class HospitalCenterJob {
@Autowired
private FreemarkerStaticService freemarkerStaticService;

public void hospitalCenterData() {
this.freemarkerStaticService.buildStaticHospitalCenterPage();
}

}

public void buildStaticHospitalCenterPage() {
Map<String, Object> model = null;
List<City> cities=this.districtService.findCityList();
for(City city1 : cities){
List<Hospital> hospitals=this.hospitalService.findHospitalList(city1.getCode());
for(Hospital h:hospitals){
model=new HashMap<String, Object>();
City city = this.districtService.getCityByCityPyAbbr(city1.getPyAbbr());
if(city != null){
Hospital hospital = hospitalService.getHospitalByShortPyAbbr(h.getShortPyAbbr());
if(hospital != null){
model.put("cityName", city.getName());
model.put("PyAbbr", city.getPyAbbr());
model.put("cityPyAbbr",    city1.getPyAbbr());
model.put("package_list", packagesService.searchPackagesListByHospitalIdAndPackageType(hospital.getId(), null));
model.put("hospital", hospital);
model.put("hospital_list", hospitalService.searchHospitalListByCityCodeAndHospitalLevel(city.getCode(), null, 4));
model.put("friendlink_list", friendLinkService.searchFriendLinkListForHospital(hospital.getId()));
model.put("brand_list", brandService.searchBrandListForHospital(hospital.getId()));
Article article = new Article();
article.setHospitalId(hospital.getId());
article.setPublication(true);
model.put("notice_list", articleService.searchNewsListByCondition(article, 1, 12).getResults());
Page<Review> page = this.reviewService.searchReviewListByCondition(null, true, null, null, null, null, hospital.getId(), 0, 1, 30);
model.put("page", page);
model.put("package_review_list", page.getResults());
this.freemarkerCommonService.initSharedData1(model);
model.put("nav", 1);
if(model.get("ftcName") != null){

model.put("seo", this.baseService.getHospitalSEOTemplate2(hospital.getHospitalName() + "_" + model.get("ftcName"), city.getName()));
}else{
model.put("seo", this.baseService.getHospitalSEOTemplate(hospital.getHospitalName(), city.getName()));
}
}
}
indexStaticService.initCityCenterPage(model,city1.getPyAbbr(),h.getShortPyAbbr());
}
}
Date d=new Date();
String s=DateHelp.dateToString(d, "yyyy-MM-dd");
APPCacheHelp.put("hospitals", s);
}

public void initCityCenterPage(Map<String,Object> model,String cityPyAbbr,String hospitalPyAbbr) {

Template template
= templateService.get("hospital_center");

String   staticPath
= "/city/"+cityPyAbbr+"/"+hospitalPyAbbr+"/"+hospitalPyAbbr+".html";
staticService.buildHTML(template.getTemplatePath(), staticPath, model);
logger.info("完成"+model+"城市主页静态化工作!");
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: