ssh 模板

2 篇文章 0 订阅

pojo

<span style="font-size:14px;">import com.njbh.core.pojo.GenericModel;

public class FanInfo implements java.io.Serializable,GenericModel{
	private String id;
	private String fanDesc;
	private String fanState;
	private String catchTime;
	private Long period;
	private String moduleId;
	
	public String getId() {
		return id;
	}
	public void setId(String id) {
		this.id = id;
	}
	public String getFanDesc() {
		return fanDesc;
	}
	public void setFanDesc(String fanDesc) {
		this.fanDesc = fanDesc;
	}
	public String getFanState() {
		return fanState;
	}
	public void setFanState(String fanState) {
		this.fanState = fanState;
	}
	public String getCatchTime() {
		return catchTime;
	}
	public void setCatchTime(String catchTime) {
		this.catchTime = catchTime;
	}
	public Long getPeriod() {
		return period;
	}
	public void setPeriod(Long period) {
		this.period = period;
	}
	public String getModuleId() {
		return moduleId;
	}
	public void setModuleId(String moduleId) {
		this.moduleId = moduleId;
	}
}</span>

service

<span style="font-size:14px;"><strong>import java.util.List;</span><span style="font-size:14px;">
import com.njbh.core.service.Service;
import com.njbh.fault.inspection.pojo.cisco.FanInfo;

public interface FanInfoService  extends Service<FanInfo, String>{
	/**
	 * @author XJ
	 * 根据设备id查找电源状态
	 * @param mouldeId
	 * @return
	 */
	public List<FanInfo> queryFanInfoState(String mouldeId);
}</strong></span>

serviceImpl

<span style="font-size:14px;"><strong>import java.util.List;

import com.njbh.core.service.impl.GenericService;
import com.njbh.fault.inspection.dao.ciso.FanInfoHome;
import com.njbh.fault.inspection.pojo.cisco.FanInfo;
import com.njbh.fault.inspection.service.ciso.FanInfoService;

public class FanInfoServiceImpl extends GenericService<FanInfo, String> implements FanInfoService{

	@Override
	public List<FanInfo> queryFanInfoState(String mouldeId) {
		FanInfoHome faninfohome = (FanInfoHome) home;
		return faninfohome.queryFanInfoState(mouldeId);
	}

}</strong></span>

dao

<strong><span style="font-size:14px;">import java.util.List;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.transform.Transformers;

import com.njbh.core.home.GenericHome;
import com.njbh.fault.inspection.pojo.cisco.FanInfo;

public class FanInfoHome extends GenericHome<FanInfo, String>{
	private static final Log log = LogFactory.getLog(FanInfoHome.class);
	
	public FanInfoHome(Class<FanInfo> c) {
		super(c);
		// TODO Auto-generated constructor stub
	}
	public FanInfoHome(){
		this(FanInfo.class);
	}
	
	public List<FanInfo> queryFanInfoState(String mouldeId){
		log.debug("attaching FanInfoHome queryFanInfoState");
		try {
			StringBuffer sql = new StringBuffer();
			sql.append(" select FAN_STATE \"fanState\" from FANINFO ");
			sql.append(" where MODULEID=?");
			sql.append(" and PERIOD=(select max(PERIOD) from FANINFO where MODULEID=?)");
			Query query = sessionFactory.getCurrentSession().createSQLQuery(sql.toString());
			query.setString(0, mouldeId);
			query.setString(1, mouldeId);
			Query transQuery = query.setResultTransformer(Transformers.aliasToBean(FanInfo.class));
			log.debug("attaching queryFanInfoState successful");
			return transQuery.list();
		} catch (HibernateException e) {
			log.error("attaching queryFanInfoState failed", e);
			return null;
		}
	}
} </span></strong>  


action

<strong><span style="font-size:14px;">import java.util.List;

import com.njbh.core.action.GenericAction;
import com.njbh.fault.inspection.pojo.cisco.FanInfo;
import com.njbh.fault.inspection.service.ciso.FanInfoService;

public class FanInfoAction extends GenericAction<FanInfoService>{
	private String mouldeId;

	public String getMouldeId() {
		return mouldeId;
	}

	public void setMouldeId(String mouldeId) {
		this.mouldeId = mouldeId;
	}
	
	public String queryFanInfoState(){
		FanInfoService fanInfoService =(FanInfoService)service;
		List<FanInfo> list= fanInfoService.queryFanInfoState(mouldeId);
		
		this.setJsonStr(listToJoson(list));
		return SUCCESS;
	}
}</span></strong>

struts.xml

<strong><span style="font-size:14px;">      <action name="queryFanInfoState" class="FanInfoAction" method="queryFanInfoState">
	        <result name="SUCCESS">jsondata.jsp</result>
      </action></span></strong>

application.xml

	<bean id="FanInfoAction" class="com.njbh.fault.inspection.action.cisco.FanInfoAction" scope="request">
		<property name="service" ref="fanInfoService" />
	</bean>
<pre name="code" class="html">	    <strong><span style="font-size:14px;"><bean id="fanInfoService" class="com.njbh.fault.inspection.service.ciso.impl.FanInfoServiceImpl">
 		<property name="home" ref="fanInfoHome" />
	</bean></span></strong>

 
        <strong><span style="font-size:14px;">   <bean id="fanInfoHome" class="com.njbh.fault.inspection.dao.ciso.FanInfoHome">
		<property name="sessionFactory" ref="sessionFactory" />
	</bean></span></strong>


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值