作者 yangfu

feat: 增加任务手动触发

... ... @@ -9,6 +9,7 @@ import (
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/log"
)
// 定时同步生产计划
func SyncProductPlan(ctx context.Context) error {
defer func() {
if r := recover(); r != nil {
... ...
... ... @@ -5,6 +5,7 @@ import (
"github.com/linmadan/egglib-go/utils/json"
"github.com/linmadan/egglib-go/web/beego"
"github.com/linmadan/egglib-go/web/beego/utils"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/crontab"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/statistics/query"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/application/statistics/service"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/constant"
... ... @@ -46,6 +47,33 @@ func (controller *StatisticsController) CommonStatisticsHandler(actionType strin
}
}
func (controller *StatisticsController) TaskHandler() func(ctx *context.Context) {
return func(ctx *context.Context) {
task := ctx.Input.Query(":taskId")
switch task {
case "1":
crontab.AutoApproveProductAttendanceRecord(nil)
break
case "2":
crontab.AutoApproveProductRecord(nil)
break
case "3":
crontab.AutoFlushDeviceDailyRunningRecord(nil)
break
case "4":
crontab.AutoFlushDeviceDailyRunningRecordOEE(nil)
break
case "5":
crontab.AutoWorkshopPlanCompletionRecord(nil)
break
case "6":
crontab.SyncProductPlan(nil)
break
}
Response(ctx, nil, nil)
}
}
func Response(ctx *context.Context, data interface{}, err error) {
var response utils.JsonResponse
if err != nil {
... ...
package routers
import (
"github.com/beego/beego/v2/server/web"
"gitlab.fjmaimaimai.com/allied-creation/allied-creation-manufacture/pkg/port/beego/controllers"
)
func init() {
web.Get("/task/:taskId", (&controllers.StatisticsController{}).TaskHandler())
}
... ...