📄 hetongservice.java
字号:
/* * Created on 2007-11-06 16:25:18 * * By Yehailong * Copyright juneng.com.cn, 2005-2006, All rights reserved. */package cn.com.juneng.hetong.service;import java.util.List;import java.io.Serializable;import cn.com.juneng.system.common.COMMON;import cn.com.juneng.system.common.SpringBeanFactory;import cn.com.juneng.baseinfo.service.BaseinfoService;import cn.com.juneng.baseinfo.vo.BaseinfoVOImpl;import cn.com.juneng.hetong.vo.HetongVOImpl;import cn.com.juneng.hetong.dao.HetongDAO;/** * service类,由Spring容器注入DAO实现,并管理事务性 * @author xiean */public class HetongService { private HetongDAO hetongDAO; /** * spring注入dao实现 * @param hetongDAO */ public void setHetongDAO(HetongDAO hetongDAO) { this.hetongDAO = hetongDAO; } public HetongDAO getHetongDAO() { return this.hetongDAO; } public void remove(Serializable[] key)throws Exception{ if(key!=null){ for (int i=0;i<key.length ;i++ ){ hetongDAO.remove(key[i]); } } } public HetongVOImpl findByPrimaryKey(String key)throws Exception{ return hetongDAO.findByPrimaryKey(key); } public void create(Object obj)throws Exception{ HetongVOImpl hetongvo=(HetongVOImpl)obj; if(COMMON.isEmpty(hetongvo.getUpdatedate())) hetongvo.setUpdatedate(COMMON.toTimestamp()); /**新增时,如果信息表示最新的,先更新原有已的标志,再插入记录*/ if(hetongvo.getFlag().equalsIgnoreCase(COMMON.NEWFLAG)){ String hql=" from HetongVOImpl where zgid=? and flag=?"; int rownum=hetongDAO.getRowCount(hql,new Object[]{hetongvo.getZgid(), COMMON.NEWFLAG}); if(rownum>=1){ hql="update HetongVOImpl set flag=? where zgid=?"; hetongDAO.update(hql,new Object[]{COMMON.OLDFLAG,hetongvo.getZgid()}); } BaseinfoService baseinfoService = (BaseinfoService)SpringBeanFactory.getBean("baseinfoService"); BaseinfoVOImpl baseinfovo=baseinfoService.findByPrimaryKey(hetongvo.getZgid()); baseinfovo.setPyjssj(hetongvo.getEnddate()); baseinfovo.setPysj(hetongvo.getStartdate()); baseinfoService.update(baseinfovo); } hetongDAO.create(obj); } public void update(Object obj)throws Exception{ HetongVOImpl hetongvo=(HetongVOImpl)obj; if(COMMON.isEmpty(hetongvo.getUpdatedate())) hetongvo.setUpdatedate(COMMON.toTimestamp()); /**新增时,如果信息表示最新的,先更新原有已的标志,再插入记录*/ if(hetongvo.getFlag().equalsIgnoreCase(COMMON.NEWFLAG)){ String hql=" from HetongVOImpl where zgid=? and flag=?"; int rownum=hetongDAO.getRowCount(hql,new Object[]{hetongvo.getZgid(), COMMON.NEWFLAG}); if(rownum>=1){ hql="update HetongVOImpl set flag=? where zgid=?"; hetongDAO.update(hql,new Object[]{COMMON.OLDFLAG,hetongvo.getZgid()}); } BaseinfoService baseinfoService = (BaseinfoService)SpringBeanFactory.getBean("baseinfoService"); BaseinfoVOImpl baseinfovo=baseinfoService.findByPrimaryKey(hetongvo.getZgid()); baseinfovo.setPyjssj(hetongvo.getEnddate()); baseinfovo.setPysj(hetongvo.getStartdate()); baseinfoService.update(baseinfovo); } hetongDAO.update(obj); } public List getList(String queryHql,String orderHql,int start, int maxResults) throws Exception { String hql = "from HetongVOImpl "; if(!COMMON.isEmpty(queryHql)){ hql += "where "+queryHql; } if(COMMON.isEmpty(orderHql)){ orderHql = " order by rid desc"; } hql += " "+orderHql; return hetongDAO.find(hql,start,maxResults); } public int getRowCount(String queryHql){ String hql = "from HetongVOImpl "; if(!COMMON.isEmpty(queryHql)){ hql += "where "+queryHql; } return hetongDAO.getRowCount(hql,null); }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -