|
|
|
@ -26,6 +26,7 @@ import (
|
|
|
|
|
"github.com/xormplus/builder"
|
|
|
|
|
"regexp"
|
|
|
|
|
"strconv"
|
|
|
|
|
"strings"
|
|
|
|
|
"time"
|
|
|
|
|
)
|
|
|
|
|
|
|
|
|
@ -193,7 +194,7 @@ func ExportStudentInfoExcel(targetPath string, bureauId string, ExportExcelStatu
|
|
|
|
|
for k := 2 + ExcelUtil.HiddenRows; k <= 5000+ExcelUtil.HiddenRows; k++ {
|
|
|
|
|
|
|
|
|
|
//设置单元格格式
|
|
|
|
|
cName:="B"+CommonUtil.ConvertIntToString(k)
|
|
|
|
|
cName := "B" + CommonUtil.ConvertIntToString(k)
|
|
|
|
|
f.SetCellStyle(SheetName, cName, cName, tableStyleIntStyle)
|
|
|
|
|
|
|
|
|
|
//入学年份
|
|
|
|
@ -204,7 +205,7 @@ func ExportStudentInfoExcel(targetPath string, bureauId string, ExportExcelStatu
|
|
|
|
|
_ = f.AddDataValidation(SheetName, dvRange)
|
|
|
|
|
|
|
|
|
|
//设置单元格格式
|
|
|
|
|
cName="C"+CommonUtil.ConvertIntToString(k)
|
|
|
|
|
cName = "C" + CommonUtil.ConvertIntToString(k)
|
|
|
|
|
f.SetCellStyle(SheetName, cName, cName, tableStyleIntStyle)
|
|
|
|
|
|
|
|
|
|
//班号
|
|
|
|
@ -341,7 +342,10 @@ func ImportStudentInfoExcel(excelPath string, bureauId string, actionPersonId st
|
|
|
|
|
}
|
|
|
|
|
//2、对excel的合法性进行检查
|
|
|
|
|
excelSuccess = checkExcel(excelPath, s1, MapClass, MapStage)
|
|
|
|
|
|
|
|
|
|
//两个有一个不成功,则提示
|
|
|
|
|
if !excelSuccess {
|
|
|
|
|
return false, "02", nil //02:在excel检测中,发现问题,请检查后重新上传!
|
|
|
|
|
}
|
|
|
|
|
//将excel文件读取到mysql的临时数据表中
|
|
|
|
|
err := readToTable(excelPath, s1, MapClass, bureauId, batchId, MapStage)
|
|
|
|
|
if err != nil {
|
|
|
|
@ -351,7 +355,7 @@ func ImportStudentInfoExcel(excelPath string, bureauId string, actionPersonId st
|
|
|
|
|
mysqlSuccess = checkTempTable(excelPath, s1, batchId, bureauId)
|
|
|
|
|
|
|
|
|
|
//两个有一个不成功,则提示
|
|
|
|
|
if !excelSuccess || !mysqlSuccess {
|
|
|
|
|
if !mysqlSuccess {
|
|
|
|
|
return false, "02", nil //02:在excel检测中,发现问题,请检查后重新上传!
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -413,6 +417,8 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
|
|
|
|
|
|
|
|
|
|
//当前年份
|
|
|
|
|
CurrentYear := time.Now().Year()
|
|
|
|
|
RedStyle, _ := f.GetCellStyle(s1.Title, Const.RedCell)
|
|
|
|
|
WhiteStyle, _ := f.GetCellStyle(s1.Title, Const.WhiteCell)
|
|
|
|
|
|
|
|
|
|
for i, row := range rows {
|
|
|
|
|
//放过表头
|
|
|
|
@ -467,6 +473,8 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -488,6 +496,13 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
|
|
|
|
|
if !DateUtil.CheckDateStr(row[j]) {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
//是合法日期
|
|
|
|
|
//尝试转一下整数
|
|
|
|
|
s := row[j]
|
|
|
|
|
_, err := strconv.Atoi(s)
|
|
|
|
|
if err == nil { //如果可以转为整数,那么可能是距离1900-01-01的天数
|
|
|
|
|
row[j] = DateUtil.ConvertToFormatDay(row[j]) //转为合法日期格式
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//(6)民族
|
|
|
|
@ -522,36 +537,42 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
|
|
|
|
|
}
|
|
|
|
|
//(10)独生子女
|
|
|
|
|
if j == 10 {
|
|
|
|
|
row[j] = strings.Replace(row[j], " ", "", -1)
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(11)随迁子女
|
|
|
|
|
if j == 11 {
|
|
|
|
|
row[j] = strings.Replace(row[j], " ", "", -1)
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(12)务工子女
|
|
|
|
|
if j == 12 {
|
|
|
|
|
row[j] = strings.Replace(row[j], " ", "", -1)
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(13)孤儿
|
|
|
|
|
if j == 13 {
|
|
|
|
|
row[j] = strings.Replace(row[j], " ", "", -1)
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(14)留守儿童
|
|
|
|
|
if j == 14 {
|
|
|
|
|
row[j] = strings.Replace(row[j], " ", "", -1)
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(15)残疾儿童
|
|
|
|
|
if j == 15 {
|
|
|
|
|
row[j] = strings.Replace(row[j], " ", "", -1)
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
@ -559,14 +580,18 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
|
|
|
|
|
//标红
|
|
|
|
|
cName, _ := excelize.ColumnNumberToName(j + 1)
|
|
|
|
|
cell := cName + CommonUtil.ConvertIntToString(i+1)
|
|
|
|
|
|
|
|
|
|
nowStyle, _ := f.GetCellStyle(s1.Title, cell)
|
|
|
|
|
if !pass {
|
|
|
|
|
//红色
|
|
|
|
|
style, _ := f.GetCellStyle(s1.Title, Const.RedCell)
|
|
|
|
|
_ = f.SetCellStyle(s1.Title, cell, cell, style)
|
|
|
|
|
if nowStyle != RedStyle {
|
|
|
|
|
_ = f.SetCellStyle(s1.Title, cell, cell, RedStyle)
|
|
|
|
|
}
|
|
|
|
|
firstSuccess = false
|
|
|
|
|
} else {
|
|
|
|
|
style, _ := f.GetCellStyle(s1.Title, Const.WhiteCell)
|
|
|
|
|
_ = f.SetCellStyle(s1.Title, cell, cell, style)
|
|
|
|
|
if nowStyle != WhiteStyle {
|
|
|
|
|
_ = f.SetCellStyle(s1.Title, cell, cell, WhiteStyle)
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
@ -707,7 +732,7 @@ func checkTempTable(excelPath string, s1 ExcelUtil.TemplateStruct, batchId strin
|
|
|
|
|
/****************************************************************************/
|
|
|
|
|
//检查学生的身份证号重复
|
|
|
|
|
sql = `select t1.sfzjh,t2.row_number from t_base_student as t1 inner join t_base_student_import_excel as t2
|
|
|
|
|
on t1.sfzjh=t2.sfzjh where t2.batch_id=? and t1.bureau_id<>?`
|
|
|
|
|
on t1.sfzjh=t2.sfzjh where t2.batch_id=? and t1.bureau_id<>? and t1.sfzjh<>''`
|
|
|
|
|
listIdCardStudent, err := db.SQL(sql, batchId, bureauId).Query().List()
|
|
|
|
|
if err != nil {
|
|
|
|
|
LogUtil.Error(Const.DataBaseActionError, "在查询学生的身份证号重复时发生严重错误!")
|
|
|
|
@ -716,7 +741,7 @@ func checkTempTable(excelPath string, s1 ExcelUtil.TemplateStruct, batchId strin
|
|
|
|
|
//存在学生身份证号检查重复
|
|
|
|
|
for i := range listIdCardStudent {
|
|
|
|
|
rowNumber := listIdCardStudent[i]["row_number"].(int64)
|
|
|
|
|
cell := "H" + CommonUtil.ConvertInt64ToString(rowNumber)
|
|
|
|
|
cell := "J" + CommonUtil.ConvertInt64ToString(rowNumber)
|
|
|
|
|
style, _ := f.GetCellStyle(s1.Title, Const.YellowCell)
|
|
|
|
|
_ = f.SetCellStyle(s1.Title, cell, cell, style)
|
|
|
|
|
//设计二级检查失败
|
|
|
|
|