|
@@ -0,0 +1,53 @@
|
|
|
+package datacenter_client
|
|
|
+
|
|
|
+import (
|
|
|
+ "encoding/json"
|
|
|
+ "errors"
|
|
|
+ "fmt"
|
|
|
+ "log"
|
|
|
+ "metawant.greentech.com.cn/gaoyagang/gt-common/httplib"
|
|
|
+)
|
|
|
+
|
|
|
+type RangeMaxMinReq struct {
|
|
|
+ ProjectId string
|
|
|
+ ItemName string
|
|
|
+ Stime string
|
|
|
+ Etime string
|
|
|
+}
|
|
|
+
|
|
|
+type RangeMaxMinResp struct {
|
|
|
+ Code int `json:"code"`
|
|
|
+ Msg string `json:"msg"`
|
|
|
+ Data *InstrumentCompareData `json:"data"`
|
|
|
+}
|
|
|
+type InstrumentCompareData struct {
|
|
|
+ Max float64 `json:"max_val"`
|
|
|
+ Min float64 `json:"min_val"`
|
|
|
+}
|
|
|
+
|
|
|
+func (d *DcApiClient) ObtainRangeMaxMin (req *ItemHistoryReq) (resp *InstrumentCompareData, err error) {
|
|
|
+ url := fmt.Sprintf("http://%s/api/dtgateway/v1/item-history/max-min", d.ServerIp)
|
|
|
+ h := httplib.Get(url)
|
|
|
+ h.Param("project_id", req.ProjectId)
|
|
|
+ h.Param("item_name", req.ItemName)
|
|
|
+ h.Param("stime", req.Stime)
|
|
|
+ h.Param("etime", req.Etime)
|
|
|
+
|
|
|
+ body, err := d.RequestMiddleProcess(h, req.ProjectId)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("GetItemHistory Error:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ result := &RangeMaxMinResp{}
|
|
|
+ err = json.Unmarshal(body, &result)
|
|
|
+ if err != nil {
|
|
|
+ log.Println("GetItemHistory Error:", err)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ if result.Code != 200 {
|
|
|
+ err = errors.New(result.Msg)
|
|
|
+ return
|
|
|
+ }
|
|
|
+ resp = result.Data
|
|
|
+ return
|
|
|
+}
|