Переглянути джерело

Merge branch 'master' of http://120.55.44.4:10080/gaoyagang/gt-common

wulei 1 рік тому
батько
коміт
ee55323414
2 змінених файлів з 151 додано та 102 видалено
  1. 119 102
      datacenter_client/types.go
  2. 32 0
      datacenter_client/v1/ObtainRangeFirstLast.go

+ 119 - 102
datacenter_client/types.go

@@ -15,118 +15,123 @@ type (
 		Min float64 `json:"min_val"`
 	}
 
+	RangeFirstLast struct {
+		First float64 `json:"first"`
+		Last  float64 `json:"last"`
+	}
+
 	WorkingPump struct {
-		Id           int64
-		ProjectId    int64
-		DeviceCode   string
-		FeedPressure float64
-		OutPressure  float64
-		Duration     int64
-		Current      float64
-		Frequency    float64
-		Lift         float64
-		Efficiency   float64
-		RunStatus    int64
-		FaultStatus  int64
-		CTime        string
+		Id           int64   `json:"id"`
+		ProjectId    int64   `json:"project_id"`
+		DeviceCode   string  `json:"device_code"`
+		FeedPressure float64 `json:"feed_pressure"`
+		OutPressure  float64 `json:"out_pressure"`
+		Duration     int64   `json:"duration"`
+		Current      float64 `json:"current"`
+		Frequency    float64 `json:"frequency"`
+		Lift         float64 `json:"lift"`
+		Efficiency   float64 `json:"efficiency"`
+		RunStatus    int64   `json:"run_status"`
+		FaultStatus  int64   `json:"fault_status"`
+		CTime        string  `json:"c_time"`
 	}
 
 	WorkingChest struct {
-		Id                  int64
-		ProjectId           int64
-		DeviceCode          string
-		Switch              int64
-		Level               float64
-		AgitatorStatus      int64
-		AgitatorDuration    int64
-		AgitatorFaultStatus int64
-		CTime               string
+		Id                  int64   `json:"id"`
+		ProjectId           int64   `json:"project_id"`
+		DeviceCode          string  `json:"device_code"`
+		Switch              int64   `json:"switch"`
+		Level               float64 `json:"level"`
+		AgitatorStatus      int64   `json:"agitator_status"`
+		AgitatorDuration    int64   `json:"agitator_duration"`
+		AgitatorFaultStatus int64   `json:"agitator_fault_status"`
+		CTime               string  `json:"c_time"`
 	}
 
 	WorkingRo struct {
-		Id                  int64
-		ProjectId           int64
-		DeviceCode          string
-		WaterTemperature    float64
-		FeedFlow_1St        float64
-		ConFlow_1St         float64
-		ProductFlow_1St     float64
-		FeedPressure_1St    float64
-		ConPressure_1St     float64
-		ProductPressure_1St float64
-		Tmp_1St             float64
-		Flux_1St            float64
-		Permeability_1St    float64
-		FeedFlow_2Nd        float64
-		ConFlow_2Nd         float64
-		ProductFlow_2Nd     float64
-		FeedPressure_2Nd    float64
-		ConPressure_2Nd     float64
-		ProductPressure_2Nd float64
-		Tmp_2Nd             float64
-		Flux_2Nd            float64
-		Permeability_2Nd    float64
-		FeedFlow_3Th        float64
-		ConFlow_3Th         float64
-		ProductFlow_3Th     float64
-		FeedPressure_3Th    float64
-		ConPressure_3Th     float64
-		ProductPressure_3Th float64
-		Tmp_3Th             float64
-		Flux_3Th            float64
-		Permeability_3Th    float64
-		FeedWqTurbidity     float64
-		FeedWqPh            int64
-		ProductWqPh         int64
-		FeedWqAl            float64
-		ProductWqAl         float64
-		FeedWqFe            float64
-		ProductWqFe         float64
-		FeedWqMn            float64
-		ProductWqMn         float64
-		FeedWqSio2          float64
-		ProductWqSio2       float64
-		FeedWqCod           float64
-		ProductWqCod        float64
-		FeedWqP             float64
-		ProductWqP          float64
-		Step                int64
-		CTime               string
+		Id                  int64   `json:"id"`
+		ProjectId           int64   `json:"project_id"`
+		DeviceCode          string  `json:"device_code"`
+		WaterTemperature    float64 `json:"water_temperature"`
+		FeedFlow_1St        float64 `json:"feed_flow_1_st"`
+		ConFlow_1St         float64 `json:"con_flow_1_st"`
+		ProductFlow_1St     float64 `json:"product_flow_1_st"`
+		FeedPressure_1St    float64 `json:"feed_pressure_1_st"`
+		ConPressure_1St     float64 `json:"con_pressure_1_st"`
+		ProductPressure_1St float64 `json:"product_pressure_1_st"`
+		Tmp_1St             float64 `json:"tmp_1_st"`
+		Flux_1St            float64 `json:"flux_1_st"`
+		Permeability_1St    float64 `json:"permeability_1_st"`
+		FeedFlow_2Nd        float64 `json:"feed_flow_2_nd"`
+		ConFlow_2Nd         float64 `json:"con_flow_2_nd"`
+		ProductFlow_2Nd     float64 `json:"product_flow_2_nd"`
+		FeedPressure_2Nd    float64 `json:"feed_pressure_2_nd"`
+		ConPressure_2Nd     float64 `json:"con_pressure_2_nd"`
+		ProductPressure_2Nd float64 `json:"product_pressure_2_nd"`
+		Tmp_2Nd             float64 `json:"tmp_2_nd"`
+		Flux_2Nd            float64 `json:"flux_2_nd"`
+		Permeability_2Nd    float64 `json:"permeability_2_nd"`
+		FeedFlow_3Th        float64 `json:"feed_flow_3_th"`
+		ConFlow_3Th         float64 `json:"con_flow_3_th"`
+		ProductFlow_3Th     float64 `json:"product_flow_3_th"`
+		FeedPressure_3Th    float64 `json:"feed_pressure_3_th"`
+		ConPressure_3Th     float64 `json:"con_pressure_3_th"`
+		ProductPressure_3Th float64 `json:"product_pressure_3_th"`
+		Tmp_3Th             float64 `json:"tmp_3_th"`
+		Flux_3Th            float64 `json:"flux_3_th"`
+		Permeability_3Th    float64 `json:"permeability_3_th"`
+		FeedWqTurbidity     float64 `json:"feed_wq_turbidity"`
+		FeedWqPh            int64   `json:"feed_wq_ph"`
+		ProductWqPh         int64   `json:"product_wq_ph"`
+		FeedWqAl            float64 `json:"feed_wq_al"`
+		ProductWqAl         float64 `json:"product_wq_al"`
+		FeedWqFe            float64 `json:"feed_wq_fe"`
+		ProductWqFe         float64 `json:"product_wq_fe"`
+		FeedWqMn            float64 `json:"feed_wq_mn"`
+		ProductWqMn         float64 `json:"product_wq_mn"`
+		FeedWqSio2          float64 `json:"feed_wq_sio_2"`
+		ProductWqSio2       float64 `json:"product_wq_sio_2"`
+		FeedWqCod           float64 `json:"feed_wq_cod"`
+		ProductWqCod        float64 `json:"product_wq_cod"`
+		FeedWqP             float64 `json:"feed_wq_p"`
+		ProductWqP          float64 `json:"product_wq_p"`
+		Step                int64   `json:"step"`
+		CTime               string  `json:"c_time"`
 	}
 
 	WorkingUf struct {
-		Id               int64
-		ProjectId        int64
-		DeviceCode       string
-		WaterTemperature float64
-		FeedFlow         float64
-		ConFlow          float64
-		ProductFlow      float64
-		FeedPressure     float64
-		ConPressure      float64
-		ProductPressure  float64
-		Tmp              float64
-		Flux             float64
-		Permeability     float64
-		FeedWqTurbidity  float64
-		FeedWqPh         int64
-		ProductWqPh      int64
-		FeedWqAl         float64
-		ProductWqAl      float64
-		FeedWqFe         float64
-		ProductWqFe      float64
-		FeedWqMn         float64
-		ProductWqMn      float64
-		FeedWqSio2       float64
-		ProductWqSio2    float64
-		FeedWqCod        float64
-		ProductWqCod     float64
-		FeedWqP          float64
-		ProductWqP       float64
-		Step             int64
-		FilterTime       float64
-		FilterCycle      int64
-		CTime            string
+		Id               int64   `json:"id"`
+		ProjectId        int64   `json:"project_id"`
+		DeviceCode       string  `json:"device_code"`
+		WaterTemperature float64 `json:"water_temperature"`
+		FeedFlow         float64 `json:"feed_flow"`
+		ConFlow          float64 `json:"con_flow"`
+		ProductFlow      float64 `json:"product_flow"`
+		FeedPressure     float64 `json:"feed_pressure"`
+		ConPressure      float64 `json:"con_pressure"`
+		ProductPressure  float64 `json:"product_pressure"`
+		Tmp              float64 `json:"tmp"`
+		Flux             float64 `json:"flux"`
+		Permeability     float64 `json:"permeability"`
+		FeedWqTurbidity  float64 `json:"feed_wq_turbidity"`
+		FeedWqPh         int64   `json:"feed_wq_ph"`
+		ProductWqPh      int64   `json:"product_wq_ph"`
+		FeedWqAl         float64 `json:"feed_wq_al"`
+		ProductWqAl      float64 `json:"product_wq_al"`
+		FeedWqFe         float64 `json:"feed_wq_fe"`
+		ProductWqFe      float64 `json:"product_wq_fe"`
+		FeedWqMn         float64 `json:"feed_wq_mn"`
+		ProductWqMn      float64 `json:"product_wq_mn"`
+		FeedWqSio2       float64 `json:"feed_wq_sio_2"`
+		ProductWqSio2    float64 `json:"product_wq_sio_2"`
+		FeedWqCod        float64 `json:"feed_wq_cod"`
+		ProductWqCod     float64 `json:"product_wq_cod"`
+		FeedWqP          float64 `json:"feed_wq_p"`
+		ProductWqP       float64 `json:"product_wq_p"`
+		Step             int64   `json:"step"`
+		FilterTime       float64 `json:"filter_time"`
+		FilterCycle      int64   `json:"filter_cycle"`
+		CTime            string  `json:"c_time"`
 	}
 )
 
@@ -161,6 +166,13 @@ type (
 		Etime     string
 	}
 
+	RangeFirstLastReq struct {
+		ProjectId string
+		ItemName  string
+		Stime     string
+		Etime     string
+	}
+
 	ItemHistoryReq struct {
 		ProjectId string
 		ItemName  string
@@ -241,6 +253,11 @@ type (
 		Data *InstrumentCompareData `json:"data"`
 	}
 
+	RangeFirstLastResp struct {
+		Code int             `json:"code"`
+		Msg  string          `json:"msg"`
+		Data *RangeFirstLast `json:"data"`
+	}
 	ItemHistoryRespList struct {
 		List []ItemHistoryResp
 	}

+ 32 - 0
datacenter_client/v1/ObtainRangeFirstLast.go

@@ -0,0 +1,32 @@
+package v1
+
+import (
+	"errors"
+	"log"
+	"metawant.greentech.com.cn/gaoyagang/gt-common/datacenter_client"
+	"metawant.greentech.com.cn/gaoyagang/gt-common/httplib"
+)
+
+func (d *DcApi) ObtainRangeFirstLast(req *datacenter_client.RangeFirstLastReq) (resp *datacenter_client.RangeFirstLast, err error) {
+	url := d.serviceUrl("/item-history/max-min")
+	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)
+
+	result := &datacenter_client.RangeFirstLastResp{}
+
+	err = d.call(h, result)
+
+	if err != nil {
+		log.Println("ObtainRangeFirstLast Error:", err)
+		return
+	}
+	if result.Code != 200 {
+		err = errors.New(result.Msg)
+		return
+	}
+	resp = result.Data
+	return
+}