|
|
@ -20,6 +20,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查是不是合法的xls文件
|
|
|
|
* 功能:检查是不是合法的xls文件
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-03
|
|
|
|
* 时间:2019-01-03
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
* @throws FileNotFoundException
|
|
|
|
* @throws FileNotFoundException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -28,15 +29,11 @@ public class TeacherImportExcelUtil {
|
|
|
|
//尝试一下是不是有效的xls文件
|
|
|
|
//尝试一下是不是有效的xls文件
|
|
|
|
Workbook wb = null;
|
|
|
|
Workbook wb = null;
|
|
|
|
boolean isValidExcel = false;
|
|
|
|
boolean isValidExcel = false;
|
|
|
|
try
|
|
|
|
try {
|
|
|
|
{
|
|
|
|
|
|
|
|
wb = new HSSFWorkbook(in);
|
|
|
|
wb = new HSSFWorkbook(in);
|
|
|
|
isValidExcel = true;
|
|
|
|
isValidExcel = true;
|
|
|
|
}
|
|
|
|
} finally {
|
|
|
|
finally
|
|
|
|
if (!isValidExcel && wb != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if(!isValidExcel && wb!=null)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
wb.close();
|
|
|
|
wb.close();
|
|
|
|
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
@ -49,6 +46,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查人员的任教日期与出生年月日的关系
|
|
|
|
* 功能:检查人员的任教日期与出生年月日的关系
|
|
|
|
* 任教:黄海
|
|
|
|
* 任教:黄海
|
|
|
|
* 时间:2019-01-10
|
|
|
|
* 时间:2019-01-10
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param templateXls
|
|
|
|
* @param templateXls
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
* @throws FileNotFoundException
|
|
|
|
* @throws FileNotFoundException
|
|
|
@ -64,11 +62,9 @@ public class TeacherImportExcelUtil {
|
|
|
|
//遍历每一个人进行检查
|
|
|
|
//遍历每一个人进行检查
|
|
|
|
boolean success = true;
|
|
|
|
boolean success = true;
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
for (Row row : sheet1)
|
|
|
|
for (Row row : sheet1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
//放过行首
|
|
|
|
//放过行首
|
|
|
|
if(count <1)
|
|
|
|
if (count < 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -93,13 +89,10 @@ public class TeacherImportExcelUtil {
|
|
|
|
c.add(Calendar.YEAR, 16);
|
|
|
|
c.add(Calendar.YEAR, 16);
|
|
|
|
d_birthday = c.getTime();
|
|
|
|
d_birthday = c.getTime();
|
|
|
|
int i = d_teach_date.compareTo(d_birthday);
|
|
|
|
int i = d_teach_date.compareTo(d_birthday);
|
|
|
|
if(i<0)
|
|
|
|
if (i < 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
success = false;
|
|
|
|
success = false;
|
|
|
|
row.getCell(10).setCellStyle(redStyle);
|
|
|
|
row.getCell(10).setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
row.getCell(10).setCellStyle(whileStyle);
|
|
|
|
row.getCell(10).setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -109,22 +102,17 @@ public class TeacherImportExcelUtil {
|
|
|
|
wb.write(excelFileOutPutStream);
|
|
|
|
wb.write(excelFileOutPutStream);
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
|
|
|
|
|
|
|
|
if(wb!=null)
|
|
|
|
if (wb != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
wb.close();
|
|
|
|
wb.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(in!=null)
|
|
|
|
if (in != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(success)
|
|
|
|
if (success) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("message", "检查通过!");
|
|
|
|
jo.put("message", "检查通过!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "存在任教年月日在出生日期后16年之内的日期,请下载模板进行检查!");
|
|
|
|
jo.put("message", "存在任教年月日在出生日期后16年之内的日期,请下载模板进行检查!");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -135,21 +123,19 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查是不是用于教师批量导入的模板
|
|
|
|
* 功能:检查是不是用于教师批量导入的模板
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-03
|
|
|
|
* 时间:2019-01-03
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param wb
|
|
|
|
* @param wb
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static Sheet getSheetByWorkbook(Workbook wb,String templateJson)
|
|
|
|
public static Sheet getSheetByWorkbook(Workbook wb, String templateJson) {
|
|
|
|
{
|
|
|
|
|
|
|
|
// 检查sheet表个数
|
|
|
|
// 检查sheet表个数
|
|
|
|
int sheetCount = wb.getNumberOfSheets();
|
|
|
|
int sheetCount = wb.getNumberOfSheets();
|
|
|
|
String sheet1Name = "教师导入模板";
|
|
|
|
String sheet1Name = "教师导入模板";
|
|
|
|
String sheet2Name = "学科隐藏Sheet";
|
|
|
|
String sheet2Name = "学科隐藏Sheet";
|
|
|
|
if(sheetCount!=2)
|
|
|
|
if (sheetCount != 2) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!wb.getSheetName(0).equals(sheet1Name) || !wb.getSheetName(1).equals(sheet2Name))
|
|
|
|
if (!wb.getSheetName(0).equals(sheet1Name) || !wb.getSheetName(1).equals(sheet2Name)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//检查列数
|
|
|
|
//检查列数
|
|
|
@ -159,8 +145,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
//实际列数
|
|
|
|
//实际列数
|
|
|
|
Sheet sheet1 = wb.getSheetAt(0);
|
|
|
|
Sheet sheet1 = wb.getSheetAt(0);
|
|
|
|
int nowCols = sheet1.getRow(0).getPhysicalNumberOfCells();
|
|
|
|
int nowCols = sheet1.getRow(0).getPhysicalNumberOfCells();
|
|
|
|
if(needCols!=nowCols)
|
|
|
|
if (needCols != nowCols) {
|
|
|
|
{
|
|
|
|
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return sheet1;
|
|
|
|
return sheet1;
|
|
|
@ -170,23 +155,21 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查是不是有空值
|
|
|
|
* 功能:检查是不是有空值
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-03
|
|
|
|
* 时间:2019-01-03
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param sheet1
|
|
|
|
* @param sheet1
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static JSONObject checkHaveBlankError(Sheet sheet1, CellStyle redStyle, CellStyle whileStyle)
|
|
|
|
private static JSONObject checkHaveBlankError(Sheet sheet1, CellStyle redStyle, CellStyle whileStyle) {
|
|
|
|
{
|
|
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
boolean Error = false;
|
|
|
|
boolean Error = false;
|
|
|
|
//一共多少列?
|
|
|
|
//一共多少列?
|
|
|
|
int nowCols = sheet1.getRow(0).getPhysicalNumberOfCells();
|
|
|
|
int nowCols = sheet1.getRow(0).getPhysicalNumberOfCells();
|
|
|
|
//遍历每一行
|
|
|
|
//遍历每一行
|
|
|
|
for (Row row : sheet1)
|
|
|
|
for (Row row : sheet1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
//放过行首
|
|
|
|
//放过行首
|
|
|
|
if(count <1)
|
|
|
|
if (count < 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -194,17 +177,13 @@ public class TeacherImportExcelUtil {
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
for (int i = 1; i < nowCols; i++)
|
|
|
|
for (int i = 1; i < nowCols; i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Cell cell = row.getCell(i);
|
|
|
|
Cell cell = row.getCell(i);
|
|
|
|
if(cell==null || cell.toString().equals(""))
|
|
|
|
if (cell == null || cell.toString().equals("")) {
|
|
|
|
{
|
|
|
|
|
|
|
|
cell = row.createCell(i);
|
|
|
|
cell = row.createCell(i);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
Error = true;
|
|
|
|
Error = true;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -218,11 +197,11 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查输入的项目是不是在合法的值域内
|
|
|
|
* 功能:检查输入的项目是不是在合法的值域内
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-03
|
|
|
|
* 时间:2019-01-03
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param sheet1
|
|
|
|
* @param sheet1
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static boolean checkValidValue(Sheet sheet1,CellStyle redStyle,CellStyle whileStyle)
|
|
|
|
private static boolean checkValidValue(Sheet sheet1, CellStyle redStyle, CellStyle whileStyle) {
|
|
|
|
{
|
|
|
|
|
|
|
|
boolean isRangeValid = true;
|
|
|
|
boolean isRangeValid = true;
|
|
|
|
//4、检查数据的值域是不是有效
|
|
|
|
//4、检查数据的值域是不是有效
|
|
|
|
Map mapMz = ImportBindUtil.bindMz(); //民族
|
|
|
|
Map mapMz = ImportBindUtil.bindMz(); //民族
|
|
|
@ -234,11 +213,9 @@ public class TeacherImportExcelUtil {
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
int nowCols = sheet1.getRow(0).getPhysicalNumberOfCells();
|
|
|
|
int nowCols = sheet1.getRow(0).getPhysicalNumberOfCells();
|
|
|
|
|
|
|
|
|
|
|
|
for (Row row : sheet1)
|
|
|
|
for (Row row : sheet1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
//放过行首
|
|
|
|
//放过行首
|
|
|
|
if(count <1)
|
|
|
|
if (count < 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -250,68 +227,51 @@ public class TeacherImportExcelUtil {
|
|
|
|
Cell stageCell = null;
|
|
|
|
Cell stageCell = null;
|
|
|
|
String subject_name = "";
|
|
|
|
String subject_name = "";
|
|
|
|
Cell subjectCell = null;
|
|
|
|
Cell subjectCell = null;
|
|
|
|
for (int i = 0; i < nowCols; i++)
|
|
|
|
for (int i = 0; i < nowCols; i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Cell cell = row.getCell(i);
|
|
|
|
Cell cell = row.getCell(i);
|
|
|
|
switch (i)
|
|
|
|
switch (i) {
|
|
|
|
{
|
|
|
|
|
|
|
|
//性别
|
|
|
|
//性别
|
|
|
|
case 2:
|
|
|
|
case 2:
|
|
|
|
if(!mapXb.containsKey(getValue(cell).toString().trim()))
|
|
|
|
if (!mapXb.containsKey(getValue(cell).toString().trim())) {
|
|
|
|
{
|
|
|
|
|
|
|
|
isRangeValid = false;
|
|
|
|
isRangeValid = false;
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
//民族
|
|
|
|
//民族
|
|
|
|
case 3:
|
|
|
|
case 3:
|
|
|
|
if(!mapMz.containsKey(getValue(cell).toString().trim()))
|
|
|
|
if (!mapMz.containsKey(getValue(cell).toString().trim())) {
|
|
|
|
{
|
|
|
|
|
|
|
|
isRangeValid = false;
|
|
|
|
isRangeValid = false;
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
//政治面貌
|
|
|
|
//政治面貌
|
|
|
|
case 4:
|
|
|
|
case 4:
|
|
|
|
if(!mapZzmm.containsKey(getValue(cell).toString().trim()))
|
|
|
|
if (!mapZzmm.containsKey(getValue(cell).toString().trim())) {
|
|
|
|
{
|
|
|
|
|
|
|
|
isRangeValid = false;
|
|
|
|
isRangeValid = false;
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
//学历
|
|
|
|
//学历
|
|
|
|
case 6:
|
|
|
|
case 6:
|
|
|
|
if(!mapXl.containsKey(getValue(cell).toString().trim()))
|
|
|
|
if (!mapXl.containsKey(getValue(cell).toString().trim())) {
|
|
|
|
{
|
|
|
|
|
|
|
|
isRangeValid = false;
|
|
|
|
isRangeValid = false;
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
//职称
|
|
|
|
//职称
|
|
|
|
case 7:
|
|
|
|
case 7:
|
|
|
|
if(!mapZc.containsKey(getValue(cell).toString().trim()))
|
|
|
|
if (!mapZc.containsKey(getValue(cell).toString().trim())) {
|
|
|
|
{
|
|
|
|
|
|
|
|
isRangeValid = false;
|
|
|
|
isRangeValid = false;
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
cell.setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
break;
|
|
|
@ -327,8 +287,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
//从教年月日
|
|
|
|
//从教年月日
|
|
|
|
case 10:
|
|
|
|
case 10:
|
|
|
|
if(!CommonUtil.isValidDate(getValue(cell).toString().trim().replace("/","-")))
|
|
|
|
if (!CommonUtil.isValidDate(getValue(cell).toString().trim().replace("/", "-"))) {
|
|
|
|
{
|
|
|
|
|
|
|
|
isRangeValid = false;
|
|
|
|
isRangeValid = false;
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
cell.setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -336,14 +295,11 @@ public class TeacherImportExcelUtil {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果学段科目正确
|
|
|
|
//如果学段科目正确
|
|
|
|
if(!mapstageSubject.containsKey(stage_name+subject_name))
|
|
|
|
if (!mapstageSubject.containsKey(stage_name + subject_name)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
isRangeValid = false;
|
|
|
|
isRangeValid = false;
|
|
|
|
stageCell.setCellStyle(redStyle);
|
|
|
|
stageCell.setCellStyle(redStyle);
|
|
|
|
subjectCell.setCellStyle(redStyle);
|
|
|
|
subjectCell.setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
stageCell.setCellStyle(whileStyle);
|
|
|
|
stageCell.setCellStyle(whileStyle);
|
|
|
|
subjectCell.setCellStyle(whileStyle);
|
|
|
|
subjectCell.setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -355,6 +311,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:获取指定单元格的值
|
|
|
|
* 功能:获取指定单元格的值
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-01
|
|
|
|
* 时间:2019-01-01
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param cell
|
|
|
|
* @param cell
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -383,38 +340,31 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查身份证号是不是存在问题
|
|
|
|
* 功能:检查身份证号是不是存在问题
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-03
|
|
|
|
* 时间:2019-01-03
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param sheet1
|
|
|
|
* @param sheet1
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private static List<String> getNoValidCardNoList(Sheet sheet1,CellStyle redStyle,CellStyle whileStyle)
|
|
|
|
private static List<String> getNoValidCardNoList(Sheet sheet1, CellStyle redStyle, CellStyle whileStyle) {
|
|
|
|
{
|
|
|
|
|
|
|
|
List<String> NoValidCardList = new ArrayList<>();
|
|
|
|
List<String> NoValidCardList = new ArrayList<>();
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
for (Row row : sheet1)
|
|
|
|
for (Row row : sheet1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
//放过行首
|
|
|
|
//放过行首
|
|
|
|
if(count <1)
|
|
|
|
if (count < 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String cardNo = row.getCell(5).getStringCellValue().trim();
|
|
|
|
String cardNo = row.getCell(5).getStringCellValue().trim();
|
|
|
|
JSONObject jo = IDCardUtil.IDCardValidate(cardNo);
|
|
|
|
JSONObject jo = IDCardUtil.IDCardValidate(cardNo);
|
|
|
|
if(!(boolean)jo.get("success"))
|
|
|
|
if (!(boolean) jo.get("success")) {
|
|
|
|
{
|
|
|
|
|
|
|
|
row.getCell(5).setCellStyle(redStyle);
|
|
|
|
row.getCell(5).setCellStyle(redStyle);
|
|
|
|
NoValidCardList.add(cardNo);
|
|
|
|
NoValidCardList.add(cardNo);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
row.getCell(5).setCellStyle(whileStyle);
|
|
|
|
row.getCell(5).setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -425,37 +375,30 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查某个sheet中重复的身份证号数量
|
|
|
|
* 功能:检查某个sheet中重复的身份证号数量
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-3
|
|
|
|
* 时间:2019-01-3
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param sheet1
|
|
|
|
* @param sheet1
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static Map<String,Integer> CheckCardNoRepeatInExcel(Sheet sheet1,CellStyle redStyle,CellStyle whileStyle)
|
|
|
|
public static Map<String, Integer> CheckCardNoRepeatInExcel(Sheet sheet1, CellStyle redStyle, CellStyle whileStyle) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Map<String, Integer> map = new HashMap<>();
|
|
|
|
Map<String, Integer> map = new HashMap<>();
|
|
|
|
int count = 0;
|
|
|
|
int count = 0;
|
|
|
|
for (Row row : sheet1)
|
|
|
|
for (Row row : sheet1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
//放过行首
|
|
|
|
//放过行首
|
|
|
|
if(count <1)
|
|
|
|
if (count < 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String cardNo = row.getCell(5).getStringCellValue().trim();
|
|
|
|
String cardNo = row.getCell(5).getStringCellValue().trim();
|
|
|
|
if(map.containsKey(cardNo))
|
|
|
|
if (map.containsKey(cardNo)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
map.put(cardNo, map.get(cardNo) + 1);
|
|
|
|
map.put(cardNo, map.get(cardNo) + 1);
|
|
|
|
row.getCell(5).setCellStyle(redStyle);
|
|
|
|
row.getCell(5).setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
map.put(cardNo, 1);
|
|
|
|
map.put(cardNo, 1);
|
|
|
|
row.getCell(5).setCellStyle(whileStyle);
|
|
|
|
row.getCell(5).setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -468,6 +411,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:将本次的导入结果保存到数据库中
|
|
|
|
* 功能:将本次的导入结果保存到数据库中
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-04
|
|
|
|
* 时间:2019-01-04
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param bureau_id
|
|
|
|
* @param bureau_id
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
@ -477,14 +421,11 @@ public class TeacherImportExcelUtil {
|
|
|
|
String main_school_id;
|
|
|
|
String main_school_id;
|
|
|
|
OrganizationModel orgModel = new OrganizationModel();
|
|
|
|
OrganizationModel orgModel = new OrganizationModel();
|
|
|
|
List<Record> rs = orgModel.getAreaIdByParentId(bureau_id);
|
|
|
|
List<Record> rs = orgModel.getAreaIdByParentId(bureau_id);
|
|
|
|
if(rs!=null && rs.size()>0)
|
|
|
|
if (rs != null && rs.size() > 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
city_id = rs.get(0).getStr("city_id");
|
|
|
|
city_id = rs.get(0).getStr("city_id");
|
|
|
|
area_id = rs.get(0).getStr("area_id");
|
|
|
|
area_id = rs.get(0).getStr("area_id");
|
|
|
|
main_school_id = rs.get(0).getStr("main_school_id");
|
|
|
|
main_school_id = rs.get(0).getStr("main_school_id");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
city_id = "-1";
|
|
|
|
city_id = "-1";
|
|
|
|
area_id = "-1";
|
|
|
|
area_id = "-1";
|
|
|
|
main_school_id = "-1";
|
|
|
|
main_school_id = "-1";
|
|
|
@ -497,23 +438,19 @@ public class TeacherImportExcelUtil {
|
|
|
|
sql = Db.getSql("organization.getFirstLevelOrgName");
|
|
|
|
sql = Db.getSql("organization.getFirstLevelOrgName");
|
|
|
|
List<Record> rsOrgHavingName = Db.find(sql, bureau_id, bureau_id);
|
|
|
|
List<Record> rsOrgHavingName = Db.find(sql, bureau_id, bureau_id);
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
Map<String, String> map = new HashMap<>();
|
|
|
|
for(int i=0;i<rsOrgHavingName.size();i++)
|
|
|
|
for (int i = 0; i < rsOrgHavingName.size(); i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
map.put(rsOrgHavingName.get(i).getStr("org_name"), rsOrgHavingName.get(i).getStr("org_id"));
|
|
|
|
map.put(rsOrgHavingName.get(i).getStr("org_name"), rsOrgHavingName.get(i).getStr("org_id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
List<String> list = new ArrayList<>();
|
|
|
|
for(int i=0;i<rsOrgName.size();i++)
|
|
|
|
for (int i = 0; i < rsOrgName.size(); i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
String cName = rsOrgName.get(i).getStr("org_name");
|
|
|
|
String cName = rsOrgName.get(i).getStr("org_name");
|
|
|
|
if(!map.containsKey(cName))
|
|
|
|
if (!map.containsKey(cName)) {
|
|
|
|
{
|
|
|
|
|
|
|
|
list.add(cName);
|
|
|
|
list.add(cName);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
List<Record> rsImport = new ArrayList<>();
|
|
|
|
List<Record> rsImport = new ArrayList<>();
|
|
|
|
//批量增加
|
|
|
|
//批量增加
|
|
|
|
for(int i=0;i<list.size();i++)
|
|
|
|
for (int i = 0; i < list.size(); i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
String nowTime = CommonUtil.GetCurrentTimeString();
|
|
|
|
String nowTime = CommonUtil.GetCurrentTimeString();
|
|
|
|
Record record = new Record();
|
|
|
|
Record record = new Record();
|
|
|
|
String org_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
String org_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
@ -544,16 +481,14 @@ public class TeacherImportExcelUtil {
|
|
|
|
sql = Db.getSql("organization.getFirstLevelOrgName");
|
|
|
|
sql = Db.getSql("organization.getFirstLevelOrgName");
|
|
|
|
rsOrgHavingName = Db.find(sql, bureau_id, bureau_id);
|
|
|
|
rsOrgHavingName = Db.find(sql, bureau_id, bureau_id);
|
|
|
|
map = new HashMap<>();
|
|
|
|
map = new HashMap<>();
|
|
|
|
for(int i=0;i<rsOrgHavingName.size();i++)
|
|
|
|
for (int i = 0; i < rsOrgHavingName.size(); i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
map.put(rsOrgHavingName.get(i).getStr("org_name"), rsOrgHavingName.get(i).getStr("org_id"));
|
|
|
|
map.put(rsOrgHavingName.get(i).getStr("org_name"), rsOrgHavingName.get(i).getStr("org_id"));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//查找所有本次导入的部门进行回写
|
|
|
|
//查找所有本次导入的部门进行回写
|
|
|
|
sql = Db.getSql("loginPerson.selectBatchInfoTeacher");
|
|
|
|
sql = Db.getSql("loginPerson.selectBatchInfoTeacher");
|
|
|
|
rs = Db.find(sql, batch_id);
|
|
|
|
rs = Db.find(sql, batch_id);
|
|
|
|
List<Record> fixList = new ArrayList<>();
|
|
|
|
List<Record> fixList = new ArrayList<>();
|
|
|
|
for(int i=0;i<rs.size();i++)
|
|
|
|
for (int i = 0; i < rs.size(); i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
Record record = new Record();
|
|
|
|
Record record = new Record();
|
|
|
|
int id = rs.get(i).getInt("id");
|
|
|
|
int id = rs.get(i).getInt("id");
|
|
|
|
String org_name = rs.get(i).getStr("org_name");
|
|
|
|
String org_name = rs.get(i).getStr("org_name");
|
|
|
@ -576,8 +511,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
//4.2 写入人员表
|
|
|
|
//4.2 写入人员表
|
|
|
|
long AllPk = PkUtil.GetPersonNumPk(5, rs.size());
|
|
|
|
long AllPk = PkUtil.GetPersonNumPk(5, rs.size());
|
|
|
|
List<Record> saveRs = new ArrayList<>();
|
|
|
|
List<Record> saveRs = new ArrayList<>();
|
|
|
|
for(int i=0;i<rs.size();i++)
|
|
|
|
for (int i = 0; i < rs.size(); i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
long pk = AllPk - rs.size() + i + 1;
|
|
|
|
long pk = AllPk - rs.size() + i + 1;
|
|
|
|
Record record = new Record();
|
|
|
|
Record record = new Record();
|
|
|
|
String loginName = "tea" + pk;
|
|
|
|
String loginName = "tea" + pk;
|
|
|
@ -594,7 +528,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
record.set("mz", rs.get(i).getStr("mz_id"));
|
|
|
|
record.set("mz", rs.get(i).getStr("mz_id"));
|
|
|
|
|
|
|
|
|
|
|
|
//对身份证号进行加密处理
|
|
|
|
//对身份证号进行加密处理
|
|
|
|
String idcard_code= MysqlAesUtil.Encrypt(rs.get(i).getStr("idcard_code"));
|
|
|
|
String idcard_code = rs.get(i).getStr("idcard_code");
|
|
|
|
record.set("idcard_code", idcard_code);
|
|
|
|
record.set("idcard_code", idcard_code);
|
|
|
|
|
|
|
|
|
|
|
|
//根据身份证号换算出生日期
|
|
|
|
//根据身份证号换算出生日期
|
|
|
@ -635,6 +569,7 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查是不是合法的xls文件
|
|
|
|
* 功能:检查是不是合法的xls文件
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-04
|
|
|
|
* 时间:2019-01-04
|
|
|
|
|
|
|
|
*
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static JSONObject IsValidXls(String templateXls) throws IOException {
|
|
|
|
public static JSONObject IsValidXls(String templateXls) throws IOException {
|
|
|
@ -647,46 +582,36 @@ public class TeacherImportExcelUtil {
|
|
|
|
|
|
|
|
|
|
|
|
//检查是不是EXCEL文件
|
|
|
|
//检查是不是EXCEL文件
|
|
|
|
File excelFile = new File(templateXls); // 创建文件对象
|
|
|
|
File excelFile = new File(templateXls); // 创建文件对象
|
|
|
|
if(!excelFile.exists())
|
|
|
|
if (!excelFile.exists()) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "文件不存在!!");
|
|
|
|
jo.put("message", "文件不存在!!");
|
|
|
|
return jo;
|
|
|
|
return jo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(!excelFile.getName().endsWith("xls"))
|
|
|
|
if (!excelFile.getName().endsWith("xls")) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "只接收xls格式文件!");
|
|
|
|
jo.put("message", "只接收xls格式文件!");
|
|
|
|
return jo;
|
|
|
|
return jo;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
|
FileInputStream in = new FileInputStream(excelFile); // 文件流
|
|
|
|
Workbook wb = getWorkbook(in);
|
|
|
|
Workbook wb = getWorkbook(in);
|
|
|
|
if(wb==null)
|
|
|
|
if (wb == null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "不是EXCEL文件格式!");
|
|
|
|
jo.put("message", "不是EXCEL文件格式!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//检查是不是符合我们要求的模板
|
|
|
|
//检查是不是符合我们要求的模板
|
|
|
|
Sheet sheet1 = getSheetByWorkbook(wb, templateJson);
|
|
|
|
Sheet sheet1 = getSheetByWorkbook(wb, templateJson);
|
|
|
|
if(sheet1==null)
|
|
|
|
if (sheet1 == null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "不是符合要求的模板文件!");
|
|
|
|
jo.put("message", "不是符合要求的模板文件!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("message", "是符合要求的模板文件!");
|
|
|
|
jo.put("message", "是符合要求的模板文件!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(in!=null)
|
|
|
|
if (in != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(wb!=null)
|
|
|
|
if (wb != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
wb.close();
|
|
|
|
wb.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return jo;
|
|
|
|
return jo;
|
|
|
@ -696,11 +621,11 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查xls文件是不是存在空值
|
|
|
|
* 功能:检查xls文件是不是存在空值
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-04
|
|
|
|
* 时间:2019-01-04
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param templateXls
|
|
|
|
* @param templateXls
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static JSONObject IsHaveBlank(String templateXls) throws IOException
|
|
|
|
public static JSONObject IsHaveBlank(String templateXls) throws IOException {
|
|
|
|
{
|
|
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
|
|
|
|
|
|
|
|
FileInputStream in = new FileInputStream(templateXls); // 文件流
|
|
|
|
FileInputStream in = new FileInputStream(templateXls); // 文件流
|
|
|
@ -722,31 +647,23 @@ public class TeacherImportExcelUtil {
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
|
|
|
|
|
|
|
|
//2、检查是不是都完整填写
|
|
|
|
//2、检查是不是都完整填写
|
|
|
|
if(ErrorBlankJO.getBoolean("Error"))
|
|
|
|
if (ErrorBlankJO.getBoolean("Error")) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "发现有个人信息为空的列,不能继续,请检查后重新提交!");
|
|
|
|
jo.put("message", "发现有个人信息为空的列,不能继续,请检查后重新提交!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
if (ErrorBlankJO.getInteger("count") == 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if(ErrorBlankJO.getInteger("count")==0)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "检查发现是一个空的表格,不能上传!");
|
|
|
|
jo.put("message", "检查发现是一个空的表格,不能上传!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("message", "检查通过,不存在空值的项!");
|
|
|
|
jo.put("message", "检查通过,不存在空值的项!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(in!=null)
|
|
|
|
if (in != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(wb!=null)
|
|
|
|
if (wb != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
wb.close();
|
|
|
|
wb.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return jo;
|
|
|
|
return jo;
|
|
|
@ -756,12 +673,12 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查是不是存在值域不正确的数据
|
|
|
|
* 功能:检查是不是存在值域不正确的数据
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-04
|
|
|
|
* 时间:2019-01-04
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param templateXls
|
|
|
|
* @param templateXls
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
* @throws IOException
|
|
|
|
* @throws IOException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static JSONObject IsHaveErrorData(String templateXls) throws IOException
|
|
|
|
public static JSONObject IsHaveErrorData(String templateXls) throws IOException {
|
|
|
|
{
|
|
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
// 文件流
|
|
|
|
// 文件流
|
|
|
|
FileInputStream in = new FileInputStream(templateXls);
|
|
|
|
FileInputStream in = new FileInputStream(templateXls);
|
|
|
@ -780,21 +697,17 @@ public class TeacherImportExcelUtil {
|
|
|
|
wb.write(excelFileOutPutStream);
|
|
|
|
wb.write(excelFileOutPutStream);
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
|
|
|
|
|
|
|
|
if(ErrorRange)
|
|
|
|
if (ErrorRange) {
|
|
|
|
{ jo.put("success",false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "发现值域不正确的单元格,不能继续,请检查后重新提交!");
|
|
|
|
jo.put("message", "发现值域不正确的单元格,不能继续,请检查后重新提交!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("message", "检查通过!");
|
|
|
|
jo.put("message", "检查通过!");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(in!=null)
|
|
|
|
if (in != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(wb!=null)
|
|
|
|
if (wb != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
wb.close();
|
|
|
|
wb.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return jo;
|
|
|
|
return jo;
|
|
|
@ -805,11 +718,11 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查指定的文件是不是存在xls中身份证号重复
|
|
|
|
* 功能:检查指定的文件是不是存在xls中身份证号重复
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-03
|
|
|
|
* 时间:2019-01-03
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param templateXls
|
|
|
|
* @param templateXls
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static JSONObject CheckXlsCardNoDuplicate(String templateXls) throws IOException
|
|
|
|
public static JSONObject CheckXlsCardNoDuplicate(String templateXls) throws IOException {
|
|
|
|
{
|
|
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
FileInputStream in = new FileInputStream(templateXls);
|
|
|
|
FileInputStream in = new FileInputStream(templateXls);
|
|
|
|
Workbook wb = getWorkbook(in);
|
|
|
|
Workbook wb = getWorkbook(in);
|
|
|
@ -820,29 +733,22 @@ public class TeacherImportExcelUtil {
|
|
|
|
|
|
|
|
|
|
|
|
//进行身份证号的检查,检查是不是合法
|
|
|
|
//进行身份证号的检查,检查是不是合法
|
|
|
|
List<String> CardNoList = getNoValidCardNoList(sheet1, redStyle, whileStyle);
|
|
|
|
List<String> CardNoList = getNoValidCardNoList(sheet1, redStyle, whileStyle);
|
|
|
|
if(CardNoList!=null && CardNoList.size()>0)
|
|
|
|
if (CardNoList != null && CardNoList.size() > 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "存在身份证号不合法的人员,请下载模板后检查!");
|
|
|
|
jo.put("message", "存在身份证号不合法的人员,请下载模板后检查!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
//进行身份证号重复的检查
|
|
|
|
//进行身份证号重复的检查
|
|
|
|
Map<String, Integer> map = CheckCardNoRepeatInExcel(sheet1, redStyle, whileStyle);
|
|
|
|
Map<String, Integer> map = CheckCardNoRepeatInExcel(sheet1, redStyle, whileStyle);
|
|
|
|
CardNoList.clear();
|
|
|
|
CardNoList.clear();
|
|
|
|
for (Map.Entry<String, Integer> entry : map.entrySet())
|
|
|
|
for (Map.Entry<String, Integer> entry : map.entrySet()) {
|
|
|
|
{
|
|
|
|
if (entry.getValue() > 1) {
|
|
|
|
if(entry.getValue()>1)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
CardNoList.add(entry.getKey());
|
|
|
|
CardNoList.add(entry.getKey());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(CardNoList!=null && CardNoList.size()>0)
|
|
|
|
if (CardNoList != null && CardNoList.size() > 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "EXCEL文件中存在身份证号重复的人员,请下载模板后检查!");
|
|
|
|
jo.put("message", "EXCEL文件中存在身份证号重复的人员,请下载模板后检查!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else{
|
|
|
|
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("message", "EXCEL文件中不存在身份证号重复的人员!");
|
|
|
|
jo.put("message", "EXCEL文件中不存在身份证号重复的人员!");
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -852,12 +758,10 @@ public class TeacherImportExcelUtil {
|
|
|
|
wb.write(excelFileOutPutStream);
|
|
|
|
wb.write(excelFileOutPutStream);
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
|
|
|
|
|
|
|
|
if(wb!=null)
|
|
|
|
if (wb != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
wb.close();
|
|
|
|
wb.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(in!=null)
|
|
|
|
if (in != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return jo;
|
|
|
|
return jo;
|
|
|
@ -867,13 +771,13 @@ public class TeacherImportExcelUtil {
|
|
|
|
* 功能:检查指定的文件是不是存在与mysql数据库中已有人员身份证号重复的问题
|
|
|
|
* 功能:检查指定的文件是不是存在与mysql数据库中已有人员身份证号重复的问题
|
|
|
|
* 作者:黄海
|
|
|
|
* 作者:黄海
|
|
|
|
* 时间:2019-01-04
|
|
|
|
* 时间:2019-01-04
|
|
|
|
|
|
|
|
*
|
|
|
|
* @param templateXls
|
|
|
|
* @param templateXls
|
|
|
|
* @param bureau_id
|
|
|
|
* @param bureau_id
|
|
|
|
* @return
|
|
|
|
* @return
|
|
|
|
* @throws IOException
|
|
|
|
* @throws IOException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static JSONObject CheckMysqlCardNoDuplicate(String templateXls, String bureau_id) throws Exception
|
|
|
|
public static JSONObject CheckMysqlCardNoDuplicate(String templateXls, String bureau_id) throws Exception {
|
|
|
|
{
|
|
|
|
|
|
|
|
FileInputStream in = new FileInputStream(templateXls);
|
|
|
|
FileInputStream in = new FileInputStream(templateXls);
|
|
|
|
Workbook wb = getWorkbook(in);
|
|
|
|
Workbook wb = getWorkbook(in);
|
|
|
|
Sheet sheet1 = wb.getSheetAt(0);
|
|
|
|
Sheet sheet1 = wb.getSheetAt(0);
|
|
|
@ -894,20 +798,16 @@ public class TeacherImportExcelUtil {
|
|
|
|
String batch_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
String batch_id = UUID.randomUUID().toString().toUpperCase();
|
|
|
|
|
|
|
|
|
|
|
|
List<Record> records = new ArrayList<>();
|
|
|
|
List<Record> records = new ArrayList<>();
|
|
|
|
for (Row row : sheet1)
|
|
|
|
for (Row row : sheet1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
//放过行首
|
|
|
|
//放过行首
|
|
|
|
if(count <1)
|
|
|
|
if (count < 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).getStringCellValue().equals("")) {
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).getStringCellValue().equals("")) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String org_name = row.getCell(0).getStringCellValue().trim();
|
|
|
|
String org_name = row.getCell(0).getStringCellValue().trim();
|
|
|
@ -929,17 +829,15 @@ public class TeacherImportExcelUtil {
|
|
|
|
record.set("person_name", person_name);
|
|
|
|
record.set("person_name", person_name);
|
|
|
|
record.set("xb_id", mapXb.get(xb_name));
|
|
|
|
record.set("xb_id", mapXb.get(xb_name));
|
|
|
|
|
|
|
|
|
|
|
|
if(mapMz.get(mz_name)==null)
|
|
|
|
if (mapMz.get(mz_name) == null) {
|
|
|
|
{
|
|
|
|
for (Object key : mapMz.keySet()) {
|
|
|
|
for (Object key : mapMz.keySet())
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Object value = mapMz.get(key);
|
|
|
|
Object value = mapMz.get(key);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
record.set("mz_id", mapMz.get(mz_name));
|
|
|
|
record.set("mz_id", mapMz.get(mz_name));
|
|
|
|
record.set("zzmm_id", mapZzmm.get(zzmm_name));
|
|
|
|
record.set("zzmm_id", mapZzmm.get(zzmm_name));
|
|
|
|
record.set("idcard_code", idcard_code);
|
|
|
|
record.set("idcard_code", idcard_code);
|
|
|
|
record.set("idcard_code_aes",MysqlAesUtil.Encrypt(idcard_code));
|
|
|
|
record.set("idcard_code_aes", idcard_code);
|
|
|
|
record.set("xl_id", mapXl.get(xl_name));
|
|
|
|
record.set("xl_id", mapXl.get(xl_name));
|
|
|
|
record.set("zc_id", mapZc.get(zc_name));
|
|
|
|
record.set("zc_id", mapZc.get(zc_name));
|
|
|
|
record.set("stage_id", mapStage.get(stage_name));
|
|
|
|
record.set("stage_id", mapStage.get(stage_name));
|
|
|
@ -958,33 +856,25 @@ public class TeacherImportExcelUtil {
|
|
|
|
|
|
|
|
|
|
|
|
//看看哪些是重复的?
|
|
|
|
//看看哪些是重复的?
|
|
|
|
Map<String, String> duplicateMap = new HashMap<>();
|
|
|
|
Map<String, String> duplicateMap = new HashMap<>();
|
|
|
|
for(int i=0;i<rs.size();i++)
|
|
|
|
for (int i = 0; i < rs.size(); i++) {
|
|
|
|
{
|
|
|
|
|
|
|
|
duplicateMap.put(rs.get(i).getStr("idcard_code"), "1");
|
|
|
|
duplicateMap.put(rs.get(i).getStr("idcard_code"), "1");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
//回写到excel中去
|
|
|
|
//回写到excel中去
|
|
|
|
count = 0;
|
|
|
|
count = 0;
|
|
|
|
for (Row row : sheet1)
|
|
|
|
for (Row row : sheet1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
//放过行首
|
|
|
|
//放过行首
|
|
|
|
if(count <1)
|
|
|
|
if (count < 1) {
|
|
|
|
{
|
|
|
|
|
|
|
|
count++;
|
|
|
|
count++;
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
//如果当前行没有数据,跳出循环: 行首第一个单元格为空,即视为当前行及以下不再为有效区域!
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
if (row.getCell(1) == null || row.getCell(1).toString().equals("")) {
|
|
|
|
break;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
if (duplicateMap.containsKey(row.getCell(5).getStringCellValue())) {
|
|
|
|
{
|
|
|
|
|
|
|
|
if(duplicateMap.containsKey(row.getCell(5).getStringCellValue()))
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
row.getCell(5).setCellStyle(redStyle);
|
|
|
|
row.getCell(5).setCellStyle(redStyle);
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
row.getCell(5).setCellStyle(whileStyle);
|
|
|
|
row.getCell(5).setCellStyle(whileStyle);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -995,24 +885,19 @@ public class TeacherImportExcelUtil {
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
excelFileOutPutStream.flush();
|
|
|
|
|
|
|
|
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
JSONObject jo = new JSONObject();
|
|
|
|
if(rs.size()>0)
|
|
|
|
if (rs.size() > 0) {
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("success", false);
|
|
|
|
jo.put("message", "身份证号与系统中已有人员身份证号重复!");
|
|
|
|
jo.put("message", "身份证号与系统中已有人员身份证号重复!");
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
else
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("success", true);
|
|
|
|
jo.put("message", "身份证号与系统中已有人员身份证号无重复!");
|
|
|
|
jo.put("message", "身份证号与系统中已有人员身份证号无重复!");
|
|
|
|
jo.put("batch_id", batch_id);
|
|
|
|
jo.put("batch_id", batch_id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
//关闭workbook
|
|
|
|
//关闭workbook
|
|
|
|
if(wb!=null)
|
|
|
|
if (wb != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
wb.close();
|
|
|
|
wb.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
if(in!=null)
|
|
|
|
if (in != null) {
|
|
|
|
{
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
in.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return jo;
|
|
|
|
return jo;
|
|
|
|