diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go index 74cd1544..a38c7f87 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherDao/BaseTeacherDao.go @@ -1261,3 +1261,21 @@ func DeleteTeacherAllPosition(personIds []string) (bool, error) { } return true, nil } + +/** +功能:获取指定人员在指定单位下有哪些职务 +作者:黄海 +时间:2020-08-20 +*/ +func GetPositionInfoByPersonIdAndBureauId(personId string, bureauId string) ([]string, error) { + sql := `select id from t_base_teacher_position where person_id=? and bureau_id=? and b_use=1` + list, err := db.SQL(sql, personId, bureauId).Query().List() + if err != nil { + return nil, err + } + res := make([]string, len(list)) + for i := range list { + res[i] = list[i]["id"].(string) + } + return res, nil +} diff --git a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go index 09136bfa..2d28eb5a 100644 --- a/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go +++ b/dsBaseRpc/RpcService/BaseTeacher/BaseTeacherService/BaseTeacherService.go @@ -19,6 +19,7 @@ import ( "dsBaseRpc/Utils/PinYinUtil" "dsBaseRpc/Utils/SqlKit" "dsBaseRpc/models" + "encoding/json" "fmt" ) @@ -36,8 +37,9 @@ func (s *Rpc) GetBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) var reply BaseTeacherProto.Reply //通用获取单条 list := SqlKit.QueryByIds([]string{in.PersonId}, "t_base_teacher") - //处理从教年月 + if len(list) > 0 { + //处理从教年月 if list[0]["cjny"].(string)[0:4] == "1900" { list[0]["cjny"] = "" } @@ -50,6 +52,25 @@ func (s *Rpc) GetBaseTeacher(ctx context.Context, in *BaseTeacherProto.ModelArg) return &reply, err } list[0]["org_name"] = orgName + //人员所在单位,获取人员在此单位下的职务 + if in.BureauId != "" { + positionArray, err := BaseTeacherDao.GetPositionInfoByPersonIdAndBureauId(in.PersonId, in.BureauId) + if err != nil { + reply.Success = false + reply.Message = Const.DataBaseActionError + LogUtil.Error(ErrorConst.SqlQueryError, "执行GetPositionInfoByPersonIdAndBureauId时发生严重错误:"+err.Error()) + return &reply, err + } + //转换数组为JSON数据格式 + b, err := json.Marshal(positionArray) + if err != nil { + reply.Success = false + reply.Message = Const.DataBaseActionError + LogUtil.Error(ErrorConst.SqlQueryError, "执行positionArray转JSON时发生严重错误:"+err.Error()) + return &reply, err + } + list[0]["position_id_array"] = string(b) + } } //将结果序列化 reply.Success = true diff --git a/dsBaseRpc/main.go b/dsBaseRpc/main.go index fcf8c69c..329dea97 100644 --- a/dsBaseRpc/main.go +++ b/dsBaseRpc/main.go @@ -55,7 +55,7 @@ func main() { //添加定时清理垃圾的代码 c := cron.New(cron.WithSeconds()) c.AddFunc("0 0 1 * * *", func() { - + //清除导入数据的临时表 var db = DbUtil.Engine sql := "truncate table t_base_teacher_import_excel"