Просмотр исходного кода

调整温湿度值历史查询功能

dongjh месяцев назад: 4
Родитель
Сommit
0b2f8e80cf

+ 2 - 2
jeecg-module-system/jeecg-system-start/src/main/resources/application-dev.yml

@@ -159,7 +159,7 @@ spring:
         master:
           # 打包时修改该配置
           url: jdbc:mysql://127.0.0.1:3306/guAn_rl?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
-#          url: jdbc:mysql://152.136.206.27:3306/guAn_rl?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
+#          url: jdbc:mysql://119.3.168.55:3306/guAn_rl?characterEncoding=UTF-8&useUnicode=true&useSSL=false&tinyInt1isBit=false&allowPublicKeyRetrieval=true&serverTimezone=Asia/Shanghai
           username: itdm-boot
           password: itdm-boot@2023
           driver-class-name: com.mysql.cj.jdbc.Driver
@@ -333,7 +333,7 @@ third-app:
 
 binarylog:
   # 打包时修改该配置
-#  host: 152.136.206.27
+#  host: 119.3.168.55
   host: 127.0.0.1
   username: itdm-boot
   password: itdm-boot@2023

+ 3 - 1
module-guan/src/main/java/org/jeecg/modules/MysqlBinLogClient.java

@@ -197,7 +197,9 @@ public class MysqlBinLogClient implements ApplicationRunner {
 //                    log.info("guan_anachglog Insert");
 
                     Object[] obj = Arrays.stream(((WriteRowsEventData) data).getRows().get(0)).toArray();
-                    if ("设备状态".equals(obj[2].toString())) {
+//                    设备启动时间由“设备状态”改成“通风启停”
+//                    if ("设备状态".equals(obj[2].toString())) {
+                    if ("通风启停".equals(obj[2].toString())) {
                         GuanAnachglog anachglog = new GuanAnachglog();
                         anachglog.setId((Integer) obj[0]);
                         anachglog.setProjnodeid((Integer) obj[1]);

+ 1 - 1
module-guan/src/main/java/org/jeecg/modules/webaccess/controller/WebAccessController.java

@@ -170,7 +170,7 @@ public class WebAccessController {
     @ApiOperation(value = "获取全程曲线", notes = "获取全程曲线")
     @RequestMapping(value = "/getQcqx", method = RequestMethod.GET)
     public Result getQcqx(GuanTest guanTest) {
-        List<CurveDTO> rtn = webAccessService.getWholeCurve(guanTest.getStarttime());
+        List<CurveDTO> rtn = webAccessService.searchWholeCurve(guanTest.getStarttime(), guanTest.getCreateTime());
 
         return Result.OK("获取成功", rtn);
     }

+ 115 - 2
module-guan/src/main/java/org/jeecg/modules/webaccess/service/WebAccessService.java

@@ -5,6 +5,7 @@ import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.collections.map.HashedMap;
+import org.hibernate.dialect.Sybase11Dialect;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.common.util.RedisUtil;
 import org.jeecg.modules.common.GuanCommonConstant;
@@ -785,7 +786,13 @@ public class WebAccessService {
                 curve.setSubList(subList);
             }
             else {
-                curve.setSubList(null);
+                // 赋一个空值
+                CurveSubDTO subdto = new CurveSubDTO();
+                subdto.setLogtime(new Date());
+                subdto.setTagvalue(param.getTagName());
+                List<CurveSubDTO> subList = new ArrayList<>();
+                subList.add((subdto));
+                curve.setSubList(subList);
             }
             curveList.add(curve);
         }
@@ -890,7 +897,13 @@ public class WebAccessService {
                 curve.setSubList(subList);
             }
             else {
-                curve.setSubList(null);
+                // 赋一个空值
+                CurveSubDTO subdto = new CurveSubDTO();
+                subdto.setLogtime(new Date());
+                subdto.setTagvalue(param.getTagName());
+                List<CurveSubDTO> subList = new ArrayList<>();
+                subList.add((subdto));
+                curve.setSubList(subList);
             }
             curveList.add(curve);
         }
@@ -901,6 +914,106 @@ public class WebAccessService {
     }
 
     /**
+     * 获取全程曲线(查询)
+     * @param startTime 开始时间
+     * @return
+     */
+    public List<CurveDTO> searchWholeCurve(Date startTime, Date endTime) {
+        // 获取大屏参数设置
+        GuanDashboardParam paramat = new GuanDashboardParam();
+        paramat.setStatus("1"); // 状态为启用
+        paramat.setIflog("Y"); // 需要获取历史记录
+        List<GuanDashboardParam> dashboardParamList = dashboardParamMapper.selectAllDashboardParam(paramat);
+        if (dashboardParamList == null || dashboardParamList.size() < 1) {
+            return null;
+        }
+
+        // 组合参数信息
+        List<CurveDTO> curveList = new ArrayList<CurveDTO>();
+        Integer qcIntervals = null; // 全程曲线的 每笔数据之间隔时间
+        Integer qcRecord = null; // 全程曲线的 获取记录条数
+        if (endTime == null || "".equals(endTime)) {
+            endTime = new Date();
+        }
+
+        // 开始时间
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(endTime); // 设置当前的时间戳
+        // calendar.add(Calendar.SECOND, -syyxsj);
+        // Date startTime = calendar.getTime(); // 试验开始时间(也是 全程曲线开始时间)
+        GuanTest guanTest = guanTestMapper.selectTop1Test();
+        startTime = startTime == null ? guanTest.getStarttime() : startTime; // 试验开始时间(也是 全程曲线开始时间)
+        Integer syyxsj = Integer.parseInt(((endTime.getTime() - startTime.getTime()) / 1000) + "");
+
+        for (GuanDashboardParam param : dashboardParamList) {
+            // 没有点位名
+            if (param.getTagName() == null || "".equals(param.getTagName())) {
+                continue;
+            }
+            if (!param.getParamName().equals("辐射强度值-全程") && !param.getParamName().equals("湿度实值-全程") &&
+                    !param.getParamName().equals("温度实值-全程")) {
+                continue;
+            }
+            JSONObject jo = null;
+            CurveDTO curve = new CurveDTO();
+            curve.setTagname(param.getTagName());
+
+            // 2 获取 全程曲线 参数
+            curve.setType("全程");
+            // 2.1 每笔数据之间隔时间
+            qcIntervals = 1;
+
+            // 2.2 获取记录条数
+            if (qcRecord == null) {
+                qcRecord = Integer.parseInt((ChronoUnit.MINUTES.between(
+                        LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime).replace(" ", "T")),
+                        LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(endTime).replace(" ", "T"))
+                ) / qcIntervals) + "");
+            }
+
+            // 2.3 组合参数
+            jo = generateDataLogObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime),
+                    param.getIntervaltype() == null || "".equals(param.getIntervaltype()) ? "M" : param.getIntervaltype(),
+                    qcIntervals,
+                    qcRecord,
+                    param.getDatatype() == null || "".equals(param.getDatatype()) ? "0" : param.getDatatype(),
+                    param.getTagName());
+
+            // 获取信息
+            JSONObject dataLog = GetDataLog(jo);
+            curve.setName(param.getParamName());
+            curve.setTagname(param.getTagName());
+            log.info(dataLog.getJSONArray("DataLog").toString());
+            if (dataLog.getJSONArray("DataLog").size() > 0) {
+                List<String> values = dataLog.getJSONArray("DataLog").getJSONObject(0).getJSONArray("Values");
+                List<CurveSubDTO> subList = new ArrayList<>();
+                if (values != null && values.size() > 0) {
+                    for (String value : values) {
+                        CurveSubDTO sub = new CurveSubDTO();
+                        sub.setTagvalue(value);
+                        subList.add(sub);
+                    }
+                }
+                curve.setSubList(subList);
+            }
+            else {
+                // 赋一个空值
+                CurveSubDTO subdto = new CurveSubDTO();
+                subdto.setLogtime(new Date());
+                subdto.setTagvalue(param.getTagName());
+                List<CurveSubDTO> subList = new ArrayList<>();
+                subList.add((subdto));
+                curve.setSubList(subList);
+            }
+            curveList.add(curve);
+        }
+        // 设置全程曲线时间分布
+        genTime(startTime, endTime, qcIntervals, "MM-dd HH:mm:ss", curveList, "全程");
+
+        return curveList;
+    }
+
+    /**
      * 生成曲线的时间
      *
      * @param startTime 开始时间