Explorar o código

风机报警和升压站报警功能修改优化

shilin hai 1 ano
pai
achega
e58d4e654f
Modificáronse 24 ficheiros con 1461 adicións e 48 borrados
  1. 14 7
      alarm-custom/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmRule.java
  2. 25 25
      alarm-custom/src/main/java/com/gyee/alarm/service/AlarmCustomService.java
  3. 4 0
      alarm-service/src/main/java/com/gyee/alarm/init/CacheContext.java
  4. 1 0
      alarm-service/src/main/java/com/gyee/alarm/model/vo/AlarmCustomType.java
  5. 6 1
      alarm-web/pom.xml
  6. 290 0
      alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java
  7. 20 0
      alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmRuleController.java
  8. 20 0
      alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmTypeController.java
  9. 109 1
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRuleMapper.java
  10. 16 0
      alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmTypeMapper.java
  11. 38 9
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmRule.java
  12. 52 0
      alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmType.java
  13. 2 0
      alarm-web/src/main/java/com/gyee/alarm/model/vo/AjaxResult.java
  14. 24 0
      alarm-web/src/main/java/com/gyee/alarm/model/vo/AlarmRuleVo.java
  15. 180 0
      alarm-web/src/main/java/com/gyee/alarm/service/AlarmRuleService.java
  16. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmRuleService.java
  17. 16 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmTypeService.java
  18. 1 1
      alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmRuleServiceImpl.java
  19. 20 0
      alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmTypeServiceImpl.java
  20. 48 0
      alarm-web/src/main/java/com/gyee/alarm/util/ExcelUtils.java
  21. 530 0
      alarm-web/src/main/java/com/gyee/alarm/util/StringUtil.java
  22. 6 3
      alarm-web/src/main/resources/application-jn.yml
  23. 38 0
      log/ota.log
  24. BIN=BIN
      log/ota.log.2023-08-07.0.gz

+ 14 - 7
alarm-custom/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmRule.java

@@ -1,6 +1,9 @@
 package com.gyee.alarm.model.auto;
 
 import com.baomidou.mybatisplus.extension.activerecord.Model;
+import java.time.LocalDateTime;
+import java.util.Date;
+
 import lombok.Data;
 import lombok.EqualsAndHashCode;
 
@@ -10,7 +13,7 @@ import lombok.EqualsAndHashCode;
  * </p>
  *
  * @author shilin
- * @since 2023-06-27
+ * @since 2023-08-09
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
@@ -49,11 +52,6 @@ public class ProEconAlarmRule extends Model {
     private Integer rank;
 
     /**
-     * 是否启用
-     */
-    private Boolean enable;
-
-    /**
      * 机型
      */
     private String modelId;
@@ -93,11 +91,20 @@ public class ProEconAlarmRule extends Model {
      */
     private String electricalId;
 
-
     /**
      * 关联部件
      */
     private String relatedParts;
 
+    /**
+     * 创建时间
+     */
+    private Date createTime;
+
+    /**
+     * 是否启用
+     */
+    private Boolean enable;
+
 
 }

+ 25 - 25
alarm-custom/src/main/java/com/gyee/alarm/service/AlarmCustomService.java

@@ -142,31 +142,31 @@ public class AlarmCustomService {
 
         System.out.println(str.toString());
 
-//        //读取升压站测点
-//        int wslen = 1;
-//        List<ProBasicPowerstationPoint> wspols=new ArrayList<>();
-//        for(int i=0;i<wsPointList.size();i++)
-//        {
-//            wspols.add(wsPointList.get(i));
-//            if(i!=0 && i%readCount==0)
-//            {
-//                str.setLength(0);
-//                str.append("总数:").append(wspols.size()).append(",线程数:").append(readCount).append(",分块大小:").append(wslen);
-//
-//                new Thread(new ReadWsDataThread(executor, edosUtil, readRows,  wspols,interval,str)).start();
-//                wspols=new ArrayList<>();
-//                wslen++;
-//            }
-//        }
-//
-//        if(!wspols.isEmpty())
-//        {
-//            str.setLength(0);
-//            str.append("总数:").append(wspols.size()).append(",线程数:").append(readCount).append(",分块大小:").append(wslen);
-//
-//            new Thread(new ReadWsDataThread(executor, edosUtil, readRows,  wspols,interval,str)).start();
-//
-//        }
+        //读取升压站测点
+        int wslen = 1;
+        List<ProBasicPowerstationPoint> wspols=new ArrayList<>();
+        for(int i=0;i<wsPointList.size();i++)
+        {
+            wspols.add(wsPointList.get(i));
+            if(i!=0 && i%readCount==0)
+            {
+                str.setLength(0);
+                str.append("总数:").append(wspols.size()).append(",线程数:").append(readCount).append(",分块大小:").append(wslen);
+
+                new Thread(new ReadWsDataThread(executor, edosUtil, readRows,  wspols,interval,str)).start();
+                wspols=new ArrayList<>();
+                wslen++;
+            }
+        }
+
+        if(!wspols.isEmpty())
+        {
+            str.setLength(0);
+            str.append("总数:").append(wspols.size()).append(",线程数:").append(readCount).append(",分块大小:").append(wslen);
+
+            new Thread(new ReadWsDataThread(executor, edosUtil, readRows,  wspols,interval,str)).start();
+
+        }
 
 
     }

+ 4 - 0
alarm-service/src/main/java/com/gyee/alarm/init/CacheContext.java

@@ -602,10 +602,14 @@ public class CacheContext implements CommandLineRunner {
                 }else  if(vo.getCategory().equals(AlarmCustomType.WP.getCode()))
                 {
                     wpCustomls.add(vo);
+                }else  if(vo.getCategory().equals(AlarmCustomType.Bt.getCode()))
+                {
+                    wpCustomls.add(vo);
                 }
 
             }
         }
+        alarmRulesMap.put(AlarmCustomType.Bt.getCode(),btCustomls);
         alarmRulesMap.put(AlarmCustomType.WT.getCode(),wtCustomls);
         alarmRulesMap.put(AlarmCustomType.WP.getCode(),wpCustomls);
 

+ 1 - 0
alarm-service/src/main/java/com/gyee/alarm/model/vo/AlarmCustomType.java

@@ -3,6 +3,7 @@ package com.gyee.alarm.model.vo;
 public enum AlarmCustomType {
 
     WT("windturbine", "设备自定义报警"),
+    Bt("booststation", "升压站报警"),
     WP("station", "场站自定义报警");
 
     private String code;

+ 6 - 1
alarm-web/pom.xml

@@ -164,7 +164,12 @@
             <artifactId>taos-jdbcdriver</artifactId>
             <version>3.2.2</version>
         </dependency>
-
+        <!-- 工具类相关 -->
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>easyexcel</artifactId>
+            <version>3.2.0</version>
+        </dependency>
     </dependencies>
     <build>
         <plugins>

+ 290 - 0
alarm-web/src/main/java/com/gyee/alarm/controller/AlertRuleController.java

@@ -0,0 +1,290 @@
+package com.gyee.alarm.controller;
+
+import com.alibaba.fastjson.JSONObject;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.alarm.model.auto.ProEconAlarmRule;
+import com.gyee.alarm.model.vo.AjaxResult;
+import com.gyee.alarm.model.vo.AjaxStatus;
+import com.gyee.alarm.model.vo.AlarmRuleVo;
+import com.gyee.alarm.service.AlarmRuleService;
+
+import com.gyee.alarm.util.ExcelUtils;
+import com.gyee.alarm.util.SnowflakeGenerator;
+import com.gyee.alarm.util.StringUtils;
+
+import com.gyee.common.util.DateUtils;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+
+import org.codehaus.groovy.syntax.TokenUtil;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.*;
+
+
+@Slf4j
+@RestController
+@RequestMapping("/alertrule")
+@CrossOrigin
+public class AlertRuleController {
+
+    @Autowired
+    private AlarmRuleService alarmRuleService;
+
+   
+    @GetMapping(value = "/list")
+    public List<AlarmRuleVo> queryTree() {
+        List<AlarmRuleVo> alertrules = alarmRuleService.queryTree();
+        return alertrules;
+    }
+
+
+
+    //@UserLoginToken
+    @PostMapping(value = "/save")
+    @ResponseBody
+   
+    public AjaxResult saveAlertrule(HttpServletRequest request, @RequestBody ProEconAlarmRule alarmRule) throws Exception {
+
+        int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
+
+        return AjaxResult.successData(AjaxStatus.success.code, result);
+
+    }
+    @PostMapping(value = "/update")
+    @ResponseBody
+
+    public AjaxResult updateAlertrule(HttpServletRequest request, @RequestBody ProEconAlarmRule alarmRule) throws Exception {
+
+        int result = alarmRuleService.saveAndUpdateAlertrule(alarmRule);
+        return AjaxResult.successData(AjaxStatus.success.code, result);
+
+    }
+    @DeleteMapping(value = "/delete")
+    public int deleteAlertrule(ProEconAlarmRule alarmRule) {
+        return alarmRuleService.deleteAlertrule(alarmRule);
+    }
+
+    //@UserLoginToken
+    @GetMapping(value = "/page")
+    public IPage<ProEconAlarmRule> queryByPage(HttpServletRequest request,
+            @RequestParam(value = "pagenum") Integer pageNum,
+            @RequestParam(value = "pagesize") Integer pageSize,
+            @RequestParam(value = "name", required = false) String name,
+            @RequestParam(value = "station", required = false) String station,
+            @RequestParam(value = "modelId", required = false) String modelId,
+            @RequestParam(value = "rank", required = false) String rank,
+            @RequestParam(value = "category", required = false) String category,
+            @RequestParam(value = "enabled",required = false) String enabled,
+            @RequestParam(value = "relatedparts",required = false) String relatedparts
+    ) {
+        Page<ProEconAlarmRule> page = new Page(pageNum, pageSize);
+
+          IPage<ProEconAlarmRule> pageResult = alarmRuleService.pageQueryAll(page, name,station,modelId,rank,category,enabled,relatedparts);
+
+        return pageResult;
+    }
+
+    private AjaxResult dataCheck(ProEconAlarmRule alertrule) {
+
+        String msg = "";
+        boolean result = true;
+        if (StringUtils.isBlank(alertrule.getName())) {
+            msg = "报警名称不能为空";
+            result = false;
+        } else if (StringUtils.isBlank(alertrule.getDescription())) {
+            msg = "规则描述不能为空";
+            result = false;
+        } else if (StringUtils.isBlank(alertrule.getExpression())) {
+            msg = "报警规则不能为空";
+            result = false;
+        } else if (StringUtils.empty(alertrule.getRank())) {
+            msg = "报警级别不能为空";
+            result = false;
+        }
+        else if (StringUtils.isBlank(alertrule.getStationId())) {
+            msg = "风场不能为空";
+            result = false;
+        } else if (StringUtils.isBlank(alertrule.getCategory())) {
+            msg = "报警类别不能为空";
+            result = false;
+        }
+        if (alertrule.getCategory().equals("1")) {
+            if (StringUtils.isBlank(alertrule.getModelId())) {
+                msg = "风机型号不能为空";
+                result = false;
+            }
+        }
+
+        if (result) {
+            return AjaxResult.successData(AjaxStatus.success.code, result);
+        } else {
+            return AjaxResult.successData(AjaxStatus.error.code, result);
+        }
+    }
+
+    //@UserLoginToken
+    @PostMapping(value = "/save-batch")
+    @ResponseBody
+    public AjaxResult saveAlertruleBatch(HttpServletRequest request,@RequestBody List<ProEconAlarmRule> lst) throws Exception {
+
+
+        boolean allCheck = true;
+
+        for (ProEconAlarmRule alertrule : lst) {
+            String msg = "";
+            boolean result = true;
+            if (StringUtils.isBlank(alertrule.getName())) {
+                msg = "报警名称不能为空";
+                result = false;
+            } else if (StringUtils.isBlank(alertrule.getDescription())) {
+                msg = "规则描述不能为空";
+                result = false;
+            } else if (StringUtils.isBlank(alertrule.getExpression())) {
+                msg = "报警规则不能为空";
+                result = false;
+            } else if (StringUtils.empty(alertrule.getRank())) {
+                msg = "报警级别不能为空";
+                result = false;
+            }
+            else if (StringUtils.isBlank(alertrule.getStationId())) {
+                msg = "风场不能为空";
+                result = false;
+            } else if (StringUtils.isBlank(alertrule.getCategory())) {
+                msg = "报警类别不能为空";
+                result = false;
+            }
+            if (alertrule.getCategory().equals("1")) {
+                if (StringUtils.isBlank(alertrule.getModelId())) {
+                    msg = "风机型号不能为空";
+                    result = false;
+                }
+            }
+            if ( result!= true) {
+                allCheck = false;
+                if (!result) {
+                    return AjaxResult.successData(AjaxStatus.error.code, msg);
+                }
+            }
+        }
+        if (allCheck) {
+            for (ProEconAlarmRule alertRule : lst) {
+                int result = alarmRuleService.saveAndUpdateAlertrule(alertRule);
+                if (result <= 0) {
+                    return AjaxResult.successData(AjaxStatus.error.code, alertRule.getName() + ":" + "操作数据库失败");
+
+                }
+            }
+            return AjaxResult.successData(AjaxStatus.success.code, "ok");
+        } else {
+            return AjaxResult.successData(AjaxStatus.success.code, "ok");
+        }
+
+
+    }
+
+
+    @GetMapping("/get-import-template")
+    @ApiOperation(value = "获得导入模板")
+    public void importTemplate(HttpServletResponse response) throws IOException {
+        // 手动创建导出 demo
+        Date current = com.gyee.common.util.DateUtils.getCurrentDate();
+        Calendar calendar = Calendar.getInstance();
+        calendar.setTime(current);
+        calendar.add(Calendar.DAY_OF_MONTH, -1);
+        Date previousDay = calendar.getTime();
+
+        List<ProEconAlarmRule> list = Arrays.asList(
+                ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度1温度传感器异常值").description("温度等于850度或者温度小于零下40度")
+                        .expression("AI242 == 850 || AI242 <-40").tag("").rank(4).modelId("TZ-2000")
+                        .category("1").range("0")
+                        .stationId("ZK_FDC").projectId("ZK_FDC").lineId("ZK_FDC").deviceId("ZK_FDC")
+                        .electricalId("").relatedParts("BJ").createTime(DateUtils.truncate(previousDay))
+                        .enable(true)
+                        .build(),
+
+                ProEconAlarmRule.builder().id("").name("单机变桨电池柜温度2超限报警").description("温度等于850度或者温度小于零下40度")
+                        .expression("(AI243>=65 || AI243<-10)").tag("").rank(4).modelId("TZ-2000")
+                        .category("1").range("0")
+                        .stationId("ZK_FDC").projectId("ZK_FDC").lineId("ZK_FDC").deviceId("ZK_FDC")
+                        .electricalId("").relatedParts("BJ").createTime(DateUtils.truncate(previousDay))
+                        .enable(true)
+                        .build()
+
+        );
+
+        // 输出
+        ExcelUtils.write(response, "导入模板.xls", "导入模板", ProEconAlarmRule.class, list);
+    }
+
+    @PostMapping("/import")
+    @ApiOperation(value = "导入",notes = "导入")
+    public AjaxResult importExcel(@RequestParam("file") MultipartFile file) throws Exception {
+        List<ProEconAlarmRule> list = ExcelUtils.read(file, ProEconAlarmRule.class);
+
+        if(com.gyee.common.model.StringUtils.notEmp(list) && !list.isEmpty())
+        {
+            boolean allCheck = true;
+            for(ProEconAlarmRule alertrule:list)
+            {
+                String msg = "";
+                boolean result = true;
+                if (StringUtils.isBlank(alertrule.getName())) {
+                    msg = "报警名称不能为空";
+                    result = false;
+                } else if (StringUtils.isBlank(alertrule.getDescription())) {
+                    msg = "规则描述不能为空";
+                    result = false;
+                } else if (StringUtils.isBlank(alertrule.getExpression())) {
+                    msg = "报警规则不能为空";
+                    result = false;
+                } else if (StringUtils.empty(alertrule.getRank())) {
+                    msg = "报警级别不能为空";
+                    result = false;
+                }
+                else if (StringUtils.isBlank(alertrule.getStationId())) {
+                    msg = "风场不能为空";
+                    result = false;
+                } else if (StringUtils.isBlank(alertrule.getCategory())) {
+                    msg = "报警类别不能为空";
+                    result = false;
+                }
+                if (alertrule.getCategory().equals("1")) {
+                    if (StringUtils.isBlank(alertrule.getModelId())) {
+                        msg = "风机型号不能为空";
+                        result = false;
+                    }
+                }
+                if ( result!= true) {
+                    allCheck = false;
+                    if (!result) {
+                        return AjaxResult.successData(AjaxStatus.error.code, msg);
+                    }
+                }
+
+                if(allCheck)
+                {
+                    alertrule.setId(String.valueOf(SnowflakeGenerator.generateId()));
+                    alertrule.setCreateTime(new Date());
+
+                    alarmRuleService.saveAndUpdateAlertrule(alertrule);
+                }
+
+            }
+        }
+        if (com.gyee.common.model.StringUtils.isNotNull(list)) {
+            return AjaxResult.successData(AjaxStatus.success.code, list);
+        } else {
+            return AjaxResult.successData(AjaxStatus.error.code, "ok");
+        }
+
+
+    }
+}

+ 20 - 0
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmRuleController.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 自定义报警配置 前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@RestController
+@RequestMapping("//pro-econ-alarm-rule")
+public class ProEconAlarmRuleController {
+
+}

+ 20 - 0
alarm-web/src/main/java/com/gyee/alarm/controller/ProEconAlarmTypeController.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.controller;
+
+
+import org.springframework.web.bind.annotation.RequestMapping;
+
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * <p>
+ * 自定义类型 前端控制器
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@RestController
+@RequestMapping("//pro-econ-alarm-type")
+public class ProEconAlarmTypeController {
+
+}

+ 109 - 1
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmRuleMapper.java

@@ -1,7 +1,16 @@
 package com.gyee.alarm.mapper.auto;
 
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.gyee.alarm.model.auto.ProEconAlarmRule;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.gyee.alarm.model.vo.AlarmRuleVo;
+import com.gyee.common.model.Alertrule2;
+import org.apache.ibatis.annotations.Param;
+import org.apache.ibatis.annotations.Select;
+import org.apache.ibatis.annotations.Update;
+
+import java.util.List;
 
 /**
  * <p>
@@ -9,8 +18,107 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper;
  * </p>
  *
  * @author shilin
- * @since 2023-06-27
+ * @since 2023-08-09
  */
 public interface ProEconAlarmRuleMapper extends BaseMapper<ProEconAlarmRule> {
 
+
+    @Update({"<script>",
+            "update pro_econ_alarm_rule a",
+            "<set>",
+            "<if test='name != null'>a.name = #{name},</if>",
+            "<if test='description != null'>a.description = #{description},</if>",
+            "<if test='expression != null'>a.expression = #{expression},</if>",
+            "<if test='tag != null'>a.tag = #{tag},</if>",
+            "<if test='rank != null'>a.rank = #{rank},</if>",
+            "<if test='enable != null'>a.enable = #{enable},</if>",
+            "<if test='modelId != null'>a.model_id = #{modelId},</if>",
+            "<if test='category != null'>a.category = #{category},</if>",
+            "<if test='range != null'>a.range = #{range},</if>",
+            "<if test='stationId != null'>a.station_id = #{stationId},</if>",
+            "<if test='deviceId != null'>a.device_id = #{deviceId},</if>",
+            "<if test='lineId != null'>a.line_id = #{lineId},</if>",
+            "<if test='projectId != null'>a.project_id = #{projectId},</if>",
+            "<if test='electricalId != null'>a.electrical_id = #{electricalId},</if>",
+            "<if test='relatedParts != null'>a.related_parts = #{relatedParts},</if>",
+            "<if test='createtime != null'>a.create_time = #{createtime}</if>",
+            "</set>",
+            "where a.id = #{id}",
+
+            "</script>"})
+    Integer updateByAlertruleId(@Param("alertrule") ProEconAlarmRule alertrule);
+
+    @Select({"<script>",
+            "select a.* from pro_econ_alarm_rule a",
+            "<where>",
+            "a.station like '%${station}%'",
+
+            "<if test='name !=null and name !='''>",
+            "and a.name like '%${name}%'",
+            "</if>",
+            "<if test='modelId !=null and modelId !='''>",
+            "and a.model_id like '%${modelId}%'",
+            "</if>",
+            "<if test='rank !=null and rank !='''>",
+            "and a.rank = #{rank}",
+            "</if>",
+            "<if test='category !=null and category !='''>",
+            "and a.category = #{category}",
+            "</if>",
+            "<if test='enabled !=null and enabled !='''>",
+            "and a.enable = #{enable}",
+            "</if>",
+            "<if test='relatedparts !=null and relatedparts !='''>",
+            "and a.related_parts = #{relatedparts}",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+    IPage<ProEconAlarmRule> pageQueryAll(Page page,
+                                   @Param("name") String name,
+                                   @Param("station") String station,
+                                   @Param("modelId")String modelId,
+                                   @Param("rank")String rank,
+                                   @Param("category")String category,
+                                   @Param("enable") String enable,
+                                   @Param("relatedparts")String relatedparts);
+
+    @Select("select distinct a.related_parts as relatedParts,a.name as alarmName,d.name  as typeName from pro_econ_alarm_rule a"+
+            "left join pro_econ_alarm_type d on d.nem_code = a.related_parts"+
+            "where related_parts is not null")
+    List<AlarmRuleVo> queryTree();
+
+    @Select(" select a.name from  pro_econ_alarm_rule a where a.related_parts = #{relatedParts}   group by a.name ")
+    List<ProEconAlarmRule> quertByrelatedParts(@Param("relatedParts") String relatedParts);
+    @Select({"<script>",
+            "select a.* from pro_econ_alarm_rule a",
+            "<where>",
+            "a.station like '%${station}%'",
+            "<if test='modelId !=null and modelId !='''>",
+            "and a.model_id like '%${modelId}%'",
+            "</if>",
+
+            "</where>",
+
+            "</script>"})
+    List<ProEconAlarmRule> getAllByStationIdAndModelId(@Param("station") String station,
+                                                       @Param("modelId") String modelId
+    );
+
+
+    @Select({"<script>",
+            "select a.* from pro_econ_alarm_rule a",
+            "<where>",
+            "a.station like '%${station}%'",
+
+            "<if test='name !=null and name !='''>",
+            "and a.name like '%${name}%'",
+            "</if>",
+            "<if test='modelid !=null and modelid !='''>",
+            "and a.model_id like '%${modelid}%'",
+            "</if>",
+            "</where>",
+
+            "</script>"})
+     List<ProEconAlarmRule> getUniformCodeByNameAndStation(@Param("name")String name, @Param("station")String station, @Param("modelid")String modelid);
 }

+ 16 - 0
alarm-web/src/main/java/com/gyee/alarm/mapper/auto/ProEconAlarmTypeMapper.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.mapper.auto;
+
+import com.gyee.alarm.model.auto.ProEconAlarmType;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * <p>
+ * 自定义类型 Mapper 接口
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface ProEconAlarmTypeMapper extends BaseMapper<ProEconAlarmType> {
+
+}

+ 38 - 9
alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmRule.java

@@ -1,8 +1,12 @@
 package com.gyee.alarm.model.auto;
 
+import com.alibaba.excel.annotation.ExcelProperty;
 import com.baomidou.mybatisplus.extension.activerecord.Model;
-import lombok.Data;
-import lombok.EqualsAndHashCode;
+import java.time.LocalDateTime;
+import java.util.Date;
+
+import lombok.*;
+import lombok.experimental.Accessors;
 
 /**
  * <p>
@@ -10,10 +14,14 @@ import lombok.EqualsAndHashCode;
  * </p>
  *
  * @author shilin
- * @since 2023-06-27
+ * @since 2023-08-09
  */
 @Data
 @EqualsAndHashCode(callSuper = true)
+@Builder
+@AllArgsConstructor
+@NoArgsConstructor
+@Accessors(chain = false) // 设置 chain = false,避免用户导入有问题
 public class ProEconAlarmRule extends Model {
 
     private static final long serialVersionUID = 1L;
@@ -21,83 +29,104 @@ public class ProEconAlarmRule extends Model {
     /**
      * 编号
      */
+    @ExcelProperty("编号")
     private String id;
 
     /**
      * 自定义报警名称
      */
+    @ExcelProperty("自定义报警名称")
     private String name;
 
     /**
      * 报警描述
      */
+    @ExcelProperty("报警描述")
     private String description;
 
     /**
      * 公式
      */
+    @ExcelProperty("公式")
     private String expression;
 
     /**
      * 标签
      */
+    @ExcelProperty("标签")
     private String tag;
 
     /**
      * 报警级别
      */
+    @ExcelProperty("报警级别")
     private Integer rank;
 
     /**
-     * 是否启用
-     */
-    private Boolean enable;
-
-    /**
      * 机型
      */
+    @ExcelProperty("机型")
     private String modelId;
 
     /**
      * 报警类别
      */
+    @ExcelProperty("报警类别")
     private String category;
 
     /**
      * 范围
      */
+    @ExcelProperty("范围")
     private String range;
 
     /**
      * 场站ID
      */
+    @ExcelProperty("场站ID")
     private String stationId;
 
     /**
      * 项目ID
      */
+    @ExcelProperty("项目ID")
     private String projectId;
 
     /**
      * 线路ID
      */
+    @ExcelProperty("线路ID")
     private String lineId;
 
     /**
      * 设备ID
      */
+    @ExcelProperty("设备ID")
     private String deviceId;
 
     /**
      * 电气ID
      */
+    @ExcelProperty("电气ID")
     private String electricalId;
 
-
     /**
      * 关联部件
      */
+    @ExcelProperty("关联部件")
     private String relatedParts;
 
+    /**
+     * 创建时间
+     */
+    @ExcelProperty("创建时间")
+    private Date createTime;
+
+    /**
+     * 是否启用
+     */
+    @ExcelProperty("是否启用")
+    private Boolean enable;
+
 
 }

+ 52 - 0
alarm-web/src/main/java/com/gyee/alarm/model/auto/ProEconAlarmType.java

@@ -0,0 +1,52 @@
+package com.gyee.alarm.model.auto;
+
+import com.baomidou.mybatisplus.extension.activerecord.Model;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+
+/**
+ * <p>
+ * 自定义类型
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Data
+@EqualsAndHashCode(callSuper = true)
+public class ProEconAlarmType extends Model {
+
+    private static final long serialVersionUID = 1L;
+
+    /**
+     * 编号
+     */
+    private String id;
+
+    /**
+     * 报警类别
+     */
+    private String category;
+
+    /**
+     * 编码
+     */
+    private String nemCode;
+
+    /**
+     * 类型名称
+     */
+    private String name;
+
+    /**
+     * 范围
+     */
+    private Integer orderNumber;
+
+    /**
+     * 是否启用
+     */
+    private Integer enable;
+
+
+}

+ 2 - 0
alarm-web/src/main/java/com/gyee/alarm/model/vo/AjaxResult.java

@@ -101,4 +101,6 @@ public class AjaxResult extends HashMap<String, Object>
         super.put(key, value);
         return this;
     }
+
+
 }

+ 24 - 0
alarm-web/src/main/java/com/gyee/alarm/model/vo/AlarmRuleVo.java

@@ -0,0 +1,24 @@
+package com.gyee.alarm.model.vo;
+
+import lombok.Data;
+
+@Data
+public class AlarmRuleVo {
+
+    /**
+     * 关联部件编码
+     */
+    private String relatedParts;
+
+    /**
+     * 报警名称
+     */
+    private String alarmName;
+
+    /**
+     * 部件名称
+     */
+    private String typeName;
+
+
+}

+ 180 - 0
alarm-web/src/main/java/com/gyee/alarm/service/AlarmRuleService.java

@@ -0,0 +1,180 @@
+package com.gyee.alarm.service;
+
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.gyee.alarm.mapper.auto.AlarmTsMapper;
+import com.gyee.alarm.mapper.auto.ProEconAlarmRuleMapper;
+import com.gyee.alarm.model.auto.ProEconAlarmRule;
+
+
+import com.gyee.alarm.model.auto.ProEconAlarmType;
+import com.gyee.alarm.model.auto.ProEconCurveFittingMain;
+import com.gyee.alarm.model.vo.AlarmRuleVo;
+import com.gyee.alarm.service.auto.IProEconAlarmTypeService;
+import com.gyee.alarm.util.SnowflakeGenerator;
+import com.gyee.alarm.util.StringUtil;
+import com.gyee.alarm.util.StringUtils;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.util.*;
+import java.util.stream.Collectors;
+
+
+@Service
+public class AlarmRuleService {
+
+    @Resource
+    private ProEconAlarmRuleMapper proEconAlarmRuleMapper;
+    @Resource
+    private IProEconAlarmTypeService proEconAlarmTypeService;
+
+
+    private int saveAlertrule(ProEconAlarmRule alarmRule) throws Exception {
+
+        int result = 0;
+
+        if (StringUtils.notEmp(alarmRule)) {
+
+            alarmRule.setCreateTime(new Date());
+            alarmRule.setId(String.valueOf(SnowflakeGenerator.generateId()));
+            result= proEconAlarmRuleMapper.insert(alarmRule);
+        }
+//        if (result > 0) {
+//            int i = eventService.saveEventAlertRule(alarmRule, oldRule2, userData.getUserName());
+        return result;
+    }
+
+
+    public int saveAndUpdateAlertrule(ProEconAlarmRule alarmRule) throws Exception {
+
+        int result = 0;
+
+        if (StringUtils.notEmp(alarmRule)) {
+
+            if (StringUtils.notEmp(alarmRule.getId())) {
+
+                ProEconAlarmRule  oldRule2 = proEconAlarmRuleMapper.selectById(alarmRule.getId());
+                if (oldRule2 != null) {
+                    result = proEconAlarmRuleMapper.updateByAlertruleId(alarmRule);
+                }else
+                {
+                    result = saveAlertrule(alarmRule);
+                }
+            }
+            else
+            {
+                result =  saveAlertrule(alarmRule);
+            }
+
+        }
+
+        return result;
+    }
+
+    public int deleteAlertrule(ProEconAlarmRule alarmRule) {
+        return proEconAlarmRuleMapper.deleteById(alarmRule.getId());
+    }
+
+
+    public IPage<ProEconAlarmRule> pageQueryAll(Page page, String name, String station, String modelId, String rank, String category, String enabled, String relatedparts) {
+        IPage<ProEconAlarmRule> AlertruleIPage = proEconAlarmRuleMapper.pageQueryAll(page, name, station, modelId, rank, category, enabled, relatedparts);
+
+        return AlertruleIPage;
+    }
+
+
+    public List<AlarmRuleVo> queryTree() {
+        List<AlarmRuleVo> dsList = proEconAlarmRuleMapper.queryTree();
+        return dsList;
+    }
+
+
+
+    //首页风机部件查询
+    public Map<String, Integer> queryList(String station, String modelId) {
+        Map<String, Integer> map2 = new HashMap<>();
+        map2.put("CLX", 0);
+        map2.put("YP", 0);
+        map2.put("YY", 0);
+        map2.put("BJXT", 0);
+        map2.put("PHXT", 0);
+        map2.put("BPXT", 0);
+        map2.put("CFXT", 0);
+        map2.put("ZZ", 0);
+        map2.put("FDJ", 0);
+        map2.put("QT", 0);
+
+        List<ProEconAlarmRule> dslist = proEconAlarmRuleMapper.getAllByStationIdAndModelId(station, modelId);
+        map2.put("SUM", dslist.size());
+        for (ProEconAlarmRule ar : dslist) {
+            int cnt = 0;
+            switch (ar.getRelatedParts()) {
+                case "CLX":
+                    cnt = map2.get("CLX").intValue();
+                    map2.put("CLX", ++cnt);
+                    break;
+                case "YP":
+                    cnt = map2.get("YP").intValue();
+                    map2.put("YP", ++cnt);
+                    break;
+                case "YY":
+                    cnt = map2.get("YY").intValue();
+                    map2.put("YY", ++cnt);
+                    break;
+                case "BJXT":
+                    cnt = map2.get("BJXT").intValue();
+                    map2.put("BJXT", ++cnt);
+                    break;
+                case "PHXT":
+                    cnt = map2.get("PHXT").intValue();
+                    map2.put("PHXT", ++cnt);
+                    break;
+                case "BPXT":
+                    cnt = map2.get("BPXT").intValue();
+                    map2.put("BPXT", ++cnt);
+                    break;
+                case "CFXT":
+                    cnt = map2.get("CFXT").intValue();
+                    map2.put("CFXT", ++cnt);
+                    break;
+                case "ZZ":
+                    cnt = map2.get("ZZ").intValue();
+                    map2.put("ZZ", ++cnt);
+                    break;
+                case "FDJ":
+                    cnt = map2.get("FDJ").intValue();
+                    map2.put("FDJ", ++cnt);
+                    break;
+                default:
+                    cnt = map2.get("QT").intValue();
+                    map2.put("QT", ++cnt);
+                    break;
+            }
+        }
+        return map2;
+    }
+
+
+
+
+    public List<String> getUniformCodeByNameAndStation(String name, String station, String modelid) {
+
+        List<ProEconAlarmRule> rules = proEconAlarmRuleMapper.getUniformCodeByNameAndStation(name, station, modelid);
+        if (rules == null || rules.size() == 0)
+            return null;
+
+        ProEconAlarmRule rule = rules.get(0);
+        String expression = "(([A][I])|([D][I]))([0-9]+)";
+        List<String> list = StringUtil.pattern(rule.getExpression(), expression);
+
+        return list;
+    }
+
+    public ProEconAlarmRule selectByAlertruleId(String id) {
+        return proEconAlarmRuleMapper.selectById(id);
+    }
+
+}

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmRuleService.java

@@ -9,7 +9,7 @@ import com.baomidou.mybatisplus.extension.service.IService;
  * </p>
  *
  * @author shilin
- * @since 2023-06-27
+ * @since 2023-08-09
  */
 public interface IProEconAlarmRuleService extends IService<ProEconAlarmRule> {
 

+ 16 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/IProEconAlarmTypeService.java

@@ -0,0 +1,16 @@
+package com.gyee.alarm.service.auto;
+
+import com.gyee.alarm.model.auto.ProEconAlarmType;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * <p>
+ * 自定义类型 服务类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+public interface IProEconAlarmTypeService extends IService<ProEconAlarmType> {
+
+}

+ 1 - 1
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmRuleServiceImpl.java

@@ -12,7 +12,7 @@ import org.springframework.stereotype.Service;
  * </p>
  *
  * @author shilin
- * @since 2023-06-27
+ * @since 2023-08-09
  */
 @Service
 public class ProEconAlarmRuleServiceImpl extends ServiceImpl<ProEconAlarmRuleMapper, ProEconAlarmRule> implements IProEconAlarmRuleService {

+ 20 - 0
alarm-web/src/main/java/com/gyee/alarm/service/auto/impl/ProEconAlarmTypeServiceImpl.java

@@ -0,0 +1,20 @@
+package com.gyee.alarm.service.auto.impl;
+
+import com.gyee.alarm.model.auto.ProEconAlarmType;
+import com.gyee.alarm.mapper.auto.ProEconAlarmTypeMapper;
+import com.gyee.alarm.service.auto.IProEconAlarmTypeService;
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springframework.stereotype.Service;
+
+/**
+ * <p>
+ * 自定义类型 服务实现类
+ * </p>
+ *
+ * @author shilin
+ * @since 2023-08-09
+ */
+@Service
+public class ProEconAlarmTypeServiceImpl extends ServiceImpl<ProEconAlarmTypeMapper, ProEconAlarmType> implements IProEconAlarmTypeService {
+
+}

+ 48 - 0
alarm-web/src/main/java/com/gyee/alarm/util/ExcelUtils.java

@@ -0,0 +1,48 @@
+package com.gyee.alarm.util;
+
+import com.alibaba.excel.EasyExcel;
+import com.alibaba.excel.write.style.column.LongestMatchColumnWidthStyleStrategy;
+import org.springframework.web.multipart.MultipartFile;
+
+import javax.servlet.http.HttpServletResponse;
+import java.io.IOException;
+import java.net.URLEncoder;
+import java.util.List;
+
+/**
+ * Excel 工具类
+ *
+ * @author 芋道源码
+ */
+public class ExcelUtils {
+
+    /**
+     * 将列表以 Excel 响应给前端
+     *
+     * @param response 响应
+     * @param filename 文件名
+     * @param sheetName Excel sheet 名
+     * @param head Excel head 头
+     * @param data 数据列表哦
+     * @param <T> 泛型,保证 head 和 data 类型的一致性
+     * @throws IOException 写入失败的情况
+     */
+    public static <T> void write(HttpServletResponse response, String filename, String sheetName,
+                                 Class<T> head, List<T> data) throws IOException {
+        // 输出 Excel
+        EasyExcel.write(response.getOutputStream(), head)
+                .autoCloseStream(false) // 不要自动关闭,交给 Servlet 自己处理
+                .registerWriteHandler(new LongestMatchColumnWidthStyleStrategy()) // 基于 column 长度,自动适配。最大 255 宽度
+                .sheet(sheetName).doWrite(data);
+        // 设置 header 和 contentType。写在最后的原因是,避免报错时,响应 contentType 已经被修改了
+        response.addHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename, "UTF-8"));
+        response.setContentType("application/vnd.ms-excel;charset=UTF-8");
+    }
+
+    public static <T> List<T> read(MultipartFile file, Class<T> head) throws IOException {
+       return EasyExcel.read(file.getInputStream(), head, null)
+                .autoCloseStream(false)  // 不要自动关闭,交给 Servlet 自己处理
+                .doReadAllSync();
+    }
+
+}

+ 530 - 0
alarm-web/src/main/java/com/gyee/alarm/util/StringUtil.java

@@ -0,0 +1,530 @@
+package com.gyee.alarm.util;
+
+
+
+import java.math.BigDecimal;
+import java.math.RoundingMode;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.regex.Matcher;
+import java.util.regex.Pattern;
+
+
+/**
+ * 字符串工具类
+ * 
+ * @author fc
+ */
+public class StringUtil extends org.apache.commons.lang3.StringUtils
+{
+    /** 空字符串 */
+    private static final String NULLSTR = "";
+
+    /** 下划线 */
+    private static final char SEPARATOR = '_';
+
+    /**
+     * 获取参数不为空值
+     * 
+     * @param value defaultValue 要判断的value
+     * @return value 返回值
+     */
+    public static <T> T nvl(T value, T defaultValue)
+    {
+        return value != null ? value : defaultValue;
+    }
+
+    /**
+     * * 判断一个Collection是否为空, 包含List,Set,Queue
+     * 
+     * @param coll 要判断的Collection
+     * @return true:为空 false:非空
+     */
+    public static boolean isEmpty(Collection<?> coll)
+    {
+        return isNull(coll) || coll.isEmpty();
+    }
+
+    /**
+     * * 判断一个Collection是否非空,包含List,Set,Queue
+     * 
+     * @param coll 要判断的Collection
+     * @return true:非空 false:空
+     */
+    public static boolean isNotEmpty(Collection<?> coll)
+    {
+        return !isEmpty(coll);
+    }
+    public static int roundToInt(double num) {
+
+        return new BigDecimal(num).setScale(0, RoundingMode.HALF_UP).intValue();
+    }
+    /**
+     * * 判断一个对象数组是否为空
+     * 
+     * @param objects 要判断的对象数组
+     ** @return true:为空 false:非空
+     */
+    public static boolean isEmpty(Object[] objects)
+    {
+        return isNull(objects) || (objects.length == 0);
+    }
+
+    /**
+     * * 判断一个对象数组是否非空
+     * 
+     * @param objects 要判断的对象数组
+     * @return true:非空 false:空
+     */
+    public static boolean isNotEmpty(Object[] objects)
+    {
+        return !isEmpty(objects);
+    }
+
+    /**
+     * * 判断一个Map是否为空
+     * 
+     * @param map 要判断的Map
+     * @return true:为空 false:非空
+     */
+    public static boolean isEmpty(Map<?, ?> map)
+    {
+        return isNull(map) || map.isEmpty();
+    }
+
+    /**
+     * * 判断一个Map是否为空
+     * 
+     * @param map 要判断的Map
+     * @return true:非空 false:空
+     */
+    public static boolean isNotEmpty(Map<?, ?> map)
+    {
+        return !isEmpty(map);
+    }
+
+    /**
+     * * 判断一个字符串是否为空串
+     * 
+     * @param str String
+     * @return true:为空 false:非空
+     */
+    public static boolean isEmpty(String str)
+    {
+        return isNull(str) || NULLSTR.equals(str.trim());
+    }
+
+    /**
+     * * 判断一个字符串是否为非空串
+     * 
+     * @param str String
+     * @return true:非空串 false:空串
+     */
+    public static boolean isNotEmpty(String str)
+    {
+        return !isEmpty(str);
+    }
+
+    /**
+     * * 判断一个对象是否为空
+     * 
+     * @param object Object
+     * @return true:为空 false:非空
+     */
+    public static boolean isNull(Object object)
+    {
+        return object == null;
+    }
+
+    /**
+     * * 判断一个对象是否非空
+     * 
+     * @param object Object
+     * @return true:非空 false:空
+     */
+    public static boolean isNotNull(Object object)
+    {
+        return !isNull(object);
+    }
+
+    /**
+     * * 判断一个对象是否是数组类型(Java基本型别的数组)
+     * 
+     * @param object 对象
+     * @return true:是数组 false:不是数组
+     */
+    public static boolean isArray(Object object)
+    {
+        return isNotNull(object) && object.getClass().isArray();
+    }
+
+    /**
+     * 去空格
+     */
+    public static String trim(String str)
+    {
+        return (str == null ? "" : str.trim());
+    }
+
+    /**
+     * 截取字符串
+     * 
+     * @param str 字符串
+     * @param start 开始
+     * @return 结果
+     */
+    public static String substring(final String str, int start)
+    {
+        if (str == null)
+        {
+            return NULLSTR;
+        }
+
+        if (start < 0)
+        {
+            start = str.length() + start;
+        }
+
+        if (start < 0)
+        {
+            start = 0;
+        }
+        if (start > str.length())
+        {
+            return NULLSTR;
+        }
+
+        return str.substring(start);
+    }
+
+    /**
+     * 截取字符串
+     * 
+     * @param str 字符串
+     * @param start 开始
+     * @param end 结束
+     * @return 结果
+     */
+    public static String substring(final String str, int start, int end)
+    {
+        if (str == null)
+        {
+            return NULLSTR;
+        }
+
+        if (end < 0)
+        {
+            end = str.length() + end;
+        }
+        if (start < 0)
+        {
+            start = str.length() + start;
+        }
+
+        if (end > str.length())
+        {
+            end = str.length();
+        }
+
+        if (start > end)
+        {
+            return NULLSTR;
+        }
+
+        if (start < 0)
+        {
+            start = 0;
+        }
+        if (end < 0)
+        {
+            end = 0;
+        }
+
+        return str.substring(start, end);
+    }
+
+
+
+
+    /**
+     * 驼峰命名转下划线 nameVc>>name_vc
+     */
+    public static String toUnderScoreCase(String s)
+    {
+        if (s == null)
+        {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder();
+        boolean upperCase = false;
+        for (int i = 0; i < s.length(); i++)
+        {
+            char c = s.charAt(i);
+
+            boolean nextUpperCase = true;
+
+            if (i < (s.length() - 1))
+            {
+                nextUpperCase = Character.isUpperCase(s.charAt(i + 1));
+            }
+
+            if ((i > 0) && Character.isUpperCase(c))
+            {
+                if (!upperCase || !nextUpperCase)
+                {
+                    sb.append(SEPARATOR);
+                }
+                upperCase = true;
+            }
+            else
+            {
+                upperCase = false;
+            }
+
+            sb.append(Character.toLowerCase(c));
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * 是否包含字符串
+     * 
+     * @param str 验证字符串
+     * @param strs 字符串组
+     * @return 包含返回true
+     */
+    public static boolean inStringIgnoreCase(String str, String... strs)
+    {
+        if (str != null && strs != null)
+        {
+            for (String s : strs)
+            {
+                if (str.equalsIgnoreCase(trim(s)))
+                {
+                    return true;
+                }
+            }
+        }
+        return false;
+    }
+   
+    
+    /**
+     * 将下划线大写方式命名的字符串转换为驼峰式。如果转换前的下划线大写方式命名的字符串为空,则返回空字符串。 例如:HELLO_WORLD->HelloWorld
+     * 
+     * @param name 转换前的下划线大写方式命名的字符串
+     * @return 转换后的驼峰式命名的字符串
+     */
+    public static String convertToCamelCase(String name)
+    {
+        StringBuilder result = new StringBuilder();
+        // 快速检查
+        if (name == null || name.isEmpty())
+        {
+            // 没必要转换
+            return "";
+        }
+        else if (!name.contains("_"))
+        {
+            // 不含下划线,仅将首字母大写
+            return name.substring(0, 1).toUpperCase() + name.substring(1);
+        }
+        // 用下划线将原始字符串分割
+        String[] camels = name.split("_");
+        for (String camel : camels)
+        {
+            // 跳过原始字符串中开头、结尾的下换线或双重下划线
+            if (camel.isEmpty())
+            {
+                continue;
+            }
+            // 首字母大写
+            result.append(camel.substring(0, 1).toUpperCase());
+            result.append(camel.substring(1).toLowerCase());
+        }
+        return result.toString();
+    }
+    /**
+     * 首字母大写
+     *
+     * @param name
+     * @return
+     */
+    public static String firstUpperCase(String name) {
+        name = name.substring(0, 1).toUpperCase() + name.substring(1);
+        return name;
+    }
+    /**
+     * 首字母小写
+     *
+     * @param name
+     * @return
+     */
+    public static String firstLowerCase(String name) {
+        name = name.substring(0, 1).toLowerCase() + name.substring(1);
+        return name;
+
+    }
+    
+    /**
+     * 将下划线转化为大写
+     *
+     * @param name
+     * @param firstCase 首字母是否大写 true:大写 false;小写
+     * @return
+     */
+    public static String upperCase_(String name, boolean firstCase) {
+        if(isEmpty(name)){
+            return "";
+        }
+        String[] s = name.split("_");
+        StringBuffer stringBuffer = new StringBuffer();
+        for (String s1 : s) {
+            stringBuffer.append(s1.substring(0, 1).toUpperCase() + s1.substring(1));
+        }
+        if(!firstCase){
+            return firstLowerCase(stringBuffer.toString());
+        }
+        return stringBuffer.toString();
+    }
+    
+    /**
+     * get方法名字转成 t_b_abc>>tBAbc
+     * @param str
+     * @return
+     * @author gyee
+     * @Date 2020年1月30日 下午11:55:54
+     */
+    public static String toFUNName(String str) {
+    	StringBuffer buffer=new StringBuffer();
+    	String name=str;
+    	if(name.contains("_")) {
+    		// 用下划线将原始字符串分割
+            String[] camels = name.split("_");
+            boolean b=true;
+            
+            for (String str1 : camels) {
+            	if(str1.length()==1&&b) {
+            		b=false;
+            		buffer.append(str1);
+            	}else {
+            		buffer.append(StringUtil.firstUpperCase(str1));
+            	}
+				
+			}
+    	}else {
+    		buffer.append(StringUtil.firstUpperCase(name));
+    	}
+		return buffer.toString();
+    }
+
+
+    /**
+     * 是否不为空串
+     *
+     * @param obj
+     * @return
+     */
+    public static boolean notEmp(Object obj) {
+        return !empty(obj);
+    }
+
+    /**
+     * 是否为空串
+     *
+     * @param obj
+     * @return
+     */
+    public static boolean empty(Object obj) {
+        if (obj == null)
+            return true;
+        String str;
+        if (obj instanceof String) {
+            str = (String) obj;
+        } else {
+            str = obj.toString();
+        }
+        return str.length() == 0;
+    }
+
+    public static double round(double num, int digit) {
+
+        return new BigDecimal(num).setScale(digit, RoundingMode.HALF_UP).doubleValue();
+    }
+    /**
+     * 将字符串解析为Date类型
+     *
+     * @param date
+     * @param pattern
+     * @return
+     */
+    public static Date toDate(String date, String pattern) {
+        SimpleDateFormat format = new SimpleDateFormat(pattern);
+        try {
+            return format.parse(date);
+        } catch (ParseException e) {
+            throw new RuntimeException(String.format("Failed to parse the String [%s] to Date.", date), e);
+        }
+    }
+    /**
+     *
+     * @方法名称: getUUID
+     * @描述: 获得UUID
+     * @参数 @return
+     * @返回值 String
+     * @抛出异常
+     */
+    public static String getUUID() {
+        String s = UUID.randomUUID().toString();
+        // 去掉“-”符号
+        return s.substring(0, 8) + s.substring(9, 13) + s.substring(14, 18) + s.substring(19, 23) + s.substring(24);
+    }
+
+    /**
+     * 判断是否为数字字符串
+     * @param str
+     * @return
+     */
+    public static boolean isNumeric(String str){
+        Pattern pattern = Pattern.compile("^(-?\\d+)(\\.\\d+)?$");
+        if(notEmp(str))
+        {
+            Matcher isNum = pattern.matcher(str);
+            if( !isNum.matches() ){
+                return false;
+            }
+
+        }else
+        {
+            return false;
+        }
+
+        return true;
+    }
+
+
+    /**
+     * 正则表达式
+     * @param input     需要匹配的字符串
+     * @param expression 正则表达公式
+     * @return
+     */
+    public static List<String> pattern(String input, String expression){
+        // 创建 Pattern 对象
+        Pattern p = Pattern.compile(expression);
+        Matcher m = p.matcher(input);
+
+        ArrayList list = new ArrayList();
+        while (m.find()) {
+            list.add(m.group(0));
+        }
+        //去除重复值
+        HashSet hs=new HashSet(list);
+        list.clear();
+        list.addAll(hs);
+
+        return list;
+    }
+}

+ 6 - 3
alarm-web/src/main/resources/application-jn.yml

@@ -167,11 +167,14 @@ frequency:
   powerrationing: 1
   #切入切出
   cutinandout: 1
-
+#线程数量
 task-count: 10
-
+#间隔秒数
 interval: 1
-
+#是否对自定义报警加密
+rule_encryption: true
+#加密key
+rule_encryption_key: gyee-alarm123456
 
 
 

+ 38 - 0
log/ota.log

@@ -36,3 +36,41 @@
 2023-08-09 08:43:10.905  INFO 7284 --- [SpringContextShutdownHook] com.alibaba.druid.pool.DruidDataSource   : {dataSource-2} closed
 2023-08-09 08:43:10.905  INFO 7284 --- [SpringContextShutdownHook] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed
 2023-08-09 08:43:10.905  INFO 7284 --- [SpringContextShutdownHook] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource all closed success,bye
+2023-08-09 08:43:15.588  INFO 6928 --- [main] com.gyee.alarm.AlarmWeb                  : Starting AlarmWeb on sltc with PID 6928 (E:\idea_workspace\alarmNew\alarm-web\target\classes started by shilin in E:\idea_workspace\alarmNew)
+2023-08-09 08:43:15.590  INFO 6928 --- [main] com.gyee.alarm.AlarmWeb                  : The following profiles are active: jn
+2023-08-09 08:43:16.478  INFO 6928 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
+2023-08-09 08:43:16.480  INFO 6928 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
+2023-08-09 08:43:16.537  INFO 6928 --- [main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 48ms. Found 0 Redis repository interfaces.
+2023-08-09 08:43:16.814  INFO 6928 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'spring.datasource.dynamic-com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties' of type [com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceProperties] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
+2023-08-09 08:43:16.819  INFO 6928 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration' of type [com.baomidou.dynamic.datasource.spring.boot.autoconfigure.DynamicDataSourceAutoConfiguration$$EnhancerBySpringCGLIB$$de42143c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
+2023-08-09 08:43:16.833  INFO 6928 --- [main] trationDelegate$BeanPostProcessorChecker : Bean 'dsProcessor' of type [com.baomidou.dynamic.datasource.processor.DsHeaderProcessor] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
+2023-08-09 08:43:17.041  INFO 6928 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 6015 (http)
+2023-08-09 08:43:17.049  INFO 6928 --- [main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
+2023-08-09 08:43:17.050  INFO 6928 --- [main] org.apache.catalina.core.StandardEngine  : Starting Servlet engine: [Apache Tomcat/9.0.29]
+2023-08-09 08:43:17.150  INFO 6928 --- [main] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
+2023-08-09 08:43:17.151  INFO 6928 --- [main] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 1401 ms
+2023-08-09 08:43:17.356  INFO 6928 --- [main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1,master} inited
+2023-08-09 08:43:17.357 ERROR 6928 --- [main] com.alibaba.druid.pool.DruidDataSource   : testWhileIdle is true, validationQuery not set
+2023-08-09 08:43:17.357  INFO 6928 --- [main] com.alibaba.druid.pool.DruidDataSource   : {dataSource-2,slave} inited
+2023-08-09 08:43:17.358  INFO 6928 --- [main] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource - add a datasource named [slave] success
+2023-08-09 08:43:17.358  INFO 6928 --- [main] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource - add a datasource named [master] success
+2023-08-09 08:43:17.358  INFO 6928 --- [main] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource initial loaded [2] datasource,primary datasource named [master]
+2023-08-09 08:43:18.545 ERROR 6928 --- [main] c.b.m.core.MybatisConfiguration          : mapper[com.gyee.alarm.mapper.auto.AlarmTsMapper.createTable] is ignored, because it exists, maybe from xml file
+2023-08-09 08:43:20.876  INFO 6928 --- [main] o.s.s.concurrent.ThreadPoolTaskExecutor  : Initializing ExecutorService 'applicationTaskExecutor'
+2023-08-09 08:43:21.191  INFO 6928 --- [main] o.s.b.a.e.web.EndpointLinksResolver      : Exposing 2 endpoint(s) beneath base path '/actuator'
+2023-08-09 08:43:21.290  INFO 6928 --- [main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat started on port(s): 6015 (http) with context path ''
+2023-08-09 08:43:21.292  INFO 6928 --- [main] com.gyee.alarm.AlarmWeb                  : Started AlarmWeb in 6.005 seconds (JVM running for 7.005)
+2023-08-09 08:43:21.295  INFO 6928 --- [main] com.gyee.alarm.init.CacheContext         : 缓存开始------------------------------------------------------------
+2023-08-09 08:43:21.296  INFO 6928 --- [main] com.gyee.alarm.init.CacheContext         : SXJ_KGDL_NJL_FDC_STA------------------19
+2023-08-09 08:43:22.438  INFO 6928 --- [main] io.lettuce.core.EpollProvider            : Starting without optional epoll library
+2023-08-09 08:43:22.440  INFO 6928 --- [main] io.lettuce.core.KqueueProvider           : Starting without optional kqueue library
+2023-08-09 08:43:23.998  INFO 6928 --- [main] com.gyee.alarm.init.CacheContext         : 3177
+2023-08-09 08:43:49.065  INFO 6928 --- [main] com.gyee.alarm.init.CacheContext         : 缓存结束------------------------------------------------------------
+2023-08-09 08:43:49.354  INFO 6928 --- [RMI TCP Connection(3)-192.168.56.1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring DispatcherServlet 'dispatcherServlet'
+2023-08-09 08:43:49.355  INFO 6928 --- [RMI TCP Connection(3)-192.168.56.1] o.s.web.servlet.DispatcherServlet        : Initializing Servlet 'dispatcherServlet'
+2023-08-09 08:43:49.365  INFO 6928 --- [RMI TCP Connection(3)-192.168.56.1] o.s.web.servlet.DispatcherServlet        : Completed initialization in 10 ms
+2023-08-09 09:30:14.620  INFO 6928 --- [SpringContextShutdownHook] o.s.s.concurrent.ThreadPoolTaskExecutor  : Shutting down ExecutorService 'applicationTaskExecutor'
+2023-08-09 09:30:14.952  INFO 6928 --- [SpringContextShutdownHook] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource start closing ....
+2023-08-09 09:30:14.955  INFO 6928 --- [SpringContextShutdownHook] com.alibaba.druid.pool.DruidDataSource   : {dataSource-2} closed
+2023-08-09 09:30:14.956  INFO 6928 --- [SpringContextShutdownHook] com.alibaba.druid.pool.DruidDataSource   : {dataSource-1} closed
+2023-08-09 09:30:14.956  INFO 6928 --- [SpringContextShutdownHook] c.b.d.d.DynamicRoutingDataSource         : dynamic-datasource all closed success,bye

BIN=BIN
log/ota.log.2023-08-07.0.gz