作者 yangfu

feat: 增加任务手动触发

@@ -9,6 +9,7 @@ import ( @@ -9,6 +9,7 @@ import (
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
10 ) 10 )
11 11
  12 +// 定时同步生产计划
12 func SyncProductPlan(ctx context.Context) error { 13 func SyncProductPlan(ctx context.Context) error {
13 defer func() { 14 defer func() {
14 if r := recover(); r != nil { 15 if r := recover(); r != nil {
@@ -5,6 +5,7 @@ import ( @@ -5,6 +5,7 @@ import (
5 "github.com/linmadan/egglib-go/utils/json" 5 "github.com/linmadan/egglib-go/utils/json"
6 "github.com/linmadan/egglib-go/web/beego" 6 "github.com/linmadan/egglib-go/web/beego"
7 "github.com/linmadan/egglib-go/web/beego/utils" 7 "github.com/linmadan/egglib-go/web/beego/utils"
  8 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab"
8 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/statistics/query" 9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/statistics/query"
9 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/statistics/service" 10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/statistics/service"
10 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant" 11 "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
@@ -46,6 +47,33 @@ func (controller *StatisticsController) CommonStatisticsHandler(actionType strin @@ -46,6 +47,33 @@ func (controller *StatisticsController) CommonStatisticsHandler(actionType strin
46 } 47 }
47 } 48 }
48 49
  50 +func (controller *StatisticsController) TaskHandler() func(ctx *context.Context) {
  51 + return func(ctx *context.Context) {
  52 + task := ctx.Input.Query(":taskId")
  53 + switch task {
  54 + case "1":
  55 + crontab.AutoApproveProductAttendanceRecord(nil)
  56 + break
  57 + case "2":
  58 + crontab.AutoApproveProductRecord(nil)
  59 + break
  60 + case "3":
  61 + crontab.AutoFlushDeviceDailyRunningRecord(nil)
  62 + break
  63 + case "4":
  64 + crontab.AutoFlushDeviceDailyRunningRecordOEE(nil)
  65 + break
  66 + case "5":
  67 + crontab.AutoWorkshopPlanCompletionRecord(nil)
  68 + break
  69 + case "6":
  70 + crontab.SyncProductPlan(nil)
  71 + break
  72 + }
  73 + Response(ctx, nil, nil)
  74 + }
  75 +}
  76 +
49 func Response(ctx *context.Context, data interface{}, err error) { 77 func Response(ctx *context.Context, data interface{}, err error) {
50 var response utils.JsonResponse 78 var response utils.JsonResponse
51 if err != nil { 79 if err != nil {
  1 +package routers
  2 +
  3 +import (
  4 + "github.com/beego/beego/v2/server/web"
  5 + "gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/beego/controllers"
  6 +)
  7 +
  8 +func init() {
  9 + web.Get("/task/:taskId", (&controllers.StatisticsController{}).TaskHandler())
  10 +}