`
收藏列表
标题 标签 来源
动态页面的生成 freemaker
package com.sgcc.evisp.consumer.info;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;

import com.sgcc.evisp.consumer.bizc.IProcedureWSBizc;
import com.sgcc.evisp.consumer.info.util.TemplateBuilder;
import com.sgcc.evisp.consumer.util.SystemConfig;
import com.sgcc.evoms.operation.evisp.vo.RmeasBasicInfoBo;
import com.sgcc.evoms.operation.evisp.vo.RmeasBasicInfos;
import com.sgcc.evoms.operation.evisp.vo.StatisticDealBo;
import com.sgcc.evoms.operation.evisp.vo.StatisticDealInfos;
import com.sgcc.evoms.operation.evisp.vo.StatisticNumBo;
import com.sgcc.evoms.operation.evisp.vo.StatisticStationDealInfos;

import freemarker.template.Template;
import freemarker.template.TemplateException;

public class CountConsumer {

	private Logger logger = LoggerFactory.getLogger(CountConsumer.class);

	@Autowired
	private IProcedureWSBizc procedureWSBizc;
	
	@SuppressWarnings({"rawtypes", "unchecked", "unused" })
	public void execute(Object message) {
		logger.info("开始刷新设施统计页面...");
		try {
//			IEvomsStatisticService webService = XFireServiceBuilder.buildService(PortConstant.EVOMSSTATISTICSERVICE,
//							IEvomsStatisticService.class);
//			StatisticNumBo bo = webService.statisticNumInfo();
			
			StatisticNumBo bo =  procedureWSBizc.callWebService("IEvomsStatisticService", "statisticNumInfoWs", new String[]{}, StatisticNumBo.class);
//			调式接口方法
//			List<String> l = new ArrayList<String>();
//			l.add(null);	
//			l.add("3140111111111104");
//			l.add(null);
//			l.add(null);
////			String[] params =(String[]) l.toArray();
//			int size = l.size();
//			String[] params = (String[])l.toArray(new String[size]);
//			RmeasBasicInfos dealbo = procedureWSBizc.callWebService("IEvomsStatisticService","statisticStakeDealWs",new String[]{"3140100000408029","2013-8-4","2013-8-6"},RmeasBasicInfos.class);
			logger.info("调用结果:" +bo.getIsSuc());
			if ("1".equals(bo.getIsSuc())) {
				logger.info("站点数:" + bo.getStationNum());
				logger.info("桩数:" + bo.getStakeNum());
				logger.info("车辆数:" + bo.getCarNum());
				logger.info("交易数:" + bo.getTradeNum());
				OutputStreamWriter out = null;
				try {
					Template template = TemplateBuilder.genTemplate("/ftl/index", "count.ftl");
					Map args = new HashMap();
					args.put("bo", bo);
					String topPath = SystemConfig.getConfig("html.index.path");
					File file = new File(topPath);
					if (!file.exists()) {
						file.mkdirs();
					}
					topPath = topPath + "/count.shtml";
					File f = new File(topPath);
					if (!f.exists()) {
						f.createNewFile();
					}
					out = new OutputStreamWriter(new FileOutputStream(topPath), "UTF-8");
					template.process(args, out);
					out.flush();
				} catch (IOException e) {
					e.printStackTrace();
				} catch (TemplateException e) {
					e.printStackTrace();
				} finally {
					try {
						out.close();
					} catch (IOException e) {
						e.printStackTrace();
					}
				}
			} else {
				logger.error("接口调用失败!失败原因:" + bo.getErrorMsg());
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
		logger.info("设施统计页面刷新完毕...");
	}

}
Global site tag (gtag.js) - Google Analytics