|
|
|
@ -57,7 +57,7 @@ func GetByIds(ids []string) ([]models.TBaseTeacher, error) {
|
|
|
|
|
*/
|
|
|
|
|
func GetMaxSortId(OrgId string) int64 {
|
|
|
|
|
//取最大值
|
|
|
|
|
sql := "select ifnull(max(sort_id),0) as maxSortId from t_base_teacher where org_id=? and b_use=1"
|
|
|
|
|
sql := "select ifnull(max(sort_id),0) as maxSortId from t_base_teacher_org where org_id=? and b_use=1"
|
|
|
|
|
listSort, _ := db.SQL(sql, OrgId).Query().List()
|
|
|
|
|
SortId := listSort[0]["maxSortId"].(int64)
|
|
|
|
|
return SortId
|
|
|
|
@ -97,8 +97,8 @@ func PageBaseTeacher(in *BaseTeacherProto.QueryArg) ([]map[string]interface{}, i
|
|
|
|
|
// 注意使用limit时要使用方言
|
|
|
|
|
// 注意两个表关联时的on用法:
|
|
|
|
|
var myBuilder = builder.Dialect(builder.MYSQL).Select("t1.*").
|
|
|
|
|
From("t_base_teacher as t1").
|
|
|
|
|
OrderBy("t1.sort_id")
|
|
|
|
|
From("t_base_teacher as t1").LeftJoin("t_base_teacher_org as t2", "t1.person_id=t2.person_id").
|
|
|
|
|
OrderBy("t2.sort_id")
|
|
|
|
|
//所在单位ID
|
|
|
|
|
list := SqlKit.QueryByIds([]string{in.OrgId}, "t_base_organization")
|
|
|
|
|
if list == nil {
|
|
|
|
@ -107,10 +107,10 @@ func PageBaseTeacher(in *BaseTeacherProto.QueryArg) ([]map[string]interface{}, i
|
|
|
|
|
bureauId := list[0]["bureau_id"].(string)
|
|
|
|
|
if in.OrgId == bureauId {
|
|
|
|
|
//如果是单位ID
|
|
|
|
|
myBuilder.And(builder.Eq{"t1.bureau_id": in.OrgId})
|
|
|
|
|
myBuilder.And(builder.Eq{"t2.bureau_id": in.OrgId})
|
|
|
|
|
} else {
|
|
|
|
|
//如果是部门ID
|
|
|
|
|
myBuilder.And(builder.Eq{"t1.org_id": in.OrgId})
|
|
|
|
|
myBuilder.And(builder.Eq{"t2.org_id": in.OrgId})
|
|
|
|
|
}
|
|
|
|
|
//姓名模糊搜索
|
|
|
|
|
myBuilder.And(builder.Like{"t1.xm", in.Xm})
|
|
|
|
@ -182,27 +182,16 @@ func FillLoginInfo(list *[]map[string]interface{}) error {
|
|
|
|
|
//批量教师修改部门
|
|
|
|
|
func ReviseTeacherOrg(Ids []string, OrgId string) error {
|
|
|
|
|
//1、目前这个部门,最大的SortId
|
|
|
|
|
sql := "select ifnull(max(sort_id),0) as maxSortId from t_base_teacher where b_use=1 and org_id=?"
|
|
|
|
|
sql := "select ifnull(max(sort_id),0) as maxSortId from t_base_teacher_org where b_use=1 and org_id=?"
|
|
|
|
|
listSortId, _ := db.SQL(sql, OrgId).Query().List()
|
|
|
|
|
maxSortId := int32(listSortId[0]["maxSortId"].(int64))
|
|
|
|
|
//2、声明事务
|
|
|
|
|
session := db.NewSession()
|
|
|
|
|
defer session.Close()
|
|
|
|
|
session.Begin()
|
|
|
|
|
|
|
|
|
|
for i := range Ids {
|
|
|
|
|
var person models.TBaseTeacher
|
|
|
|
|
person.OrgId = OrgId
|
|
|
|
|
person.SortId = maxSortId + int32(i+1)
|
|
|
|
|
_, err := db.ID(Ids[i]).Cols("org_id", "sort_id").Update(person)
|
|
|
|
|
if err != nil {
|
|
|
|
|
session.Rollback()
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//提交事务
|
|
|
|
|
err := session.Commit()
|
|
|
|
|
return err
|
|
|
|
|
//2、删除旧的部门关系
|
|
|
|
|
DeleteTeacherOrgInfo(Ids, OrgId)
|
|
|
|
|
|
|
|
|
|
//3、插入人员部门关系
|
|
|
|
|
AddTeacherOrgInfo(Ids, OrgId, 1, maxSortId)
|
|
|
|
|
return nil
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//导出本单位教职工账号信息到EXCEL
|
|
|
|
@ -210,11 +199,13 @@ func ExportTeacherAccountInfoExcel(in *BaseTeacherProto.ModelArg) ([]map[string]
|
|
|
|
|
var myBuilder = builder.Dialect(builder.MYSQL).Select("t1.*,t3.org_name").
|
|
|
|
|
From("t_sys_loginperson as t1").
|
|
|
|
|
InnerJoin("t_base_teacher as t2", "t1.person_id=t2.person_id").
|
|
|
|
|
InnerJoin("t_base_organization as t3", "t2.org_id=t3.org_id")
|
|
|
|
|
InnerJoin("t_base_teacher_org as t4", "t2.person_id=t4.person_id").
|
|
|
|
|
InnerJoin("t_base_organization as t3", "t4.org_id=t3.org_id")
|
|
|
|
|
|
|
|
|
|
myBuilder.Where(builder.Eq{"t1.b_use": 1}).
|
|
|
|
|
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})
|
|
|
|
|
And(builder.Eq{"t3.bureau_id": in.BureauId}).And(builder.Eq{"t1.identity_id": 2})
|
|
|
|
|
myBuilder.OrderBy("t2.sort_id").OrderBy("t2.id_int")
|
|
|
|
|
sql, err := myBuilder.ToBoundSQL()
|
|
|
|
|
if err != nil {
|
|
|
|
@ -303,8 +294,9 @@ func ExportTeacherInfoExcel(targetPath string, bureauId string, ExportExcelStatu
|
|
|
|
|
sql := `select t2.org_name,t1.xm,
|
|
|
|
|
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 order by t1.sort_id,t1.id_int`
|
|
|
|
|
from t_base_teacher as t1 inner join t_base_teacher_org as t3 on t1.person_id=t3.person_id
|
|
|
|
|
inner join t_base_organization as t2 on t3.org_id=t2.org_id
|
|
|
|
|
where t3.bureau_id=? and t1.identity_id=2 and t1.b_use=1 order by t3.sort_id,t1.id_int`
|
|
|
|
|
list, _ := db.SQL(sql, bureauId).Query().List()
|
|
|
|
|
for i := range list {
|
|
|
|
|
record := list[i]
|
|
|
|
@ -786,12 +778,8 @@ func insertTeacher(batchId string, bureauModel models.TBaseOrganization, actionP
|
|
|
|
|
var model models.TBaseTeacher
|
|
|
|
|
//身份
|
|
|
|
|
model.IdentityId = 2
|
|
|
|
|
//所在部门
|
|
|
|
|
model.OrgId = r1.OrgId
|
|
|
|
|
//人员编号
|
|
|
|
|
model.PersonId = CommonUtil.GetUUID()
|
|
|
|
|
//单位
|
|
|
|
|
model.BureauId = bureauModel.BureauId
|
|
|
|
|
//导入即可用
|
|
|
|
|
model.BUse = 1
|
|
|
|
|
//身份证号
|
|
|
|
@ -800,14 +788,7 @@ func insertTeacher(batchId string, bureauModel models.TBaseOrganization, actionP
|
|
|
|
|
model.Sfzjlxm = r1.Sfzjlxm
|
|
|
|
|
//编制
|
|
|
|
|
model.Bzlbm = r1.Bzlbm
|
|
|
|
|
//所属省份
|
|
|
|
|
model.ProvinceCode = bureauModel.ProvinceCode
|
|
|
|
|
//所属城市
|
|
|
|
|
model.CityCode = bureauModel.CityCode
|
|
|
|
|
//县区
|
|
|
|
|
model.DistrictCode = bureauModel.DistrictCode
|
|
|
|
|
//主校
|
|
|
|
|
model.MainSchoolId = bureauModel.MainSchoolId
|
|
|
|
|
|
|
|
|
|
//从教年月
|
|
|
|
|
model.Cjny = DateUtil.ConvertDate("1900-01-01")
|
|
|
|
|
//出生日期与性别
|
|
|
|
@ -821,8 +802,6 @@ func insertTeacher(batchId string, bureauModel models.TBaseOrganization, actionP
|
|
|
|
|
model.Csrq = DateUtil.ConvertDate("1980-01-01")
|
|
|
|
|
model.Xbm = "1"
|
|
|
|
|
}
|
|
|
|
|
//排序号
|
|
|
|
|
model.SortId = 1
|
|
|
|
|
//学段
|
|
|
|
|
model.StageId = r1.StageId
|
|
|
|
|
//学科
|
|
|
|
@ -853,6 +832,8 @@ func insertTeacher(batchId string, bureauModel models.TBaseOrganization, actionP
|
|
|
|
|
model.StateId = 1
|
|
|
|
|
//添加到数组中
|
|
|
|
|
teacherArray = append(teacherArray, model)
|
|
|
|
|
//保存人员所在的部门信息
|
|
|
|
|
AddTeacherOrgInfo([]string{model.PersonId}, r1.OrgId, 1, 1)
|
|
|
|
|
}
|
|
|
|
|
//批量插入
|
|
|
|
|
if len(teacherArray) > 0 {
|
|
|
|
@ -862,7 +843,6 @@ func insertTeacher(batchId string, bureauModel models.TBaseOrganization, actionP
|
|
|
|
|
}
|
|
|
|
|
//记录日志
|
|
|
|
|
ActionLog(teacherArray, Const.ActionInsert, actionPersonId, actionIp)
|
|
|
|
|
|
|
|
|
|
//产生登录名
|
|
|
|
|
accountArray := SysLoginpersonService.GenerateLoginAccount(2, int64(len(teacherImportExcelArray)))
|
|
|
|
|
var loginpersonModels = make([]models.TSysLoginperson, 0)
|
|
|
|
@ -915,12 +895,8 @@ func updateTeacherImport(batchId string, bureauModel models.TBaseOrganization, a
|
|
|
|
|
var model models.TBaseTeacher
|
|
|
|
|
//身份
|
|
|
|
|
model.IdentityId = 2
|
|
|
|
|
//所在部门
|
|
|
|
|
model.OrgId = r1.OrgId
|
|
|
|
|
//人员编号
|
|
|
|
|
model.PersonId = MapSfzjh[r1.Sfzjh] //通过身份证件号反向获取到人员的id
|
|
|
|
|
//单位
|
|
|
|
|
model.BureauId = bureauModel.BureauId
|
|
|
|
|
//导入即可用
|
|
|
|
|
model.BUse = 1
|
|
|
|
|
//身份证号
|
|
|
|
@ -929,14 +905,6 @@ func updateTeacherImport(batchId string, bureauModel models.TBaseOrganization, a
|
|
|
|
|
model.Sfzjlxm = r1.Sfzjlxm
|
|
|
|
|
//编制
|
|
|
|
|
model.Bzlbm = r1.Bzlbm
|
|
|
|
|
//所属省份
|
|
|
|
|
model.ProvinceCode = bureauModel.ProvinceCode
|
|
|
|
|
//所属城市
|
|
|
|
|
model.CityCode = bureauModel.CityCode
|
|
|
|
|
//县区
|
|
|
|
|
model.DistrictCode = bureauModel.DistrictCode
|
|
|
|
|
//主校
|
|
|
|
|
model.MainSchoolId = bureauModel.MainSchoolId
|
|
|
|
|
//从教年月
|
|
|
|
|
model.Cjny = DateUtil.ConvertDate("1999-09-01")
|
|
|
|
|
//出生日期与性别
|
|
|
|
@ -982,6 +950,8 @@ func updateTeacherImport(batchId string, bureauModel models.TBaseOrganization, a
|
|
|
|
|
model.StateId = 1
|
|
|
|
|
//添加到数组中
|
|
|
|
|
teacherArray = append(teacherArray, model)
|
|
|
|
|
//保存人员所在的部门信息
|
|
|
|
|
AddTeacherOrgInfo([]string{model.PersonId}, r1.OrgId, 1, 1)
|
|
|
|
|
}
|
|
|
|
|
//批量更新
|
|
|
|
|
if len(teacherArray) > 0 {
|
|
|
|
@ -1041,7 +1011,7 @@ func getOrgNameMap(bureauId string) (map[string]string, error) {
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-08-05
|
|
|
|
|
*/
|
|
|
|
|
func AddTeacherOrgInfo(personIds []string, orgId string, isMain int32) (bool, string, error) {
|
|
|
|
|
func AddTeacherOrgInfo(personIds []string, orgId string, isMain int32, fromSortId int32) (bool, string, error) {
|
|
|
|
|
//(1)获取单位ID
|
|
|
|
|
list := SqlKit.QueryByIds([]string{orgId}, "t_base_organization")
|
|
|
|
|
if len(list) == 0 {
|
|
|
|
@ -1067,12 +1037,13 @@ func AddTeacherOrgInfo(personIds []string, orgId string, isMain int32) (bool, st
|
|
|
|
|
model.CityCode = CityCode
|
|
|
|
|
model.DistrictCode = DistrictCode
|
|
|
|
|
model.MainSchoolId = mainSchoolId
|
|
|
|
|
model.SortId = 1
|
|
|
|
|
model.SortId = fromSortId
|
|
|
|
|
model.IsMain = isMain
|
|
|
|
|
_, err := db.Insert(model)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return false, "插入人员部门关系表时失败!", err
|
|
|
|
|
}
|
|
|
|
|
fromSortId++
|
|
|
|
|
}
|
|
|
|
|
return true, "保存成功!", nil
|
|
|
|
|
}
|
|
|
|
@ -1091,3 +1062,28 @@ func DeleteTeacherOrgInfo(personIds []string, orgId string) error {
|
|
|
|
|
_, err := db.SQL(sql).Execute()
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:将人员从全部部门下删除,支持批量操作
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-08-05
|
|
|
|
|
*/
|
|
|
|
|
func DeleteTeacherOrgInfoAll(personIds []string) error {
|
|
|
|
|
//主部门是不能删除的,主部门只能随着人员删除而删除
|
|
|
|
|
//批量删除教师在此部门的信息
|
|
|
|
|
var myBuilder = builder.Dialect(builder.MYSQL).Update(builder.Eq{"b_use": -2}).
|
|
|
|
|
From("t_base_teacher_org").Where(builder.Eq{"b_use": 1}.And(builder.In("person_id", personIds)))
|
|
|
|
|
sql, _ := myBuilder.ToBoundSQL()
|
|
|
|
|
_, err := db.SQL(sql).Execute()
|
|
|
|
|
return err
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
功能:修改指定人员在指定部门下的排序号
|
|
|
|
|
作者:黄海
|
|
|
|
|
时间:2020-08-05
|
|
|
|
|
*/
|
|
|
|
|
func UpdateSortId(personId string, orgId string, sortId int32) {
|
|
|
|
|
sql := `update t_base_teacher_org set sort_id=? where person_id=? and org_id=?`
|
|
|
|
|
db.SQL(sql, sortId, personId, orgId).Execute()
|
|
|
|
|
}
|
|
|
|
|