WarningSourceService.java 1.37 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
package com.hp.cmsz.service;

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.Provider;
import com.hp.cmsz.entity.WarningSource;
import com.hp.cmsz.repository.WarningSourceDao;
/**
 * 
 * @author Liu Ying
 *
 */
@Component
@Transactional(readOnly=true)
public class WarningSourceService {

	@Autowired
	private WarningSourceDao warningSourceDao;
	
	//得到所有告警来源
	public List<WarningSource> getAllWarningSource(){
		return (List<WarningSource>) warningSourceDao.findAllWarningSource();
	}
	
	/*//得到告警来源名称
	public String getWarningSourceNameByWarningSourceId(Long warningSourceId){
		return warningSourceDao.findByWarningSourceId(warningSourceId).get(0).getWarningSourceName();
	}*/
	
	public String getWarningSourceNameByWarningSourceId(List<Long> warningSourceId){
		List<WarningSource> warningSourceList = warningSourceDao.findByWarningSourceIdIn(warningSourceId);
		String warningSourceName="";
		for(int i=0;i<warningSourceList.size();i++){
			if(i==warningSourceList.size()-1){
				warningSourceName +=  warningSourceList.get(i).getWarningSourceName();
			}else{
				warningSourceName +=  warningSourceList.get(i).getWarningSourceName()+" ";
			}
		}
		return warningSourceName;
	}
}