From afe12869d0273e2ecc8479f09d11e95eb063bd37 Mon Sep 17 00:00:00 2001 From: huanghai <10402852@qq.com> Date: Tue, 28 Jul 2020 09:33:59 +0800 Subject: [PATCH] 'commit' --- .../BaseStudent/BaseStudentDao/BaseStudentDao.go | 6 +++--- .../BaseTeacher/BaseTeacherDao/BaseTeacherDao.go | 6 +++--- dsBaseRpc/Utils/CommonUtil/CommonUtil.go | 10 ++++++++++ 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go b/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go index 342eba35..2679617b 100644 --- a/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go +++ b/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go @@ -457,13 +457,13 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[stri } //(7)身份证号 if j == 7 { - if row[j-1] == "居民身份证" && !CommonUtil.IsIdCard(row[j]) { + if row[j-1] == "居民身份证" && !CommonUtil.IsIdCard(CommonUtil.CompressStr(row[j])) { pass = false } if row[j] == "" { pass = false } - _idCardMap[row[j]] = append(_idCardMap[row[j]], i+1) + _idCardMap[CommonUtil.CompressStr(row[j])] = append(_idCardMap[CommonUtil.CompressStr(row[j])], i+1) } //(8)独生子女 if j == 8 { @@ -580,7 +580,7 @@ func readToTable(excelPath string, s1 ExcelUtil.TemplateStruct, MapClass map[str //身份证件类型 m.Sfzjlxm = SysDictKit.MapDictKindChineseToCode["sfzjlxm_"+row[6]] //身份证件号 - m.Sfzjh = row[7] + m.Sfzjh = CommonUtil.CompressStr(row[7]) //独生子女 m.Dszybz = int32(CommonUtil.ConvertStringToInt(SysDictKit.MapTrueOrFalseNameToValue[row[8]])) //随迁子女 diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go index f5345632..50d548fe 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go @@ -448,7 +448,7 @@ func readToTable(excelPath string, s1 ExcelUtil.TemplateStruct, MapOrgName map[s //身份证件类型 m.Sfzjlxm = SysDictKit.MapDictKindChineseToCode["sfzjlxm_"+row[4]] //身份证件号 - m.Sfzjh = row[5] + m.Sfzjh =CommonUtil.CompressStr(row[5]) //学历 m.Xlm = SysDictKit.MapDictKindChineseToCode["xlm_"+row[6]] //学位 @@ -666,13 +666,13 @@ func checkExcel(excelPath string, s1 ExcelUtil.TemplateStruct, MapOrgName map[st } //(5)身份证号 if j == 5 { - if row[j-1] == "居民身份证" && !CommonUtil.IsIdCard(row[j]) { + if row[j-1] == "居民身份证" && !CommonUtil.IsIdCard(CommonUtil.CompressStr(row[j])) { pass = false } if row[j] == "" { pass = false } - _idCardMap[row[j]] = append(_idCardMap[row[j]], i+1) + _idCardMap[CommonUtil.CompressStr(row[j])] = append(_idCardMap[CommonUtil.CompressStr(row[j])], i+1) } //(6)学历 if j == 6 { diff --git a/dsBaseRpc/Utils/CommonUtil/CommonUtil.go b/dsBaseRpc/Utils/CommonUtil/CommonUtil.go index 497da7e7..f1d4c479 100644 --- a/dsBaseRpc/Utils/CommonUtil/CommonUtil.go +++ b/dsBaseRpc/Utils/CommonUtil/CommonUtil.go @@ -654,3 +654,13 @@ func MapToJson(m map[string]interface{}) (string, error) { } return string(jsonByte), nil } + +//利用正则表达式压缩字符串,去除空格或制表符 +func CompressStr(str string) string { + if str == "" { + return "" + } + //匹配一个或多个空白符的正则表达式 + reg := regexp.MustCompile("\\s+") + return reg.ReplaceAllString(str, "") +}