| | |
| | | package v1 |
| | | |
| | | import ( |
| | | "apsClient/conf" |
| | | "apsClient/constvar" |
| | | "apsClient/model" |
| | | "apsClient/model/common" |
| | | "apsClient/model/response" |
| | | "apsClient/nsq" |
| | | "apsClient/pkg/contextx" |
| | | "apsClient/pkg/convertx" |
| | | "apsClient/pkg/ecode" |
| | |
| | | return |
| | | } |
| | | id := convertx.Atoi(idx) |
| | | _, code := service.NewTaskService().GetProcedureById(id) |
| | | procedure, code := service.NewTaskService().GetProcedureById(id) |
| | | if code != ecode.OK { |
| | | ctx.Fail(code) |
| | | return |
| | |
| | | ctx.Fail(ecode.UnknownErr) |
| | | return |
| | | } |
| | | |
| | | msg := &common.MsgTaskStatusUpdate{ |
| | | WorkOrderId: procedure.WorkOrderID, |
| | | ProcedureID: procedure.ProceduresInfo.ProcedureID, |
| | | DeviceId: procedure.ProceduresInfo.DeviceID, |
| | | IsProcessing: false, |
| | | IsFinish: true, |
| | | } |
| | | |
| | | caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicTaskProcedureStatusUpdate, conf.Conf.NsqConf.NodeId), "") |
| | | err = caller.Send(msg) |
| | | if err != nil { |
| | | logx.Errorf("send task status update msg error:%v", err.Error()) |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | |
| | | ctx.FailWithMsg(ecode.NeedConfirmedErr, "糟糕,工艺下发失败。") |
| | | return |
| | | } |
| | | |
| | | msg := &common.MsgTaskStatusUpdate{ |
| | | WorkOrderId: procedure.WorkOrderID, |
| | | ProcedureID: procedure.ProceduresInfo.ProcedureID, |
| | | DeviceId: procedure.ProceduresInfo.DeviceID, |
| | | IsProcessing: true, |
| | | IsFinish: false, |
| | | } |
| | | |
| | | caller := nsq.NewCaller(fmt.Sprintf(constvar.NsqTopicTaskProcedureStatusUpdate, conf.Conf.NsqConf.NodeId), "") |
| | | err = caller.Send(msg) |
| | | if err != nil { |
| | | logx.Errorf("send task status update msg error:%v", err.Error()) |
| | | } |
| | | |
| | | ctx.Ok() |
| | | } |
| | | |
| | |
| | | package constvar |
| | | |
| | | const ( |
| | | NsqTopicScheduleTask = "aps.%v.scheduleTask" //排程任务下发 |
| | | NsqTopicGetPlcAddress = "aps.%v.getPlcAddress" |
| | | NsqTopicSendPlcAddress = "aps.%v.sendPlcAddress" |
| | | NsqTopicProcessParamsRequest = "aps.%v.processParams.request" |
| | | NsqTopicProcessParamsResponse = "aps.%v.processParams.response" |
| | | NsqTopicApsProcessParams = "aps.%v.aps.processParams" //有了新的工艺模型 |
| | | NsqTopicScheduleTask = "aps.%v.scheduleTask" //排程任务下发 |
| | | NsqTopicGetPlcAddress = "aps.%v.getPlcAddress" |
| | | NsqTopicSendPlcAddress = "aps.%v.sendPlcAddress" |
| | | NsqTopicProcessParamsRequest = "aps.%v.processParams.request" |
| | | NsqTopicProcessParamsResponse = "aps.%v.processParams.response" |
| | | NsqTopicApsProcessParams = "aps.%v.aps.processParams" //有了新的工艺模型 |
| | | NsqTopicTaskProcedureStatusUpdate = "aps.%v.task.procedure.status" //工序状态更新 |
| | | ) |
| | | |
| | | type PlcStartAddressType int |
| | |
| | | DeviceId string `json:"deviceId" gorm:"-"` //用于过滤获取nsq消息 |
| | | } |
| | | ) |
| | | |
| | | // MsgTaskStatusUpdate 任务状态改变 |
| | | type MsgTaskStatusUpdate struct { |
| | | WorkOrderId string `json:"workOrderId"` //工单编号 |
| | | ProcedureID string `json:"procedureId"` // 工序 |
| | | DeviceId string `json:"deviceId"` //用于过滤获取nsq消息 |
| | | IsProcessing bool //是否处理中 |
| | | IsFinish bool //是否完成 |
| | | } |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | func (caller *DefaultCaller) Send(input interface{}) error { |
| | | msg, err := json.Marshal(input) |
| | | if err != nil { |
| | | return err |
| | | } |
| | | producer := GetProducer() |
| | | err = producer.Publish(caller.RequestTopic, msg) |
| | | return err |
| | | |
| | | } |