浏览代码

优化同步时间

kobe6258 1 月之前
父节点
当前提交
894aaabdc4
共有 3 个文件被更改,包括 18 次插入5 次删除
  1. 3 3
      config/config.go
  2. 1 1
      rpc/sso/sso_service.go
  3. 14 1
      task/htfutures/sync_staff_task.go

+ 3 - 3
config/config.go

@@ -136,9 +136,9 @@ type HTFutures struct {
 }
 
 type SyncTask struct {
-	EnableTask       bool `mapstructure:"enable-task" json:"enable-task" yaml:"enable-task" description:"是否启动同步任务"`
-	SyncTaskInterval int  `mapstructure:"sync-task-interval" json:"sync-task-interval" yaml:"sync-task-interval" description:"定时任务时间间隔"`
-	SyncRoleId       int  `mapstructure:"sync_role_id" json:"sync_role_id" yaml:"sync_role_id" description:"同步用户角色id"`
+	EnableTask       bool   `mapstructure:"enable-task" json:"enable-task" yaml:"enable-task" description:"是否启动同步任务"`
+	SyncTaskInterval string `mapstructure:"sync-task-interval" json:"sync-task-interval" yaml:"sync-task-interval" description:"定时任务时间间隔"`
+	SyncRoleId       int    `mapstructure:"sync_role_id" json:"sync_role_id" yaml:"sync_role_id" description:"同步用户角色id"`
 }
 type PCSG struct {
 	BloombergApiUrl string `mapstructure:"bloomberge-api-url" json:"bloomberge-api-url" yaml:"bloomberge-api-url" description:"彭博API服务地址"`

+ 1 - 1
rpc/sso/sso_service.go

@@ -89,7 +89,7 @@ func (s *SSOService) Login(ctx context.Context, req *LoginRequest) (*LoginRespon
 			Msg:     "登录失败",
 		}, nil
 	}
-	global.FILE_LOG.Info("返回的userInfo结果集%v", user)
+	global.FILE_LOG.Info("返回的userInfo结果集", user)
 	return &LoginResponse{
 		Msg: "登录成功",
 		Data: &UserInfo{

+ 14 - 1
task/htfutures/sync_staff_task.go

@@ -14,7 +14,14 @@ func StartCronJob() {
 	// 创建一个新的 cron 实例
 	c := cron.New(cron.WithSeconds())
 	//constr := "0 17 * * * *"
-	constr := "*/5 * * * * *"
+	//constr := "*/5 * * * * *"
+	var constr string
+	if global.CONFIG.HTFutures.SyncTask.SyncTaskInterval == "" {
+		constr = "0 0 0 * * *"
+	} else {
+		constr = global.CONFIG.HTFutures.SyncTask.SyncTaskInterval
+	}
+	//constr := "0 0 0 * * *"
 	// 添加定时任务
 	_, err := c.AddFunc(constr, func() {
 
@@ -89,6 +96,9 @@ func SyncETA() {
 	}
 	var Employee []eta.Admin
 	for _, item := range staffList {
+		if item.LOGINID == "" {
+			continue
+		}
 		var department *eta.SysDepartment
 		department, err = eta.GetDepartmentById(item.SUBCOMPANYID1)
 		if err != nil {
@@ -188,6 +198,9 @@ func syncCrmOAInfo() {
 	}
 	var Employee []wx_crm.SysUser
 	for _, item := range staffList {
+		if item.LOGINID == "" {
+			continue
+		}
 		idList, departmentErr := GetEmployeeDepartmentList(item.DEPARTMENTID)
 		if departmentErr != nil {
 			global.FILE_LOG.Error("获取员工部门组织架构失败:", departmentErr.Error(), "跳过同步员工", item.WORKCODE)