Explorar o código

峰平谷大屏实时告警01

qiangxuan hai 7 meses
pai
achega
12701ca836

+ 162 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/controller/LeanEventWarnInfoController.java

@@ -0,0 +1,162 @@
+package org.jeecg.modules.homePageData.controller;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.homePageData.entity.LeanEventWarnInfo;
+import org.jeecg.modules.homePageData.service.ILeanEventWarnInfoService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+import java.util.Arrays;
+
+/**
+* @Description: 精益事件告警信息表
+* @Author: jeecg-boot
+* @Date:   2024-10-29
+* @Version: V1.0
+*/
+@Api(tags="精益事件告警信息表")
+@RestController
+@RequestMapping("/leanEventWarn/leanEventWarnInfo")
+@Slf4j
+public class LeanEventWarnInfoController extends JeecgController<LeanEventWarnInfo, ILeanEventWarnInfoService> {
+   @Autowired
+   private ILeanEventWarnInfoService leanEventWarnInfoService;
+
+   /**
+    * 分页列表查询
+    *
+    * @param leanEventWarnInfo
+    * @param pageNo
+    * @param pageSize
+    * @param req
+    * @return
+    */
+   //@AutoLog(value = "精益事件告警信息表-分页列表查询")
+   @ApiOperation(value="精益事件告警信息表-分页列表查询", notes="精益事件告警信息表-分页列表查询")
+   @GetMapping(value = "/list")
+   public Result<IPage<LeanEventWarnInfo>> queryPageList(LeanEventWarnInfo leanEventWarnInfo,
+                                  @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+                                  @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+                                  HttpServletRequest req) {
+       QueryWrapper<LeanEventWarnInfo> queryWrapper = QueryGenerator.initQueryWrapper(leanEventWarnInfo, req.getParameterMap());
+       Page<LeanEventWarnInfo> page = new Page<LeanEventWarnInfo>(pageNo, pageSize);
+       IPage<LeanEventWarnInfo> pageList = leanEventWarnInfoService.page(page, queryWrapper);
+       return Result.OK(pageList);
+   }
+
+   /**
+    *   添加
+    *
+    * @param leanEventWarnInfo
+    * @return
+    */
+   @AutoLog(value = "精益事件告警信息表-添加")
+   @ApiOperation(value="精益事件告警信息表-添加", notes="精益事件告警信息表-添加")
+   @RequiresPermissions("leanEventWarn:lean_event_warn_info:add")
+   @PostMapping(value = "/add")
+   public Result<String> add(@RequestBody LeanEventWarnInfo leanEventWarnInfo) {
+       leanEventWarnInfoService.save(leanEventWarnInfo);
+       return Result.OK("添加成功!");
+   }
+
+   /**
+    *  编辑
+    *
+    * @param leanEventWarnInfo
+    * @return
+    */
+   @AutoLog(value = "精益事件告警信息表-编辑")
+   @ApiOperation(value="精益事件告警信息表-编辑", notes="精益事件告警信息表-编辑")
+   @RequiresPermissions("leanEventWarn:lean_event_warn_info:edit")
+   @RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+   public Result<String> edit(@RequestBody LeanEventWarnInfo leanEventWarnInfo) {
+       leanEventWarnInfoService.updateById(leanEventWarnInfo);
+       return Result.OK("编辑成功!");
+   }
+
+   /**
+    *   通过id删除
+    *
+    * @param id
+    * @return
+    */
+   @AutoLog(value = "精益事件告警信息表-通过id删除")
+   @ApiOperation(value="精益事件告警信息表-通过id删除", notes="精益事件告警信息表-通过id删除")
+   @RequiresPermissions("leanEventWarn:lean_event_warn_info:delete")
+   @DeleteMapping(value = "/delete")
+   public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+       leanEventWarnInfoService.removeById(id);
+       return Result.OK("删除成功!");
+   }
+
+   /**
+    *  批量删除
+    *
+    * @param ids
+    * @return
+    */
+   @AutoLog(value = "精益事件告警信息表-批量删除")
+   @ApiOperation(value="精益事件告警信息表-批量删除", notes="精益事件告警信息表-批量删除")
+   @RequiresPermissions("leanEventWarn:lean_event_warn_info:deleteBatch")
+   @DeleteMapping(value = "/deleteBatch")
+   public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+       this.leanEventWarnInfoService.removeByIds(Arrays.asList(ids.split(",")));
+       return Result.OK("批量删除成功!");
+   }
+
+   /**
+    * 通过id查询
+    *
+    * @param id
+    * @return
+    */
+   //@AutoLog(value = "精益事件告警信息表-通过id查询")
+   @ApiOperation(value="精益事件告警信息表-通过id查询", notes="精益事件告警信息表-通过id查询")
+   @GetMapping(value = "/queryById")
+   public Result<LeanEventWarnInfo> queryById(@RequestParam(name="id",required=true) String id) {
+       LeanEventWarnInfo leanEventWarnInfo = leanEventWarnInfoService.getById(id);
+       if(leanEventWarnInfo==null) {
+           return Result.error("未找到对应数据");
+       }
+       return Result.OK(leanEventWarnInfo);
+   }
+
+   /**
+   * 导出excel
+   *
+   * @param request
+   * @param leanEventWarnInfo
+   */
+   @RequiresPermissions("leanEventWarn:lean_event_warn_info:exportXls")
+   @RequestMapping(value = "/exportXls")
+   public ModelAndView exportXls(HttpServletRequest request, LeanEventWarnInfo leanEventWarnInfo) {
+       return super.exportXls(request, leanEventWarnInfo, LeanEventWarnInfo.class, "精益事件告警信息表");
+   }
+
+   /**
+     * 通过excel导入数据
+   *
+   * @param request
+   * @param response
+   * @return
+   */
+   @RequiresPermissions("leanEventWarn:lean_event_warn_info:importExcel")
+   @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+   public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+       return super.importExcel(request, response, LeanEventWarnInfo.class);
+   }
+
+}

+ 83 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/entity/LeanEventWarnInfo.java

@@ -0,0 +1,83 @@
+package org.jeecg.modules.homePageData.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.io.Serializable;
+import java.util.Date;
+
+/**
+ * @Description: 精益事件告警信息表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-29
+ * @Version: V1.0
+ */
+@Data
+@TableName("lean_event_warn_info")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="lean_event_warn_info对象", description="精益事件告警信息表")
+public class LeanEventWarnInfo implements Serializable {
+    private static final long serialVersionUID = 1L;
+
+	/**主键*/
+	@TableId(type = IdType.ASSIGN_ID)
+    @ApiModelProperty(value = "主键")
+    private String id;
+	/**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+	/**创建日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private Date createTime;
+	/**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+	/**更新日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+	/**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private String sysOrgCode;
+	/**区域ID*/
+	@Excel(name = "区域ID", width = 15)
+    @ApiModelProperty(value = "区域ID")
+    private String deviceRegionId;
+	/**设备ID*/
+	@Excel(name = "设备ID", width = 15)
+    @ApiModelProperty(value = "设备ID")
+    private String deviceInformationId;
+	/**采集点ID*/
+	@Excel(name = "采集点ID", width = 15)
+    @ApiModelProperty(value = "采集点ID")
+    private String devicePointId;
+	/**告警类型*/
+	@Excel(name = "告警类型", width = 15)
+    @ApiModelProperty(value = "告警类型")
+    private String warnType;
+	/**设备预警信息*/
+	@Excel(name = "设备预警信息", width = 15)
+    @ApiModelProperty(value = "设备预警信息")
+    private String deviceWarnInfo;
+	/**设备预警级别(0:重度,1:中度,2:轻度)*/
+	@Excel(name = "设备预警级别(0:重度,1:中度,2:轻度)", width = 15)
+    @ApiModelProperty(value = "设备预警级别(0:重度,1:中度,2:轻度)")
+    private String deviceWarnLevel;
+	/**拓展字段*/
+	@Excel(name = "拓展字段", width = 15)
+    @ApiModelProperty(value = "拓展字段")
+    private String remark;
+}

+ 64 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/entity/LeanEventWarnInfoResult.java

@@ -0,0 +1,64 @@
+package org.jeecg.modules.homePageData.entity;
+
+import com.fasterxml.jackson.annotation.JsonFormat;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+import org.springframework.format.annotation.DateTimeFormat;
+
+import java.util.Date;
+
+/**
+ * @Description: 精益事件告警信息表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-29
+ * @Version: V1.0
+ */
+@Data
+public class LeanEventWarnInfoResult {
+
+    @ApiModelProperty(value = "主键")
+    private String id;
+	/**创建人*/
+    @ApiModelProperty(value = "创建人")
+    private String createBy;
+	/**创建日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建日期")
+    private Date createTime;
+	/**更新人*/
+    @ApiModelProperty(value = "更新人")
+    private String updateBy;
+	/**更新日期*/
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "更新日期")
+    private Date updateTime;
+	/**所属部门*/
+    @ApiModelProperty(value = "所属部门")
+    private String sysOrgCode;
+	/**区域ID*/
+    @ApiModelProperty(value = "区域ID")
+    private String deviceRegionId;
+	/**设备ID*/
+    @ApiModelProperty(value = "设备ID")
+    private String deviceInformationId;
+	/**采集点ID*/
+    @ApiModelProperty(value = "采集点ID")
+    private String devicePointId;
+	/**告警类型*/
+    @ApiModelProperty(value = "告警类型")
+    private String warnType;
+	/**设备预警信息*/
+    @ApiModelProperty(value = "设备预警信息")
+    private String deviceWarnInfo;
+	/**设备预警级别(0:重度,1:中度,2:轻度)*/
+    @ApiModelProperty(value = "设备预警级别(0:重度,1:中度,2:轻度)")
+    private String deviceWarnLevel;
+	/**拓展字段*/
+    @ApiModelProperty(value = "拓展字段")
+    private String remark;
+    /**设备名称*/
+    @ApiModelProperty(value = "设备名称")
+    private String deviceTitle;
+}

+ 17 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/mapper/LeanEventWarnInfoMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.homePageData.mapper;
+
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import org.jeecg.modules.homePageData.entity.LeanEventWarnInfo;
+import org.jeecg.modules.homePageData.entity.LeanEventWarnInfoResult;
+
+import java.util.List;
+
+/**
+ * @Description: 精益事件告警信息表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-29
+ * @Version: V1.0
+ */
+public interface LeanEventWarnInfoMapper extends BaseMapper<LeanEventWarnInfo> {
+    List<LeanEventWarnInfoResult> queryLeanEventWarnInfo();
+}

+ 17 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/mapper/xml/LeanEventWarnInfoMapper.xml

@@ -0,0 +1,17 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.jeecg.modules.homePageData.mapper.LeanEventWarnInfoMapper">
+
+    <select id="queryLeanEventWarnInfo"
+            resultType="org.jeecg.modules.homePageData.entity.LeanEventWarnInfoResult">
+        SELECT
+            di.device_title,
+            lewi.*
+        FROM
+            lean_event_warn_info lewi
+                INNER JOIN device_information di ON lewi.device_information_id = di.id
+                AND lewi.create_time BETWEEN CURDATE() AND CURDATE() + INTERVAL 1 DAY
+        ORDER BY
+            lewi.create_time DESC
+    </select>
+</mapper>

+ 14 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/ILeanEventWarnInfoService.java

@@ -0,0 +1,14 @@
+package org.jeecg.modules.homePageData.service;
+
+import com.baomidou.mybatisplus.extension.service.IService;
+import org.jeecg.modules.homePageData.entity.LeanEventWarnInfo;
+
+/**
+ * @Description: 精益事件告警信息表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-29
+ * @Version: V1.0
+ */
+public interface ILeanEventWarnInfoService extends IService<LeanEventWarnInfo> {
+
+}

+ 29 - 16
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/impl/HomePageDataServiceImpl.java

@@ -1,17 +1,16 @@
 package org.jeecg.modules.homePageData.service.impl;
 
 import org.jeecg.common.util.oConvertUtils;
-import org.jeecg.modules.deviceLesm.entity.DeviceInformation;
 import org.jeecg.modules.deviceLesm.entity.DeviceRegion;
 import org.jeecg.modules.deviceLesm.service.IDeviceInformationService;
 import org.jeecg.modules.deviceLesm.service.IDeviceRegionService;
+import org.jeecg.modules.homePageData.entity.LeanEventWarnInfoResult;
+import org.jeecg.modules.homePageData.mapper.LeanEventWarnInfoMapper;
 import org.jeecg.modules.homePageData.service.IHomePageDataService;
-import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.entity.PeaksAndValleysTimeConfig;
 import org.jeecg.modules.systemConfig.peaksAndValleysTimeConfig.service.IPeaksAndValleysTimeConfigService;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
 
-import java.text.ParseException;
 import java.text.SimpleDateFormat;
 import java.util.*;
 import java.util.concurrent.atomic.AtomicReference;
@@ -29,6 +28,9 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
     @Autowired
     private IDeviceInformationService deviceInformationService;
 
+    @Autowired
+    private LeanEventWarnInfoMapper leanEventWarnInfoMapper;
+
 
     @Override
     public List<Map<String, String>> regionPfvElectricity() {
@@ -138,22 +140,33 @@ public class HomePageDataServiceImpl implements IHomePageDataService {
 
     @Override
     public List<Map<String, String>> realAlarm() {
-        List<DeviceInformation> deviceInformations = deviceInformationService.list();
+//        if(oConvertUtils.listIsNotEmpty(deviceInformations)){
+//            String[] alarms = new String[]{"耗电异常","停止运行","运行异常"};
+//            String[] levels = new String[]{"高度","轻度","中度"};
+//            long time = new Date().getTime();
+//            for (int i = 0; i < 10; i++) {
+//                time -= Math.random()*60*30+30*60;
+//                Map<String,String> map = new HashMap<>();
+//                SimpleDateFormat format = new SimpleDateFormat("HH:mm");
+//                map.put("time",format.format(new Date(time)));
+//                map.put("name",deviceInformations.get((int)(Math.random()*deviceInformations.size())).getDeviceTitle());
+//                map.put("alarmInfo",alarms[(int)(Math.random()*3)]);
+//                map.put("level",levels[(int)(Math.random()*3)]);
+//                res.add(map);
+//            }
+//        }
         List<Map<String, String>> res = new ArrayList<>();
-        if(oConvertUtils.listIsNotEmpty(deviceInformations)){
-            String[] alarms = new String[]{"耗电异常","停止运行","运行异常"};
-            String[] levels = new String[]{"高度","轻度","中度"};
-            long time = new Date().getTime();
-            for (int i = 0; i < 10; i++) {
-                time -= Math.random()*60*30+30*60;
-                Map<String,String> map = new HashMap<>();
+        List<LeanEventWarnInfoResult> leanEventWarnInfoResult = leanEventWarnInfoMapper.queryLeanEventWarnInfo();
+        if(oConvertUtils.listIsNotEmpty(leanEventWarnInfoResult)){
+            leanEventWarnInfoResult.forEach(x ->{
+                Map<String, String> map = new HashMap<>();
                 SimpleDateFormat format = new SimpleDateFormat("HH:mm");
-                map.put("time",format.format(new Date(time)));
-                map.put("name",deviceInformations.get((int)(Math.random()*deviceInformations.size())).getDeviceTitle());
-                map.put("alarmInfo",alarms[(int)(Math.random()*3)]);
-                map.put("level",levels[(int)(Math.random()*3)]);
+                map.put("time", format.format(x.getCreateTime()));
+                map.put("name", x.getDeviceTitle());
+                map.put("alarmInfo", x.getDeviceWarnInfo());
+                map.put("level",x.getDeviceWarnLevel());
                 res.add(map);
-            }
+            });
         }
         return res;
     }

+ 18 - 0
zgztBus/jeecg-module-lesm/src/main/java/org/jeecg/modules/homePageData/service/impl/LeanEventWarnInfoServiceImpl.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.homePageData.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.jeecg.modules.homePageData.entity.LeanEventWarnInfo;
+import org.jeecg.modules.homePageData.mapper.LeanEventWarnInfoMapper;
+import org.jeecg.modules.homePageData.service.ILeanEventWarnInfoService;
+import org.springframework.stereotype.Service;
+
+/**
+ * @Description: 精益事件告警信息表
+ * @Author: jeecg-boot
+ * @Date:   2024-10-29
+ * @Version: V1.0
+ */
+@Service
+public class LeanEventWarnInfoServiceImpl extends ServiceImpl<LeanEventWarnInfoMapper, LeanEventWarnInfo> implements ILeanEventWarnInfoService {
+
+}