diff --git a/interface/mingfeng/cs/getCompanyAnniversary.jsp b/interface/mingfeng/cs/getCompanyAnniversary.jsp new file mode 100644 index 0000000..0cccd60 --- /dev/null +++ b/interface/mingfeng/cs/getCompanyAnniversary.jsp @@ -0,0 +1,373 @@ +<%@ page import="weaver.general.*" %> +<%@page import="weaver.conn.RecordSet"%> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.text.SimpleDateFormat" %> +<%@ page import="java.util.*" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="weaver.formmode.setup.ModeRightInfo" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.Period" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> + +<% + List> dataList = new ArrayList>(); + Map data_Map = null; + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + SimpleDateFormat sdf = new SimpleDateFormat("MM-dd" ) ; + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ; + SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd") ; + int days = 30 ; + String workflowid = "838"; + String formtable = "" ; + String sql = "select abs(formid) as formid from workflow_base where id = "+workflowid ; + rs.executeQuery(sql); + if(rs.next()){ + String formid = Util.null2String(rs.getString("formid")); + if(StringUtils.isNotBlank(formid)){ + formtable = "formtable_main_"+formid ; + } + } + + String where = "" ; + if(StringUtils.isNotBlank(formtable)){ + where = " and h.id not in(select k.lzyg \n" + + " from workflow_requestbase p\n" + + " inner join "+formtable+" k on k.requestid = p.requestid\n" + + " where workflowid = "+workflowid+"\n" + + " and p.currentnodetype = 3 ) "; + } + + for(int i=0;i"); + if(yearsDiff > 0){ + String userid = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String sex = Util.null2String(rs.getString("sex")); + String departmentname = Util.null2String(rs.getString("departmentname")); + String subcompanyname = Util.null2String(rs.getString("subcompanyname")); +// String zn = Util.null2String(rs.getString("zn")); + String departmentid = Util.null2String(rs.getString("departmentid")); + String jobtitlename = Util.null2String(rs.getString("jobtitlename")); + + String deptnamenew = "" ; + data_Map = new HashMap(); + data_Map.put("userid",userid); + data_Map.put("sex",sex); + data_Map.put("jobtitlename",jobtitlename); + data_Map.put("lastname",lastname); + data_Map.put("departmentname",departmentname); + data_Map.put("subcompanyname",subcompanyname); + if(StringUtils.isNotBlank(departmentid)){ + deptnamenew = getTopDepartment(departmentid); + } + if(StringUtils.isBlank(deptnamenew)){ + deptnamenew = departmentname ; + } + data_Map.put("deptnamenew",deptnamenew); + data_Map.put("zn",yearsDiff+""); + data_Map.put("nf",currentYear); + dataList.add(data_Map); + } + } + } + } + + + + String modeid = "" ; + String formid = "" ; + String uftable = "uf_rzznzfgly"; + sql =" select k.id,k.formid from modeinfo k \n" + + " inner join workflow_bill l on formid = l.id\n" + + " where l.tablename = '"+uftable+"' " ; + rs.execute(sql); + if(rs.next()){ + modeid = Util.null2String(rs.getString("id")); + formid = Util.null2String(rs.getString("formid")); + } + + for(int i=0;i dMap = dataList.get(i); + String nf = dMap.get("nf"); + String ry = dMap.get("userid"); + int rzzn = Util.getIntValue(dMap.get("zn")); + + if(StringUtils.isNotBlank(ry) && StringUtils.isNotBlank(nf)){ + + sql = " select id from "+uftable+" where ry='"+ry+"' and nf ='"+nf+"'"; + rs.executeQuery(sql); + if(rs.next()){ + billid = Util.null2String(rs.getString("id")); + } + if(StringUtils.isBlank(billid)){ + billid = updateAnniversaryWishes(ry,modeid,nf,rzzn); + } + } + + dMap.put("billid",billid); + dMap.put("modeid",modeid); + dMap.put("formid",formid); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",dataList); + +%> +<%=jsonObject.toString() %> + + +<%! + + public String getTopDepartment(String departmentid){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + String departmentname = "" ; + if(StringUtils.isNotBlank(departmentid)){ + String sql = " with tem_table(department_id,department_name,supdep_id,curlevel) as (\n" + + " select id,departmentname,supdepid, 1 as level \n" + + " from HrmDepartment where id = " + departmentid+ + " union all \n" + + " select a.id,a.departmentname,a.supdepid, b.curlevel+1 \n" + + " from HrmDepartment a \n" + + " inner join tem_table b on (a.id = b.supdep_id)\n" + + " ) \n" + + " select * from tem_table "; + + bb.writeLog("sql:"+sql); + rs.executeQuery(sql); + while (rs.next()){ + String department_id = Util.null2String(rs.getString("department_id")); + String department_name = Util.null2String(rs.getString("department_name")); + String supdep_id = Util.null2String(rs.getString("supdep_id")); + if(StringUtils.isBlank(supdep_id) || "0".equals(supdep_id)){ + departmentname = department_name ; + } + } + } + bb.writeLog("departmentname:"+departmentname); + + return departmentname; + } + + + + public String updateAnniversaryWishes(String user_id,String modeid,String currentYear,int rzzn){ + + String billid = "" ; + BaseBean log = new BaseBean(); + log.writeLog("updateAnniversaryWishes! "); + + String uftable = "uf_rzznzfgly"; + RecordSet rs = new RecordSet(); + + BaseBean bb = new BaseBean(); + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ; + + try{ + Map dataMap = new HashMap(); + + bb.writeLog("currentYear:"+currentYear); + + String sql =" select k.* from (" + + " select h.id,h.lastname,h.sex,h.companystartdate,h.departmentid,h.subcompanyid1," + + " right(companystartdate,5) startday " + + " from hrmresource h " + + " where h.id = "+user_id+" " + + " and h.status in(0,1,2,3) " + + " and (h.belongto is null or h.belongto = -1 ) " + + " and h.companystartdate is not null " + + " ) k " + + " order by k.startday desc " ; + + bb.writeLog("updateAnniversaryWishes-sql:"+sql); + + rs.executeQuery(sql); + if (rs.next()){ + String userid = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); +// int rzzn = Util.getIntValue(Util.null2String(rs.getString("rzzn")),0); + String subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); + String departmentid = Util.null2String(rs.getString("departmentid")); + String companystartdate = Util.null2String(rs.getString("companystartdate")); + String zfy = getZfy(lastname,rzzn); + String rzyr = Util.null2String(rs.getString("startday")); + + dataMap = new HashMap(); + dataMap.put("ry",userid); + dataMap.put("xm",lastname); + dataMap.put("zfy",zfy); + dataMap.put("bm",departmentid); + dataMap.put("rzrq",companystartdate); + dataMap.put("fb",subcompanyid1); + dataMap.put("nf",currentYear); + dataMap.put("rzzn",rzzn+""); + dataMap.put("rzyr",rzyr); + + } + + if(!dataMap.isEmpty()){ + String ry = dataMap.get("ry"); + String nf = dataMap.get("nf"); + sql = " select id from "+uftable+" where ry='"+ry+"' and nf = '"+nf+"'"; + rs.executeQuery(sql); + if(rs.next()){ + billid = Util.null2String(rs.getString("id")); + } + if(StringUtils.isBlank(billid)){ + billid = updateWishesInfo(uftable,dataMap,modeid); + } + } + }catch (Exception e){ + + } + return billid; + } + + + public String updateWishesInfo(String fromtable,Map datas,String formmodeid){ + RecordSet rs = new RecordSet(); + String dataid = "" ; + BaseBean bb = new BaseBean(); + ModeRightInfo modeRightInfo = new ModeRightInfo(); + String uuid = UUID.randomUUID().toString().replace("-",""); + bb.writeLog("uuid:"+uuid); + + SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat formatter2 = new SimpleDateFormat("HH:mm:ss"); + String currentdate = formatter1.format(new Date()); + String currenttime = formatter2.format(new Date()); + String modedatacreater = "1"; + String modedatacreatertype = "0"; + + bb.writeLog("formmodeid:"+formmodeid); + datas.put("formmodeid", formmodeid); + datas.put("modedatacreater", modedatacreater); + datas.put("modedatacreatertype", modedatacreatertype); + datas.put("modedatacreatedate", currentdate); + datas.put("modedatacreatetime", currenttime); + datas.put("uuid", uuid); + + String tablenvalue = ""; + String tablename = ""; + for (Map.Entry entry : datas.entrySet()) { + String fieldname = Util.null2String(entry.getKey()).trim(); + String fieldvalue = Util.null2String(entry.getValue()).replace("'", "''").trim(); + tablename += tablename == "" ? fieldname : "," + fieldname; + tablenvalue += tablenvalue == "" ? "'" + fieldvalue + "'" : ",'" + fieldvalue + "'"; + } + if (tablename != "" && tablenvalue != "") { + int count = 0; + String sql = " insert into " + fromtable + "(" + tablename + ") values (" + tablenvalue + ")"; + bb.writeLog("sql:" + sql); + boolean boo = rs.executeUpdate(sql); + if (boo) { + count++; + } + bb.writeLog("count:" + count); + if (count > 0) { + sql = " select id from " + fromtable + " where uuid='" + uuid + "'"; + bb.writeLog("sql:" + sql); + rs.execute(sql); + if (rs.next()) { + dataid = Util.null2String(rs.getString("id")); + } + if (!"".equals(dataid)) { + modeRightInfo.editModeDataShare(Integer.valueOf(modedatacreater), Util.getIntValue(formmodeid), Integer.parseInt(dataid)); + } + } + } + return dataid; + } + + public static String convert(int number) { + if (number <= 0) { + return ""; + } + //数字对应的汉字 + String[] num = {"一", "二", "三", "四", "五", "六", "七", "八", "九"}; + //单位 + String[] unit = {"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千", "万亿"}; + //将输入数字转换为字符串 + String result = String.valueOf(number); + //将该字符串分割为数组存放 + char[] ch = result.toCharArray(); + //结果 字符串 + String str = ""; + int length = ch.length; + for (int i = 0; i < length; i++) { + int c = (int) ch[i] - 48; + if (c != 0) { + str += num[c - 1] + unit[length - i - 1]; + } + } + if (number < 20 && number > 9) { + str = str.substring(1); + } +// System.out.println(str); + return str ; + } + + + public String getZfy(String lastname,int rzzn){ + String rzzzdx = "" ; + if(rzzn > 0){ + rzzzdx = convert(rzzn); + } + String zfy ="
\n" + + "

亲爱的"+lastname+"

\n" + + "

 

\n" + + "

衷心祝贺您与铭沣同行"+rzzzdx+"周年快乐!

\n" + + "

感谢您将自己的青春年华和工作热情奉献给了铭沣!

\n" + + "

感谢您辛勤的付出与不懈的跟随与守候,期待我们一起度过下一个周年!

\n" + + "

今天的您是否忙碌在工作岗位上而忽略了这个重要的日子......

\n" + + "

但公司记得您每一份付出和努力!

\n" + + "

感谢您的一路相伴,未来我们继续同行!

\n" + + "

 

\n" + + "

 

\n" + + "

 MATFRON

\n" + + "
"; + return zfy; + } + +%> + + + + diff --git a/interface/mingfeng/cs/getCompanyAnniversary2.jsp b/interface/mingfeng/cs/getCompanyAnniversary2.jsp new file mode 100644 index 0000000..5e6836f --- /dev/null +++ b/interface/mingfeng/cs/getCompanyAnniversary2.jsp @@ -0,0 +1,450 @@ +<%@ page import="weaver.general.*" %> +<%@page import="weaver.conn.RecordSet"%> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.text.SimpleDateFormat" %> +<%@ page import="java.util.*" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> +<%@ page import="weaver.formmode.setup.ModeRightInfo" %> +<%@ page import="java.time.LocalDate" %> +<%@ page import="java.time.Period" %> +<%@ page language="java" contentType="text/html; charset=UTF-8" %> + +<% + List> dataList = new ArrayList>(); + Map data_Map = null; + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + SimpleDateFormat sdf = new SimpleDateFormat("MM-dd" ) ; + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ; + SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd" ) ; + int days = 30 ; + + String workflowid = "838"; + out.println("workflowid:"+workflowid+"
"); + String formtable = "" ; + String sql = "select abs(formid) as formid from workflow_base where id = "+workflowid ; + rs.executeQuery(sql); + if(rs.next()){ + String formid = Util.null2String(rs.getString("formid")); + if(StringUtils.isNotBlank(formid)){ + formtable = "formtable_main_"+formid ; + } + } + out.println("formtable:"+formtable+"
"); + String where = "" ; + if(StringUtils.isNotBlank(formtable)){ + where = " and h.id not in(select k.lzyg \n" + + " from workflow_requestbase p\n" + + " inner join "+formtable+" k on k.requestid = p.requestid\n" + + " where workflowid = "+workflowid+"\n" + + " and p.currentnodetype = 3 ) "; + } + out.println("where:"+where+"
"); + +// for(int i=0;i"); +// String currentYear = sdf2.format(calendar.getTime()) ; +// out.println("currentYear:"+currentYear+"
"); +// +// String enddate = sdf3.format(calendar.getTime()) ; +// out.println("enddate:"+enddate+"
"); +// +// sql = " select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," + +// " h.companystartdate,convert(varchar(50), getdate(), 23) as enddate," + +// " (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))-1) as zn" + +// " from hrmresource h\n" + +// " inner join HrmDepartment d on d.id = h.departmentid\n" + +// " inner join HrmSubCompany s on s.id = h.subcompanyid1\n" + +// " left join HrmJobTitles k on k.id = h.jobtitle\n" + +// " where right(h.companystartdate,5) = '"+currentDay+"'\n" + +// " and h.status in(0,1,2,3)" + +// " and (h.belongto is null or h.belongto = -1 ) " + where + +// " and h.companystartdate is not null " + +// " ) k " ; +// +// out.println("getCompanyAnniversary-sql:"+sql+"
"); +// rs.executeQuery(sql); +// while (rs.next()){ +// +// String companystartdate = Util.null2String(rs.getString("companystartdate")); +// +// if(StringUtils.isNotBlank(companystartdate) && StringUtils.isNotBlank(enddate)){ +// LocalDate date1 = LocalDate.parse(companystartdate); +// LocalDate date2 = LocalDate.parse(enddate); +// +// Period period = Period.between(date1, date2); +// int yearsDiff = period.getYears(); // 获取年数差距 +// out.println("yearsDiff:"+yearsDiff+"
"); +// if(yearsDiff > 0){ +// String userid = Util.null2String(rs.getString("id")); +// String lastname = Util.null2String(rs.getString("lastname")); +// String sex = Util.null2String(rs.getString("sex")); +// String departmentname = Util.null2String(rs.getString("departmentname")); +// String subcompanyname = Util.null2String(rs.getString("subcompanyname")); +// String departmentid = Util.null2String(rs.getString("departmentid")); +// String jobtitlename = Util.null2String(rs.getString("jobtitlename")); +// +// String deptnamenew = "" ; +// data_Map = new HashMap(); +// data_Map.put("userid",userid); +// data_Map.put("sex",sex); +// data_Map.put("jobtitlename",jobtitlename); +// data_Map.put("lastname",lastname); +// data_Map.put("departmentname",departmentname); +// data_Map.put("subcompanyname",subcompanyname); +// if(StringUtils.isNotBlank(departmentid)){ +// deptnamenew = getTopDepartment(departmentid); +// } +// if(StringUtils.isBlank(deptnamenew)){ +// deptnamenew = departmentname ; +// } +// data_Map.put("deptnamenew",deptnamenew); +// data_Map.put("zn",yearsDiff+""); +// data_Map.put("nf",currentYear); +// dataList.add(data_Map); +// } +// } +// } +// } +// +// out.println("dataList2:"+dataList.size()+"
"); + + for(int i=0;i"); + String currentYear = sdf2.format(calendar.getTime()) ; + out.println("currentYear:"+currentYear+"
"); + + String enddate = sdf3.format(calendar.getTime()) ; + out.println("enddate2:"+enddate+"
"); + + sql =" select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," + + " h.companystartdate,convert(varchar(50), getdate(), 23) as enddate," + + " (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))-1) as zn" + + " from hrmresource h\n" + + " inner join HrmDepartment d on d.id = h.departmentid\n" + + " inner join HrmSubCompany s on s.id = h.subcompanyid1\n" + + " left join HrmJobTitles k on k.id = h.jobtitle\n" + + " where right(h.companystartdate,5) = '"+currentDay+"'\n" + + " and h.status in(0,1,2,3)" + + " and (h.belongto is null or h.belongto = -1 ) " + where + + " and h.companystartdate is not null " + + " ) k " ; + + out.println("getCompanyAnniversary-sql:"+sql+"
"); + rs.executeQuery(sql); + while (rs.next()){ + + String companystartdate = Util.null2String(rs.getString("companystartdate")); + + if(StringUtils.isNotBlank(companystartdate) && StringUtils.isNotBlank(enddate)){ + LocalDate date1 = LocalDate.parse(companystartdate); + LocalDate date2 = LocalDate.parse(enddate); + + Period period = Period.between(date1, date2); + int yearsDiff = period.getYears(); // 获取年数差距 + out.println("yearsDiff:"+yearsDiff); + if(yearsDiff > 0){ + String userid = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String sex = Util.null2String(rs.getString("sex")); + String departmentname = Util.null2String(rs.getString("departmentname")); + String subcompanyname = Util.null2String(rs.getString("subcompanyname")); + String departmentid = Util.null2String(rs.getString("departmentid")); + String jobtitlename = Util.null2String(rs.getString("jobtitlename")); + + String deptnamenew = "" ; + data_Map = new HashMap(); + data_Map.put("userid",userid); + data_Map.put("sex",sex); + data_Map.put("jobtitlename",jobtitlename); + data_Map.put("lastname",lastname); + data_Map.put("departmentname",departmentname); + data_Map.put("subcompanyname",subcompanyname); + if(StringUtils.isNotBlank(departmentid)){ + deptnamenew = getTopDepartment(departmentid); + } + if(StringUtils.isBlank(deptnamenew)){ + deptnamenew = departmentname ; + } + data_Map.put("deptnamenew",deptnamenew); + data_Map.put("zn",yearsDiff+""); + data_Map.put("nf",currentYear); + dataList.add(data_Map); + } + } + } + } + + out.println("dataList2:"+dataList.size()+"
"); + + String modeid = "" ; + String formid = "" ; + String uftable = "uf_rzznzfgly"; + sql =" select k.id,k.formid from modeinfo k \n" + + " inner join workflow_bill l on formid = l.id\n" + + " where l.tablename = '"+uftable+"' " ; + rs.execute(sql); + if(rs.next()){ + modeid = Util.null2String(rs.getString("id")); + formid = Util.null2String(rs.getString("formid")); + } + + for(int i=0;i dMap = dataList.get(i); + String nf = dMap.get("nf"); + String ry = dMap.get("userid"); + int rzzn = Util.getIntValue(dMap.get("rzzn")); + out.println("rzzn:"+rzzn+"
"); + + if(StringUtils.isNotBlank(ry) && StringUtils.isNotBlank(nf)){ + + sql = " select id from "+uftable+" where ry='"+ry+"' and nf ='"+nf+"'"; + rs.executeQuery(sql); + if(rs.next()){ + billid = Util.null2String(rs.getString("id")); + } + + out.println("billid:"+billid+"
"); + if(StringUtils.isBlank(billid)){ + billid = updateAnniversaryWishes(ry,modeid,nf,rzzn); + } + out.println("billid2:"+billid+"
"); + } + + dMap.put("billid",billid); + dMap.put("modeid",modeid); + dMap.put("formid",formid); + } + JSONObject jsonObject = new JSONObject(); + jsonObject.put("data",dataList); + +%> +<%=jsonObject.toString() %> + + +<%! + + public String getTopDepartment(String departmentid){ + RecordSet rs = new RecordSet(); + BaseBean bb = new BaseBean(); + String departmentname = "" ; + if(StringUtils.isNotBlank(departmentid)){ + String sql = " with tem_table(department_id,department_name,supdep_id,curlevel) as (\n" + + " select id,departmentname,supdepid, 1 as level \n" + + " from HrmDepartment where id = " + departmentid+ + " union all \n" + + " select a.id,a.departmentname,a.supdepid, b.curlevel+1 \n" + + " from HrmDepartment a \n" + + " inner join tem_table b on (a.id = b.supdep_id)\n" + + " ) \n" + + " select * from tem_table "; + + bb.writeLog("sql:"+sql); + rs.executeQuery(sql); + while (rs.next()){ + String department_id = Util.null2String(rs.getString("department_id")); + String department_name = Util.null2String(rs.getString("department_name")); + String supdep_id = Util.null2String(rs.getString("supdep_id")); + if(StringUtils.isBlank(supdep_id) || "0".equals(supdep_id)){ + departmentname = department_name ; + } + } + } + bb.writeLog("departmentname:"+departmentname); + + return departmentname; + } + + + + public String updateAnniversaryWishes(String user_id,String modeid,String currentYear,int rzzn){ + + String billid = "" ; + BaseBean log = new BaseBean(); + log.writeLog("updateAnniversaryWishes! "); + + String uftable = "uf_rzznzfgly"; + RecordSet rs = new RecordSet(); + + BaseBean bb = new BaseBean(); + SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ; + + try{ + Map dataMap = new HashMap(); + + bb.writeLog("currentYear:"+currentYear); + + String sql =" select k.* from (" + + " select h.id,h.lastname,h.sex,h.companystartdate,h.departmentid,h.subcompanyid1," + + " right(companystartdate,5) startday " + + " from hrmresource h " + + " where h.id = "+user_id+" " + + " and h.status in(0,1,2,3) " + + " and (h.belongto is null or h.belongto = -1 ) " + + " and h.companystartdate is not null " + + " ) k " + + " order by k.startday desc " ; + + bb.writeLog("updateAnniversaryWishes-sql:"+sql); + + rs.executeQuery(sql); + if (rs.next()){ + String userid = Util.null2String(rs.getString("id")); + String lastname = Util.null2String(rs.getString("lastname")); + String subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); + String departmentid = Util.null2String(rs.getString("departmentid")); + String companystartdate = Util.null2String(rs.getString("companystartdate")); + String zfy =getZfy(lastname,rzzn); + String rzyr = Util.null2String(rs.getString("startday")); + + dataMap = new HashMap(); + dataMap.put("ry",userid); + dataMap.put("xm",lastname); + dataMap.put("zfy",zfy); + dataMap.put("bm",departmentid); + dataMap.put("rzrq",companystartdate); + dataMap.put("fb",subcompanyid1); + dataMap.put("nf",currentYear); + dataMap.put("rzzn",rzzn+""); + dataMap.put("rzyr",rzyr); + + } + + if(!dataMap.isEmpty()){ + String ry = dataMap.get("ry"); + String nf = dataMap.get("nf"); + sql = " select id from "+uftable+" where ry='"+ry+"' and nf = '"+nf+"'"; + rs.executeQuery(sql); + if(rs.next()){ + billid = Util.null2String(rs.getString("id")); + } + if(StringUtils.isBlank(billid)){ + billid = updateWishesInfo(uftable,dataMap,modeid); + } + } + }catch (Exception e){ + + } + return billid; + } + + + public String updateWishesInfo(String fromtable,Map datas,String formmodeid){ + RecordSet rs = new RecordSet(); + String dataid = "" ; + BaseBean bb = new BaseBean(); + ModeRightInfo modeRightInfo = new ModeRightInfo(); + String uuid = UUID.randomUUID().toString().replace("-",""); + bb.writeLog("uuid:"+uuid); + + SimpleDateFormat formatter1 = new SimpleDateFormat("yyyy-MM-dd"); + SimpleDateFormat formatter2 = new SimpleDateFormat("HH:mm:ss"); + String currentdate = formatter1.format(new Date()); + String currenttime = formatter2.format(new Date()); + String modedatacreater = "1"; + String modedatacreatertype = "0"; + + bb.writeLog("formmodeid:"+formmodeid); + datas.put("formmodeid", formmodeid); + datas.put("modedatacreater", modedatacreater); + datas.put("modedatacreatertype", modedatacreatertype); + datas.put("modedatacreatedate", currentdate); + datas.put("modedatacreatetime", currenttime); + datas.put("uuid", uuid); + + String tablenvalue = ""; + String tablename = ""; + for (Map.Entry entry : datas.entrySet()) { + String fieldname = Util.null2String(entry.getKey()).trim(); + String fieldvalue = Util.null2String(entry.getValue()).replace("'", "''").trim(); + tablename += tablename == "" ? fieldname : "," + fieldname; + tablenvalue += tablenvalue == "" ? "'" + fieldvalue + "'" : ",'" + fieldvalue + "'"; + } + if (tablename != "" && tablenvalue != "") { + int count = 0; + String sql = " insert into " + fromtable + "(" + tablename + ") values (" + tablenvalue + ")"; + bb.writeLog("sql:" + sql); + boolean boo = rs.executeUpdate(sql); + if (boo) { + count++; + } + bb.writeLog("count:" + count); + if (count > 0) { + sql = " select id from " + fromtable + " where uuid='" + uuid + "'"; + bb.writeLog("sql:" + sql); + rs.execute(sql); + if (rs.next()) { + dataid = Util.null2String(rs.getString("id")); + } + if (!"".equals(dataid)) { + modeRightInfo.editModeDataShare(Integer.valueOf(modedatacreater), Util.getIntValue(formmodeid), Integer.parseInt(dataid)); + } + } + } + return dataid; + } + + public static String convert(int number) { + if (number <= 0) { + return ""; + } + //数字对应的汉字 + String[] num = {"一", "二", "三", "四", "五", "六", "七", "八", "九"}; + //单位 + String[] unit = {"", "十", "百", "千", "万", "十", "百", "千", "亿", "十", "百", "千", "万亿"}; + //将输入数字转换为字符串 + String result = String.valueOf(number); + //将该字符串分割为数组存放 + char[] ch = result.toCharArray(); + //结果 字符串 + String str = ""; + int length = ch.length; + for (int i = 0; i < length; i++) { + int c = (int) ch[i] - 48; + if (c != 0) { + str += num[c - 1] + unit[length - i - 1]; + } + } + if (number < 20 && number > 9) { + str = str.substring(1); + } +// System.out.println(str); + return str ; + } + + + public String getZfy(String lastname,int rzzn){ + String rzzzdx = "" ; + if(rzzn > 0){ + rzzzdx = convert(rzzn); + } + String zfy ="
\n" + + "

亲爱的"+lastname+"

\n" + + "

 

\n" + + "

衷心祝贺您与铭沣同行"+rzzzdx+"周年快乐!

\n" + + "

感谢您将自己的青春年华和工作热情奉献给了铭沣!

\n" + + "

感谢您辛勤的付出与不懈的跟随与守候,期待我们一起度过下一个周年!

\n" + + "

今天的您是否忙碌在工作岗位上而忽略了这个重要的日子......

\n" + + "

但公司记得您每一份付出和努力!

\n" + + "

感谢您的一路相伴,未来我们继续同行!

\n" + + "

 

\n" + + "

 

\n" + + "

 MATFRON

\n" + + "
"; + return zfy; + } + +%> + + + + diff --git a/interface/mingfeng/getCompanyAnniversary.jsp b/interface/mingfeng/getCompanyAnniversary.jsp index 515e8e4..28a8c5f 100644 --- a/interface/mingfeng/getCompanyAnniversary.jsp +++ b/interface/mingfeng/getCompanyAnniversary.jsp @@ -14,8 +14,10 @@ Map data_Map = null; RecordSet rs = new RecordSet(); BaseBean bb = new BaseBean(); + SimpleDateFormat sdf = new SimpleDateFormat("MM-dd" ) ; SimpleDateFormat sdf2 = new SimpleDateFormat("yyyy" ) ; + SimpleDateFormat sdf3 = new SimpleDateFormat("yyyy-MM-dd") ; int days = 30 ; String workflowid = "890"; String formtable = "" ; @@ -46,26 +48,26 @@ String currentYear = sdf2.format(calendar.getTime()) ; bb.writeLog("currentYear:"+currentYear); - sql =" select k.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," + - " h.companystartdate,convert(varchar(50), getdate(), 23) as enddate," + - " (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))-1) as zn" + - " from hrmresource h\n" + - " inner join HrmDepartment d on d.id = h.departmentid\n" + - " inner join HrmSubCompany s on s.id = h.subcompanyid1\n" + - " left join HrmJobTitles k on k.id = h.jobtitle\n" + - " where right(h.companystartdate,5) = '"+currentDay+"'\n" + - " and h.status in(0,1,2,3)" + - " and (h.belongto is null or h.belongto = -1 ) " + - " and h.companystartdate is not null " + where + - " ) k " ; + String enddate = sdf3.format(calendar.getTime()) ; + + sql =" select k2.* from (select h.id,h.lastname,h.sex,h.departmentid,d.departmentname,s.subcompanyname,k.jobtitlename," + + " h.companystartdate,convert(varchar(50), getdate(), 23) as enddate," + + " (datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23))) as zn" + + " from hrmresource h\n" + + " inner join HrmDepartment d on d.id = h.departmentid\n" + + " inner join HrmSubCompany s on s.id = h.subcompanyid1\n" + + " left join HrmJobTitles k on k.id = h.jobtitle\n" + + " where right(h.companystartdate,5) = '"+currentDay+"'\n" + + " and h.status in(0,1,2,3)" + + " and (h.belongto is null or h.belongto = -1 ) " + + " and h.companystartdate is not null " + where + + " ) k2 " ; bb.writeLog("getCompanyAnniversary-sql:"+sql); rs.executeQuery(sql); while (rs.next()){ String companystartdate = Util.null2String(rs.getString("companystartdate")); - String enddate = Util.null2String(rs.getString("enddate")); - if(StringUtils.isNotBlank(companystartdate) && StringUtils.isNotBlank(enddate)){ LocalDate date1 = LocalDate.parse(companystartdate); LocalDate date2 = LocalDate.parse(enddate); @@ -98,7 +100,7 @@ deptnamenew = departmentname ; } data_Map.put("deptnamenew",deptnamenew); - data_Map.put("zn",zn); + data_Map.put("zn",yearsDiff+""); data_Map.put("nf",currentYear); dataList.add(data_Map); } @@ -125,6 +127,7 @@ Map dMap = dataList.get(i); String nf = dMap.get("nf"); String ry = dMap.get("userid"); + int rzzn = Util.getIntValue(dMap.get("zn")); if(StringUtils.isNotBlank(ry) && StringUtils.isNotBlank(nf)){ @@ -134,7 +137,7 @@ billid = Util.null2String(rs.getString("id")); } if(StringUtils.isBlank(billid)){ - billid = updateAnniversaryWishes(ry,modeid,nf); + billid = updateAnniversaryWishes(ry,modeid,nf,rzzn); } } @@ -184,7 +187,7 @@ - public String updateAnniversaryWishes(String user_id,String modeid,String currentYear){ + public String updateAnniversaryWishes(String user_id,String modeid,String currentYear,int rzzn){ String billid = "" ; BaseBean log = new BaseBean(); @@ -203,14 +206,13 @@ String sql =" select k.* from (" + " select h.id,h.lastname,h.sex,h.companystartdate,h.departmentid,h.subcompanyid1," + - " datediff(year,h.companystartdate,convert(varchar(50), getdate(), 23)) as rzzn," + " right(companystartdate,5) startday " + " from hrmresource h " + " where h.id = "+user_id+" " + " and h.status in(0,1,2,3) " + " and (h.belongto is null or h.belongto = -1 ) " + " and h.companystartdate is not null " + - " ) k where k.rzzn > 0 " + + " ) k " + " order by k.startday desc " ; bb.writeLog("updateAnniversaryWishes-sql:"+sql); @@ -219,11 +221,11 @@ if (rs.next()){ String userid = Util.null2String(rs.getString("id")); String lastname = Util.null2String(rs.getString("lastname")); - int rzzn = Util.getIntValue(Util.null2String(rs.getString("rzzn")),0); +// int rzzn = Util.getIntValue(Util.null2String(rs.getString("rzzn")),0); String subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); String departmentid = Util.null2String(rs.getString("departmentid")); String companystartdate = Util.null2String(rs.getString("companystartdate")); - String zfy =getZfy(lastname,rzzn); + String zfy = getZfy(lastname,rzzn); String rzyr = Util.null2String(rs.getString("startday")); dataMap = new HashMap(); diff --git a/interface/mingfeng/getPortalDepartment.jsp b/interface/mingfeng/getPortalDepartment.jsp index 987592c..62276c0 100644 --- a/interface/mingfeng/getPortalDepartment.jsp +++ b/interface/mingfeng/getPortalDepartment.jsp @@ -13,8 +13,9 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% + String subcompanyid1 = "62"; JSONObject jsonObject = new JSONObject(); - OptionVO optionVO = getPortalDepartment(); + OptionVO optionVO = getPortalDepartment(subcompanyid1); jsonObject.put("data",optionVO); %> @@ -22,13 +23,13 @@ <%! - public OptionVO getPortalDepartment() { + public OptionVO getPortalDepartment(String subcompanyid1) { RecordSet rs = new RecordSet(); LinkedList xData = new LinkedList<>(); LinkedList yData = new LinkedList<>(); - String where = " and (belongto is null or belongto = -1 ) "; + String where = " and (belongto is null or belongto = -1 ) and subcompanyid1 = "+subcompanyid1; List ids = new ArrayList<>(); - rs.executeQuery(" select id,departmentname from hrmdepartment where supdepid = 0 and (canceled = 0 or canceled is null) and subcompanyid1 = 62 "); + rs.executeQuery(" select id,departmentname from hrmdepartment where supdepid = 0 and (canceled = 0 or canceled is null) and subcompanyid1 ="+subcompanyid1); while (rs.next()) { xData.add(Util.null2String(rs.getString("departmentname"))); ids.add(Util.getIntValue(rs.getString("id"))); diff --git a/interface/mingfeng/getPortalEducational.jsp b/interface/mingfeng/getPortalEducational.jsp index e59443c..231b447 100644 --- a/interface/mingfeng/getPortalEducational.jsp +++ b/interface/mingfeng/getPortalEducational.jsp @@ -11,8 +11,9 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% + String subcompanyid1 = "62"; JSONObject jsonObject = new JSONObject(); - OptionVO optionVO = getPortalEducational(); + OptionVO optionVO = getPortalEducational(subcompanyid1); jsonObject.put("data",optionVO); %> @@ -20,11 +21,11 @@ <%! - public OptionVO getPortalEducational() { + public OptionVO getPortalEducational(String subcompanyid1) { + DecimalFormat df = new DecimalFormat("#.0"); RecordSet rs = new RecordSet(); - List colorList = Arrays.asList("#faf0e6","#7cfc00","#ee8164","#9933fa","#f19c45","#6fcecf","#507ef7","#ao20f0"); LinkedList seriesData = new LinkedList<>(); LinkedList nameSet = new LinkedList<>(); @@ -35,24 +36,19 @@ " where t.xl is not null \n" + " and h.status in(0,1,2,3)\n" + " and (h.belongto is null or h.belongto = -1 )\n" + + " and h.subcompanyid1 = " + subcompanyid1 + " group by t.xl,d.name " + " order by t.xl desc " ; rs.executeQuery(sql); - int index = 0; while (rs.next()) { - if (index > colorList.size()){ - index = 0; - } - index++; String name = Util.formatMultiLang (Util.null2String(rs.getString("name"))); - - seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("sum"))).name(name).color(colorList.get(index)).build()); + seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("sum"))).name(name).build()); nameSet.add(name); } - double percentage = seriesData.stream().mapToDouble(SeriesParam::getValue).sum(); - seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage)))); + // double percentage = seriesData.stream().mapToDouble(SeriesParam::getValue).sum(); + // seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage)))); // LinkedList legendDataFirst = new LinkedList<>(); // if (nameSet.size() > 2) { diff --git a/interface/mingfeng/getPortalEthnic.jsp b/interface/mingfeng/getPortalEthnic.jsp index 863f12b..27d2486 100644 --- a/interface/mingfeng/getPortalEthnic.jsp +++ b/interface/mingfeng/getPortalEthnic.jsp @@ -10,8 +10,9 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% + String subcompanyid1 = "62"; JSONObject jsonObject = new JSONObject(); - OptionVO optionVO = getPortalEthnic(); + OptionVO optionVO = getPortalEthnic(subcompanyid1); jsonObject.put("data",optionVO); %> @@ -19,14 +20,13 @@ <%! - public OptionVO getPortalEthnic() { + public OptionVO getPortalEthnic(String subcompanyid1) { - DecimalFormat df = new DecimalFormat("#.00"); +// DecimalFormat df = new DecimalFormat("#.00"); String fieldid = "27"; String fieldname = "field"+fieldid ; RecordSet rs = new RecordSet(); - List colorList = Arrays.asList("#6e94f3","#faf0e6","#7cfc00","#ao20f0","#00ced1","#83d8ae","#697695","#8ac9e9","#9933fa","#c0ff3e","#ffe4c4","#cd6090"); LinkedList seriesData = new LinkedList<>(); LinkedList nameSet = new LinkedList<>(); @@ -37,20 +37,18 @@ " where k.fieldid="+fieldid+" \n" + " and t."+fieldname+" is not null \n" + " and t.scope = 'HrmCustomFieldByInfoType' and t.scopeid='3' \n" + - " and h.status in(0,1,2,3)" + + " and h.status in(0,1,2,3) and h.subcompanyid1=" + subcompanyid1+ " and (h.belongto is null or h.belongto = -1 ) " + " group by t."+fieldname+",k.selectname \n" + ""); while (rs.next()) { - Random random = new Random(); - String color = colorList.get(random.nextInt(colorList.size())); String name = Util.null2String(rs.getString("name")); - seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("sums"))).name(name).color(color).build()); + seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("sums"))).name(name).build()); nameSet.add(name); } - double percentage = seriesData.stream().mapToDouble(SeriesParam::getValue).sum(); - seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage)))); +// double percentage = seriesData.stream().mapToDouble(SeriesParam::getValue).sum(); +// seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage)))); return OptionVO.builder() diff --git a/interface/mingfeng/getPortalHomePlace.jsp b/interface/mingfeng/getPortalHomePlace.jsp new file mode 100644 index 0000000..fb7767e --- /dev/null +++ b/interface/mingfeng/getPortalHomePlace.jsp @@ -0,0 +1,78 @@ +<%@ page import="weaver.general.*" %> +<%@page import="weaver.conn.RecordSet"%> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.*" %> +<%@ page import="com.engine.matfron.entity.OptionVO" %> +<%@ page import="com.engine.matfron.entity.SeriesParam" %> +<%@ page import="java.util.stream.Collectors" %> +<%@ page import="java.text.DecimalFormat" %> + + +<%@ page language="java" contentType="text/html; charset=UTF-8" %> + +<% + String subcompanyid1 = "62"; + JSONObject jsonObject = new JSONObject(); + OptionVO optionVO = getPortalHomePlace(subcompanyid1); + jsonObject.put("data",optionVO); + +%> +<%=jsonObject.toString() %> + +<%! + + public OptionVO getPortalHomePlace(String subcompanyid1) { + + DecimalFormat df = new DecimalFormat("#.00"); + + RecordSet rs = new RecordSet(); + LinkedList seriesData = new LinkedList<>(); + LinkedList legendData = new LinkedList<>(); + String where = " and (h.belongto is null or h.belongto = -1 ) and subcompanyid1 = "+subcompanyid1; + + rs.executeQuery(" select h.locationid,l.locationname,count(1) as num " + + " from hrmresource h\n" + + " left join hrmlocations l on h.locationid = l.id\n" + + " where h.status < 4 and h.locationid is not null "+where+" " + + " group by h.locationid,l.locationname"); + while (rs.next()) { + String locationname = Util.null2String(rs.getString("locationname")); + legendData.add(locationname); + seriesData.add(SeriesParam.builder().value(Util.getDoubleValue(rs.getString("num"))).name(locationname).build()); + } + +// List values = seriesData.stream().map(SeriesParam :: getValue).collect(Collectors.toList()); +// double percentage = values.stream().mapToDouble(Double::doubleValue).sum(); +// seriesData.forEach(item -> item.setValue(Double.valueOf(df.format((item.getValue() * 100) / percentage)))); + + return OptionVO.builder() + .titleText("归属地分析") + .legendDataFirst(legendData) + .seriesData(seriesData) + .build(); + + } + +%> + + +<%! + /** + * 平分legendData + * @param nameSet + */ + private LinkedList treeSetSplitExample(LinkedList nameSet) { + int splitSize = nameSet.size() / 2; + LinkedList legendDataFirst = nameSet.stream() + .collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize, + Collectors.toCollection(LinkedList::new))) + .get(false); + nameSet.removeAll(legendDataFirst); + return legendDataFirst; + } + + +%> + + + diff --git a/interface/mingfeng/getPortalLeaveMonth.jsp b/interface/mingfeng/getPortalLeaveMonth.jsp new file mode 100644 index 0000000..0f85f32 --- /dev/null +++ b/interface/mingfeng/getPortalLeaveMonth.jsp @@ -0,0 +1,106 @@ +<%@ page import="weaver.general.*" %> +<%@page import="weaver.conn.RecordSet"%> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.*" %> +<%@ page import="com.engine.matfron.entity.OptionVO" %> +<%@ page import="com.engine.matfron.util.CommonUtils" %> +<%@ page import="com.engine.matfron.util.CommonDateUtil" %> +<%@ page import="java.time.YearMonth" %> +<%@ page import="com.engine.matfron.entity.BrowserParam" %> +<%@ page import="org.apache.commons.lang.StringUtils" %> + + +<%@ page language="java" contentType="text/html; charset=UTF-8" %> + +<% + String subcompanyid1 = "62"; + JSONObject jsonObject = new JSONObject(); + String departmentIds = Util.null2String(request.getParameter("departmentIds")); + jsonObject = getLeaveMonth(departmentIds,subcompanyid1); + + +%> +<%=jsonObject.toString() %> + +<%! + + public JSONObject getLeaveMonth(String departmentIds,String subcompanyid1) { + JSONObject jsonObject = new JSONObject(); + RecordSet rs = new RecordSet(); + String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now())); + String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now())); + LinkedList xData = new LinkedList<>(); + LinkedList barSeriesData = new LinkedList<>(); + LinkedList browser = new LinkedList<>(); + String where = " and (s.belongto is null or s.belongto = -1 ) and s.subcompanyid1 = "+subcompanyid1; + + StringBuilder sql = new StringBuilder(); + sql.append( " select t.departmentname, t.id,CASE \n" + + " WHEN a.sum IS NULL THEN 0 \n" + + " ELSE a.sum \n" + + " END AS num " + + " from hrmdepartment t \n" + + " left join (select s.departmentid,count(1) as sum from hrmstatushistory h left join hrmresource s on h.resourceid = s.id where h.type_n = 5 "+where+" and h.changedate >= ? and h.changedate <= ? group by s.departmentid ) a on t.id = a.departmentid " + + " "); + + if(StringUtils.isNotEmpty(departmentIds)) { + sql.append(" where (t.canceled = 0 or t.canceled is null)"); + sql.append(" and t.id in (").append(departmentIds).append(")"); + } + + rs.executeQuery(sql.toString(),startMonth,endMonth); + + int i = 0; + while (rs.next()) { + i++; + Integer id = Util.getIntValue(rs.getString("id")); + String name = Util.null2String(rs.getString("departmentname")); + int num = Util.getIntValue(rs.getString("num")); + xData.add(name); + int countBydeptId = countBydeptId(id, endMonth) + num; + barSeriesData.add( countBydeptId == 0 ? 0 : (num * 100) / countBydeptId); + browser.add(BrowserParam.builder().id(id).name(name).build()); + if(i>=5){ + break; + } + } + + int max = Collections.max(barSeriesData); + max = max < 80 ? max + 20 : 100; + int ceil =(int) Math.ceil((double) max / 4); + int roundedMax = CommonUtils.roundedMax(ceil, 4); + + OptionVO optionVo = OptionVO.builder().titleText("当月多部门离职率统计") + .xData(xData) + .yMin(0) + .yMax(roundedMax) + .yInterval(ceil) + .barSeriesData(barSeriesData) + .build(); + + jsonObject.put("data",optionVo); + jsonObject.put("replaceDatas",browser); + return jsonObject; + } + + +%> +<%! + /** + * 根据日期部门人数统计 + * @param departmentId + * @return + */ + private int countBydeptId(Integer departmentId,String endMonth) { + RecordSet rs = new RecordSet(); + + String where = " and (belongto is null or belongto = -1 ) "; + + rs.executeQuery("select count(1) as sum from hrmresource where departmentId = ? and status < 4 and companystartdate <= ? " + where ,departmentId,endMonth); + rs.next(); + return Util.getIntValue(rs.getString("sum")); + } +%> + + + diff --git a/interface/mingfeng/getPortalLeaveYear.jsp b/interface/mingfeng/getPortalLeaveYear.jsp new file mode 100644 index 0000000..9cd5a43 --- /dev/null +++ b/interface/mingfeng/getPortalLeaveYear.jsp @@ -0,0 +1,153 @@ +<%@ page import="weaver.general.*" %> +<%@page import="weaver.conn.RecordSet"%> +<%@ page import="com.alibaba.fastjson.JSONObject" %> +<%@ page import="java.util.*" %> +<%@ page import="com.engine.matfron.entity.OptionVO" %> +<%@ page import="com.engine.matfron.util.CommonUtils" %> +<%@ page import="com.engine.matfron.util.CommonDateUtil" %> +<%@ page import="java.time.YearMonth" %> +<%@ page import="com.engine.matfron.entity.BrowserParam" %> +<%@ page import="org.apache.commons.lang.StringUtils" %> +<%@ page import="weaver.hrm.company.DepartmentComInfo" %> +<%@ page import="java.util.stream.Collectors" %> +<%@ page import="com.engine.matfron.exception.CustomizeRunTimeException" %> +<%@ page import="java.time.LocalDate" %> + + +<%@ page language="java" contentType="text/html; charset=UTF-8" %> + +<% + String subcompanyid1 = "62"; + JSONObject jsonObject = new JSONObject(); + String departmentIds = Util.null2String(request.getParameter("departmentIds")); + jsonObject = getLeaveYear(departmentIds,subcompanyid1); + +%> +<%=jsonObject.toString() %> + +<%! + + public JSONObject getLeaveYear(String departmentIds,String subcompanyid1) { + JSONObject jsonObject = new JSONObject(); + RecordSet rs = new RecordSet(); + LinkedList legendDataFirst = new LinkedList<>(); + LinkedList barSeriesData = new LinkedList<>(); + LinkedList barSeriesDataTwo = new LinkedList<>(); + LinkedList barSeriesDataThree = new LinkedList<>(); + DepartmentComInfo comInfo = new DepartmentComInfo(); + LinkedList browser = new LinkedList<>(); + List deptList = new ArrayList<>(); + + if(StringUtils.isNotEmpty(departmentIds)) { + deptList = Arrays.stream(departmentIds.split(",")).map(Integer::parseInt).collect(Collectors.toList()); + + }else { +// rs.executeQuery("select distinct t.id from hrmdepartment t \n" + +// " left join hrmresource h on t.id = h.departmentid\n" + +// " left join hrmstatushistory s on h.id = s.resourceid where s.type_n = 5 "); + rs.executeQuery("select id from hrmdepartment where canceled = 0 or canceled is null and subcompanyid1="+subcompanyid1); + while (rs.next()) { + deptList.add(Util.getIntValue(rs.getString("id"))); + } + + } + + deptList = deptList.stream().limit(3).collect(Collectors.toList()); + + deptList.forEach(dept -> { + try { + String departmentName = comInfo.getDepartmentName(String.valueOf(dept)); + legendDataFirst.add(departmentName); + browser.add(BrowserParam.builder().id(dept).name(departmentName).build()); + } catch (Exception e) { + throw new CustomizeRunTimeException("所选部门不存在"); + } + }); + + List yearMonths = CommonDateUtil.getYearMonths(LocalDate.now()); + List finalDeptList = deptList; + yearMonths.forEach(yearMonth -> { + String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth)); + String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth)); + for (int i = 0; i < 3; i++) { + Integer value = calculateLeave(finalDeptList.get(i), startMonth, endMonth,subcompanyid1); + switch (i) { + case 0: + barSeriesData.add(value); + break; + case 1: + barSeriesDataTwo.add(value); + break; + case 2: + barSeriesDataThree.add(value); + break; + default: + break; + + } + } + + }); + + LinkedList sumData = new LinkedList<>(); + sumData.addAll(barSeriesData); + sumData.addAll(barSeriesDataTwo); + sumData.addAll(barSeriesDataThree); + + int max = Collections.max(sumData); + max = max < 80 ? max + 20 : 100; + int ceil =(int) Math.ceil((double) max / 4); + int roundedMax = CommonUtils.roundedMax(ceil, 4); + + OptionVO optionVo = OptionVO.builder().titleText("年度离职率统计") + .legendDataFirst(legendDataFirst) + .yMin(0) + .yMax(roundedMax) + .yInterval(ceil) + .barSeriesData(barSeriesData) + .barSeriesDataTwo(barSeriesDataTwo) + .barSeriesDataThree(barSeriesDataThree) + .build(); + jsonObject.put("data",optionVo); + jsonObject.put("replaceDatas",browser); + return jsonObject; + } + + +%> +<%! + private Integer calculateLeave(Integer id,String startMonth,String endMonth,String subcompanyid1) { + RecordSet rs = new RecordSet(); + + String where = " and (s.belongto is null or s.belongto = -1 ) and s.subcompanyid1 = "+subcompanyid1; + + String sql =" select t.departmentname, t.id," + + " case when a.sum IS NULL THEN 0 ELSE a.sum END AS num " + + " from hrmdepartment t \n" + + " left join (select s.departmentid,count(1) as sum from hrmstatushistory h left join hrmresource s on h.resourceid = s.id where type_n = 5 "+ where +" and changedate >= ? and changedate <= ? group by s.departmentid ) a on t.id = a.departmentid " + + " where t.id = ? and (t.canceled = 0 or t.canceled is null)"; + + rs.executeQuery(sql,startMonth,endMonth,id); + rs.next(); + int countBydeptId = countBydeptId(id, endMonth); + return countBydeptId == 0 ? 0 : ((Util.getIntValue(rs.getString("num")) * 100) / countBydeptId); + } +%> +<%! + /** + * 根据日期部门人数统计 + * @param departmentId + * @return + */ + private int countBydeptId(Integer departmentId,String endMonth) { + RecordSet rs = new RecordSet(); + + String where = " and (belongto is null or belongto = -1 ) "; + + rs.executeQuery("select count(1) as sum from hrmresource where departmentId = ? and status < 4 and companystartdate <= ? " + where ,departmentId,endMonth); + rs.next(); + return Util.getIntValue(rs.getString("sum")); + } +%> + + diff --git a/interface/mingfeng/getPortalSubCompany.jsp b/interface/mingfeng/getPortalSubCompany.jsp index fc297fc..cef0d5e 100644 --- a/interface/mingfeng/getPortalSubCompany.jsp +++ b/interface/mingfeng/getPortalSubCompany.jsp @@ -7,13 +7,16 @@ <%@ page import="java.time.YearMonth" %> <%@ page import="com.engine.matfron.util.CommonDateUtil" %> <%@ page import="java.time.LocalDate" %> +<%@ page import="java.text.SimpleDateFormat" %> +<%@ page import="org.apache.commons.lang3.StringUtils" %> <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% + String subcompanyid1 = "62"; JSONObject jsonObject = new JSONObject(); - OptionVO optionVO = getPortalSubCompany(); + OptionVO optionVO = getPortalSubCompany(subcompanyid1); jsonObject.put("data",optionVO); jsonObject.put("status",true); @@ -22,21 +25,26 @@ <%! - public OptionVO getPortalSubCompany() { + public OptionVO getPortalSubCompany(String subcompanyid1) { RecordSet rs = new RecordSet(); LinkedList yData = new LinkedList<>(); - String where = " and (belongto is null or belongto = -1 ) "; + String where = " and (belongto is null or belongto = -1 ) and subcompanyid1 = "+subcompanyid1; + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM"); + String nowMonth = sdf.format(new Date()); List yearMonths = CommonDateUtil.getYearMonths(LocalDate.now()); yearMonths.forEach(yearMonth -> { String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(yearMonth)); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(yearMonth)); - rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate <= ?" + where ,endMonth); - if (rs.next()) { - Integer sum = Util.getIntValue(rs.getString("sum"),0); - yData.add(sum); - } + String selectMonth = sdf.format(CommonDateUtil.toDateEndOfMonth(yearMonth)); + if(selectMonth.compareTo(nowMonth)<=0){ + rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and companystartdate <= ?" + where ,endMonth); + if (rs.next()) { + Integer sum = Util.getIntValue(rs.getString("sum"),0); + yData.add(sum); + } + } }); int max = Collections.max(yData); diff --git a/interface/mingfeng/getPortalTop.jsp b/interface/mingfeng/getPortalTop.jsp index e9d6af5..37551b2 100644 --- a/interface/mingfeng/getPortalTop.jsp +++ b/interface/mingfeng/getPortalTop.jsp @@ -13,8 +13,10 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% + + String subcompanyid1 = "62" ; JSONObject jsonObject = new JSONObject(); - LinkedList list = getPortalTop(); + LinkedList list = getPortalTop(subcompanyid1); jsonObject.put("data",list); %> @@ -22,10 +24,10 @@ <%! - public LinkedList getPortalTop() { + public LinkedList getPortalTop(String subcompanyid1) { RecordSet rs = new RecordSet(); DecimalFormat df = new DecimalFormat("#.00"); - String subcompanyid1 = "62" ; + BaseBean bb = new BaseBean(); LinkedList portalTopVOList = new LinkedList(); String where = " and (belongto is null or belongto = -1 ) "; @@ -36,7 +38,7 @@ portalTopVOList.add(PortalTopVO.builder().title("在职人数总数").count(count).build()); int sb_count = 0 ; - String sql = " select count(1) as cou from hrsa_insurance_base_info where run_status in(2,3) and isnull(delete_type,0) !=1 " ; + String sql = " select count(1) as cou from hrsa_insurance_base_info where run_status in(2,3) and isnull(delete_type,0) !=1 " ; rs.executeQuery(sql); if(rs.next()){ sb_count = Util.getIntValue(rs.getString("cou"), 0); @@ -57,11 +59,17 @@ String avgAge = df.format(averageAge); portalTopVOList.add(PortalTopVO.builder().title("平均年龄").count(avgAge).build()); + int sum = 0; String startMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateStartOfMonth(YearMonth.now())); String endMonth = CommonDateUtil.getFormatYear(CommonDateUtil.toDateEndOfMonth(YearMonth.now())); - rs.executeQuery("select count(1) as sum from hrmresource where status < 4 and subcompanyid1 ="+subcompanyid1+" and companystartdate >= ? and companystartdate <= ?" + where,startMonth,endMonth); - rs.next(); - Integer sum = Util.getIntValue(rs.getString("sum"),0); + sql = " select count(1) as sum from hrmresource where status < 4 and subcompanyid1 ="+subcompanyid1+" and companystartdate >= '"+startMonth+"' and companystartdate <= '"+endMonth+"'" + where ; + bb.writeLog("sql:"+sql); + rs.executeQuery(sql); + if(rs.next()){ + sum = Util.getIntValue(Util.null2String(rs.getString("sum")),0); + } + + bb.writeLog("sum:"+sum); portalTopVOList.add(PortalTopVO.builder().title("本月新入职人员").count(sum).build()); return portalTopVOList; @@ -70,23 +78,5 @@ %> -<%! - /** - * 平分legendData - * @param nameSet - */ - private LinkedList treeSetSplitExample(LinkedList nameSet) { - int splitSize = nameSet.size() / 2; - LinkedList legendDataFirst = nameSet.stream() - .collect(Collectors.partitioningBy(e -> nameSet.indexOf(e) < splitSize, - Collectors.toCollection(LinkedList::new))) - .get(false); - nameSet.removeAll(legendDataFirst); - return legendDataFirst; - } - - -%> - diff --git a/interface/mingfeng/getPortalUserGender.jsp b/interface/mingfeng/getPortalUserGender.jsp index 9526e43..f9ce2fd 100644 --- a/interface/mingfeng/getPortalUserGender.jsp +++ b/interface/mingfeng/getPortalUserGender.jsp @@ -12,8 +12,9 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% + String subcompanyid1 = "62"; JSONObject jsonObject = new JSONObject(); - OptionVO OptionVO = getAgeAndSex(); + OptionVO OptionVO = getAgeAndSex(subcompanyid1); jsonObject.put("data",OptionVO); %> @@ -21,29 +22,39 @@ <%! - public OptionVO getAgeAndSex() { + public OptionVO getAgeAndSex(String subcompanyid1) { RecordSet rs = new RecordSet(); LinkedList barSeriesData = new LinkedList<>(); LinkedList barSeriesDataTwo = new LinkedList<>(); - List ageArr = Arrays.asList("16~20","21~25","26~30","31~35","36~40","41~45","46~50","51~55","56~60","61~65","66~70"); - String where = " and (belongto is null or belongto = -1 ) "; - + List ageArr = Arrays.asList("20及以下","21~25","26~30","31~35","36~40","41~45","46~50","51~55","56及以上"); + String where = " and (belongto is null or belongto = -1 ) and subcompanyid1 = "+subcompanyid1; List birthdayListMen = new ArrayList<>(); - rs.executeQuery("select birthday from hrmresource where status < 4 "+where+" and sex is not null and birthday is not null and birthday <> '' and sex = 0"); + rs.executeQuery(" select birthday from hrmresource where status < 4 "+where+" and sex is not null and birthday is not null and birthday <> '' and sex = 0"); while (rs.next()) { birthdayListMen.add(Util.null2String(rs.getString("birthday"))); } - List menAge = birthdayListMen.stream() - .map(birthday -> { + List menAge = birthdayListMen.stream().map(birthday -> { LocalDate birthdate = LocalDate.parse(birthday); LocalDate now = LocalDate.now(); return Period.between(birthdate, now).getYears(); - }) - .collect(Collectors.toList()); + }).collect(Collectors.toList()); + for (int i = 0; i < ageArr.size(); i++) { - String[] split = ageArr.get(i).split("~"); - List collect = menAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList()); - barSeriesData.add(collect.size()); + if(i==0){ + String split0 = "0"; + String split1 = "20"; + List collect = menAge.stream().filter(item -> item >= Integer.parseInt(split0) && item <= Integer.parseInt(split1)).collect(Collectors.toList()); + barSeriesData.add(collect.size()); + }else if(i==(ageArr.size()-1)){ + String split0 = "56"; + String split1 = "100"; + List collect = menAge.stream().filter(item -> item >= Integer.parseInt(split0) && item <= Integer.parseInt(split1)).collect(Collectors.toList()); + barSeriesData.add(collect.size()); + }else{ + String[] split = ageArr.get(i).split("~"); + List collect = menAge.stream().filter(item -> item >= Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList()); + barSeriesData.add(collect.size()); + } } int yMax = barSeriesData.stream().max(Integer::compare).orElse(0); @@ -64,7 +75,7 @@ LinkedList list = new LinkedList<>(); for (int i = 0; i < ageArr.size(); i++) { String[] split = ageArr.get(i).split("~"); - List collect = womenAge.stream().filter(item -> item > Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList()); + List collect = womenAge.stream().filter(item -> item >= Integer.parseInt(split[0]) && item <= Integer.parseInt(split[1])).collect(Collectors.toList()); barSeriesDataTwo.add(-collect.size()); list.add(collect.size()); } @@ -75,7 +86,7 @@ int divisor = sum % 6; sum = sum + (6 - divisor) + 12; int ceil =(int) Math.ceil((double) sum / 3); - int roundedMax = CommonUtils.roundedMax(ceil, 6); + int roundedMax = CommonUtils.roundedMax(ceil, 6); return OptionVO.builder() .titleText("年龄与性别分析") diff --git a/interface/mingfeng/getPortalUserJobType.jsp b/interface/mingfeng/getPortalUserJobType.jsp index b30830d..607c68c 100644 Binary files a/interface/mingfeng/getPortalUserJobType.jsp and b/interface/mingfeng/getPortalUserJobType.jsp differ diff --git a/interface/mingfeng/getPortalWorkCompany.jsp b/interface/mingfeng/getPortalWorkCompany.jsp index 646ce64..05748df 100644 --- a/interface/mingfeng/getPortalWorkCompany.jsp +++ b/interface/mingfeng/getPortalWorkCompany.jsp @@ -12,8 +12,9 @@ <%@ page language="java" contentType="text/html; charset=UTF-8" %> <% + String subcompanyid1 = "62"; JSONObject jsonObject = new JSONObject(); - OptionVO OptionVO = getSurname(); + OptionVO OptionVO = getSurname(subcompanyid1); jsonObject.put("data",OptionVO); %> @@ -21,13 +22,13 @@ <%! - public OptionVO getSurname() { + public OptionVO getSurname(String subcompanyid1) { DecimalFormat df = new DecimalFormat("#.00"); RecordSet rs = new RecordSet(); LinkedList seriesData = new LinkedList<>(); - String where = " and (belongto is null or belongto = -1 ) "; + String where = " and (belongto is null or belongto = -1 ) and subcompanyid1 = "+subcompanyid1; List surnameList = new ArrayList<>(); rs.executeQuery("select companyworkyear,count(1) as sum from hrmresource where status < 4 " + where + @@ -43,12 +44,14 @@ statisticsList.add(count); } - double percentage = statisticsList.stream().mapToDouble(Double::doubleValue).sum(); - List newList = statisticsList.stream() - .map(num -> Double.valueOf (df.format((num * 100 ) / percentage))) - .collect(Collectors.toList()); +// double percentage = statisticsList.stream().mapToDouble(Double::doubleValue).sum(); +// List newList = statisticsList.stream() +// .map(num -> Double.valueOf (df.format((num * 100 ) / percentage))) +// .collect(Collectors.toList()); +// +// newList.forEach(count -> seriesData.add(SeriesParam.builder().value(count).build())); - newList.forEach(count -> seriesData.add(SeriesParam.builder().value(count).build())); + statisticsList.forEach(count -> seriesData.add(SeriesParam.builder().value(count).build())); return OptionVO.builder() .titleText("司龄统计") @@ -62,7 +65,7 @@ * @return */ private Double statisticsSurname(Integer min,Integer max,List surnameList) { - return surnameList.stream().filter(item -> item.getCompanyworkyear() > min && item.getCompanyworkyear() <= max) + return surnameList.stream().filter(item -> item.getCompanyworkyear() >= min && item.getCompanyworkyear() < max) .mapToDouble(SurnameParam::getCount).sum(); }