|
|
<%@ page import="weaver.conn.RecordSet" %>
|
|
|
<%@ page import="weaver.general.TimeUtil" %>
|
|
|
<%@ page import="weaver.general.Util" %>
|
|
|
<%@ page import="weaver.interfaces.dito.util.ReadExcel" %>
|
|
|
<%@ page import="java.util.HashMap" %>
|
|
|
<%@ page import="java.util.List" %>
|
|
|
<%@ page import="java.util.Map" %>
|
|
|
<%@ page import="java.util.Objects" %>
|
|
|
|
|
|
|
|
|
<%--
|
|
|
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<Map<String, String>> deptlists = r.readExcel("/whalecloud/cos", "organization.xlsx", 0, 0, 0);
|
|
|
List<Map<String, String>> postlists = r.readExcel("/whalecloud/cos", "system_post.xlsx", 0, 0, 0);
|
|
|
List<Map<String, String>> lists = r.readExcel("/whalecloud/cos", "system_user_post.xlsx", 0, 0, 0);
|
|
|
List<Map<String, String>> hrmlists = r.readExcel("/whalecloud/cos", "staff.xlsx", 0, 0, 0);
|
|
|
if (Objects.nonNull(lists)) {
|
|
|
for (int i = 0; i < lists.size(); i++) {
|
|
|
Map<String, String> m = lists.get(i);
|
|
|
|
|
|
String ORG_ID = Util.null2String(m.get("org_id"));
|
|
|
Map<String,String> 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<Map<String, String>> lists, String id) {
|
|
|
String code = "";
|
|
|
RecordSet rs = new RecordSet();
|
|
|
for (int i = 0; i < lists.size(); i++) {
|
|
|
Map<String, String> 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<String, String> getSubcompanyid1(List<Map<String, String>> lists, String id) {
|
|
|
Map<String, String> res = new HashMap<>();
|
|
|
RecordSet rs = new RecordSet();
|
|
|
String subcompanyid1 = "";
|
|
|
String deptid = "";
|
|
|
for (int i = 0; i < lists.size(); i++) {
|
|
|
Map<String, String> 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<Map<String, String>> lists, String id) {
|
|
|
String postcode = "";
|
|
|
|
|
|
|
|
|
for (int i = 0; i < lists.size(); i++) {
|
|
|
Map<String, String> 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;
|
|
|
}
|
|
|
%>
|
|
|
|
|
|
|