NatsWorkOrder.go 789 B

1234567891011121314151617181920212223242526272829303132
  1. package NatsServer
  2. import (
  3. "Cold_Api/controllers/lib"
  4. "fmt"
  5. "github.com/beego/beego/v2/core/logs"
  6. "github.com/vmihailenco/msgpack/v5"
  7. "time"
  8. )
  9. func Read_WorkOrderT_State_Count(T_pids string) (int64, int64) {
  10. msg, err := lib.Nats.Request("Cold_WorkOrder_Read_WorkOrderT_State_Count", []byte(T_pids), 3*time.Second)
  11. if err != nil {
  12. return 0, 0
  13. }
  14. logs.Debug(fmt.Sprintf("UserListAll: %v\n", string(msg.Data)))
  15. type T_R struct {
  16. Code int16 `xml:"Code"`
  17. Msg string `xml:"Msg"`
  18. TodayWorkOrderNum int64 // 今日工单数量
  19. UntreatedWorkOrderNum int64 // 未处理工单数量
  20. }
  21. var t_R T_R
  22. err = msgpack.Unmarshal(msg.Data, &t_R)
  23. if err != nil {
  24. return 0, 0
  25. }
  26. return t_R.TodayWorkOrderNum, t_R.UntreatedWorkOrderNum
  27. }