静态页生成

该博客介绍了一个Spring服务,用于通过定时任务生成医院中心的静态页面。服务中利用FreemarkerStaticService来构建静态页面,遍历城市和医院数据,填充模板并保存为HTML。内容涉及城市、医院信息、套餐、友链、品牌新闻等,并实现了SEO优化和缓存更新。
摘要由CSDN通过智能技术生成
<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+"城市主页静态化工作!");
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值