package NatsServer import ( "Cold_Api/controllers/lib" "errors" "github.com/beego/beego/v2/core/logs" "github.com/vmihailenco/msgpack/v5" "time" ) func Update_Task_BySN(T_sn string, T_CalibrationTime time.Time) error { type T_Req struct { T_sn string `xml:"T_sn"` T_CalibrationTime string `xml:"T_CalibrationTime"` } v := T_Req{ T_sn: T_sn, T_CalibrationTime: T_CalibrationTime.Format("2006-01-02 15:04:05"), } logs.Debug("Nats =>", lib.FuncName(), v) b, err := msgpack.Marshal(&v) if err != nil { return err } msg, err := lib.Nats.Request("ColdVerify_Server_Update_Task_BySN", b, 3*time.Second) if err != nil { return err } type T_R struct { Code int16 `xml:"Code"` Msg string `xml:"Msg"` Data interface{} `xml:"Data"` } var t_R T_R err = msgpack.Unmarshal(msg.Data, &t_R) if err != nil { return err } if t_R.Code != 200 { return errors.New(t_R.Msg) } return nil }