uf_test.go 1.6 KB

123456789101112131415161718192021222324252627282930
  1. package handler
  2. import (
  3. "GtDataStore/app/cmd/organization/internal/config"
  4. "encoding/json"
  5. "github.com/go-redis/redis/v8"
  6. "github.com/zeromicro/go-zero/core/conf"
  7. "metawant.greentech.com.cn/gaoyagang/gt-common/envitem"
  8. "testing"
  9. )
  10. func Test_transDeviceUfData(t *testing.T) {
  11. var c config.Config
  12. conf.MustLoad("../../../etc/organization.test.yaml", &c)
  13. //ctx := svc.NewServiceContext(c)
  14. envitem.SetOptions(envitem.Options{GtServerIp: c.GtServerIp, AdjustValue: true, Cache: redis.NewClient(&redis.Options{Addr: c.Cache[0].Host, Password: c.Cache[0].Pass, MaxRetries: 5})})
  15. j := `{"tmp":{"project_id":92,"item":"C.M.UF1_DB@press_PV","default_val":0},"feed_flow":{"project_id":92,"item":"C.M.UF1_FT_JS@out","default_val":0},"feed_pressure":{"project_id":92,"item":"C.M.UF1_PT_JS@out","default_val":0},"product_pressure":{"project_id":92,"item":"C.M.UF1_PT_CS@out","default_val":0},"feed_wq_turbidity":{"project_id":92,"item":"C.M.UF_Tur_ZJS@out","default_val":0},"water_temperature":{"project_id":92,"item":"C.M.RO_TT_ZJS@out","default_val":0},"product_wq_ph":{"project_id":92,"item":"C.M.UF_PH_ZCS@out","default_val":0},"step":{"project_id":92,"item":"C.M.UF1_DB@word_control","default_val":0},"filter_time":{"project_id":92,"item":"C.M.UF1_DB@time_production_display"},"filter_cycle":{"project_id":92,"item":"C.M.UF1_DB@cycle_out"},"permeability":{"project_id":92,"item":"UF1Per"},"flux":{"project_id":92,"item":"UF1_FluxF"}}`
  16. mulItems := envitem.MultiEnvItem{}
  17. json.Unmarshal([]byte(j), &mulItems)
  18. step := mulItems.GetItemInt64Value("filter_cycle")
  19. t.Log(step)
  20. //t.Log(mulItems)
  21. }