zhangqian
2023-09-23 14fc2f577e2c0b7b146c1a430e9438f317ad5b0c
任务接收增加channel字段,postion字段改为channel
17个文件已修改
227 ■■■■ 已修改文件
api/v1/plc.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/task.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
crontask/cron_task.go 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 30 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 23 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/common/common.go 7 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/device_plc.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/procedures.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/production_progress.go 10 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/request/task.go 8 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
model/response/common.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
nsq/msg_handler.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/cache_store.go 38 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/plc.go 6 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/progress.go 18 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/task.go 14 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
api/v1/plc.go
@@ -31,8 +31,8 @@
    if !ok {
        return
    }
    finishNumber, _ := service.PlcCacheGet(params.Position, constvar.PlcCacheKeyFinishNumber)
    totalNumber, _ := service.PlcCacheGet(params.Position, constvar.PlcCacheKeyTotalNumber)
    finishNumber, _ := service.PlcCacheGet(params.Channel, constvar.PlcCacheKeyFinishNumber)
    totalNumber, _ := service.PlcCacheGet(params.Channel, constvar.PlcCacheKeyTotalNumber)
    resp := new(response.ProductProgress)
    resp.FinishNumber = cast.ToInt(finishNumber)
    resp.TotalNumber = cast.ToInt(totalNumber)
@@ -40,7 +40,7 @@
    plcStatus := 1 //断开连接
    isConnect := service.PlcIsConnect()
    if isConnect {
        lastUpdateTime := service.FinishUpdateTimeGet(params.Position)
        lastUpdateTime := service.FinishUpdateTimeGet(params.Channel)
        if time.Now().Unix()-cast.ToInt64(lastUpdateTime) < conf.Conf.PLC.StandbyTime { //生产
            plcStatus = 2
        } else {
api/v1/task.go
@@ -107,7 +107,7 @@
        params.Page = 1
    }
    if params.PageSize <= 0 {
        params.PageSize = 1
        params.PageSize = 100
    }
    taskResponse, code := service.NewTaskService().GetTask(params.Page, params.PageSize, service.TaskModeUnStarted) //时间到了未开始的
@@ -201,7 +201,7 @@
        ctx.Fail(code)
        return
    }
    err := service.NewTaskService().UpdateProcedureStatus(nil, id, model.ProcedureStatusFinished, procedure.Position)
    err := service.NewTaskService().UpdateProcedureStatus(nil, id, model.ProcedureStatusFinished, procedure.Channel)
    if err != nil {
        logx.Errorf("UpdateProcedureStatus err: %v", err.Error())
        ctx.Fail(ecode.UnknownErr)
@@ -262,11 +262,11 @@
    }
    err = model.WithTransaction(func(db *gorm.DB) error {
        err = taskService.UpdateProcedureStatusAndPosition(db, params.ProcedureId, model.ProcedureStatusProcessing, params.Position)
        err = taskService.UpdateProcedureStatusAndChannel(db, params.ProcedureId, model.ProcedureStatusProcessing, params.Channel)
        if err != nil {
            return err
        }
        procedure.Position = params.Position
        procedure.Channel = params.Channel
        err = taskService.UpdateOrderStatus(db, order.ID, model.OrderStatusProcessing)
        if err != nil {
            return err
@@ -288,11 +288,11 @@
    if err != nil {
        logx.Errorf("SendProcessParams: %v", err.Error())
        err = model.WithTransaction(func(db *gorm.DB) error {
            err = taskService.UpdateProcedureStatusAndPosition(db, params.ProcedureId, model.ProcedureStatusWaitProcess, params.Position)
            err = taskService.UpdateProcedureStatusAndChannel(db, params.ProcedureId, model.ProcedureStatusWaitProcess, params.Channel)
            if err != nil {
                return err
            }
            procedure.Position = params.Position
            procedure.Channel = params.Channel
            err = taskService.UpdateOrderStatus(db, order.ID, model.OrderStatusWaitProcess)
            if err != nil {
                return err
@@ -307,7 +307,7 @@
        return
    }
    plcConfig.CurrentTryTimes = 0
    err = service.PlcWrite(plcConfig, constvar.PlcStartAddressTypeTotalNumber, params.Position, order.Amount.IntPart())
    err = service.PlcWrite(plcConfig, constvar.PlcStartAddressTypeTotalNumber, params.Channel, order.Amount.IntPart())
    if err != nil {
        ctx.FailWithMsg(ecode.NeedConfirmedErr, "糟糕,工艺下发失败。")
        return
crontask/cron_task.go
@@ -38,8 +38,8 @@
                }
                finishNumber := cast.ToInt64(value)
                if finishNumber != 0 {
                    service.PlcCacheSet(addressItem.Position, constvar.PlcCacheKeyFinishNumber, finishNumber)
                    _ = service.NewProgressService().UpdateProgress(addressItem.Position, cast.ToInt64(finishNumber))
                    service.PlcCacheSet(addressItem.Channel, constvar.PlcCacheKeyFinishNumber, finishNumber)
                    _ = service.NewProgressService().UpdateProgress(addressItem.Channel, cast.ToInt64(finishNumber))
                }
                logx.Infof("plc read finish number: %v", finishNumber)
            }
@@ -64,8 +64,8 @@
                }
                totalNumber := cast.ToInt64(value)
                if totalNumber != 0 {
                    service.PlcCacheSet(addressItem.Position, constvar.PlcCacheKeyTotalNumber, totalNumber)
                    _ = service.NewProgressService().UpdateProgress(addressItem.Position, cast.ToInt64(totalNumber))
                    service.PlcCacheSet(addressItem.Channel, constvar.PlcCacheKeyTotalNumber, totalNumber)
                    _ = service.NewProgressService().UpdateProgress(addressItem.Channel, cast.ToInt64(totalNumber))
                }
                logx.Infof("plc read total number: %v", totalNumber)
            }
@@ -83,14 +83,14 @@
    if code != ecode.OK {
        return
    }
    var positions []int
    var channels []int32
    for _, item := range plcConfig.Details {
        if item.FieldName == constvar.PlcStartAddressTypeFinishNumber {
            positions = append(positions, item.Position)
            channels = append(channels, item.Channel)
        }
    }
    for _, position := range positions {
        progress, err := service.NewProgressService().GetCurrentProgress(position)
    for _, channel := range channels {
        progress, err := service.NewProgressService().GetCurrentProgress(channel)
        if err != nil {
            return
        }
docs/docs.go
@@ -634,6 +634,10 @@
                        "type": "string"
                    }
                },
                "channel": {
                    "description": "通道序号",
                    "type": "integer"
                },
                "deviceId": {
                    "type": "string"
                },
@@ -775,6 +779,10 @@
        "model.DevicePlcAddress": {
            "type": "object",
            "properties": {
                "channel": {
                    "description": "数据起始地址",
                    "type": "integer"
                },
                "fieldName": {
                    "description": "对应系统字段",
                    "allOf": [
@@ -785,10 +793,6 @@
                },
                "length": {
                    "description": "数据长度",
                    "type": "integer"
                },
                "position": {
                    "description": "数据起始地址",
                    "type": "integer"
                },
                "startAddress": {
@@ -947,6 +951,10 @@
        "model.Procedures": {
            "type": "object",
            "properties": {
                "channel": {
                    "description": "通道",
                    "type": "integer"
                },
                "deviceId": {
                    "type": "string"
                },
@@ -954,10 +962,6 @@
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "position": {
                    "description": "每个设备可能有多个机位同时生产,用position表示位置",
                    "type": "integer"
                },
                "procedure": {
@@ -996,7 +1000,7 @@
                "procedureId"
            ],
            "properties": {
                "position": {
                "channel": {
                    "type": "integer"
                },
                "procedureId": {
@@ -1136,15 +1140,15 @@
                    "description": "是否可以开始生产",
                    "type": "boolean"
                },
                "channel": {
                    "description": "当前任务在设备第几个通道",
                    "type": "integer"
                },
                "currentProcedureIndex": {
                    "type": "integer"
                },
                "order": {
                    "$ref": "#/definitions/model.Order"
                },
                "position": {
                    "description": "当前任务在设备第几个位置",
                    "type": "integer"
                },
                "procedure": {
                    "$ref": "#/definitions/model.Procedures"
docs/swagger.json
@@ -622,6 +622,10 @@
                        "type": "string"
                    }
                },
                "channel": {
                    "description": "通道序号",
                    "type": "integer"
                },
                "deviceId": {
                    "type": "string"
                },
@@ -763,6 +767,10 @@
        "model.DevicePlcAddress": {
            "type": "object",
            "properties": {
                "channel": {
                    "description": "数据起始地址",
                    "type": "integer"
                },
                "fieldName": {
                    "description": "对应系统字段",
                    "allOf": [
@@ -773,10 +781,6 @@
                },
                "length": {
                    "description": "数据长度",
                    "type": "integer"
                },
                "position": {
                    "description": "数据起始地址",
                    "type": "integer"
                },
                "startAddress": {
@@ -935,6 +939,10 @@
        "model.Procedures": {
            "type": "object",
            "properties": {
                "channel": {
                    "description": "通道",
                    "type": "integer"
                },
                "deviceId": {
                    "type": "string"
                },
@@ -942,10 +950,6 @@
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "position": {
                    "description": "每个设备可能有多个机位同时生产,用position表示位置",
                    "type": "integer"
                },
                "procedure": {
@@ -984,7 +988,7 @@
                "procedureId"
            ],
            "properties": {
                "position": {
                "channel": {
                    "type": "integer"
                },
                "procedureId": {
@@ -1124,15 +1128,15 @@
                    "description": "是否可以开始生产",
                    "type": "boolean"
                },
                "channel": {
                    "description": "当前任务在设备第几个通道",
                    "type": "integer"
                },
                "currentProcedureIndex": {
                    "type": "integer"
                },
                "order": {
                    "$ref": "#/definitions/model.Order"
                },
                "position": {
                    "description": "当前任务在设备第几个位置",
                    "type": "integer"
                },
                "procedure": {
                    "$ref": "#/definitions/model.Procedures"
docs/swagger.yaml
@@ -30,6 +30,9 @@
        items:
          type: string
        type: array
      channel:
        description: 通道序号
        type: integer
      deviceId:
        type: string
      deviceName:
@@ -131,15 +134,15 @@
    type: object
  model.DevicePlcAddress:
    properties:
      channel:
        description: 数据起始地址
        type: integer
      fieldName:
        allOf:
        - $ref: '#/definitions/constvar.PlcStartAddressType'
        description: 对应系统字段
      length:
        description: 数据长度
        type: integer
      position:
        description: 数据起始地址
        type: integer
      startAddress:
        description: 数据起始地址
@@ -248,14 +251,14 @@
    - ProcedureStatusFinished
  model.Procedures:
    properties:
      channel:
        description: 通道
        type: integer
      deviceId:
        type: string
      endTime:
        type: integer
      id:
        type: integer
      position:
        description: 每个设备可能有多个机位同时生产,用position表示位置
        type: integer
      procedure:
        allOf:
@@ -277,7 +280,7 @@
    type: object
  request.SendProcessParams:
    properties:
      position:
      channel:
        type: integer
      procedureId:
        type: integer
@@ -375,13 +378,13 @@
      canStarted:
        description: 是否可以开始生产
        type: boolean
      channel:
        description: 当前任务在设备第几个通道
        type: integer
      currentProcedureIndex:
        type: integer
      order:
        $ref: '#/definitions/model.Order'
      position:
        description: 当前任务在设备第几个位置
        type: integer
      procedure:
        $ref: '#/definitions/model.Procedures'
    type: object
model/common/common.go
@@ -51,6 +51,7 @@
        OutputMaterials   []*ProcedureMaterial `json:"outputMaterials"`   // 输出物料列表
        Workers           []*ProcedureWorker   `json:"workers"`           // 人员列表
        AllProcedureNames []string             `json:"allProcedureNames"` // 所属工单工序列表
        Channel           int32                `json:"channel"`           //通道序号
    }
    DeliverScheduleTask struct {
@@ -68,8 +69,8 @@
        KeyData        []byte
        AddressData    []byte
        DeviceId       string
        PlcAddressList []*PlcAddress
        PlcConfig      PlcConfig
        PlcAddressList []*PlcAddress //plc 完成量,总量, 读写地址
        PlcConfig      PlcConfig     //用网口还是端口以及网口ip port
    }
    PlcConfig struct {
@@ -86,7 +87,7 @@
    PlcAddress struct {
        DeviceID     string                       `json:"deviceID"`     // 设备id
        Position     int                          `json:"position"`     // 生产位置,一个机器可能有多个机位,需要分别配置plc地址
        Channel      int                          `json:"channel"`      // 生产通道on,一个机器可能有多个机位,需要分别配置plc地址
        StartAddress int                          `json:"startAddress"` // 数据起始地址
        Length       int                          `json:"length"`       // 数据长度
        Type         string                       `json:"type"`         // 数据类型
model/device_plc.go
@@ -33,7 +33,7 @@
    }
    DevicePlcAddress struct {
        Position     int                               `json:"position"`     // 数据起始地址
        Channel      int32                             `json:"channel"`      // 数据起始地址
        StartAddress int                               `json:"startAddress"` // 数据起始地址
        Length       int                               `json:"length"`       // 数据长度
        Type         constvar.PlcStartAddressValueType `json:"type"`         // 数据类型
model/procedures.go
@@ -17,7 +17,7 @@
        OrderID        string `gorm:"index;type:varchar(191);not null;comment:订单ID" json:"-"`
        DeviceID       string `gorm:"index;type:varchar(191);comment:设备ID" json:"deviceId"`
        ProcedureID    string `gorm:"index;type:varchar(191);comment:工序ID" json:"procedureId"`
        Position       int    `gorm:"type:int;comment:工作位置" json:"position"` //每个设备可能有多个机位同时生产,用position表示位置
        Channel        int32  `gorm:"index;comment:通道" json:"channel"` //通道
        StartTime      int64  `gorm:"comment:计划开始时间" json:"startTime"`
        EndTime        int64  `gorm:"comment:计划结束时间" json:"endTime"`
        Status         ProcedureStatus
model/production_progress.go
@@ -15,7 +15,7 @@
        ProcedureID      string `gorm:"type:varchar(191);comment:工序ID" json:"procedureId"`
        DeviceID         string `gorm:"type:varchar(191);not null;comment:设备ID" json:"deviceId"`
        FinishedQuantity int64  `gorm:"type:int;not null;comment:完成数量" json:"finishedQuantity"`
        Position         int    `gorm:"type:int;comment:工作位置" json:"position"` //每个设备可能有多个机位同时生产,用position表示位置
        Channel          int32  `gorm:"type:int;comment:工作通道" json:"channel"` //通道
        TotalQuantity    int64  `gorm:"type:int;not null;comment:总量" json:"totalQuantity"`
    }
@@ -74,8 +74,8 @@
    return slf
}
func (slf *ProductionProgressSearch) SetPosition(position int) *ProductionProgressSearch {
    slf.Position = position
func (slf *ProductionProgressSearch) SetChannel(channel int32) *ProductionProgressSearch {
    slf.Channel = channel
    return slf
}
@@ -106,8 +106,8 @@
        db = db.Where("device_id = ?", slf.DeviceID)
    }
    if slf.Position != 0 {
        db = db.Where("position = ?", slf.Position)
    if slf.Channel != 0 {
        db = db.Where("channel = ?", slf.Channel)
    }
    return db
model/request/task.go
@@ -15,11 +15,11 @@
}
type SendProcessParams struct {
    ProcedureId int `json:"procedureId" binding:"required"`
    Position    int `json:"position"`
    ProcedureId int   `json:"procedureId" binding:"required"`
    Channel     int32 `json:"channel"`
}
type GetProductProgress struct {
    ProcedureId int `json:"procedureId" binding:"required"`
    Position    int `json:"position"`
    ProcedureId int   `json:"procedureId" binding:"required"`
    Channel     int32 `json:"channel"`
}
model/response/common.go
@@ -24,7 +24,7 @@
    Order     *model.Order
    Procedure *model.Procedures
    Position              int //当前任务在设备第几个位置
    Channel               int32 //当前任务在设备第几个通道
    AllProcedures         []string
    CurrentProcedureIndex int
    CanStarted            bool //是否可以开始生产
nsq/msg_handler.go
@@ -59,6 +59,7 @@
                StartTime:      procedure.StartTime,
                EndTime:        procedure.EndTime,
                Status:         model.ProcedureStatusWaitProcess,
                Channel:        procedure.Channel,
                ProceduresInfo: common.ProductProcedure{},
            }
            procedureData, err := json.Marshal(procedure)
service/cache_store.go
@@ -47,36 +47,36 @@
}
const (
    PlcCacheKey             = "plc:%v:%v" //plc:position:key
    PlcCacheKey             = "plc:%v:%v" //plc:channel:key
    CurrentTaskCacheKey     = "current_task"
    CurrentProgressCacheKey = "current_progress:%v"          //current_progress:position
    PlcCacheKeyUpdateTime   = "finish_number_update_time:%v" //finish_number_update_time:position
    CurrentProgressCacheKey = "current_progress:%v"          //current_progress:channel
    PlcCacheKeyUpdateTime   = "finish_number_update_time:%v" //finish_number_update_time:channel
)
func PlcCacheGet(position int, key string) (interface{}, bool) {
    return defaultCacheStore.Get(fmt.Sprintf(PlcCacheKey, position, key))
func PlcCacheGet(channel int32, key string) (interface{}, bool) {
    return defaultCacheStore.Get(fmt.Sprintf(PlcCacheKey, channel, key))
}
func PlcCacheSet(position int, key string, value interface{}) {
func PlcCacheSet(channel int32, key string, value interface{}) {
    if key == constvar.PlcCacheKeyFinishNumber {
        oldFinishNumber, exists := PlcCacheGet(position, key)
        oldFinishNumber, exists := PlcCacheGet(channel, key)
        if !exists || cast.ToInt(oldFinishNumber) != cast.ToInt(value) { //finishNumber有了变化,设置更新时间缓存
            FinishUpdateTimeSet(position, time.Now().Unix())
            FinishUpdateTimeSet(channel, time.Now().Unix())
        }
    }
    defaultCacheStore.Add(fmt.Sprintf(PlcCacheKey, position, key), value)
    defaultCacheStore.Add(fmt.Sprintf(PlcCacheKey, channel, key), value)
}
func FinishUpdateTimeGet(position int) interface{} {
    val, ok := defaultCacheStore.Get(fmt.Sprintf(PlcCacheKeyUpdateTime, position))
func FinishUpdateTimeGet(channel int32) interface{} {
    val, ok := defaultCacheStore.Get(fmt.Sprintf(PlcCacheKeyUpdateTime, channel))
    if ok {
        return val
    }
    return 0
}
func FinishUpdateTimeSet(position int, value interface{}) {
    defaultCacheStore.Add(fmt.Sprintf(PlcCacheKeyUpdateTime, position), value)
func FinishUpdateTimeSet(channel int32, value interface{}) {
    defaultCacheStore.Add(fmt.Sprintf(PlcCacheKeyUpdateTime, channel), value)
}
func TaskCacheSet(value *response.TaskData) {
@@ -94,17 +94,17 @@
    return nil, false
}
func ProgressCacheGet(position int) (*model.ProductionProgress, bool) {
    if v, ok := defaultCacheStore.Get(fmt.Sprintf(CurrentProgressCacheKey, position)); ok {
func ProgressCacheGet(channel int32) (*model.ProductionProgress, bool) {
    if v, ok := defaultCacheStore.Get(fmt.Sprintf(CurrentProgressCacheKey, channel)); ok {
        return v.(*model.ProductionProgress), ok
    }
    return nil, false
}
func ProgressCacheSet(position int, value *model.ProductionProgress) {
    defaultCacheStore.Add(fmt.Sprintf(CurrentProgressCacheKey, position), value)
func ProgressCacheSet(channel int32, value *model.ProductionProgress) {
    defaultCacheStore.Add(fmt.Sprintf(CurrentProgressCacheKey, channel), value)
}
func ProgressCacheUnset(position int) {
    defaultCacheStore.Remove(fmt.Sprintf(CurrentProgressCacheKey, position))
func ProgressCacheUnset(channel int32) {
    defaultCacheStore.Remove(fmt.Sprintf(CurrentProgressCacheKey, channel))
}
service/plc.go
@@ -15,7 +15,7 @@
    "github.com/spf13/cast"
)
func PlcWrite(plcConfig *model.DevicePlc, fieldType constvar.PlcStartAddressType, position int, value interface{}) (err error) {
func PlcWrite(plcConfig *model.DevicePlc, fieldType constvar.PlcStartAddressType, channel int32, value interface{}) (err error) {
    var (
        startAddress int
        ipAddr       string
@@ -27,7 +27,7 @@
    plcConfig.CurrentTryTimes++
    for _, pc := range plcConfig.Details {
        if pc.FieldName == fieldType && pc.Position == position {
        if pc.FieldName == fieldType && pc.Channel == channel {
            startAddress = pc.StartAddress
        }
    }
@@ -39,7 +39,7 @@
        if err != nil {
            logx.Errorf("plc write failed, address: %v, value: %v, err: %v", startAddress, value, err.Error())
            plcConfig.CurrentErr = err
            return PlcWrite(plcConfig, fieldType, position, value)
            return PlcWrite(plcConfig, fieldType, channel, value)
        }
        logx.Infof("plc write ok, address: %v, value: %v", startAddress, value)
    } else if plcConfig.Method == constvar.PlcMethodSerial {
service/progress.go
@@ -22,20 +22,20 @@
            ProcedureID:   procedure.ProceduresInfo.ProcedureID,
            DeviceID:      procedure.DeviceID,
            TotalQuantity: order.Amount.IntPart(),
            Position:      procedure.Position,
            Channel:       procedure.Channel,
        }
        err := model.NewProductionProgressSearch(db).Create(progress)
        if err != nil {
            return err
        }
        ProgressCacheSet(procedure.Position, progress)
        ProgressCacheSet(procedure.Channel, progress)
    }
    return nil
}
func (slf ProgressService) UpdateProgress(position int, finishedQuantity int64) (err error) {
    progressCache, err := slf.GetCurrentProgress(position)
func (slf ProgressService) UpdateProgress(channel int32, finishedQuantity int64) (err error) {
    progressCache, err := slf.GetCurrentProgress(channel)
    if err != nil {
        return err
    }
@@ -44,17 +44,17 @@
    }
    if finishedQuantity > progressCache.FinishedQuantity { //当有变化时才更新
        progressCache.FinishedQuantity = finishedQuantity
        ProgressCacheSet(position, progressCache)
        ProgressCacheSet(channel, progressCache)
        return model.NewProductionProgressSearch(nil).SetId(progressCache.ID).Save(progressCache)
    }
    return nil
}
func (slf ProgressService) GetCurrentProgress(position int) (progressCache *model.ProductionProgress, err error) {
func (slf ProgressService) GetCurrentProgress(channel int32) (progressCache *model.ProductionProgress, err error) {
    var ok bool
    progressCache, ok = ProgressCacheGet(position)
    progressCache, ok = ProgressCacheGet(channel)
    if !ok {
        progressCache, err = model.NewProductionProgressSearch(nil).SetPosition(position).SetOrder("id desc").First()
        progressCache, err = model.NewProductionProgressSearch(nil).SetChannel(channel).SetOrder("id desc").First()
        if err == gorm.ErrRecordNotFound {
            return nil, errors.New("progress not found")
        }
@@ -66,7 +66,7 @@
            progressCache = nil
        }
        if progressCache != nil {
            ProgressCacheSet(position, progressCache)
            ProgressCacheSet(channel, progressCache)
        }
    }
    return
service/task.go
@@ -91,7 +91,7 @@
            Procedure:             procedure,
            AllProcedures:         procedure.ProceduresInfo.AllProcedureNames,
            CurrentProcedureIndex: 0,
            Position:              procedure.Position,
            Channel:               procedure.Channel,
        }
        index := 0
        for _, name := range procedure.ProceduresInfo.AllProcedureNames {
@@ -132,19 +132,19 @@
    return procedure, ecode.OK
}
func (slf TaskService) UpdateProcedureStatusAndPosition(db *gorm.DB, id int, status model.ProcedureStatus, position int) error {
func (slf TaskService) UpdateProcedureStatusAndChannel(db *gorm.DB, id int, status model.ProcedureStatus, channel int32) error {
    if status == model.ProcedureStatusFinished {
        ProgressCacheUnset(position)
        ProgressCacheUnset(channel)
    }
    return model.NewProceduresSearch(db).SetId(id).UpdateByMap(map[string]interface{}{
        "status":   status,
        "position": position,
        "status":  status,
        "channel": channel,
    })
}
func (slf TaskService) UpdateProcedureStatus(db *gorm.DB, id int, status model.ProcedureStatus, position int) error {
func (slf TaskService) UpdateProcedureStatus(db *gorm.DB, id int, status model.ProcedureStatus, channel int32) error {
    if status == model.ProcedureStatusFinished {
        ProgressCacheUnset(position)
        ProgressCacheUnset(channel)
    }
    return model.NewProceduresSearch(db).SetId(id).UpdateByMap(map[string]interface{}{
        "status": status,