📄 taskaction.java
字号:
} else {// 其余为数值或字符
value = StringTool.transformString(fieldId, value);
}
uf.setFilterName(field);
uf.setOperator(operator);
uf.setFilterValue(value);
uf.setUserDefined(ud);
if (StringTool.isNotBlank(filterId)) {// 若过滤条件不为空,则修改该过滤条件
taskEventMgr.updateUserFilter(uf);// 修改过滤条件
} else {
taskEventMgr.addUserFilter(uf);// 保存过滤条件
}
}
}
// **删除过滤字段;
String delIdStr = request.getParameter("delId");
StringBuffer sb = null;
if (delIdStr.length() > 0) {
sb = new StringBuffer(delIdStr);
String sid = sb.substring(0, delIdStr.length());
String[] did = sid.split(",");
for (int i = 0; i < did.length; i++) {
String strId = did[i];
if (strId != null && !strId.equals("")) {
UserFilter uff = taskEventMgr.getUserFilterById(strId);
if (uff != null) {
taskEventMgr.deleteFilter(uff);
}
}
}
}
// **删除过滤字段;
String optionFields = request.getParameter("preOptions"); // 分离预选项
UserField userField = taskEventMgr.getUserFieldByOption(ud);
userField.setFieldName(optionFields);
userField.setUserDefined(ud);
taskEventMgr.updateUserField(userField);// 修改显示字段
request.setAttribute("isSuccess", Constants.SAVESUCCESS);
return getAllTaskEvents(mapping, form, request, response);
}
/**
* @author LuWenBang
* @date 2009-03-03
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws Exception
*/
public ActionForward getTaskEventsByOption(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws Exception {
User user = SessionMgr.getCustSession(request);// 获取当前正在操作的用户;
if (user == null) {
return mapping.findForward("login");// 如果session不存在用户,重新登陆;
}
String forward = "activityList";
String optionId = request.getParameter("optionId");
logger.debug("选择项的id:" + optionId);
// 2009-02-05 add 数据范围
Rights rights = SessionMgr.getJspRightsControl(request).get("1")
.getRightsMap().get("104");
String style = rights.getStyle();
String userIds = authorizationMgr.findUserDataRange(rights.getId(),
user);
List<UserDefined> options = new ArrayList<UserDefined>();
if (Constants.STYLE_BLOCK.equals(style)) {// 2009-02-05 add 数据范围
options = taskEventMgr.getOptionsByUserAndType(user,
Constants.ALLACTIVITY_INT);// 根据用户获取所有用户自定义选项
}
request.setAttribute("options", options);
List<String> definedField = taskEventMgr.getDefinedField(optionId, request);//获取显示字段列表;
List<Activity> activityList = taskEventMgr.getActivityByOption(optionId, 1, request.getSession());//获取列表;
PageController pageController = taskEventMgr.getPageController(1, request.getSession());//页面控制;
String currentPage = request.getParameter("currentPage");
XPage xpage = new XPage(request.getContextPath()
+ "/task.do?method=getTaskEventsByOption", activityList.size(), 1,
15, activityList);
if (currentPage != null && !currentPage.equals("")) {
xpage.setCurrentItems(Integer.parseInt(currentPage));
} else {
xpage.setCurrentItems(1);
}
xpage.setPageBar();
request.setAttribute("xpage", xpage);
request.setAttribute("definedField", definedField);
request.setAttribute("activityList", activityList);
request.setAttribute("pageController", pageController);
return mapping.findForward(forward);
}
/** ***********************************以下为封装抽取出来的方法****************************************** */
/**
* @author 福建圆创软件;
* @function 把参数list列表封装成页面对象;
* @param request
* 从action中方法获取rquest对象做参数;
* @param path
* path为action方法执行路径;
* @param collections
* 为该列表对象,底下可以多种集合对象实现;
* @return void;
*/
private void encasePage(HttpServletRequest request, String path,
Collection collections) throws ApplicationException {
/** 把用户list封装成分页* */
if (collections != null && collections.size() > 0) {// 判断集合如果不为空;
String currentPage = request.getParameter("currentPage");
XPage xpage = new XPage(request.getContextPath() + path,
collections.size(), 1, 12, collections);// 实例化一个页面对象;
if (currentPage != null && !currentPage.equals("")) {
xpage.setCurrentItems(Integer.parseInt(currentPage));
} else {
xpage.setCurrentItems(1);
}
xpage.setPageBar();
request.setAttribute("xpage", xpage);
} else {
logger.error("集合为空,不能组装成分页!");
}
}
/**
* @author 福建圆创软件;
* @function 处理页面上的任务活动bean,封装成持久类pojo来操作;
* @param mapping
* @param form
* @param request
* @param response
* @return 返回一个任务活动的持久类对象;
* @throws ApplicationException
*/
private ActivityTask handleTask(ActionForm form, HttpServletRequest request)
throws ApplicationException {
User currentUser = SessionMgr.getCustSession(request);// 当前正在操作的用户;
TaskForm taskForm = (TaskForm) form;// 获取页面封装的form
ActivityTask task = new ActivityTask();// 实例化一个任务活动的持久对象;
try {
BeanUtils.copyProperties(task, taskForm);// 把form的属性复制到持久类pojo的属性;
task.setCreateDate(DateTimeTool
.getCurrentDate("yyyy-MM-dd HH:mm:ss"));// 设置制定时间;
task.setFlag(Constants.ACTIVEFLAG);// flag可编辑;
/** 获取被分配人,把被分配人存储到持久类中* */
Integer assignerId = taskForm.getAssignerId();// 获取页面传过来的用户id;
// dwr根据该id搜索相关用户
logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
+ "搜索id为" + assignerId + "的用户!");
task.setAssignerId(assignerId);// 被分配人
/** 设置修改人的对象和修改时间* */
task.setLastModifyTime(DateTimeTool
.getCurrentDate("yyyy-MM-dd HH:mm:ss"));// 修改时间;
task.setModifyManId(currentUser.getId());// 修改人;
task.setUser(currentUser);// 设置创建人;
/** 判断页面上的具体记录是否为空,如果为空则相关类也为空* */
String recordName = taskForm.getRecordName();// 页面输入相关项具体记录的名称;
if (recordName == null || recordName.equals("")) {// 如果相关项的具体记录名称为空
task.setFunctionId(null);// 相关项也设置为空;
task.setRecordId(null);// 相关项具体记录也为空;
}
/** 判断是否有提醒日期,如果没有提醒时间也为空* */
String wakeUpDate = taskForm.getWakeUpDate();// 页面输入的提醒时间
if (wakeUpDate == null || wakeUpDate.equals("")) {// 判断是否有提醒日期,如果没有的话提醒时间也为空;
task.setWakeUpDate(null);// 把提醒日期设置为空;
task.setWakeUpTime(null);// 把提醒时间设置为空;
}
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
/** 判断添加任务活动时是否要给联系人发送邮件* */
Integer cid = taskForm.getContactId();
CustomerContact customerContact = null;
if (cid != null) {
customerContact = taskEventMgr.getCustomerContactById(cid);
task.setCustomerContact(customerContact);// 把联系人设置到任务对象;
}
return task;
}
/**
* @author 福建圆创软件;
* @function 搜索相关项具体记录的通用方法;
* @param request
* @param functionId
* @param id
*/
private void findRecord(HttpServletRequest request, String functionId,
Integer id) throws ApplicationException {
/** 根据页面选择的相关项类型来具体查找记录类型列表* */
List functionRecordCollections = taskEventMgr
.getAllfunctionRecordCollection(id);
String path = "/task.do?method=allSelectFunctionRecord&functionId="
+ functionId;// 要搜索列表的执行路径;
encasePage(request, path, functionRecordCollections);// 把联系人列表装载成分页,传入到page里面;
}
/**
* @author 福建圆创软件;
* @function 搜索某个任务活动以及相关信息的通用方法;
* @param request
* @throws ApplicationException
*/
private void showDetailTask(ActionForm form, HttpServletRequest request)
throws ApplicationException {
/** 获取任务活动,转存到视图层的bean中后存储到request范围; * */
User currentUser = SessionMgr.getCustSession(request);// 获取当前正在操作的用户;
Integer id = Integer.parseInt(request.getParameter("id"));// 该id为任务活动的内码id主键;
ActivityTask task = taskEventMgr.getTsakById(id);// 搜索这个id的任务活动;
logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
+ "搜索id为" + id + "的任务活动!");
TaskForm taskForm = (TaskForm) form;// 实例化一个页面上的任务活动对象;
logger.debug("能取到bean的值吗????????????????????????"
+ taskForm.getSubject());
try {
BeanUtils.copyProperties(taskForm, task);// 把持久类的任务活动对象属性复制到视图层的任务活动bean当中;
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
/** 获取被分配人,存储到request范围;* */
Integer assignerId = task.getAssignerId();// 被分配人id
User user = taskEventMgr.getUserById(assignerId);// 获取被分配人对象;
logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
+ "搜索id为" + assignerId + "的用户!");
request.setAttribute("user", user);// 把被分配人传到request范围;
/** 获取上次修改人,存储到request范围;* */
Integer modifyUid = task.getModifyManId();// 获取上次修改人的id;
User modifyUser = taskEventMgr.getUserById(modifyUid);// 获取该修改人的对象;
logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
+ "搜索id为" + modifyUid + "的用户!");
request.setAttribute("modifyUser", modifyUser);// 把上次修改人传到request范围;
User creator = task.getUser();
request.setAttribute("creator", creator);
/** 获取任务活动的相关联系人,存储到request范围;* */
CustomerContact contact = task.getCustomerContact();// 获取联系人id
Integer contactId = null;
if (contact != null) {
contactId = contact.getId();
}
if (contactId != null) {// 判断任务活动的联系人是否为空;
CustomerContact customerContact = taskEventMgr
.getCustomerContactById(contactId);// 获取任务活动的相关联系人;
logger.debug("用户:" + currentUser.getUserName() + " 在 " + new Date()
+ "搜索id为" + contactId + "的联系人!");
taskForm.setContactName(customerContact.getName());// 把联系人名称储存到任务活动对象的联系人名称上面;
taskForm.setContactId(contactId);
request.setAttribute("customerContact", customerContact);// 需要把联系人对象存放到request范围里,因为联系人电话和邮箱需要用到;
}
/** 通过获取相关项id,判断该相关类型后传回具体的记录对象* */
String functionId = task.getFunctionId();// 获取相关项;
Integer rid = task.getRecordId();// 获取具体记录的id;
if (functionId != null && !functionId.equals("")) {// 如果相关项不为空;
Integer fid = Integer.parseInt(functionId);
switch (fid) {
case 1: {
Customer customer = taskEventMgr.getCustomerByRid(rid);// 根据相关项具体记录id搜索记录;
logger.debug("用户:" + currentUser.getUserName() + " 在 "
+ new Date() + "搜索id为" + rid + "的客户!");
taskForm.setRecordName(customer.getCustomerName());// 把客户名称设置到任务活动中的具体实体名;
taskForm.setRecordId(customer.getId());// 把客户id设置到任务活动中的具体实体id;
}
break;
case 2: {
BusinessOpportunity opport = taskEventMgr.getOpportByRid(rid);// 根据相关项具体记录id搜索记录;
logger.debug("用户:" + currentUser.getUserName() + " 在 "
+ new Date() + "搜索id为" + rid + "的业务机会!");
taskForm.setRecordName(opport.getBusiOpportName());// 把业务机会名称设置到任务活动中的具体实体名;
taskForm.setRecordId(opport.getId());// 把业务机会id设置到任务活动中的具体实体id;
}
break;
}
}
request.setAttribute("task", taskForm);// 把该任务活动传到request范围;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -