📄 taskdaoimpl.java
字号:
package com.yuanchung.sales.dao.taskEvent.impl;
import java.sql.SQLException;
import java.util.List;
import org.hibernate.HibernateException;
import org.hibernate.Query;
import org.hibernate.Session;
import org.springframework.dao.DataAccessException;
import org.springframework.orm.hibernate3.HibernateCallback;
import org.springframework.orm.hibernate3.support.HibernateDaoSupport;
import com.yuanchung.sales.dao.taskEvent.TaskDAO;
import com.yuanchung.sales.exception.ApplicationException;
import com.yuanchung.sales.model.businessOpportunity.BusinessOpportunity;
import com.yuanchung.sales.model.customer.Customer;
import com.yuanchung.sales.model.customer.CustomerContact;
import com.yuanchung.sales.model.taskEvent.ActivityTask;
import com.yuanchung.sales.model.user.User;
import com.yuanchung.sales.model.userDefined.UserDefined;
import com.yuanchung.sales.model.userDefined.UserField;
import com.yuanchung.sales.model.userDefined.UserFilter;
import com.yuanchung.sales.util.Constants;
import com.yuanchung.sales.util.DateTimeTool;
@SuppressWarnings("unchecked")
/**
*
* @author 福建圆创软件;
* @function 实现任务DAO接口的实现类,具体处理任务活动的增删改查;
*
*/
public class TaskDAOImpl extends HibernateDaoSupport implements TaskDAO {
/**
* @author 陆文邦;
* @function 获取全部用户;
* @param flag根据任务活动状态来搜索;
* @return 返回全部用户的列表;
*/
public List<User> getAllUsers(String userIds) throws DataAccessException {
return this.getHibernateTemplate().find(
"from User u where u.id in(" + userIds + ")");
}
/**
* @author 陆文邦;
* @function 用于获取搜索符合条件的用户;
* @param 用userName参数模糊搜索;
* @param flag
* 根据状态来搜索记录;
* @return 返回搜索的用户列表;
*/
public List getUsersByNameLike(String familyName)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from User u where u.familyName like '%" + familyName + "%'");
}
/**
* @author 陆文邦;
* @function 用于获取搜索符合条件的客户;
* @param 用userName参数模糊搜索;
* @param flag
* 根据状态来搜索记录;
* @return 返回搜索的客户列表;
*/
public List getCustomerByNameLike(String name) throws DataAccessException {
return this.getHibernateTemplate().find(
"from Customer c where c.flag=" + Constants.ACTIVEFLAG
+ " and c.customerName like '%" + name + "%'");
}
/**
* @author 陆文邦;
* @function 用于获取搜索符合条件的业务机会;
* @param 用userName参数模糊搜索;
* @param flag
* 根据状态来搜索记录;
* @return 返回搜索的业务机会列表;
*/
public List getOpportByNameLike(String name) throws DataAccessException {
return this.getHibernateTemplate().find(
"from BusinessOpportunity bo where bo.flag="
+ Constants.ACTIVEFLAG
+ " and bo.busiOpportName like '%" + name + "%'");
}
/**
* @author 陆文邦;
* @function 用于获取搜索符合条件的联系人;
* @param name
* @return
* @throws ApplicationException
*/
public List getCustomerContactByNameLike(String name)
throws ApplicationException {
return this.getHibernateTemplate().find(
"from CustomerContact cc where cc.flag=" + Constants.ACTIVEFLAG
+ " and cc.name like '%" + name + "%'");
}
/**
* @author 陆文邦;
* @function 搜索全部的联系人;
* @param flag;根据记录状态来搜索;
* @return 返回搜索的联系人;
*/
public List<CustomerContact> getAllCustomerContacts(Integer flag)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from CustomerContact cc where cc.flag=?", flag);
}
/**
* @author 陆文邦;
* @function 获取全部的客户;
* @param flag;根据flag搜索是否被删除的记录
* @return 返回全部客户的列表;
*/
public List<Customer> getAllCustomers(Integer flag)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from Customer c where c.flag=?", flag);
}
/**
* @author 陆文邦;
* @function 获取全部的业务机会;
* @param flag
* 根据任务记录状态来搜索;
* @return 返回全部业务机会的列表
*/
public List<BusinessOpportunity> getAllOpports(Integer flag)
throws DataAccessException {
return this.getHibernateTemplate().find(
"from BusinessOpportunity bo where bo.flag=?", flag);
}
/**
* @author 陆文邦;
* @function 添加任务活动;
* @param 保存raskPojo参数的实例
* @return 返回是否保存成功;
*/
public boolean addTask(ActivityTask taskPojo) throws DataAccessException {
this.getHibernateTemplate().save(taskPojo);
return true;
}
/**
* @author 陆文邦;
* @function 搜索具体某个用户;
* @param id
* 根据用户id的主键来搜索用户
* @return 返回该id号的用户;
*/
public User getUserById(Integer id) throws DataAccessException {
return (User) this.getHibernateTemplate().get(User.class, id);
}
/**
* @author 陆文邦;
* @function 搜索全部任务活动;
* @param user
* 根据用户user搜索任务活动;
* @param flag
* 根据任务活动记录状态搜索;--是否已经被删除;
* @return 返回全部的任务活动;
*/
public List getAllTasks(Integer flag, User user) throws DataAccessException {
return this
.getHibernateTemplate()
.find(
"from ActivityTask at where at.executeState<>3 and at.flag=? and at.assignerId=? order by at.finalTime",
new Object[] { flag, user.getId() });
}
/**
* @author 陆文邦;
* @function 搜索id号的任务活动;
* @param id
* 根据该id参数来搜索;
* @return 返回该任务活动;
*/
public ActivityTask getTsakById(Integer id) throws DataAccessException {
return (ActivityTask) this.getHibernateTemplate().get(
ActivityTask.class, id);
}
/**
* @author 陆文邦;
* @function 搜索id号的联系人;
* @param id
* 根据该id参数来搜索;
* @return 返回该联系人;
*/
public CustomerContact getgetCustomerContactById(Integer id)
throws DataAccessException {
return (CustomerContact) this.getHibernateTemplate().get(
CustomerContact.class, id);
}
/**
* @author 陆文邦;
* @function 搜索该rid号的客户;
* @param id
* 根据该rid参数来搜索;
* @return 返回该具体客户;
*/
public Customer getCustomerByRid(Integer rid) throws DataAccessException {
return (Customer) this.getHibernateTemplate().get(Customer.class, rid);
}
/**
* @author 陆文邦;
* @function 搜索该rid号的业务机会;
* @param id
* 根据该rid参数来搜索;
* @return 返回该具体业务机会;
*/
public BusinessOpportunity getOpportByRid(Integer rid)
throws DataAccessException {
return (BusinessOpportunity) this.getHibernateTemplate().get(
BusinessOpportunity.class, rid);
}
/**
* @author 陆文邦;
* @function 修改该任务活动对象;
* @param id
* 修改taskPojo对象的参数;
* @return 返回是否修改成功;
*/
public boolean modifyTask(ActivityTask task) throws DataAccessException {
this.getHibernateTemplate().update(task);
return true;
}
/**
* @author 陆文邦;
* @function 批量修改任务活动;
* @return 返回是否修改成功;
*/
public void updateTasks(int modifyManId, String modifyTime,
String classCode, int recordId, int flag)
throws DataAccessException {
this
.getHibernateTemplate()
.bulkUpdate(
"update ActivityTask as at set at.flag=?, at.modifyManId=?, at.lastModifyTime=? where at.functionId=? and at.recordId=?",
new Object[] { flag, modifyManId, modifyTime,
classCode, recordId });
}
/**
* @author 陆文邦;
* @function 搜索全部任务活动;
* @param whereSql
* 根据whereSql搜索记录;
* @param type
* 根据类型任务活动;
* @return 返回全部的任务活动;
*/
public List getAllTasksByHql(Integer flag, User user, String whereSql)
throws DataAccessException {
return this
.getHibernateTemplate()
.find(
"from ActivityTask at where at.executeState<>3 and at.flag=? and at.assignerId=?"
+ whereSql
+ "'"
+ DateTimeTool.getCurrentDate("yyyy-MM-dd")
+ "'" + " order by at.finalTime",
new Object[] { flag, user.getId() });
}
/**
* @author 陆文邦;
* @function 搜索全部任务活动;
* @param whereSql
* 根据whereSql搜索记录;
* @param type
* 根据类型任务活动;
* @param to区分重写方法;
* @return 返回全部的任务活动;
*/
public List getAllTasksByFuture(Integer flag, User user, String toBeSql,
Integer to) throws DataAccessException {
return this
.getHibernateTemplate()
.find(
"from ActivityTask at where at.executeState<>3 and at.flag=? and at.assignerId=?"
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -