diff --git a/interface/hjkj/updateDepartMentCode.jsp b/interface/hjkj/updateDepartMentCode.jsp new file mode 100644 index 00000000..a7895972 --- /dev/null +++ b/interface/hjkj/updateDepartMentCode.jsp @@ -0,0 +1,145 @@ +<%@ page import="java.util.Map" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.Objects" %> +<%@ page import="weaver.interfaces.util.ReadExcel" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="java.util.HashMap" %> + + +<%-- + User: wangj + Design Ideas: +--%> +<%@ page contentType="text/html;charset=UTF-8" %> +<% + ReadExcel r = new ReadExcel(); + RecordSet rs = new RecordSet(); + int scount = 0; + int fcount = 0; + List> lists = r.readExcel("/whalecloud/cos", "organization.xlsx", 0, 0, 0); + if (Objects.nonNull(lists)) { + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); +// m.forEach((key, value) -> { +// System.out.println(key + ":" + value); +// }); + int ORG_LEVEL = Util.getIntValue(m.get("org_level")); + String ORG_ID = m.get("org_id"); + + String ORG_TYPE = m.get("org_type"); + String PARENT_ORG_ID = m.get("parent_org_id"); + String ORG_CODE = m.get("org_code"); + String ORG_NAME = m.get("org_name"); + + //状态正常 + String canceled = ""; + + //一级部门 + if (ORG_LEVEL == 1) { + String subcompany = "59"; + String supdepid = "0"; + boolean flag = insertDepartment(ORG_NAME, ORG_CODE, canceled, subcompany, supdepid, ORG_ID); + if (flag) { + scount++; + } else { + fcount++; + } + } + + //下及部门 + if (ORG_LEVEL > 1) { + Map map = new HashMap<>(); + map = getSubcompanyid1(lists, PARENT_ORG_ID); + String subcompany = map.get("subcompanyid1"); + String supdepid = map.get("supdepid"); + boolean flag = insertDepartment(ORG_NAME, ORG_CODE, canceled, subcompany, supdepid, ORG_ID); + if (flag) { + scount++; + } else { + fcount++; + } + } + + + } + } + out.print("success:" + scount + ",false:" + fcount); +%> + +<%! + private String getSubcompanyid(List> lists, String id) { + RecordSet rs = new RecordSet(); + String Subcompanyid = ""; + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String ORG_ID = m.get("org_id"); + String ORG_NAME = m.get("org_name"); + String ORG_CODE = m.get("org_code"); + String PARENT_ORG_ID = m.get("parent_org_id"); + if (ORG_ID.equals(id)) { + rs.execute("select id from hrmsubcompany where SUBCOMPANYCODE = '" + ORG_CODE + "'"); + while (rs.next()) { + Subcompanyid = Util.null2String(rs.getString("id")); + } + } + } + return Subcompanyid; + } +%> + +<%! + private Map getSubcompanyid1(List> lists, String id) { + Map res = new HashMap<>(); + RecordSet rs = new RecordSet(); + String subcompanyid1 = ""; + String supdepid = ""; + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String ORG_ID = m.get("org_id"); + + String ORG_CODE = m.get("org_code"); + + if (ORG_ID.equals(id)) { + rs.execute("select id,subcompanyid1 from hrmdepartment where departmentcode = '" + ORG_CODE + "'"); + while (rs.next()) { + supdepid = Util.null2String(rs.getString("id")); + subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); + res.put("supdepid", supdepid); + res.put("subcompanyid1", subcompanyid1); + } + } + } + + return res; + } +%> + +<%! + private boolean insertDepartment(String ORG_NAME, String ORG_CODE, String canceled, String subcompanyid1, String supdepid, String ORG_ID) { + RecordSet rs = new RecordSet(); + boolean isexist = false; + boolean flag = false; + String sql = "select count(1) as sl from hrmdepartment where departmentcode = ?"; + rs.executeQuery(sql,ORG_CODE); + while (rs.next()){ + if(Util.getIntValue(rs.getString("sl"))>0){ + isexist = true; + } + } + if(isexist){ + String deptUpdateSql = " update hrmdepartment set departmentmark=?,departmentname=?,canceled=?," + + " subcompanyid1=?,showorder=?, supdepid=? where departmentcode=? "; + + flag = rs.executeUpdate(deptUpdateSql,new Object[]{ORG_NAME,ORG_NAME,canceled,subcompanyid1,ORG_ID,supdepid,ORG_CODE}); + + }else{ + String deptInsertSql = " insert into hrmdepartment(departmentmark,departmentname,departmentcode," + + " canceled,subcompanyid1,supdepid,showorder) values(?,?,?,?,?,?,?) "; + flag = rs.executeUpdate(deptInsertSql, new Object[]{ORG_NAME, ORG_NAME, ORG_CODE, canceled, subcompanyid1, supdepid, ORG_ID}); + } + + + return flag; + } +%> diff --git a/interface/hjkj/updateHrmresource.jsp b/interface/hjkj/updateHrmresource.jsp new file mode 100644 index 00000000..0679351c --- /dev/null +++ b/interface/hjkj/updateHrmresource.jsp @@ -0,0 +1,133 @@ +<%@ page import="java.util.Map" %> +<%@ page import="java.util.List" %> +<%@ page import="java.util.Objects" %> +<%@ page import="weaver.interfaces.util.ReadExcel" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="java.util.HashMap" %> +<%@ page import="org.apache.commons.codec.digest.DigestUtils" %> +<%@ page import="weaver.general.TimeUtil" %> + + +<%-- + User: wangj + Design Ideas: +--%> +<%@ page contentType="text/html;charset=UTF-8" %> +<% + ReadExcel r = new ReadExcel(); + RecordSet rs = new RecordSet(); + int scount = 0; + int fcount = 0; + + List> deptlists = r.readExcel("/whalecloud/cos", "organization.xlsx", 0, 0, 0); + List> hrmlists = r.readExcel("/whalecloud/cos", "staff.xlsx", 0, 0, 0); + if (Objects.nonNull(hrmlists)) { + for (int i = 0; i < hrmlists.size(); i++) { + Map h = hrmlists.get(i); + //部门id + String ORG_ID = Util.null2String(h.get("org_id")); + String STAFF_CODE = Util.null2String(h.get("staff_code")); + + String pwd = "1"; + String creator = "1"; + String jobTitleId = "464"; + String password = DigestUtils.md5Hex(pwd).toUpperCase(); //MD5加密 + String STAFF_NAME = Util.null2String(h.get("staff_name")); + Map res = getSubcompanyid1(deptlists,ORG_ID); + String deptId = Util.null2String(res.get("deptid")); + String subcompanyid1 = Util.null2String(res.get("subcompanyid1")); + if("".equals(deptId)) continue; + String E_MAIL = Util.null2String(h.get("e_mail")); + String MOBILE_PHONE = Util.null2String(h.get("mobile_phone")); + String STATUS_CD = Util.null2String(h.get("status_cd")); + String status = "1"; + if("1100".equals(STATUS_CD) || "1200".equals(STATUS_CD) || "1300".equals(STATUS_CD)){ + status = "5"; + } + String STAFF_ID = Util.null2String(h.get("staff_id")); + String systemlanguage = "8" ; + String currentDate = TimeUtil.getCurrentDateString();//当前日期 + String currentDateTime = TimeUtil.getCurrentTimeString(); //当前时间 + String locationid = "2" ; + String seclevel = "20" ; + String createrid = "1" ; + String lastmodid = "1" ; + boolean flag = insertHrmresource( STAFF_CODE, password, STAFF_NAME, deptId, subcompanyid1, creator, E_MAIL, MOBILE_PHONE, jobTitleId, status, + STAFF_ID, systemlanguage, currentDate, currentDateTime, locationid, seclevel, createrid, lastmodid); + if(flag){ + scount++; + }else{ + fcount++; + } + } + } + out.print("success:" + scount + ",false:" + fcount); +%> + + +<%! + private Map getSubcompanyid1(List> lists, String id) { + Map res = new HashMap<>(); + RecordSet rs = new RecordSet(); + String subcompanyid1 = ""; + String deptid = ""; + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String ORG_ID = m.get("org_id"); + String ORG_CODE = m.get("org_code"); + if (ORG_ID.equals(id)) { + rs.execute("select id,subcompanyid1 from hrmdepartment where departmentcode = '" + ORG_CODE + "'"); + while (rs.next()) { + deptid = Util.null2String(rs.getString("id")); + subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); + res.put("deptid", deptid); + res.put("subcompanyid1", subcompanyid1); + } + } + } + + return res; + } +%> + + + + + +<%! + private boolean insertHrmresource(String STAFF_CODE,String password,String STAFF_NAME,String deptId,String subcompanyid1,String creator,String E_MAIL,String MOBILE_PHONE,String jobTitleId,String status, + String STAFF_ID,String systemlanguage,String currentDate,String currentDateTime,String locationid,String seclevel,String createrid,String lastmodid) { + RecordSet rs = new RecordSet(); + boolean flag = false; + String loginid = ""; + String sql = " select loginid from hrmresource where workcode=?" ; + + rs.executeQuery(sql,new Object[]{STAFF_CODE}); + if(rs.next()){ + loginid = Util.null2String(rs.getString("loginid")); + } + + if(!"".equals(loginid)){ + String userUpdateSql = " update hrmresource set lastname=?,departmentid=?,subcompanyid1=?," + + " creater=?,email=?,mobile=?,jobtitle=?,status=?,dsporder=?,lastmoddate=?,modified=? where workcode=? "; + + + flag = rs.executeUpdate(userUpdateSql,new Object[]{STAFF_NAME,deptId,subcompanyid1,creator,E_MAIL, + MOBILE_PHONE,jobTitleId,status,STAFF_ID,currentDate,currentDateTime,STAFF_CODE}); + + }else{ + rs.executeProc("HrmResourceMaxId_Get", ""); + rs.next(); + String id = "" + rs.getInt(1); + String userInsertSql = " insert into hrmresource(id,loginid,password,workcode,lastname,departmentid,subcompanyid1," + + "creater,email,mobile,jobtitle,status,dsporder,systemlanguage,createdate,lastmoddate,created,modified," + + "locationid,seclevel,createrid,lastmodid) " + + " values(?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?,?)"; + flag = rs.executeUpdate(userInsertSql,new Object[]{id,STAFF_CODE,password,STAFF_CODE,STAFF_NAME,deptId,subcompanyid1, + creator,E_MAIL,MOBILE_PHONE,jobTitleId,status,STAFF_ID,systemlanguage,currentDate,currentDate,currentDateTime,currentDateTime, + locationid,seclevel,createrid,lastmodid}); + } + return flag; + } +%> diff --git a/interface/hjkj/updatePost.jsp b/interface/hjkj/updatePost.jsp new file mode 100644 index 00000000..66c1e46d --- /dev/null +++ b/interface/hjkj/updatePost.jsp @@ -0,0 +1,104 @@ +<%@ page import="weaver.interfaces.util.ReadExcel" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="java.util.*" %> +<%@ page import="weaver.general.TimeUtil" %> +<%@ page import="weaver.backup.fkcustomer.FkCustomerBrowserDef" %> + + +<%-- + User: wangj + Design Ideas: +--%> +<%@ page contentType="text/html;charset=UTF-8" %> +<% + ReadExcel r = new ReadExcel(); + RecordSet rs = new RecordSet(); + int scount = 0; + int fcount = 0; + String creater = "1"; + String created = TimeUtil.getCurrentTimeString(); + String modified = TimeUtil.getCurrentTimeString(); + String modifier = "1"; + List> deptlists = r.readExcel("/whalecloud/cos", "organization.xlsx", 0, 0, 0); + List> lists = r.readExcel("/whalecloud/cos", "system_post.xlsx", 0, 0, 0); + if (Objects.nonNull(lists)) { + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String SYS_POST_CODE = Util.null2String(m.get("SYS_POST_CODE")); + String SYS_POST_NAME = Util.null2String(m.get("SYS_POST_NAME")); + String IS_SYNC = Util.null2String(m.get("IS_SYNC")); + if (!"YES".equals(IS_SYNC)) { + continue; + } + String allname = "~`~`7 " + SYS_POST_NAME + "`~`8 " + SYS_POST_NAME + "`~`~"; + String ORG_ID = Util.null2String(m.get("ORG_ID")); + Map res = getSubcompanyid1(deptlists, ORG_ID); + String deptid = Util.null2String(res.get("deptid")); + + boolean flag = insertPost(allname, creater, created, modified, modifier, SYS_POST_CODE, deptid); + if (flag) { + scount++; + } else { + fcount++; + } + + } + } + out.print("success:" + scount + ",false:" + fcount); +%> + +<%! + private boolean insertPost(String allname, String creater, String created, String modified, String modifier, String sysPostCode, String departmentId) { + RecordSet rs = new RecordSet(); + boolean iflag = false; + String groupsid = "803"; + String jobactivitiesid = "233"; + String uuid = UUID.randomUUID().toString(); + + String id = ""; + String sql = "select id from hrmjobtitles where jobtitlecode = ?"; + rs.executeQuery(sql,new Object[]{sysPostCode}); + while (rs.next()){ + id = Util.null2String(rs.getString("id")); + } + + if(!"".equals(id)){ + String updateHrmjobactivitiesSl = "update hrmjobtitles set jobtitlemark=?,jobtitlename=?,modified=?,modifier=? where id=?"; + iflag = rs.executeUpdate(updateHrmjobactivitiesSl,allname,allname,modified,modifier,id); + + }else{ + uuid = UUID.randomUUID().toString(); + String insertHrmjobactivitiesSql = " insert into hrmjobtitles(jobtitlemark,jobtitlename,jobactivityid,jobdepartmentid,jobtitlecode,created,creater,modified,modifier,uuid) values(?,?,?,?,?,?,?,?,?,?)"; + iflag = rs.executeUpdate(insertHrmjobactivitiesSql, new Object[]{allname, allname, jobactivitiesid, departmentId, sysPostCode, created, creater, modified, modifier, uuid}); + + } + + return iflag; + } +%> + +<%! + private Map getSubcompanyid1(List> lists, String id) { + Map res = new HashMap<>(); + RecordSet rs = new RecordSet(); + String subcompanyid1 = ""; + String deptid = ""; + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String ORG_ID = m.get("ORG_ID"); + String ORG_CODE = m.get("org_code"); + if (ORG_ID.equals(id)) { + rs.execute("select id,subcompanyid1 from hrmdepartment where departmentcode = '" + ORG_CODE + "'"); + while (rs.next()) { + deptid = Util.null2String(rs.getString("id")); + subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); + res.put("deptid", deptid); + res.put("subcompanyid1", subcompanyid1); + } + } + } + + return res; + } +%> diff --git a/interface/hjkj/updatePostUser.jsp b/interface/hjkj/updatePostUser.jsp new file mode 100644 index 00000000..c931d5fc --- /dev/null +++ b/interface/hjkj/updatePostUser.jsp @@ -0,0 +1,144 @@ +<%@ page import="weaver.interfaces.util.ReadExcel" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="java.util.*" %> +<%@ page import="weaver.general.TimeUtil" %> +<%@ page import="weaver.backup.fkcustomer.FkCustomerBrowserDef" %> + + +<%-- + User: wangj + Design Ideas: +--%> +<%@ page contentType="text/html;charset=UTF-8" %> +<% + ReadExcel r = new ReadExcel(); + RecordSet rs = new RecordSet(); + int scount = 0; + int fcount = 0; + String creater = "1"; + String created = TimeUtil.getCurrentTimeString(); + String modified = TimeUtil.getCurrentTimeString(); + String modifier = "1"; + List> deptlists = r.readExcel("/whalecloud/cos", "organization.xlsx", 0, 0, 0); + List> postlists = r.readExcel("/whalecloud/cos", "system_post.xlsx", 0, 0, 0); + List> lists = r.readExcel("/whalecloud/cos", "system_user_post.xlsx", 0, 0, 0); + List> hrmlists = r.readExcel("/whalecloud/cos", "staff.xlsx", 0, 0, 0); + if (Objects.nonNull(lists)) { + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + + String ORG_ID = Util.null2String(m.get("org_id")); + Map deptres = getSubcompanyid1(deptlists,ORG_ID); + String postCode = Util.null2String(m.get("sys_post_code")); + String userCode =Util.null2String(m.get("staff_code")); + String departmentId = Util.null2String(deptres.get("deptid")); + boolean flag = insertPostUser(postCode, departmentId, userCode); + if (flag) { + scount++; + } else { + fcount++; + } + + } + } + out.print("success:" + scount + ",false:" + fcount); +%> + +<%! + private boolean insertPostUser(String postCode, String departmentId,String userCode) { + RecordSet rs = new RecordSet(); + boolean flag = false; + String jobtitlesId = ""; + String userId = ""; + String currentDateTime = TimeUtil.getCurrentTimeString(); //当前时间 + String updateStaff = "1"; + + String queryRoleIdSql = " select id from hrmjobtitles where jobtitlecode= ?"; + rs.executeQuery(queryRoleIdSql, postCode); + if (rs.next()) { + jobtitlesId = rs.getString("id"); + } + + if("".equals(jobtitlesId)){ + jobtitlesId = "464"; + } + + + + String sql = "select id from hrmresource where loginid = ?"; + rs.executeQuery(sql,userCode); + while (rs.next()) { + userId = Util.null2String(rs.getString("id")); + } + + if (!"".equals(userId) && !"".equals(jobtitlesId)) { + String updateUserJobSql = "update hrmresource set jobtitle=?,modified=?,modifier=? where id=?"; + flag = rs.executeUpdate(updateUserJobSql, jobtitlesId, currentDateTime, updateStaff, userId); + } + return flag; + } +%> + +<%! + private String getUserCode(List> lists, String id) { + String code = ""; + RecordSet rs = new RecordSet(); + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String STAFF_ID = Util.null2String(m.get("staff_id")); + String STAFF_CODE = Util.null2String(m.get("staff_code")); + if (STAFF_ID.equals(id)) { + code= STAFF_CODE; + } + } + return code; + } +%> + +<%! + private Map getSubcompanyid1(List> lists, String id) { + Map res = new HashMap<>(); + RecordSet rs = new RecordSet(); + String subcompanyid1 = ""; + String deptid = ""; + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String ORG_ID = m.get("org_id"); + String ORG_CODE = m.get("org_code"); + if (ORG_ID.equals(id)) { + rs.execute("select id,subcompanyid1 from hrmdepartment where departmentcode = '" + ORG_CODE + "'"); + while (rs.next()) { + deptid = Util.null2String(rs.getString("id")); + subcompanyid1 = Util.null2String(rs.getString("subcompanyid1")); + res.put("deptid", deptid); + res.put("subcompanyid1", subcompanyid1); + } + } + } + + return res; + } +%> + + +<%! + private String getPostCode(List> lists, String id) { + String postcode = ""; + + + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String SYS_POST_CODE = Util.null2String(m.get("sys_post_code")); + String SYS_POST_ID = Util.null2String(m.get("sys_post_id")); + if (SYS_POST_ID.equals(id)) { + postcode = SYS_POST_CODE; + break; + } + } + + return postcode; + } +%> + + diff --git a/interface/hjkj/updateRole.jsp b/interface/hjkj/updateRole.jsp new file mode 100644 index 00000000..07c7cfda --- /dev/null +++ b/interface/hjkj/updateRole.jsp @@ -0,0 +1,68 @@ +<%@ page import="weaver.interfaces.util.ReadExcel" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="java.util.*" %> +<%@ page import="weaver.general.TimeUtil" %> +<%@ page import="weaver.backup.fkcustomer.FkCustomerBrowserDef" %> + + +<%-- + User: wangj + Design Ideas: +--%> +<%@ page contentType="text/html;charset=UTF-8" %> +<% + ReadExcel r = new ReadExcel(); + int scount = 0; + int fcount = 0; + List> lists = r.readExcel("/whalecloud/cos", "system_roles.xlsx", 0, 0, 0); + if (Objects.nonNull(lists)) { + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String SYS_ROLE_CODE = Util.null2String(m.get("SYS_ROLE_CODE")); + String SYS_ROLE_NAME = Util.null2String(m.get("SYS_ROLE_NAME")); + String IS_SYNC = Util.null2String(m.get("IS_SYNC")); + if(!"YES".equals(IS_SYNC)){ + continue; + } + boolean flag = insertRole(SYS_ROLE_CODE, SYS_ROLE_NAME); + if (flag) { + scount++; + } else { + fcount++; + } + + } + } + out.print("success:" + scount + ",false:" + fcount); +%> + +<%! + private boolean insertRole(String sysRoleCode, String sysRoleName) { + boolean flag = false; + RecordSet rs = new RecordSet(); + String rolesmark = "~`~`7 " + sysRoleName + "`~`8 " + sysRoleName + "`~`9 " + sysRoleName + "`~`~"; + String rolesname = "~`~`7 " + sysRoleName + "`~`8 " + sysRoleName + "`~`9 " + sysRoleName + "`~`~"; + String type = "0"; + String subcompanyid = "0"; + String uuid = UUID.randomUUID().toString(); + String queryRoleSql = "select id from hrmroles where ecology_pinyin_search=?"; + rs.executeQuery(queryRoleSql, sysRoleCode); + + String id = ""; + if (rs.next()) { + id = rs.getString("id"); + } + + if ("".equals(id)) { + String insertHrmrolesSql = " insert into hrmroles(rolesmark,rolesname,type,subcompanyid,ecology_pinyin_search,uuid) values(?,?,?,?,?,?)"; + flag = rs.executeUpdate(insertHrmrolesSql, new Object[]{rolesmark, rolesname, type, subcompanyid, sysRoleCode, uuid}); + } else { + String updateHrmrolesSql = " update hrmroles set rolesmark=?,rolesname=? where id=?"; + flag = rs.executeUpdate(updateHrmrolesSql, sysRoleName, sysRoleName, id); + } + return flag; + } +%> + + diff --git a/interface/hjkj/updateRoleUser.jsp b/interface/hjkj/updateRoleUser.jsp new file mode 100644 index 00000000..6dacaefb --- /dev/null +++ b/interface/hjkj/updateRoleUser.jsp @@ -0,0 +1,124 @@ +<%@ page import="weaver.interfaces.util.ReadExcel" %> +<%@ page import="weaver.conn.RecordSet" %> +<%@ page import="weaver.general.Util" %> +<%@ page import="java.util.*" %> +<%@ page import="weaver.general.TimeUtil" %> +<%@ page import="weaver.backup.fkcustomer.FkCustomerBrowserDef" %> +<%@ page import="com.icbc.api.internal.apache.http.impl.cookie.S" %> + + +<%-- + User: wangj + Design Ideas: +--%> +<%@ page contentType="text/html;charset=UTF-8" %> +<% + ReadExcel r = new ReadExcel(); + int scount = 0; + int fcount = 0; + List> rolelists = r.readExcel("/whalecloud/cos", "system_roles.xlsx", 0, 0, 0); + List> userlists = r.readExcel("/whalecloud/cos", "system_roles.xlsx", 0, 0, 0); + List> lists = r.readExcel("/whalecloud/cos", "system_user_role.xlsx", 0, 0, 0); + if (Objects.nonNull(lists)) { + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String SYS_ROLE_ID = Util.null2String(m.get("SYS_ROLE_ID")); + String SYS_USER_ID = Util.null2String(m.get("SYS_USER_ID")); + String SYS_ROLE_CODE = getRoleCode(rolelists,SYS_ROLE_ID); + String SYS_USER_CODE = getUserCode(userlists,SYS_USER_ID); + if (!"".equals(SYS_ROLE_CODE) && !"".equals(SYS_USER_CODE)) { + boolean flag = insertRoleUser(SYS_ROLE_CODE, SYS_USER_CODE); + if (flag) { + scount++; + } else { + fcount++; + } + } + + } + } + out.print("success:" + scount + ",false:" + fcount); +%> + +<%! + private boolean insertRoleUser(String systemUserCode, String roleCode) { + boolean flag = false; + RecordSet rs = new RecordSet(); + + String userId = ""; + String roleId = ""; + String rolelevel = "2"; //总部=2;分部=1;部门=0 + String resourcetype = "1"; //1=人力资源 + + + String sql = " select id from hrmresource where loginid=?"; + rs.executeQuery(sql, new Object[]{systemUserCode}); + if (rs.next()) { + userId = Util.null2String(rs.getString("id")); + } + String queryRoleIdSql = "select id from hrmroles where ecology_pinyin_search=?"; + rs.executeQuery(queryRoleIdSql, roleCode); + if (rs.next()) { + roleId = rs.getString("id"); + } + + if (!"".equals(userId) && !"".equals(roleId)) { + //查看是否已存在角色用户关系 + String releationId = ""; + String ifExistSql = "select id from hrmrolemembers where roleid=? and resourceid=?"; + rs.executeQuery(ifExistSql, roleId, userId); + if (rs.next()) { + releationId = rs.getString("id"); + } + + if (!"".equals(releationId)) { + + String delHrmrolemembersSql = " delete from hrmrolemembers where id = ?"; + flag = rs.executeUpdate(delHrmrolemembersSql, releationId); + + } else { + + String insertHrmrolemembersSql = "insert into hrmrolemembers(roleid,resourceid,rolelevel,resourcetype,uuid) values(?,?,?,?,?)"; + flag = rs.executeUpdate(insertHrmrolemembersSql, roleId, userId, rolelevel, resourcetype, UUID.randomUUID().toString()); + + } + } + + return flag; + } +%> + + +<%! + private String getUserCode(List> lists, String id) { + String code = ""; + RecordSet rs = new RecordSet(); + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String STAFF_ID = Util.null2String(m.get("STAFF_ID")); + String STAFF_CODE = Util.null2String(m.get("STAFF_CODE")); + if (STAFF_ID.equals(id)) { + code= STAFF_CODE; + } + } + return code; + } +%> + +<%! + private String getRoleCode(List> lists, String id) { + String code = ""; + RecordSet rs = new RecordSet(); + for (int i = 0; i < lists.size(); i++) { + Map m = lists.get(i); + String SYS_ROLE_ID = Util.null2String(m.get("SYS_ROLE_ID")); + String SYS_ROLE_CODE = Util.null2String(m.get("SYS_ROLE_CODE")); + if (SYS_ROLE_ID.equals(id)) { + code= SYS_ROLE_CODE; + } + } + return code; + } +%> + + diff --git a/src/weaver/interfaces/util/ReadExcel.java b/src/weaver/interfaces/util/ReadExcel.java new file mode 100644 index 00000000..22c5de16 --- /dev/null +++ b/src/weaver/interfaces/util/ReadExcel.java @@ -0,0 +1,192 @@ +package weaver.interfaces.util; + +/** + * 类的详细说明 + * + * @author wangj + * @version 1.00版本 + * @Date 2022/10/17 + */ + +import org.apache.poi.hssf.usermodel.HSSFCell; +import org.apache.poi.hssf.usermodel.HSSFRow; +import org.apache.poi.hssf.usermodel.HSSFSheet; +import org.apache.poi.hssf.usermodel.HSSFWorkbook; +import org.apache.poi.openxml4j.util.ZipSecureFile; +import org.apache.poi.ss.usermodel.CellType; +import org.apache.poi.xssf.usermodel.XSSFCell; +import org.apache.poi.xssf.usermodel.XSSFRow; +import org.apache.poi.xssf.usermodel.XSSFSheet; +import org.apache.poi.xssf.usermodel.XSSFWorkbook; + +import java.io.File; +import java.io.FileInputStream; +import java.io.InputStream; +import java.util.*; + +/** + * 读取Excel数据 + * @author wangj + * @createTime 2020-11-30 22:54:21 + * @version 1.1 + * @modifyLog 1.1 优化代码 + * + */ +public class ReadExcel { + + /** + * 读取Excel + * @author zql + * @createTime 2020-11-30 22:54:34 + * + * @param filepath 文件路径 + * @param filename 文件名,包括扩展名 + * @param startrow 开始行号,索引从0开始 + * @param startcol 开始列号,索引从0开始 + * @param sheetnum 工作簿,索引从0开始 + * @return + */ + public List> readExcel(String filepath, String filename, int startrow, int startcol, int sheetnum) { + List> varList = new ArrayList>(); + if (filename.endsWith(".xls")) { + varList = this.readExcel2003(filepath, filename, startrow, startcol, sheetnum); + } else if (filename.endsWith(".xlsx")) { + varList = this.readExcel2007(filepath, filename, startrow, startcol, sheetnum); + } else { + System.out.println("Only excel files with XLS or XLSX suffixes are allowed to be read!"); + return null; + } + return varList; + } + + /** + * 读取2003Excel + * @author zql + * @createTime 2020-11-30 22:57:35 + * + * @param filepath 文件路径 + * @param filename 文件名,包括扩展名 + * @param startrow 开始行号,索引从0开始 + * @param startcol 开始列号,索引从0开始 + * @param sheetnum 工作簿,索引从0开始 + * @return + */ + public List> readExcel2003(String filepath, String filename, int startrow, int startcol, int sheetnum) { + List> varList = new ArrayList>(); + try { + ZipSecureFile.setMinInflateRatio(0); + File target = new File(filepath, filename); + FileInputStream fis = new FileInputStream(target); + HSSFWorkbook wb = new HSSFWorkbook(fis); + fis.close(); + // sheet 从0开始 + HSSFSheet sheet = wb.getSheetAt(sheetnum); + // 取得最后一行的行号 + int rowNum = sheet.getLastRowNum() + 1; + + HSSFRow rowTitle = sheet.getRow(0); + // 标题行的最后一个单元格位置 + int cellTitleNum = rowTitle.getLastCellNum(); + String[] title = new String[cellTitleNum]; + for (int i = startcol; i < cellTitleNum; i++) { + HSSFCell cell = rowTitle.getCell(Short.parseShort(String.valueOf(i))); + if (Objects.nonNull(cell)) { + cell.setCellType(CellType.STRING); + title[i] = cell.getStringCellValue(); + } else { + title[i] = ""; + } + } + + // 行循环开始 + for (int i = startrow + 1; i < rowNum; i++) { + Map varpd = new HashMap(); + // 行 + HSSFRow row = sheet.getRow(i); + // 列循环开始 + for (int j = startcol; j < cellTitleNum; j++) { + HSSFCell cell = row.getCell(Short.parseShort(String.valueOf(j))); + String cellValue = ""; + if (Objects.nonNull(cell)) { + // 把类型先设置为字符串类型 + cell.setCellType(CellType.STRING); + cellValue = cell.getStringCellValue(); + } + varpd.put(title[j], cellValue); + } + varList.add(varpd); + } + wb.close(); + } catch (Exception e) { + System.out.println(e); + } + return varList; + } + + /** + * 读取2007Excel + * @author zql + * @createTime 2020-11-30 23:23:20 + * + * @param filepath 文件路径 + * @param filename 文件名,包括扩展名 + * @param startrow 开始行号,索引从0开始 + * @param startcol 开始列号,索引从0开始 + * @param sheetnum 工作簿,索引从0开始 + * @return + */ + public List> readExcel2007(String filepath, String filename, int startrow, int startcol, int sheetnum) { + List> varList = new ArrayList>(); + try { + ZipSecureFile.setMinInflateRatio(0); + File target = new File(filepath, filename); + InputStream ins = new FileInputStream(target); + XSSFWorkbook wb = new XSSFWorkbook(ins); + ins.close(); + // 得到Excel工作表对象 + XSSFSheet sheet = wb.getSheetAt(sheetnum); + // 取得最后一行的行号 + int rowNum = sheet.getLastRowNum() + 1; + + XSSFRow rowTitle = sheet.getRow(0); + int cellTitleNum = rowTitle.getLastCellNum(); + String[] title = new String[cellTitleNum]; + for (int i = startcol; i < cellTitleNum; i++) { + XSSFCell cell = rowTitle.getCell(Short.parseShort(String.valueOf(i))); + if (Objects.nonNull(cell)) { + // 把类型先设置为字符串类型 + cell.setCellType(CellType.STRING); + title[i] = cell.getStringCellValue(); + } else { + title[i] = ""; + } + } + + // 行循环开始 + for (int i = startrow + 1; i < rowNum; i++) { + Map varpd = new HashMap(); + // 得到Excel工作表的行 + XSSFRow row = sheet.getRow(i); + // 列循环开始 + for (int j = startcol; j < cellTitleNum; j++) { + // 得到Excel工作表指定行的单元格 + XSSFCell cell = row.getCell(j); + String cellValue = ""; + if (Objects.nonNull(cell)) { + // 把类型先设置为字符串类型 + cell.setCellType(CellType.STRING); + cellValue = cell.getStringCellValue(); + } + varpd.put(title[j], cellValue); + } + varList.add(varpd); + } + wb.close(); + } catch (Exception e) { + System.out.println(e); + } + return varList; + } + +} +