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.
81 lines
3.5 KiB
Plaintext
81 lines
3.5 KiB
Plaintext
<%@ page import="java.util.List" %>
|
|
<%@ page import="java.util.ArrayList" %>
|
|
<%@ page import="java.io.FileInputStream" %>
|
|
<%@ page import="java.io.File" %>
|
|
<%@ page import="org.apache.poi.ss.usermodel.Workbook" %>
|
|
<%@ page import="org.apache.poi.xssf.usermodel.XSSFWorkbook" %>
|
|
<%@ page import="org.apache.poi.ss.usermodel.Sheet" %>
|
|
<%@ page import="org.apache.poi.ss.usermodel.Row" %>
|
|
<%@ page import="java.util.Iterator" %>
|
|
<%@ page import="weaver.conn.RecordSet" %>
|
|
<%@ page import="com.engine.custom.archives.entity.Dept" %>
|
|
<%@ page import="com.alibaba.fastjson.JSONObject" %>
|
|
|
|
|
|
<%
|
|
List<Dept> depts = readExcelFile("/opt/weaver/filesys/zzxx.xlsx");
|
|
// 输出或处理dept列表
|
|
out.println(depts.size());
|
|
out.println(JSONObject.toJSONString(depts));
|
|
RecordSet recordSet = new RecordSet();
|
|
String comSql = "update hrmsubcompanydefined set DAPYBH = ? where SUBCOMID = (select id from hrmsubcompany where SUBCOMPANYNAME = ? )";
|
|
// String deptByDeptSql = "update hrmdepartmentdefined set DAPYBH = ? where SUBCOMPANYNAME = ? and SUPDEPID = (select * from hrmdepartmentdefined where DAPYBH = ? )";
|
|
// String deptByComSql = "update hrmdepartmentdefined set DAPYBH = ? where SUBCOMPANYNAME = ? and SUPDEPID = (select * from SUBCOMPANYID1 where DAPYBH = ? )";
|
|
String deptSql = "update hrmdepartmentdefined set DAPYBH = ? where deptid in (select id from hrmdepartment where DEPARTMENTNAME = ? ) and deptid in (select id from hrmdepartment where SUBCOMPANYID1 = (select SUBCOMID from hrmsubcompanydefined where DAPYBH = ? ) or SUPDEPID = (select DEPTID from hrmdepartmentdefined where DAPYBH = ? ) )";
|
|
|
|
for (Dept dept : depts) {
|
|
if ("zgs".equals(dept.getType())) {
|
|
continue;
|
|
}
|
|
if ("zonghang".equals(dept.getType())) {
|
|
recordSet.executeUpdate(comSql, dept.getId(), dept.getName());
|
|
}
|
|
if ("zhih".equals(dept.getType()) || "fh".equals(dept.getType())) {
|
|
if ("10".equals(dept.getParentId())) {
|
|
recordSet.executeUpdate(comSql, dept.getId(), dept.getName());
|
|
} else {
|
|
recordSet.executeUpdate(deptSql, dept.getId(), dept.getName(), dept.getParentId(), dept.getParentId());
|
|
}
|
|
}
|
|
if ("ld".equals(dept.getType()) || "bm".equals(dept.getType())) {
|
|
recordSet.executeUpdate(deptSql, dept.getId(), dept.getName(), dept.getParentId(), dept.getParentId());
|
|
}
|
|
}
|
|
|
|
|
|
%>
|
|
|
|
<%!
|
|
public static List<Dept> readExcelFile(String filePath) {
|
|
List<Dept> dept = new ArrayList<>();
|
|
try (FileInputStream fis = new FileInputStream(new File(filePath));
|
|
Workbook workbook = new XSSFWorkbook(fis)) {
|
|
|
|
Sheet sheet = workbook.getSheetAt(0);
|
|
Iterator<Row> rowIterator = sheet.iterator();
|
|
|
|
if (rowIterator.hasNext()) {
|
|
rowIterator.next(); // 跳过标题行
|
|
}
|
|
|
|
while (rowIterator.hasNext()) {
|
|
Row row = rowIterator.next();
|
|
Dept Dept = new Dept();
|
|
Dept.setId(row.getCell(0).getStringCellValue());
|
|
Dept.setName(row.getCell(1).getStringCellValue());
|
|
Dept.setType(row.getCell(2).getStringCellValue());
|
|
Dept.setParentId(row.getCell(3).getStringCellValue());
|
|
Dept.setAllName(row.getCell(4).getStringCellValue());
|
|
// 假设第一列是姓名,第二列是年龄
|
|
dept.add(Dept);
|
|
}
|
|
} catch (Exception e) {
|
|
e.printStackTrace();
|
|
}
|
|
return dept;
|
|
}
|
|
|
|
%>
|
|
|
|
|