diff --git a/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go b/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go index a60573d8..7d6ea7a0 100644 --- a/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go +++ b/dsBaseRpc/RpcService/BaseStudent/BaseStudentDao/BaseStudentDao.go @@ -266,7 +266,7 @@ func ExportStudentInfoExcel(targetPath string, bureauId string, ExportExcelStatu func ImportStudentInfoExcel(excelPath string, bureauId string,actionPersonId string,actionIp string) (bool, string, error) { //判断文件是不是存在 if !FileUtil.PathExists(excelPath) { - return false, "文件没有找到", nil + return false, "03", nil //03:文件没有找到 } //模板是不是系统提供的 var templateSuccess = true @@ -295,7 +295,7 @@ func ImportStudentInfoExcel(excelPath string, bureauId string,actionPersonId str //1、对模板的合法性进行检查 templateSuccess = ExcelUtil.IsValidTemplate(excelPath, s1) if !templateSuccess { - return false, "不是系统提供的模板,无法完成导入!", nil + return false, "01", nil //01:不是系统提供的模板,无法完成导入! } //2、对excel的合法性进行检查 excelSuccess = checkExcel(excelPath, s1, MapClass, MapStage) @@ -310,7 +310,7 @@ func ImportStudentInfoExcel(excelPath string, bureauId string,actionPersonId str //两个有一个不成功,则提示 if !excelSuccess || !mysqlSuccess { - return false, "在excel检测中,发现问题,请检查后重新上传!", nil + return false, "02", nil //02:在excel检测中,发现问题,请检查后重新上传! } //4、获取所有单位的一些属性,用于一会维护人员信息时使用 diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go index 13303ef2..151f4ae1 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go @@ -99,7 +99,8 @@ func PageBaseTeacher(in *BaseTeacherProto.QueryArg) ([]map[string]interface{}, i // 注意两个表关联时的on用法: var myBuilder = builder.Dialect(builder.MYSQL).Select("t1.*"). From("t_base_teacher as t1"). - LeftJoin("t_base_teacher_org as t2", "t1.person_id=t2.person_id") + LeftJoin("t_base_teacher_org as t2", "t1.person_id=t2.person_id"). + OrderBy("t1.org_id").OrderBy("t1.sort_id") //所在单位ID list := SqlKit.QueryByIds([]string{in.OrgId}, "t_base_organization") if list == nil { @@ -216,7 +217,7 @@ func ExportTeacherAccountInfoExcel(in *BaseTeacherProto.ModelArg) ([]map[string] And(builder.Eq{"t2.b_use": 1}). And(builder.Eq{"t3.b_use": 1}). And(builder.Eq{"t2.bureau_id": in.BureauId}).And(builder.Eq{"t1.identity_id": 2}) - myBuilder.OrderBy("t3.sort_id").OrderBy("t2.sort_id").OrderBy("t2.id_int") + myBuilder.OrderBy("t3.org_id").OrderBy("t2.sort_id") sql, err := myBuilder.ToBoundSQL() if err != nil { return nil, 0, err @@ -305,7 +306,7 @@ func ExportTeacherInfoExcel(targetPath string, bureauId string, ExportExcelStatu t1.mzm,t1.zzmmm,t1.sfzjlxm, (case t1.sfzjh when '-1' then '' else t1.sfzjh end ) as sfzjh, t1.xlm,t1.xwm,t1.zcm,t1.bzlbm,t1.stage_id,t1.subject_id,t1.gwzym,t1.lxdh,t1.dzxx from t_base_teacher as t1 inner join t_base_organization as t2 on t1.org_id=t2.org_id - where t1.bureau_id=? and t1.identity_id=2 and t1.b_use=1` + where t1.bureau_id=? and t1.identity_id=2 and t1.b_use=1 order by t1.org_id,t1.sort_id` list, _ := db.SQL(sql, bureauId).Query().List() for i := range list { record := list[i] @@ -355,7 +356,7 @@ func ExportTeacherInfoExcel(targetPath string, bureauId string, ExportExcelStatu func ImportTeacherInfoExcel(excelPath string, bureauId string, actionPersonId string, actionIp string) (bool, string, error) { //判断文件是不是存在 if !FileUtil.PathExists(excelPath) { - return false, "文件没有找到", nil + return false, "03", nil //03:文件没有找到 } //模板是不是系统提供的 var templateSuccess = true @@ -381,7 +382,7 @@ func ImportTeacherInfoExcel(excelPath string, bureauId string, actionPersonId st //1、对模板的合法性进行检查 templateSuccess = ExcelUtil.IsValidTemplate(excelPath, s1) if !templateSuccess { - return false, "不是系统提供的模板,无法完成导入!", nil + return false, "01", nil //01:不是系统提供的模板,无法完成导入! } //2、对excel的合法性进行检查 excelSuccess = checkExcel(excelPath, s1, MapOrgName) @@ -394,7 +395,7 @@ func ImportTeacherInfoExcel(excelPath string, bureauId string, actionPersonId st //两个有一个不成功,则提示 if !excelSuccess || !mysqlSuccess { - return false, "在excel检测中,发现问题,请检查后重新上传!", nil + return false, "02", nil //02:在excel检测中,发现问题,请检查后重新上传! } //4、获取所有单位的一些属性,用于一会维护人员信息时使用 diff --git a/dsBaseRpc/Test/excel_test.go b/dsBaseRpc/Test/excel_test.go index 55c5278e..d6e8940f 100644 --- a/dsBaseRpc/Test/excel_test.go +++ b/dsBaseRpc/Test/excel_test.go @@ -2,6 +2,7 @@ package Test import ( "dsBaseRpc/RpcService/BaseStudent/BaseStudentDao" + "fmt" "testing" ) @@ -50,22 +51,22 @@ func TestTeacherExportExcel(t *testing.T) { 时间:2020-06-05 */ func TestStudentExportExcel(t *testing.T) { - //哪个单位 - bureauId := "7ED4080B-924F-40F0-9004-881A2B833E44" - //文件在哪里 - fileName := "E:\\Work\\dsMin\\dsBaseWeb\\Html\\ExcelTemp\\" + bureauId + ".xlsx" - BaseStudentDao.ExportStudentInfoExcel(fileName, bureauId, 1, []string{}) + ////哪个单位 + //bureauId := "7ED4080B-924F-40F0-9004-881A2B833E44" + ////文件在哪里 + //fileName := "E:\\Work\\dsMin\\dsBaseWeb\\Html\\ExcelTemp\\" + bureauId + ".xlsx" + //BaseStudentDao.ExportStudentInfoExcel(fileName, bureauId, 1, []string{}) } func TestImportStudent(t *testing.T) { - ////哪个单位 - //bureauId := "042F28BE-296C-40F4-8AD4-A68A6D852CF0" - ////文件在哪里 - //fileName := `E:\Work\dsMin\dsBaseWeb\html\ExcelTemp\` + bureauId + ".xlsx" - //success, message, err := BaseStudentDao.ImportStudentInfoExcel(fileName, bureauId) - //if err != nil { - // fmt.Println(err.Error()) - //} - //fmt.Println(success) - //fmt.Println(message) + //哪个单位 + bureauId := "4763978F-D464-4A3F-93D4-9857668D10A7" + //文件在哪里 + fileName := `E:\Work\dsMin\dsBaseWeb\Html\ExcelTemp\` + bureauId + ".xlsx" + success, message, err := BaseStudentDao.ImportStudentInfoExcel(fileName, bureauId,"B4A8ED19-84DB-4388-BD3D-25BACD463119","10.10.24.100") + if err != nil { + fmt.Println(err.Error()) + } + fmt.Println(success) + fmt.Println(message) } diff --git a/dsBaseWeb/Html/ExcelTemp/4763978F-D464-4A3F-93D4-9857668D10A7.xlsx b/dsBaseWeb/Html/ExcelTemp/4763978F-D464-4A3F-93D4-9857668D10A7.xlsx new file mode 100644 index 00000000..3cad745d Binary files /dev/null and b/dsBaseWeb/Html/ExcelTemp/4763978F-D464-4A3F-93D4-9857668D10A7.xlsx differ