zhangqian
2023-10-09 41a9bf370cff977ff8afe122a7610e07fa6c3b80
api/v1/task.go
@@ -9,7 +9,6 @@
   "apsClient/model/response"
   "apsClient/nsq"
   "apsClient/pkg/contextx"
   "apsClient/pkg/convertx"
   "apsClient/pkg/ecode"
   "apsClient/pkg/logx"
   "apsClient/pkg/safe"
@@ -18,7 +17,8 @@
   "errors"
   "fmt"
   "github.com/gin-gonic/gin"
   "gorm.io/gorm"
   "github.com/jinzhu/gorm"
   "github.com/spf13/cast"
   "sort"
   "sync"
   "time"
@@ -115,6 +115,7 @@
   taskResponse.Prompt = conf.Conf.Prompt
   taskResponse.ChannelAmount = channelAmount
   taskResponse.TaskCount = service.NewTaskService().NewTaskCount()
   ctx.OkWithDetailed(taskResponse)
}
@@ -136,7 +137,7 @@
      ctx.Fail(ecode.ParamsErr)
      return
   }
   id := convertx.Atoi(idx)
   id := cast.ToUint(idx)
   procedure, code := service.NewTaskService().GetProcedureById(id)
   if code != ecode.OK {
      ctx.Fail(code)
@@ -196,10 +197,18 @@
      ctx.Fail(ecode.ParamsErr)
      return
   }
   id := convertx.Atoi(idx)
   id := cast.ToUint(idx)
   procedure, code := service.NewTaskService().GetProcedureById(id)
   if code != ecode.OK {
      ctx.Fail(code)
      return
   }
   if procedure.Status == model.ProcedureStatusFinished {
      ctx.Ok()
      return
   }
   if procedure.Status != model.ProcedureStatusProcessing {
      ctx.Fail(ecode.ParamsErr)
      return
   }
   err := service.NewTaskService().UpdateProcedureStatus(nil, id, model.ProcedureStatusFinished, procedure.Channel)
@@ -285,7 +294,7 @@
      return
   }
   plcConfig, code := service.NewDevicePlcService().GetDevicePlc()
   if code != ecode.OK || plcConfig.Id == 0 {
   if code != ecode.OK || plcConfig.ID == 0 {
      ctx.FailWithMsg(ecode.NeedConfirmedErr, "请先配置PLC")
      return
   }