|
@@ -0,0 +1,95 @@
|
|
|
+package org.jeecg.modules.dashboardInterface.controller;
|
|
|
+
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
+import org.jeecg.modules.base.service.IInterlockBaseService;
|
|
|
+import org.jeecg.modules.dashboardInterface.entity.InterlockAndYbStatus;
|
|
|
+import org.jeecg.modules.dashboardInterface.service.IDashboardINterfaceService;
|
|
|
+import org.jeecg.modules.iotedgeCollectData.entity.ResultD;
|
|
|
+import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.web.bind.annotation.*;
|
|
|
+
|
|
|
+import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
+import java.util.List;
|
|
|
+import java.util.Map;
|
|
|
+
|
|
|
+/**
|
|
|
+ * @author dzc
|
|
|
+ * @date 2024/7/5 10:55
|
|
|
+ * @package org.jeecg.modules.dashboardInterface.controller
|
|
|
+ * @project interlock_server
|
|
|
+ * @des
|
|
|
+ */
|
|
|
+@RestController
|
|
|
+@RequestMapping("/dashboard/currentSystemStatus")
|
|
|
+@Slf4j
|
|
|
+public class CurrentSystemStatusController {
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IDashboardINterfaceService dashboardService;
|
|
|
+ @Autowired
|
|
|
+ @SuppressWarnings("all")
|
|
|
+ private IInterlockBaseService baseService;
|
|
|
+
|
|
|
+ @GetMapping(value = "/")
|
|
|
+ public JSONObject testConnect() {
|
|
|
+ log.info("检查服务成功");
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("status",200);
|
|
|
+ return jsonObject;
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/search")
|
|
|
+ public String search(@RequestBody JSONObject request) {
|
|
|
+ log.info("调用search接口:{}", JSON.toJSONString(request));
|
|
|
+
|
|
|
+ List<String> list = dashboardService.getDeviceSystem();
|
|
|
+
|
|
|
+ return JSON.toJSONString(list);
|
|
|
+ }
|
|
|
+
|
|
|
+ @PostMapping(value = "/query")
|
|
|
+ public String query(@RequestBody JSONObject request) throws Exception {
|
|
|
+ log.info("调用query接口:{}", JSON.toJSONString(request));
|
|
|
+
|
|
|
+ List<Map<String, Object>> targets = (List<Map<String, Object>>) request.get("targets");
|
|
|
+ String deviceName = "";
|
|
|
+ String sysName = "";
|
|
|
+ for (Map<String, Object> map : targets) {
|
|
|
+ String refId = (String) map.get("refId");
|
|
|
+ if ("A".equals(refId)) {
|
|
|
+ deviceName = map.get("target").toString();
|
|
|
+ }
|
|
|
+ if ("B".equals(refId)) {
|
|
|
+ sysName = map.get("target").toString();
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
+
|
|
|
+ ArrayList<ResultD> list = new ArrayList<>();
|
|
|
+
|
|
|
+ String systemStatus = dashboardService.getSystemStatus(deviceName, sysName);
|
|
|
+
|
|
|
+
|
|
|
+ ResultD<String[]> result1 = new ResultD<>();
|
|
|
+ result1.setTarget("状态");
|
|
|
+
|
|
|
+ ArrayList<String[]> strings1 = new ArrayList<>();
|
|
|
+
|
|
|
+
|
|
|
+ String str1 = "2024-06-13";
|
|
|
+ Date data1 = format.parse(str1);
|
|
|
+
|
|
|
+ String[] v1 = new String[]{systemStatus};
|
|
|
+ strings1.add(v1);
|
|
|
+ result1.setDatapoints(strings1);
|
|
|
+
|
|
|
+ list.add(result1);
|
|
|
+
|
|
|
+ return JSON.toJSONString(list);
|
|
|
+ }
|
|
|
+}
|