You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
haojing/interface/hjkj/updatePost.jsp

104 lines
4.1 KiB
Plaintext

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

<%@ 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.*" %>
<%--
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>> lists = r.readExcel("/whalecloud/cos", "system_post.xlsx", 0, 0, 0);
if (Objects.nonNull(lists)) {
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_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<String, String> 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<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;
}
%>