diff --git a/device_gather/pom.xml b/device_gather/pom.xml new file mode 100644 index 0000000..8ad1b2c --- /dev/null +++ b/device_gather/pom.xml @@ -0,0 +1,164 @@ + + + 4.0.0 + + com.xr.device_net + device_car + 1.0.1 + + device_gather + ${project.artifactId} + + 1.8 + + + + + false + + + true + + ias-snapshots + Infinite Automation Snapshot Repository + https://maven.mangoautomation.net/repository/ias-snapshot/ + + + + true + + + false + + ias-releases + Infinite Automation Release Repository + https://maven.mangoautomation.net/repository/ias-release/ + + + + + org.springframework.boot + spring-boot-starter + + + + org.springframework.boot + spring-boot-starter-web + + + + org.springframework.boot + spring-boot-starter-tomcat + + + org.freemarker + freemarker + 2.3.28 + + + mysql + mysql-connector-java + 8.0.27 + + + com.baomidou + mybatis-plus-boot-starter + 3.4.1 + + + + org.springframework.cloud + spring-cloud-starter-netflix-eureka-client + + + + org.springframework.cloud + spring-cloud-starter-openfeign + + + org.springframework.boot + spring-boot-starter-websocket + + + com.alibaba + fastjson + 1.2.78 + compile + + + commons-discovery + commons-discovery + 0.2 + + + commons-io + commons-io + 2.6 + + + com.baomidou + mybatis-plus-generator + 3.4.1 + + + com.baomidou + dynamic-datasource-spring-boot-starter + 3.4.1 + + + io.github.java-native + jssc + 2.9.4 + + + com.infiniteautomation + modbus4j + 3.0.4 + + + org.rxtx + rxtx + 2.1.7 + + + org.scream3r + jssc + 2.8.0 + + + org.bouncycastle + bcprov-jdk15on + 1.59 + + + + + + + src/main/resources + false + + **/* + **/*.fxml + **/fxml/*.fxml + + + + + + org.springframework.boot + spring-boot-maven-plugin + 2.0.8.RELEASE + + + + repackage + + + + + + + + diff --git a/device_gather/src/main/java/com/xr/device/DeviceGatherApplication.java b/device_gather/src/main/java/com/xr/device/DeviceGatherApplication.java new file mode 100644 index 0000000..26f8c70 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/DeviceGatherApplication.java @@ -0,0 +1,19 @@ +package com.xr.device; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.cloud.client.discovery.EnableDiscoveryClient; +import org.springframework.cloud.openfeign.EnableFeignClients; +import org.springframework.scheduling.annotation.EnableScheduling; + +@EnableScheduling//开启定时任务 +@SpringBootApplication +@EnableDiscoveryClient +@EnableFeignClients +public class DeviceGatherApplication { + + public static void main(String[] args) { + SpringApplication.run(DeviceGatherApplication.class, args); + } + +} diff --git a/device_gather/src/main/java/com/xr/device/common/configvalue/StaticPropProxy.java b/device_gather/src/main/java/com/xr/device/common/configvalue/StaticPropProxy.java new file mode 100644 index 0000000..5285d81 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/common/configvalue/StaticPropProxy.java @@ -0,0 +1,11 @@ +package com.xr.device.common.configvalue; + +import com.xr.device.common.utils.StaticPropUtil; +import org.springframework.stereotype.Component; + +@Component +public class StaticPropProxy { + public StaticPropProxy(StaticProperties staticProperties){ + StaticPropUtil.initDingDingProp(staticProperties); + } +} diff --git a/device_gather/src/main/java/com/xr/device/common/configvalue/StaticProperties.java b/device_gather/src/main/java/com/xr/device/common/configvalue/StaticProperties.java new file mode 100644 index 0000000..21b007c --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/common/configvalue/StaticProperties.java @@ -0,0 +1,17 @@ +package com.xr.device.common.configvalue; + +import lombok.Data; +import org.springframework.beans.factory.annotation.Value; +import org.springframework.stereotype.Component; + +@Component +@Data +public class StaticProperties { + + @Value("${upload.img.url}") + private String imgUrl; + + @Value("${upload.img.path}") + private String imgPath; + +} diff --git a/device_gather/src/main/java/com/xr/device/common/utils/StaticPropUtil.java b/device_gather/src/main/java/com/xr/device/common/utils/StaticPropUtil.java new file mode 100644 index 0000000..c49d5c7 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/common/utils/StaticPropUtil.java @@ -0,0 +1,17 @@ +package com.xr.device.common.utils; + + +import com.xr.device.common.configvalue.StaticProperties; + +public class StaticPropUtil { + + public static String imgUrl; + + public static String imgPath; + + public static void initDingDingProp(StaticProperties dingProperties){ + imgUrl = dingProperties.getImgUrl(); + imgPath = dingProperties.getImgPath(); + } + +} diff --git a/device_gather/src/main/java/com/xr/device/common/utils/UploadUtil.java b/device_gather/src/main/java/com/xr/device/common/utils/UploadUtil.java new file mode 100644 index 0000000..c108c70 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/common/utils/UploadUtil.java @@ -0,0 +1,185 @@ +package com.xr.device.common.utils; + +import org.apache.poi.ss.usermodel.Workbook; + +import javax.imageio.ImageIO; +import java.awt.*; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; +import java.io.File; +import java.io.FileOutputStream; +import java.io.IOException; +import java.io.InputStream; +import java.net.URL; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.text.SimpleDateFormat; +import java.util.Date; + +public class UploadUtil { + + public static String uploadExcel(Workbook workbook,String path,String url1,String fileName) throws Exception{ + FileOutputStream outputStream =new FileOutputStream(path+fileName); + workbook.write(outputStream); + outputStream.close(); + String url = url1+fileName; + return url; + } + + + public static String uploadImage(String clentIp,Integer configId,String fileName) throws Exception { + // 构建完整的路径 + String url = "http://"+clentIp+":8080/tao/snapshot"; + SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd-HH"); + String date = sim.format(new Date()); + String dates[] = date.split("-"); + + String year = dates[0]; + String month = dates[1]; + String day = dates[2]; + String ho = dates[3]; + String fullPath = StaticPropUtil.imgPath+configId + File.separator + year + File.separator + month + File.separator + day + File.separator +ho+File.separator+ fileName; + + // 创建目录结构 + Path directoryPath = Paths.get(StaticPropUtil.imgPath,configId.toString(), year, month, day,ho); + if (!Files.exists(directoryPath)) { + Files.createDirectories(directoryPath); + } + + downloadImage(url,fullPath); + + // 构建URL + String url1 = StaticPropUtil.imgUrl+ configId + "/" + year + "/"+ month + "/" + day + "/" +ho+"/"+ fileName; + return url1; + } + + public static String uploadImage(BufferedImage buffer,Integer configId,String fileName) throws Exception { + // 构建完整的路径 + SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd-HH"); + String date = sim.format(new Date()); + String dates[] = date.split("-"); + + String year = dates[0]; + String month = dates[1]; + String day = dates[2]; + String ho = dates[3]; + String fullPath = StaticPropUtil.imgPath+configId + File.separator + year + File.separator + month + File.separator + day + File.separator +ho+File.separator+ fileName; + + // 创建目录结构 + Path directoryPath = Paths.get(StaticPropUtil.imgPath,configId.toString(), year, month, day,ho); + if (!Files.exists(directoryPath)) { + Files.createDirectories(directoryPath); + } + + downloadImage(buffer,fullPath); + + // 构建URL + String url1 = StaticPropUtil.imgUrl+ configId + "/" + year + "/"+ month + "/" + day + "/" +ho+"/"+ fileName; + return url1; + } + + + public static BufferedImage urlByImage(String url) throws IOException { + URL urlfile = new URL(url); + InputStream is2 = urlfile.openStream(); + BufferedImage uImg= ImageIO.read(is2); + return uImg; + } + + public static void delFile(String path,String url,String fileUrl){ + String filePath = fileUrl.replace(url,path).replace("/","\\"); + File file = new File(filePath); + if(file.exists()){ + file.delete(); + } + } + + public static void downloadImage(String imageUrl, String destinationPath) throws IOException { + URL url = new URL(imageUrl); + try (InputStream in = url.openStream(); + FileOutputStream out = new FileOutputStream(destinationPath)) { + byte[] buffer = new byte[1024]; + int bytesRead; + while ((bytesRead = in.read(buffer)) != -1) { + out.write(buffer, 0, bytesRead); + } + } + } + + public static void downloadImage(BufferedImage bufferedImage, String destinationPath) throws IOException { + File file = new File(destinationPath); + ImageIO.write(bufferedImage,"jpg",file); + } + + public static BufferedImage drawRectangleAndText(BufferedImage image, double x1, double y1,double x2, double wid, double hei, String text1, String text2) { + // 创建一个Graphics2D对象 + Graphics2D g2d = image.createGraphics(); + + + // 设置抗锯齿 + g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); + + + // 创建一个Rectangle2D.Double对象 + Rectangle2D.Double rect = new Rectangle2D.Double(x1, y1, wid, hei); + + // 绘制红色框 + g2d.setColor(Color.RED); + g2d.draw(rect); + // 设置粗线条 + g2d.setStroke(new BasicStroke(3.0f * 30)); // 设置线条宽度为3.0f + + // 设置字体和颜色 + g2d.setFont(new Font("微软雅黑", Font.BOLD, 38)); // 使用支持中文的字体,增加字体大小 + + // 获取当前时间 + String currentTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()); + // 获取文本的宽度和高度 + FontMetrics fm = g2d.getFontMetrics(); + + // 绘制当前时间的背景矩形 + int padding = 20; + int currentTimeWidth = fm.stringWidth(currentTime); + int currentTimeHeight = fm.getHeight(); + int rectPadding = 5; // 背景矩形内边距 + g2d.setColor(new Color(0, 0, 0, 50)); // 黑色半透明背景 + g2d.fillRect(padding, padding, currentTimeWidth + 2 * rectPadding, currentTimeHeight + 2 * rectPadding); + + // 绘制当前时间在左上角,内边距为20px + g2d.setColor(Color.WHITE); + int currentTimeX = padding + rectPadding + (currentTimeWidth + rectPadding - currentTimeWidth) / 2; + int currentTimeY = padding + rectPadding + fm.getAscent(); + g2d.drawString(currentTime, currentTimeX, currentTimeY); + + // 绘制文本2的背景矩形 + int text2Width = fm.stringWidth(text2); + int text2Height = fm.getHeight(); + g2d.setColor(new Color(0, 0, 0, 50)); // 黑色半透明背景 + g2d.fillRect(padding, padding + currentTimeHeight + rectPadding * 2, text2Width + 2 * rectPadding, text2Height + 2 * rectPadding); + + // 绘制文本2在时间的下面,内边距为20px + g2d.setColor(Color.WHITE); + int text2X = padding + rectPadding + (text2Width + rectPadding - text2Width) / 2; + int text2Y = padding + currentTimeHeight + rectPadding * 3 + fm.getAscent(); + g2d.drawString(text2, text2X, text2Y); + + // 计算文本1的右上角位置 + int text1Width = fm.stringWidth(text1); + int text1X = (int) (x1 + wid); // 框的右上角位置 + int text1Y = (int) (y1 + fm.getAscent()); // 框的右上角紧挨着框 + g2d.setColor(Color.RED); + + g2d.drawString(text1, text1X, text1Y); + + + // 释放资源 + g2d.dispose(); + + return image; + } + + + + +} diff --git a/device_gather/src/main/java/com/xr/device/model/entity/DeviceCamera.java b/device_gather/src/main/java/com/xr/device/model/entity/DeviceCamera.java new file mode 100644 index 0000000..bda6a89 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/entity/DeviceCamera.java @@ -0,0 +1,126 @@ +package com.xr.device.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDateTime; +import lombok.Data; + +/** + * + * @TableName device_camera + */ +@TableName(value ="device_camera") +@Data +public class DeviceCamera implements Serializable { + /** + * 主键 + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * 摄像头编号 + */ + private String deviceNo; + + /** + * 类型(1 usb 2 mipi 3 球机 4 枪机) + */ + private String deviceType; + + /** + * IP + */ + private String deviceIp; + + /** + * 端口 + */ + private String devicePort; + + /** + * 账号 + */ + private String account; + + /** + * 密码 + */ + private String password; + + /** + * x轴 + */ + private String x; + + /** + * y轴 + */ + private String y; + + /** + * z轴 + */ + private String z; + + /** + * 摄像头型号 + */ + private String deviceModel; + + /** + * 安装位置 + */ + private String position; + + /** + * 品牌 + */ + private String brand; + + /** + * 备注 + */ + private String remarks; + + /** + * 状态(0未使用 1已使用) + */ + private String status; + + /** + * 创建人 + */ + private String createUser; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 修改人 + */ + private String updateUser; + + /** + * 修改时间 + */ + private LocalDateTime updateTime; + + /** + * 传输间隔 + */ + private Integer transmissionInterval; + + /** + * 对焦时间 + */ + private Integer warmup; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/device_gather/src/main/java/com/xr/device/model/entity/FocalLengthConfig.java b/device_gather/src/main/java/com/xr/device/model/entity/FocalLengthConfig.java new file mode 100644 index 0000000..31bab4e --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/entity/FocalLengthConfig.java @@ -0,0 +1,141 @@ +package com.xr.device.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDateTime; +import lombok.Data; + +/** + * + * @TableName focal_length_config + */ +@TableName(value ="focal_length_config") +@Data +public class FocalLengthConfig implements Serializable { + /** + * 主键 + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * 表计配置编号 + */ + private Integer configId; + + /** + * 焦距名称 + */ + private String focalName; + + /** + * 焦距tabs下标 + */ + private String focalIndex; + + /** + * 截图框宽 + */ + private Double copperWid; + + /** + * 截图框高 + */ + private Double copperHei; + + /** + * 截图框X坐标 + */ + private Double copperX; + + /** + * + */ + private Double copperX2; + + /** + * 截图框Y坐标 + */ + private Double copperY; + + /** + * + */ + private Double copperY2; + + /** + * 1指针表计,2数字表计,3状态类 + */ + private String configType; + + /** + * 指针最小值 + */ + private Double meterMin; + + /** + * 指针最大值 + */ + private Double meterMax; + + /** + * 旋转角度 + */ + private Integer rotate; + + /** + * 缩放倍数 + */ + private Double scale; + + /** + * 状态类状态数量 + */ + private Integer stateNum; + + /** + * 保存状态类多个状态的结果集 + */ + private String parameter; + + /** + * 解析得测试结果 + */ + private String result; + + /** + * 算法:0圆形表计1扇形表计 + */ + private Integer algorithm; + + /** + * 创建人 + */ + private String createUser; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 修改人 + */ + private String updateUser; + + /** + * 修改时间 + */ + private LocalDateTime updateTime; + + /** + * 焦距图片 + */ + private byte[] focalPicture; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/device_gather/src/main/java/com/xr/device/model/entity/MeterConfig.java b/device_gather/src/main/java/com/xr/device/model/entity/MeterConfig.java new file mode 100644 index 0000000..0e71519 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/entity/MeterConfig.java @@ -0,0 +1,180 @@ +package com.xr.device.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.util.Date; + +import lombok.Data; + +/** + * + * @TableName meter_config + */ +@TableName(value ="meter_config") +@Data +public class MeterConfig implements Serializable { + /** + * 主键 + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * ids5000表id + */ + private Integer ids5000Id; + + /** + * 间隔类型 1 分钟 2 小时 3 天 + */ + private Integer intervalType; + + /** + * 电压等级(1安全电压2低压3高压4超高压5特高压) + */ + private String voltageClass; + + /** + * 所属间隔 + */ + private String owningInterval; + + /** + * 识别间隔 + */ + private String identificationInterval; + + /** + * 所属设备 + */ + private String deviceName; + + /** + * y坐标 + */ + private Double locationY; + + /** + * x坐标 + */ + private Double locationX; + + /** + * 设备类型 + */ + private String deviceType; + + /** + * 表计编号 + */ + private String meterCode; + + /** + * 表计名称 + */ + private String meterName; + + /** + * 所属摄像头 + */ + private Integer cameraId; + + /** + * 告警最小值 + */ + private Double warningMax; + + /** + * 告警最大值 + */ + private Double warningMin; + + /** + * 表计类型配置编号 + */ + private Integer typeId; + + /** + * 状态(0停用1启用) + */ + private Integer status; + + /** + * 首次识别时间 + */ + private Date firstTime; + + /** + * 算法类型 1usb2mipi 3内部算法 + */ + private String algorithmType; + + /** + * 执行间隔时间 + */ + private Integer intervalTime; + + /** + * 焦距数量 + */ + private Integer focalNumber; + + /** + * 超参配置 + */ + private String parameterConfig; + + /** + * 备注 + */ + private String remarks; + + /** + * 61850读数模型 + */ + private String iec61850mx; + + /** + * 1校准 其他不校准 + */ + private Integer isJz; + + /** + * 校准值 + */ + private String jzVal; + + /** + * 0 未初始化 1已初始化 + */ + private String initStatus; + + /** + * 创建人 + */ + private String createUser; + + /** + * 创建时间 + */ + private Date createTime; + + /** + * 修改人 + */ + private String updateUser; + + /** + * 修改时间 + */ + private Date updateTime; + + @TableField(exist = false) + private String deviceIp; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/device_gather/src/main/java/com/xr/device/model/entity/MeterReadingRecord.java b/device_gather/src/main/java/com/xr/device/model/entity/MeterReadingRecord.java new file mode 100644 index 0000000..b18c701 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/entity/MeterReadingRecord.java @@ -0,0 +1,96 @@ +package com.xr.device.model.entity; + +import com.baomidou.mybatisplus.annotation.IdType; +import com.baomidou.mybatisplus.annotation.TableField; +import com.baomidou.mybatisplus.annotation.TableId; +import com.baomidou.mybatisplus.annotation.TableName; +import java.io.Serializable; +import java.time.LocalDateTime; +import lombok.Data; + +/** + * + * @TableName meter_reading_record + */ +@TableName(value ="meter_reading_record") +@Data +public class MeterReadingRecord implements Serializable { + /** + * 主键id + */ + @TableId(type = IdType.AUTO) + private Integer id; + + /** + * 表计id + */ + private Integer meterId; + + /** + * 表计编号 + */ + private String meterCode; + + /** + * 表计类型id + */ + private Integer meterTypeId; + + /** + * 表计类型名称 + */ + private String meterTypeName; + + /** + * 所属间隔 + */ + private String owningInterval; + + /** + * 读数时间 + */ + private LocalDateTime readingTime; + + /** + * 读数类型(1 一体化电源 2 AI摄像头 3 串口) + */ + private Integer readingType; + + /** + * 0 遥控 1遥信 2遥测 + */ + private Integer dataType; + + /** + * 读数值 + */ + private String readingValue; + + /** + * 表计照片 + */ + private String readingUrl; + + /** + * 创建人 + */ + private String createUser; + + /** + * 创建时间 + */ + private LocalDateTime createTime; + + /** + * 修改人 + */ + private String updateUser; + + /** + * 修改时间 + */ + private LocalDateTime updateTime; + + @TableField(exist = false) + private static final long serialVersionUID = 1L; +} \ No newline at end of file diff --git a/device_gather/src/main/java/com/xr/device/model/mapper/DeviceCameraMapper.java b/device_gather/src/main/java/com/xr/device/model/mapper/DeviceCameraMapper.java new file mode 100644 index 0000000..bf8070e --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/mapper/DeviceCameraMapper.java @@ -0,0 +1,20 @@ +package com.xr.device.model.mapper; + +import com.xr.device.model.entity.DeviceCamera; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* @author 范亚杰 +* @description 针对表【device_camera】的数据库操作Mapper +* @createDate 2024-06-25 17:30:54 +* @Entity com.xr.device.model.entity.DeviceCamera +*/ +@Mapper +public interface DeviceCameraMapper extends BaseMapper { + +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/model/mapper/FocalLengthConfigMapper.java b/device_gather/src/main/java/com/xr/device/model/mapper/FocalLengthConfigMapper.java new file mode 100644 index 0000000..8e5e2f3 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/mapper/FocalLengthConfigMapper.java @@ -0,0 +1,20 @@ +package com.xr.device.model.mapper; + +import com.xr.device.model.entity.FocalLengthConfig; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* @author 范亚杰 +* @description 针对表【focal_length_config】的数据库操作Mapper +* @createDate 2024-06-25 17:31:06 +* @Entity com.xr.device.model.entity.FocalLengthConfig +*/ +@Mapper +public interface FocalLengthConfigMapper extends BaseMapper { + +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/model/mapper/MeterConfigMapper.java b/device_gather/src/main/java/com/xr/device/model/mapper/MeterConfigMapper.java new file mode 100644 index 0000000..6de48f9 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/mapper/MeterConfigMapper.java @@ -0,0 +1,24 @@ +package com.xr.device.model.mapper; + +import com.xr.device.model.entity.MeterConfig; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +import java.util.List; + +/** +* @author 范亚杰 +* @description 针对表【meter_config】的数据库操作Mapper +* @createDate 2024-06-25 17:30:43 +* @Entity com.xr.device.model.entity.MeterConfig +*/ +@Mapper +public interface MeterConfigMapper extends BaseMapper { + + List getMeterList(); + +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/model/mapper/MeterReadingRecordMapper.java b/device_gather/src/main/java/com/xr/device/model/mapper/MeterReadingRecordMapper.java new file mode 100644 index 0000000..e85c5a7 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/mapper/MeterReadingRecordMapper.java @@ -0,0 +1,20 @@ +package com.xr.device.model.mapper; + +import com.xr.device.model.entity.MeterReadingRecord; +import com.baomidou.mybatisplus.core.mapper.BaseMapper; +import org.apache.ibatis.annotations.Mapper; + +/** +* @author 范亚杰 +* @description 针对表【meter_reading_record】的数据库操作Mapper +* @createDate 2024-06-25 17:30:30 +* @Entity com.xr.device.model.entity.MeterReadingRecord +*/ +@Mapper +public interface MeterReadingRecordMapper extends BaseMapper { + +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/model/service/DeviceCameraService.java b/device_gather/src/main/java/com/xr/device/model/service/DeviceCameraService.java new file mode 100644 index 0000000..a77b6bb --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/DeviceCameraService.java @@ -0,0 +1,13 @@ +package com.xr.device.model.service; + +import com.xr.device.model.entity.DeviceCamera; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author 范亚杰 +* @description 针对表【device_camera】的数据库操作Service +* @createDate 2024-06-25 17:30:54 +*/ +public interface DeviceCameraService extends IService { + +} diff --git a/device_gather/src/main/java/com/xr/device/model/service/FocalLengthConfigService.java b/device_gather/src/main/java/com/xr/device/model/service/FocalLengthConfigService.java new file mode 100644 index 0000000..67bf60f --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/FocalLengthConfigService.java @@ -0,0 +1,13 @@ +package com.xr.device.model.service; + +import com.xr.device.model.entity.FocalLengthConfig; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author 范亚杰 +* @description 针对表【focal_length_config】的数据库操作Service +* @createDate 2024-06-25 17:31:06 +*/ +public interface FocalLengthConfigService extends IService { + +} diff --git a/device_gather/src/main/java/com/xr/device/model/service/MeterConfigService.java b/device_gather/src/main/java/com/xr/device/model/service/MeterConfigService.java new file mode 100644 index 0000000..35618a5 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/MeterConfigService.java @@ -0,0 +1,17 @@ +package com.xr.device.model.service; + +import com.xr.device.model.entity.MeterConfig; +import com.baomidou.mybatisplus.extension.service.IService; + +import java.util.List; + +/** +* @author 范亚杰 +* @description 针对表【meter_config】的数据库操作Service +* @createDate 2024-06-25 17:30:43 +*/ +public interface MeterConfigService extends IService { + + List getMeterList(); + +} diff --git a/device_gather/src/main/java/com/xr/device/model/service/MeterReadingRecordService.java b/device_gather/src/main/java/com/xr/device/model/service/MeterReadingRecordService.java new file mode 100644 index 0000000..5adce52 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/MeterReadingRecordService.java @@ -0,0 +1,13 @@ +package com.xr.device.model.service; + +import com.xr.device.model.entity.MeterReadingRecord; +import com.baomidou.mybatisplus.extension.service.IService; + +/** +* @author 范亚杰 +* @description 针对表【meter_reading_record】的数据库操作Service +* @createDate 2024-06-25 17:30:30 +*/ +public interface MeterReadingRecordService extends IService { + +} diff --git a/device_gather/src/main/java/com/xr/device/model/service/impl/DeviceCameraServiceImpl.java b/device_gather/src/main/java/com/xr/device/model/service/impl/DeviceCameraServiceImpl.java new file mode 100644 index 0000000..100cfe0 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/impl/DeviceCameraServiceImpl.java @@ -0,0 +1,24 @@ +package com.xr.device.model.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.xr.device.model.entity.DeviceCamera; +import com.xr.device.model.service.DeviceCameraService; +import com.xr.device.model.mapper.DeviceCameraMapper; +import org.springframework.stereotype.Service; + +/** +* @author 范亚杰 +* @description 针对表【device_camera】的数据库操作Service实现 +* @createDate 2024-06-25 17:30:54 +*/ +@Service +@DS("db2") +public class DeviceCameraServiceImpl extends ServiceImpl + implements DeviceCameraService{ + +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/model/service/impl/FocalLengthConfigServiceImpl.java b/device_gather/src/main/java/com/xr/device/model/service/impl/FocalLengthConfigServiceImpl.java new file mode 100644 index 0000000..1ccbbd3 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/impl/FocalLengthConfigServiceImpl.java @@ -0,0 +1,24 @@ +package com.xr.device.model.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.xr.device.model.entity.FocalLengthConfig; +import com.xr.device.model.service.FocalLengthConfigService; +import com.xr.device.model.mapper.FocalLengthConfigMapper; +import org.springframework.stereotype.Service; + +/** +* @author 范亚杰 +* @description 针对表【focal_length_config】的数据库操作Service实现 +* @createDate 2024-06-25 17:31:06 +*/ +@Service +@DS("db2") +public class FocalLengthConfigServiceImpl extends ServiceImpl + implements FocalLengthConfigService{ + +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/model/service/impl/MeterConfigServiceImpl.java b/device_gather/src/main/java/com/xr/device/model/service/impl/MeterConfigServiceImpl.java new file mode 100644 index 0000000..2338b72 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/impl/MeterConfigServiceImpl.java @@ -0,0 +1,30 @@ +package com.xr.device.model.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.xr.device.model.entity.MeterConfig; +import com.xr.device.model.service.MeterConfigService; +import com.xr.device.model.mapper.MeterConfigMapper; +import org.springframework.stereotype.Service; + +import java.util.List; + +/** +* @author 范亚杰 +* @description 针对表【meter_config】的数据库操作Service实现 +* @createDate 2024-06-25 17:30:43 +*/ +@Service +@DS("db2") +public class MeterConfigServiceImpl extends ServiceImpl + implements MeterConfigService{ + + @Override + public List getMeterList() { + return ((MeterConfigMapper)this.baseMapper).getMeterList(); + } +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/model/service/impl/MeterReadingRecordServiceImpl.java b/device_gather/src/main/java/com/xr/device/model/service/impl/MeterReadingRecordServiceImpl.java new file mode 100644 index 0000000..deb8651 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/model/service/impl/MeterReadingRecordServiceImpl.java @@ -0,0 +1,24 @@ +package com.xr.device.model.service.impl; + +import com.baomidou.dynamic.datasource.annotation.DS; +import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; +import com.xr.device.model.entity.MeterReadingRecord; +import com.xr.device.model.service.MeterReadingRecordService; +import com.xr.device.model.mapper.MeterReadingRecordMapper; +import org.springframework.stereotype.Service; + +/** +* @author 范亚杰 +* @description 针对表【meter_reading_record】的数据库操作Service实现 +* @createDate 2024-06-25 17:30:30 +*/ +@Service +@DS("db2") +public class MeterReadingRecordServiceImpl extends ServiceImpl + implements MeterReadingRecordService{ + +} + + + + diff --git a/device_gather/src/main/java/com/xr/device/schedule/GetMeterSchedule.java b/device_gather/src/main/java/com/xr/device/schedule/GetMeterSchedule.java new file mode 100644 index 0000000..b540ff2 --- /dev/null +++ b/device_gather/src/main/java/com/xr/device/schedule/GetMeterSchedule.java @@ -0,0 +1,26 @@ +package com.xr.device.schedule; + +import com.xr.device.model.entity.MeterConfig; +import com.xr.device.model.service.FocalLengthConfigService; +import com.xr.device.model.service.MeterConfigService; +import lombok.RequiredArgsConstructor; +import org.springframework.scheduling.annotation.Scheduled; +import org.springframework.stereotype.Component; + +import java.util.List; + +@Component +@RequiredArgsConstructor +public class GetMeterSchedule { + + private final MeterConfigService meterConfigService; + + private final FocalLengthConfigService focalLengthConfigService; + + @Scheduled(cron = "0 0 0/3 * * ?") + public void getMeterSchedule(){ + List configs = meterConfigService.getMeterList(); + + } + +} diff --git a/device_gather/src/main/resources/application-dev.yml b/device_gather/src/main/resources/application-dev.yml new file mode 100644 index 0000000..7130e22 --- /dev/null +++ b/device_gather/src/main/resources/application-dev.yml @@ -0,0 +1,80 @@ +server: + port: 8085 + servlet: + context-path: /cars-api + #context-path: / + +spring: + datasource: + dynamic: + primary: db1 + strict: false + datasource: + db1: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mysql://116.196.120.81:3306/device_system?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 5ea47c0bdd7146ebbd53020eca@672307 + db2: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 5ea47c0bdd7146ebbd53020eca@672307 + #Hikari连接池配置 + hikari: + #池中维护的最小空闲连接数 + minimum-idle: 5 + #池中最大连接数,包括闲置和使用中的连接 + maximum-pool-size: 15 + #自动提交从池中返回的连接 + auto-commit: true + #连接允许在池中闲置的最长时间 + idle-timeout: 30000 + #连接池的用户定义名称,主要出现在日志记录和JMX管理控制台中以识别池和池配置 + pool-name: DatebookHikariCP + #池中连接最长生命周期 + max-lifetime: 18000000 + #等待来自池的连接的最大毫秒数 + connection-timeout: 30000 + #验证该连接是否是有效的查询语句 + connection-test-query: select 1 from dual + cloud: + inetutils: + timeout-seconds: 1000 + config: + enabled: false + # redis 相关 + redis: + host: ${REDIS_URL:localhost} + port: ${REDIS_PORT:6379} + password: ${REDIS_PWD:111111} + timeout: 10000 + jedis: + pool: + max-active: 1000 + max-wait: -1ms + max-idle: 10 + min-idle: 5 +swagger: + show: true +analysis: + url: http://192.168.1.123:9000/vi/syncrec + +upload: + img: + url: http://192.168.1.83:18081/file/img/zs/ + path: D:\\service\\fileService\\img\\zs\\ +python: + path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe + modelPath: D:\\smartGrid\\smartGrid\\models +eureka: + instance: + instance-id: ${spring.cloud.client.ip-address}:${server.port} + prefer-ip-address: true + client: + healthcheck: + enabled: true + service-url: + defaultZone: http://localhost:8084/eureka \ No newline at end of file diff --git a/device_gather/src/main/resources/application-prod.yml b/device_gather/src/main/resources/application-prod.yml new file mode 100644 index 0000000..7130e22 --- /dev/null +++ b/device_gather/src/main/resources/application-prod.yml @@ -0,0 +1,80 @@ +server: + port: 8085 + servlet: + context-path: /cars-api + #context-path: / + +spring: + datasource: + dynamic: + primary: db1 + strict: false + datasource: + db1: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mysql://116.196.120.81:3306/device_system?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 5ea47c0bdd7146ebbd53020eca@672307 + db2: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mysql://116.196.120.81:3306/image_analysis_zs?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 5ea47c0bdd7146ebbd53020eca@672307 + #Hikari连接池配置 + hikari: + #池中维护的最小空闲连接数 + minimum-idle: 5 + #池中最大连接数,包括闲置和使用中的连接 + maximum-pool-size: 15 + #自动提交从池中返回的连接 + auto-commit: true + #连接允许在池中闲置的最长时间 + idle-timeout: 30000 + #连接池的用户定义名称,主要出现在日志记录和JMX管理控制台中以识别池和池配置 + pool-name: DatebookHikariCP + #池中连接最长生命周期 + max-lifetime: 18000000 + #等待来自池的连接的最大毫秒数 + connection-timeout: 30000 + #验证该连接是否是有效的查询语句 + connection-test-query: select 1 from dual + cloud: + inetutils: + timeout-seconds: 1000 + config: + enabled: false + # redis 相关 + redis: + host: ${REDIS_URL:localhost} + port: ${REDIS_PORT:6379} + password: ${REDIS_PWD:111111} + timeout: 10000 + jedis: + pool: + max-active: 1000 + max-wait: -1ms + max-idle: 10 + min-idle: 5 +swagger: + show: true +analysis: + url: http://192.168.1.123:9000/vi/syncrec + +upload: + img: + url: http://192.168.1.83:18081/file/img/zs/ + path: D:\\service\\fileService\\img\\zs\\ +python: + path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe + modelPath: D:\\smartGrid\\smartGrid\\models +eureka: + instance: + instance-id: ${spring.cloud.client.ip-address}:${server.port} + prefer-ip-address: true + client: + healthcheck: + enabled: true + service-url: + defaultZone: http://localhost:8084/eureka \ No newline at end of file diff --git a/device_gather/src/main/resources/application.yml b/device_gather/src/main/resources/application.yml new file mode 100644 index 0000000..1d8bf05 --- /dev/null +++ b/device_gather/src/main/resources/application.yml @@ -0,0 +1,82 @@ +spring: + profiles: + #active: dev #开发环境 + # active: test #测试环境5 + active: dev #生产环境 + # active: prod #生产环境 + application: + name: gather + + devtools: + restart: + log-condition-evaluation-delta: false + security: + user: + name: admin + password: admin + servlet: + multipart: + max-file-size: 500MB + max-request-size: 500MB + jackson: + date-format: yyyy-MM-dd + time-zone: GMT+8 + default-property-inclusion: non_null +mybatis-plus: + mapper-locations: classpath:mapper/*Mapper.xml + type-aliases-package: com.xr.device + # 在查询语句的是否,对Map或者是entity进行映射赋值的时候null也进行映射。默认false,不进行映射 + configuration: + map-underscore-to-camel-case: true + call-setters-on-nulls: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + # 设置更新或者修改的时候的策略,不进行校验,否则如果是null则不会进行更新或者插入,当然在@TableField注解进行指定单个字段 + global-config: + db-config: + insert-strategy: ignored + update-strategy: ignored +logging: + level: + root: info + com.xr: debug + org: + springframework: + boot: + autoconfigure: error + +### Ribbon 配置 +ribbon: + # 连接超时 + ConnectTimeout: 100000 + # 响应超时 + ReadTimeout: 100000 +### Feign 配置 +feign: + # 开启断路器(熔断器) + hystrix: + enabled: true +### Hystrix 配置 +hystrix: + # 这样将会自动配置一个 Hystrix 并发策略插件的 hook,这个 hook 会将 SecurityContext 从主线程传输到 Hystrix 的命令。 + # 因为 Hystrix 不允许注册多个 Hystrix 策略,所以可以声明 HystrixConcurrencyStrategy + # 为一个 Spring bean 来实现扩展。Spring Cloud 会在 Spring 的上下文中查找你的实现,并将其包装在自己的插件中。 + shareSecurityContext: true + command: + default: + circuitBreaker: + # 当在配置时间窗口内达到此数量的失败后,进行短路。默认20个 + requestVolumeThreshold: 100 + # 触发短路的时间值,当该值设为5000时,则当触发 circuit break 后的5000毫秒内都会拒绝request + # 也就是5000毫秒后才会关闭circuit。默认5000 + sleepWindowInMilliseconds: 5000 + # 强制打开熔断器,如果打开这个开关,那么拒绝所有request,默认false + forceOpen: false + # 强制关闭熔断器 如果这个开关打开,circuit将一直关闭且忽略,默认false + forceClosed: false + execution: + isolation: + thread: + # 熔断器超时时间,默认:1000/毫秒 + timeoutInMilliseconds: 20000 + + diff --git a/device_gather/src/main/resources/banner.txt b/device_gather/src/main/resources/banner.txt new file mode 100644 index 0000000..1b8480c --- /dev/null +++ b/device_gather/src/main/resources/banner.txt @@ -0,0 +1,23 @@ +================================================================== +// _ooOoo_ // +// o8888888o // +// 88" . "88 // +// (| ^_^ |) // +// O\ = /O // +// ____/`---'\____ // +// .' \\| |// `. // +// / \\||| : |||// \ // +// / _||||| -:- |||||- \ // +// | | \\\ - /// | | // +// | \_| ''\---/'' | | // +// \ .-\__ `-` ___/-. / // +// ___`. .' /--.--\ `. . ___ // +// ."" '< `.___\_<|>_/___.' >'"". // +// | | : `- \`.;`\ _ /`;.`/ - ` : | | // +// \ \ `-. \_ __\ /__ _/ .-` / / // +// ========`-.____`-.___\_____/___.-`____.-'======== // +// `=---=' // +// ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ // +// 佛祖保佑 永不宕机 永无BUG // + \\\\ //// + ============================================================= \ No newline at end of file diff --git a/device_gather/src/main/resources/logback.xml b/device_gather/src/main/resources/logback.xml new file mode 100644 index 0000000..05ba33e --- /dev/null +++ b/device_gather/src/main/resources/logback.xml @@ -0,0 +1,51 @@ + + + + + + + + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + + + + + + ${LOG_HOME}/deviceCar.log.%d{yyyy-MM-dd}.log + + 30 + + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + + + + 10MB + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/device_gather/src/main/resources/mapper/DeviceCameraMapper.xml b/device_gather/src/main/resources/mapper/DeviceCameraMapper.xml new file mode 100644 index 0000000..7758a04 --- /dev/null +++ b/device_gather/src/main/resources/mapper/DeviceCameraMapper.xml @@ -0,0 +1,40 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id,device_no,device_type, + device_ip,device_port,account, + password,x,y, + z,device_model,position, + brand,remarks,status, + create_user,create_time,update_user, + update_time,transmission_interval,warmup + + diff --git a/device_gather/src/main/resources/mapper/FocalLengthConfigMapper.xml b/device_gather/src/main/resources/mapper/FocalLengthConfigMapper.xml new file mode 100644 index 0000000..57aeaf0 --- /dev/null +++ b/device_gather/src/main/resources/mapper/FocalLengthConfigMapper.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id,config_id,focal_name, + focal_index,copper_wid,copper_hei, + copper_x,copper_x2,copper_y, + copper_y2,config_type,meter_min, + meter_max,rotate,scale, + state_num,parameter,result, + algorithm,create_user,create_time, + update_user,update_time,focal_picture + + diff --git a/device_gather/src/main/resources/mapper/MeterConfigMapper.xml b/device_gather/src/main/resources/mapper/MeterConfigMapper.xml new file mode 100644 index 0000000..b1dc5f9 --- /dev/null +++ b/device_gather/src/main/resources/mapper/MeterConfigMapper.xml @@ -0,0 +1,59 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + id,ids5000_id,interval_type, + voltage_class,owning_interval,identification_interval, + device_name,location_y,location_x, + device_type,meter_code,meter_name, + camera_id,warning_max,warning_min, + type_id,status,first_time, + algorithm_type,interval_time,focal_number, + parameter_config,remarks,iec61850mx, + is_jz,jz_val,init_status, + create_user,create_time,update_user, + update_time + + + + diff --git a/device_gather/src/main/resources/mapper/MeterReadingRecordMapper.xml b/device_gather/src/main/resources/mapper/MeterReadingRecordMapper.xml new file mode 100644 index 0000000..e2a466c --- /dev/null +++ b/device_gather/src/main/resources/mapper/MeterReadingRecordMapper.xml @@ -0,0 +1,32 @@ + + + + + + + + + + + + + + + + + + + + + + + + id,meter_id,meter_code, + meter_type_id,meter_type_name,owning_interval, + reading_time,reading_type,data_type, + reading_value,reading_url,create_user, + create_time,update_user,update_time + + diff --git a/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ValueFormatUtil.java b/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ValueFormatUtil.java new file mode 100644 index 0000000..b2b8416 --- /dev/null +++ b/device_iec61850clent/src/main/java/com/xr/iec61850clent/common/util/ValueFormatUtil.java @@ -0,0 +1,31 @@ +package com.xr.iec61850clent.common.util; + +import com.xr.iec61850clent.models.entity.MeterConfig; +import com.xr.iec61850clent.models.service.MeterConfigService; + +public class ValueFormatUtil { + + /* + * 处理AI分析的计数器数值,针对可以识别到,但偶尔有错误结果出现的情况 + * 1.抄写基准值 + * 2.与基准值比较,如果比基准值大于1,可能计数器跳1,更新基准值,并返回结果 + * 反之返回基准值结果为识别结果 + * 3.如果未设基准值,去0后保存结果 + * */ + public static String getNumBerJx(float getVal,MeterConfig config, MeterConfigService meterConfigService){ + int s = (int) getVal; + Integer jz = Integer.valueOf(config.getJzVal())+1; + if(StringUtils.isNotEmpty(config.getJzVal())){ + if(s==jz){ + config.setJzVal(jz+""); + meterConfigService.updateById(config); + return jz+""; + }else{ + return config.getJzVal(); + } + }else{ + return s+""; + } + } + +} diff --git a/device_iec61850clent/src/main/java/com/xr/iec61850clent/models/iec61850run/Iec61850Scheduled.java b/device_iec61850clent/src/main/java/com/xr/iec61850clent/models/iec61850run/Iec61850Scheduled.java index f9b09b8..55bfae1 100644 --- a/device_iec61850clent/src/main/java/com/xr/iec61850clent/models/iec61850run/Iec61850Scheduled.java +++ b/device_iec61850clent/src/main/java/com/xr/iec61850clent/models/iec61850run/Iec61850Scheduled.java @@ -3,9 +3,7 @@ package com.xr.iec61850clent.models.iec61850run; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.beanit.iec61850bean.*; import com.beanit.iec61850bean.internal.cli.*; -import com.xr.iec61850clent.common.util.ModeUtil; -import com.xr.iec61850clent.common.util.SpringUtils; -import com.xr.iec61850clent.common.util.UploadUtil; +import com.xr.iec61850clent.common.util.*; import com.xr.iec61850clent.models.entity.*; import com.xr.iec61850clent.models.service.*; import org.springframework.scheduling.annotation.Scheduled; @@ -28,7 +26,7 @@ public class Iec61850Scheduled { private int conner =0; String[] args = new String[] {"param1", "param2", "param3"}; - @Scheduled(cron = "0 0/1 * * * ?")//每10分钟执行一次 + @Scheduled(cron = "0 0 9,15 * * ?")//每天9点和下午三点执行 public void run(){ StringCliParameter hostParam = new CliParameterBuilder("-h") .setDescription("要访问的服务器的IP域地址。").buildStringParameter("host","192.168.1.93"); IntCliParameter portParam = new CliParameterBuilder("-p").setDescription("要连接的端口。").buildIntParameter("port", 102); @@ -133,9 +131,6 @@ public class Iec61850Scheduled { if(lds5000==null){ continue; } - if(lds5000.getClentIp().equals("192.168.1.57")){ - System.out.println("-----------------------"); - } QueryWrapper queryWrapper=new QueryWrapper<>(); queryWrapper.eq("node",lds5000.getNode()); queryWrapper.eq("clent_ip","192.168.1.93"); @@ -159,13 +154,22 @@ public class Iec61850Scheduled { if(node.getFc().name().equals("MX")){ String value = "0"; float f = Float.valueOf(lds5000.getF()); - if(config.getTypeId() == 3 || config.getTypeId() == 5 || config.getTypeId() == 7){//油位计,保留2位小数 - value = String.format("%.2f", f); + if(config.getTypeId() == 5 || config.getTypeId() == 7){ + if(f ==0 && StringUtils.isNotEmpty(config.getJzVal())){ + value = config.getJzVal(); + }else{ + value = String.format("%.2f", f); + } + } + if(config.getTypeId() == 3 ){ + if((f == 0 || f>1)&& StringUtils.isNotEmpty(config.getJzVal())){ + value = config.getJzVal(); + }else{ + value = String.format("%.2f", f*100)+"%"; + } } if(config.getTypeId() == 4 || config.getTypeId() == 11){//开关计数器 - //处理为整数 - int s = (int) f; - value = s+""; + value= ValueFormatUtil.getNumBerJx(f,config,meterConfigService); } if(config.getTypeId() == 8){//档位数据处理 //处理为整数 @@ -195,6 +199,8 @@ public class Iec61850Scheduled { int s = Math.round(f); if(s>=10){ value = 0+""; + }else { + value = s+""; } } if(config.getIsJz() == 1){ @@ -216,10 +222,7 @@ public class Iec61850Scheduled { meterReadingRecord.setReadingUrl(url1); meterReadingRecord.setMeterTypeId(config.getTypeId()); meterReadingRecord.setOwningInterval(config.getOwningInterval()); - if(config.getIsJz()!=1){ - meterReadingRecordService.save(meterReadingRecord); - } - //abnormalReadingJudgment(meterReadingRecord); + meterReadingRecordService.save(meterReadingRecord); } }else{ lds5000.setCreateTime(new Date()); diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/Files.java b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/Files.java index 7a969ff..935b0e7 100644 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/Files.java +++ b/device_udpclent/src/main/java/com/xr/device_udpclent/common/utils/Files.java @@ -103,10 +103,11 @@ public class Files { String year = dates[0]; String month = dates[1]; String day = dates[2]; - String fullPath = StaticPropUtil.imagePath + configId + File.separator + year + File.separator + month + File.separator + day + File.separator + fileName; - + //String fullPath = StaticPropUtil.imagePath + configId + File.separator + year + File.separator + month + File.separator + day + File.separator + fileName; + String fullPath = StaticPropUtil.imagePath + File.separator + fileName; // 创建目录结构 - Path directoryPath = Paths.get(StaticPropUtil.imagePath, configId.toString(), year, month, day); + //Path directoryPath = Paths.get(StaticPropUtil.imagePath, configId.toString(), year, month, day); + Path directoryPath = Paths.get(StaticPropUtil.imagePath); if (!java.nio.file.Files.exists(directoryPath)) { java.nio.file.Files.createDirectories(directoryPath); } diff --git a/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/UdpClentScheduled.java b/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/UdpClentScheduled.java index 3a15938..f5f1345 100644 --- a/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/UdpClentScheduled.java +++ b/device_udpclent/src/main/java/com/xr/device_udpclent/models/scheduled/UdpClentScheduled.java @@ -43,18 +43,29 @@ public class UdpClentScheduled { private MeterConfigService meterConfigService; - @Scheduled(cron = "0 0/1 * * * ?") + @Scheduled(cron = "0 0/3 * * * ?") //定时发送监测数据 public void udpTask(){ if(meterReadingRecordService == null){ meterReadingRecordService = SpringUtil.getBean(MeterReadingRecordService.class); } - List list = meterReadingRecordService.selectMaxReading(); - for (MeterReadingRecord record:list){ +// List list = meterReadingRecordService.selectMaxReading(); +// for (MeterReadingRecord record:list){ // QueryWrapper wrapper=new QueryWrapper<>(); // wrapper.eq("config_id",record.getMeterId()); // List configs=focalLengthConfigService.list(wrapper); // if(configs.size()>0){ + List configs = focalLengthConfigService.list(); + for (FocalLengthConfig config:configs) { + if(config.getFocalIndex()!=null){ + BufferedImage image = Files.bytesTobufferedImage(config.getFocalPicture()); + try { + Files.uploadImage(image,config.getConfigId()); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + } // FocalLengthConfig config = configs.get(0); // MeterConfig meterConfig=meterConfigService.getById(config.getConfigId()); // BufferedImage image = Files.bytesTobufferedImage(config.getFocalPicture()); @@ -69,57 +80,57 @@ public class UdpClentScheduled { // e.printStackTrace(); // } // } + // } +// ByteBuf buf = Unpooled.buffer(); +// ByteBuf checksumBuffer = Unpooled.buffer(Long.BYTES); +// buf.writeBytes(new byte[]{(byte) 0xEB, (byte) 0x90,(byte) 0xEB, (byte) 0x90,(byte)0x78}); +// buf.writeShortLE(3); +// buf.writeShort(record.getMeterId()); +// buf.writeByte(2); +// String s="在线监测#"+record.getReadingUrl(); +// byte [] sx; +// try { +// sx = s.getBytes("GB2312"); +// } catch (UnsupportedEncodingException e) { +// throw new RuntimeException(e); // } - ByteBuf buf = Unpooled.buffer(); - ByteBuf checksumBuffer = Unpooled.buffer(Long.BYTES); - buf.writeBytes(new byte[]{(byte) 0xEB, (byte) 0x90,(byte) 0xEB, (byte) 0x90,(byte)0x78}); - buf.writeShortLE(3); - buf.writeShort(record.getMeterId()); - buf.writeByte(2); - String s="在线监测#"+record.getReadingUrl(); - byte [] sx; - try { - sx = s.getBytes("GB2312"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - buf.writeByte(sx.length); - buf.writeBytes(sx); - byte [] sz; - try { - sz = record.getReadingValue().getBytes("GB2312"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException(e); - } - buf.writeByte(sz.length); - buf.writeBytes(sz); - buf.writeBytes(generateCP56Time2a()); - - // 计算要校验的部分的开始索引和结束索引 - byte c = 0; - int startIndex = 5; // 从第6位开始,索引是5(因为索引从0开始) - int endIndex = buf.readableBytes() - 1; // 到倒数第二位结束 - // 截取并处理指定范围内的字节 - if (startIndex <= endIndex) { - // 临时存放截取的字节 - byte[] slice = new byte[endIndex - startIndex + 1]; - // 从ByteBuf中获取数据 - buf.getBytes(startIndex, slice); - c=checksum8(slice); - // 更新Checksum对象 - //checksum.update(slice, 0, slice.length); - } - buf.writeByte(c); - // 将checksumBuffer追加到buffer末尾 - buf.writeBytes(checksumBuffer); - System.out.println(EnumUtil.byteBufTo16Str(buf)); - udpClientService.sendData(buf); - try { - Thread.sleep(100); - } catch (InterruptedException e) { - throw new RuntimeException(e); - } - } +// buf.writeByte(sx.length); +// buf.writeBytes(sx); +// byte [] sz; +// try { +// sz = record.getReadingValue().getBytes("GB2312"); +// } catch (UnsupportedEncodingException e) { +// throw new RuntimeException(e); +// } +// buf.writeByte(sz.length); +// buf.writeBytes(sz); +// buf.writeBytes(generateCP56Time2a()); +// +// // 计算要校验的部分的开始索引和结束索引 +// byte c = 0; +// int startIndex = 5; // 从第6位开始,索引是5(因为索引从0开始) +// int endIndex = buf.readableBytes() - 1; // 到倒数第二位结束 +// // 截取并处理指定范围内的字节 +// if (startIndex <= endIndex) { +// // 临时存放截取的字节 +// byte[] slice = new byte[endIndex - startIndex + 1]; +// // 从ByteBuf中获取数据 +// buf.getBytes(startIndex, slice); +// c=checksum8(slice); +// // 更新Checksum对象 +// //checksum.update(slice, 0, slice.length); +// } +// buf.writeByte(c); +// // 将checksumBuffer追加到buffer末尾 +// buf.writeBytes(checksumBuffer); +// System.out.println(EnumUtil.byteBufTo16Str(buf)); +// udpClientService.sendData(buf); +// try { +// Thread.sleep(100); +// } catch (InterruptedException e) { +// throw new RuntimeException(e); +// } +// } } diff --git a/device_udpclent/src/main/resources/application-sn.yml b/device_udpclent/src/main/resources/application-sn.yml new file mode 100644 index 0000000..ba10faf --- /dev/null +++ b/device_udpclent/src/main/resources/application-sn.yml @@ -0,0 +1,107 @@ +server: + port: 8091 + servlet: + context-path: /api +spring: + datasource: + dynamic: + primary: db1 + strict: false + datasource: + db1: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mysql://116.196.120.81:3306/device_system?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 5ea47c0bdd7146ebbd53020eca@672307 + db2: + driver-class-name: com.mysql.cj.jdbc.Driver + type: com.zaxxer.hikari.HikariDataSource + url: jdbc:mysql://116.196.120.81:3306/image_analysis?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&allowMultiQueries=true&serverTimezone=Asia/Shanghai&useSSL=false + username: root + password: 5ea47c0bdd7146ebbd53020eca@672307 + #Hikari连接池配置 + hikari: + #池中维护的最小空闲连接数 + minimum-idle: 5 + #池中最大连接数,包括闲置和使用中的连接 + maximum-pool-size: 15 + #自动提交从池中返回的连接 + auto-commit: true + #连接允许在池中闲置的最长时间 + idle-timeout: 30000 + #连接池的用户定义名称,主要出现在日志记录和JMX管理控制台中以识别池和池配置 + pool-name: DatebookHikariCP + #池中连接最长生命周期 + max-lifetime: 18000000 + #等待来自池的连接的最大毫秒数 + connection-timeout: 30000 + #验证该连接是否是有效的查询语句 + connection-test-query: select 1 from dual + cloud: + inetutils: + timeout-seconds: 1000 + config: + enabled: false + stream: + kafka: + binder: + brokers: localhost:9092 #Kafka的消息中间件服务器 + zk-nodes: localhost:2181 #Zookeeper的节点,如果集群,后面加,号分隔 + auto-create-topics: false #如果设置为false,就不会自动创建Topic 有可能你Topic还没创建就直接调用了。 +# kafka: +# bootstrap-servers: localhost:9092 +# consumer: +# group-id: ai-consumer-group +#kafka: +# topic: ai-topic +# # redis 相关 +# redis: +# host: ${REDIS_URL:localhost} +# port: ${REDIS_PORT:6379} +# password: ${REDIS_PWD:111111} +# timeout: 10000 +# jedis: +# pool: +# max-active: 1000 +# max-wait: -1ms +# max-idle: 10 +# min-idle: 5 +mybatis-plus: + mapper-locations: classpath:mapper/*Mapper.xml + type-aliases-package: com.xr.device_udpclent + # 在查询语句的是否,对Map或者是entity进行映射赋值的时候null也进行映射。默认false,不进行映射 + configuration: + map-underscore-to-camel-case: true + call-setters-on-nulls: true + log-impl: org.apache.ibatis.logging.stdout.StdOutImpl + # 设置更新或者修改的时候的策略,不进行校验,否则如果是null则不会进行更新或者插入,当然在@TableField注解进行指定单个字段 + global-config: + db-config: + insert-strategy: ignored + update-strategy: ignored +logging: + org: + springframework: + boot: + autoconfigure: + logging: debug +udp: + server: + host: 172.26.4.59 + port: 9300 +upLoad: + url: http://192.168.1.83:18081/file/img/zs/ + path: D:\\service\\fileService\\img\\sn\\ +python: + path: C:\\Users\\admin\\Anaconda3\\envs\\myconda310\\python.exe + modelPath: D:\\smartGrid\\smartGrid\\models +eureka: + instance: + instance-id: ${spring.cloud.client.ip-address}:${server.port} + prefer-ip-address: true + client: + healthcheck: + enabled: true + service-url: + defaultZone: http://localhost:8084/eureka \ No newline at end of file diff --git a/device_udpclent/src/main/resources/application.yml b/device_udpclent/src/main/resources/application.yml index 9fd79d5..35321a2 100644 --- a/device_udpclent/src/main/resources/application.yml +++ b/device_udpclent/src/main/resources/application.yml @@ -1,6 +1,6 @@ spring: profiles: - active: prod #开发环境 + active: sn #开发环境 # active: test #测试环境5 #active: prod #生产环境 application: diff --git a/pom.xml b/pom.xml index de6c445..315907c 100644 --- a/pom.xml +++ b/pom.xml @@ -19,6 +19,7 @@ device_gateway device_udpclent device_udpserver + device_gather