types.go 10.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. package datacenter_client
  2. type (
  3. // 公共部分
  4. ItemHistoryResp struct {
  5. ProjectId int `json:"project_id"`
  6. ItemName string `json:"item_name"`
  7. Val float64 `json:"val"`
  8. HTime string `json:"h_time"`
  9. }
  10. InstrumentCompareData struct {
  11. Max float64 `json:"max_val"`
  12. Min float64 `json:"min_val"`
  13. Avg float64 `json:"avg_val"`
  14. }
  15. RangeFirstLast struct {
  16. First float64 `json:"first"`
  17. Last float64 `json:"last"`
  18. }
  19. WorkingPump struct {
  20. Id int64 `json:"id"`
  21. ProjectId int64 `json:"project_id"`
  22. DeviceCode string `json:"device_code"`
  23. FeedPressure float64 `json:"feed_pressure"`
  24. OutPressure float64 `json:"out_pressure"`
  25. Duration int64 `json:"duration"`
  26. Current float64 `json:"current"`
  27. Frequency float64 `json:"frequency"`
  28. Lift float64 `json:"lift"`
  29. Efficiency float64 `json:"efficiency"`
  30. RunStatus int64 `json:"run_status"`
  31. FaultStatus int64 `json:"fault_status"`
  32. CTime string `json:"c_time"`
  33. }
  34. WorkingChest struct {
  35. Id int64 `json:"id"`
  36. ProjectId int64 `json:"project_id"`
  37. DeviceCode string `json:"device_code"`
  38. Switch int64 `json:"switch"`
  39. Level float64 `json:"level"`
  40. AgitatorStatus int64 `json:"agitator_status"`
  41. AgitatorDuration int64 `json:"agitator_duration"`
  42. AgitatorFaultStatus int64 `json:"agitator_fault_status"`
  43. CTime string `json:"c_time"`
  44. }
  45. WorkingRo struct {
  46. Id int64 `json:"id"`
  47. ProjectId int64 `json:"project_id"`
  48. DeviceCode string `json:"device_code"`
  49. WaterTemperature float64 `json:"water_temperature"`
  50. FeedFlow_1St float64 `json:"feed_flow_1_st"`
  51. ConFlow_1St float64 `json:"con_flow_1_st"`
  52. ProductFlow_1St float64 `json:"product_flow_1_st"`
  53. FeedPressure_1St float64 `json:"feed_pressure_1_st"`
  54. ConPressure_1St float64 `json:"con_pressure_1_st"`
  55. ProductPressure_1St float64 `json:"product_pressure_1_st"`
  56. Tmp_1St float64 `json:"tmp_1_st"`
  57. Flux_1St float64 `json:"flux_1_st"`
  58. Permeability_1St float64 `json:"permeability_1_st"`
  59. FeedFlow_2Nd float64 `json:"feed_flow_2_nd"`
  60. ConFlow_2Nd float64 `json:"con_flow_2_nd"`
  61. ProductFlow_2Nd float64 `json:"product_flow_2_nd"`
  62. FeedPressure_2Nd float64 `json:"feed_pressure_2_nd"`
  63. ConPressure_2Nd float64 `json:"con_pressure_2_nd"`
  64. ProductPressure_2Nd float64 `json:"product_pressure_2_nd"`
  65. Tmp_2Nd float64 `json:"tmp_2_nd"`
  66. Flux_2Nd float64 `json:"flux_2_nd"`
  67. Permeability_2Nd float64 `json:"permeability_2_nd"`
  68. FeedFlow_3Th float64 `json:"feed_flow_3_th"`
  69. ConFlow_3Th float64 `json:"con_flow_3_th"`
  70. ProductFlow_3Th float64 `json:"product_flow_3_th"`
  71. FeedPressure_3Th float64 `json:"feed_pressure_3_th"`
  72. ConPressure_3Th float64 `json:"con_pressure_3_th"`
  73. ProductPressure_3Th float64 `json:"product_pressure_3_th"`
  74. Tmp_3Th float64 `json:"tmp_3_th"`
  75. Flux_3Th float64 `json:"flux_3_th"`
  76. Permeability_3Th float64 `json:"permeability_3_th"`
  77. FeedWqTurbidity float64 `json:"feed_wq_turbidity"`
  78. FeedWqPh int64 `json:"feed_wq_ph"`
  79. ProductWqPh int64 `json:"product_wq_ph"`
  80. FeedWqAl float64 `json:"feed_wq_al"`
  81. ProductWqAl float64 `json:"product_wq_al"`
  82. FeedWqFe float64 `json:"feed_wq_fe"`
  83. ProductWqFe float64 `json:"product_wq_fe"`
  84. FeedWqMn float64 `json:"feed_wq_mn"`
  85. ProductWqMn float64 `json:"product_wq_mn"`
  86. FeedWqSio2 float64 `json:"feed_wq_sio_2"`
  87. ProductWqSio2 float64 `json:"product_wq_sio_2"`
  88. FeedWqCod float64 `json:"feed_wq_cod"`
  89. ProductWqCod float64 `json:"product_wq_cod"`
  90. FeedWqP float64 `json:"feed_wq_p"`
  91. ProductWqP float64 `json:"product_wq_p"`
  92. Step int64 `json:"step"`
  93. CTime string `json:"c_time"`
  94. }
  95. WorkingUf struct {
  96. Id int64 `json:"id"`
  97. ProjectId int64 `json:"project_id"`
  98. DeviceCode string `json:"device_code"`
  99. WaterTemperature float64 `json:"water_temperature"`
  100. FeedFlow float64 `json:"feed_flow"`
  101. ConFlow float64 `json:"con_flow"`
  102. ProductFlow float64 `json:"product_flow"`
  103. FeedPressure float64 `json:"feed_pressure"`
  104. ConPressure float64 `json:"con_pressure"`
  105. ProductPressure float64 `json:"product_pressure"`
  106. Tmp float64 `json:"tmp"`
  107. Flux float64 `json:"flux"`
  108. Permeability float64 `json:"permeability"`
  109. FeedWqTurbidity float64 `json:"feed_wq_turbidity"`
  110. FeedWqPh int64 `json:"feed_wq_ph"`
  111. ProductWqPh int64 `json:"product_wq_ph"`
  112. FeedWqAl float64 `json:"feed_wq_al"`
  113. ProductWqAl float64 `json:"product_wq_al"`
  114. FeedWqFe float64 `json:"feed_wq_fe"`
  115. ProductWqFe float64 `json:"product_wq_fe"`
  116. FeedWqMn float64 `json:"feed_wq_mn"`
  117. ProductWqMn float64 `json:"product_wq_mn"`
  118. FeedWqSio2 float64 `json:"feed_wq_sio_2"`
  119. ProductWqSio2 float64 `json:"product_wq_sio_2"`
  120. FeedWqCod float64 `json:"feed_wq_cod"`
  121. ProductWqCod float64 `json:"product_wq_cod"`
  122. FeedWqP float64 `json:"feed_wq_p"`
  123. ProductWqP float64 `json:"product_wq_p"`
  124. Step int64 `json:"step"`
  125. FilterTime float64 `json:"filter_time"`
  126. FilterCycle int64 `json:"filter_cycle"`
  127. CTime string `json:"c_time"`
  128. }
  129. )
  130. type (
  131. // 请求参数部分
  132. FindWorkingUfByCycleReq struct {
  133. ProjectId int64
  134. DeviceCode string
  135. FilterCycle int64
  136. Step int64
  137. FilterTimeStart float64
  138. FilterTimeEnd float64
  139. Limit int64
  140. }
  141. DcWorkingReq struct {
  142. ProjectId int64
  143. DeviceCode string
  144. Stime string
  145. Etime string
  146. Page int64
  147. PageSize int64
  148. Order string
  149. }
  150. // 点位最大 and 最小值请求
  151. RangeMaxMinReq struct {
  152. ProjectId string
  153. ItemName string
  154. Stime string
  155. Etime string
  156. }
  157. RangeFirstLastReq struct {
  158. ProjectId string
  159. ItemName string
  160. Stime string
  161. Etime string
  162. }
  163. ItemHistoryReq struct {
  164. ProjectId string
  165. ItemName string
  166. Stime string
  167. Etime string
  168. }
  169. // 点位数据写入结构
  170. ItemHistoryData struct {
  171. ProjectId int `json:"project_id"`
  172. ItemName string `json:"item_name"`
  173. Val float64 `json:"val"`
  174. HTime string `json:"h_time"`
  175. }
  176. // 点位数据写入请求
  177. MultiAddReq struct {
  178. List []ItemHistoryData `json:"list"`
  179. }
  180. ItemHistoryListReq struct {
  181. ProjectId int
  182. ItemName string
  183. Stime string
  184. Etime string
  185. Size int
  186. Interval string // 时间单位 minute,h,day,s
  187. Aggregator string // 聚合方式 min,max,avg,sum,realtime, new
  188. MaxVal float64 `json:"max_val"`
  189. MinVal float64 `json:"min_val"`
  190. }
  191. )
  192. type (
  193. // 响应结构部分
  194. GetWorkingPumpByCodeResp struct {
  195. Code int `json:"code"`
  196. Msg string `json:"msg"`
  197. Data struct {
  198. List []WorkingPump `json:"list"`
  199. } `json:"data"`
  200. }
  201. GetWorkingChestByCodeResp struct {
  202. Code int `json:"code"`
  203. Msg string `json:"msg"`
  204. Data struct {
  205. List []WorkingChest `json:"list"`
  206. } `json:"data"`
  207. }
  208. GetWorkingRoByCodeResp struct {
  209. Code int `json:"code"`
  210. Msg string `json:"msg"`
  211. Data struct {
  212. List []WorkingRo `json:"list"`
  213. } `json:"data"`
  214. }
  215. FindWorkingUfByCycleResp struct {
  216. Code int `json:"code"`
  217. Msg string `json:"msg"`
  218. Data struct {
  219. List []WorkingUf `json:"list"`
  220. } `json:"data"`
  221. }
  222. GetWorkingUfByCodeResp struct {
  223. Code int `json:"code"`
  224. Msg string `json:"msg"`
  225. Data struct {
  226. List []WorkingUf `json:"list"`
  227. } `json:"data"`
  228. }
  229. RangeMaxMinResp struct {
  230. Code int `json:"code"`
  231. Msg string `json:"msg"`
  232. Data *InstrumentCompareData `json:"data"`
  233. }
  234. RangeFirstLastResp struct {
  235. Code int `json:"code"`
  236. Msg string `json:"msg"`
  237. Data *RangeFirstLast `json:"data"`
  238. }
  239. ItemHistoryRespList struct {
  240. List []ItemHistoryResp
  241. }
  242. ItemHistoryListResp struct {
  243. Name string `json:"name"`
  244. Htime string `json:"htime_at"`
  245. Val float64 `json:"val"`
  246. }
  247. ItemHistoryListRespList struct {
  248. List []ItemHistoryListResp
  249. }
  250. MultiAddBody struct {
  251. Code int `json:"code"`
  252. Msg string `json:"msg"`
  253. }
  254. ItemHistoryBody struct {
  255. Code int `json:"code"`
  256. Msg string `json:"msg"`
  257. Data ItemHistoryRespList `json:"data"`
  258. }
  259. ItemHistoryListBody struct {
  260. Code int `json:"code"`
  261. Msg string `json:"msg"`
  262. Data ItemHistoryListRespList `json:"data"`
  263. }
  264. )
  265. type (
  266. // DcAPI 在这里定义了数据中心接口, 具体实现在版本目录中(目前只有v1)
  267. DcAPI interface {
  268. // GetItemHistory 查询历史点位数据
  269. GetItemHistory(req ItemHistoryReq) (resp []ItemHistoryResp, err error)
  270. // MultiAddData 点位数据写入
  271. MultiAddData(req MultiAddReq) (err error)
  272. // ObtainRangeMaxMin 查询最大最小值
  273. ObtainRangeMaxMin(req *RangeMaxMinReq) (resp *InstrumentCompareData, err error)
  274. // ObtainRangeMaxMin 查询最大最小值
  275. ObtainRangeFirstLast(req *RangeFirstLastReq) (resp *RangeFirstLast, err error)
  276. // GetWorkingUfByCode 获得uf工况数据
  277. GetWorkingUfByCode(DcWorkingReq) (*GetWorkingUfByCodeResp, error)
  278. // FindWorkingUfByCycle 查询uf工况数据, 按周期进行过滤
  279. FindWorkingUfByCycle(FindWorkingUfByCycleReq) (*FindWorkingUfByCycleResp, error)
  280. // GetWorkingRoByCode 查询ro工况数据
  281. GetWorkingRoByCode(DcWorkingReq) (*GetWorkingRoByCodeResp, error)
  282. // GetWorkingChestByCode 查询液体容器类工况数据
  283. GetWorkingChestByCode(DcWorkingReq) (*GetWorkingChestByCodeResp, error)
  284. // GetWorkingPumpByCode 查询泵类工况数据
  285. GetWorkingPumpByCode(DcWorkingReq) (*GetWorkingPumpByCodeResp, error)
  286. // 平替双胞胎图表接口(时间区间内按要求聚合)
  287. GetItemHistoryList(ItemHistoryListReq) (resp []ItemHistoryListResp, err error)
  288. }
  289. )