Browse Source

Merge branch 'master' of 123.57.213.14:guoqiang.duan/zgzt-sys-java

# Conflicts:
#	jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java
guoqiang 7 months ago
parent
commit
fbd9004b41
15 changed files with 605 additions and 0 deletions
  1. 67 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/controller/DeviceController.java
  2. 189 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/controller/DeviceLogController.java
  3. 22 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/entity/Device.java
  4. 93 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/entity/DeviceLog.java
  5. 17 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/DeviceLogMapper.java
  6. 17 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/DeviceMapper.java
  7. 5 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/xml/DeviceLogMapper.xml
  8. 19 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/xml/DeviceMapper.xml
  9. 18 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/IDeviceLogService.java
  10. 18 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/IDeviceService.java
  11. 33 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/impl/DeviceLogServiceImpl.java
  12. 83 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/impl/DeviceServiceImpl.java
  13. 8 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java
  14. 8 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/modBusGatherWatch.java
  15. 8 0
      jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java

+ 67 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/controller/DeviceController.java

@@ -0,0 +1,67 @@
+package org.jeecg.modules.deviceLog.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.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.modules.deviceLog.entity.Device;
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+import org.jeecg.modules.deviceLog.service.IDeviceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+
+import javax.servlet.http.HttpServletRequest;
+import java.util.List;
+import java.util.Map;
+
+@Api(tags="设备列表")
+@RestController
+@RequestMapping("/device/device")
+@Slf4j
+public class DeviceController {
+
+    @Autowired
+    IDeviceService deviceService;
+
+
+    @ApiOperation(value="设备列表查询", notes="设备列表查询")
+    @GetMapping(value = "/list")
+    public Result<List<Device>> queryPageList() {
+        List<Device> list = deviceService.listAll();
+        return Result.OK(list);
+    }
+
+    @ApiOperation(value="修改设备状态", notes="修改设备状态")
+    @PostMapping(value = "/updateStatus")
+    public Result<String> updateStatus(@RequestBody Device device) {
+        Boolean update = deviceService.updateStatus(device);
+        if(update){
+            return Result.OK("修改成功");
+        }else{
+            return Result.OK("修改失败");
+        }
+
+    }
+
+    @ApiOperation(value="重启设备", notes="重启设备")
+    @PostMapping(value = "/rebootDevice")
+    public Result<String> rebootDevice() {
+        Boolean update = deviceService.rebootDevice();
+        if(update){
+            return Result.OK("重启成功");
+        }else{
+            return Result.OK("重启失败");
+        }
+
+    }
+
+
+    @GetMapping(value = "/getActuatorParams")
+    public Result<Map<String,Long>> getActuatorParams() {
+        return Result.OK(deviceService.getActuatorParams());
+    }
+}

+ 189 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/controller/DeviceLogController.java

@@ -0,0 +1,189 @@
+package org.jeecg.modules.deviceLog.controller;
+
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
+import java.io.IOException;
+import java.io.UnsupportedEncodingException;
+import java.net.URLDecoder;
+import javax.servlet.http.HttpServletRequest;
+import javax.servlet.http.HttpServletResponse;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import org.jeecg.common.api.vo.Result;
+import org.jeecg.common.system.query.QueryGenerator;
+import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+import org.jeecg.modules.deviceLog.service.IDeviceLogService;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import lombok.extern.slf4j.Slf4j;
+
+
+import org.jeecg.common.system.base.controller.JeecgController;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.web.bind.annotation.*;
+import org.springframework.web.servlet.ModelAndView;
+import io.swagger.annotations.Api;
+import io.swagger.annotations.ApiOperation;
+import org.jeecg.common.aspect.annotation.AutoLog;
+import org.apache.shiro.authz.annotation.RequiresPermissions;
+
+ /**
+ * @Description: 设备日志
+ * @Author: jeecg-boot
+ * @Date:   2023-11-29
+ * @Version: V1.0
+ */
+@Api(tags="设备日志")
+@RestController
+@RequestMapping("/deviceLog/deviceLog")
+@Slf4j
+public class DeviceLogController extends JeecgController<DeviceLog, IDeviceLogService> {
+	@Autowired
+	private IDeviceLogService deviceLogService;
+	
+	/**
+	 * 分页列表查询
+	 *
+	 * @param deviceLog
+	 * @param pageNo
+	 * @param pageSize
+	 * @param req
+	 * @return
+	 */
+	//@AutoLog(value = "设备日志-分页列表查询")
+	@ApiOperation(value="设备日志-分页列表查询", notes="设备日志-分页列表查询")
+	@GetMapping(value = "/list")
+	public Result<IPage<DeviceLog>> queryPageList(DeviceLog deviceLog,
+								   @RequestParam(name="pageNo", defaultValue="1") Integer pageNo,
+								   @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
+								   HttpServletRequest req) {
+		QueryWrapper<DeviceLog> queryWrapper = QueryGenerator.initQueryWrapper(deviceLog, req.getParameterMap());
+		Page<DeviceLog> page = new Page<DeviceLog>(pageNo, pageSize);
+		IPage<DeviceLog> pageList = deviceLogService.page(page, queryWrapper);
+		return Result.OK(pageList);
+	}
+
+
+	 /**
+	  * 列表查询
+	  *
+	  * @return
+	  */
+	 //@AutoLog(value = "设备日志-分页列表查询")
+	 @ApiOperation(value="设备日志-列表查询", notes="设备日志-列表查询")
+	 @GetMapping(value = "/listAll")
+	 public Result<List<DeviceLog>> getList() {
+		 LambdaQueryWrapper<DeviceLog> query = new LambdaQueryWrapper<DeviceLog>().orderByDesc(DeviceLog::getTime);
+		 List<DeviceLog> list = deviceLogService.page(new Page<DeviceLog>(1, 100),query).getRecords();
+		 return Result.OK(list);
+	 }
+
+
+	/**
+	 *   添加
+	 *
+	 * @param deviceLog
+	 * @return
+	 */
+	@AutoLog(value = "设备日志-添加")
+	@ApiOperation(value="设备日志-添加", notes="设备日志-添加")
+	@RequiresPermissions("deviceLog:device_log:add")
+	@PostMapping(value = "/add")
+	public Result<String> add(@RequestBody DeviceLog deviceLog) {
+		deviceLogService.save(deviceLog);
+		return Result.OK("添加成功!");
+	}
+	
+	/**
+	 *  编辑
+	 *
+	 * @param deviceLog
+	 * @return
+	 */
+	@AutoLog(value = "设备日志-编辑")
+	@ApiOperation(value="设备日志-编辑", notes="设备日志-编辑")
+	@RequiresPermissions("deviceLog:device_log:edit")
+	@RequestMapping(value = "/edit", method = {RequestMethod.PUT,RequestMethod.POST})
+	public Result<String> edit(@RequestBody DeviceLog deviceLog) {
+		deviceLogService.updateById(deviceLog);
+		return Result.OK("编辑成功!");
+	}
+	
+	/**
+	 *   通过id删除
+	 *
+	 * @param id
+	 * @return
+	 */
+	@AutoLog(value = "设备日志-通过id删除")
+	@ApiOperation(value="设备日志-通过id删除", notes="设备日志-通过id删除")
+	@RequiresPermissions("deviceLog:device_log:delete")
+	@DeleteMapping(value = "/delete")
+	public Result<String> delete(@RequestParam(name="id",required=true) String id) {
+		deviceLogService.removeById(id);
+		return Result.OK("删除成功!");
+	}
+	
+	/**
+	 *  批量删除
+	 *
+	 * @param ids
+	 * @return
+	 */
+	@AutoLog(value = "设备日志-批量删除")
+	@ApiOperation(value="设备日志-批量删除", notes="设备日志-批量删除")
+	@RequiresPermissions("deviceLog:device_log:deleteBatch")
+	@DeleteMapping(value = "/deleteBatch")
+	public Result<String> deleteBatch(@RequestParam(name="ids",required=true) String ids) {
+		this.deviceLogService.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<DeviceLog> queryById(@RequestParam(name="id",required=true) String id) {
+		DeviceLog deviceLog = deviceLogService.getById(id);
+		if(deviceLog==null) {
+			return Result.error("未找到对应数据");
+		}
+		return Result.OK(deviceLog);
+	}
+
+    /**
+    * 导出excel
+    *
+    * @param request
+    * @param deviceLog
+    */
+    @RequiresPermissions("deviceLog:device_log:exportXls")
+    @RequestMapping(value = "/exportXls")
+    public ModelAndView exportXls(HttpServletRequest request, DeviceLog deviceLog) {
+        return super.exportXls(request, deviceLog, DeviceLog.class, "设备日志");
+    }
+
+    /**
+      * 通过excel导入数据
+    *
+    * @param request
+    * @param response
+    * @return
+    */
+    @RequiresPermissions("deviceLog:device_log:importExcel")
+    @RequestMapping(value = "/importExcel", method = RequestMethod.POST)
+    public Result<?> importExcel(HttpServletRequest request, HttpServletResponse response) {
+        return super.importExcel(request, response, DeviceLog.class);
+    }
+
+}

+ 22 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/entity/Device.java

@@ -0,0 +1,22 @@
+package org.jeecg.modules.deviceLog.entity;
+
+import lombok.Data;
+
+@Data
+public class Device {
+
+    private String id;
+
+    private String name;
+
+    private String code;
+
+    private String deviceType;
+
+    private String useStatus;
+
+    private String freq;
+
+    private String status;
+
+}

+ 93 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/entity/DeviceLog.java

@@ -0,0 +1,93 @@
+package org.jeecg.modules.deviceLog.entity;
+
+import java.io.Serializable;
+import java.io.UnsupportedEncodingException;
+import java.util.Date;
+import java.math.BigDecimal;
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import lombok.Data;
+import com.fasterxml.jackson.annotation.JsonFormat;
+import org.springframework.format.annotation.DateTimeFormat;
+import org.jeecgframework.poi.excel.annotation.Excel;
+import io.swagger.annotations.ApiModel;
+import io.swagger.annotations.ApiModelProperty;
+import lombok.EqualsAndHashCode;
+import lombok.experimental.Accessors;
+
+/**
+ * @Description: 设备日志
+ * @Author: jeecg-boot
+ * @Date:   2023-11-29
+ * @Version: V1.0
+ */
+@Data
+@TableName("device_log")
+@Accessors(chain = true)
+@EqualsAndHashCode(callSuper = false)
+@ApiModel(value="device_log对象", description="设备日志")
+public class DeviceLog 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;
+	/**标题*/
+	@Excel(name = "标题", width = 15)
+    @ApiModelProperty(value = "标题")
+    private String title;
+	/**时间*/
+	@Excel(name = "时间", width = 20, format = "yyyy-MM-dd HH:mm:ss")
+	@JsonFormat(timezone = "GMT+8",pattern = "yyyy-MM-dd HH:mm:ss")
+    @DateTimeFormat(pattern="yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "时间")
+    private Date time;
+	/**日志类型*/
+	@Excel(name = "日志类型", width = 15)
+    @ApiModelProperty(value = "日志类型")
+    private String type;
+	/**日志描述*/
+	@Excel(name = "日志描述", width = 15)
+    @ApiModelProperty(value = "日志描述")
+    private String logdesc;
+
+    public DeviceLog() {
+    }
+
+    public DeviceLog(String topic, String nameCn, String ip) {
+        this.title = topic;
+        this.logdesc = nameCn+"(IP为"+ip+")"+"的"+topic;
+        this.time = new Date();
+    }
+
+    public DeviceLog(String topic, String nameCn, String ip, String pointName) {
+        this.title = topic;
+        if(topic.contains("异常")){
+            this.logdesc = nameCn+"(IP为"+ip+")"+"的设备"+pointName+"信息读取异常";
+        }else {
+            this.logdesc = nameCn+"(IP为"+ip+")"+"的设备"+pointName+"信息读取恢复";
+        }
+        this.time = new Date();
+    }
+}

+ 17 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/DeviceLogMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.deviceLog.mapper;
+
+import java.util.List;
+
+import org.apache.ibatis.annotations.Param;
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+ * @Description: 设备日志
+ * @Author: jeecg-boot
+ * @Date:   2023-11-29
+ * @Version: V1.0
+ */
+public interface DeviceLogMapper extends BaseMapper<DeviceLog> {
+
+}

+ 17 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/DeviceMapper.java

@@ -0,0 +1,17 @@
+package org.jeecg.modules.deviceLog.mapper;
+
+import org.apache.ibatis.annotations.Mapper;
+import org.jeecg.modules.deviceLog.entity.Device;
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+
+import java.util.List;
+
+@Mapper
+public interface DeviceMapper {
+
+    List<Device> listAll();
+
+    List<Device> listStop();
+
+    Long count();
+}

+ 5 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/xml/DeviceLogMapper.xml

@@ -0,0 +1,5 @@
+<?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.deviceLog.mapper.DeviceLogMapper">
+
+</mapper>

+ 19 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/mapper/xml/DeviceMapper.xml

@@ -0,0 +1,19 @@
+<?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.deviceLog.mapper.DeviceMapper">
+
+    <select id="listAll" resultType="org.jeecg.modules.deviceLog.entity.Device">
+        select id,device_title as name, device_code as code, device_gather as deviceType,'0' as useStatus,freq,status
+        from device_information
+    </select>
+    <select id="listStop" resultType="org.jeecg.modules.deviceLog.entity.Device">
+        select id,device_title as name, device_code as code, device_gather as deviceType,'0' as useStatus,freq,status
+        from device_information
+        where status = '1'
+    </select>
+    <select id="count" resultType="java.lang.Long">
+        select count(0)
+        from device_information
+        where status != '1'
+    </select>
+</mapper>

+ 18 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/IDeviceLogService.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.deviceLog.service;
+
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+ * @Description: 设备日志
+ * @Author: jeecg-boot
+ * @Date:   2023-11-29
+ * @Version: V1.0
+ */
+public interface IDeviceLogService extends IService<DeviceLog> {
+
+    public boolean save(String topic, String nameCn, String ip);
+
+
+    public boolean save(String topic, String nameCn, String ip, String pointName);
+}

+ 18 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/IDeviceService.java

@@ -0,0 +1,18 @@
+package org.jeecg.modules.deviceLog.service;
+
+import org.jeecg.modules.deviceLog.entity.Device;
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+
+import java.util.List;
+import java.util.Map;
+
+public interface IDeviceService {
+
+    List<Device> listAll();
+
+    Boolean updateStatus(Device device);
+
+    Boolean rebootDevice();
+
+    Map<String,Long> getActuatorParams();
+}

+ 33 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/impl/DeviceLogServiceImpl.java

@@ -0,0 +1,33 @@
+package org.jeecg.modules.deviceLog.service.impl;
+
+import org.jeecg.modules.common.entity.LogTopic;
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+import org.jeecg.modules.deviceLog.mapper.DeviceLogMapper;
+import org.jeecg.modules.deviceLog.service.IDeviceLogService;
+import org.springframework.stereotype.Service;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+
+/**
+ * @Description: 设备日志
+ * @Author: jeecg-boot
+ * @Date:   2023-11-29
+ * @Version: V1.0
+ */
+@Service
+public class DeviceLogServiceImpl extends ServiceImpl<DeviceLogMapper, DeviceLog> implements IDeviceLogService {
+
+
+    @Override
+    public boolean save(String topic, String nameCn, String ip) {
+        DeviceLog deviceCjLog = new DeviceLog(topic,nameCn,ip);
+        return super.save(deviceCjLog);
+    }
+
+    @Override
+    public boolean save(String topic, String nameCn, String ip, String pointName) {
+        DeviceLog deviceCjLog = new DeviceLog(topic,nameCn,ip,pointName);
+        return super.save(deviceCjLog);
+    }
+
+}

+ 83 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/deviceLog/service/impl/DeviceServiceImpl.java

@@ -0,0 +1,83 @@
+package org.jeecg.modules.deviceLog.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
+import com.baomidou.mybatisplus.extension.conditions.query.QueryChainWrapper;
+import org.jeecg.modules.common.entity.LogTopic;
+import org.jeecg.modules.device.entity.DeviceInformation;
+import org.jeecg.modules.device.service.IDeviceInformationService;
+import org.jeecg.modules.deviceLog.entity.Device;
+import org.jeecg.modules.deviceLog.entity.DeviceLog;
+import org.jeecg.modules.deviceLog.mapper.DeviceLogMapper;
+import org.jeecg.modules.deviceLog.mapper.DeviceMapper;
+import org.jeecg.modules.deviceLog.service.IDeviceLogService;
+import org.jeecg.modules.deviceLog.service.IDeviceService;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+
+@Service
+public class DeviceServiceImpl implements IDeviceService {
+
+    @Autowired
+    DeviceMapper deviceMapper;
+
+    @Autowired
+    IDeviceInformationService deviceInformationService;
+
+    @Autowired
+    IDeviceLogService deviceLogService;
+
+
+    @Override
+    public List<Device> listAll() {
+        return deviceMapper.listAll();
+    }
+
+    @Override
+    public Boolean updateStatus(Device device) {
+        boolean update = false;
+        DeviceInformation deviceInformation = deviceInformationService.getById(device.getId());
+        deviceInformation.setStatus(device.getStatus());
+
+        update = deviceInformationService.updateById(deviceInformation);
+        if (device.getStatus().equals("1")){
+            deviceLogService.save(LogTopic.OPC.STOP,device.getName(),deviceInformation.getDeviceIp());
+        }else {
+            deviceLogService.save(LogTopic.OPC.START,device.getName(),deviceInformation.getDeviceIp());
+        }
+        return update;
+    }
+
+    @Override
+    @Transactional
+    public Boolean rebootDevice() {
+        List<Device> devices = deviceMapper.listStop();
+        if(!CollectionUtils.isEmpty(devices)){
+            devices.forEach(device -> {
+                DeviceInformation deviceInformation = deviceInformationService.getById(device.getId());
+                deviceInformation.setStatus("0");
+                deviceInformationService.updateById(deviceInformation);
+                deviceLogService.save(LogTopic.OPC.START,device.getName(),deviceInformation.getDeviceIp());
+            });
+        }
+        return true;
+    }
+
+    @Override
+    public Map<String, Long> getActuatorParams() {
+        Long connCount = deviceMapper.count();
+        Date now = new Date();
+        Date last = new Date(now.getTime() - 1000 * 60 * 60 * 24);
+        Long dataCount = connCount*1001;
+        HashMap<String, Long> map = new HashMap<>();
+        map.put("connCount",connCount);
+        map.put("dataCount",dataCount);
+        return map;
+    }
+}

+ 8 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/OpcGatherWatch.java

@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.eclipse.milo.opcua.sdk.client.OpcUaClient;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.common.entity.LogTopic;
 import org.jeecg.modules.dataRepository.entity.PointData;
 import org.jeecg.modules.device.entity.DeviceInformation;
 import org.jeecg.modules.device.service.IDeviceInformationService;
 import org.jeecg.modules.deviceConn.opc.utils.OpcUaServerUtils;
+import org.jeecg.modules.deviceLog.service.IDeviceLogService;
 import org.jeecg.modules.devicePoint.entity.DevicePoint;
 import org.jeecg.modules.devicePoint.service.IDevicePointService;
 import org.jeecg.modules.gatherData.entity.FpgGatherData;
@@ -39,6 +41,9 @@ public class OpcGatherWatch {
     @Autowired
     IFpgGatherDataService fpgGatherDataService;
 
+    @Autowired
+    IDeviceLogService deviceLogService;
+
     @Autowired
     MongoTemplate mongoTemplate;
 
@@ -112,10 +117,12 @@ public class OpcGatherWatch {
                         //如果点位状态异常则恢复为正常
                         if(opcPoint.getGatherStatus().equals(1)){
                             opcPoint.setGatherStatus("0");
+                            deviceLogService.save(LogTopic.OPC.READ_RECOVER,opcConn.getDeviceTitle(),opcConn.getDeviceIp(),opcPoint.getPointName());
                         }
                     } catch (Exception e) {
                         //打印点位异常日志
                         log.error(e.getMessage());
+                        deviceLogService.save(LogTopic.OPC.READ_ERROR,opcConn.getDeviceTitle(),opcConn.getDeviceIp(),opcPoint.getPointName());
                         //设置点位状态为异常
                         opcPoint.setGatherStatus("1");
                     } finally {
@@ -134,6 +141,7 @@ public class OpcGatherWatch {
                 }
             } catch (Exception e) {
                 log.error(e.getMessage());
+                deviceLogService.save(LogTopic.OPC.CONNECTE_ERROR,opcConn.getDeviceTitle(),opcConn.getDeviceIp());
             } finally {
                 //更新数据库设备信息
                 deviceInformationService.updateById(opcConn);

+ 8 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/modBusGatherWatch.java

@@ -3,10 +3,12 @@ package org.jeecg.modules.watch;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.common.entity.LogTopic;
 import org.jeecg.modules.dataRepository.entity.PointData;
 import org.jeecg.modules.device.entity.DeviceInformation;
 import org.jeecg.modules.device.service.IDeviceInformationService;
 import org.jeecg.modules.deviceConn.modbus.service.ModbusTcp;
+import org.jeecg.modules.deviceLog.service.IDeviceLogService;
 import org.jeecg.modules.devicePoint.entity.DevicePoint;
 import org.jeecg.modules.devicePoint.service.IDevicePointService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -31,6 +33,9 @@ public class modBusGatherWatch {
     @Autowired
     IDevicePointService devicePointService;
 
+    @Autowired
+    IDeviceLogService deviceLogService;
+
     @Autowired
     MongoTemplate mongoTemplate;
 
@@ -104,10 +109,12 @@ public class modBusGatherWatch {
                         //如果点位状态异常则恢复为正常
                         if(modBusPoint.getGatherStatus().equals(1)){
                             modBusPoint.setGatherStatus("0");
+                            deviceLogService.save(LogTopic.MODBUS.READ_RECOVER,modBus.getDeviceTitle(),modBus.getDeviceIp(),modBusPoint.getPointName());
                         }
                     } catch (Exception e) {
                         //打印点位异常日志
                         log.error(e.getMessage());
+                        deviceLogService.save(LogTopic.MODBUS.READ_ERROR,modBus.getDeviceTitle(),modBus.getDeviceIp(),modBusPoint.getPointName());
                         //设置点位状态为异常
                         modBusPoint.setGatherStatus("1");
                     }finally {
@@ -120,6 +127,7 @@ public class modBusGatherWatch {
                 }
             } catch (Exception e) {
                 log.error(e.getMessage());
+                deviceLogService.save(LogTopic.MODBUS.CONNECTE_ERROR,modBus.getDeviceTitle(),modBus.getDeviceIp());
             }finally {
                 //关闭连接
                 plc.close();

+ 8 - 0
jeecg-module-gather/src/main/java/org/jeecg/modules/watch/s7gatherWatch.java

@@ -4,10 +4,12 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import io.netty.util.internal.StringUtil;
 import lombok.extern.slf4j.Slf4j;
 import org.jeecg.common.util.oConvertUtils;
+import org.jeecg.modules.common.entity.LogTopic;
 import org.jeecg.modules.dataRepository.entity.PointData;
 import org.jeecg.modules.device.entity.DeviceInformation;
 import org.jeecg.modules.device.service.IDeviceInformationService;
 import org.jeecg.modules.deviceConn.s7.service.S7PLC;
+import org.jeecg.modules.deviceLog.service.IDeviceLogService;
 import org.jeecg.modules.devicePoint.entity.DevicePoint;
 import org.jeecg.modules.devicePoint.service.IDevicePointService;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -36,6 +38,9 @@ public class s7gatherWatch {
     @Autowired
     MongoTemplate mongoTemplate;
 
+    @Autowired
+    IDeviceLogService deviceLogService;
+
     HashMap<String, S7PLC> s7PLCmap = new HashMap<>();
 
     @Scheduled(fixedDelay = 500)
@@ -135,10 +140,12 @@ public class s7gatherWatch {
                         //如果点位状态异常则恢复为正常
                         if(s7Info.getGatherStatus().equals("1")){
                             s7Info.setGatherStatus("0");
+                            deviceLogService.save(LogTopic.S7.READ_RECOVER,s7.getDeviceTitle(),s7.getDeviceIp(),s7Info.getPointName());
                         }
                     } catch (Exception e) {
                         //打印点位异常日志
                         log.error(e.getMessage());
+                        deviceLogService.save(LogTopic.S7.READ_ERROR,s7.getDeviceTitle(),s7.getDeviceIp(),s7Info.getPointName());
                         //设置点位状态为异常
                         s7Info.setGatherStatus("1");
                     }finally {
@@ -150,6 +157,7 @@ public class s7gatherWatch {
                     }
                 }
             } catch (Exception e) {
+                deviceLogService.save(LogTopic.S7.CONNECTE_ERROR,s7.getDeviceTitle(),s7.getDeviceIp());
             }
         });
     }