|
@@ -1,9 +1,18 @@
|
|
|
package com.ruoyi.data.controller;
|
|
package com.ruoyi.data.controller;
|
|
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Arrays;
|
|
import java.util.Arrays;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
import java.util.concurrent.TimeUnit;
|
|
|
|
|
|
|
|
|
|
+import cn.hutool.json.JSONArray;
|
|
|
|
|
+import cn.hutool.json.JSONObject;
|
|
|
|
|
+import com.ruoyi.data.domain.PointData;
|
|
|
|
|
+import com.ruoyi.data.domain.SensorPoint;
|
|
|
|
|
+import com.ruoyi.data.domain.bo.TblDatapointBo;
|
|
|
|
|
+import com.ruoyi.data.domain.bo.TblUnitBo;
|
|
|
|
|
+import com.ruoyi.data.domain.vo.TblDatapointVo;
|
|
|
|
|
+import com.ruoyi.data.service.ITblDatapointService;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
import javax.validation.constraints.*;
|
|
import javax.validation.constraints.*;
|
|
@@ -39,6 +48,8 @@ public class TblSensorController extends BaseController {
|
|
|
|
|
|
|
|
private final ITblSensorService iTblSensorService;
|
|
private final ITblSensorService iTblSensorService;
|
|
|
|
|
|
|
|
|
|
+ private final ITblDatapointService iTblDatapointService;
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* 查询传感器列列表
|
|
* 查询传感器列列表
|
|
|
*/
|
|
*/
|
|
@@ -105,4 +116,51 @@ public class TblSensorController extends BaseController {
|
|
|
@PathVariable Long[] ids) {
|
|
@PathVariable Long[] ids) {
|
|
|
return toAjax(iTblSensorService.deleteWithValidByIds(Arrays.asList(ids), true));
|
|
return toAjax(iTblSensorService.deleteWithValidByIds(Arrays.asList(ids), true));
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 获取传感器列详细信息(包含测点数据)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param id 主键
|
|
|
|
|
+ */
|
|
|
|
|
+ @SaCheckPermission("data:sensor:query")
|
|
|
|
|
+ @GetMapping("/sensorDataPoint/{id}")
|
|
|
|
|
+ public R<SensorPoint> getsensorDataPoint(@NotNull(message = "主键不能为空")
|
|
|
|
|
+ @PathVariable Long id) {
|
|
|
|
|
+ SensorPoint sensorPoint = new SensorPoint();
|
|
|
|
|
+ TblSensorVo tblSensorVo = iTblSensorService.queryById(id);
|
|
|
|
|
+ TblDatapointBo tblDatapointBo = new TblDatapointBo();
|
|
|
|
|
+ List<TblDatapointVo> tblDatapointVoList = iTblDatapointService.queryList(tblDatapointBo);
|
|
|
|
|
+ sensorPoint.setTblSensorVo(tblSensorVo);
|
|
|
|
|
+ List<PointData> pointDatas = new ArrayList<PointData>();
|
|
|
|
|
+ JSONArray pointArry = new JSONArray(tblSensorVo.getDatapoints());
|
|
|
|
|
+ for(Object pointObject:pointArry){
|
|
|
|
|
+ JSONObject jsonObject = new JSONObject(pointObject);
|
|
|
|
|
+ if(jsonObject.get("dataPointId")!=null){
|
|
|
|
|
+ Long pointId = Long.valueOf((String) jsonObject.get("dataPointId"));
|
|
|
|
|
+ for(TblDatapointVo tblDatapointVo:tblDatapointVoList){
|
|
|
|
|
+ if( pointId == tblDatapointVo.getId()) {
|
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
|
+ pointData.setName((String) jsonObject.get("name"));
|
|
|
|
|
+ pointData.setLabel((String) jsonObject.get("label"));
|
|
|
|
|
+ pointData.setUnit((String) jsonObject.get("unit"));
|
|
|
|
|
+ pointData.setUnitType((String) jsonObject.get("unitType"));
|
|
|
|
|
+ pointData.setDataPointInfo(tblDatapointVo);
|
|
|
|
|
+ pointDatas.add(pointData);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }else{
|
|
|
|
|
+ PointData pointData = new PointData();
|
|
|
|
|
+ pointData.setName((String) jsonObject.get("name"));
|
|
|
|
|
+ pointData.setLabel((String) jsonObject.get("label"));
|
|
|
|
|
+ pointData.setUnit((String) jsonObject.get("unit"));
|
|
|
|
|
+ pointData.setUnitType((String) jsonObject.get("unitType"));
|
|
|
|
|
+ pointDatas.add(pointData);
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ tblSensorVo.setDatapoints(null);
|
|
|
|
|
+ sensorPoint.setDataPoints(pointDatas);
|
|
|
|
|
+ return R.ok(sensorPoint);
|
|
|
|
|
+// return R.ok(iTblSensorService.queryById(id));
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|