You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
6.7 KiB

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

package BaseTeacherService
import (
"dsBaseWeb/Business/BaseOrganization/BaseOrganizationProto"
"dsBaseWeb/Business/BaseOrganization/BaseOrganizationService"
"dsBaseWeb/Business/BaseTeacher/BaseTeacherProto"
"dsBaseWeb/Business/SysDict/SysDictProto"
"dsBaseWeb/Business/SysDict/SysDictService"
"dsBaseWeb/Utils/CommonUtil"
"dsBaseWeb/Utils/ConfigUtil"
"dsBaseWeb/Utils/LogUtil"
"os"
"path/filepath"
"strings"
"time"
)
func PageTeacherInfo(page int32, limit int32, orgId string, xm string, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
Reply, err := PageBaseTeacher(BaseTeacherProto.QueryArg{Page: page, Limit: limit, OrgId: orgId, Xm: xm, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
if Reply.List != "[]" {
//补充性别名称
codeArr := CommonUtil.ListCollectAttributes(Reply.List, "xbm")
DictReply, _ := SysDictService.PageSysDictMultipleDictCode(SysDictProto.MultipleQueryArg{DictKind: "xbm", MultipleDictCode: codeArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
handleListStr := CommonUtil.ListMerge(Reply.List, DictReply.List, "xbm", "dict_code", "xb_name", "dict_value")
Reply.List = handleListStr
//补充部门名称
codeArr = CommonUtil.ListCollectAttributes(Reply.List, "org_id")
OrgReply, _ := BaseOrganizationService.GetMultipleBaseOrganization(codeArr)
handleListStr = CommonUtil.ListMerge(Reply.List, OrgReply.List, "org_id", "org_id", "org_name", "org_name")
Reply.List = handleListStr
//补充学段名称
codeArr = CommonUtil.ListCollectAttributes(Reply.List, "stage_id")
StageReply, _ := SysDictService.GetStageName(SysDictProto.GetStageNameArg{StageId: codeArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
handleListStr = CommonUtil.ListMerge(Reply.List, StageReply.List, "stage_id", "stage_id", "stage_name", "stage_name")
Reply.List = handleListStr
//补充学科名称
codeArr = CommonUtil.ListCollectAttributes(Reply.List, "subject_id")
SubjectReply, _ := SysDictService.GetSubjectName(SysDictProto.GetSubjectNameArg{SubjectId: codeArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
handleListStr = CommonUtil.ListMerge(Reply.List, SubjectReply.List, "subject_id", "subject_id", "subject_name", "subject_name")
Reply.List = handleListStr
}
return Reply, err
}
func GetTeacherInfo(personId string, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
Reply, err := GetBaseTeacher(BaseTeacherProto.ModelArg{PersonId: personId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
if Reply.List != "[]" {
//补充部门名称
codeArr := CommonUtil.ListCollectAttributes(Reply.List, "org_id")
orgReply, _ := BaseOrganizationService.GetBaseOrganization(BaseOrganizationProto.ModelArg{OrgId: codeArr[0], ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
handleListStr := CommonUtil.ListMerge(Reply.List, orgReply.List, "org_id", "org_id", "org_name", "org_name")
Reply.List = handleListStr
}
return Reply, err
}
func AddTeacherInfo(orgId string, xm string, xbm string, csrq string, sfzjlxm string, sfzjh string, mzm string, zzmmm string, zcm string, bzlbm string, xlm string, xwm string, cjny string, stageId string, subjectId string, lxdh string, dzxx string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
Reply, err := AddBaseTeacher(BaseTeacherProto.ModelArg{OrgId: orgId, Xm: xm, Xbm: xbm, Csrq: csrq, Sfzjlxm: sfzjlxm, Sfzjh: sfzjh, Mzm: mzm, Zzmmm: zzmmm, Zcm: zcm, Bzlbm: bzlbm, Xlm: xlm, Xwm: xwm, Cjny: cjny, StageId: stageId, SubjectId: subjectId, Lxdh: lxdh, Dzxx: dzxx, SortId: sortId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
return Reply, err
}
func DeleteTeacherInfo(ids string, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
idsArr := strings.Split(ids, ",")
Reply, err := DeleteBaseTeacher(BaseTeacherProto.DeleteIdsArg{Ids: idsArr, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
return Reply, err
}
func UpdateTeacherInfo(personId string, xm string, xbm string, csrq string, sfzjlxm string, sfzjh string, mzm string, zzmmm string, zcm string, bzlbm string, xlm string, xwm string, cjny string, stageId string, subjectId string, lxdh string, dzxx string, sortId int32, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
forceUpdateFields := []string{"cjny", "lxdh", "dzxx"}
Reply, err := UpdateBaseTeacher(BaseTeacherProto.ModelArg{PersonId: personId, Xm: xm, Xbm: xbm, Csrq: csrq, Sfzjlxm: sfzjlxm, Sfzjh: sfzjh, Mzm: mzm, Zzmmm: zzmmm, Zcm: zcm, Bzlbm: bzlbm, Xlm: xlm, Xwm: xwm, Cjny: cjny, StageId: stageId, SubjectId: subjectId, Lxdh: lxdh, Dzxx: dzxx, SortId: sortId, ForceUpdateFields: forceUpdateFields, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
return Reply, err
}
func ExportTeacherAccountExcel(bureauId string, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
Reply, err := ExportTeacherAccountInfoExcel(BaseTeacherProto.ModelArg{BureauId: bureauId, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
return Reply, err
}
func ExportTeacherExcel(bureauId string, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
Reply, err := ExportTeacherInfoExcel(BaseTeacherProto.ModelArg{BureauId: bureauId, ExportExcelStatus: 1, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
return Reply, err
}
func DownLoadTeacherTemplateExcel(bureauId string, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
Reply, err := ExportTeacherInfoExcel(BaseTeacherProto.ModelArg{BureauId: bureauId, ExportExcelStatus: 0, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
return Reply, err
}
func ImportTeacherExcel(bureauId string, excelPath string, actionPersonId string, actionIpAddress string) (*BaseTeacherProto.Reply, error) {
Reply, err := ImportTeacherInfoExcel(BaseTeacherProto.ImportArg{BureauId: bureauId, ExcelPath: excelPath, ActionPersonId: actionPersonId, ActionIpAddress: actionIpAddress})
return Reply, err
}
//删除7天前无用的模板文件
func DeleteInvalidFile(path string) {
//7天
diffTime := int64(3600 * 24 * ConfigUtil.DiffTime)
//当前时间使用Unix时间戳
nowTime := time.Now().Unix()
err := filepath.Walk(path, func(path string, f os.FileInfo, err error) error {
if f == nil {
return err
}
fileTime := f.ModTime().Unix()
if (nowTime - fileTime) > diffTime { //判断文件是否超过7天
//fmt.Printf("Delete file %v !\r\n", path)
os.RemoveAll(path)
}
return nil
})
if err != nil {
LogUtil.Error("删除7天前无用的模板文件错误: ", err.Error())
}
}