Browse Source

历史记录获取调整
增加预制曲线的数据获取

dongjh 1 year ago
parent
commit
4c3d95d6ff

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

@@ -15,7 +15,10 @@ import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.text.SimpleDateFormat;
 import java.util.ArrayList;
+import java.util.Calendar;
+import java.util.Date;
 import java.util.List;
 
 @Api(tags = "webaccess测试")
@@ -68,8 +71,12 @@ public class WebAccessController {
     @ApiOperation(value = "获取历史数据(webaccess)", notes = "获取历史数据(webaccess)")
     @RequestMapping(value = "/getWADataLog", method = RequestMethod.GET)
     public Result getWADataLog() {
-        JSONObject jsonObject = webAccessService.generateDataLogObject("2023-12-19 12:00:00", "M",
-                1, 1000, "0", "设备状态");
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(new Date()); // 设置当前的时间戳
+        calendar.add(Calendar.MINUTE, -5);
+        Date startTime = calendar.getTime();
+        JSONObject jsonObject = webAccessService.generateDataLogObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime),
+                "M", 1, 5, "0", "当前湿度值");
         JSONObject result = webAccessService.GetDataLog(jsonObject);
         JSONArray jsonArray = result.getJSONArray("DataLog");
 
@@ -87,4 +94,39 @@ public class WebAccessController {
 
         return Result.OK("获取成功", result);
     }
+
+    /**
+     * 获取报警信息
+     */
+    @ApiOperation(value = "获取报警信息(webaccess)", notes = "获取报警信息(webaccess)")
+    @RequestMapping(value = "/getAlarmLog", method = RequestMethod.GET)
+    public Result getAlarmLog(Integer pageNo, Integer pageSize) {
+        pageNo = pageNo == null ? 10 : pageNo;
+        pageSize = pageSize == null ? 10 : pageSize;
+
+        JSONObject rowcount = webAccessService.getAlarmSummaryCount();
+        Integer total = (Integer) rowcount.get("Total");
+        Integer start = total - pageNo * pageSize;
+        Integer pages = total / pageSize + 1;
+
+        JSONObject jsonObject = webAccessService.getAlarmSummary(start, pageSize);
+        JSONArray jsonArray = jsonObject.getJSONArray("AlarmTagList");
+
+        JSONObject result = new JSONObject();
+        result.put("current", pageNo);
+        result.put("pages", pages);
+        result.put("size", pageSize);
+        result.put("total", total);
+
+        // 将获得的报警信息倒序排列
+        JSONArray rtnArray = new JSONArray();
+        if (jsonArray != null && jsonArray.size() > 0) {
+            for (int i = jsonArray.size() - 1; i >= 0; i--) {
+                rtnArray.add(jsonArray.get(i));
+            }
+        }
+        result.put("AlarmTagList", rtnArray);
+
+        return Result.OK("获取成功", result);
+    }
 }

+ 47 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/dto/CirculateDTO.java

@@ -0,0 +1,47 @@
+package org.jeecg.modules.webaccess.dto;
+
+import lombok.Data;
+import org.jeecg.modules.webaccess.service.WebAccessService;
+
+import java.util.List;
+
+/**
+ * 预制曲线实体
+ */
+@Data
+public class CirculateDTO {
+    /**
+     * 循环名
+     */
+    private String circname;
+
+    /**
+     * 起始段
+     */
+    private Integer beginsec;
+
+    /**
+     * 结束段
+     */
+    private Integer endsec;
+
+    /**
+     * 次数
+     */
+    private Integer timenum;
+
+    /**
+     * 开始时间
+     */
+    private String begintime;
+
+    /**
+     * 结束时间
+     */
+    private String endtime;
+
+    /**
+     * 段信息
+     */
+    private List<SectionDTO> sections;
+}

+ 44 - 0
module-guan/src/main/java/org/jeecg/modules/webaccess/dto/SectionDTO.java

@@ -0,0 +1,44 @@
+package org.jeecg.modules.webaccess.dto;
+
+import lombok.Data;
+
+/**
+ * 预制曲线实体-段
+ */
+@Data
+public class SectionDTO {
+    /**
+     * 段号
+     */
+    private Integer secname;
+
+    /**
+     * 温度
+     */
+    private Float temperature;
+
+    /**
+     * 湿度
+     */
+    private Float humidity;
+
+    /**
+     * 辐射
+     */
+    private Float radiation;
+
+    /**
+     * 时间
+     */
+    private String time;
+
+    /**
+     * 分
+     */
+    private Integer minute;
+
+    /**
+     * 秒
+     */
+    private Integer second;
+}

+ 12 - 4
module-guan/src/main/java/org/jeecg/modules/webaccess/job/WAMsgJob.java

@@ -5,12 +5,15 @@ import net.sf.json.JSONArray;
 import net.sf.json.JSONObject;
 import org.jeecg.common.util.DateUtils;
 import org.jeecg.modules.message.websocket.WebSocket;
+import org.jeecg.modules.webaccess.dto.CirculateDTO;
 import org.jeecg.modules.webaccess.service.WebAccessService;
 import org.quartz.Job;
 import org.quartz.JobExecutionContext;
 import org.quartz.JobExecutionException;
 import org.springframework.beans.factory.annotation.Autowired;
 
+import java.util.List;
+
 @Slf4j
 public class WAMsgJob implements Job {
 
@@ -36,13 +39,18 @@ public class WAMsgJob implements Job {
         jsonObject.put("设备历史值", logArray);
 
         // 最新一条报警信息
-        JSONArray lastAlarmArray = webAccessService.getDashboardDataLog();
+        JSONArray lastAlarmArray = webAccessService.getDashboardLastAlarm();
         jsonObject.put("最新一条报警信息", lastAlarmArray);
 
+        // 预制曲线
+        List<CirculateDTO> yzqxList = webAccessService.getYzcx();
+        jsonObject.put("预制曲线", yzqxList);
+
         // 报警信息列表
-        JSONArray alarmArray = webAccessService.getDashboardDataLog();
-        jsonObject.put("报警信息列表", alarmArray);
+//        JSONArray alarmArray = webAccessService.getDashboardPageAlarm();
+//        jsonObject.put("报警信息列表", alarmArray);
 
-        webSocket.pushMessageByObject(jsonObject);
+//        webSocket.pushMessageByObject(jsonObject);
+        webSocket.pushMessage(jsonObject.toString());
     }
 }

+ 406 - 14
module-guan/src/main/java/org/jeecg/modules/webaccess/service/WebAccessService.java

@@ -6,6 +6,8 @@ import org.apache.commons.codec.binary.Base64;
 import org.apache.commons.collections.map.HashedMap;
 import org.jeecg.modules.system.entity.SysDictItem;
 import org.jeecg.modules.system.service.ISysDictItemService;
+import org.jeecg.modules.webaccess.dto.CirculateDTO;
+import org.jeecg.modules.webaccess.dto.SectionDTO;
 import org.jeecg.modules.webaccess.dto.WaLogDTO;
 import org.jeecg.modules.webaccess.entity.GuanDashboardParam;
 import org.jeecg.modules.webaccess.mapper.GuanDashboardParamMapper;
@@ -19,7 +21,12 @@ import org.springframework.stereotype.Service;
 import org.springframework.web.client.RestTemplate;
 
 import java.text.SimpleDateFormat;
+import java.time.LocalDate;
+import java.time.LocalDateTime;
+import java.time.ZoneId;
+import java.time.temporal.ChronoUnit;
 import java.util.*;
+import java.util.concurrent.TimeUnit;
 import java.util.jar.JarEntry;
 
 /**
@@ -259,7 +266,7 @@ public class WebAccessService {
      * @return
      */
     public JSONObject getAlarmSummary(Integer start, Integer count) {
-        String url = getDictItemDesc("取得实时警报资料数量", "group");
+        String url = getDictItemDesc("取得实时警报资料", "group");
         url += "/" + start + "/" + count;
         JSONObject result = httpRequest(url, null);
 
@@ -390,7 +397,7 @@ public class WebAccessService {
     }
     //endregion
 
-    //region <<根据大屏参数设置,获取点位值>>
+    //region <<根据大屏参数设置,获取实时点位值>>
     /**
      * 取得测点(Tag)的量测值
      *
@@ -507,10 +514,10 @@ public class WebAccessService {
         resJsonArray.add(addObject);
 
         // 斜率设定
-        addObject.put("Name", "斜率设定");
-        addObject.put("Value",0);
-        addObject.put("Quality", 0);
-        resJsonArray.add(addObject);
+//        addObject.put("Name", "斜率设定");
+//        addObject.put("Value",0);
+//        addObject.put("Quality", 0);
+//        resJsonArray.add(addObject);
 
         // 升温/降温:温度输出率为0%-100%则是加热状态,-100%--0%则是降温状态
         addObject.put("Name", "升温");
@@ -558,7 +565,9 @@ public class WebAccessService {
 
         return rtnArray;
     }
+    //endregion
 
+    //region <<根据大屏参数设定,取得历史记录>>
     /**
      * 取得历史记录
      *
@@ -574,23 +583,135 @@ public class WebAccessService {
         // 组合参数信息
         JSONArray list = new JSONArray();
         if (dashboardParamList != null && dashboardParamList.size() > 0) {
+            Integer ssIntervals = null; // 实时曲线的 每笔数据之间隔时间
+            Integer qcIntervals = null; // 全程曲线的 每笔数据之间隔时间
+
+            Integer ssRecord = null; // 实时曲线的 获取记录条数
+            Integer qcRecord = null; // 全程曲线的 获取记录条数
+
+            Integer ssDuration = null; // 实时曲线的 获取历史记录时长
+
+            Date now = new Date();
+
+            // 获取试验运行时间
+            List<WaLogDTO> tags = new ArrayList<>();
+            WaLogDTO waLogDTO = new WaLogDTO("试验运行时间");
+            tags.add(waLogDTO);
+            JSONObject waparams = generateGetObject(tags);
+            Integer syyxsj = Integer.parseInt(getTagNameValues(waparams)); // 获取试验运行时间
+
+            // 开始时间
+            Calendar calendar = Calendar.getInstance();
+            calendar.setTime(now); // 设置当前的时间戳
+            calendar.add(Calendar.SECOND, -syyxsj);
+            Date startTime = calendar.getTime(); // 试验开始时间(也是 全程曲线开始时间)
+            Date realityTime = null; // 实时曲线开始时间
+
             for (GuanDashboardParam param : dashboardParamList) {
                 if (param.getTagName() != null && !"".equals(param.getTagName())) {
-                    JSONObject jo = generateDataLogObject("2023-12-26 21:00:00",
-                            param.getIntervaltype() == null || "".equals(param.getIntervaltype()) ? "M" : param.getIntervaltype(),
-                            param.getIntervals() == null ? 1 : param.getIntervals(),
-                            param.getRecords() == null ? 1000 : param.getRecords(),
-                            param.getDatatype() == null || "".equals(param.getDatatype()) ? "0" : param.getDatatype(),
-                            param.getTagName());
+                    JSONObject jo = null;
+
+                    // 1 获取 实时曲线 参数
+                    if (param.getParamName().equals("辐射强度值-实时") || param.getParamName().equals("湿度实值-实时") ||
+                            param.getParamName().equals("温度实值-实时")) {
+                        // 1.1 每笔数据之间隔时间
+                        if (ssIntervals == null) {
+                            ssIntervals = param.getIntervals() == 0 || param.getIntervals() == null ? 1 : param.getIntervals();
+                        }
+
+                        // 1.2 开始时间(实验运行时间>历史时长,则用历史时长计算开始时间,否则用实际运行时间计算开始时间)
+                        if (ssDuration == null) {
+                            ssDuration = param.getDuration() == null || param.getDuration() == 0 ? 4 : param.getDuration();
+                        }
+                        if (realityTime == null) {
+                            calendar.setTime(now); // 设置当前的时间戳
+                            if (syyxsj > param.getDuration() * 3600) {
+                                calendar.add(Calendar.HOUR, -ssDuration);
+                            }
+                            else {
+                                calendar.add(Calendar.SECOND, -syyxsj);
+                            }
+                            realityTime = calendar.getTime();
+                        }
+
+                        // 1.3 计算 获取记录条数
+                        if (ssRecord == null) {
+                            ssRecord = Integer.parseInt((ChronoUnit.MINUTES.between(
+                                    LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(realityTime).replace(" ", "T")),
+                                    LocalDateTime.parse(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(now).replace(" ", "T"))
+                                ) / ssIntervals) + "");
+                        }
+
+                        // 组合参数
+                        jo = generateDataLogObject(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(realityTime),
+                                param.getIntervaltype() == null || "".equals(param.getIntervaltype()) ? "M" : param.getIntervaltype(),
+                                ssIntervals,
+                                ssRecord,
+                                param.getDatatype() == null || "".equals(param.getDatatype()) ? "0" : param.getDatatype(),
+                                param.getTagName());
+                    }
+
+                    // 2 获取 全程曲线 参数
+                    if (param.getParamName().equals("辐射强度值-全程") || param.getParamName().equals("湿度实值-全程") ||
+                            param.getParamName().equals("温度实值-全程")) {
+                        // 2.1 每笔数据之间隔时间
+                        if (qcIntervals == null) {
+                            qcIntervals = param.getIntervals() == 0 || param.getIntervals() == null ? 1 : param.getIntervals();
+                        }
+
+                        // 2.2 计算每笔数据之间隔时间(设x = 参数定义的间隔时间,y = 间隔天数,计算公式:x + x * y)
+                        if (qcIntervals == null) {
+                            qcIntervals = param.getIntervals() == 0 || param.getIntervals() == null ? 1 : param.getIntervals();
+                            LocalDate startLocalDate = startTime.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+                            LocalDate endLocalDate = now.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
+                            Long day = ChronoUnit.DAYS.between(startLocalDate, endLocalDate);
+                            qcIntervals = qcIntervals + qcIntervals * (Integer.parseInt(day.toString()));
+                        }
+
+                        // 2.3 获取记录条数
+                        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(now).replace(" ", "T"))
+                                ) / qcIntervals) + "");
+                        }
+
+                        // 2.4 组合参数
+                        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);
                     JSONObject logObj = new JSONObject();
                     logObj.put("Name", param.getParamName());
-                    logObj.put("Values", dataLog.getJSONArray("DataLog").getJSONObject(0).getJSONArray("Values"));
+                    if (dataLog.getJSONArray("DataLog").size() > 0) {
+                        logObj.put("Values", dataLog.getJSONArray("DataLog").getJSONObject(0).getJSONArray("Values"));
+                    }
+                    else {
+                        logObj.put("Values", null);
+                    }
                     list.add(logObj);
                 }
             }
+
+            // 获取实时曲线时间分布
+            List<String> stimes = genTime(realityTime, now, ssIntervals);
+            JSONObject stimeObject = new JSONObject();
+            stimeObject.put("Name", "实时曲线-时间分布");
+            stimeObject.put("Values", stimes);
+            list.add(stimeObject);
+
+            // 获取全程曲线时间分布
+            List<String> qtimes = genTime(startTime, now, qcIntervals);
+            JSONObject qtimeObject = new JSONObject();
+            qtimeObject.put("Name", "全程曲线-时间分布");
+            qtimeObject.put("Values", qtimes);
+            list.add(qtimeObject);
         }
         else {
             return null;
@@ -599,6 +720,277 @@ public class WebAccessService {
     }
 
     /**
+     * 生成实时曲线需要的时间
+     * @param startTime 开始时间
+     * @param intervals 间隔频率(分钟)
+     */
+    private List<String> genTime(Date startTime, Date endTime, Integer intervals) {
+        List<String> times = new ArrayList<>();
+
+        // 循环获取时间
+        Calendar calendar = Calendar.getInstance();
+        while (startTime.before(endTime)) {
+//            times.add(new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(startTime));
+            times.add(new SimpleDateFormat("HH:mm").format(startTime));
+            // 设置当前的时间戳
+            calendar.setTime(startTime);
+            calendar.add(Calendar.MINUTE, intervals);
+            startTime = calendar.getTime();
+        }
+
+        return times;
+    }
+    //endregion
+
+    // region <<获取预制曲线>>
+    /**
+     * 获取预制曲线
+     * @return
+     */
+    public List<CirculateDTO> getYzcx() {
+        // 获取4个内部循环定义信息(启始段、结束段、次数)
+        List<CirculateDTO> circulates = getNbxh();
+
+        // 获取循环详细信息(温度、湿度、时间)
+        getCxsd(circulates);
+
+        circulates.remove(circulates.size() - 1);
+
+        return circulates;
+    }
+
+    /**
+     * 获取循环详细信息(温度、湿度、时间)
+     * @param circulates 循环信息
+     * @return
+     */
+    private void getCxsd(List<CirculateDTO> circulates) {
+        Integer allSecond = 0; // 累加的秒
+
+        // 循环获取信息
+        if (circulates != null && circulates.size() > 0) {
+            for (int j = 0; j < circulates.size(); j++) {
+                // 全部循环设定值,则略过
+                if (circulates.get(j).getCircname().equals("全部循环设定值")) {
+                    continue;
+                }
+
+                List<SectionDTO> sections = new ArrayList<>();
+                for (int i = circulates.get(j).getBeginsec(); i <= circulates.get(j).getEndsec(); i++) {
+                    int xb = i + 1; // 下标
+                    String cxd = (xb < 10 ? "0" + xb : "" + xb);
+
+                    SectionDTO section = new SectionDTO();
+                    section.setSecname(i); // 段号
+
+                    WaLogDTO waLogDTO = new WaLogDTO("");
+                    List<WaLogDTO> tags = new ArrayList<>();
+                    JSONObject waparams = new JSONObject();
+
+                    // 温度
+                    tags.clear();
+                    waLogDTO.setTagname("程序温度设定区域" + cxd);
+                    tags.add(waLogDTO);
+                    waparams = generateGetObject(tags);
+                    section.setTemperature(Float.parseFloat(getTagNameValues(waparams)));
+
+                    // 湿度
+                    tags.clear();
+                    waLogDTO.setTagname("程序湿度设定区域" + cxd);
+                    tags.add(waLogDTO);
+                    waparams = generateGetObject(tags);
+                    section.setHumidity(Float.parseFloat(getTagNameValues(waparams)));
+
+                    // 分
+                    tags.clear();
+                    waLogDTO.setTagname("程序时间设定区域_分" + cxd);
+                    tags.add(waLogDTO);
+                    waparams = generateGetObject(tags);
+                    Integer minute = Integer.parseInt(getTagNameValues(waparams));
+                    section.setMinute(minute);
+
+                    // 秒
+                    tags.clear();
+                    waLogDTO.setTagname("程序时间设定区域_秒" + cxd);
+                    tags.add(waLogDTO);
+                    waparams = generateGetObject(tags);
+                    Integer second = Integer.parseInt(getTagNameValues(waparams));
+                    section.setSecond(second);
+
+                    // 时间
+                    Long hourl = TimeUnit.SECONDS.toHours(allSecond);
+                    String hours = hourl + "";
+                    if (hourl == 0) {
+                        hours = "00";
+                    } else if (hourl > 0 && hourl < 10) {
+                        hours = "0" + hourl;
+                    }
+                    Long minutel = TimeUnit.SECONDS.toMinutes(allSecond % 3600);
+                    String minutes = minutel + "";
+                    if (minutel == 0) {
+                        minutes = "00";
+                    } else if (minutel > 0 && minutel < 10) {
+                        minutes = "0" + minutel;
+                    }
+                    section.setTime(hours + ":" + minutes);
+
+                    allSecond += minute * 60 + second;
+
+                    sections.add(section);
+                }
+                if (sections != null && sections.size() > 0) {
+                    circulates.get(j).setBegintime(sections.get(0).getTime());
+                    circulates.get(j).setEndtime(sections.get(sections.size() - 1).getTime());
+                }
+                circulates.get(j).setSections(sections);
+            }
+        }
+    }
+
+    /**
+     * 获取4个内部循环定义信息(启始段、结束段、次数)
+     * @return
+     */
+    private List<CirculateDTO> getNbxh() {
+        // 组合参数信息
+        List<WaLogDTO> tags = new ArrayList<>();
+        tags.add(new WaLogDTO("内部循环1_启始段"));
+        tags.add(new WaLogDTO("内部循环1_结束段"));
+        tags.add(new WaLogDTO("内部循环1_次数"));
+        tags.add(new WaLogDTO("内部循环2_启始段"));
+        tags.add(new WaLogDTO("内部循环2_结束段"));
+        tags.add(new WaLogDTO("内部循环2_次数"));
+        tags.add(new WaLogDTO("内部循环3_启始段"));
+        tags.add(new WaLogDTO("内部循环3_结束段"));
+        tags.add(new WaLogDTO("内部循环3_次数"));
+        tags.add(new WaLogDTO("内部循环4_启始段"));
+        tags.add(new WaLogDTO("内部循环4_结束段"));
+        tags.add(new WaLogDTO("内部循环4_次数"));
+        tags.add(new WaLogDTO("全部循环设定值"));
+        JSONObject waparams = generateGetObject(tags);
+
+        // 获取信息
+        JSONObject jsonObject = getTagNameValuesNoAnalysis(waparams);
+        JSONArray resArray = jsonObject.getJSONArray("Values");
+        List<CirculateDTO> circulates = new ArrayList<>();
+
+        // 重新排列(怕webaccess传回的数据顺序不对)
+        // 1外部循环
+        if (resArray.size() > 0) {
+            Integer nbxh1_qsd = 0;
+            Integer nbxh1_jsd = 0;
+            Integer nbxh1_cs = 0;
+            Integer nbxh2_qsd = 0;
+            Integer nbxh2_jsd = 0;
+            Integer nbxh2_cs = 0;
+            Integer nbxh3_qsd = 0;
+            Integer nbxh3_jsd = 0;
+            Integer nbxh3_cs = 0;
+            Integer nbxh4_qsd = 0;
+            Integer nbxh4_jsd = 0;
+            Integer nbxh4_cs = 0;
+            Integer quanbu = 0;
+
+            for (Integer i = 0; i < resArray.size(); i++) {
+                JSONObject nbxh = resArray.getJSONObject(i);
+                switch (nbxh.get("Name").toString()) {
+                    // 1.1内部循环1
+                    case "内部循环1_启始段":
+                        nbxh1_qsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环1_结束段":
+                        nbxh1_jsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环1_次数":
+                        nbxh1_cs = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    // 1.2内部循环2
+                    case "内部循环2_启始段":
+                        nbxh2_qsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环2_结束段":
+                        nbxh2_jsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环2_次数":
+                        nbxh2_cs = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    // 1.3内部循环3
+                    case "内部循环3_启始段":
+                        nbxh3_qsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环3_结束段":
+                        nbxh3_jsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环3_次数":
+                        nbxh3_cs = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    // 1.4内部循环4
+                    case "内部循环4_启始段":
+                        nbxh4_qsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环4_结束段":
+                        nbxh4_jsd = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    case "内部循环4_次数":
+                        nbxh4_cs = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    // 2全部循环
+                    case "全部循环设定值":
+                        quanbu = Integer.parseInt(nbxh.get("Value").toString());
+                        break;
+                    default:
+                        break;
+                }
+            }
+            // 依据循环的次序,判断循环是否使用,使用则添加到循环中,否则抛弃
+            if (nbxh1_cs > 0) {
+                CirculateDTO circulate = new CirculateDTO();
+                circulate.setCircname("内部循环1");
+                circulate.setBeginsec(nbxh1_qsd);
+                circulate.setEndsec(nbxh1_jsd);
+                circulate.setTimenum(nbxh1_cs);
+                circulates.add(circulate);
+            }
+
+            if (nbxh2_cs > 0) {
+                CirculateDTO circulate = new CirculateDTO();
+                circulate.setCircname("内部循环2");
+                circulate.setBeginsec(nbxh2_qsd);
+                circulate.setEndsec(nbxh2_jsd);
+                circulate.setTimenum(nbxh2_cs);
+                circulates.add(circulate);
+            }
+
+            if (nbxh3_cs > 0) {
+                CirculateDTO circulate = new CirculateDTO();
+                circulate.setCircname("内部循环3");
+                circulate.setBeginsec(nbxh3_qsd);
+                circulate.setEndsec(nbxh3_jsd);
+                circulate.setTimenum(nbxh3_cs);
+                circulates.add(circulate);
+            }
+
+            if (nbxh4_cs > 0) {
+                CirculateDTO circulate = new CirculateDTO();
+                circulate.setCircname("内部循环4");
+                circulate.setBeginsec(nbxh4_qsd);
+                circulate.setEndsec(nbxh4_jsd);
+                circulate.setTimenum(nbxh4_cs);
+                circulates.add(circulate);
+            }
+
+            CirculateDTO circulate = new CirculateDTO();
+            circulate.setCircname("全部循环设定值");
+            circulate.setTimenum(nbxh1_qsd);
+            circulates.add(circulate);
+        }
+
+        return circulates;
+    }
+    // endregion
+
+    // region <<获取报警信息>>
+    /**
      * 获取最新一条报警信息
      * @return
      */
@@ -610,7 +1002,7 @@ public class WebAccessService {
         if (jsonObject != null) {
             Integer total = (Integer) jsonObject.get("Total");
             if (total != null && total > 0) {
-                JSONObject alarms = getAlarmSummary(total, 1);
+                JSONObject alarms = getAlarmSummary(total - 1, 1);
                 jsonArray = alarms.getJSONArray("AlarmTagList");
             }
         }