📄 humanfileaction.java
字号:
if (level == 1) {
for (Object obj : levelList) {
ConfigFileSecondKind csk = (ConfigFileSecondKind) obj;
xml.append("<level>");
xml.append("<id>" + csk.getSecondKindId() + "</id>");
xml.append("<name>" + csk.getSecondKindName() + "</name>");
xml.append("</level>");
}
} else if (level == 2) {
for (Object obj : levelList) {
ConfigFileThirdKind ctk = (ConfigFileThirdKind) obj;
xml.append("<level>");
xml.append("<id>" + ctk.getThirdKindId() + "</id>");
xml.append("<name>" + ctk.getThirdKindName() + "</name>");
xml.append("</level>");
}
} else if (level == 3) {
for (Object obj : levelList) {
ConfigMajor cm = (ConfigMajor) obj;
xml.append("<level>");
xml.append("<id>" + cm.getMakId() + "</id>");
xml.append("<name>" + cm.getMajorName() + "</name>");
xml.append("</level>");
}
}
xml.append("</levels>");
out.write(xml.toString());
out.flush();
out.close();
return null;
}
/**
* 删除人资档案(将状态标记为删除)
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doDeleteHumanFile(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String id = request.getParameter("id");
String hql = "update HumanFile set humanFileStatus=0 where hufId = "
+ id;
boolean flag = humanBiz.update(hql, null);
if (flag) {
request.setAttribute("msg", getAlert("删除成功"));
} else {
request.setAttribute("msg", getAlert("删除失败"));
}
return mapping.findForward("deleteOk");
}
/**
* 加载humanFile_query.jsp下拉列表的数据源
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toLoadFirstKind(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
String hql = "from ConfigFileFirstKind";
String hql1 = "from ConfigMajorKind";
List firstLevel = humanBiz.search(hql);
List jobCateList = humanBiz.search(hql1);
request.setAttribute("firstLevel", firstLevel);
request.setAttribute("jobCateList", jobCateList);
return mapping.findForward("query");
}
/**
* 档案查询
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doQuery(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int pageId = 1;
try {
pageId = Integer.parseInt(request.getParameter("currPageId"));
} catch (Exception e) {
}
HumanFileForm hff = (HumanFileForm) form;
StringBuffer buf = new StringBuffer(
"from HumanFile where checkStatus = 1 and (humanFileStatus is null or humanFileStatus != 0) ");
if (!"NULL".equals(hff.getFirstKindId())
&& hff.getFirstKindId() != null) {
buf.append("and firstKindId ='" + hff.getFirstKindId() + "' ");
}
if (!"NULL".equals(hff.getSecondKindId())
&& hff.getSecondKindId() != null) {
buf.append("and secondKindId = '" + hff.getSecondKindId() + "' ");
}
if (!"NULL".equals(hff.getThirdKindId())
&& hff.getThirdKindId() != null) {
buf.append("and thirdKindId = '" + hff.getThirdKindId() + "' ");
}
if (!"NULL".equals(hff.getHumanMajorKindId())
&& hff.getHumanMajorKindId() != null) {
buf.append("and humanMajorKindId = '" + hff.getHumanMajorKindId()
+ "' ");
}
if (!"NULL".equals(hff.getHumanMajorId())
&& hff.getHumanMajorId() != null) {
buf.append("and humanMajorId = '" + hff.getHumanMajorId() + "' ");
}
if (hff.getStartTime() != "" && hff.getStartTime() != null
&& hff.getEndTime() != "" && hff.getEndTime() != null) {
buf.append("and registTime > '" + hff.getStartTime()
+ "' and registTime < '" + hff.getEndTime() + "'");
}
List humanList = humanBiz.search(buf.toString());
int recordCount = humanList.size();
List list = humanBiz.paginationSearch(pageSize, pageId, buf.toString());
// 分页所须数据
request.setAttribute("humanList", list);
// 记录总数
request.setAttribute("recordCount", recordCount);
// 当前第几页
request.setAttribute("currPageId", pageId);
// 一页多少条
request.setAttribute("pageSize", pageSize);
return mapping.findForward("queryResult");
}
/**
* 加载查询的档案
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doQueryDetail(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int id = Integer.parseInt(request.getParameter("id"));
String hql = "from HumanFile where hufId = " + id;
HumanFile hf = (HumanFile) humanBiz.uniqueSearch(hql);
hf.setRemark(this.htmlEncode(hf.getRemark()));
hf.setHumanHistroyRecords(this.htmlEncode(hf.getHumanHistroyRecords()));
hf.setHumanFamilyMembership(this.htmlEncode(hf
.getHumanFamilyMembership()));
request.setAttribute("human", hf);
this.setHumanSource(request);
return mapping.findForward("queryDetail");
}
/**
* 加载待修改的档案
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int id = Integer.parseInt(request.getParameter("id"));
String hql = "from HumanFile where hufId = " + id;
HumanFile hf = (HumanFile) humanBiz.uniqueSearch(hql);
request.setAttribute("human", hf);
this.setHumanSource(request);
return mapping.findForward("tomodify");
}
/**
* 加载待恢复的档案信息
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toResume(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int id = Integer.parseInt(request.getParameter("id"));
String hql = "from HumanFile where hufId = " + id;
HumanFile hf = (HumanFile) humanBiz.uniqueSearch(hql);
request.setAttribute("human", hf);
this.setHumanSource(request);
return mapping.findForward("resume");
}
/**
* 恢复删除的信息
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doResume(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
short id = Short.parseShort(request.getParameter("id"));
String hql = "update HumanFile set humanFileStatus =1 where hufId = ?";
boolean flag = humanBiz.update(hql, id);
if (flag) {
request.setAttribute("msg", getAlert("恢复成功"));
}
return mapping.findForward("resumeOk");
}
/**
* 变更档案
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward doModify(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
HumanFileForm hff = (HumanFileForm) form;
HumanFile human = new HumanFile();
try {
BeanUtils.copyProperties(human, hff);
human.setCheckStatus((short) 0);
String username = this.getUserName(request);
human.setChanger(username);
human.setChangeTime(new Date());
humanBiz.modify(human);
request.setAttribute("msg", getAlert("变更成功"));
request.setAttribute("humanId", human.getHumanId());
return mapping.findForward("modifyOk");
} catch (IllegalAccessException e) {
e.printStackTrace();
} catch (InvocationTargetException e) {
e.printStackTrace();
}
return null;
}
/**
* 精确查询(根据ID或身份证号码)
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toLoadHumanFile(ActionMapping mapping,
ActionForm form, HttpServletRequest request,
HttpServletResponse response) {
int type = Integer.parseInt(request.getParameter("type"));
String id = request.getParameter("id");
String hql = "";
if (type == 1) {
hql = "from HumanFile where humanId = ? and (humanFileStatus != 0 or humanFileStatus is NULL)";
} else {
hql = "from HumanFile where humanIdCard = ? and (humanFileStatus != 0 or humanFileStatus is NULL)";
}
HumanFile hf = (HumanFile) humanBiz.uniqueSearch(hql, id);
if (hf != null) {
request.setAttribute("human", hf);
return mapping.findForward("queryDetail");
} else {
request.setAttribute("msg", getAlert("您所查询的档案不存在或已被删除"));
return mapping.findForward("exactitude");
}
}
/**
* 加载删除的档案
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toLoadResume(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
int pageId = 1;
try {
pageId = Integer.parseInt(request.getParameter("currPageId"));
} catch (Exception e) {
}
String hql = "from HumanFile where humanFileStatus = 0";
List humanList = humanBiz.paginationSearch(pageSize, pageId, hql);
String hql2 = "select count(h.hufId) from HumanFile h where h.humanFileStatus = 0";
int count = Integer.parseInt(humanBiz.uniqueSearch(hql2, null)
.toString());
request.setAttribute("humanList", humanList);
request.setAttribute("currPageId", pageId);
request.setAttribute("recordCount", count);
request.setAttribute("pageSize", pageSize);
return mapping.findForward("toResume");
}
/**
* 跳转至重新上传附件页面
*
* @param mapping
* @param form
* @param request
* @param response
* @return
*/
public ActionForward toReupload(ActionMapping mapping, ActionForm form,
HttpServletRequest request, HttpServletResponse response) {
String humanId = request.getParameter("humanId");
request.setAttribute("humanId", humanId);
return mapping.findForward("toReupload");
}
/**
* 加载要绑定的数据源
*
* @param request
*/
public void setHumanSource(HttpServletRequest request) {
// 加载一二三级机构数据源
String hql1 = "from ConfigFileFirstKind";
List firstLevel = humanBiz.search(hql1);
// 职位分类
String hql4 = "from ConfigMajorKind";
List jobCateList = humanBiz.search(hql4);
// 职称
String hql6 = "from ConfigPublicChar where attributeKind = '职称'";
List jobList = humanBiz.search(hql6);
// 国籍
String hql7 = "from ConfigPublicChar where attributeKind = '国籍'";
List countryList = humanBiz.search(hql7);
// 民族
String hql8 = "from ConfigPublicChar where attributeKind = '民族'";
List nationList = humanBiz.search(hql8);
// 宗教信仰
String hql9 = "from ConfigPublicChar where attributeKind = '宗教信仰'";
List religionList = humanBiz.search(hql9);
// 政治面貌
String hql10 = "from ConfigPublicChar where attributeKind = '政治面貌'";
List polityList = humanBiz.search(hql10);
// 学历(文凭)
String hql11 = "from ConfigPublicChar where attributeKind = '学历'";
List diplomaList = humanBiz.search(hql11);
// 学历专业
String hql12 = "from ConfigPublicChar where attributeKind = '专业'";
List specialityList = humanBiz.search(hql12);
// 薪酬标准
String hql13 = "from SalaryStandard where checkStatus=1";
List salaryLevelList = humanBiz.search(hql13);
// 教育年限
String hql14 = "from ConfigPublicChar where attributeKind = '教育年限'";
List educstedYear = humanBiz.search(hql14);
// 特长
String hql15 = "from ConfigPublicChar where attributeKind = '特长'";
List specList = humanBiz.search(hql15);
// 爱好
String hql16 = "from ConfigPublicChar where attributeKind = '爱好'";
List hobbyList = humanBiz.search(hql16);
// 将相关参数加载放入请求中
request.setAttribute("firstLevel", firstLevel);
request.setAttribute("jobCateList", jobCateList);
request.setAttribute("jobList", jobList);
request.setAttribute("countryList", countryList);
request.setAttribute("nationList", nationList);
request.setAttribute("religionList", religionList);
request.setAttribute("polityList", polityList);
request.setAttribute("diplomaList", diplomaList);
request.setAttribute("specialityList", specialityList);
request.setAttribute("salaryLevelList", salaryLevelList);
request.setAttribute("educstedYear", educstedYear);
request.setAttribute("specList", specList);
request.setAttribute("hobbyList", hobbyList);
}
/**
* 返回至客户端提示消息
*
* @param content
* @return
*/
private String getAlert(String content) {
return "<script>alert(\"" + content + "!\");</script>";
}
/**
* 得到当前登录的用户名
*
* @param request
* @return
*/
private String getUserName(HttpServletRequest request) {
HttpSession ses = request.getSession();
String userName = ((Users) ses.getAttribute("users")).getUserName();
return userName;
}
/**
* 将数据库数据中的回车符替换为换行符<br/>
*
* @param str
* @return
*/
private String htmlEncode(String str) {
return str.replace("\n", "<br/>");
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -