⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pubperiodconfig.java

📁 博克后台的开发,有很多使用的方法和例子可以提供给大家学习
💻 JAVA
字号:
package com.webpublish.config;

import com.webpublish.config.ComStatic;
import com.webpublish.util.DateUtil;

import java.util.Iterator;
import java.util.List;

import org.apache.commons.lang.math.NumberUtils;
import org.dom4j.Attribute;
import org.dom4j.Document;
import org.dom4j.Element;

public class PubPeriodConfig {

	/**
	 * @param 获得Period节点的XPath
	 */
	public static final String pubPeriodPath = ComStatic.getSysConfig
			.getProperty("pubPeriodPath");

	/**
	 * @param 获得power属性的XPath
	 */
	public static final String pubSequencePath = ComStatic.getSysConfig
			.getProperty("pubSequencePath");

	/**
	 * @param 获得Period节点的XPath
	 */
	public static final String xmlPathPeriod = ComStatic.getSysConfig
			.getProperty("XPathPeriod");

	/**
	 * @param 获得power属性的XPath
	 */
	public static final String xmlPathPower = ComStatic.getSysConfig
			.getProperty("XPathPower");

	/**
	 * @param 获得Timelist属性的XPath
	 */
	public static final String xmlPathTimelist = ComStatic.getSysConfig
			.getProperty("XPathTimelist");

	private static Document pubPeriodDoc = ComStatic.xmlUtil
			.openXml(pubPeriodPath);

	private static Document pubSequenceDoc = ComStatic.xmlUtil
			.openXml(pubSequencePath);

	private static Element pubSequenceRoot = pubSequenceDoc.getRootElement();

	private static String pubStartTime = pubSequenceRoot
			.element("pubstarttime").getStringValue();

	/**
	 * 得到power元素的集合
	 */
	private static List powerAttributeList = pubPeriodDoc
			.selectNodes(xmlPathPower);

	/**
	 * 得到Period值的集合
	 */
	private static List powerValueslist = pubPeriodDoc
			.selectNodes(xmlPathPeriod);

	/**
	 * 得到Timelist值的集合
	 */
	public static List timelistValues = pubSequenceDoc
			.selectNodes(xmlPathTimelist);

	public static Iterator timeIter = PubPeriodConfig.timelistValues.iterator();

	/**
	 * @return 返回所有符合发布条件的时段的和,类型为long
	 */
	public static final long getPubPeriodNumber(String pubNowDate) {

		long PeriodNumber = 0;
		long powerValue = 0;
		long betweenMinute = DateUtil.getBetweenMinutes(pubStartTime,
				pubNowDate);

		Iterator attributeIter = powerAttributeList.iterator();

		Iterator valuesIter = powerValueslist.iterator();

		while (attributeIter.hasNext() && valuesIter.hasNext()) {
			Attribute powerAttribute = (Attribute) attributeIter.next();
			Element periodElement = (Element) valuesIter.next();
			powerValue = NumberUtils.toLong(periodElement.getText());

			if ((betweenMinute % powerValue) < 15) {
				PeriodNumber += NumberUtils.toLong(powerAttribute.getText());
			}
		}
		return PeriodNumber;
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		while (timeIter.hasNext()) {
			Element timeElement = (Element) timeIter.next();
			String pubTimer = timeElement.getText();
			System.out.println(pubTimer);

			// alarmClock.start(pubTimer);
		}

	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -