201 lines
6.0 KiB
Plaintext
201 lines
6.0 KiB
Plaintext
<%@ page import="weaver.general.Util" %>
|
||
<%@ page import="java.text.SimpleDateFormat" %>
|
||
<%@ page import="java.util.Date" %>
|
||
<%@ page import="java.util.Calendar" %>
|
||
<%@ page import="weaver.conn.RecordSet" %>
|
||
<%@ page import="weaver.hrm.resource.ResourceComInfo" %>
|
||
<%@ page import="weaver.hrm.company.SubCompanyComInfo" %>
|
||
<%@ page language="java" contentType="text/html; charset=utf-8" pageEncoding="utf-8"%>
|
||
<jsp:useBean id="rs" class="weaver.conn.RecordSet" scope="page" />
|
||
<%
|
||
int sum = 0;
|
||
String resourceId = Util.null2String(request.getParameter("userid"));
|
||
String startdate = Util.null2String(request.getParameter("date"));
|
||
|
||
//服务处
|
||
String fwc = getGlc(resourceId,startdate);
|
||
//班组
|
||
String bz = getBz(resourceId,startdate);
|
||
//中心
|
||
String zx = getZx(resourceId);
|
||
|
||
//入离职状态 0-当月入职 1-当月离职
|
||
String rlzzt = null;
|
||
//入职日期
|
||
String rzrq = Util.null2String(getRzrq(resourceId));
|
||
if(rzrq!=null && !"".equals(rzrq)){
|
||
String rzrq_date = rzrq.substring(0,7);
|
||
if(rzrq_date.equals(startdate)){
|
||
rlzzt = "0";
|
||
}
|
||
}
|
||
|
||
//离职日期
|
||
String lzrq = Util.null2String(getLzrq(resourceId));
|
||
if(lzrq!=null && !"".equals(lzrq)){
|
||
String lzrq_date = lzrq.substring(0,7);
|
||
if(lzrq_date.equals(startdate)){
|
||
rlzzt = "1";
|
||
}
|
||
}
|
||
|
||
sum++;
|
||
%>
|
||
|
||
<%!
|
||
|
||
/**
|
||
* 获取 入职日期
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getRzrq(String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select companystartdate from HrmResource where id = ?",userid);
|
||
while (rs.next()){
|
||
result = Util.null2String(rs.getString("companystartdate"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 离职日期
|
||
* @param userid
|
||
* @return
|
||
*/
|
||
public static String getLzrq(String userid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
rs.executeQuery("select changedate from HrmStatusHistory where type_n='5' and resourceid=?",userid);
|
||
while (rs.next()){
|
||
result = Util.null2String(rs.getString("changedate"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 服务处
|
||
* @param resourceid
|
||
* @param kqdate
|
||
* @return
|
||
*/
|
||
public static String getGlc(String resourceid,String kqdate){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
String newdeptid = getNewDeptid(resourceid,kqdate);
|
||
rs.executeQuery("select dbo.getDept('"+newdeptid+"',2) as fwc");
|
||
if(rs.next()){
|
||
result = com.wbi.util.Util.null2String(rs.getString("fwc"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 班组
|
||
* @param resourceid
|
||
* @param kqdate
|
||
* @return
|
||
*/
|
||
public static String getBz(String resourceid,String kqdate){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
String newdeptid = getNewDeptid(resourceid,kqdate);
|
||
rs.executeQuery("select dbo.getDept('"+newdeptid+"',3) as bz");
|
||
if(rs.next()){
|
||
result = com.wbi.util.Util.null2String(rs.getString("bz"));
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 中心
|
||
* @param resourceid
|
||
* @return
|
||
*/
|
||
public static String getZx(String resourceid){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
try {
|
||
rs.executeQuery("select field100032 as zx from cus_fielddata where scope = 'HrmCustomFieldByInfoType' and scopeid = '3' and id = ?", resourceid);
|
||
if (rs.next()) {
|
||
result = com.wbi.util.Util.null2String(rs.getString("zx"));
|
||
} else {
|
||
String subcomid = new ResourceComInfo().getSubCompanyID(resourceid);
|
||
result = new SubCompanyComInfo().getSubCompanyname(subcomid);
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
rs.writeLog(e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 获取 部门id 如果指定月份的次月 人员有异动记录,需要返回原部门。 如果没有,返回组织架构所属部门
|
||
* @param resourceid
|
||
* @param date
|
||
* @return
|
||
*/
|
||
public static String getNewDeptid(String resourceid,String date){
|
||
String result = "";
|
||
RecordSet rs = new RecordSet();
|
||
try {
|
||
String nextdate = addDateMonth(date, 1);
|
||
String nextmonth = nextdate.substring(5, 7);
|
||
rs.executeQuery("select oldDepartmentId from HrmStatusHistory where resourceid=? and changedate > ? and MONTH(changedate)=" + nextmonth,resourceid,date);
|
||
if (rs.next()) {
|
||
result = com.wbi.util.Util.null2String(rs.getString("oldDepartmentId"));
|
||
} else {
|
||
result = new ResourceComInfo().getDepartmentID(resourceid);
|
||
}
|
||
}catch (Exception e){
|
||
e.printStackTrace();
|
||
rs.writeLog(e);
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/**
|
||
* 对时间的月数进行加减
|
||
* @param daytime 时间的格式:yyyy-MM-dd
|
||
* @param day 月数 -1则代表减一月
|
||
* @return
|
||
*/
|
||
public static String addDateMonth(String daytime, int day){
|
||
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
||
Date date = null;
|
||
try {
|
||
date = format.parse(daytime);
|
||
if (date == null){
|
||
return "";
|
||
}
|
||
Calendar cal = Calendar.getInstance();
|
||
cal.setTime(date);
|
||
cal.add(Calendar.MONTH, day);// 加一月
|
||
date = cal.getTime();
|
||
cal = null;
|
||
return format.format(date);
|
||
} catch (Exception ex) {
|
||
ex.printStackTrace();
|
||
}
|
||
return "";
|
||
}
|
||
|
||
%>
|
||
|
||
<BODY>
|
||
|
||
<h1>Congratulation Mode 666666 !</h1>
|
||
|
||
<h1> sum <%=sum%> </h1>
|
||
|
||
<h2> 入离职状态 <%=rlzzt%> </h2>
|
||
|
||
<h2> 服务处 <%=fwc%> </h2>
|
||
|
||
<h2> 班组 <%=bz%> </h2>
|
||
|
||
<h2> 中心 <%=zx%> </h2>
|
||
|
||
</BODY> |