📄 taskeventmgrimpl.java
字号:
taskPojo.setAssignerId(id);
try {
taskDAO.addTask(taskPojo);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.ADDTASK_EXCEPTION);
}
html = "<html><body>" + user.getFamilyName() + "已经向您分配了一个新建任务:";
if (taskPojo.getCustomerContact() != null
&& "".equals(taskPojo.getCustomerContact())) {
html += " <br>" + "联系人:<b>"
+ taskPojo.getCustomerContact().getName() + "</b>";
}
html += "<br>到期日期:<b>" + taskPojo.getFinalTime()
+ "<br>有关这个任务的详细信息,请单击下面的链接<br>" + "</b><br>"
+ "<a href='http://" + UtilGetIp.getIp() + ":8082"
+ path + "/user.do?method=login&taskId="
+ taskPojo.getId() + "&name=" + assigner.getUserName()
+ "&pw="
+ new KeyBean().getkeyBeanofStr(assigner.getPassword())
+ "'>" + "http://" + UtilGetIp.getIp() + ":8082" + path
+ "/task.do?method=detailTask&id=" + taskPojo.getId()
+ "</a><br></body></html>";
sendMail(taskPojo, html, assigner);
}
flag = true;
} else {
try {
assigner = taskDAO.getUserById(taskPojo.getAssignerId());
taskDAO.addTask(taskPojo);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.ADDTASK_EXCEPTION);
}
html = "<html><body>" + user.getFamilyName() + "已经向您分配了一个新建任务:";
if (taskPojo.getCustomerContact() != null
&& "".equals(taskPojo.getCustomerContact())) {
html += " <br>" + "联系人:<b>"
+ taskPojo.getCustomerContact().getName() + "</b>";
}
html += "<br>到期日期:<b>" + taskPojo.getFinalTime()
+ "<br>有关这个任务的详细信息,请单击下面的链接<br>" + "</b><br>"
+ "<a href='http://" + UtilGetIp.getIp() + ":8082" + path
+ "/user.do?method=login&taskId=" + taskPojo.getId()
+ "&name=" + assigner.getUserName() + "&pw="
+ new KeyBean().getkeyBeanofStr(assigner.getPassword())
+ "'>" + "http://" + UtilGetIp.getIp() + ":8082" + path
+ "/task.do?method=detailTask&id=" + taskPojo.getId()
+ "</a><br></body></html>";
sendMail(taskPojo, html, assigner);
flag = true;
}
return flag;
}
/**
* @author LuWenBang
* @date 2009_02_18;
* @param taskPojo
* @param html
* @param assigner
*/
private void sendMail(ActivityTask taskPojo, String html, User assigner) {
if (assigner != null) {// 判断是否有被分配人;
// 如果被分配人邮箱不为空
if (assigner.getEmail() != null
|| !(assigner.getEmail().equals(""))) {
if (taskPojo.getSendMail() != null) {// 当字段为1的时候表示要发送邮件;
MailBox mailBox = new MailBox();
mailBox.setSmtpHost("smtp.163.com");
mailBox.setMailFrom(MailAuthenticator.LU_MAIL_USER);// 把公司邮箱作为发送油箱;
mailBox.setMailTo(assigner.getEmail());// 把联系人邮箱作为收件邮箱;
// 设置邮箱主题;
mailBox.setSubject(taskPojo.getSubject());
logger.debug("需要发送的邮箱:" + assigner.getEmail());
mailBox.setMsgContent(html);
try {
mailBox.sendMail();
} catch (IOException e) {
e.printStackTrace();
} catch (MessagingException e) {
e.printStackTrace();
}
}
}
}
}
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 添加日历事件;
* @param 保存eventPojo参数的实例
* @return 返回是否保存成功;
* @修改时间:
* @修改人:
*/
/*
* public boolean addEvent(Event event) throws ApplicationException { try {
* return eventDAO.addEvent(event); } catch (Exception e) {
* e.printStackTrace(); throw new
* ApplicationException(Constants.ADDEVENT_EXCEPTION); } }
*/
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 搜索具体某个用户;
* @param id
* 根据用户id的主键来搜索用户
* @return 返回该id号的用户;
* @修改时间:
* @修改人:
*/
public User getUserById(Integer id) throws ApplicationException {
try {
return taskDAO.getUserById(id);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.FINDUSEREXCEPTION);
}
}
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 搜索全部任务活动;
* @param flag
* 根据flag状态搜索记录;
* @param type
* 根据类型任务活动;
* @return 返回全部的任务活动;
* @修改时间:
* @修改人:
*/
public List<ActivityTaskVo> getAllTasks(Integer flag, User user,
Integer type) throws ApplicationException {
try {
List<ActivityTaskVo> result = new ArrayList<ActivityTaskVo>();
List taskPojoList = null;
if (user != null) {// 如果参数user不为空的话;
if (type == null || type.equals(8)) {
taskPojoList = taskDAO.getAllTasks(Constants.ACTIVEFLAG,
user);// 获取全部任务活动对象列表;
} else {
switch (type) {
case 1: {// 逾期;
String whereSql = " and at.finalTime <";// 逾期;
taskPojoList = taskDAO.getAllTasksByHql(
Constants.ACTIVEFLAG, user, whereSql);
}
break;
case 2: {// 今天;
String whereSql = " and at.finalTime = ";// 今天;
taskPojoList = taskDAO.getAllTasksByHql(
Constants.ACTIVEFLAG, user, whereSql);
}
break;
case 3: {// 今天+逾期;
String whereSql = " and at.finalTime <= ";// 今天+逾期;
taskPojoList = taskDAO.getAllTasksByHql(
Constants.ACTIVEFLAG, user, whereSql);
}
break;
case 4: {// 明天;
String toBeSql = " and at.finalTime =";
Integer to = 1;
taskPojoList = taskDAO.getAllTasksByFuture(
Constants.ACTIVEFLAG, user, toBeSql, to);
}
break;
case 5: {// 未来7天;
String toBeSql = " and at.finalTime>=" + "'"
+ DateTimeTool.getCurrentDate("yyyy-MM-dd")
+ "'" + " and at.finalTime<";
Integer to = 7;
taskPojoList = taskDAO.getAllTasksByFuture(
Constants.ACTIVEFLAG, user, toBeSql, to);
}
break;
case 6: {// 未来7天+逾期
String toBeSql = " and at.finalTime<";
Integer to = 7;
taskPojoList = taskDAO.getAllTasksByFuture(
Constants.ACTIVEFLAG, user, toBeSql, to);
}
break;
case 7: {// 本月
String toBeSql = " and at.finalTime>=" + "'"
+ DateTimeTool.getMonthFirstDay("yyyy-MM-dd")
+ "'" + " and at.finalTime<" + "'"
+ DateTimeTool.getMonthLastDay("yyyy-MM-dd")
+ "'";
// String ggg = null;
taskPojoList = taskDAO.getAllTasksByFuture(
Constants.ACTIVEFLAG, user, toBeSql, type);
}
break;
}
}
for (Object o : taskPojoList) {
ActivityTask a = (ActivityTask) o;// 把该object对象强转为任务pojo;
Integer rid = a.getRecordId();
String recordName = null;// 该记录的名称;
Object oo = null;// 定义一个对象接受;
if (rid != null) {
Integer functionId = Integer
.parseInt(a.getFunctionId());
switch (functionId) {
case 1: {
oo = taskDAO.getCustomerByRid(rid);// 根据相关项具体记录id搜索记录;
recordName = ((Customer) oo).getCustomerName();// 把该记录名称放进;
}
break;
case 2: {
oo = taskDAO.getOpportByRid(rid);// 根据相关项具体记录id搜索记录;
recordName = ((BusinessOpportunity) oo)
.getBusiOpportName();// 把该记录名称放进;
}
break;
}
}
// 组装任务Vo,把单个任务vo加到result列表中去;
result
.add(new ActivityTaskVo(a.getId(), recordName, a
.getRecordId(), a.getCustomerContact(), a
.getSubject(), a.getFinalTime(), a
.getFunctionId()));
}// 循环结束;
}
return result;// 返回封装好的结果集;
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.FINDTASK_EXCEPTION);
}
}
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 搜索id号的任务活动;
* @param id
* 根据该id参数来搜索;
* @return 返回该任务活动;
* @修改时间:
* @修改人:
*/
public ActivityTask getTsakById(Integer id) throws ApplicationException {
try {
return taskDAO.getTsakById(id);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.FINDTASK_EXCEPTION);
}
}
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 搜索id号的任务活动;
* @param id
* 根据该id参数来搜索;
* @return 返回该任务活动;
* @修改时间:
* @修改人:
*/
public CustomerContact getCustomerContactById(Integer id)
throws ApplicationException {
try {
return taskDAO.getgetCustomerContactById(id);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.FINDCONTACTEXCEPTION);
}
}
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 搜索该rid号的客户;
* @param id
* 根据该rid参数来搜索;
* @return 返回该具体客户;
* @修改时间:
* @修改人:
*/
public Customer getCustomerByRid(Integer rid) throws ApplicationException {
try {
return taskDAO.getCustomerByRid(rid);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.FINDCUSTOMEREXCEPTION);
}
}
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 搜索该rid号的业务机会;
* @param id
* 根据该rid参数来搜索;
* @return 返回该具体业务机会;
* @修改时间:
* @修改人:
*/
public BusinessOpportunity getOpportByRid(Integer rid)
throws ApplicationException {
try {
return taskDAO.getOpportByRid(rid);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.FINDBUSIOPPORTEXCEPTION);
}
}
/**
* @author 陆文邦;
* @date 2008-11-17;
* @function 修改该任务活动对象;
* @param id
* 修改taskPojo对象的参数;
* @return 返回是否修改成功;
* @修改时间:
* @修改人:
*/
public boolean modifyTask(ActivityTask task) throws ApplicationException {
try {
return taskDAO.modifyTask(task);
} catch (Exception e) {
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -