master
huanghai 5 years ago
parent 1cfa4cac5b
commit be4f4f870e

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

@ -982,8 +982,7 @@ func updateTeacherImport(batchId string, actionPersonId string, actionIp string)
model.Xbm = r1.Xbm model.Xbm = r1.Xbm
} }
} else { } else {
//如果不是身份证号,那就用个默认值吧 model.Csrq = r1.Csrq
model.Csrq = DateUtil.ConvertDate("1999-09-01")
model.Xbm = r1.Xbm model.Xbm = r1.Xbm
} }
//排序号 //排序号

@ -1,24 +1,30 @@
package models package models
import (
"time"
)
type TBaseStudentImportExcel struct { type TBaseStudentImportExcel struct {
Id string `xorm:"not null pk default ''0'' comment('ID') CHAR(36)"` Id string `xorm:"not null pk default ''0'' comment('ID') CHAR(36)"`
BureauId string `xorm:"not null comment('单位ID') CHAR(36)"` BureauId string `xorm:"not null comment('单位ID') CHAR(36)"`
StageId string `xorm:"not null comment('学部ID') CHAR(1)"` StageId string `xorm:"not null comment('学部ID') CHAR(1)"`
Rxnf int32 `xorm:"not null comment('入学年份') INT(11)"` Rxnf int32 `xorm:"not null comment('入学年份') INT(11)"`
Bh int32 `xorm:"not null comment('班号') INT(11)"` Bh int32 `xorm:"not null comment('班号') INT(11)"`
ClassId string `xorm:"not null comment('班级号') index(class_id) CHAR(36)"` ClassId string `xorm:"not null comment('班级号') index(class_id) CHAR(36)"`
Xm string `xorm:"not null default '''' comment('学生姓名') VARCHAR(100)"` Xm string `xorm:"not null default '''' comment('学生姓名') VARCHAR(100)"`
Mzm string `xorm:"not null default '''' comment('民族码') CHAR(2)"` Xbm string `xorm:"not null comment('性别码') CHAR(1)"`
Zzmmm string `xorm:"not null default '''' comment('政治面貌码') CHAR(2)"` Csrq time.Time `xorm:"not null comment('出生日期') DATE"`
Sfzjlxm string `xorm:"not null default '''' comment('身份证件类型码') CHAR(1)"` Mzm string `xorm:"not null default '''' comment('民族码') CHAR(2)"`
Sfzjh string `xorm:"not null default '''' comment('身份证件号') index(sfzjh) VARCHAR(100)"` Zzmmm string `xorm:"not null default '''' comment('政治面貌码') CHAR(2)"`
Dszybz int32 `xorm:"not null comment('独生子女') INT(11)"` Sfzjlxm string `xorm:"not null default '''' comment('身份证件类型码') CHAR(1)"`
Sqznbz int32 `xorm:"not null comment('随迁子女') INT(11)"` Sfzjh string `xorm:"not null default '''' comment('身份证件号') index(sfzjh) VARCHAR(100)"`
Jcwgrysqznbz int32 `xorm:"not null comment('进城务工人员子女') INT(11)"` Dszybz int32 `xorm:"not null comment('独生子女') INT(11)"`
Gebz int32 `xorm:"not null comment('孤儿') INT(11)"` Sqznbz int32 `xorm:"not null comment('随迁子女') INT(11)"`
Lsetbz int32 `xorm:"not null comment('留守儿童') INT(11)"` Jcwgrysqznbz int32 `xorm:"not null comment('进城务工人员子女') INT(11)"`
Cjbz int32 `xorm:"not null comment('残疾儿童') INT(11)"` Gebz int32 `xorm:"not null comment('孤儿') INT(11)"`
BatchId string `xorm:"not null comment('批次ID') index(class_id) index(sfzjh) CHAR(36)"` Lsetbz int32 `xorm:"not null comment('留守儿童') INT(11)"`
RowNumber int32 `xorm:"not null default 0 comment('对应的EXCEL是第几行的数据') INT(11)"` Cjbz int32 `xorm:"not null comment('残疾儿童') INT(11)"`
InsertOrUpdate int32 `xorm:"not null default 1 comment('是新增加还是修改1新增2:修改') INT(11)"` BatchId string `xorm:"not null comment('批次ID') index(class_id) index(sfzjh) CHAR(36)"`
RowNumber int32 `xorm:"not null default 0 comment('对应的EXCEL是第几行的数据') INT(11)"`
PersonId string `xorm:"default 'NULL' comment('人员ID') CHAR(36)"`
} }

Loading…
Cancel
Save