MonthService.java 3.59 KB
Newer Older
afe's avatar
afe committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133
package com.hp.cmsz.service;

import java.util.Calendar;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import com.hp.cmsz.entity.AnalysisType;
import com.hp.cmsz.entity.Granularity;
import com.hp.cmsz.entity.Month;
import com.hp.cmsz.entity.WarningSource;
import com.hp.cmsz.repository.AnalysisTypeDao;
import com.hp.cmsz.repository.GranularityDao;
import com.hp.cmsz.repository.MonthDao;
import com.hp.cmsz.repository.WarningSourceDao;
/**
 * 
 * @author sophia
 *
 */
@Component
@Transactional(readOnly=true)
public class MonthService {

	@Autowired
	private MonthDao monthDao;
	
	/*//得到所有
	public List<Month> getAllMonth(){
		return (List<Month>) monthDao.findAll();
	}
	
	
	
	//得到月份
	public List<Month> getMonth2003() {
			return (List<Month>) monthDao.findByYearName("2003年");
		}
	
	public List<Month> getMonth2004() {
		return (List<Month>) monthDao.findByYearName("2004年");
	}
	public List<Month> getMonth2005() {
		return (List<Month>) monthDao.findByYearName("2005年");
	}
	public List<Month> getMonth2006() {
		return (List<Month>) monthDao.findByYearName("2006年");
	}
	public List<Month> getMonth2007() {
		return (List<Month>) monthDao.findByYearName("2007年");
	}
	public List<Month> getMonth2008() {
		return (List<Month>) monthDao.findByYearName("2008年");
	}
	public List<Month> getMonth2009() {
		return (List<Month>) monthDao.findByYearName("2009年");
	}
	public List<Month> getMonth2010() {
		return (List<Month>) monthDao.findByYearName("2010年");
	}
	public List<Month> getMonth2011() {
		return (List<Month>) monthDao.findByYearName("2011年");
	}
	public List<Month> getMonth2012() {
		return (List<Month>) monthDao.findByYearName("2012年");
	}
	public List<Month> getMonth2013() {
		return (List<Month>) monthDao.findByYearName("2013年");
	}
	public List<Month> getMonth2014() {
		return (List<Month>) monthDao.findByYearName("2014年");
	}
	public List<Month> getMonth2015() {
		return (List<Month>) monthDao.findByYearName("2015年");
	}
	public List<Month> getMonth2016() {
		return (List<Month>) monthDao.findByYearName("2016年");
	}
	public List<Month> getMonth2017() {
		return (List<Month>) monthDao.findByYearName("2017年");
	}
	public List<Month> getMonth2018() {
		return (List<Month>) monthDao.findByYearName("2018年");
	}
	public List<Month> getMonth2019() {
		return (List<Month>) monthDao.findByYearName("2019年");
	}
	public List<Month> getMonth2020() {
		return (List<Month>) monthDao.findByYearName("2020年");
	}
	public List<Month> getMonth2021() {
		return (List<Month>) monthDao.findByYearName("2021年");
	}
	public List<Month> getMonth2022() {
		return (List<Month>) monthDao.findByYearName("2022年");
	}*/
	
	//得到年份
	public List<String> getYearList(){
		return monthDao.getYearList(getThisYear());
	}
	
	//得到最新的月份
	public List<Month> getLatestMonthList(){
		String yearJanMonth = getThisYear()+"1月";
		String yearThisMonth = getThisYear()+getThisMonth();
		return monthDao.getMonthList(yearJanMonth, yearThisMonth);
	}
	
	/**
	 * 得到今年的年份
	 * @return
	 */
	public String getThisYear(){
		  Calendar cal = Calendar.getInstance();
	      int year = cal.get(Calendar.YEAR);
	      String yearStr = String.valueOf(year);
	      return yearStr+"年";
	}
	
	/**
	 * 得到最新的月份
	 * @return
	 */
	private String getThisMonth(){
		  Calendar cal = Calendar.getInstance();
	      int month = cal.get(Calendar.MONTH)+1;
	      String monthStr = String.valueOf(month);
	      return monthStr+"月";
	}
}