|
|
|
@ -322,9 +322,6 @@ func ImportStudentInfoExcel(excelPath string, bureauId string, actionPersonId st
|
|
|
|
|
var bureauModel models.TBaseOrganization
|
|
|
|
|
db.Where("org_id=?", bureauId).Get(&bureauModel)
|
|
|
|
|
|
|
|
|
|
//5、更新标识修改,数据库里有的为修改,没有是新增
|
|
|
|
|
insertOrUpdateFlagSetting(batchId)
|
|
|
|
|
|
|
|
|
|
//6、新增
|
|
|
|
|
insertCount, _, _ = insertStudent(batchId, bureauModel, actionPersonId, actionIp)
|
|
|
|
|
|
|
|
|
@ -442,26 +439,30 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(4)民族
|
|
|
|
|
if j == 4 {
|
|
|
|
|
//(4)性别
|
|
|
|
|
|
|
|
|
|
//(5)出生日期
|
|
|
|
|
|
|
|
|
|
//(6)民族
|
|
|
|
|
if j == 6 {
|
|
|
|
|
if _, ok := SysDictKit.MapDictKindChineseToCode["mzm_"+row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(5)政治面貌
|
|
|
|
|
if j == 5 {
|
|
|
|
|
//(7)政治面貌
|
|
|
|
|
if j == 7 {
|
|
|
|
|
if _, ok := SysDictKit.MapDictKindChineseToCode["zzmmm_"+row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(6)身份证件类型
|
|
|
|
|
if j == 6 {
|
|
|
|
|
//(8)身份证件类型
|
|
|
|
|
if j == 8 {
|
|
|
|
|
if _, ok := SysDictKit.MapDictKindChineseToCode["sfzjlxm_"+row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(7)身份证号
|
|
|
|
|
if j == 7 {
|
|
|
|
|
//(9)身份证号
|
|
|
|
|
if j == 9 {
|
|
|
|
|
if row[j-1] == "居民身份证" && !CommonUtil.IsIdCard(CommonUtil.CompressStr(row[j])) {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
@ -470,38 +471,38 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri
|
|
|
|
|
}
|
|
|
|
|
_idCardMap[CommonUtil.CompressStr(row[j])] = append(_idCardMap[CommonUtil.CompressStr(row[j])], i+1)
|
|
|
|
|
}
|
|
|
|
|
//(8)独生子女
|
|
|
|
|
if j == 8 {
|
|
|
|
|
//(10)独生子女
|
|
|
|
|
if j == 10 {
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(9)随迁子女
|
|
|
|
|
if j == 9 {
|
|
|
|
|
//(11)随迁子女
|
|
|
|
|
if j == 11 {
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(10)务工子女
|
|
|
|
|
if j == 10 {
|
|
|
|
|
//(12)务工子女
|
|
|
|
|
if j == 12 {
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(11)孤儿
|
|
|
|
|
if j == 11 {
|
|
|
|
|
//(13)孤儿
|
|
|
|
|
if j == 13 {
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(12)留守儿童
|
|
|
|
|
if j == 12 {
|
|
|
|
|
//(14)留守儿童
|
|
|
|
|
if j == 14 {
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//(13)残疾儿童
|
|
|
|
|
if j == 13 {
|
|
|
|
|
//(15)残疾儿童
|
|
|
|
|
if j == 15 {
|
|
|
|
|
if _, ok := SysDictKit.MapTrueOrFalseNameToValue[row[j]]; !ok {
|
|
|
|
|
pass = false
|
|
|
|
|
}
|
|
|
|
@ -578,32 +579,38 @@ func readToTable(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[str
|
|
|
|
|
}
|
|
|
|
|
//姓名
|
|
|
|
|
m.Xm = row[3]
|
|
|
|
|
//性别
|
|
|
|
|
if row[2] == "男" {
|
|
|
|
|
m.Xbm = "1"
|
|
|
|
|
} else {
|
|
|
|
|
m.Xbm = "2"
|
|
|
|
|
}
|
|
|
|
|
//出生日期
|
|
|
|
|
m.Csrq = DateUtil.ConvertDate(row[3])
|
|
|
|
|
//民族
|
|
|
|
|
m.Mzm = SysDictKit.MapDictKindChineseToCode["mzm_"+row[4]]
|
|
|
|
|
m.Mzm = SysDictKit.MapDictKindChineseToCode["mzm_"+row[6]]
|
|
|
|
|
//政治面貌
|
|
|
|
|
m.Zzmmm = SysDictKit.MapDictKindChineseToCode["zzmmm_"+row[5]]
|
|
|
|
|
m.Zzmmm = SysDictKit.MapDictKindChineseToCode["zzmmm_"+row[7]]
|
|
|
|
|
//身份证件类型
|
|
|
|
|
m.Sfzjlxm = SysDictKit.MapDictKindChineseToCode["sfzjlxm_"+row[6]]
|
|
|
|
|
m.Sfzjlxm = SysDictKit.MapDictKindChineseToCode["sfzjlxm_"+row[8]]
|
|
|
|
|
//身份证件号
|
|
|
|
|
m.Sfzjh = CommonUtil.CompressStr(row[7])
|
|
|
|
|
m.Sfzjh = CommonUtil.CompressStr(row[9])
|
|
|
|
|
//独生子女
|
|
|
|
|
m.Dszybz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[8]]))
|
|
|
|
|
m.Dszybz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[10]]))
|
|
|
|
|
//随迁子女
|
|
|
|
|
m.Sqznbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[9]]))
|
|
|
|
|
m.Sqznbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[11]]))
|
|
|
|
|
//务工子女
|
|
|
|
|
m.Jcwgrysqznbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[10]]))
|
|
|
|
|
m.Jcwgrysqznbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[12]]))
|
|
|
|
|
//孤儿
|
|
|
|
|
m.Gebz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[11]]))
|
|
|
|
|
m.Gebz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[13]]))
|
|
|
|
|
//留守儿童
|
|
|
|
|
m.Lsetbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[12]]))
|
|
|
|
|
m.Lsetbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[14]]))
|
|
|
|
|
//残疾儿童
|
|
|
|
|
m.Cjbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[13]]))
|
|
|
|
|
m.Cjbz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[15]]))
|
|
|
|
|
//批次号
|
|
|
|
|
m.BatchId = batchId
|
|
|
|
|
//第几行的数据
|
|
|
|
|
m.RowNumber = int32(i + 1)
|
|
|
|
|
//新增还是修改,默认是新增
|
|
|
|
|
m.InsertOrUpdate = 1
|
|
|
|
|
//添加到数组中
|
|
|
|
|
ms = append(ms, m)
|
|
|
|
|
}
|
|
|
|
@ -664,16 +671,6 @@ func checkTempTable(excelPath string, s1 ExcelUtil.TemplateStruct, batchId strin
|
|
|
|
|
return success
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:修改指定批次的更新和插入标识
|
|
|
|
|
*/
|
|
|
|
|
func insertOrUpdateFlagSetting(batchId string) {
|
|
|
|
|
//1、更新标识修改,数据库里有的为修改,没有是新增
|
|
|
|
|
sql := `update t_base_student_import_excel as t1 join t_base_student as t2 on t1.sfzjh=t2.sfzjh
|
|
|
|
|
set t1.insert_or_update=2 where t2.b_use=1 and t1.batch_id=?`
|
|
|
|
|
db.SQL(sql, batchId).Execute()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:插入学生
|
|
|
|
|
*/
|
|
|
|
@ -681,7 +678,7 @@ func insertStudent(batchId string, bureauModel models.TBaseOrganization, actionP
|
|
|
|
|
//新增学生
|
|
|
|
|
studentImportExcelArray := make([]models.TBaseStudentImportExcel, 0)
|
|
|
|
|
studentArray := make([]models.TBaseStudent, 0)
|
|
|
|
|
db.Where("batch_id=? and insert_or_update=1", batchId).Find(&studentImportExcelArray)
|
|
|
|
|
db.Where("batch_id=? and length(person_id)=0", batchId).Find(&studentImportExcelArray)
|
|
|
|
|
|
|
|
|
|
for i := range studentImportExcelArray {
|
|
|
|
|
r1 := studentImportExcelArray[i]
|
|
|
|
@ -709,13 +706,17 @@ func insertStudent(batchId string, bureauModel models.TBaseOrganization, actionP
|
|
|
|
|
//出生日期与性别
|
|
|
|
|
if model.Sfzjlxm == "1" {
|
|
|
|
|
//根据身份证号,提取男女,出生日期
|
|
|
|
|
_, birthday, xbm := IdCardUtil.GetIdCardNoInfo(r1.Sfzjh)
|
|
|
|
|
model.Csrq = DateUtil.ConvertDate(birthday)
|
|
|
|
|
model.Xbm = xbm
|
|
|
|
|
isValid, birthday, xbm := IdCardUtil.GetIdCardNoInfo(r1.Sfzjh)
|
|
|
|
|
if isValid {
|
|
|
|
|
model.Csrq = DateUtil.ConvertDate(birthday)
|
|
|
|
|
model.Xbm = xbm
|
|
|
|
|
} else {
|
|
|
|
|
model.Csrq = r1.Csrq
|
|
|
|
|
model.Xbm = r1.Xbm
|
|
|
|
|
}
|
|
|
|
|
} else {
|
|
|
|
|
//如果不是身份证号,那就用个默认值吧
|
|
|
|
|
model.Csrq = DateUtil.ConvertDate("1977-10-11")
|
|
|
|
|
model.Xbm = "1"
|
|
|
|
|
model.Csrq = r1.Csrq
|
|
|
|
|
model.Xbm = r1.Xbm
|
|
|
|
|
}
|
|
|
|
|
//民族
|
|
|
|
|
model.Mzm = r1.Mzm
|
|
|
|
@ -795,7 +796,7 @@ func updateStudentImport(batchId string, bureauModel models.TBaseOrganization, a
|
|
|
|
|
//开始
|
|
|
|
|
studentImportExcelArray := make([]models.TBaseStudentImportExcel, 0)
|
|
|
|
|
studentArray := make([]models.TBaseStudent, 0)
|
|
|
|
|
db.Where("batch_id=? and insert_or_update=2", batchId).Find(&studentImportExcelArray)
|
|
|
|
|
db.Where("batch_id=? and length(person_id)=36", batchId).Find(&studentImportExcelArray)
|
|
|
|
|
|
|
|
|
|
//准备更新的数据
|
|
|
|
|
for i := range studentImportExcelArray {
|
|
|
|
|