第一次提交

main
吴顺杰 2 months ago
commit 8af05699ca

33
.gitignore vendored

@ -0,0 +1,33 @@
HELP.md
target/
!.mvn/wrapper/maven-wrapper.jar
!**/src/main/**/target/
!**/src/test/**/target/
### STS ###
.apt_generated
.classpath
.factorypath
.project
.settings
.springBeans
.sts4-cache
### IntelliJ IDEA ###
.idea
*.iws
*.iml
*.ipr
### NetBeans ###
/nbproject/private/
/nbbuild/
/dist/
/nbdist/
/.nb-gradle/
build/
!**/src/main/**/build/
!**/src/test/**/build/
### VS Code ###
.vscode/

@ -0,0 +1,100 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://maven.apache.org/POM/4.0.0"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.parkingLot</groupId>
<artifactId>parkingLot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>ParkingLot</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
<spring-boot.version>2.6.13</spring-boot.version>
</properties>
<dependencies>
<!-- https://mvnrepository.com/artifact/cn.hutool/hutool-all -->
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.25</version>
</dependency>
<dependency>
<groupId>com.alibaba.fastjson2</groupId>
<artifactId>fastjson2</artifactId>
<version>2.0.41</version>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- https://mvnrepository.com/artifact/com.google.guava/guava -->
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
<version>28.1-jre</version>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-dependencies</artifactId>
<version>${spring-boot.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<!--打包成jar包时的名字-->
<finalName>parkingLot</finalName>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.8.1</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<version>${spring-boot.version}</version>
<configuration>
<mainClass>com.parkingLot.ParkingLotApplication</mainClass>
</configuration>
<executions>
<execution>
<id>repackage</id>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>

@ -0,0 +1,13 @@
package com.parkingLot;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
@SpringBootApplication
public class ParkingLotApplication {
public static void main(String[] args) {
SpringApplication.run(ParkingLotApplication.class, args);
}
}

@ -0,0 +1,93 @@
package com.parkingLot.base.constant;
/**
*
*
* @author ruoyi
*/
public class HttpStatus {
/**
*
*/
public static final int SUCCESS = 200;
/**
*
*/
public static final int CREATED = 201;
/**
*
*/
public static final int ACCEPTED = 202;
/**
*
*/
public static final int NO_CONTENT = 204;
/**
*
*/
public static final int MOVED_PERM = 301;
/**
*
*/
public static final int SEE_OTHER = 303;
/**
*
*/
public static final int NOT_MODIFIED = 304;
/**
*
*/
public static final int BAD_REQUEST = 400;
/**
*
*/
public static final int UNAUTHORIZED = 401;
/**
* 访
*/
public static final int FORBIDDEN = 403;
/**
*
*/
public static final int NOT_FOUND = 404;
/**
* http
*/
public static final int BAD_METHOD = 405;
/**
*
*/
public static final int CONFLICT = 409;
/**
*
*/
public static final int UNSUPPORTED_TYPE = 415;
/**
*
*/
public static final int ERROR = 500;
/**
*
*/
public static final int NOT_IMPLEMENTED = 501;
/**
*
*/
public static final int WARN = 601;
}

@ -0,0 +1,78 @@
package com.parkingLot.base.controller;
import com.parkingLot.base.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
* web
*
* @author ruoyi
*/
public class BaseController {
protected final Logger logger = LoggerFactory.getLogger(this.getClass());
/**
*
*/
public AjaxResult success() {
return AjaxResult.success();
}
/**
*
*/
public AjaxResult error() {
return AjaxResult.error();
}
/**
*
*/
public AjaxResult success(String message) {
return AjaxResult.success(message);
}
/**
*
*/
public AjaxResult success(Object data) {
return AjaxResult.success(data);
}
/**
*
*/
public AjaxResult error(String message) {
return AjaxResult.error(message);
}
/**
*
*/
public AjaxResult warn(String message) {
return AjaxResult.warn(message);
}
/**
*
*
* @param rows
* @return
*/
protected AjaxResult toAjax(int rows) {
return rows > 0 ? AjaxResult.success() : AjaxResult.error();
}
/**
*
*
* @param result
* @return
*/
protected AjaxResult toAjax(boolean result) {
return result ? success() : error();
}
}

@ -0,0 +1,202 @@
package com.parkingLot.base.domain;
import cn.hutool.core.bean.BeanUtil;
import com.parkingLot.base.constant.HttpStatus;
import java.util.HashMap;
import java.util.Objects;
/**
*
*
* @author ruoyi
*/
public class AjaxResult extends HashMap<String, Object> {
/**
*
*/
public static final String CODE_TAG = "code";
/**
*
*/
public static final String MSG_TAG = "msg";
/**
*
*/
public static final String DATA_TAG = "data";
private static final long serialVersionUID = 1L;
/**
* AjaxResult 使
*/
public AjaxResult() {
}
/**
* AjaxResult
*
* @param code
* @param msg
*/
public AjaxResult(int code, String msg) {
super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
}
/**
* AjaxResult
*
* @param code
* @param msg
* @param data
*/
public AjaxResult(int code, String msg, Object data) {
super.put(CODE_TAG, code);
super.put(MSG_TAG, msg);
if (BeanUtil.isNotEmpty(data)) {
super.put(DATA_TAG, data);
}
}
/**
*
*
* @return
*/
public static AjaxResult success() {
return AjaxResult.success("操作成功");
}
/**
*
*
* @return
*/
public static AjaxResult success(Object data) {
return AjaxResult.success("操作成功", data);
}
/**
*
*
* @param msg
* @return
*/
public static AjaxResult success(String msg) {
return AjaxResult.success(msg, null);
}
/**
*
*
* @param msg
* @param data
* @return
*/
public static AjaxResult success(String msg, Object data) {
return new AjaxResult(HttpStatus.SUCCESS, msg, data);
}
/**
*
*
* @param msg
* @return
*/
public static AjaxResult warn(String msg) {
return AjaxResult.warn(msg, null);
}
/**
*
*
* @param msg
* @param data
* @return
*/
public static AjaxResult warn(String msg, Object data) {
return new AjaxResult(HttpStatus.WARN, msg, data);
}
/**
*
*
* @return
*/
public static AjaxResult error() {
return AjaxResult.error("操作失败");
}
/**
*
*
* @param msg
* @return
*/
public static AjaxResult error(String msg) {
return AjaxResult.error(msg, null);
}
/**
*
*
* @param msg
* @param data
* @return
*/
public static AjaxResult error(String msg, Object data) {
return new AjaxResult(HttpStatus.ERROR, msg, data);
}
/**
*
*
* @param code
* @param msg
* @return
*/
public static AjaxResult error(int code, String msg) {
return new AjaxResult(code, msg, null);
}
/**
*
*
* @return
*/
public boolean isSuccess() {
return Objects.equals(HttpStatus.SUCCESS, this.get(CODE_TAG));
}
/**
*
*
* @return
*/
public boolean isWarn() {
return Objects.equals(HttpStatus.WARN, this.get(CODE_TAG));
}
/**
*
*
* @return
*/
public boolean isError() {
return Objects.equals(HttpStatus.ERROR, this.get(CODE_TAG));
}
/**
* 便
*
* @param key
* @param value
* @return
*/
@Override
public AjaxResult put(String key, Object value) {
super.put(key, value);
return this;
}
}

@ -0,0 +1,39 @@
package com.parkingLot.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.filter.CorsFilter;
/**
*
*
* @author wu
* @since 2024/12/16 15:47
*/
@Configuration
public class GlobalCorsConfig {
@Bean
public CorsFilter corsFilter() {
//1. 添加 CORS配置信息
CorsConfiguration config = new CorsConfiguration();
// 放行哪些原始域
config.addAllowedOriginPattern("*");
// 是否发送 Cookie
config.setAllowCredentials(true);
// 放行哪些请求方式
config.addAllowedMethod("*");
// 放行哪些原始请求头部信息
config.addAllowedHeader("*");
// 暴露哪些头部信息
config.addExposedHeader("*");
//2. 添加映射路径
UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource();
corsConfigurationSource.registerCorsConfiguration("/**", config);
//3. 返回新的CorsFilter
return new CorsFilter(corsConfigurationSource);
}
}

@ -0,0 +1,87 @@
package com.parkingLot.config.exception;
import com.parkingLot.base.domain.AjaxResult;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.validation.BindException;
import org.springframework.web.HttpRequestMethodNotSupportedException;
import org.springframework.web.bind.MethodArgumentNotValidException;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.method.annotation.MethodArgumentTypeMismatchException;
import javax.servlet.http.HttpServletRequest;
/**
*
*
* @author ruoyi
*/
@RestControllerAdvice
public class GlobalExceptionHandler {
private static final Logger log = LoggerFactory.getLogger(GlobalExceptionHandler.class);
/**
*
*/
@ExceptionHandler(HttpRequestMethodNotSupportedException.class)
public AjaxResult handleHttpRequestMethodNotSupported(HttpRequestMethodNotSupportedException e,
HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',不支持'{}'请求", requestURI, e.getMethod());
return AjaxResult.error(e.getMessage());
}
/**
*
*/
@ExceptionHandler(MethodArgumentTypeMismatchException.class)
public AjaxResult handleMethodArgumentTypeMismatchException(MethodArgumentTypeMismatchException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求参数类型不匹配'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(String.format("请求参数类型不匹配,参数[%s]要求类型为:'%s',但输入值为:'%s'", e.getName(), e.getRequiredType().getName(), e.getValue()));
}
/**
*
*/
@ExceptionHandler(RuntimeException.class)
public AjaxResult handleRuntimeException(RuntimeException e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生未知异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
}
/**
*
*/
@ExceptionHandler(Exception.class)
public AjaxResult handleException(Exception e, HttpServletRequest request) {
String requestURI = request.getRequestURI();
log.error("请求地址'{}',发生系统异常.", requestURI, e);
return AjaxResult.error(e.getMessage());
}
/**
*
*/
@ExceptionHandler(BindException.class)
public AjaxResult handleBindException(BindException e) {
log.error(e.getMessage(), e);
String message = e.getAllErrors().get(0).getDefaultMessage();
return AjaxResult.error(message);
}
/**
*
*/
@ExceptionHandler(MethodArgumentNotValidException.class)
public Object handleMethodArgumentNotValidException(MethodArgumentNotValidException e) {
log.error(e.getMessage(), e);
String message = e.getBindingResult().getFieldError().getDefaultMessage();
return AjaxResult.error(message);
}
}

@ -0,0 +1,45 @@
package com.parkingLot.controller;
import com.parkingLot.base.controller.BaseController;
import com.parkingLot.dto.Response.CommonResponse;
import com.parkingLot.service.RemoteCallService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import javax.annotation.Resource;
/**
* @author wu
* @since 2024/12/12 16:39
*/
@RestController
@RequestMapping("/remoteCall")
public class RemoteCallController extends BaseController {
@Resource
private RemoteCallService remoteCallService;
/**
*
*
* @return
*/
@GetMapping("/GetAreaFreeSpaceNum")
public CommonResponse GetAreaFreeSpaceNum() {
return remoteCallService.GetAreaFreeSpaceNum();
}
/**
*
*
* @param plateNo
* @return
*/
@GetMapping("/GetCarInfoByPlateNo")
public CommonResponse GetCarInfoByPlateNo(@RequestParam("plateNo") String plateNo) {
return remoteCallService.GetCarInfoByPlateNo(plateNo);
}
}

@ -0,0 +1,31 @@
package com.parkingLot.dto;
import lombok.Data;
/**
* @author wu
* @since 2024/12/17 13:59
*/
@Data
public class AreaInfoDTO {
/**
*
*/
private Integer areaCode;
/**
*
*/
private String areaName;
/**
*
*/
private Integer freeSpaceNum;
/**
*
*/
private Integer placeCount;
}

@ -0,0 +1,65 @@
package com.parkingLot.dto;
import lombok.Data;
import java.io.Serializable;
/**
* @author wu
* @since 2024/12/17 14:29
*/
@Data
public class CarInfoDTO implements Serializable {
private static final long serialVersionUID = 5405232225738524744L;
/**
*
*/
private String carColor;
/**
*
*/
private String carStyle;
/**
*
*/
private Integer carType;
/**
*
*/
private String entryPlace;
/**
* (yyyy-MM-dd HH:mm:ss)
*/
private String entryTime;
/**
*
*/
private String imgName;
/**
* 1base642=URL访0:
*/
private Integer imgType;
/**
*
*/
private Integer parkingTime;
/**
*
*/
private String plateNo;
/**
* ID
*/
private String trafficId;
}

@ -0,0 +1,31 @@
package com.parkingLot.dto;
import lombok.Data;
import java.util.List;
/**
* @author wu
* @since 2024/12/17 13:58
*/
@Data
public class DataDTO {
private List<AreaInfoDTO> areaInfo;
/**
*
*/
private Integer freeSpaceNum;
/**
*
*/
private String parkName;
/**
*
*/
private Integer totalNum;
}

@ -0,0 +1,28 @@
package com.parkingLot.dto.Response;
import com.fasterxml.jackson.annotation.JsonProperty;
import lombok.Data;
import java.io.Serializable;
/**
*
*
* @author wu
* @since 2024/12/17 13:57
*/
@Data
public class CommonResponse implements Serializable {
private static final long serialVersionUID = -4789816950186563398L;
@JsonProperty("data")
private Object data;
@JsonProperty("resCode")
private String resCode;
@JsonProperty("resMsg")
private String resMsg;
}

@ -0,0 +1,943 @@
package com.parkingLot.quartz;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.collection.CollectionUtil;
import com.parkingLot.dto.AreaInfoDTO;
import com.parkingLot.dto.DataDTO;
import com.parkingLot.dto.Response.CommonResponse;
import com.parkingLot.service.RemoteCallService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import javax.imageio.ImageIO;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
/**
*
*
* @author wu
* @since 2024/12/17 09:15
*/
@Slf4j
@Configuration
@EnableScheduling
public class QuartzImg {
@javax.annotation.Resource
private RemoteCallService remoteCallService;
private DataDTO dataDTO;
/**
*
*/
private void getAreaFreeSpaceNum() {
CommonResponse commonResponse = remoteCallService.GetAreaFreeSpaceNum();
Object data = commonResponse.getData();
if (data == null) {
return;
}
dataDTO = BeanUtil.copyProperties(data, DataDTO.class);
}
/**
* 91
*/
@Scheduled(cron = "0 */1 * * * *")
public void updateImgOne() {
getAreaFreeSpaceNum();
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.91_反面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇南停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.91输出反面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 91
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgTow() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.91_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
;
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.91输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 92
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgThree() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.92_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
;
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.92输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 93
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgFour() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.93_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
;
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.93输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 94
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgFive() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.94_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
;
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇南停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.94输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 95
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgSix() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.95_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
;
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.95输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 96
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgSeven() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.96_反面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
;
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇南停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.96输出反面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 96
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgEight() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.96_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 18);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[2];
;
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 133; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 2 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = height - 68;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.96输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 101
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgNine() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.101_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 50);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[3];
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[2] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇南停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 20; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 5 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = yPosition - 70;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.101输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 102
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgTen() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.102_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 50);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[3];
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[2] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇南停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 20; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 5 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = yPosition - 70;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.102输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 103
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgEleven() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.103_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 50);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[3];
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[2] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇南停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 20; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 5 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = yPosition - 70;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.103输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 104
*/
@Scheduled(cron = "2 */1 * * * *")
public void updateImgTwelve() {
try {
// 加载图片资源
Resource resource = new ClassPathResource("static/templates/192.168.1.104_正面.bmp");
InputStream inputStream = resource.getInputStream();
Image src = ImageIO.read(inputStream);
int width = src.getWidth(null);
int height = src.getHeight(null);
// 创建一个新的BufferedImage对象用于绘制
BufferedImage image = new BufferedImage(width, height, BufferedImage.TYPE_INT_RGB);
Graphics g = image.createGraphics();
// 绘制原始图片
g.drawImage(src, 0, 0, width, height, null);
// 设置字体颜色
g.setColor(new Color(152, 251, 152)); // 设置字体颜色为淡绿色
// 设置加粗字体大小为18
Font font = new Font("黑体", Font.BOLD, 50);
g.setFont(font);
// 要绘制的字符串
String[] text = new String[3];
// 创建FontMetrics对象用于获取字符串的宽度
FontMetrics fm = g.getFontMetrics(font);
if (CollectionUtil.isEmpty(dataDTO.getAreaInfo())) {
return;
}
for (AreaInfoDTO dto : dataDTO.getAreaInfo()) {
if ("镇东停车场".equals(dto.getAreaName())) {
text[2] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇南停车场".equals(dto.getAreaName())) {
text[1] = String.valueOf(dto.getFreeSpaceNum());
}
if ("镇北停车场".equals(dto.getAreaName())) {
text[0] = String.valueOf(dto.getFreeSpaceNum());
}
}
// 设置初始y坐标
int yPosition = height - 20; // 初始y位置
// 循环绘制每个字符串,计算它们的宽度并进行右对齐
for (String str : text) {
int stringWidth = fm.stringWidth(str); // 计算字符串的宽度
// 计算绘制文本的x坐标使文本右对齐
int xPosition = width - 5 - stringWidth;
g.drawString(str, xPosition, yPosition); // 绘制字符串
// 调整y坐标确保文本不重叠
yPosition = yPosition - 70;
}
// 释放图形上下文
g.dispose();
// 输出文件路径
File out = new File("D:\\fujica\\PushScreenInfo\\192.168.1.104输出正面.bmp");
// 检查目标文件所在的目录是否存在
File parentDir = out.getParentFile();
if (!parentDir.exists()) {
// 如果目录不存在,创建该目录
parentDir.mkdirs();
}
// 保存修改后的图片
ImageIO.write(image, "bmp", out);
log.info("图片保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 91
*/
@Scheduled(cron = "5 */1 * * * *")
public void updateImgThirteen() {
try {
// 加载第一个图像
File file1 = new File("D:\\fujica\\PushScreenInfo\\192.168.1.91输出正面.bmp");
BufferedImage image1 = ImageIO.read(file1);
// 加载第二个图像
File file2 = new File("D:\\fujica\\PushScreenInfo\\192.168.1.91输出反面.bmp");
BufferedImage image2 = ImageIO.read(file2);
// 计算合并后图像的宽度和高度
int totalWidth = image1.getWidth() + image2.getWidth(); // 宽度是两个图像宽度之和
int maxHeight = Math.max(image1.getHeight(), image2.getHeight()); // 高度是两个图像中较大的高度
// 创建一个新的BufferedImage对象用于保存合并后的图像
BufferedImage mergedImage = new BufferedImage(totalWidth, maxHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = mergedImage.createGraphics();
// 绘制第一个图像到合并图像的左侧
g.drawImage(image1, 0, 0, null);
// 绘制第二个图像到合并图像的右侧
g.drawImage(image2, image1.getWidth(), 0, null);
// 释放图形上下文
g.dispose();
// 保存合并后的图像
File outFile = new File("D:\\fujica\\PushScreenInfo\\192.168.1.91输出正反.bmp");
ImageIO.write(mergedImage, "bmp", outFile);
log.info("图像合并并保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 96
*/
@Scheduled(cron = "5 */1 * * * *")
public void updateImgFourteen() {
try {
// 加载第一个图像
File file1 = new File("D:\\fujica\\PushScreenInfo\\192.168.1.96输出正面.bmp");
BufferedImage image1 = ImageIO.read(file1);
// 加载第二个图像
File file2 = new File("D:\\fujica\\PushScreenInfo\\192.168.1.96输出反面.bmp");
BufferedImage image2 = ImageIO.read(file2);
// 计算合并后图像的宽度和高度
int totalWidth = image1.getWidth() + image2.getWidth(); // 宽度是两个图像宽度之和
int maxHeight = Math.max(image1.getHeight(), image2.getHeight()); // 高度是两个图像中较大的高度
// 创建一个新的BufferedImage对象用于保存合并后的图像
BufferedImage mergedImage = new BufferedImage(totalWidth, maxHeight, BufferedImage.TYPE_INT_RGB);
Graphics g = mergedImage.createGraphics();
// 绘制第一个图像到合并图像的左侧
g.drawImage(image1, 0, 0, null);
// 绘制第二个图像到合并图像的右侧
g.drawImage(image2, image1.getWidth(), 0, null);
// 释放图形上下文
g.dispose();
// 保存合并后的图像
File outFile = new File("D:\\fujica\\PushScreenInfo\\192.168.1.96输出正反.bmp");
ImageIO.write(mergedImage, "bmp", outFile);
log.info("图像合并并保存成功!");
} catch (IOException e) {
e.printStackTrace();
}
}
}

@ -0,0 +1,27 @@
package com.parkingLot.service;
import com.parkingLot.dto.Response.CommonResponse;
/**
* @author wu
* @since 2024/12/13 09:11
*/
public interface RemoteCallService {
/**
*
*
* @return
*/
CommonResponse GetAreaFreeSpaceNum();
/**
*
*
* @param plateNo
* @return
*/
CommonResponse GetCarInfoByPlateNo(String plateNo);
}

@ -0,0 +1,113 @@
package com.parkingLot.service.impl;
import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.util.IdUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.http.HttpRequest;
import cn.hutool.json.JSONUtil;
import com.alibaba.fastjson2.JSONObject;
import com.parkingLot.dto.CarInfoDTO;
import com.parkingLot.dto.DataDTO;
import com.parkingLot.dto.Response.CommonResponse;
import com.parkingLot.service.RemoteCallService;
import com.parkingLot.utils.SignatureUtil;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import java.util.Map;
/**
* @author wu
* @since 2024/12/13 09:11
*/
@Service
public class RemoteCallServiceImpl implements RemoteCallService {
@Value("${url}")
private String url;
@Value("${appId}")
private String appId;
@Value("${appSecret}")
private String appSecret;
@Value("${parkId}")
private String parkId;
/**
*
*
* @param serviceCode
* @return
*/
private JSONObject getMap(String serviceCode) {
JSONObject jsonObject = new JSONObject();
jsonObject.put("appId", appId);
jsonObject.put("parkId", parkId);
jsonObject.put("ts", System.currentTimeMillis());
jsonObject.put("reqId", IdUtil.fastSimpleUUID());
jsonObject.put("serviceCode", serviceCode);
return jsonObject;
}
/**
*
*
* @return
*/
@Override
public CommonResponse GetAreaFreeSpaceNum() {
CommonResponse response = new CommonResponse();
JSONObject jsonObject = getMap("getAreaFreeSpaceNum");
String key = SignatureUtil.paramsSign(jsonObject, appSecret);
jsonObject.put("key", key);
String body = jsonObject.toJSONString();
String result = HttpRequest.post(url + "api/wec/GetAreaFreeSpaceNum")
.header("version", "1.0.0")
.header("accept-language", "zh-CN")
.body(body).execute().body();
Map<String, Object> map = JSONUtil.parseObj(result);
Object dataObj = map.get("data");
response.setResMsg((String) map.get("resMsg"));
response.setResCode((String) map.get("resCode"));
if (dataObj == null || dataObj == "" || StrUtil.isEmpty(String.valueOf(dataObj))) {
return response;
}
Map<String, Object> data = JSONUtil.parseObj(dataObj);
DataDTO dataDTO = BeanUtil.toBeanIgnoreCase(data, DataDTO.class, false);
response.setData(dataDTO);
return response;
}
/**
*
*
* @param plateNo
* @return
*/
@Override
public CommonResponse GetCarInfoByPlateNo(String plateNo) {
CommonResponse response = new CommonResponse();
JSONObject jsonObject = getMap("getCarInfoByPlateNo");
jsonObject.put("plateNo", plateNo);
String key = SignatureUtil.paramsSign(jsonObject, appSecret);
jsonObject.put("key", key);
String body = jsonObject.toJSONString();
String result = HttpRequest.post(url + "api/wec/GetCarInfoByPlateNo")
.header("version", "1.0.0")
.header("accept-language", "zh-CN")
.body(body).execute().body();
Map<String, Object> map = JSONUtil.parseObj(result);
Object dataObj = map.get("data");
response.setResMsg((String) map.get("resMsg"));
response.setResCode((String) map.get("resCode"));
if (dataObj == null || dataObj == "" || StrUtil.isEmpty(String.valueOf(dataObj))) {
return response;
}
Map<String, Object> data = JSONUtil.parseObj(dataObj);
CarInfoDTO dataDTO = BeanUtil.toBeanIgnoreCase(data, CarInfoDTO.class, false);
response.setData(dataDTO);
return response;
}
}

@ -0,0 +1,85 @@
package com.parkingLot.utils;
import com.alibaba.fastjson2.JSONObject;
import com.google.common.base.Joiner;
import java.nio.charset.StandardCharsets;
import java.security.MessageDigest;
import java.security.NoSuchAlgorithmException;
import java.util.Map;
import java.util.TreeMap;
/**
*
*
* @author wu
* @since 2024/12/13 09:21
*/
public class SignatureUtil {
/**
*
*
* {"amount":100,"orderNo":"闽C12345","payTime":"2020-03-06 10:57:22","freeDetail":"[{\"code\":\"\",\"money\":100,\"time\":0,\"type\":0}]","paySource":"85d15350778b11e9bbaa506b4b2f6421","outOrderNo":"T20200306124536001","parkId":"1000001","payableAmount":200,"reqId":"5be4e3e6d5704a7d91ccbd9731d970f5","payType":1006,"payMethod":6,"appId":"85d15350778b11e9bbaa506b4b2f6421","freeTime":0,"paymentExt":"{\"deviceNo\":\"123456\"}","freeMoney":100,"ts":1583744086841}
* urlamount=100&freeDetail=[{"code":"","money":100,"time":0,"type":0}]&freeMoney=100&freeTime=0&orderNo=C12345&outOrderNo=T20200306124536001&parkId=1000001&payMethod=6&paySource=85d15350778b11e9bbaa506b4b2f6421&payTime=2020-03-06 10:57:22&payType=1006&payableAmount=200&paymentExt={"deviceNo":"123456"}&reqId=5be4e3e6d5704a7d91ccbd9731d970f5&ts=1583744086841&EED96C219E83450A
* B19F7863ADCC8B5442A757AC7B90F6AC
*
* @param requestBody
* @param appSecret
* @return
*/
public static String paramsSign(JSONObject requestBody, String appSecret) {
TreeMap<String, String> params = new TreeMap<>();
//过滤掉keyappId字段空属性及Map或List等复杂对象
requestBody.entrySet().stream().filter(
p -> !"key".equals(p.getKey())
&& !"appId".equals(p.getKey())
&& p.getValue() != null
&& !(p.getValue() instanceof Map)
&& !(p.getValue() instanceof Iterable))
.forEach(p -> {
if (!p.getValue().equals("")) {
params.put(p.getKey(), p.getValue().toString());
}
});
//拼接appSecret
String temp = Joiner.on("&").withKeyValueSeparator("=").join(params).concat("&").concat(appSecret);
return md5(temp).toUpperCase();
}
/**
* md5 , mysql,JavaScriptmd5.
*
* @param plainText
* @return
*/
private static String md5(String plainText) {
if (null == plainText) {
plainText = "";
}
String mD5Str = null;
try {
// JDK 支持以下6种消息摘要算法不区分大小写
// md5,sha(sha-1),md2,sha-256,sha-384,sha-512
MessageDigest md = MessageDigest.getInstance("MD5");
md.update(plainText.getBytes(StandardCharsets.UTF_8));
byte[] b = md.digest();
int i;
StringBuilder builder = new StringBuilder(32);
for (byte value : b) {
i = value;
if (i < 0) {
i += 256;
}
if (i < 16) {
builder.append("0");
}
builder.append(Integer.toHexString(i));
}
mD5Str = builder.toString();
} catch (NoSuchAlgorithmException e) {
e.printStackTrace();
}
return mD5Str;
}
}

@ -0,0 +1,18 @@
# 日志配置
logging:
level:
com.parkingLot: error
org.springframework: error
# 科拓请求地址
url: https://kp-open.keytop.cn/unite-api/
# 科拓appId
appId: 13798
# 科拓appSecret
appSecret: f387dfe312244e46913b2123c70f934e
# 车场id
parkId: 512025407

@ -0,0 +1,13 @@
server:
port: 9004
servlet:
# 应用的访问路径
context-path: /api
spring:
profiles:
active: dev
# 日志配置
logging:
level:
com.parkingLot: info
org.springframework: info

@ -0,0 +1,93 @@
<?xml version="1.0" encoding="UTF-8"?>
<configuration>
<!-- 日志存放路径 -->
<property name="log.path" value="/home/logs/parkingLot"/>
<!-- 日志输出格式 -->
<property name="log.pattern" value="%d{HH:mm:ss.SSS} [%thread] %-5level %logger{20} - [%method,%line] - %msg%n"/>
<!-- 控制台输出 -->
<appender name="console" class="ch.qos.logback.core.ConsoleAppender">
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统日志输出 -->
<appender name="file_info" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-info.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-info.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>INFO</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<appender name="file_error" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-error.log</file>
<!-- 循环政策:基于时间创建日志文件 -->
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 日志文件名格式 -->
<fileNamePattern>${log.path}/sys-error.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
<filter class="ch.qos.logback.classic.filter.LevelFilter">
<!-- 过滤的级别 -->
<level>ERROR</level>
<!-- 匹配时的操作:接收(记录) -->
<onMatch>ACCEPT</onMatch>
<!-- 不匹配时的操作:拒绝(不记录) -->
<onMismatch>DENY</onMismatch>
</filter>
</appender>
<!-- 用户访问日志输出 -->
<appender name="sys-user" class="ch.qos.logback.core.rolling.RollingFileAppender">
<file>${log.path}/sys-user.log</file>
<rollingPolicy class="ch.qos.logback.core.rolling.TimeBasedRollingPolicy">
<!-- 按天回滚 daily -->
<fileNamePattern>${log.path}/sys-user.%d{yyyy-MM-dd}.log</fileNamePattern>
<!-- 日志最大的历史 60天 -->
<maxHistory>60</maxHistory>
</rollingPolicy>
<encoder>
<pattern>${log.pattern}</pattern>
</encoder>
</appender>
<!-- 系统模块日志级别控制 -->
<logger name="com.ruoyi" level="info"/>
<!-- Spring日志级别控制 -->
<logger name="org.springframework" level="warn"/>
<root level="info">
<appender-ref ref="console"/>
</root>
<!--系统操作日志-->
<root level="info">
<appender-ref ref="file_info"/>
<appender-ref ref="file_error"/>
</root>
<!--系统用户操作日志-->
<logger name="sys-user" level="info">
<appender-ref ref="sys-user"/>
</logger>
</configuration>

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 17 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 16 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.5 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.7 KiB

@ -0,0 +1,13 @@
package com.parkingLot;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
@SpringBootTest
class ParkingLotApplicationTests {
@Test
void contextLoads() {
}
}
Loading…
Cancel
Save