📄 trainingnoticeaction.java
字号:
package com.mdcl.mocha.jlcmcc.trainingNotice.action;
import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.log4j.Logger;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;
import com.mdcl.mocha.bpm.sdk.ServiceManager;
import com.mdcl.mocha.bpm.sdk.license.LicenseException;
import com.mdcl.mocha.bpm.sdk.osm.IAccountsMgmtService;
import com.mdcl.mocha.bpm.sdk.osm.IOrgMgmtService;
import com.mdcl.mocha.bpm.sdk.osm.entity.AccountsBean;
import com.mdcl.mocha.bpm.sdk.osm.entity.EmpBean;
import com.mdcl.mocha.bpm.sdk.osm.entity.EmpInstBean;
import com.mdcl.mocha.bpm.sdk.osm.entity.OrgBean;
import com.mdcl.mocha.bpm.webcommons.action.BPMBaseAction;
import com.mdcl.mocha.bpm.webcommons.constant.ISessionAttributeConstant;
import com.mdcl.mocha.jlcmcc.trainingNotice.bo.ITrainingNoticeManager;
import com.mdcl.mocha.jlcmcc.trainingNotice.bo.TrainingNoticeManager;
/**
* <strong>Title : TrainingNoticeAction<br>
* </strong> <strong>Description : </strong><br>
* <strong>Create on : 2007-10-8<br>
* </strong>
* <p>
* <strong>Copyright (C) Mocha Software Co.,Ltd.<br>
* </strong>
* <p>
*
* @author linda linda@mochasoft.com.cn<br>
* @version <strong>吉林移动BPM一期</strong><br>
* <br>
* <strong>修改历史:</strong><br>
* 修改人 修改日期 修改描述<br>
* -------------------------------------------<br>
* <br>
* <br>
*/
public class TrainingNoticeAction extends BPMBaseAction {
/**
* <code>S_LOGGER</code>-注释
*/
private static final Logger S_LOGGER = Logger
.getLogger(TrainingNoticeAction.class);
/**
* 方法描述
*
* 数据操作通用方法,处理保存、删除、更新以及查询请求
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward operateInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeAction.operateInfo()>>>");
}
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
}
// 获取数据参数
String[] id = request.getParameterValues("id");
String[] user_name = request.getParameterValues("user_name");
String[] user_id = request.getParameterValues("user_id");
String[] company_name = request.getParameterValues("company_name");
String[] company_id = request.getParameterValues("company_id");
String[] dept_name = request.getParameterValues("dept_name");
String[] dept_id = request.getParameterValues("dept_id");
String[] phone = request.getParameterValues("phone");
String[] email = request.getParameterValues("email");
String[] user_type = request.getParameterValues("user_type");
String[] add_user = request.getParameterValues("add_user");
String[] remark = request.getParameterValues("remark");
String[] boInsId = request.getParameterValues("boInsId");
// 获得信息条数
String quantityStr = request.getParameter("quantity");
int quantity = 0;
if (quantityStr != null) {
quantity = Integer.parseInt(quantityStr);
}
// 获得二次显示的查询条件
String query_user_type = request.getParameter("query_user_type");
String query_add_user = request.getParameter("query_add_user");
String query_boInsId = request.getParameter("query_boInsId");
String orderBy = request.getParameter("orderby");
if (orderBy == null || orderBy.equals(""))
orderBy = "id";
// 获得操作类型
String opTypeStr = request.getParameter("opType");
int opType = 0;
if (opTypeStr != null) {
if (opTypeStr.equals("insert"))
opType = ITrainingNoticeManager.DBOPERTAION_INSERT;
else if (opTypeStr.equals("delete"))
opType = ITrainingNoticeManager.DBOPERTAION_DELETE;
else if (opTypeStr.equals("update"))
opType = ITrainingNoticeManager.DBOPERTAION_UPDATE;
else if (opTypeStr.equals("search"))
opType = ITrainingNoticeManager.DBOPERTAION_SEARCH;
else
opType = 0;
}
// 设置返回页面
String forward = "Success";
// 将数据压入Map中,以便于数据传输
Map map = new HashMap();
map.put("id", id);
map.put("user_name", user_name);
map.put("user_id", user_id);
map.put("dept_name", dept_name);
map.put("dept_id", dept_id);
map.put("company_name", company_name);
map.put("company_id", company_id);
map.put("phone", phone);
map.put("email", email);
map.put("user_type", user_type);
map.put("add_user", add_user);
map.put("remark", remark);
map.put("boInsId", boInsId);
String message = "";
try {
// 获得培训通知服务类接口
ITrainingNoticeManager trainingService = new TrainingNoticeManager();
// 进行查询操作
if (opType == ITrainingNoticeManager.DBOPERTAION_SEARCH) {
List list = trainingService.queryInfo(map, quantity, true,
orderBy);
request.setAttribute("list", list);
forward = "Success";
}
// 进行插入、更新、删除操作
else if (opType != 0) {
if (!trainingService.dateOperate(map, quantity, opType)) {
message = "操作失败!";
forward = "Message";
} else {
if (query_user_type != null && query_add_user != null) {
Map queryMap = new HashMap();
queryMap.put("user_type", query_user_type);
queryMap.put("add_user", query_add_user);
queryMap.put("boInsId", query_boInsId);
List list = trainingService.queryInfo(queryMap, 1,
false, orderBy);
request.setAttribute("list", list);
request.setAttribute("queryMap", queryMap);
forward = "Success";
} else {
message = "操作成功!";
forward = "Message";
}
}
}
// 没有指定操作
else {
message = "没有指定操作!";
forward = "Message";
}
} catch (Exception e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
request.getSession().setAttribute(
ISessionAttributeConstant.ERR_EXCEPTION_KEY, e);
}
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeAction.operateInfo()<<<");
}
request.setAttribute("message", message);
return mapping.findForward(forward);
}
/**
* 方法描述
*
* 处理数据查询请求(普通类型),返回封装内容为TrainingNoticeBean的List
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward queryInfo(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeAction.queryInfo()>>>");
}
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
}
// 获得数据参数
String id = request.getParameter("id");
String user_name = request.getParameter("user_id");
String user_id = request.getParameter("user_id");
String company_name = request.getParameter("company_name");
String company_id = request.getParameter("company_id");
String dept_name = request.getParameter("dept_name");
String dept_id = request.getParameter("dept_id");
String phone = request.getParameter("phone");
String email = request.getParameter("email");
String user_type = request.getParameter("user_type");
String add_user = request.getParameter("add_user");
String remark = request.getParameter("remark");
String boInsId = request.getParameter("boInsId");
if (user_type != null) {
if (user_type.trim().equals("internal"))
user_type = "系统人员";
else if (user_type.trim().equals("external"))
user_type = "外部人员";
}
// 将数据压入Map中,以便于数据传输
Map map = new HashMap();
map.put("id", id);
map.put("user_id", user_id);
map.put("user_name", user_name);
map.put("dept_name", dept_name);
map.put("dept_id", dept_id);
map.put("company_name", company_name);
map.put("company_id", company_id);
map.put("phone", phone);
map.put("email", email);
map.put("user_type", user_type);
map.put("add_user", add_user);
map.put("remark", remark);
map.put("boInsId", boInsId);
String orderBy = request.getParameter("orderby");
if (orderBy == null || orderBy.equals(""))
orderBy = "id";
List list = null;
try {
// 获得培训通知服务类接口
ITrainingNoticeManager trainingService = new TrainingNoticeManager();
list = trainingService.queryInfo(map, 1, false, orderBy);
} catch (Exception e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
request.getSession().setAttribute(
ISessionAttributeConstant.ERR_EXCEPTION_KEY, e);
request.setAttribute("message", "操作失败!");
return mapping.findForward("Message");
}
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeAction.queryInfo()<<<");
}
request.setAttribute("list", list);
request.setAttribute("queryMap", map);
return mapping.findForward("Success");
}
/**
* 方法描述
*
* 处理数据查询请求(Ajax请求),以XML格式输出数据
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward queryInfoXML(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeAction.queryInfoXML()>>>");
}
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
}
// 获得帐号id
String idStr = request.getParameter("id");
String[] user_id = idStr.split(":");
// 设置返回内容的类型
response.setContentType("text/xml;charset=UTF-8");
response.setHeader("Cache-Control", "no-cache");
// 设置文件头
String xml_head = "\n<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
String xml = "<traninginfos>\n";
try {
for (int i = 0; i < user_id.length; i++) {
// 获得帐号管理服务类接口
IAccountsMgmtService accountsMng = (IAccountsMgmtService) ServiceManager
.getInstance().getService(IAccountsMgmtService.class);
// 获得行政组织管理服务类接口
IOrgMgmtService orgMng = (IOrgMgmtService) ServiceManager
.getInstance().getService(IOrgMgmtService.class);
// 通过帐号ID获得帐号实体Bean
AccountsBean account = accountsMng.getAccountsById(user_id[i]);
// 获得当前帐号实体所属的人员信息实体Bean
EmpBean emp = account.getEmpinfo();
// 获得当前帐号实体所属的行政组织信息实体List
List list = account.getEilist();
EmpInstBean empInst = (EmpInstBean) list.get(0);
// 获得当前人员信息实体所属的二级行政组织信息实体Bean
OrgBean dept = orgMng.getOrgByLevel(empInst.getOrgid(), 2);
if (dept.getId() == null) {
dept = empInst.getOrginfo();
}
// 获得当前行政组织信息实体所属的一级行政组织信息实体Bean
OrgBean company = orgMng.getOrgByLevel(dept.getId(), 1);
if (company.getId() == null) {
company = dept;
dept = new OrgBean();
}
xml += "\t<traininginfo>\n";
xml += "\t\t<info>" + emp.getEmpname() + "</info>\n"
+ "\t\t<info>" + emp.getId() + "</info>\n"
+ "\t\t<info>" + company.getOrgname() + "</info>\n"
+ "\t\t<info>" + company.getId() + "</info>\n"
+ "\t\t<info>" + dept.getOrgname() + "</info>\n"
+ "\t\t<info>" + dept.getId() + "</info>\n"
+ "\t\t<info>" + emp.getMobile() + "</info>\n"
+ "\t\t<info>" + emp.getEmail() + "</info>\n";
xml += "\t</traininginfo>\n";
}
} catch (LicenseException e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
request.getSession().setAttribute(
ISessionAttributeConstant.LICENSE_EXCEPTION_KEY, e);
request.setAttribute("message", "操作失败!");
return mapping.findForward("Message");
} catch (Exception e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
request.getSession().setAttribute(
ISessionAttributeConstant.ERR_EXCEPTION_KEY, e);
request.setAttribute("message", "操作失败!");
return mapping.findForward("Message");
}
xml = xml_head + xml + "</traninginfos>\n";
PrintWriter out = null;
try {
out = response.getWriter();
} catch (IOException e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
}
out.write(xml);
out.flush();
out.close();
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeActionAjax.queryInfoXML()<<<");
}
return null;
}
/**
* 方法描述
*
* 根据请求选择跳转页面 —— 主要是处理显示“添加系统人员”、“添加外部人员”页面的请求
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward showPage(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeAction.showPage()>>>");
}
try {
request.setCharacterEncoding("UTF-8");
} catch (UnsupportedEncodingException e) {
S_LOGGER.error("TrainingNoticeAction.error", e);
}
// 获得请求的页面标识
String reqPage = request.getParameter("reqPage");
// 获得当前办理人的userID及流程实例ID,便于传入显示页面,方便统一保存入库,用于查询当前办理人添加的人员信息
String add_user = request.getParameter("add_user");
String boInsId = request.getParameter("boInsId");
String forward = null;
if (reqPage != null) {
// 请求显示“添加内系统人员”页面
if (reqPage.trim().equals("AddInternal"))
forward = "AddInternal";
// 请求显示“添加外部人员”页面
else if (reqPage.trim().equals("AddExternal"))
forward = "AddExternal";
// 都不匹配,不做页面跳转
else
return null;
}
// 将当前办理人userID,传入显示页面
request.setAttribute("add_user", add_user);
request.setAttribute("boInsId", boInsId);
if (S_LOGGER.isDebugEnabled()) {
S_LOGGER.debug("TrainingNoticeAction.showPage()<<<");
}
return mapping.findForward(forward);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -