kobe6258 7 сар өмнө
parent
commit
2cf70a9494

+ 10 - 5
config/config.go

@@ -118,11 +118,11 @@ type Xiangyu struct {
 
 // 海通的配置
 type HTFutures struct {
-	APIAuth           bool   `mapstructure:"api-auth" json:"api-auth" yaml:"api-auth" description:"海通SSO登录签名认证"`
-	PrivateKeyPemPath string `mapstructure:"private-key-pem-path" json:"private-key-pem-path" yaml:"private-key-pem-path" description:"私钥文件目录"`
-	SSOAuthHost       string `mapstructure:"sso-auth-host" json:"sso-auth-host" yaml:"sso-auth-host" description:"用户认证平台地址"`
-	OaDBDns           string `mapstructure:"oa-db-dns" json:"oa-db-dns" yaml:"oa-db-dns" description:"OA数据库连接地址"`
-	EnableTask        bool   `mapstructure:"enable-task" json:"enable-task" yaml:"enable-task" description:"启动任务"`
+	APIAuth           bool     `mapstructure:"api-auth" json:"api-auth" yaml:"api-auth" description:"海通SSO登录签名认证"`
+	PrivateKeyPemPath string   `mapstructure:"private-key-pem-path" json:"private-key-pem-path" yaml:"private-key-pem-path" description:"私钥文件目录"`
+	SSOAuthHost       string   `mapstructure:"sso-auth-host" json:"sso-auth-host" yaml:"sso-auth-host" description:"用户认证平台地址"`
+	OaDBDns           string   `mapstructure:"oa-db-dns" json:"oa-db-dns" yaml:"oa-db-dns" description:"OA数据库连接地址"`
+	SyncTask          SyncTask `mapstructure:"sync-task" json:"sync-task" yaml:"sync-task" description:"同步任务"`
 	//UserKey               string `mapstructure:"user-key" json:"user-key" yaml:"user-key" description:"统一平台秘钥"`
 	//DefaultRoleId         int    `mapstructure:"default-role-id" json:"default-role-id" yaml:"default-role-id" description:"默认的角色id"`
 	//IndexSyncHost         string `mapstructure:"index-sync-host" json:"index-sync-host" yaml:"index-sync-host" description:"指标同步平台地址"`
@@ -134,6 +134,11 @@ type HTFutures struct {
 	//IndexCrmTarget        string `mapstructure:"index-crm-target" json:"index-crm-target" yaml:"index-crm-target" description:"crm指标平台编码"`
 }
 
+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"`
+}
 type PCSG struct {
 	BloombergApiUrl string `mapstructure:"bloomberge-api-url" json:"bloomberge-api-url" yaml:"bloomberge-api-url" description:"彭博API服务地址"`
 }

+ 1 - 1
core/run_server.go

@@ -32,7 +32,7 @@ func RunServe() {
 	if global.CONFIG.HTFutures.OaDBDns != "" {
 		init_serve.DMDataBase()
 	}
-	if global.CONFIG.HTFutures.EnableTask {
+	if global.CONFIG.HTFutures.SyncTask.EnableTask {
 		HTtask.StartCronJob()
 	}
 	if global.CONFIG.OracleJY.Account != "" {

+ 9 - 3
task/htfutures/sync_staff_task.go

@@ -12,11 +12,16 @@ import (
 func StartCronJob() {
 	// 创建一个新的 cron 实例
 	c := cron.New(cron.WithSeconds())
+	seconds := global.CONFIG.HTFutures.SyncTask.SyncTaskInterval
+	if seconds == 0 {
+		seconds = 60
+	}
+	cornStr := fmt.Sprintf("*/%d * * * * *", seconds)
+	global.FILE_LOG.Info("cron表达式", cornStr)
 	// 添加定时任务
-	_, err := c.AddFunc("*/5 * * * * *", func() {
+	_, err := c.AddFunc(cornStr, func() {
 		syncCrmOAInfo()
 	})
-
 	if err != nil {
 		fmt.Println("添加定时任务失败:", err)
 		return
@@ -109,9 +114,10 @@ func syncCrmOAInfo() {
 		}
 		fillSize := 4 - len(idList)
 		var departments []int
+		departments = append(departments, idList...)
 		if fillSize > 0 {
 			for i := 0; i < fillSize; i++ {
-				departments = append(departments, 0)
+				departments = append([]int{0}, departments...)
 			}
 		}
 		sysUser := wx_crm.SysUser{