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/updateRole.jsp

70 lines
2.5 KiB
Plaintext

<%@ page import="weaver.conn.RecordSet" %>
<%@ page import="weaver.general.Util" %>
2 years ago
<%@ page import="weaver.interfaces.dito.util.ReadExcel" %>
<%@ page import="java.util.List" %>
<%@ page import="java.util.Map" %>
<%@ page import="java.util.Objects" %>
<%@ page import="java.util.UUID" %>
<%--
User: wangj
Design Ideas
--%>
<%@ page contentType="text/html;charset=UTF-8" %>
<%
ReadExcel r = new ReadExcel();
int scount = 0;
int fcount = 0;
List<Map<String, String>> lists = r.readExcel("/whalecloud/cos", "system_roles.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_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;
}
%>