Browse Source

/*红外对接问题统一修改*/

master
htjcAdmin 8 months ago
parent
commit
2366d547be
10 changed files with 770 additions and 373 deletions
  1. +6
    -9
      src/main/java/com/inspect/simulator/controller/InfraredController.java
  2. +0
    -16
      src/main/java/com/inspect/simulator/domain/Infrared/Coordinate.java
  3. +35
    -0
      src/main/java/com/inspect/simulator/domain/Infrared/InfraPictureInfo.java
  4. +113
    -0
      src/main/java/com/inspect/simulator/domain/basedata/BasedataEqpBook.java
  5. +68
    -0
      src/main/java/com/inspect/simulator/domain/basedata/BasedataEqpBookChannel.java
  6. +26
    -0
      src/main/java/com/inspect/simulator/mapper/BasedataEqpBookChannelMapper.java
  7. +3
    -6
      src/main/java/com/inspect/simulator/service/HikVisionService.java
  8. +326
    -341
      src/main/java/com/inspect/simulator/service/impl/HikVisionServiceImpl.java
  9. +1
    -1
      src/main/java/com/inspect/simulator/utils/sftp/SftpClient.java
  10. +192
    -0
      src/main/resources/mapper/metadata/BasedataEqpBookChannelMapper.xml

+ 6
- 9
src/main/java/com/inspect/simulator/controller/InfraredController.java View File

@ -1,9 +1,6 @@
package com.inspect.simulator.controller;
import com.inspect.simulator.domain.Infrared.Camera;
import com.inspect.simulator.domain.Infrared.Coordinate;
import com.inspect.simulator.domain.Infrared.InfraredInfo;
import com.inspect.simulator.domain.Infrared.NvrInfo;
import com.inspect.simulator.domain.Infrared.*;
import com.inspect.simulator.service.HikVisionService;
import com.inspect.simulator.hikVision.utils.AjaxResult;
import org.springframework.beans.factory.annotation.Autowired;
@ -48,16 +45,16 @@ public class InfraredController {
//图谱解析
@PostMapping("/ir/capturePicture")
@ResponseBody
public AjaxResult capturePicture(@RequestBody Coordinate coordinate) {
public AjaxResult capturePicture(@RequestBody InfraPictureInfo infraPictureInfo) {
return hikVisionService.capturePicture(coordinate);
return hikVisionService.capturePicture(infraPictureInfo);
}
//图谱解析
@PostMapping("/ir/calculate/capturePicture")
@PostMapping("/ir/calculatePicture")
@ResponseBody
public AjaxResult calculatePicture(@RequestBody Coordinate coordinate) {
public AjaxResult calculatePicture(@RequestBody InfraPictureInfo infraPictureInfo) {
return hikVisionService.calculatePicture(coordinate);
return hikVisionService.calculatePicture(infraPictureInfo);
}
}

+ 0
- 16
src/main/java/com/inspect/simulator/domain/Infrared/Coordinate.java View File

@ -8,25 +8,9 @@ import lombok.NoArgsConstructor;
@NoArgsConstructor
@AllArgsConstructor
public class Coordinate {
private String channelCode;
//点一坐标
private Integer firstX;
private Integer firstY;
//点二坐标
private Integer secondX;
private Integer secondY;
private String filePath;
//图片宽
private Integer imgWidth;
//图片高
private Integer imgHeight;
private Coordinate[] coordinates;
//红外图片类型 1-NVR;2-IVS;3-无人机
private Integer imgType;
}

+ 35
- 0
src/main/java/com/inspect/simulator/domain/Infrared/InfraPictureInfo.java View File

@ -0,0 +1,35 @@
package com.inspect.simulator.domain.Infrared;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.List;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class InfraPictureInfo {
private Long channelId;
private String channelCode;
//点一坐标
private Integer firstX;
private Integer firstY;
//点二坐标
private Integer secondX;
private Integer secondY;
private String filePath;
//图片宽
private Integer imgWidth;
//图片高
private Integer imgHeight;
private List<Coordinate> coordinates;
//红外图片类型 1-NVR;2-IVS;3-无人机
private Integer imgType;
}

+ 113
- 0
src/main/java/com/inspect/simulator/domain/basedata/BasedataEqpBook.java View File

@ -0,0 +1,113 @@
package com.inspect.simulator.domain.basedata;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.inspect.simulator.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
import java.util.List;
@Setter
@Getter
public class BasedataEqpBook extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long eqpBookId;
private String stationName;
private String stationCode;
private Long areaId;
private String areaName;
private String patrolDeviceName;
private String patrolDeviceCode;
private String deviceModel;
private String manufacturer;
private String useUnit;
private String deviceSource;
private String productionDate;
private String productionCode;
private String isTransport;
private String useMode;
private String videoMode;
private String place;
private String positionX;
private String positionY;
private String positionZ;
private String type;
private String patrolDeviceInfo;
private String robotsCode;
private String ipAddr;
private String port;
private String user;
private String password;
private String delFlag;
private String mainSystemCode;
private String mapFilePath;
private String videoNvrCode;
@Override
public String toString() {
return "BasedataEqpBook{" +
"eqpBookId=" + eqpBookId +
", stationName='" + stationName + '\'' +
", stationCode='" + stationCode + '\'' +
", areaId=" + areaId +
", areaName='" + areaName + '\'' +
", patrolDeviceName='" + patrolDeviceName + '\'' +
", patrolDeviceCode='" + patrolDeviceCode + '\'' +
", deviceModel='" + deviceModel + '\'' +
", manufacturer='" + manufacturer + '\'' +
", useUnit='" + useUnit + '\'' +
", deviceSource='" + deviceSource + '\'' +
", productionDate='" + productionDate + '\'' +
", productionCode='" + productionCode + '\'' +
", isTransport='" + isTransport + '\'' +
", useMode='" + useMode + '\'' +
", videoMode='" + videoMode + '\'' +
", place='" + place + '\'' +
", positionX='" + positionX + '\'' +
", positionY='" + positionY + '\'' +
", positionZ='" + positionZ + '\'' +
", type='" + type + '\'' +
", patrolDeviceInfo='" + patrolDeviceInfo + '\'' +
", robotsCode='" + robotsCode + '\'' +
", ipAddr='" + ipAddr + '\'' +
", port='" + port + '\'' +
", user='" + user + '\'' +
", password='" + password + '\'' +
", delFlag='" + delFlag + '\'' +
", mainSystemCode='" + mainSystemCode + '\'' +
", mapFilePath='" + mapFilePath + '\'' +
", videoNvrCode='" + videoNvrCode + '\'' +
'}';
}
}

+ 68
- 0
src/main/java/com/inspect/simulator/domain/basedata/BasedataEqpBookChannel.java View File

@ -0,0 +1,68 @@
package com.inspect.simulator.domain.basedata;
import com.inspect.simulator.domain.BaseEntity;
import lombok.Getter;
import lombok.Setter;
@Setter
@Getter
public class BasedataEqpBookChannel extends BaseEntity {
private static final long serialVersionUID = 1L;
private Long channelId;
private String channelCode;
private String channelName;
private String parentChannelId;
private Long eqpBookId;
private String eqpBookName;
private String channelType;
private String onlineState;
private String channelContent;
private String provider;
private String address;
private String host;
private String port;
private String deleteFlag;
private String patrolDeviceCode;
private String username;
private String password;
private String deviceSource;
@Override
public String toString() {
return "BasedataEqpBookChannel{" +
"channelId=" + channelId +
", channelCode='" + channelCode + '\'' +
", channelName='" + channelName + '\'' +
", parentChannelId='" + parentChannelId + '\'' +
", eqpBookId=" + eqpBookId +
", eqpBookName='" + eqpBookName + '\'' +
", channelType='" + channelType + '\'' +
", onlineState='" + onlineState + '\'' +
", channelContent='" + channelContent + '\'' +
", provider='" + provider + '\'' +
", address='" + address + '\'' +
", host='" + host + '\'' +
", port='" + port + '\'' +
", deleteFlag='" + deleteFlag + '\'' +
", patrolDeviceCode='" + patrolDeviceCode + '\'' +
", username='" + username + '\'' +
", password='" + password + '\'' +
", deviceSource='" + deviceSource + '\'' +
'}';
}
}

+ 26
- 0
src/main/java/com/inspect/simulator/mapper/BasedataEqpBookChannelMapper.java View File

@ -0,0 +1,26 @@
package com.inspect.simulator.mapper;
import com.inspect.simulator.domain.basedata.BasedataEqpBook;
import com.inspect.simulator.domain.basedata.BasedataEqpBookChannel;
import org.apache.ibatis.annotations.Mapper;
import java.util.List;
@Mapper
public interface BasedataEqpBookChannelMapper {
BasedataEqpBookChannel selectBasedataEqpBookChannelByChannelId(Long channelId);
List<BasedataEqpBookChannel> selectBasedataEqpBookChannelList(BasedataEqpBookChannel channel);
int insertBasedataEqpBookChannel(BasedataEqpBookChannel channel);
int updateBasedataEqpBookChannel(BasedataEqpBookChannel channel);
int deleteBasedataEqpBookChannelByChannelId(Long channelId);
int deleteBasedataEqpBookChannelByChannelIds(Long[] channelIds);
List<BasedataEqpBookChannel> getChannelByEqpBookCode(BasedataEqpBook eqpBook);
}

+ 3
- 6
src/main/java/com/inspect/simulator/service/HikVisionService.java View File

@ -1,9 +1,6 @@
package com.inspect.simulator.service;
import com.inspect.simulator.domain.Infrared.Camera;
import com.inspect.simulator.domain.Infrared.Coordinate;
import com.inspect.simulator.domain.Infrared.InfraredInfo;
import com.inspect.simulator.domain.Infrared.NvrInfo;
import com.inspect.simulator.domain.Infrared.*;
import com.inspect.simulator.hikVision.utils.AjaxResult;
public interface HikVisionService {
@ -15,11 +12,11 @@ public interface HikVisionService {
// AjaxResult cameraHongWaiHk(Camera camera) ;
//图谱解析
AjaxResult capturePicture(Coordinate coordinate);
AjaxResult capturePicture(InfraPictureInfo infraPictureInfo);
//调用华软无人机获取csv温度
public float[][] UploadFtpImage( String url, String type, String image);
//图谱解析
AjaxResult calculatePicture(Coordinate coordinate);
AjaxResult calculatePicture(InfraPictureInfo infraPictureInfo);
}

+ 326
- 341
src/main/java/com/inspect/simulator/service/impl/HikVisionServiceImpl.java View File

@ -9,14 +9,13 @@ import com.alibaba.fastjson.JSONException;
import com.alibaba.fastjson.JSONObject;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.inspect.simulator.domain.Infrared.Camera;
import com.inspect.simulator.domain.Infrared.Coordinate;
import com.inspect.simulator.domain.Infrared.InfraredInfo;
import com.inspect.simulator.domain.Infrared.NvrInfo;
import com.inspect.simulator.domain.Infrared.*;
import com.inspect.simulator.domain.basedata.BasedataEqpBookChannel;
import com.inspect.simulator.hikVision.utils.AjaxResult;
import com.inspect.simulator.hikVision.utils.StringUtils;
import com.inspect.simulator.hikVision.utils.jna.HikVisionUtils;
import com.inspect.simulator.hikVision.utils.jna.HCNetSDK;
import com.inspect.simulator.mapper.BasedataEqpBookChannelMapper;
import com.inspect.simulator.service.HikVisionService;
import com.inspect.simulator.utils.sftp.SftpClient;
import com.sun.jna.ptr.IntByReference;
@ -87,6 +86,9 @@ public class HikVisionServiceImpl implements HikVisionService {
@Resource
private SftpClient sftpClient;
@Resource
private BasedataEqpBookChannelMapper basedataEqpBookChannelMapper;
// @Override
// public AjaxResult login(NvrInfo nvrInfo) {
// return login_V40(nvrInfo);
@ -294,58 +296,42 @@ public class HikVisionServiceImpl implements HikVisionService {
// return AjaxResult.success(infraredInfo);
// }
@Override
public AjaxResult capturePicture(Coordinate coordinate) {
InfraredInfo infraredInfo = new InfraredInfo();
try {
String imagePath = coordinate.getFilePath();
// String imagePath = "/images/ir_test.jpg";
InputStream inputStream = downloadFtp(imagePath);
String protocol = hrFtpUrl.substring(0, 6); // "ftp://"
String withoutProtocol = hrFtpUrl.substring(6); // "zthr02:zthr02@123.184.14.138:50021/"
String[] userAndHost = withoutProtocol.split("@");
if (userAndHost.length != 2) {
throw new IllegalArgumentException("URL 格式错误,缺少 @ 分隔符");
}
String[] userPass = userAndHost[0].split(":");
String username = userPass[0];
String password = userPass[1];
String hostPort = userAndHost[1].replace("/", ""); // 移除末尾的 "/"
String[] hostAndPort = hostPort.split(":");
String host = hostAndPort[0];
int port = Integer.parseInt(hostAndPort[1]);
String imageName = Paths.get(imagePath).getFileName().toString();
pic2Ftp(imageName,inputStream,host,port,username,password);
String ftpUrlName = "[\"" + hrFtpUrl + imageName + "\"]";
if (coordinate.getImgType() == 1) {
byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath));
infraredInfo = readDataHw(imageBytes, coordinate);
} else if (coordinate.getImgType() == 2) {
String s = ImageOverlaysIvs(coordinate, infraredInfo);
infraredInfo.setOutPath(s);
} else if (coordinate.getImgType() == 3) {
//sdk版本调用x86_32
//float[][] imageTem = djService.getImageTem(coordinate.getFilePath());
//调用华软接口
float[][] imageTem = UploadFtpImage(hrUavUrl, null, ftpUrlName);
if (imageTem != null && imageTem.length > 0 && imageTem[0].length > 0) {
infraredInfo.setTemperatureMatrix(imageTem);
String s = ImageOverlaysUav(coordinate, infraredInfo);
infraredInfo.setOutPath(s);
} else {
return AjaxResult.error("温度解析错误!");
public AjaxResult capturePicture(InfraPictureInfo infraPictureInfo) {
log.info("capturePicture, coordinate:{}", infraPictureInfo);
if (infraPictureInfo.getImgType() == 1) {
return AjaxResult.success("设置成功");
} else if (infraPictureInfo.getImgType() == 2) {
return AjaxResult.success("设置成功");
} else if (infraPictureInfo.getImgType() == 3) {
Long channelId = infraPictureInfo.getChannelId();
channelId = 1299L;
BasedataEqpBookChannel basedataEqpBookChannel = basedataEqpBookChannelMapper.selectBasedataEqpBookChannelByChannelId(channelId);
if (basedataEqpBookChannel != null) {
int firstX = 0;
int firstY = 0;
int secondX = 512;
int secondY = 640;
int imgWidth = 640;
int imgHeight = 512;
if(infraPictureInfo.getCoordinates() != null && !infraPictureInfo.getCoordinates().isEmpty()) {
firstX = infraPictureInfo.getCoordinates().get(0).getFirstX();
firstY = infraPictureInfo.getCoordinates().get(0).getFirstY();
secondX = infraPictureInfo.getCoordinates().get(0).getSecondX();
secondY = infraPictureInfo.getCoordinates().get(0).getSecondY();
imgWidth = infraPictureInfo.getImgHeight();
imgHeight = infraPictureInfo.getImgWidth();
}
String channelContent = firstX + "," + firstY + "," + secondX + "," + secondY + "," + imgWidth + "," + imgHeight;
basedataEqpBookChannel.setChannelContent(channelContent);
basedataEqpBookChannelMapper.updateBasedataEqpBookChannel(basedataEqpBookChannel);
return AjaxResult.success("设置成功");
} else {
return AjaxResult.error("点位不存在");
}
} catch (Exception e) {
e.printStackTrace();
return AjaxResult.error();
} else {
return AjaxResult.error("不支持该类型");
}
return AjaxResult.success(infraredInfo);
}
@ -466,8 +452,8 @@ public class HikVisionServiceImpl implements HikVisionService {
// }
//绘制框选标识
if (coordinate != null) {
String s = ImageOverlaysNvr(coordinate, infraredInfo);
infraredInfo.setOutPath(s);
//String s = ImageOverlaysNvr(coordinate, infraredInfo);
//infraredInfo.setOutPath(s);
}
} else {
System.err.println("错误:剩余数据不足以解析环境参数");
@ -479,30 +465,30 @@ public class HikVisionServiceImpl implements HikVisionService {
}
//点测温
public InfraredInfo PointTemperatureShow(Coordinate coordinate, short width, short height, float[][] temperatureMatrix) {
InfraredInfo infraredInfo = new InfraredInfo();
// 获取指定坐标的温度
if (ObjectUtil.isNotEmpty(coordinate.getFirstX())) {
if (coordinate.getImgType() != 3) {//无人机不需要对比底图
//比例缩放像素 获取底图温度值
double xMultiple = (coordinate.getImgWidth().doubleValue() / width) * 100 / 100.0;
double yMultiple = (coordinate.getImgHeight().doubleValue() / height) * 100 / 100.0;
int x = (int) (coordinate.getFirstX() / xMultiple);
int y = (int) (coordinate.getFirstY() / yMultiple);
coordinate.setFirstX(x);
coordinate.setFirstY(y);
}
if (coordinate.getFirstX() >= 0 && coordinate.getFirstX() <= width && coordinate.getFirstY() >= 0 && coordinate.getFirstY() <= height) {
float pointTemperature = temperatureMatrix[coordinate.getFirstY()][coordinate.getFirstX()]; // 注意y是行x是列
infraredInfo.setPointTemperature(pointTemperature);
} else {
System.err.println("错误:坐标超出范围");
}
}
return infraredInfo;
}
// public InfraredInfo PointTemperatureShow(Coordinate coordinate, short width, short height, float[][] temperatureMatrix) {
// InfraredInfo infraredInfo = new InfraredInfo();
// // 获取指定坐标的温度
// if (ObjectUtil.isNotEmpty(coordinate.getFirstX())) {
// if (coordinate.getImgType() != 3) {//无人机不需要对比底图
// //比例缩放像素 获取底图温度值
// double xMultiple = (coordinate.getImgWidth().doubleValue() / width) * 100 / 100.0;
// double yMultiple = (coordinate.getImgHeight().doubleValue() / height) * 100 / 100.0;
//
// int x = (int) (coordinate.getFirstX() / xMultiple);
// int y = (int) (coordinate.getFirstY() / yMultiple);
// coordinate.setFirstX(x);
// coordinate.setFirstY(y);
// }
//
// if (coordinate.getFirstX() >= 0 && coordinate.getFirstX() <= width && coordinate.getFirstY() >= 0 && coordinate.getFirstY() <= height) {
// float pointTemperature = temperatureMatrix[coordinate.getFirstY()][coordinate.getFirstX()]; // 注意y是行x是列
// infraredInfo.setPointTemperature(pointTemperature);
// } else {
// System.err.println("错误:坐标超出范围");
// }
// }
// return infraredInfo;
// }
//框选温度值计算
public InfraredInfo matrixTemperatureShow(Coordinate coordinate, short width, short height, float[][] temperatureMatrix) {
@ -510,21 +496,22 @@ public class HikVisionServiceImpl implements HikVisionService {
//存储框选矩阵温度值
List<Float> values = new ArrayList<>();
if (ObjectUtil.isNotEmpty(coordinate.getFirstX()) && ObjectUtil.isNotEmpty(coordinate.getSecondX())) {
if (coordinate.getImgType() != 3) {//无人机不需要对比底图
//倍数计算
double xMultiple = (coordinate.getImgWidth().doubleValue() / width) * 100 / 100.0;
double yMultiple = (coordinate.getImgHeight().doubleValue() / height) * 100 / 100.0;
//比例缩放像素 获取底图温度值
int x1 = (int) (coordinate.getFirstX() / xMultiple);
int y1 = (int) (coordinate.getFirstY() / yMultiple);
int x2 = (int) (coordinate.getSecondX() / xMultiple);
int y2 = (int) (coordinate.getSecondY() / yMultiple);
coordinate.setFirstX(x1);
coordinate.setFirstY(y1);
coordinate.setSecondX(x2);
coordinate.setSecondY(y2);
}
//if (coordinate.getImgType() != 3)
// {//无人机不需要对比底图
// //倍数计算
// double xMultiple = (coordinate.getImgWidth().doubleValue() / width) * 100 / 100.0;
// double yMultiple = (coordinate.getImgHeight().doubleValue() / height) * 100 / 100.0;
//
// //比例缩放像素 获取底图温度值
// int x1 = (int) (coordinate.getFirstX() / xMultiple);
// int y1 = (int) (coordinate.getFirstY() / yMultiple);
// int x2 = (int) (coordinate.getSecondX() / xMultiple);
// int y2 = (int) (coordinate.getSecondY() / yMultiple);
// coordinate.setFirstX(x1);
// coordinate.setFirstY(y1);
// coordinate.setSecondX(x2);
// coordinate.setSecondY(y2);
// }
if (coordinate.getSecondX() != 0 && coordinate.getSecondY() != 0) {
for (int j = coordinate.getFirstY(); j <= coordinate.getSecondY(); j++) { //
@ -608,238 +595,238 @@ public class HikVisionServiceImpl implements HikVisionService {
//图片标注__nvr
public String ImageOverlaysNvr(Coordinate coordinate, InfraredInfo infraredInfo) {
Coordinate[] coordinates = coordinate.getCoordinates();
Date date = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String markPicName = sf.format(date);
// 图片路径请替换为实际路径
String imagePath = coordinate.getFilePath();
// 获取文件名不含扩展名
File file = new File(imagePath);
String fileName = file.getName();
String pureName = fileName.substring(0, fileName.lastIndexOf('.'));
String filename = picPath;
String outputPath = picPath + pureName + "_" + markPicName + ".jpg";
//判断路径是否存在
File filePath = new File(filename);
if (!filePath.exists()) {
//不存在创建目录
filePath.mkdirs();
}
try {
// 加载原始图片
BufferedImage originalImage = ImageIO.read(new File(imagePath));
if (originalImage == null) {
System.err.println("无法加载图片: " + imagePath);
return null;
}
// 创建可编辑的图片副本
BufferedImage annotatedImage = new BufferedImage(
originalImage.getWidth(),
originalImage.getHeight(),
BufferedImage.TYPE_INT_RGB
);
// 绘制原始图片
Graphics2D g2d = annotatedImage.createGraphics();
g2d.drawImage(originalImage, 0, 0, null);
// 设置标注样式
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Font font = new Font("微软雅黑", Font.BOLD, 17);
for (Coordinate c : coordinates) {
//点标注
if (c.getFirstX() != null && c.getFirstY() != null && c.getSecondX() == null && c.getSecondY() == null) {
g2d.setFont(font);
// 标注点坐标
g2d.setColor(Color.GREEN);
int x = c.getFirstX();
int y = c.getFirstY();
// 确保坐标在图片范围内
if (x >= 0 && x < originalImage.getWidth() &&
y >= 0 && y < originalImage.getHeight()) {
// 绘制点用实心圆表示
g2d.fillOval(x - 3, y - 3, 6, 6);
coordinate.setFirstX(x);
coordinate.setFirstY(y);
InfraredInfo drawStringPoint = PointTemperatureShow(coordinate, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
// 添加坐标标签
g2d.drawString("(" + String.format("%.2f", drawStringPoint.getPointTemperature()) + ")", x + 8, y - 8);
}
}
//矩阵标注
if (c.getSecondX() != null && c.getSecondY() != null) {
// 标注矩形每两个点确定一个矩形
g2d.setColor(Color.RED);
int x1 = c.getFirstX();
int y1 = c.getFirstY();
int x2 = c.getSecondX();
int y2 = c.getSecondY();
// 确保坐标在图片范围内
if (x1 >= 0 && x1 < originalImage.getWidth() && y1 >= 0 && y1 < originalImage.getHeight() &&
x2 >= 0 && x2 < originalImage.getWidth() && y2 >= 0 && y2 < originalImage.getHeight()) {
// 确保x1,y1是左上角x2,y2是右下角
int rectX = Math.min(x1, x2);
int rectY = Math.min(y1, y2);
int width = Math.abs(x2 - x1);
int height = Math.abs(y2 - y1);
// 绘制矩形
g2d.drawRect(rectX, rectY, width, height);
coordinate.setFirstX(x1);
coordinate.setFirstY(y1);
coordinate.setSecondX(x2);
coordinate.setSecondY(y2);
InfraredInfo drawStringMatrix = matrixTemperatureShow(coordinate, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
infraredInfo.setFrameMax(Math.round(drawStringMatrix.getFrameMax() * 100) / 100f);
// 添加矩形标签
g2d.drawString("平均温度:" + String.format("%.2f", drawStringMatrix.getFrameAverage()) +
"最高温度:" + String.format("%.2f", drawStringMatrix.getFrameMax()) +
"最低温度:" + String.format("%.2f", drawStringMatrix.getFrameMin()), rectX + 5, rectY + 15);
}
}
}
g2d.dispose();
// 保存标注后的图片
File outputFile = new File(outputPath);
// 确保输出目录存在
outputFile.getParentFile().mkdirs();
ImageIO.write(annotatedImage, "jpg", outputFile);
// System.out.println("标注后的图片已保存到: " + outputPath);
} catch (IOException e) {
System.err.println("处理图片时出错: " + e.getMessage());
e.printStackTrace();
}
return outputPath;
}
// public String ImageOverlaysNvr(Coordinate coordinate, InfraredInfo infraredInfo) {
//
// Coordinate[] coordinates = coordinate.getCoordinates();
//
// Date date = new Date();
// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
// String markPicName = sf.format(date);
// // 图片路径请替换为实际路径
// String imagePath = coordinate.getFilePath();
// // 获取文件名不含扩展名
// File file = new File(imagePath);
// String fileName = file.getName();
// String pureName = fileName.substring(0, fileName.lastIndexOf('.'));
// String filename = picPath;
// String outputPath = picPath + pureName + "_" + markPicName + ".jpg";
// //判断路径是否存在
// File filePath = new File(filename);
// if (!filePath.exists()) {
// //不存在创建目录
// filePath.mkdirs();
// }
// try {
// // 加载原始图片
// BufferedImage originalImage = ImageIO.read(new File(imagePath));
// if (originalImage == null) {
// System.err.println("无法加载图片: " + imagePath);
// return null;
// }
//
// // 创建可编辑的图片副本
// BufferedImage annotatedImage = new BufferedImage(
// originalImage.getWidth(),
// originalImage.getHeight(),
// BufferedImage.TYPE_INT_RGB
// );
// // 绘制原始图片
// Graphics2D g2d = annotatedImage.createGraphics();
// g2d.drawImage(originalImage, 0, 0, null);
//
// // 设置标注样式
// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Font font = new Font("微软雅黑", Font.BOLD, 17);
//
// for (Coordinate c : coordinates) {
//
// //点标注
// if (c.getFirstX() != null && c.getFirstY() != null && c.getSecondX() == null && c.getSecondY() == null) {
// g2d.setFont(font);
// // 标注点坐标
// g2d.setColor(Color.GREEN);
// int x = c.getFirstX();
// int y = c.getFirstY();
//
// // 确保坐标在图片范围内
// if (x >= 0 && x < originalImage.getWidth() &&
// y >= 0 && y < originalImage.getHeight()) {
// // 绘制点用实心圆表示
// g2d.fillOval(x - 3, y - 3, 6, 6);
// coordinate.setFirstX(x);
// coordinate.setFirstY(y);
// InfraredInfo drawStringPoint = PointTemperatureShow(coordinate, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
// // 添加坐标标签
// g2d.drawString("(" + String.format("%.2f", drawStringPoint.getPointTemperature()) + ")", x + 8, y - 8);
// }
// }
//
// //矩阵标注
// if (c.getSecondX() != null && c.getSecondY() != null) {
// // 标注矩形每两个点确定一个矩形
// g2d.setColor(Color.RED);
// int x1 = c.getFirstX();
// int y1 = c.getFirstY();
// int x2 = c.getSecondX();
// int y2 = c.getSecondY();
//
// // 确保坐标在图片范围内
// if (x1 >= 0 && x1 < originalImage.getWidth() && y1 >= 0 && y1 < originalImage.getHeight() &&
// x2 >= 0 && x2 < originalImage.getWidth() && y2 >= 0 && y2 < originalImage.getHeight()) {
//
// // 确保x1,y1是左上角x2,y2是右下角
// int rectX = Math.min(x1, x2);
// int rectY = Math.min(y1, y2);
// int width = Math.abs(x2 - x1);
// int height = Math.abs(y2 - y1);
// // 绘制矩形
// g2d.drawRect(rectX, rectY, width, height);
//
// coordinate.setFirstX(x1);
// coordinate.setFirstY(y1);
// coordinate.setSecondX(x2);
// coordinate.setSecondY(y2);
//
// InfraredInfo drawStringMatrix = matrixTemperatureShow(coordinate, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
// infraredInfo.setFrameMax(Math.round(drawStringMatrix.getFrameMax() * 100) / 100f);
// // 添加矩形标签
// g2d.drawString("平均温度:" + String.format("%.2f", drawStringMatrix.getFrameAverage()) +
// "最高温度:" + String.format("%.2f", drawStringMatrix.getFrameMax()) +
// "最低温度:" + String.format("%.2f", drawStringMatrix.getFrameMin()), rectX + 5, rectY + 15);
//
// }
// }
// }
// g2d.dispose();
// // 保存标注后的图片
// File outputFile = new File(outputPath);
// // 确保输出目录存在
// outputFile.getParentFile().mkdirs();
//
// ImageIO.write(annotatedImage, "jpg", outputFile);
//// System.out.println("标注后的图片已保存到: " + outputPath);
//
// } catch (IOException e) {
// System.err.println("处理图片时出错: " + e.getMessage());
// e.printStackTrace();
// }
// return outputPath;
// }
//图片标注_iVS1800
public String ImageOverlaysIvs(Coordinate coordinate, InfraredInfo infraredInfo) {
Coordinate[] coordinates = coordinate.getCoordinates();
Date date = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String markPicName = sf.format(date);
// 图片路径请替换为实际路径
String imagePath = coordinate.getFilePath();
// 获取文件名不含扩展名
File file = new File(imagePath);
String fileName = file.getName();
String pureName = fileName.substring(0, fileName.lastIndexOf('.'));
String filename = picPath;
String outputPath = picPath + pureName + "_" + markPicName + ".jpg";
//判断路径是否存在
File filePath = new File(filename);
if (!filePath.exists()) {
//不存在创建目录
filePath.mkdirs();
}
try {
// 加载原始图片
BufferedImage originalImage = ImageIO.read(new File(imagePath));
if (originalImage == null) {
System.err.println("无法加载图片: " + imagePath);
return null;
}
// 创建可编辑的图片副本
BufferedImage annotatedImage = new BufferedImage(
originalImage.getWidth(),
originalImage.getHeight(),
BufferedImage.TYPE_INT_RGB
);
// 绘制原始图片
Graphics2D g2d = annotatedImage.createGraphics();
g2d.drawImage(originalImage, 0, 0, null);
// 设置标注样式
g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
Font font = new Font("微软雅黑", Font.BOLD, 17);
for (Coordinate c : coordinates) {
g2d.setFont(font);
//矩阵标注
if (c.getSecondX() != null && c.getSecondY() != null) {
// 标注矩形每两个点确定一个矩形
g2d.setColor(Color.WHITE);
int x1 = c.getFirstX();
int y1 = c.getFirstY();
int x2 = c.getSecondX();
int y2 = c.getSecondY();
// 确保坐标在图片范围内
if (x1 >= 0 && x1 < originalImage.getWidth() && y1 >= 0 && y1 < originalImage.getHeight() &&
x2 >= 0 && x2 < originalImage.getWidth() && y2 >= 0 && y2 < originalImage.getHeight()) {
// 确保x1,y1是左上角x2,y2是右下角
int rectX = Math.min(x1, x2);
int rectY = Math.min(y1, y2);
int width = Math.abs(x2 - x1);
int height = Math.abs(y2 - y1);
// 绘制矩形
g2d.drawRect(rectX, rectY, width, height);
coordinate.setFirstX(x1);
coordinate.setFirstY(y1);
coordinate.setSecondX(x2);
coordinate.setSecondY(y2);
// 添加矩形标签
//图片路径取值
String[] dividePath = Paths.get(imagePath).getFileName().toString().replaceAll("(?i)\\.jpg$", "").split("_");
String max = dividePath[dividePath.length - 3]; // 最大值
String min = dividePath[dividePath.length - 2]; // 最小值
String avg = dividePath[dividePath.length - 1]; // 平均值
infraredInfo.setFrameMax(Float.parseFloat(max));
// g2d.drawString("平均温度:" +avg + "最高温度:" + max + "最低温度:" + min, rectX + 5, rectY + 15);
String line1 = "平均温度:" + avg;
String line2 = "最高温度:" + max;
String line3 = "最低温度:" + min;
g2d.drawString(line1, rectX + 5, rectY + 15);
g2d.drawString(line2, rectX + 5, rectY + 30);
g2d.drawString(line3, rectX + 5, rectY + 45);
}
}
}
g2d.dispose();
// 保存标注后的图片
File outputFile = new File(outputPath);
// 确保输出目录存在
outputFile.getParentFile().mkdirs();
ImageIO.write(annotatedImage, "jpg", outputFile);
} catch (IOException e) {
System.err.println("处理图片时出错: " + e.getMessage());
e.printStackTrace();
}
return outputPath;
}
// public String ImageOverlaysIvs(Coordinate coordinate, InfraredInfo infraredInfo) {
//
// Coordinate[] coordinates = coordinate.getCoordinates();
//
// Date date = new Date();
// SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
// String markPicName = sf.format(date);
// // 图片路径请替换为实际路径
// String imagePath = coordinate.getFilePath();
// // 获取文件名不含扩展名
// File file = new File(imagePath);
// String fileName = file.getName();
// String pureName = fileName.substring(0, fileName.lastIndexOf('.'));
// String filename = picPath;
// String outputPath = picPath + pureName + "_" + markPicName + ".jpg";
// //判断路径是否存在
// File filePath = new File(filename);
// if (!filePath.exists()) {
// //不存在创建目录
// filePath.mkdirs();
// }
// try {
// // 加载原始图片
// BufferedImage originalImage = ImageIO.read(new File(imagePath));
// if (originalImage == null) {
// System.err.println("无法加载图片: " + imagePath);
// return null;
// }
//
// // 创建可编辑的图片副本
// BufferedImage annotatedImage = new BufferedImage(
// originalImage.getWidth(),
// originalImage.getHeight(),
// BufferedImage.TYPE_INT_RGB
// );
// // 绘制原始图片
// Graphics2D g2d = annotatedImage.createGraphics();
// g2d.drawImage(originalImage, 0, 0, null);
//
// // 设置标注样式
// g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
// Font font = new Font("微软雅黑", Font.BOLD, 17);
//
// for (Coordinate c : coordinates) {
// g2d.setFont(font);
// //矩阵标注
// if (c.getSecondX() != null && c.getSecondY() != null) {
// // 标注矩形每两个点确定一个矩形
// g2d.setColor(Color.WHITE);
// int x1 = c.getFirstX();
// int y1 = c.getFirstY();
// int x2 = c.getSecondX();
// int y2 = c.getSecondY();
//
// // 确保坐标在图片范围内
// if (x1 >= 0 && x1 < originalImage.getWidth() && y1 >= 0 && y1 < originalImage.getHeight() &&
// x2 >= 0 && x2 < originalImage.getWidth() && y2 >= 0 && y2 < originalImage.getHeight()) {
//
// // 确保x1,y1是左上角x2,y2是右下角
// int rectX = Math.min(x1, x2);
// int rectY = Math.min(y1, y2);
// int width = Math.abs(x2 - x1);
// int height = Math.abs(y2 - y1);
// // 绘制矩形
// g2d.drawRect(rectX, rectY, width, height);
//
// coordinate.setFirstX(x1);
// coordinate.setFirstY(y1);
// coordinate.setSecondX(x2);
// coordinate.setSecondY(y2);
// // 添加矩形标签
// //图片路径取值
// String[] dividePath = Paths.get(imagePath).getFileName().toString().replaceAll("(?i)\\.jpg$", "").split("_");
// String max = dividePath[dividePath.length - 3]; // 最大值
// String min = dividePath[dividePath.length - 2]; // 最小值
// String avg = dividePath[dividePath.length - 1]; // 平均值
// infraredInfo.setFrameMax(Float.parseFloat(max));
//// g2d.drawString("平均温度:" +avg + "最高温度:" + max + "最低温度:" + min, rectX + 5, rectY + 15);
//
// String line1 = "平均温度:" + avg;
// String line2 = "最高温度:" + max;
// String line3 = "最低温度:" + min;
//
// g2d.drawString(line1, rectX + 5, rectY + 15);
// g2d.drawString(line2, rectX + 5, rectY + 30);
// g2d.drawString(line3, rectX + 5, rectY + 45);
// }
// }
// }
// g2d.dispose();
// // 保存标注后的图片
// File outputFile = new File(outputPath);
// // 确保输出目录存在
// outputFile.getParentFile().mkdirs();
// ImageIO.write(annotatedImage, "jpg", outputFile);
// } catch (IOException e) {
// System.err.println("处理图片时出错: " + e.getMessage());
// e.printStackTrace();
// }
// return outputPath;
// }
//图片标注__无人机
public String ImageOverlaysUav(Coordinate coordinate, InfraredInfo infraredInfo) {
public String ImageOverlaysUav(InfraPictureInfo infraPictureInfo, InfraredInfo infraredInfo) {
Coordinate[] coordinates = coordinate.getCoordinates();
List<Coordinate> coordinates = infraPictureInfo.getCoordinates();
Date date = new Date();
SimpleDateFormat sf = new SimpleDateFormat("yyyyMMddHHmmss");
String markPicName = sf.format(date);
// 图片路径请替换为实际路径
String imagePath = coordinate.getFilePath();
String imagePath = infraPictureInfo.getFilePath();
// 获取文件名不含扩展名
File file = new File(imagePath);
String fileName = file.getName();
@ -854,7 +841,7 @@ public class HikVisionServiceImpl implements HikVisionService {
}
try {
InputStream inputStreamPath = downloadFtp(imagePath);
if (inputStreamPath==null){
if (inputStreamPath == null) {
System.out.println("无法加载图片: " + imagePath);
}
// 加载原始图片
@ -894,11 +881,11 @@ public class HikVisionServiceImpl implements HikVisionService {
y >= 0 && y < originalImage.getHeight()) {
// 绘制点用实心圆表示
g2d.fillOval(x - 3, y - 3, 6, 6);
coordinate.setFirstX(x);
coordinate.setFirstY(y);
InfraredInfo drawStringPoint = PointTemperatureShow(coordinate, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
// 添加坐标标签
g2d.drawString("(" + String.format("%.2f", drawStringPoint.getPointTemperature()) + ")", x + 8, y - 8);
infraPictureInfo.setFirstX(x);
infraPictureInfo.setFirstY(y);
// InfraredInfo drawStringPoint = PointTemperatureShow(c, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
// // 添加坐标标签
// g2d.drawString("(" + String.format("%.2f", drawStringPoint.getPointTemperature()) + ")", x + 8, y - 8);
}
}
@ -922,12 +909,12 @@ public class HikVisionServiceImpl implements HikVisionService {
int height = Math.abs(y2 - y1);
// 绘制矩形
g2d.drawRect(rectX, rectY, width, height);
coordinate.setFirstX(x1);
coordinate.setFirstY(y1);
coordinate.setSecondX(x2);
coordinate.setSecondY(y2);
infraPictureInfo.setFirstX(x1);
infraPictureInfo.setFirstY(y1);
infraPictureInfo.setSecondX(x2);
infraPictureInfo.setSecondY(y2);
InfraredInfo drawStringMatrix = matrixTemperatureShow(coordinate, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
InfraredInfo drawStringMatrix = matrixTemperatureShow(c, infraredInfo.getMatrixWidth(), infraredInfo.getMatrixHeight(), infraredInfo.getTemperatureMatrix());
infraredInfo.setFrameMax(Math.round(drawStringMatrix.getFrameMax() * 100) / 100f);
// 添加矩形标签
String line1 = "平均温度:" + String.format("%.2f", drawStringMatrix.getFrameAverage());
@ -946,7 +933,7 @@ public class HikVisionServiceImpl implements HikVisionService {
ImageIO.write(annotatedImage, "jpg", os);
InputStream inputStream = new ByteArrayInputStream(os.toByteArray());
picFtp(outputPath, inputStream,ftpUrlAddress,ftpUrlPort,ftpUrlAccount,ftpUrlPwd);
picFtp(outputPath, inputStream, ftpUrlAddress, ftpUrlPort, ftpUrlAccount, ftpUrlPwd);
// // 保存标注后的图片
// File outputFile = new File(outputPath);
@ -1098,7 +1085,7 @@ public class HikVisionServiceImpl implements HikVisionService {
}
public void picFtp(String newPath, InputStream originalPath,String ftpUrlAddress,Integer ftpUrlPort,String ftpUrlAccount,String ftpUrlPwd) {
public void picFtp(String newPath, InputStream originalPath, String ftpUrlAddress, Integer ftpUrlPort, String ftpUrlAccount, String ftpUrlPwd) {
FTPSClient ftps = null;
try {
ftps = new FTPSClient(true);
@ -1130,7 +1117,7 @@ public class HikVisionServiceImpl implements HikVisionService {
}
}
public void pic2Ftp(String newPath, InputStream originalPath,String ftpUrlAddress,Integer ftpUrlPort,String ftpUrlAccount,String ftpUrlPwd) {
public void pic2Ftp(String newPath, InputStream originalPath, String ftpUrlAddress, Integer ftpUrlPort, String ftpUrlAccount, String ftpUrlPwd) {
FTPClient ftps = null;
try {
ftps = new FTPClient();
@ -1186,14 +1173,12 @@ public class HikVisionServiceImpl implements HikVisionService {
}
@Override
public AjaxResult calculatePicture(Coordinate coordinate) {
public AjaxResult calculatePicture(InfraPictureInfo infraPictureInfo) {
InfraredInfo infraredInfo = new InfraredInfo();
try {
String imagePath = coordinate.getFilePath();
String imagePath = infraPictureInfo.getFilePath();
// String imagePath = "/images/ir_test.jpg";
InputStream inputStream = downloadFtp(imagePath);
String protocol = hrFtpUrl.substring(0, 6); // "ftp://"
@ -1209,20 +1194,20 @@ public class HikVisionServiceImpl implements HikVisionService {
String[] hostAndPort = hostPort.split(":");
String host = hostAndPort[0];
int port = Integer.parseInt(hostAndPort[1]);
picFtp("/",inputStream,host,port,username,password);
picFtp("/", inputStream, host, port, username, password);
String imageName = Paths.get(imagePath).getFileName().toString();
String ftpUrlName = "[\"" + hrFtpUrl + imageName + "\"]";
if (coordinate.getImgType() == 1) {
if (infraPictureInfo.getImgType() == 1) {
byte[] imageBytes = Files.readAllBytes(Paths.get(imagePath));
infraredInfo = readDataHw(imageBytes, coordinate);
} else if (coordinate.getImgType() == 2) {
infraredInfo = readDataHw(imageBytes, infraPictureInfo.getCoordinates().get(0));
} else if (infraPictureInfo.getImgType() == 2) {
String s = ImageOverlaysIvs(coordinate, infraredInfo);
infraredInfo.setOutPath(s);
} else if (coordinate.getImgType() == 3) {
// String s = ImageOverlaysIvs(infraPictureInfo.getCoordinates().get(0), infraredInfo);
// infraredInfo.setOutPath(s);
} else if (infraPictureInfo.getImgType() == 3) {
//sdk版本调用x86_32
//float[][] imageTem = djService.getImageTem(coordinate.getFilePath());
@ -1230,7 +1215,7 @@ public class HikVisionServiceImpl implements HikVisionService {
float[][] imageTem = UploadFtpImage(hrUavUrl, null, ftpUrlName);
if (imageTem != null && imageTem.length > 0 && imageTem[0].length > 0) {
infraredInfo.setTemperatureMatrix(imageTem);
String s = ImageOverlaysUav(coordinate, infraredInfo);
String s = ImageOverlaysUav(infraPictureInfo, infraredInfo);
infraredInfo.setOutPath(s);
} else {
return AjaxResult.error("温度解析错误!");


+ 1
- 1
src/main/java/com/inspect/simulator/utils/sftp/SftpClient.java View File

@ -185,7 +185,7 @@ public class SftpClient {
ftps.setControlEncoding("UTF-8");
ftps.setFileTransferMode(10);
ftps.execPROT("P");
ftps.storeFile("1122234567.jpg", new FileInputStream("E:/1.jpg"));
ftps.storeFile("/1/ir/1122234567.jpg", new FileInputStream("E:/1.jpg"));
String fileFullPathTmp = "1122.jpg";


+ 192
- 0
src/main/resources/mapper/metadata/BasedataEqpBookChannelMapper.xml View File

@ -0,0 +1,192 @@
<?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="com.inspect.simulator.mapper.BasedataEqpBookChannelMapper">
<resultMap type="com.inspect.simulator.domain.basedata.BasedataEqpBookChannel" id="BasedataEqpBookChannelResult">
<result property="channelId" column="channel_id"/>
<result property="channelCode" column="channel_code"/>
<result property="channelName" column="channel_name"/>
<result property="parentChannelId" column="parent_channel_id"/>
<result property="eqpBookId" column="eqp_book_id"/>
<result property="channelType" column="channel_type"/>
<result property="onlineState" column="online_state"/>
<result property="channelContent" column="channel_content"/>
<result property="provider" column="provider"/>
<result property="address" column="address"/>
<result property="host" column="host"/>
<result property="port" column="port"/>
<result property="createBy" column="create_by"/>
<result property="createTime" column="create_time"/>
<result property="updateBy" column="update_by"/>
<result property="updateTime" column="update_time"/>
<result property="deleteFlag" column="delete_flag"/>
<result property="patrolDeviceCode" column="patrol_device_code"/>
<result property="username" column="username"/>
<result property="password" column="password"/>
<result property="deviceSource" column="device_source" />
</resultMap>
<sql id="selectBasedataEqpBookChannelVo">
select channel_id,
channel_code,
channel_name,
parent_channel_id,
eqp_book_id,
channel_type,
online_state,
channel_content,
provider,
address,
host,
port,
create_by,
create_time,
update_by,
update_time,
delete_flag,
patrol_device_code,
username,
password,
device_source
from basedata_eqpbook_channel
</sql>
<select id="selectBasedataEqpBookChannelList" parameterType="com.inspect.simulator.domain.basedata.BasedataEqpBookChannel"
resultMap="BasedataEqpBookChannelResult">
<include refid="selectBasedataEqpBookChannelVo"/>
<where>
<if test="channelCode != null and channelCode != ''">and channel_code = #{channelCode}</if>
<if test="channelName != null and channelName != ''">and channel_name like concat('%', #{channelName},
'%')
</if>
<if test="parentChannelId != null and parentChannelId != ''">and parent_channel_id = #{parentChannelId}
</if>
<if test="eqpBookId != null">and eqp_book_id = #{eqpBookId}</if>
<if test="channelType != null and channelType != ''">and channel_type = #{channelType}</if>
<if test="onlineState != null and onlineState != ''">and online_state = #{onlineState}</if>
<if test="channelContent != null and channelContent != ''">and channel_content = #{channelContent}</if>
<if test="provider != null and provider != ''">and provider = #{provider}</if>
<if test="address != null and address != ''">and address = #{address}</if>
<if test="host != null and host != ''">and host = #{host}</if>
<if test="port != null and port != ''">and port = #{port}</if>
<if test="patrolDeviceCode != null and patrolDeviceCode != ''">and patrol_device_code =
#{patrolDeviceCode}
</if>
<if test="username != null and username != ''">and username = #{username}</if>
<if test="password != null and password != ''">and password = #{password}</if>
</where>
</select>
<select id="selectBasedataEqpBookChannelByChannelId" parameterType="Long" resultMap="BasedataEqpBookChannelResult">
<include refid="selectBasedataEqpBookChannelVo"/>
where channel_id = #{channelId}
</select>
<insert id="insertBasedataEqpBookChannel" parameterType="com.inspect.simulator.domain.basedata.BasedataEqpBookChannel" useGeneratedKeys="true"
keyProperty="channelId">
insert into basedata_eqpbook_channel
<trim prefix="(" suffix=")" suffixOverrides=",">
<if test="channelCode != null">channel_code,</if>
<if test="channelName != null and channelName != ''">channel_name,</if>
<if test="parentChannelId != null">parent_channel_id,</if>
<if test="eqpBookId != null">eqp_book_id,</if>
<if test="channelType != null">channel_type,</if>
<if test="onlineState != null">online_state,</if>
<if test="channelContent != null">channel_content,</if>
<if test="provider != null">provider,</if>
<if test="address != null">address,</if>
<if test="host != null">host,</if>
<if test="port != null">port,</if>
<if test="createBy != null">create_by,</if>
<if test="createTime != null">create_time,</if>
<if test="updateBy != null">update_by,</if>
<if test="updateTime != null">update_time,</if>
<if test="deleteFlag != null">delete_flag,</if>
<if test="patrolDeviceCode != null">patrol_device_code,</if>
<if test="username != null">username,</if>
<if test="password != null">password,</if>
<if test="deviceSource != null">device_source,</if>
</trim>
<trim prefix="values (" suffix=")" suffixOverrides=",">
<if test="channelCode != null">#{channelCode},</if>
<if test="channelName != null and channelName != ''">#{channelName},</if>
<if test="parentChannelId != null">#{parentChannelId},</if>
<if test="eqpBookId != null">#{eqpBookId},</if>
<if test="channelType != null">#{channelType},</if>
<if test="onlineState != null">#{onlineState},</if>
<if test="channelContent != null">#{channelContent},</if>
<if test="provider != null">#{provider},</if>
<if test="address != null">#{address},</if>
<if test="host != null">#{host},</if>
<if test="port != null">#{port},</if>
<if test="createBy != null">#{createBy},</if>
<if test="createTime != null">#{createTime},</if>
<if test="updateBy != null">#{updateBy},</if>
<if test="updateTime != null">#{updateTime},</if>
<if test="deleteFlag != null">#{deleteFlag},</if>
<if test="patrolDeviceCode != null">#{patrolDeviceCode},</if>
<if test="username != null">#{username},</if>
<if test="password != null">#{password},</if>
<if test="deviceSource != null">#{deviceSource},</if>
</trim>
</insert>
<update id="updateBasedataEqpBookChannel" parameterType="com.inspect.simulator.domain.basedata.BasedataEqpBookChannel">
update basedata_eqpbook_channel
<trim prefix="SET" suffixOverrides=",">
<if test="channelCode != null">channel_code = #{channelCode},</if>
<if test="channelName != null and channelName != ''">channel_name = #{channelName},</if>
<if test="parentChannelId != null">parent_channel_id = #{parentChannelId},</if>
<if test="eqpBookId != null">eqp_book_id = #{eqpBookId},</if>
<if test="channelType != null">channel_type = #{channelType},</if>
<if test="onlineState != null">online_state = #{onlineState},</if>
<if test="channelContent != null">channel_content = #{channelContent},</if>
<if test="provider != null">provider = #{provider},</if>
<if test="address != null">address = #{address},</if>
<if test="host != null">host = #{host},</if>
<if test="port != null">port = #{port},</if>
<if test="createBy != null">create_by = #{createBy},</if>
<if test="createTime != null">create_time = #{createTime},</if>
<if test="updateBy != null">update_by = #{updateBy},</if>
<if test="updateTime != null">update_time = #{updateTime},</if>
<if test="deleteFlag != null">delete_flag = #{deleteFlag},</if>
<if test="patrolDeviceCode != null">patrol_device_code = #{patrolDeviceCode},</if>
<if test="username != null">username = #{username},</if>
<if test="password != null">password = #{password},</if>
<if test="deviceSource != null">device_source = #{deviceSource},</if>
</trim>
where channel_id = #{channelId}
</update>
<delete id="deleteBasedataEqpBookChannelByChannelId" parameterType="Long">
delete
from basedata_eqpbook_channel
where channel_id = #{channelId}
</delete>
<delete id="deleteBasedataEqpBookChannelByChannelIds" parameterType="String">
delete from basedata_eqpbook_channel where channel_id in
<foreach item="channelId" collection="array" open="(" separator="," close=")">
#{channelId}
</foreach>
</delete>
<select id="getChannelByEqpBookCode" parameterType="com.inspect.simulator.domain.basedata.BasedataEqpBookChannel"
resultMap="BasedataEqpBookChannelResult">
SELECT
b.channel_id,
b.channel_name,
b.channel_code,
a.eqp_book_id,
a.patroldevice_name,
a.patrol_device_code
FROM
basedata_eqpbook a,
basedata_eqpbook_channel b
WHERE
a.eqp_book_id = b.eqp_book_id
<if test="patrolDeviceCode != null">AND a.patrol_device_code = #{patrolDeviceCode}</if>
</select>
</mapper>

Loading…
Cancel
Save