24 changed files with 346 additions and 27 deletions
@ -0,0 +1,76 @@ |
|||
package com.xr.iec61850clent.common.util; |
|||
|
|||
import org.apache.poi.ss.usermodel.Workbook; |
|||
|
|||
import javax.imageio.ImageIO; |
|||
import java.awt.image.BufferedImage; |
|||
import java.io.File; |
|||
import java.io.FileOutputStream; |
|||
import java.io.IOException; |
|||
import java.io.InputStream; |
|||
import java.net.URL; |
|||
import java.nio.file.Files; |
|||
import java.nio.file.Path; |
|||
import java.nio.file.Paths; |
|||
import java.nio.file.StandardCopyOption; |
|||
import java.text.SimpleDateFormat; |
|||
import java.util.Date; |
|||
|
|||
public class UploadUtil { |
|||
|
|||
public static String uploadExcel(Workbook workbook,String path,String url1,String fileName) throws Exception{ |
|||
FileOutputStream outputStream =new FileOutputStream(path+fileName); |
|||
workbook.write(outputStream); |
|||
outputStream.close(); |
|||
String url = url1+fileName; |
|||
return url; |
|||
} |
|||
|
|||
|
|||
public static String uploadImage(String clentIp,Integer configId,String fileName) throws Exception { |
|||
// 构建完整的路径
|
|||
String url = "http://"+clentIp+":8080/tao/snapshot"; |
|||
SimpleDateFormat sim=new SimpleDateFormat("yyyy-MM-dd-HH"); |
|||
String date = sim.format(new Date()); |
|||
String dates[] = date.split("-"); |
|||
|
|||
String year = dates[0]; |
|||
String month = dates[1]; |
|||
String day = dates[2]; |
|||
String ho = dates[3]; |
|||
String fullPath = StaticPropUtil.imgUrl+configId + File.separator + year + File.separator + month + File.separator + day + File.separator +ho+File.separator+ fileName; |
|||
|
|||
// 创建目录结构
|
|||
Path directoryPath = Paths.get(StaticPropUtil.imgUrl,configId.toString(), year, month, day,ho); |
|||
if (!java.nio.file.Files.exists(directoryPath)) { |
|||
java.nio.file.Files.createDirectories(directoryPath); |
|||
} |
|||
|
|||
downloadImage(url,fullPath); |
|||
|
|||
// 构建URL
|
|||
String url1 = StaticPropUtil.imgUrl+ configId + "/" + year + "/"+ month + "/" + day + "/" +ho+"/"+ fileName; |
|||
return url1; |
|||
} |
|||
|
|||
public static void delFile(String path,String url,String fileUrl){ |
|||
String filePath = fileUrl.replace(url,path).replace("/","\\"); |
|||
File file = new File(filePath); |
|||
if(file.exists()){ |
|||
file.delete(); |
|||
} |
|||
} |
|||
|
|||
public static void downloadImage(String imageUrl, String destinationPath) throws IOException { |
|||
URL url = new URL(imageUrl); |
|||
try (InputStream in = url.openStream(); |
|||
FileOutputStream out = new FileOutputStream(destinationPath)) { |
|||
byte[] buffer = new byte[1024]; |
|||
int bytesRead; |
|||
while ((bytesRead = in.read(buffer)) != -1) { |
|||
out.write(buffer, 0, bytesRead); |
|||
} |
|||
} |
|||
} |
|||
|
|||
} |
|||
@ -0,0 +1,46 @@ |
|||
<?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.xr.iec61850clent.models.mapper.MeterConfigMapper"> |
|||
|
|||
<resultMap id="BaseResultMap" type="com.xr.iec61850clent.models.entity.MeterConfig"> |
|||
<id property="id" column="id" jdbcType="INTEGER"/> |
|||
<result property="voltageClass" column="voltage_class" jdbcType="VARCHAR"/> |
|||
<result property="owningInterval" column="owning_interval" jdbcType="VARCHAR"/> |
|||
<result property="identificationInterval" column="identification_interval" jdbcType="VARCHAR"/> |
|||
<result property="deviceName" column="device_name" jdbcType="VARCHAR"/> |
|||
<result property="deviceType" column="device_type" jdbcType="VARCHAR"/> |
|||
<result property="meterCode" column="meter_code" jdbcType="VARCHAR"/> |
|||
<result property="meterName" column="meter_name" jdbcType="VARCHAR"/> |
|||
<result property="cameraId" column="camera_id" jdbcType="INTEGER"/> |
|||
<result property="typeId" column="type_id" jdbcType="INTEGER"/> |
|||
<result property="status" column="status" jdbcType="INTEGER"/> |
|||
<result property="firstTime" column="first_time" jdbcType="TIMESTAMP"/> |
|||
<result property="algorithmType" column="algorithm_type" jdbcType="VARCHAR"/> |
|||
<result property="intervalTime" column="interval_time" jdbcType="INTEGER"/> |
|||
<result property="intervalType" column="interval_type" jdbcType="INTEGER"/> |
|||
<result property="focalNumber" column="focal_number" jdbcType="INTEGER"/> |
|||
<result property="parameterConfig" column="parameter_config" jdbcType="VARCHAR"/> |
|||
<result property="remarks" column="remarks" jdbcType="VARCHAR"/> |
|||
<result property="initStatus" column="init_status" jdbcType="VARCHAR"/> |
|||
<result property="createUser" column="create_user" jdbcType="VARCHAR"/> |
|||
<result property="createTime" column="create_time" jdbcType="TIMESTAMP"/> |
|||
<result property="updateUser" column="update_user" jdbcType="VARCHAR"/> |
|||
<result property="updateTime" column="update_time" jdbcType="TIMESTAMP"/> |
|||
<result property="cameraType" column="device_type" jdbcType="VARCHAR"/> |
|||
<result property="cameraName" column="position" jdbcType="VARCHAR"/> |
|||
<result property="typeAlias" column="type_alias" jdbcType="VARCHAR"/> |
|||
<result property="ip" column="device_ip" jdbcType="VARCHAR"/> |
|||
</resultMap> |
|||
|
|||
<select id="selectJzConfig" resultType="com.xr.iec61850clent.models.entity.MeterConfig"> |
|||
select a.*,b.device_ip from meter_config a left join device_camera b |
|||
on a.camera_id = b.id where a.is_jz=1 |
|||
</select> |
|||
|
|||
<select id="selectNoJzConfig" resultType="com.xr.iec61850clent.models.entity.MeterConfig"> |
|||
select a.*,b.device_ip from meter_config a left join device_camera b |
|||
on a.camera_id = b.id where a.ids5000_id=#{ids5000Id} |
|||
</select> |
|||
</mapper> |
|||
@ -0,0 +1,18 @@ |
|||
package com.xr.device_udpclent.common.config; |
|||
|
|||
import org.springframework.context.annotation.Bean; |
|||
import org.springframework.context.annotation.Configuration; |
|||
import org.springframework.scheduling.TaskScheduler; |
|||
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; |
|||
|
|||
@Configuration |
|||
public class AppConfig { |
|||
|
|||
@Bean |
|||
public TaskScheduler taskScheduler() { |
|||
ThreadPoolTaskScheduler scheduler = new ThreadPoolTaskScheduler(); |
|||
scheduler.setPoolSize(5); |
|||
scheduler.initialize(); |
|||
return scheduler; |
|||
} |
|||
} |
|||
Loading…
Reference in new issue