eas.go 746 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. package service
  2. import (
  3. "fmt"
  4. "strconv"
  5. log "github.com/sirupsen/logrus"
  6. "kpt.xdmy/apiserver/model"
  7. "kpt.xdmy/pkg/util"
  8. )
  9. func Eas() {
  10. sid, err := util.EASWebServiceLogin("http://192.168.61.23:6888")
  11. if err != nil {
  12. panic(err)
  13. }
  14. fmt.Println(sid)
  15. }
  16. func (s *Service) EasBatch() {
  17. // log.Infof("%v", setting.ServerSetting)
  18. nch = make(chan error, 10)
  19. p := make([]model.Parts, 0, 0)
  20. if e := s.d.DB.Where("msg <>''").Find(&p, &model.Parts{Statue: 1, Issync: 0}).Error; e != nil {
  21. panic(e)
  22. }
  23. for _, v := range p {
  24. if v.Unit == "" {
  25. continue
  26. }
  27. go GoEas(strconv.Itoa(v.ID))
  28. if e := <-nch; e != nil {
  29. log.Errorf("EasBatch() :%v", e)
  30. }
  31. }
  32. }
  33. func GoEas(id string) {
  34. e := util.EASBillSync(5, id, "1")
  35. nch <- e
  36. }