main
黄海 2 years ago
parent 529fe4cafa
commit 1b0a24cefa

@ -50,8 +50,8 @@ public class ModifyIdCardAndTel {
String idcard_code=rs.get(i).getStr("idcard_code"); String idcard_code=rs.get(i).getStr("idcard_code");
String telephone=rs.get(i).getStr("telephone"); String telephone=rs.get(i).getStr("telephone");
String aes_idcard_code= MysqlAesUtil.Encrypt(idcard_code); String aes_idcard_code= idcard_code;
String aes_telephone=MysqlAesUtil.Encrypt(telephone); String aes_telephone=telephone;
batchSqlList.add("update t_sys_loginperson set idcard_code='"+aes_idcard_code+"',telephone='"+aes_telephone+"' where person_id='"+person_id+"'"); batchSqlList.add("update t_sys_loginperson set idcard_code='"+aes_idcard_code+"',telephone='"+aes_telephone+"' where person_id='"+person_id+"'");
} }

@ -100,7 +100,7 @@ public class InitOrgPerson {
record.set("b_use", 1); record.set("b_use", 1);
record.set("create_time", CommonUtil.GetCurrentTimeString()); record.set("create_time", CommonUtil.GetCurrentTimeString());
record.set("sort_id", sort_id); record.set("sort_id", sort_id);
String idcard_code = MysqlAesUtil.Encrypt("-1"); String idcard_code = "-1";
record.set("idcard_code", idcard_code); record.set("idcard_code", idcard_code);
record.set("original_pwd", original_pwd); record.set("original_pwd", original_pwd);
record.set("xb", 1); record.set("xb", 1);

@ -131,7 +131,7 @@ public class clearDataBase {
record.set("b_use", 1); record.set("b_use", 1);
record.set("create_time", CommonUtil.GetCurrentTimeString()); record.set("create_time", CommonUtil.GetCurrentTimeString());
record.set("sort_id", sort_id); record.set("sort_id", sort_id);
String idcard_code = MysqlAesUtil.Encrypt("-1"); String idcard_code = "-1";
record.set("idcard_code", idcard_code); record.set("idcard_code", idcard_code);
record.set("original_pwd", original_pwd); record.set("original_pwd", original_pwd);
record.set("xb", 1); record.set("xb", 1);

@ -535,7 +535,7 @@ public class StudentImportExcelUtil {
record.set("xb", rs.get(i).getStr("xb_id")); record.set("xb", rs.get(i).getStr("xb_id"));
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);
//根据身份证号换算出生日期 //根据身份证号换算出生日期
Map<String, String> m = IDCardUtil.getBirAgeSex(rs.get(i).getStr("idcard_code")); Map<String, String> m = IDCardUtil.getBirAgeSex(rs.get(i).getStr("idcard_code"));
@ -829,7 +829,7 @@ public class StudentImportExcelUtil {
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("xjh", xjh); record.set("xjh", xjh);
record.set("xjfh", xjfh); record.set("xjfh", xjfh);
record.set("source", mapSource.get(source)); record.set("source", mapSource.get(source));

@ -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;

@ -137,7 +137,7 @@ public class LoginPersonModel {
int flag = 0; int flag = 0;
try { try {
String sql = Db.getSql("loginPerson.getIdCardIsExist"); String sql = Db.getSql("loginPerson.getIdCardIsExist");
List<Record> list = Db.find(sql, MysqlAesUtil.Encrypt(id_card)); List<Record> list = Db.find(sql, id_card);
if (list.size() > 0) { if (list.size() > 0) {
flag = 1; flag = 1;
} }
@ -160,7 +160,7 @@ public class LoginPersonModel {
int flag = 0; int flag = 0;
try { try {
String sql = Db.getSql("loginPerson.getIdCardIsExistByPersonId"); String sql = Db.getSql("loginPerson.getIdCardIsExistByPersonId");
List<Record> list = Db.find(sql, MysqlAesUtil.Encrypt(id_card), person_id); List<Record> list = Db.find(sql, id_card, person_id);
if (list.size() > 0) { if (list.size() > 0) {
flag = 1; flag = 1;
} }
@ -184,7 +184,7 @@ public class LoginPersonModel {
try { try {
String sql = Db.getSql("loginPerson.getTelephoneIsExist"); String sql = Db.getSql("loginPerson.getTelephoneIsExist");
//检查加密后的手机号是不是重复 //检查加密后的手机号是不是重复
String aes_telephone = MysqlAesUtil.Encrypt(telephone); String aes_telephone = telephone;
List<Record> list = Db.find(sql, aes_telephone); List<Record> list = Db.find(sql, aes_telephone);
if (list.size() > 0) { if (list.size() > 0) {
flag = 1; flag = 1;
@ -209,7 +209,7 @@ public class LoginPersonModel {
try { try {
String sql = Db.getSql("loginPerson.getTelephoneIsExistByPersonId"); String sql = Db.getSql("loginPerson.getTelephoneIsExistByPersonId");
//检查加密后的手机号是不是重复 //检查加密后的手机号是不是重复
String aes_telephone = MysqlAesUtil.Encrypt(telephone); String aes_telephone = telephone;
List<Record> list = Db.find(sql, aes_telephone, person_id); List<Record> list = Db.find(sql, aes_telephone, person_id);
if (list.size() > 0) { if (list.size() > 0) {
flag = 1; flag = 1;

@ -147,7 +147,6 @@ public class StudentController extends Controller {
String mainSchoolId = classMap.get("main_school_id").toString(); String mainSchoolId = classMap.get("main_school_id").toString();
//对身份证号进行加密 //对身份证号进行加密
id_card= MysqlAesUtil.Encrypt(id_card);
//操作人 //操作人
String operator=getCookie("person_id"); String operator=getCookie("person_id");
//客户端ip_address //客户端ip_address
@ -415,7 +414,6 @@ public class StudentController extends Controller {
} }
} }
//对身份证号进行加密 //对身份证号进行加密
id_card= MysqlAesUtil.Encrypt(id_card);
//操作人 //操作人
String operator=getCookie("person_id"); String operator=getCookie("person_id");
//客户端ip_address //客户端ip_address

@ -88,11 +88,11 @@ public class StudentModel {
record.set("person_name", person_name+"家长"); record.set("person_name", person_name+"家长");
record.set("xb", xb); record.set("xb", xb);
record.set("mz", mz); record.set("mz", mz);
record.set("idcard_code",MysqlAesUtil.Encrypt("000000000000000000")); record.set("idcard_code","000000000000000000");
record.set("birthday", "1970-01-01"); record.set("birthday", "1970-01-01");
record.set("create_time", CommonUtil.GetCurrentTimeString()); record.set("create_time", CommonUtil.GetCurrentTimeString());
record.set("sort_id", sort_id); record.set("sort_id", sort_id);
record.set("telephone", MysqlAesUtil.Encrypt("13000000000")); record.set("telephone", "13000000000");
record.set("original_pwd", originalPwd); record.set("original_pwd", originalPwd);
record.set("email", "11111@qq.com"); record.set("email", "11111@qq.com");
record.set("b_use", "1"); record.set("b_use", "1");
@ -262,7 +262,7 @@ public class StudentModel {
if (list.size() > 0) { if (list.size() > 0) {
Record record=list.get(0); Record record=list.get(0);
//显示单个人员时,需要将身份证号进行还原出来 //显示单个人员时,需要将身份证号进行还原出来
record.set("idcard_code",MysqlAesUtil.Decrypt(record.getStr("idcard_code"))); record.set("idcard_code",record.getStr("idcard_code"));
return record; return record;
} else { } else {
return null; return null;

@ -119,7 +119,7 @@ public class TeacherController extends Controller {
//将明文密码加密 //将明文密码加密
String pwd = CommonUtil.getLdapPassword(originalPwd); String pwd = CommonUtil.getLdapPassword(originalPwd);
//对身份证号进行一次加密 //对身份证号进行一次加密
if (!StrKit.isBlank(id_card)) id_card = MysqlAesUtil.Encrypt(id_card); if (!StrKit.isBlank(id_card)) id_card =id_card;
else id_card = ""; else id_card = "";
//操作人 //操作人
String operator = getCookie("person_id"); String operator = getCookie("person_id");
@ -405,7 +405,7 @@ public class TeacherController extends Controller {
} }
//对身份证号进行一次加密 //对身份证号进行一次加密
if(!StrKit.isBlank(id_card))id_card = MysqlAesUtil.Encrypt(id_card); if(!StrKit.isBlank(id_card))id_card = id_card;
else id_card=""; else id_card="";
//操作人 //操作人
String operator = getCookie("person_id"); String operator = getCookie("person_id");

@ -268,7 +268,7 @@ public class TeacherModel {
if (list.size() > 0) { if (list.size() > 0) {
Record record = list.get(0); Record record = list.get(0);
//显示单个人员时,需要将身份证号进行还原出来 //显示单个人员时,需要将身份证号进行还原出来
record.set("idcard_code", MysqlAesUtil.Decrypt(record.getStr("idcard_code"))); record.set("idcard_code",record.getStr("idcard_code"));
return record; return record;
} else { } else {
return null; return null;

Binary file not shown.
Loading…
Cancel
Save