📄 contactaction.java
字号:
HttpServletResponse response) throws ApplicationException {
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
String id = request.getParameter("id");
CustomerContact contact = contactMgr.getContactById(id);
contact.setFlag(2);
if (contactMgr.updateContact(contact)) {
out
.print("<script>alert('删除成功!');if(confirm('是否继续删除?')){location='"
+ request.getContextPath()
+ "/contact.do?method=contactAll'}else{location='"
+ request.getContextPath()
+ "/contact.do?method=listDeteleContact'}</script>");
} else {
out
.print("<script>alert('删除失败!');location='history.back(-1)'</script>");
}
return null;
}
/**
* 显示被冻结的用户列表;
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws ApplicationException
*/
public ActionForward listDeteleContact(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ApplicationException {
User user = SessionMgr.getCustSession(request);
String forward = "listDeleteData";
List<ContactVo> contacts = contactMgr.getContactByDelete(user,
Constants.PASSIVITY);
String currentPage = request.getParameter("currentPage");
XPage xpage = new XPage(request.getContextPath()
+ "/contact.do?method=listDeteleContact", contacts.size(), 1,
8, contacts);
if (currentPage != null && !currentPage.equals("")) {
xpage.setCurrentItems(Integer.parseInt(currentPage));
} else {
xpage.setCurrentItems(1);
}
xpage.setPageBar();
request.setAttribute("xpage", xpage);
return mapping.findForward(forward);
}
/**
* 解冻某个联系人;
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws ApplicationException
*/
public ActionForward signContact(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
e.printStackTrace();
}
String id = request.getParameter("id");
Integer flag = new Integer(1);// 解冻代码;
CustomerContact contact = contactMgr.getContactById(id);
Integer cid = contact.getCustomer().getId();
Customer customer = contactMgr.getCustomerById(cid);
if (customer.getFlag().equals(1)) {// 判断该联系人的客户是否已经删除;
if (contactMgr.updateContactByFlag(Integer.parseInt(id), flag)) {
out
.print("<script>alert('还原成功!');if(confirm('是否继续还原')){location='"
+ request.getContextPath()
+ "/contact.do?method=listDeteleContact'}else{location='"
+ request.getContextPath()
+ "/contact.do?method=contactAll'}</script>");
} else {
out
.print("<script>alert('还原失败!');location='history.back(-1)'</script>");
}
} else {
out.print("<script>alert('该联系人的客户为删除状态,请先还原客户:"
+ customer.getCustomerName() + "!');location='"
+ request.getContextPath()
+ "/contact.do?method=listDeteleContact'</script>");
}
return null;
}
/**
* 彻底删除该数据以及该数据相关信息;
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws ApplicationException
*/
public ActionForward deleteContact(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String id = request.getParameter("id");
if (!StringTool.isNotBlank(id)) {
request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
throw new ApplicationException("the param you input is illegal");
}
User user = SessionMgr.getCustSession(request);
// 删除联系人
relationManage.updateEntitysStates(user.getId(), DateTimeTool
.getCurrentDate("yyyy-MM-dd HH:mm:ss"),
ClassCodeMgr.CUSTOMER_CONTACTINT, Integer.parseInt(id),
Constants.DELETESELF, Constants.PASSIVITY);
return mapping.findForward("contactAll");
}
// --------------------------------------更新后------------------------------------------//
@SuppressWarnings("unchecked")
public ActionForward contactCorrelation(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) throws ApplicationException {
ContactForm cForm = (ContactForm) form;
// String contactId = request.getParameter("contactId");
String contactId = cForm.getContactId();
String forward = "contactCorrelation";// 跳转到联系人相关项
if (!StringTool.isNotBlank(contactId)) { // 若传入的参数为空
request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
throw new IllegalParameterException(
Constants.ILLEALPARAMGOGALEXCEPTION);
}
logger.debug("有到这里吗。。。联系人ID" + contactId);
try {
// 搜索出相应联系人
CustomerContact contact = contactMgr.getContactById(contactId);
ContactVo contactVo = new ContactVo();
BeanUtils.copyProperties(contactVo, contact);// 将联系人属性拷贝给联系人VO
// 2009-02-25 add 数据范围
if (cForm.getDelRights() == null || cForm.getModifyRights() == null
|| "".equals(cForm.getDelRights())
|| "".equals(cForm.getModifyRights())) {
// 查找
User user = SessionMgr.getCustSession(request);
Rights rights = SessionMgr.getJspRightsControl(request)
.get("2").getRightsMap().get("204");
String userIds = authorizationMgr.findUserDataRange(rights
.getId(), user);
if (!authorizationMgr.isRights(user.getId(), userIds)) {
return mapping.findForward("noRights");
} else {
// 删除(数据范围)
Rights delRights = SessionMgr.getJspRightsControl(request)
.get("2").getRightsMap().get("203");
String delUserIds = authorizationMgr.findUserDataRange(
delRights.getId(), user);
logger.debug("delUserIds : " + delUserIds);
// 修改(数据范围)
Rights modifyRights = SessionMgr.getJspRightsControl(
request).get("2").getRightsMap().get("202");
String modifyUserIds = authorizationMgr.findUserDataRange(
modifyRights.getId(), user);
if (authorizationMgr.isRights(user.getId(), delUserIds)) {
contactVo.setDelRights("y");
}
if (authorizationMgr.isRights(user.getId(), modifyUserIds)) {
contactVo.setModifyRights("y");
}
}
} else {
contactVo.setDelRights(cForm.getDelRights());
contactVo.setModifyRights(cForm.getModifyRights());
}
// end add
request.setAttribute("contactVo", contactVo);
// 根据修改人的ID查找上次修改人
User modifyMan = contactMgr.getContactDao().findLastModifyMan(
contact.getModifyManId());
request.setAttribute("modifyUser", new UserVo(modifyMan.getId(),
modifyMan.getFamilyName()));
// 取得相应客户
Customer customer = contact.getCustomer();
if (customer != null) {// 判断客户是否为空,考虑到快速创建的时候联系人的客户可以为空;
contactVo.setCustomerId(customer.getId());
contactVo.setCustomerName(customer.getCustomerName());
}
// 搜索业务机会
List busiOpports = relationManage.getEntities(
ClassCodeMgr.BUSINESS_OPPORTINT,
ClassCodeMgr.CUSTOMER_CONTACTINT, Integer
.parseInt(contactId));
List<BusinessOpportunityVo> busiOpportList = relationManage
.busiOpportToBusiOpportVos(busiOpports);
request.setAttribute("busiOpports", busiOpportList);
request.setAttribute("busiOpportSize", busiOpportList.size());
logger.debug("出现错误了吗。。。");
// 搜索未处理的任务
List<ActivityTaskVo> imCompletedRasks = relationManage
.getActivityRasks(Integer.parseInt(contactId), -1);
request.setAttribute("imCompletedRasks", imCompletedRasks);
request
.setAttribute("imCompletedRaskSize", imCompletedRasks
.size());
logger.debug("未处理的任务。。。" + imCompletedRasks);
// 搜索未处理的事件
List<EventVo> imCompletedEvents = relationManage.getEvents(Integer
.parseInt(contactId), true);
request.setAttribute("imCompletedEvents", imCompletedEvents);
request.setAttribute("imCompletedEventSize", imCompletedEvents
.size());
logger.debug("未处理的事件。。。" + imCompletedEvents);
// 搜索任务历史---已经完成的任务
List<ActivityTaskVo> completedRasks = relationManage
.getActivityRasks(Integer.parseInt(contactId), 3);
request.setAttribute("completedRasks", completedRasks);
request.setAttribute("completedRaskSize", completedRasks.size());
logger.debug("联系人的历史任务。。。" + completedRasks);
// 搜索历史事件----过期事件
List<EventVo> completedEvents = relationManage.getEvents(Integer
.parseInt(contactId), false);
;
request.setAttribute("completedEvents", completedEvents);
request.setAttribute("completedEventSize", completedEvents.size());
logger.debug("联系人的历史事件。。。" + completedEvents);
} catch (Exception e) {
e.printStackTrace();
throw new ApplicationException(Constants.WITHOUTDATA);
}
return mapping.findForward(forward);
}
/**
* 新建任务
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws ApplicationException
* 2008-11-07 by 张明强 copied liu's
*/
public ActionForward createNewTask(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String contactId = request.getParameter("contactId");
logger.error("参数为。。。" + contactId);
if (!StringTool.isNotBlank(contactId)) {
logger.debug("the param you input is illegal");
request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
throw new IllegalParameterException(
"the param you input is illegal");
}
try {
CustomerContact contact = contactMgr.getContactById(contactId);
logger.error("有到这里吗。。。" + contact);
request.setAttribute("contactVo", new ContactVo(contact.getId(),
contact.getName()));
ConfigMgr configMgr = ConfigMgr.getInstance();// 取出相关项类;
Map<String, String> correlationsMap = configMgr
.getAllCorrelations();// 获取相关项对应的键值对;
if (correlationsMap != null && correlationsMap.size() > 0) {
request.setAttribute("correlationsMap", correlationsMap);// 把键值对存放到request范围内;
}
} catch (Exception e) {
request.setAttribute(Constants.ERRMSG, Constants.WITHOUTDATA);
throw new IllegalParameterException(
"the param you input is illegal");
}
return mapping.findForward("toAddTask");// 转发到添加任务活动的页面;
}
/**
* 新建事件
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws ApplicationException
* 2008-11-07 by 张明强 copied liu's
*/
public ActionForward createNewEvent(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String contactId = request.getParameter("contactId");
logger.error("参数为。。。" + contactId);
if (!StringTool.isNotBlank(contactId)) {
logger.debug("the param you input is illegal");
request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
throw new IllegalParameterException(
"the param you input is illegal");
}
try {
CustomerContact contact = contactMgr.getContactById(contactId);
logger.error("有到这里吗。。。" + contact);
request.setAttribute("contactVo", new ContactVo(contact.getId(),
contact.getName()));
ConfigMgr configMgr = ConfigMgr.getInstance();// 取出相关项类;
Map<String, String> correlationsMap = configMgr
.getAllCorrelations();// 获取相关项对应的键值对;
if (correlationsMap != null && correlationsMap.size() > 0) {
request.setAttribute("correlationsMap", correlationsMap);// 把键值对存放到request范围内;
}
} catch (Exception e) {
request.setAttribute(Constants.ERRMSG, Constants.WITHOUTDATA);
throw new IllegalParameterException(
"the param you input is illegal");
}
return mapping.findForward("toAddEvent");// 转发到添加任务活动的页面;
}
/**
* 新建业务机会
*
* @param mapping
* @param form
* @param request
* @param response
* @return
* @throws ApplicationException
*/
public ActionForward newBusiOpport(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response)
throws ApplicationException {
String contactId = request.getParameter("contactId");
logger.error("参数为。。。" + contactId);
if (!StringTool.isNotBlank(contactId)) {
logger.debug("the param you input is illegal");
request.setAttribute(Constants.ERRMSG, Constants.INPUTBANK);
throw new IllegalParameterException(
"the param you input is illegal");
}
try {
// 查找联系人
CustomerContact contact = contactMgr.getContactById(contactId);
logger.error("有到这里吗。。。" + contact);
request.setAttribute("CorrelationVo", new CorrelationVo(contact
.getId(), contact.getName()));
} catch (Exception e) {
request.setAttribute(Constants.ERRMSG, Constants.WITHOUTDATA);
throw new IllegalParameterException(
"the param you input is illegal");
}
return new ActionForward("/busiOpport/newBusiOpport.jsp");// 防止重定向
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -