You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
weaver-develop/src/com/api/hrm/util/HrmBaseStateUtil.java

1832 lines
64 KiB
Java

package com.api.hrm.util;
import java.util.ArrayList;
import java.util.Calendar;
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.commons.lang.StringUtils;
import weaver.common.StringUtil;
import weaver.conn.RecordSet;
import weaver.general.BaseBean;
import weaver.general.TimeUtil;
import weaver.general.Util;
import weaver.hrm.HrmUserVarify;
import weaver.hrm.User;
import weaver.hrm.appdetach.AppDetachComInfo;
import weaver.hrm.common.SplitPageTagFormat;
import weaver.hrm.common.database.dialect.DbDialectFactory;
import weaver.hrm.common.database.dialect.DialectUtil;
import weaver.hrm.job.EducationLevelComInfo;
import weaver.hrm.job.JobActivitiesComInfo;
import weaver.hrm.job.JobCallComInfo;
import weaver.hrm.job.JobGroupsComInfo;
import weaver.hrm.job.UseKindComInfo;
import weaver.systeminfo.SystemEnv;
public class HrmBaseStateUtil extends BaseBean {
/*
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getAgeRpResult(HttpServletRequest request,HttpServletResponse response){
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
String agearea =Util.null2String(request.getParameter("agearea"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
String sqlwhere="";
String sqlwhere_0="";
if(agearea.equals("")||agearea.equals("0"))
agearea="10";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")&&!fromdate.equals("0")){
sqlwhere+=" and companystartdate>='"+fromdate+"' ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where companystartdate>='"+fromdate+"' ";
}
else{
sqlwhere_0 +=" and companystartdate>='"+fromdate+"' ";
}
}
if(!enddate.equals("")&&!enddate.equals("0")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where (companystartdate<='"+enddate+"' or companystartdate is null)";
}
else{
sqlwhere_0 +=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
}
if(!location.equals("")&&!location.equals("0")){
sqlwhere+=" and locationid ="+location;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where locationid ="+location;
}
else{
sqlwhere_0 +=" and locationid ="+location;
}
}
if(!department.equals("")&&!department.equals("0")){
sqlwhere+=" and departmentid in ("+department+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where departmentid in ("+department+") ";
}
else{
sqlwhere_0 +=" and departmentid in ("+department+") ";
}
}
if(!subcompany.equals("")&&!subcompany.equals("0")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where subcompanyid1 in ("+subcompany+") ";
}
else{
sqlwhere_0 +=" and subcompanyid1 in ("+subcompany+") ";
}
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status <= 3";
}else{
sqlwhere_0 +=" and status <= 3";
}
}else{
sqlwhere+=" and status ="+status;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status ="+status;
}else{
sqlwhere_0 +=" and status ="+status;
}
}
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where "+innerResourceSql;
}else{
sqlwhere_0 +=" and "+innerResourceSql;
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
if (sqlwhere_0.equals("")){
sqlwhere_0 = " where " + detachSqlWhere;
} else {
sqlwhere_0 += " and " + detachSqlWhere;
}
}
String sqlstr="";
String sql="";
int resultcount=0;
if(sqlwhere_0.equals("")){
sql = "select count(*) from HrmResource where accounttype is null or accounttype=0 ";
}else{
sql = "select count(*) from HrmResource "+sqlwhere_0+" and (accounttype is null or accounttype=0)";
}
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);/*总人数*/
/*先算出年龄记录为空的人数*/
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and birthday is null or birthday =''";
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and (birthday is null or birthday ='')"+sqlwhere;
}
rs.executeSql(sqlstr);
rs.next();
resultcount = rs.getInt(1);
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(resultcount != 0){//年龄为空人数占比
map = new HashMap<String, String>();
map.put("title", SystemEnv.getHtmlLabelName(15863,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
Calendar today = Calendar.getInstance();
int tempyear = Util.getIntValue(Util.add0(today.get(Calendar.YEAR), 4));//当前年份
if(rs.getDBType().equals("oracle")){
sqlstr="select min(birthday) from HrmResource where (accounttype is null or accounttype=0) and birthday is not null and length(ltrim(rtrim(birthday)))=10 ";
}else if(rs.getDBType().equals("db2")){
sqlstr="select min(birthday) from HrmResource where birthday !='' and length(ltrim(rtrim(birthday)))=10 ";
}else if(DialectUtil.isMySql(rs.getDBType())){
sqlstr="select min(birthday) from HrmResource where (accounttype is null or accounttype=0) " +
"and birthday is not null and birthday !='' and "+
DbDialectFactory.get(rs.getDBType()).charLengthSql("ltrim(rtrim(birthday))")+"=10 ";
}else if(rs.getDBType().equals("postgresql")){
sqlstr="select min(birthday) from HrmResource where (accounttype is null or accounttype=0) and birthday is not null and birthday<>'' and length(ltrim(rtrim(birthday)))=10 ";
}else{
sqlstr="select min(birthday) from HrmResource where (accounttype is null or accounttype=0) and birthday is not null and birthday !='' and len(ltrim(rtrim(birthday)))=10 ";
}
rs.executeSql(sqlstr);
rs.next();
String minworday=rs.getString(1);//年龄最大
if(!minworday.equals("")){
int minyear = Util.getIntValue(minworday.substring(0,4));
int yearcount = tempyear-minyear+1;//年龄
int agenum = Util.getIntValue(agearea);
int cyc = yearcount/agenum +1;//循环次数
String agefrom ="";
String ageto = "";
for(int i=0;i<cyc;i++){//循环列出
int from_Y= i*agenum;
int to_Y = (i+1)* agenum-1;
agefrom =(tempyear -agenum)+"-"+
Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ;
ageto =(tempyear)+"-"+
Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ;
if(rs.getDBType().equals("oracle")){
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and birthday >'"+agefrom+"' and birthday <='"+ageto+"' and birthday is not null ";
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and birthday >'"+agefrom+"' and birthday <='"+ageto+"' and birthday is not null "+sqlwhere;
}
}else if(rs.getDBType().equals("db2")){
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where birthday >'"+agefrom+"' and birthday <='"+ageto+"' and birthday<>'' ";
}else{
sqlstr="select count(*) resultcount from HrmResource where birthday >'"+agefrom+"' and birthday <='"+ageto+"' and birthday<>'' "+sqlwhere;
}
}else{
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and birthday >'"+agefrom+"' and birthday <='"+ageto+"' and birthday<>'' and birthday is not null ";
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and birthday >'"+agefrom+"' and birthday <='"+ageto+"' and birthday<>'' and birthday is not null "+sqlwhere;
}
}
rs.executeSql(sqlstr);
rs.next();
resultcount = rs.getInt(1);
if(resultcount!=0){
map = new HashMap<String, String>();
map.put("title", from_Y+"-"+to_Y+" "+SystemEnv.getHtmlLabelName(15864,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
tempyear -= agenum;
}
}
return list;
}
/*
*
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getSexRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
String sqlwhere="";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")&&!fromdate.equals("0")){
sqlwhere+=" and companystartdate>='"+fromdate+"' ";
}
if(!enddate.equals("")&&!enddate.equals("0")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null) ";
}
if(!location.equals("")&&!location.equals("0")){
sqlwhere+=" and locationid ="+location+" ";
}
if(!department.equals("")&&!department.equals("0")){
sqlwhere+=" and departmentid in ("+department+") ";
}
if(!subcompany.equals("")&&!subcompany.equals("0")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3 ";
}else{
sqlwhere+=" and status ="+status+" ";
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sqlstr="";
String sql="";
if(sqlwhere.equals("")){
sql = "select count(*) from HrmResource where (accounttype is null or accounttype=0) and id>2 ";
}else{
sql = "select count(*) from HrmResource where (accounttype is null or accounttype=0) and id>2 "+sqlwhere;
}
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);
String sex="";
String sexname = "";
int resultcount = 0 ;
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
sqlstr = "select COUNT(*) resultcount , sex from HrmResource where (accounttype is null or accounttype=0) and id>2 "+sqlwhere +" group by sex ";
rs.executeSql(sqlstr);
while( rs.next() ) {
resultcount = Util.getIntValue(rs.getString(1),0);
sex = Util.null2String(rs.getString(2));
if(resultcount==0) continue ;
if(sex.equals("0")) sexname = SystemEnv.getHtmlLabelName(28473,user.getLanguage()) ;
else if(sex.equals("1")) sexname = SystemEnv.getHtmlLabelName(28474,user.getLanguage());
else sexname = SystemEnv.getHtmlLabelName(15808,user.getLanguage());
map = new HashMap<String, String>();
map.put("title", sexname);
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
return list;
}
/*
*
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getSeniorityRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
String workage =Util.null2String(request.getParameter("agearea"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
String sqlwhere="";
String sqlwhere_0="";
if(workage.equals(""))
workage="10";
if(status.equals("")){
status = "8";
}
if(!location.equals("")&&!location.equals("0")){
sqlwhere+=" and locationid ="+location;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where locationid ="+location;
}
else{
sqlwhere_0 +=" and locationid ="+location;
}
}
if(!fromdate.equals("")&&!fromdate.equals("0")){
sqlwhere+=" and companystartdate>='"+fromdate+"'";
}
if(!enddate.equals("")&&!enddate.equals("0")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
if(!department.equals("")&&!department.equals("0")){
sqlwhere+=" and departmentid in ("+department+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where departmentid in ("+department+") ";
}
else{
sqlwhere_0 +=" and departmentid in ("+department+") ";
}
}
if(!subcompany.equals("")&&!subcompany.equals("0")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where subcompanyid1 in ("+subcompany+") ";
}
else{
sqlwhere_0 +=" and subcompanyid1 in ("+subcompany+") ";
}
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status <= 3";
}else{
sqlwhere_0 +=" and status <= 3";
}
}else{
sqlwhere+=" and status ="+status;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status ="+status;
}else{
sqlwhere_0 +=" and status ="+status;
}
}
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where "+innerResourceSql;
}else{
sqlwhere_0 +=" and "+innerResourceSql;
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
if (sqlwhere_0.equals("")){
sqlwhere_0 = " where " + detachSqlWhere;
} else {
sqlwhere_0 += " and " + detachSqlWhere;
}
}
String sqlstr="";
String sql="";
int resultcount=0;
if(sqlwhere_0.equals("")){
sql = "select count(*) from HrmResource where accounttype is null or accounttype=0 ";
}else{
sql = "select count(*) from HrmResource "+sqlwhere_0+" and (accounttype is null or accounttype=0)";
}
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);/*总人数*/
/*先算出工龄记录为空的人数*/
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and (workstartdate is null or workstartdate ='')";
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and (workstartdate is null or workstartdate ='')"+sqlwhere;
}
rs.executeSql(sqlstr);
rs.next();
resultcount = rs.getInt(1);
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(resultcount != 0){//年龄为空人数占比
map = new HashMap<String, String>();
map.put("title", SystemEnv.getHtmlLabelName(15863,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
Calendar today = Calendar.getInstance();
int tempyear = Util.getIntValue(Util.add0(today.get(Calendar.YEAR), 4));//当前年份
if(rs.getDBType().equals("oracle")){
sqlstr="select min(workstartdate) from HrmResource where (accounttype is null or accounttype=0) and workstartdate is not null ";
}else{
sqlstr="select min(workstartdate) from HrmResource where (accounttype is null or accounttype=0) and workstartdate is not null and workstartdate !=''";
}
rs.executeSql(sqlstr);
rs.next();
String minworday=rs.getString(1);//工龄最大的!即入职最早的。
if(!minworday.equals("")){
int minyear = Util.getIntValue(minworday.substring(0,4));
int yearcount = tempyear-minyear+1;//最多的年限
int worknum = Util.getIntValue(workage);
int cyc = (worknum==0?0:yearcount/worknum) +1;//循环次数
String workfrom ="";
String workto = "";
for(int i=0;i<cyc;i++){//循环列出
int from_Y= i*worknum;
int to_Y = (i+1)* worknum;
workfrom =(tempyear -worknum)+"-"+
Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ;
workto =(tempyear)+"-"+
Util.add0(today.get(Calendar.MONTH) + 1, 2) +"-"+
Util.add0(today.get(Calendar.DAY_OF_MONTH), 2) ;
if(rs.getDBType().equals("oracle")){
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and workstartdate >'"+workfrom+"' and workstartdate <='"+workto+"' and workstartdate is not null ";
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and workstartdate >'"+workfrom+"' and workstartdate <='"+workto+"' and workstartdate is not null "+sqlwhere;
}
}else{
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and workstartdate >'"+workfrom+"' and workstartdate <='"+workto+"' and workstartdate<>'' and workstartdate is not null ";
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and workstartdate >'"+workfrom+"' and workstartdate <='"+workto+"' and workstartdate<>'' and workstartdate is not null "+sqlwhere;
}
}
rs.executeSql(sqlstr);
rs.next();
resultcount = rs.getInt(1);
if(resultcount!=0){
map = new HashMap<String, String>();
map.put("title", from_Y+"-"+to_Y+" "+SystemEnv.getHtmlLabelName(445,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
tempyear -= worknum;
}
}
return list;
}
/*
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getEduRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
String sqlwhere="";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")&&!fromdate.equals("0")){
sqlwhere+=" and companystartdate>='"+fromdate+"'";
}
if(!enddate.equals("")&&!enddate.equals("0")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
if(!location.equals("")&&!location.equals("0")){
sqlwhere+=" and locationid ="+location;
}
if(!department.equals("")&&!department.equals("0")){
sqlwhere+=" and departmentid in ("+department+") ";
}
if(!subcompany.equals("")&&!subcompany.equals("0")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3";
}else{
sqlwhere+=" and status ="+status;
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "t1");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql("t1");
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sqlstr = "";
if(sqlwhere.equals("")){
sqlstr = " select 0 resultid ,count(*) resultcount from HrmResource t1 where (educationlevel <2 or educationlevel is null) and (accounttype is null or accounttype=0) union select educationlevel resultid ,count(*) resultcount from HrmResource t1 where educationlevel > 1 and (accounttype is null or accounttype=0) group by educationlevel ";
}else{
sqlstr = " select 0 resultid ,count(*) resultcount from HrmResource t1 where (educationlevel <2 or educationlevel is null) and (accounttype is null or accounttype=0) "+sqlwhere+" union select educationlevel resultid ,count(*) resultcount from HrmResource t1 where educationlevel > 1 and (accounttype is null or accounttype=0) "+sqlwhere+" group by educationlevel ";
}
RecordSet rs = new RecordSet();
rs.executeSql(sqlstr);
while(rs.next()) {
int resultcount = rs.getInt(2);
total+=resultcount;
}
rs.beforFirst();
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(total!=0){
while(rs.next()){
String resultid = rs.getString(1);
int resultcount = rs.getInt(2);
map = new HashMap<String, String>();
String title = "";
if(Util.getIntValue(resultid, 0)>0){
try {
title = Util.toScreen(new EducationLevelComInfo().getEducationLevelname(resultid),user.getLanguage());
if(title.trim().equals("")){
title = SystemEnv.getHtmlLabelName(21381, user.getLanguage());
}
} catch (Exception e) {
e.printStackTrace();
}
}else{
title = SystemEnv.getHtmlLabelName(21381, user.getLanguage());
}
map.put("title", title);
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
}
return list;
}
/*
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getWedlockRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
String sqlwhere="";
String sqlwhere_0="";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")){
sqlwhere+=" and companystartdate>='"+fromdate+"'";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where companystartdate>='"+fromdate+"'";
}
else{
sqlwhere_0 +=" and companystartdate>='"+fromdate+"'";
}
}
if(!enddate.equals("")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where (companystartdate<='"+enddate+"' or companystartdate is null)";
}
else{
sqlwhere_0 +=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
}
if(!location.equals("")){
sqlwhere+=" and locationid ="+location;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where locationid ="+location;
}
else{
sqlwhere_0 +=" and locationid ="+location;
}
}
if(!department.equals("")){
sqlwhere+=" and departmentid in ("+department+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where departmentid in ("+department+") ";
}
else{
sqlwhere_0 +=" and departmentid in ("+department+") ";
}
}
if(!subcompany.equals("")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where subcompanyid1 in ("+subcompany+") ";
}
else{
sqlwhere_0 +=" and subcompanyid1 in ("+subcompany+") ";
}
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status <= 3";
}else{
sqlwhere_0 +=" and status <= 3";
}
}else{
sqlwhere+=" and status ="+status;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status ="+status;
}else{
sqlwhere_0 +=" and status ="+status;
}
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
if (sqlwhere_0.equals("")){
sqlwhere_0 = " where " + detachSqlWhere;
} else {
sqlwhere_0 += " and " + detachSqlWhere;
}
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sqlstr="";
String sql="";
if(sqlwhere_0.equals("")){
sql = "select count(*) from HrmResource where accounttype is null or accounttype=0 ";
}else{
sql = "select count(*) from HrmResource "+sqlwhere_0+" and (accounttype is null or accounttype=0)";
}
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);
/*先算出记录为空的人数*/
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and maritalstatus is null or maritalstatus =''";
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and (maritalstatus is null or maritalstatus ='')"+sqlwhere;
}
rs.executeSql(sqlstr);
rs.next();
int resultcount = rs.getInt(1);
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(resultcount != 0){
map = new HashMap<String, String>();
map.put("title", SystemEnv.getHtmlLabelName(15863,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
if(total!=0){
for(int i=0;i<3;i++){
String maritalstatus="";
if(i==0)maritalstatus="0";
else if(i==1)maritalstatus="1";
else if(i==2)maritalstatus="2";
if(sqlwhere.equals("")){
sqlstr = "select COUNT(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and maritalstatus = '"+maritalstatus+"'" ;
}else{
sqlstr = "select COUNT(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and maritalstatus = '"+maritalstatus+"'"+sqlwhere ;
}
rs.executeSql(sqlstr);
rs.next();
resultcount = rs.getInt(1);
if(resultcount!=0){
map = new HashMap<String, String>();
map.put("title", new SplitPageTagFormat().colFormat(maritalstatus,"{cmd:array["+user.getLanguage()+";0=470,1=471,2=472]}"));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
}
}
return list;
}
/*
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getJobCallRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
@SuppressWarnings("unused")
int totalnum = 0;
String sqlwhere="";
if(!fromdate.equals("")){
sqlwhere+=" and t1.companystartdate>='"+fromdate+"'";
}
if(!enddate.equals("")){
sqlwhere+=" and (t1.companystartdate<='"+enddate+"' or t1.companystartdate is null)";
}
if(!department.equals("")){
sqlwhere+=" and t1.departmentid in ("+department+") ";
}
if(!subcompany.equals("")){
sqlwhere+=" and t1.subcompanyid1 in ("+subcompany+") ";
}
if(!location.equals("")){
sqlwhere+=" and t1.locationid ="+location;
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and t1.status <= 3";
}else{
sqlwhere+=" and t1.status ="+status;
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "t1");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql("t1");
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sql = "select count(id) from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) and 1=1"+sqlwhere;
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);
String sqlstr="";
String nullmothod = "";
if(rs.getDBType().equals("oracle"))
{
nullmothod = "nvl(t1.jobcall,0)";
}
else if(rs.getDBType().equals("db2"))
{
nullmothod = "coalesce(t1.jobcall,0)";
}else if(DialectUtil.isMySql(rs.getDBType())){
nullmothod = DbDialectFactory.get(rs.getDBType()).isNull("t1.jobcall", 0) ;
}else{
nullmothod = "ISNULL(t1.jobcall,0)";
}
if(sqlwhere.equals(""))
{
sqlstr = "select "+nullmothod+" jobcall,COUNT(distinct t1.id) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) group by t1.jobcall";
}
else
sqlstr = "select "+nullmothod+" jobcall,COUNT(distinct t1.id) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) "+sqlwhere+" group by t1.jobcall";
sqlstr = "select a.jobcall, sum(a.resultcount) resultcount from ("+sqlstr+") a group by a.jobcall";
rs.executeSql(sqlstr);
while(rs.next()) {
int resultcount = rs.getInt(2);
totalnum+=resultcount;
}
rs.beforFirst();
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(total!=0){
while(rs.next()){
String resultid = rs.getString(1);
int resultcount = rs.getInt(2);
map = new HashMap<String, String>();
String title = "";
if("0".equals(resultid)){
title = SystemEnv.getHtmlLabelName(15863,user.getLanguage());
}else{
try {
title = Util.toScreen(new JobCallComInfo().getJobCallname(resultid),user.getLanguage());
} catch (Exception e) {
e.printStackTrace();
}
}
map.put("title", title);
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
}
return list;
}
/**
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getJobLevelRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
String area =Util.null2String(request.getParameter("agearea"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int linecolor=0;
int total=0;
String sqlwhere="";
String sqlwhere_0="";
if(area.equals(""))
area="5";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")){
sqlwhere+=" and companystartdate>='"+fromdate+"'";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where companystartdate>='"+fromdate+"'";
}
else{
sqlwhere_0 +=" and companystartdate>='"+fromdate+"'";
}
}
if(!enddate.equals("")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where (companystartdate<='"+enddate+"' or companystartdate is null)";
}
else{
sqlwhere_0 +=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
}
if(!location.equals("")){
sqlwhere+=" and locationid ="+location;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where locationid ="+location;
}
else{
sqlwhere_0 +=" and locationid ="+location;
}
}
if(!department.equals("")){
sqlwhere+=" and departmentid in ("+department+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where departmentid in ("+department+") ";
}
else{
sqlwhere_0 +=" and departmentid in ("+department+") ";
}
}
if(!subcompany.equals("")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where subcompanyid1 in ("+subcompany+") ";
}
else{
sqlwhere_0 +=" and subcompanyid1 in ("+subcompany+") ";
}
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status <= 3";
}else{
sqlwhere_0 +=" and status <= 3";
}
}else{
sqlwhere+=" and status ="+status;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status ="+status;
}else{
sqlwhere_0 +=" and status ="+status;
}
}
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where "+innerResourceSql;
}else{
sqlwhere_0 +=" and "+innerResourceSql;
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
if (sqlwhere_0.equals("")){
sqlwhere_0 = " where " + detachSqlWhere;
} else {
sqlwhere_0 += " and " + detachSqlWhere;
}
}
String sqlstr="";
String sql="";
int resultcount=0;
if(sqlwhere_0.equals("")){
sql = "select count(*) from HrmResource where accounttype is null or accounttype=0 ";
}else{
sql = "select count(*) from HrmResource "+sqlwhere_0+" and (accounttype is null or accounttype=0)";
}
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);/*总人数*/
/*先算出职级为0的人数*/
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (joblevel = 0 or joblevel is null) and (accounttype is null or accounttype=0)";
}else{
sqlstr="select count(*) resultcount from HrmResource where (joblevel = 0 or joblevel is null) and (accounttype is null or accounttype=0) "+sqlwhere;
}
rs.executeSql(sqlstr);
rs.next();
resultcount = rs.getInt(1);
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(resultcount != 0){//年龄为空人数占比
map = new HashMap<String, String>();
map.put("title", "0 "+SystemEnv.getHtmlLabelName(15872,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
sqlstr="select max(joblevel) from HrmResource where joblevel>0";
rs.executeSql(sqlstr);
rs.next();
int levelmax=rs.getInt(1);//职级最大
int levelnum = Util.getIntValue(area);
int cyc = (levelnum==0?0:levelmax/levelnum) +1;//循环次数
linecolor=1;
for(int i=0;i<cyc;i++){//循环列出
int from_L= i*levelnum+1;
int to_L = (i+1)* levelnum;
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and joblevel >="+from_L+" and joblevel <="+to_L;
}else{
sqlstr="select count(*) resultcount from HrmResource where (accounttype is null or accounttype=0) and joblevel >="+from_L+" and joblevel <="+to_L+sqlwhere;
}
rs.executeSql(sqlstr);
rs.next();
resultcount = rs.getInt(1);
if(resultcount!=0){
map = new HashMap<String, String>();
String title = levelnum==1?(from_L+" "+SystemEnv.getHtmlLabelName(15872,user.getLanguage())):(from_L+"-"+to_L+" "+SystemEnv.getHtmlLabelName(15872,user.getLanguage()));
map.put("title", title);
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
if(linecolor==0) linecolor=1;
else linecolor=0;
}
return list;
}
/*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getJobActivityRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
@SuppressWarnings("unused")
int totalnum = 0;
String sqlwhere="";
if(!fromdate.equals("")){
sqlwhere+=" and t1.companystartdate>='"+fromdate+"'";
}
if(!enddate.equals("")){
sqlwhere+=" and (t1.companystartdate<='"+enddate+"' or t1.companystartdate is null)";
}
if(!department.equals("")){
sqlwhere+=" and departmentid in ("+department+") ";
}
if(!subcompany.equals("")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
}
if(!location.equals("")){
sqlwhere+=" and t1.locationid ="+location;
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and t1.status <= 3";
}else{
sqlwhere+=" and t1.status ="+status;
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "t1");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql("t1");
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sql = "select count(id) from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) and 1=1"+sqlwhere;
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);
String sqlstr="";
if(sqlwhere.equals("")){
sqlstr = "select t3.id resultid,COUNT(t1.id) resultcount from HrmResource t1,HrmJobTitles t2,HrmJobActivities t3 where (t1.accounttype is null or t1.accounttype=0) and t1.jobtitle=t2.id and t2.jobactivityid = t3.id group by t3.id order by resultcount";
}
else
sqlstr = "select t3.id resultid,COUNT(t1.id) resultcount from HrmResource t1,HrmJobTitles t2, HrmJobActivities t3 where (t1.accounttype is null or t1.accounttype=0) and t1.jobtitle=t2.id and t2.jobactivityid = t3.id "+sqlwhere+" group by t3.id order by resultcount";
rs.executeSql(sqlstr);
while(rs.next()) {
int resultcount = rs.getInt(2);
totalnum+=resultcount;
}
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
rs.first();
if(total!=0){
do{
String resultid = rs.getString(1);
int resultcount = rs.getInt(2);
map = new HashMap<String, String>();
String title = "";
try {
JobActivitiesComInfo obj = new JobActivitiesComInfo();
title = Util.toScreen(obj.getJobActivitiesmarks(resultid),user.getLanguage());
} catch (Exception e) {
e.printStackTrace();
}
map.put("title", title);
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}while(rs.next());
}
return list;
}
/*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getJobGroupRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
//System.out.println("《》《》》》《》《》《》《》《》《》《"+fromdate+" A "+enddate+" B "+location+" C "+status+" D "+ department+" SUB " +subcompany);
int total=0;
@SuppressWarnings("unused")
int totalnum = 0;
String sqlwhere="";
if(!fromdate.equals("")){
sqlwhere+=" and t1.companystartdate>='"+fromdate+"'";
}
if(!enddate.equals("")){
sqlwhere+=" and (t1.companystartdate<='"+enddate+"' or t1.companystartdate is null)";
}
if(!department.equals("")){
sqlwhere+=" and departmentid in ("+department+") ";
}
if(!subcompany.equals("")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
}
if(!location.equals("")){
sqlwhere+=" and t1.locationid ="+location;
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and t1.status <= 3";
}else{
sqlwhere+=" and t1.status ="+status;
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "t1");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql("t1");
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sql = "select count(id) from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) and 1=1"+sqlwhere;
RecordSet rs = new RecordSet();
//System.out.println("++++++++++++++++++++++Sql1 "+sql );
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);
String sqlstr="";
if(sqlwhere.equals("")){
sqlstr = "select t4.id resultid,COUNT(t1.id) resultcount from HrmResource t1,HrmJobTitles t2,HrmJobActivities t3,HrmJobGroups t4 where (t1.accounttype is null or t1.accounttype=0) and t1.jobtitle=t2.id and t2.jobactivityid = t3.id and t3.jobgroupid = t4.id group by t4.id order by resultcount";
}
else
sqlstr = "select t4.id resultid,COUNT(t1.id) resultcount from HrmResource t1,HrmJobTitles t2, HrmJobActivities t3,HrmJobGroups t4 where (t1.accounttype is null or t1.accounttype=0) and t1.jobtitle=t2.id and t2.jobactivityid = t3.id and t3.jobgroupid = t4.id "+sqlwhere+" group by t4.id order by resultcount";
//System.out.println("++++++++++++++++++++++SqlStr1 "+sqlstr );
rs.executeSql(sqlstr);
while(rs.next()) {
int resultcount = rs.getInt(2);
totalnum+=resultcount;
}
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
rs.first();
if(total!=0){
do{
String resultid = rs.getString(1);
int resultcount = rs.getInt(2);
map = new HashMap<String, String>();
String title = "";
try {
JobGroupsComInfo obj = new JobGroupsComInfo();
title += Util.toScreen(obj.getJobGroupsname(resultid),user.getLanguage());
} catch (Exception e) {
e.printStackTrace();
}
map.put("title", title);
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
//writeLog("》》》》》》》》》》》》"+total);
list.add(map);
}while(rs.next());
}
return list;
}
/**
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getUserKindRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
String sqlwhere="";
String sqlwhere_0="";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")){
sqlwhere+=" and t1.companystartdate>='"+fromdate+"'";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where companystartdate>='"+fromdate+"'";
}
else{
sqlwhere_0 +=" and companystartdate>='"+fromdate+"'";
}
}
if(!enddate.equals("")){
sqlwhere+=" and (t1.companystartdate<='"+enddate+"' or t1.companystartdate is null)";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where (companystartdate<='"+enddate+"' or companystartdate is null)";
}
else{
sqlwhere_0 +=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
}
if(!location.equals("")){
sqlwhere+=" and t1.locationid ="+location;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where locationid ="+location;
}
else{
sqlwhere_0 +=" and locationid ="+location;
}
}
if(!department.equals("")){
sqlwhere+=" and t1.departmentid in ("+department+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where departmentid in ("+department+") ";
}
else{
sqlwhere_0 +=" and departmentid in ("+department+") ";
}
}
if(!subcompany.equals("")){
sqlwhere+=" and t1.subcompanyid1 in ("+subcompany+") ";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where subcompanyid1 in ("+subcompany+") ";
}
else{
sqlwhere_0 +=" and subcompanyid1 in ("+subcompany+") ";
}
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and t1.status <= 3";
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status <= 3";
}else{
sqlwhere_0 +=" and status <= 3";
}
}else{
sqlwhere+=" and t1.status ="+status;
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where status ="+status;
}else{
sqlwhere_0 +=" and status ="+status;
}
}
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql("t1");
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
innerResourceSql = AppDetachComInfo.getInnerResourceSql();
if(sqlwhere_0.equals("")){
sqlwhere_0 =" where "+innerResourceSql;
}else{
sqlwhere_0 +=" and "+innerResourceSql;
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "t1");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (sqlwhere_0.equals("")){
sqlwhere_0 = " where " + detachSqlWhere;
} else {
sqlwhere_0 += " and " + detachSqlWhere;
}
}
String sqlstr="";
String sql="";
if(sqlwhere_0.equals("")){
sql = "select count(*) from HrmResource where accounttype is null or accounttype=0 ";
}else{
sql = "select count(*) from HrmResource "+sqlwhere_0+" and (accounttype is null or accounttype=0)";
}
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);
/*先算出记录为空的人数*/
if(sqlwhere.equals("")){
sqlstr="select count(*) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) and t1.usekind is null or t1.usekind ='' or t1.usekind='0'";
}else{
sqlstr="select count(*) resultcount from HrmResource t1 where (t1.accounttype is null or t1.accounttype=0) and (t1.usekind is null or t1.usekind ='' or t1.usekind='0')"+sqlwhere;
}
rs.executeSql(sqlstr);
rs.next();
int resultcount = rs.getInt(1);
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(resultcount != 0){
map = new HashMap<String, String>();
map.put("title", SystemEnv.getHtmlLabelName(15863,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
if(total!=0){
if(sqlwhere.equals("")){
sqlstr = "select COUNT(*) resultcount,t2.id usekindid from HrmResource t1 ,HrmUseKind t2 where (t1.accounttype is null or t1.accounttype=0) and t1.usekind = t2.id group by t2.id order by t2.id " ;
}else{
sqlstr = "select COUNT(*) resultcount,t2.id usekindid from HrmResource t1 ,HrmUseKind t2 where (t1.accounttype is null or t1.accounttype=0) and t1.usekind = t2.id "+sqlwhere+" group by t2.id order by t2.id " ;
}
rs.executeSql(sqlstr);
while(rs.next()){
resultcount = rs.getInt(1);
String resultid= rs.getString(2);
if(resultcount!=0){
map = new HashMap<String, String>();
String title = "";
try {
title = Util.toScreen(new UseKindComInfo().getUseKindname(resultid),user.getLanguage());
} catch (Exception e) {
e.printStackTrace();
}
map.put("title", title);
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
writeLog(">>>>>>>>>>>" + total);
list.add(map);
}
}
}
return list;
}
@SuppressWarnings("deprecation")
public List<Map<String,String>> getStatusRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
String sqlwhere="";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")){
sqlwhere+=" and companystartdate>='"+fromdate+"'";
}
if(!enddate.equals("")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
if(!location.equals("")){
sqlwhere+=" and locationid ="+location;
}
if(!subcompany.equals("")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
}
if(!department.equals("")){
sqlwhere+=" and departmentid in ("+department+") ";
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3";
}else{
sqlwhere+=" and status ="+status;
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sql = "select count(*) from HrmResource where (accounttype is null or accounttype=0) and status is not null "+sqlwhere;
RecordSet rs = new RecordSet();
rs.executeSql(sql);
int total = rs.next() ? rs.getInt(1) : 0;
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
sql = "select status,count(id) resultcount from HrmResource where (accounttype is null or accounttype=0) and status is not null ";
if(!sqlwhere.equals("")){
sql += sqlwhere;
}
sql += " group by status";
rs.executeSql(sql);
if(total!=0){
while(rs.next()){
String tempStatus = StringUtil.vString(rs.getString(1));
int resultcount = rs.getInt(2);
map = new HashMap<String, String>();
map.put("title", new SplitPageTagFormat().colFormat(tempStatus,"{cmd:array["+user.getLanguage()+";0=15710,1=15711,2=480,3=15844,4=6094,5=6091,6=6092,7=2245,8=1831,9=332]}"));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
}
return list;
}
/*
*
*
*/
@SuppressWarnings("deprecation")
public List<Map<String,String>> getSecLevelRpResult(HttpServletRequest request, HttpServletResponse response) {
User user = HrmUserVarify.getUser(request, response);
String fromdate = Util.null2String(request.getParameter("fromdate"));
String enddate = Util.null2String(request.getParameter("enddate"));
String department =Util.null2String(request.getParameter("departmentid"));
String subcompany =Util.null2String(request.getParameter("subcompanyid"));
String location =Util.null2String(request.getParameter("location"));
String status =Util.null2String(request.getParameter("workstatus"));
HrmReportDetachUtil hrmReportDetachUtil = new HrmReportDetachUtil();
String startdateselect =Util.fromScreen(request.getParameter("dateselect"),user.getLanguage());
if(!startdateselect.equals("") && !startdateselect.equals("0")&& !startdateselect.equals("6")){
fromdate = TimeUtil.getDateByOption(startdateselect,"0");
enddate = TimeUtil.getDateByOption(startdateselect,"1");
}
int total=0;
String sqlwhere="";
if(status.equals("")){
status = "8";
}
if(!fromdate.equals("")){
sqlwhere+=" and companystartdate>='"+fromdate+"'";
}
if(!enddate.equals("")){
sqlwhere+=" and (companystartdate<='"+enddate+"' or companystartdate is null)";
}
if(!location.equals("")){
sqlwhere+=" and locationid ="+location;
}
if(!department.equals("")){
sqlwhere+=" and departmentid in ("+department+") ";
}
if(!subcompany.equals("")){
sqlwhere+=" and subcompanyid1 in ("+subcompany+") ";
}
if(!(status.equals("")||status.equals("9"))){
if(status.equals("8")){
sqlwhere+=" and status <= 3";
}else{
sqlwhere+=" and status ="+status;
}
}
String detachSqlWhere = hrmReportDetachUtil.getDetachSqlWhere(user.getUID(), "hrmresource");
if (StringUtils.isNotBlank(detachSqlWhere)){
sqlwhere += " and " + detachSqlWhere;
}
String innerResourceSql = AppDetachComInfo.getInnerResourceSql();
//只查询行政纬度人员
sqlwhere += " and "+innerResourceSql;
String sqlstr="";
String sql="";
if(sqlwhere.equals("")){
sql = "select count(*) from HrmResource where seclevel is not null";
}else{
sql = "select count(*) from HrmResource where seclevel is not null"+sqlwhere;
}
RecordSet rs = new RecordSet();
rs.executeSql(sql);
rs.next();
total = rs.getInt(1);
List<Map<String,String>> list = new ArrayList<Map<String,String>>();
Map<String, String> map = null;
if(total!=0){
if(sqlwhere.equals("")){
sqlstr = "select COUNT(*) resultcount,seclevel from HrmResource where seclevel is not null group by seclevel order by seclevel";
}else{
sqlstr = "select COUNT(*) resultcount,seclevel from HrmResource where seclevel is not null "+sqlwhere+" group by seclevel order by seclevel" ;
}
rs.executeSql(sqlstr);
rs.first();
do{
int resultcount = rs.getInt(1);
String resultid = rs.getString(2);
if(resultcount != 0){
map = new HashMap<String, String>();
map.put("title", resultid+" "+SystemEnv.getHtmlLabelName(15872,user.getLanguage()));
map.put("result", String.valueOf(resultcount));
map.put("percent", StringUtil.formatDoubleValue(String.valueOf(resultcount), String.valueOf(total)));
map.put("total", String.valueOf(total));
list.add(map);
}
}while(rs.next());
}
return list;
}
}