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+"月"; } }