parent
4d01da944f
commit
522dc2d1ba
4
pom.xml
4
pom.xml
|
@ -29,9 +29,9 @@
|
||||||
<java.version>1.8</java.version>
|
<java.version>1.8</java.version>
|
||||||
<junit.version>4.12</junit.version>
|
<junit.version>4.12</junit.version>
|
||||||
<jedis.version>2.9.0</jedis.version>
|
<jedis.version>2.9.0</jedis.version>
|
||||||
<druid.version>1.1.13</druid.version>
|
<druid.version>1.1.18</druid.version>
|
||||||
<mybatisplus.version>3.1.2</mybatisplus.version>
|
<mybatisplus.version>3.1.2</mybatisplus.version>
|
||||||
<mysql.version>8.0.19</mysql.version>
|
<mysql.version>8.0.25</mysql.version>
|
||||||
<mssql.version>4.0</mssql.version>
|
<mssql.version>4.0</mssql.version>
|
||||||
<oracle.version>11.2.0.3</oracle.version>
|
<oracle.version>11.2.0.3</oracle.version>
|
||||||
<commons.lang.version>2.6</commons.lang.version>
|
<commons.lang.version>2.6</commons.lang.version>
|
||||||
|
|
|
@ -11,15 +11,13 @@ import io.swagger.annotations.ApiOperation;
|
||||||
|
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.Date;
|
import java.util.*;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
|
|
||||||
import net.shapelight.common.config.GlobalValue;
|
import net.shapelight.common.config.GlobalValue;
|
||||||
|
@ -335,6 +333,116 @@ public class CarOpenApi {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String dateDir = DateUtils.format(new Date(),DateUtils.DATE_YEAR_MONTH);
|
||||||
|
String fileName = "car/" + dateDir + "/" +parkCode+"/"+UUIDUtil.uuid() + ".jpg";
|
||||||
|
if (!StringUtils.isEmpty(imgUrl)) {
|
||||||
|
URL url = null;
|
||||||
|
InputStream is = null;
|
||||||
|
HttpURLConnection httpUrl = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
//new一个URL对象
|
||||||
|
url = new URL(imgUrl);
|
||||||
|
//打开链接
|
||||||
|
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||||
|
//设置请求方式为"GET"
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
//超时响应时间为5秒
|
||||||
|
conn.setConnectTimeout(5 * 1000);
|
||||||
|
//通过输入流获取图片数据
|
||||||
|
InputStream inStream = conn.getInputStream();
|
||||||
|
|
||||||
|
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
|
//创建一个Buffer字符串
|
||||||
|
byte[] buffer = new byte[1024000];
|
||||||
|
//每次读取的字符串长度,如果为-1,代表全部读取完毕
|
||||||
|
int len = 0;
|
||||||
|
//使用一个输入流从buffer里把数据读取出来
|
||||||
|
while( (len=inStream.read(buffer)) != -1 ){
|
||||||
|
//用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
|
||||||
|
outStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
//得到图片的二进制数据,以二进制封装得到数据,具有通用性
|
||||||
|
byte[] dataImage = outStream.toByteArray();
|
||||||
|
|
||||||
|
//关闭输入流
|
||||||
|
inStream.close();
|
||||||
|
outStream.close();
|
||||||
|
|
||||||
|
ByteArrayInputStream bais = new ByteArrayInputStream(dataImage);
|
||||||
|
BufferedImage image = ImageIO.read(bais);
|
||||||
|
|
||||||
|
//获取图片的宽、高
|
||||||
|
// System.out.println("Width: " + image.getWidth());
|
||||||
|
// System.out.println("Height: " + image.getHeight());
|
||||||
|
int w = image.getWidth();
|
||||||
|
int h = image.getHeight();
|
||||||
|
//调整尺寸不能大于1024
|
||||||
|
if(w>1024 || h>1024){
|
||||||
|
image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
||||||
|
}
|
||||||
|
byte[] data = ImageUtils.imageToBytes(image);
|
||||||
|
is = new ByteArrayInputStream(data);
|
||||||
|
int rl = is.available();
|
||||||
|
PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
|
||||||
|
putObjectOptions.setContentType("image/jpeg");
|
||||||
|
this.minioClient.putObject(this.minioConfig
|
||||||
|
.getBucketName(), fileName, is, putObjectOptions);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// url = new URL(imgUrl);
|
||||||
|
//
|
||||||
|
// BufferedImage image = ImageIO.read(url);
|
||||||
|
// //获取图片的宽、高
|
||||||
|
// System.out.println("Width: " + image.getWidth());
|
||||||
|
// System.out.println("Height: " + image.getHeight());
|
||||||
|
// int w = image.getWidth();
|
||||||
|
// int h = image.getHeight();
|
||||||
|
// //调整尺寸不能大于1024
|
||||||
|
// if(w>1024 || h>1024){
|
||||||
|
// image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
||||||
|
// }
|
||||||
|
// byte[] data = ImageUtils.imageToBytes(image);
|
||||||
|
// is = new ByteArrayInputStream(data);
|
||||||
|
// int rl = is.available();
|
||||||
|
// PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
|
||||||
|
// putObjectOptions.setContentType("image/jpeg");
|
||||||
|
// this.minioClient.putObject(this.minioConfig
|
||||||
|
// .getBucketName(), fileName, is, putObjectOptions);
|
||||||
|
|
||||||
|
|
||||||
|
// httpUrl = (HttpURLConnection) url.openConnection();
|
||||||
|
// httpUrl.connect();
|
||||||
|
//// httpUrl.getInputStream();
|
||||||
|
// is = httpUrl.getInputStream();
|
||||||
|
// PutObjectOptions putObjectOptions = new PutObjectOptions(is.available(), -1L);
|
||||||
|
// putObjectOptions.setContentType("image/jpeg");
|
||||||
|
// this.minioClient.putObject(this.minioConfig
|
||||||
|
// .getBucketName(), fileName, is, putObjectOptions);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("保存图片失败:"+imgUrl+"--------------------"+e);
|
||||||
|
fileName = "";
|
||||||
|
} finally {
|
||||||
|
if (is != null)
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
if (httpUrl != null)
|
||||||
|
httpUrl.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
//去重
|
//去重
|
||||||
if (serviceName.equals("enter")) {
|
if (serviceName.equals("enter")) {
|
||||||
long enterTimeLong = bizContent.getLongValue("enterTime");
|
long enterTimeLong = bizContent.getLongValue("enterTime");
|
||||||
|
@ -372,55 +480,6 @@ public class CarOpenApi {
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
String fileName = "car/" + parkCode + "/" + UUIDUtil.uuid() + ".jpg";
|
|
||||||
if (!StringUtils.isEmpty(imgUrl)) {
|
|
||||||
URL url = null;
|
|
||||||
InputStream is = null;
|
|
||||||
HttpURLConnection httpUrl = null;
|
|
||||||
try {
|
|
||||||
url = new URL(imgUrl);
|
|
||||||
|
|
||||||
BufferedImage image = ImageIO.read(url);
|
|
||||||
//获取图片的宽、高
|
|
||||||
System.out.println("Width: " + image.getWidth());
|
|
||||||
System.out.println("Height: " + image.getHeight());
|
|
||||||
int w = image.getWidth();
|
|
||||||
int h = image.getHeight();
|
|
||||||
//调整尺寸不能大于1024
|
|
||||||
if(w>1024 || h>1024){
|
|
||||||
image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
|
||||||
}
|
|
||||||
byte[] data = ImageUtils.imageToBytes(image);
|
|
||||||
is = new ByteArrayInputStream(data);
|
|
||||||
int rl = is.available();
|
|
||||||
PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
|
|
||||||
putObjectOptions.setContentType("image/jpeg");
|
|
||||||
this.minioClient.putObject(this.minioConfig
|
|
||||||
.getBucketName(), fileName, is, putObjectOptions);
|
|
||||||
|
|
||||||
|
|
||||||
// httpUrl = (HttpURLConnection) url.openConnection();
|
|
||||||
// httpUrl.connect();
|
|
||||||
//// httpUrl.getInputStream();
|
|
||||||
// is = httpUrl.getInputStream();
|
|
||||||
// PutObjectOptions putObjectOptions = new PutObjectOptions(is.available(), -1L);
|
|
||||||
// putObjectOptions.setContentType("image/jpeg");
|
|
||||||
// this.minioClient.putObject(this.minioConfig
|
|
||||||
// .getBucketName(), fileName, is, putObjectOptions);
|
|
||||||
} catch (Exception e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
fileName = "";
|
|
||||||
} finally {
|
|
||||||
if (is != null)
|
|
||||||
try {
|
|
||||||
is.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
}
|
|
||||||
if (httpUrl != null)
|
|
||||||
httpUrl.disconnect();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
Long cellId = null;
|
Long cellId = null;
|
||||||
|
@ -461,8 +520,17 @@ public class CarOpenApi {
|
||||||
enter.setParkCodeXa(parkCodeXa);
|
enter.setParkCodeXa(parkCodeXa);
|
||||||
enter.setChannalCodeXa(channalCodeXa);
|
enter.setChannalCodeXa(channalCodeXa);
|
||||||
enter.setChannalCode(channalCode);
|
enter.setChannalCode(channalCode);
|
||||||
if (fileName.length() > 0)
|
if (fileName.length() > 0){
|
||||||
enter.setImage(fileName);
|
enter.setImage(fileName);
|
||||||
|
// try {
|
||||||
|
// minioClient.statObject(minioConfig.getBucketName(), fileName);
|
||||||
|
// enter.setImage(fileName);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// log.error("照片保存失败:" + fileName);
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
this.tenPackRecordEnterService.saveTr(enter);
|
this.tenPackRecordEnterService.saveTr(enter);
|
||||||
} else if (serviceName.equals("exit")) {
|
} else if (serviceName.equals("exit")) {
|
||||||
long exitTimeLong = bizContent.getLongValue("exitTime");
|
long exitTimeLong = bizContent.getLongValue("exitTime");
|
||||||
|
|
|
@ -619,6 +619,7 @@ public class XaImageTask implements ITask {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if(resJson.contains("ErrorLineParameter")){
|
if(resJson.contains("ErrorLineParameter")){
|
||||||
|
resJson = resJson.replace("(\"T","");
|
||||||
JSONObject resJsonObject = JSONObject.parseObject(resJson);
|
JSONObject resJsonObject = JSONObject.parseObject(resJson);
|
||||||
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
|
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
|
||||||
if(errLine.equals("empty")){
|
if(errLine.equals("empty")){
|
||||||
|
|
|
@ -8,6 +8,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import net.shapelight.common.utils.Constant;
|
||||||
import net.shapelight.common.utils.DateUtils;
|
import net.shapelight.common.utils.DateUtils;
|
||||||
import net.shapelight.modules.sys.entity.SysUserEntity;
|
import net.shapelight.modules.sys.entity.SysUserEntity;
|
||||||
import net.shapelight.modules.sys.service.SysUserService;
|
import net.shapelight.modules.sys.service.SysUserService;
|
||||||
|
@ -84,7 +85,23 @@ public class XaRealDataTask implements ITask {
|
||||||
List<TenRoomEntity> updateRooms = new ArrayList<>();
|
List<TenRoomEntity> updateRooms = new ArrayList<>();
|
||||||
int count = 0;
|
int count = 0;
|
||||||
for (TenRoomEntity room : rooms) {
|
for (TenRoomEntity room : rooms) {
|
||||||
TenPersonEntity owner = this.tenPersonService.getOwner(room.getRoomId());
|
TenPersonEntity owner = null;
|
||||||
|
List<TenPersonEntity> roomPersons = tenPersonService.getByHaveMobilePersonByRoomId(room.getRoomId());
|
||||||
|
for(TenPersonEntity personEntity:roomPersons){
|
||||||
|
if(personEntity.getPersonType().intValue() == Constant.PERSON_TYPE_OWNER){
|
||||||
|
owner = personEntity;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(owner==null){
|
||||||
|
for(TenPersonEntity personEntity:roomPersons){
|
||||||
|
if(personEntity.getPersonType().intValue() == Constant.PERSON_TYPE_MEMBER){
|
||||||
|
owner = personEntity;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// TenPersonEntity owner = this.tenPersonService.getOwner(room.getRoomId());
|
||||||
TenAddressEntity addressEntity = tenAddressService.getById(room.getPId());
|
TenAddressEntity addressEntity = tenAddressService.getById(room.getPId());
|
||||||
if (owner != null && addressEntity != null) {
|
if (owner != null && addressEntity != null) {
|
||||||
XaSYFW xaSYFW = new XaSYFW();
|
XaSYFW xaSYFW = new XaSYFW();
|
||||||
|
|
|
@ -250,26 +250,42 @@ public class XaRecordTask implements ITask {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if(resJson.contains("ErrorLineParameter")){
|
if(resJson.contains("ErrorLineParameter")){
|
||||||
JSONObject resJsonObject = JSONObject.parseObject(resJson);
|
try{
|
||||||
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
|
JSONObject resJsonObject = JSONObject.parseObject(resJson);
|
||||||
if(errLine.equals("empty")){
|
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
|
||||||
for (TenPackRecordEnterEntity recordEntity : updateRecords) {
|
if(errLine.equals("empty")){
|
||||||
recordEntity.setXaSync(1);
|
for (TenPackRecordEnterEntity recordEntity : updateRecords) {
|
||||||
tenPackRecordEnterService.updateById(recordEntity);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
String[] lines = errLine.split(",");
|
|
||||||
List<String> lineList = Arrays.asList(lines);
|
|
||||||
for (int i = 0;i<updateRecords.size();i++) {
|
|
||||||
if(lineList.contains(i+1+"")){
|
|
||||||
continue;
|
|
||||||
}else {
|
|
||||||
TenPackRecordEnterEntity recordEntity = updateRecords.get(i);
|
|
||||||
recordEntity.setXaSync(1);
|
recordEntity.setXaSync(1);
|
||||||
tenPackRecordEnterService.updateById(recordEntity);
|
tenPackRecordEnterService.updateById(recordEntity);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
String[] lines = errLine.trim().split(",");
|
||||||
|
List<String> lineList = Arrays.asList(lines);
|
||||||
|
for (int i = 0;i<updateRecords.size();i++) {
|
||||||
|
if(lineList.contains(i+1+"")){
|
||||||
|
TenPackRecordEnterEntity recordEntity = updateRecords.get(i);
|
||||||
|
recordEntity.setXaSync(1);
|
||||||
|
recordEntity.setXaSyncImage(1);
|
||||||
|
tenPackRecordEnterService.updateById(recordEntity);
|
||||||
|
}else {
|
||||||
|
TenPackRecordEnterEntity recordEntity = updateRecords.get(i);
|
||||||
|
recordEntity.setXaSync(1);
|
||||||
|
// recordEntity.setXaSyncImage(1);
|
||||||
|
tenPackRecordEnterService.updateById(recordEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("停车记录入场记录上报返回数据格式化错误,全部修改为已上传:"+resJson);
|
||||||
|
for (int i = 0;i<updateRecords.size();i++) {
|
||||||
|
TenPackRecordEnterEntity recordEntity = updateRecords.get(i);
|
||||||
|
recordEntity.setXaSync(1);
|
||||||
|
recordEntity.setXaSyncImage(1);
|
||||||
|
tenPackRecordEnterService.updateById(recordEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -357,24 +373,40 @@ public class XaRecordTask implements ITask {
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
if(resJson.contains("ErrorLineParameter")){
|
if(resJson.contains("ErrorLineParameter")){
|
||||||
JSONObject resJsonObject = JSONObject.parseObject(resJson);
|
try{
|
||||||
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
|
JSONObject resJsonObject = JSONObject.parseObject(resJson);
|
||||||
if(errLine.equals("empty")){
|
String errLine = resJsonObject.getJSONObject("sta").getString("ErrorLineParameter").trim();
|
||||||
for (TenPackRecordExitEntity recordEntity : updateRecords) {
|
if(errLine.equals("empty")){
|
||||||
recordEntity.setXaSync(1);
|
for (TenPackRecordExitEntity recordEntity : updateRecords) {
|
||||||
tenPackRecordExitService.updateById(recordEntity);
|
|
||||||
}
|
|
||||||
}else{
|
|
||||||
String[] lines = errLine.split(",");
|
|
||||||
List<String> lineList = Arrays.asList(lines);
|
|
||||||
for (int i = 0;i<updateRecords.size();i++) {
|
|
||||||
if(lineList.contains(i+1+"")){
|
|
||||||
continue;
|
|
||||||
}else {
|
|
||||||
TenPackRecordExitEntity recordEntity = updateRecords.get(i);
|
|
||||||
recordEntity.setXaSync(1);
|
recordEntity.setXaSync(1);
|
||||||
tenPackRecordExitService.updateById(recordEntity);
|
tenPackRecordExitService.updateById(recordEntity);
|
||||||
}
|
}
|
||||||
|
}else{
|
||||||
|
String[] lines = errLine.trim().split(",");
|
||||||
|
List<String> lineList = Arrays.asList(lines);
|
||||||
|
for (int i = 0;i<updateRecords.size();i++) {
|
||||||
|
if(lineList.contains(i+1+"")){
|
||||||
|
TenPackRecordExitEntity recordEntity = updateRecords.get(i);
|
||||||
|
recordEntity.setXaSync(1);
|
||||||
|
recordEntity.setXaSyncImage(1);
|
||||||
|
tenPackRecordExitService.updateById(recordEntity);
|
||||||
|
}else {
|
||||||
|
TenPackRecordExitEntity recordEntity = updateRecords.get(i);
|
||||||
|
recordEntity.setXaSync(1);
|
||||||
|
// recordEntity.setXaSyncImage(1);
|
||||||
|
tenPackRecordExitService.updateById(recordEntity);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}catch (Exception e){
|
||||||
|
//json格式化错误
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("停车记录出场记录上报返回数据格式化错误,全部修改为已上传:"+resJson);
|
||||||
|
for (int i = 0;i<updateRecords.size();i++) {
|
||||||
|
TenPackRecordExitEntity recordEntity = updateRecords.get(i);
|
||||||
|
recordEntity.setXaSync(1);
|
||||||
|
recordEntity.setXaSyncImage(1);
|
||||||
|
tenPackRecordExitService.updateById(recordEntity);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -46,6 +46,8 @@ public class TenCellController extends AbstractController {
|
||||||
private TenPersonService tenPersonService;
|
private TenPersonService tenPersonService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenDeviceService tenDeviceService;
|
private TenDeviceService tenDeviceService;
|
||||||
|
@Autowired
|
||||||
|
private TenRoomService tenRoomService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 列表
|
* 列表
|
||||||
|
@ -196,4 +198,13 @@ public class TenCellController extends AbstractController {
|
||||||
}
|
}
|
||||||
return R.ok().put("data", cellList);
|
return R.ok().put("data", cellList);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@PostMapping("/syncRoomAddress")
|
||||||
|
@ApiOperation("删除小区")
|
||||||
|
@RequiresPermissions("ten:cell")
|
||||||
|
//@RequiresPermissions("ten:cell:delete")
|
||||||
|
public R syncRoomAddress(@RequestParam("cellId") Long cellId){
|
||||||
|
int count = tenRoomService.syncAddress(cellId);
|
||||||
|
return R.ok().put("count",count);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,6 +92,9 @@ public interface TenPersonDao {
|
||||||
|
|
||||||
List<TenPersonEntity> getNotSyncImage(@Param("cellId") Long paramLong);
|
List<TenPersonEntity> getNotSyncImage(@Param("cellId") Long paramLong);
|
||||||
|
|
||||||
|
List<TenPersonEntity> getByHaveMobilePersonByRoomId(@Param("roomId") Long roomId);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,5 +47,9 @@ public interface TenRoomDao {
|
||||||
|
|
||||||
List<TenRoomEntity> getNotSync(@Param("cellId") Long paramLong);
|
List<TenRoomEntity> getNotSync(@Param("cellId") Long paramLong);
|
||||||
|
|
||||||
|
List<TenRoomEntity> getNotBindByCellId(@Param("cellId") Long paramLong);
|
||||||
|
|
||||||
|
List<TenRoomEntity> getPicByCellId(@Param("pId") Long pId,@Param("cellId") Long paramLong);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,5 +30,7 @@ public interface TenCellService extends IService<TenCellEntity> {
|
||||||
|
|
||||||
void updateByIdResis(TenCellEntity cell);
|
void updateByIdResis(TenCellEntity cell);
|
||||||
|
|
||||||
|
int syncRoomAddress(Long cellId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -120,6 +120,8 @@ public interface TenPersonService {
|
||||||
|
|
||||||
List<TenPersonEntity> getNotSyncImage(Long paramLong);
|
List<TenPersonEntity> getNotSyncImage(Long paramLong);
|
||||||
|
|
||||||
|
List<TenPersonEntity> getByHaveMobilePersonByRoomId(Long roomId);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -48,5 +48,7 @@ public interface TenRoomService {
|
||||||
int getAllCount(Map params);
|
int getAllCount(Map params);
|
||||||
|
|
||||||
List<TenRoomEntity> getNotSync(Long paramLong);
|
List<TenRoomEntity> getNotSync(Long paramLong);
|
||||||
|
|
||||||
|
int syncAddress(Long cellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -7,6 +7,7 @@ import net.shapelight.common.utils.SnowflakeIdWorker;
|
||||||
import net.shapelight.modules.sys.entity.SysUserEntity;
|
import net.shapelight.modules.sys.entity.SysUserEntity;
|
||||||
import net.shapelight.modules.sys.service.SysUserRoleService;
|
import net.shapelight.modules.sys.service.SysUserRoleService;
|
||||||
import net.shapelight.modules.sys.service.SysUserService;
|
import net.shapelight.modules.sys.service.SysUserService;
|
||||||
|
import net.shapelight.modules.ten.entity.TenRoomEntity;
|
||||||
import net.shapelight.modules.ten.entity.TenUserScopeEntity;
|
import net.shapelight.modules.ten.entity.TenUserScopeEntity;
|
||||||
import net.shapelight.modules.ten.service.*;
|
import net.shapelight.modules.ten.service.*;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
@ -178,4 +179,9 @@ public class TenCellServiceImpl extends ServiceImpl<TenCellDao, TenCellEntity> i
|
||||||
}
|
}
|
||||||
return cellIdList;
|
return cellIdList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public int syncRoomAddress(Long cellId) {
|
||||||
|
return tenRoomService.syncAddress(cellId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2065,4 +2065,9 @@ public class TenPersonServiceImpl implements TenPersonService {
|
||||||
public List<TenPersonEntity> getNotSyncImage(Long cellId) {
|
public List<TenPersonEntity> getNotSyncImage(Long cellId) {
|
||||||
return this.tenPersonDao.getNotSyncImage(cellId);
|
return this.tenPersonDao.getNotSyncImage(cellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<TenPersonEntity> getByHaveMobilePersonByRoomId(Long roomId) {
|
||||||
|
return this.tenPersonDao.getByHaveMobilePersonByRoomId(roomId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,10 +2,9 @@ package net.shapelight.modules.ten.service.impl;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
import net.shapelight.modules.ten.entity.TenAddressEntity;
|
import net.shapelight.modules.ten.entity.TenAddressEntity;
|
||||||
|
import net.shapelight.modules.ten.entity.TenBuildEntity;
|
||||||
import net.shapelight.modules.ten.entity.TenCellEntity;
|
import net.shapelight.modules.ten.entity.TenCellEntity;
|
||||||
import net.shapelight.modules.ten.service.TenAddressService;
|
import net.shapelight.modules.ten.service.*;
|
||||||
import net.shapelight.modules.ten.service.TenCellService;
|
|
||||||
import net.shapelight.modules.ten.service.TenPersonService;
|
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.cache.annotation.CacheEvict;
|
import org.springframework.cache.annotation.CacheEvict;
|
||||||
import org.springframework.cache.annotation.Cacheable;
|
import org.springframework.cache.annotation.Cacheable;
|
||||||
|
@ -22,7 +21,6 @@ import net.shapelight.common.utils.Query;
|
||||||
|
|
||||||
import net.shapelight.modules.ten.dao.TenRoomDao;
|
import net.shapelight.modules.ten.dao.TenRoomDao;
|
||||||
import net.shapelight.modules.ten.entity.TenRoomEntity;
|
import net.shapelight.modules.ten.entity.TenRoomEntity;
|
||||||
import net.shapelight.modules.ten.service.TenRoomService;
|
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
|
||||||
|
@ -36,6 +34,8 @@ public class TenRoomServiceImpl implements TenRoomService {
|
||||||
private TenPersonService tenPersonService;
|
private TenPersonService tenPersonService;
|
||||||
@Autowired
|
@Autowired
|
||||||
private TenAddressService tenAddressService;
|
private TenAddressService tenAddressService;
|
||||||
|
@Autowired
|
||||||
|
private TenBuildService tenBuildService;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageUtils queryPage(Map<String, Object> params) {
|
public PageUtils queryPage(Map<String, Object> params) {
|
||||||
|
@ -203,5 +203,41 @@ public class TenRoomServiceImpl implements TenRoomService {
|
||||||
return this.tenRoomDao.getNotSync(cellId);
|
return this.tenRoomDao.getNotSync(cellId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public int syncAddress(Long cellId) {
|
||||||
|
List<TenRoomEntity> allRooms = tenRoomDao.getNotBindByCellId(cellId);
|
||||||
|
TenCellEntity cellEntity = tenCellService.getById(cellId);
|
||||||
|
int count = 0;
|
||||||
|
String xqid = cellEntity.getThirdId();
|
||||||
|
if(xqid != null && !xqid.isEmpty()){
|
||||||
|
for(TenRoomEntity roomEntity: allRooms){
|
||||||
|
TenBuildEntity buildEntity = tenBuildService.getById(roomEntity.getBuildId(),roomEntity.getCellId());
|
||||||
|
String buildNumber = buildEntity.getNumber();
|
||||||
|
String unit = buildEntity.getUnit();
|
||||||
|
String layer = roomEntity.getLayer().toString();
|
||||||
|
String roomNumber = roomEntity.getRoomNumber().toString();
|
||||||
|
String address = "号"+buildNumber+"栋"+unit+"单元"+layer+"层"+roomNumber+"号";
|
||||||
|
//查询可以关联的标准地址
|
||||||
|
List<TenAddressEntity> searchAddressList = tenAddressService.list(new QueryWrapper<TenAddressEntity>()
|
||||||
|
.eq("dzjb",14)
|
||||||
|
.eq("xqid",xqid)
|
||||||
|
.like("dzqc",address));
|
||||||
|
//查询关联的是否已经绑定
|
||||||
|
if(searchAddressList.size() == 1){
|
||||||
|
TenAddressEntity addressEntity = searchAddressList.get(0);
|
||||||
|
List<TenRoomEntity> roomBind = tenRoomDao.getPicByCellId(addressEntity.getPId(),roomEntity.getCellId());
|
||||||
|
//没有绑定
|
||||||
|
if(roomBind.size() == 0){
|
||||||
|
count++;
|
||||||
|
roomEntity.setPId(addressEntity.getPId());
|
||||||
|
tenRoomDao.updateById(roomEntity);
|
||||||
|
}else{
|
||||||
|
String roomName = roomEntity.getRoomName();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return count;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,7 +3,7 @@ spring:
|
||||||
type: com.alibaba.druid.pool.DruidDataSource
|
type: com.alibaba.druid.pool.DruidDataSource
|
||||||
druid:
|
druid:
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://192.168.50.232:3306/cell_db_0511?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&rewriteBatchedStatements=true
|
url: jdbc:mysql://192.168.50.232:3306/cell_db_0621?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&useSSL=false&rewriteBatchedStatements=true
|
||||||
username: user
|
username: user
|
||||||
password: user@server001
|
password: user@server001
|
||||||
initial-size: 10
|
initial-size: 10
|
||||||
|
@ -19,23 +19,23 @@ spring:
|
||||||
test-on-borrow: false
|
test-on-borrow: false
|
||||||
test-on-return: false
|
test-on-return: false
|
||||||
stat-view-servlet:
|
stat-view-servlet:
|
||||||
enabled: true
|
enabled: false
|
||||||
url-pattern: /druid/*
|
url-pattern: /druid/*
|
||||||
login-username: admin
|
login-username: admin
|
||||||
login-password: admin
|
login-password: admin@A1
|
||||||
allow: 61.185.224.80
|
allow:
|
||||||
web-stat-filter:
|
web-stat-filter:
|
||||||
enabled: true
|
enabled: false
|
||||||
filter:
|
filter:
|
||||||
stat:
|
stat:
|
||||||
log-slow-sql: true
|
log-slow-sql: true
|
||||||
slow-sql-millis: 1000
|
slow-sql-millis: 1000
|
||||||
merge-sql: false
|
merge-sql: false
|
||||||
enabled: true
|
enabled: true
|
||||||
db-type: mysql
|
db-type: mysql
|
||||||
wall:
|
wall:
|
||||||
config:
|
config:
|
||||||
multi-statement-allow: true
|
multi-statement-allow: true
|
||||||
|
|
||||||
|
|
||||||
#sharding.jdbc:
|
#sharding.jdbc:
|
||||||
|
|
|
@ -919,10 +919,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getNotSync" resultType="net.shapelight.modules.ten.entity.TenPersonEntity">
|
<select id="getNotSync" resultType="net.shapelight.modules.ten.entity.TenPersonEntity">
|
||||||
select * from ten_person
|
select * from ten_person p left join ten_room r
|
||||||
where cell_id = #{cellId}
|
on p.room_id = r.room_id
|
||||||
and delete_flag = 0 and (person_type = 5000 || person_type = 5001)
|
where p.cell_id = #{cellId}
|
||||||
and xa_sync = 0
|
and p.delete_flag = 0 and (p.person_type = 5000 || p.person_type = 5001)
|
||||||
|
and p.xa_sync = 0
|
||||||
|
and r.xa_sync = 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
<select id="getNotSyncCard" resultType="net.shapelight.modules.ten.entity.TenPersonEntity">
|
<select id="getNotSyncCard" resultType="net.shapelight.modules.ten.entity.TenPersonEntity">
|
||||||
|
@ -941,6 +943,12 @@
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
<select id="getByHaveMobilePersonByRoomId" resultType="net.shapelight.modules.ten.entity.TenPersonEntity">
|
||||||
|
select * from ten_person
|
||||||
|
where room_id = #{roomId} and trim(mobile) != ''
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -421,6 +421,17 @@
|
||||||
and p_id is not null
|
and p_id is not null
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getNotBindByCellId" resultType="net.shapelight.modules.ten.entity.TenRoomEntity">
|
||||||
|
select * from ten_room where delete_flag = 0
|
||||||
|
and cell_id = #{cellId} and p_id is null
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="getPicByCellId" resultType="net.shapelight.modules.ten.entity.TenRoomEntity">
|
||||||
|
select * from ten_room where delete_flag = 0
|
||||||
|
and p_id = #{pId}
|
||||||
|
and cell_id = #{cellId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ package gb;
|
||||||
|
|
||||||
import io.minio.MinioClient;
|
import io.minio.MinioClient;
|
||||||
import io.minio.PutObjectOptions;
|
import io.minio.PutObjectOptions;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import net.coobird.thumbnailator.Thumbnails;
|
import net.coobird.thumbnailator.Thumbnails;
|
||||||
import net.shapelight.AdminApplication;
|
import net.shapelight.AdminApplication;
|
||||||
import net.shapelight.common.config.MinioConfig;
|
import net.shapelight.common.config.MinioConfig;
|
||||||
|
@ -20,10 +21,12 @@ import java.awt.image.BufferedImage;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
|
||||||
@RunWith(SpringRunner.class)
|
@RunWith(SpringRunner.class)
|
||||||
@SpringBootTest(classes = AdminApplication.class)
|
@SpringBootTest(classes = AdminApplication.class)
|
||||||
|
@Slf4j
|
||||||
public class CarImageTest {
|
public class CarImageTest {
|
||||||
@Autowired
|
@Autowired
|
||||||
private MinioClient minioClient;
|
private MinioClient minioClient;
|
||||||
|
@ -33,9 +36,11 @@ public class CarImageTest {
|
||||||
@Test
|
@Test
|
||||||
public void ossTest() {
|
public void ossTest() {
|
||||||
|
|
||||||
String imgUrl = "http://icecloud-prod.oss-cn-shenzhen.aliyuncs.com/P1610092525/image/202104/25/%E9%99%95A207AY_out_2_5802.jpg?Expires=1619330640&OSSAccessKeyId=LTAI4Furp7fmTGDMRhJ95jaX&Signature=2xS3T%2FlK9LMe%2FjAOotCEvIlCOmU%3D";
|
String imgUrl = "http://icecloud-prod.oss-cn-shenzhen.aliyuncs.com/P1613901148/image/202106/17/%E9%99%95A3U32K_out_2_4472.jpg?Expires=1623895438&OSSAccessKeyId=LTAI4Furp7fmTGDMRhJ95jaX&Signature=iJ7H8%2FmOQz2Zs81APGk2SMrREGQ%3D";
|
||||||
imgUrl = imgUrl.replace("amp;", "");
|
imgUrl = imgUrl.replace("amp;", "");
|
||||||
String fileName = "car/" + 222 + "/" + UUIDUtil.uuid() + ".jpg";
|
String fileName = "car/" + 222 + "/" + UUIDUtil.uuid() + ".jpg";
|
||||||
|
|
||||||
|
|
||||||
if (!StringUtils.isEmpty(imgUrl)) {
|
if (!StringUtils.isEmpty(imgUrl)) {
|
||||||
URL url = null;
|
URL url = null;
|
||||||
InputStream is = null;
|
InputStream is = null;
|
||||||
|
@ -43,50 +48,26 @@ public class CarImageTest {
|
||||||
try {
|
try {
|
||||||
url = new URL(imgUrl);
|
url = new URL(imgUrl);
|
||||||
|
|
||||||
|
|
||||||
BufferedImage image = ImageIO.read(url);
|
BufferedImage image = ImageIO.read(url);
|
||||||
//获取图片的宽、高
|
//获取图片的宽、高
|
||||||
System.out.println("Width: " + image.getWidth());
|
System.out.println("Width: " + image.getWidth());
|
||||||
System.out.println("Height: " + image.getHeight());
|
System.out.println("Height: " + image.getHeight());
|
||||||
//调整图片大小为 400X400尺寸
|
|
||||||
// BufferedImage newImage = ImageUtils.resizeImage(image,400,400);
|
|
||||||
int w = image.getWidth();
|
int w = image.getWidth();
|
||||||
int h = image.getHeight();
|
int h = image.getHeight();
|
||||||
|
//调整尺寸不能大于1024
|
||||||
if(w>1024 || h>1024){
|
if(w>1024 || h>1024){
|
||||||
image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// BufferedImage resizeBuff = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
|
||||||
|
|
||||||
|
|
||||||
// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
|
||||||
// if (w > 1024 || h > 1024) {
|
|
||||||
// Thumbnails.of(image)
|
|
||||||
// .size(1024, 1024)
|
|
||||||
//// .outputFormat("JPEG")
|
|
||||||
//// .outputQuality(1)
|
|
||||||
// .toOutputStream(outputStream);
|
|
||||||
// }
|
|
||||||
|
|
||||||
byte[] data = ImageUtils.imageToBytes(image);
|
byte[] data = ImageUtils.imageToBytes(image);
|
||||||
// ByteArrayInputStream
|
|
||||||
is = new ByteArrayInputStream(data);
|
is = new ByteArrayInputStream(data);
|
||||||
int rl = is.available();
|
int rl = is.available();
|
||||||
|
|
||||||
|
|
||||||
// httpUrl = (HttpURLConnection) url.openConnection();
|
|
||||||
// httpUrl.connect();
|
|
||||||
//// httpUrl.getInputStream();
|
|
||||||
// is = httpUrl.getInputStream();
|
|
||||||
// int rl = httpUrl.getContentLength();
|
|
||||||
// int l = is.available();
|
|
||||||
PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
|
PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
|
||||||
putObjectOptions.setContentType("image/jpeg");
|
putObjectOptions.setContentType("image/jpeg");
|
||||||
this.minioClient.putObject(this.minioConfig
|
this.minioClient.putObject(this.minioConfig
|
||||||
.getBucketName(), fileName, is, putObjectOptions);
|
.getBucketName(), fileName, is, putObjectOptions);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
// log.error("保存图片失败:"+imgUrl+":"+e.getMessage());
|
||||||
fileName = "";
|
fileName = "";
|
||||||
} finally {
|
} finally {
|
||||||
if (is != null)
|
if (is != null)
|
||||||
|
@ -99,5 +80,157 @@ public class CarImageTest {
|
||||||
httpUrl.disconnect();
|
httpUrl.disconnect();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
// String imgUrl = "http://icecloud-prod.oss-cn-shenzhen.aliyuncs.com/P1610092525/image/202104/25/%E9%99%95A207AY_out_2_5802.jpg?Expires=1619330640&OSSAccessKeyId=LTAI4Furp7fmTGDMRhJ95jaX&Signature=2xS3T%2FlK9LMe%2FjAOotCEvIlCOmU%3D";
|
||||||
|
// imgUrl = imgUrl.replace("amp;", "");
|
||||||
|
// String fileName = "car/" + 222 + "/" + UUIDUtil.uuid() + ".jpg";
|
||||||
|
// if (!StringUtils.isEmpty(imgUrl)) {
|
||||||
|
// URL url = null;
|
||||||
|
// InputStream is = null;
|
||||||
|
// HttpURLConnection httpUrl = null;
|
||||||
|
// try {
|
||||||
|
// url = new URL(imgUrl);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
// BufferedImage image = ImageIO.read(url);
|
||||||
|
// //获取图片的宽、高
|
||||||
|
// System.out.println("Width: " + image.getWidth());
|
||||||
|
// System.out.println("Height: " + image.getHeight());
|
||||||
|
// //调整图片大小为 400X400尺寸
|
||||||
|
//// BufferedImage newImage = ImageUtils.resizeImage(image,400,400);
|
||||||
|
// int w = image.getWidth();
|
||||||
|
// int h = image.getHeight();
|
||||||
|
// if(w>1024 || h>1024){
|
||||||
|
// image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// BufferedImage resizeBuff = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||||
|
//// if (w > 1024 || h > 1024) {
|
||||||
|
//// Thumbnails.of(image)
|
||||||
|
//// .size(1024, 1024)
|
||||||
|
////// .outputFormat("JPEG")
|
||||||
|
////// .outputQuality(1)
|
||||||
|
//// .toOutputStream(outputStream);
|
||||||
|
//// }
|
||||||
|
//
|
||||||
|
// byte[] data = ImageUtils.imageToBytes(image);
|
||||||
|
//// ByteArrayInputStream
|
||||||
|
// is = new ByteArrayInputStream(data);
|
||||||
|
// int rl = is.available();
|
||||||
|
//
|
||||||
|
//
|
||||||
|
//// httpUrl = (HttpURLConnection) url.openConnection();
|
||||||
|
//// httpUrl.connect();
|
||||||
|
////// httpUrl.getInputStream();
|
||||||
|
//// is = httpUrl.getInputStream();
|
||||||
|
//// int rl = httpUrl.getContentLength();
|
||||||
|
//// int l = is.available();
|
||||||
|
// PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
|
||||||
|
// putObjectOptions.setContentType("image/jpeg");
|
||||||
|
// this.minioClient.putObject(this.minioConfig
|
||||||
|
// .getBucketName(), fileName, is, putObjectOptions);
|
||||||
|
// } catch (Exception e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// fileName = "";
|
||||||
|
// } finally {
|
||||||
|
// if (is != null)
|
||||||
|
// try {
|
||||||
|
// is.close();
|
||||||
|
// } catch (IOException e) {
|
||||||
|
// e.printStackTrace();
|
||||||
|
// }
|
||||||
|
// if (httpUrl != null)
|
||||||
|
// httpUrl.disconnect();
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void imageUrlTest() {
|
||||||
|
String imgUrl = "http://icecloud-prod.oss-cn-shenzhen.aliyuncs.com/P1613901148/image/202106/17/%E9%99%95AH345%E5%AD%A6_in_2_9660.jpg?Expires=1623901253&OSSAccessKeyId=LTAI4Furp7fmTGDMRhJ95jaX&Signature=ASDVTMGzPt8INggoslRbYBgyenc%3D";
|
||||||
|
imgUrl = imgUrl.replace("amp;", "");
|
||||||
|
String fileName = "car/" + 222 + "/" + UUIDUtil.uuid() + ".jpg";
|
||||||
|
|
||||||
|
log.error("开始执行");
|
||||||
|
|
||||||
|
if (!StringUtils.isEmpty(imgUrl)) {
|
||||||
|
URL url = null;
|
||||||
|
InputStream is = null;
|
||||||
|
// HttpURLConnection httpUrl = null;
|
||||||
|
try {
|
||||||
|
|
||||||
|
//new一个URL对象
|
||||||
|
url = new URL(imgUrl);
|
||||||
|
//打开链接
|
||||||
|
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
|
||||||
|
//设置请求方式为"GET"
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
//超时响应时间为5秒
|
||||||
|
conn.setConnectTimeout(5 * 1000);
|
||||||
|
//通过输入流获取图片数据
|
||||||
|
InputStream inStream = conn.getInputStream();
|
||||||
|
|
||||||
|
ByteArrayOutputStream outStream = new ByteArrayOutputStream();
|
||||||
|
//创建一个Buffer字符串
|
||||||
|
byte[] buffer = new byte[1024000];
|
||||||
|
//每次读取的字符串长度,如果为-1,代表全部读取完毕
|
||||||
|
int len = 0;
|
||||||
|
//使用一个输入流从buffer里把数据读取出来
|
||||||
|
while( (len=inStream.read(buffer)) != -1 ){
|
||||||
|
//用输出流往buffer里写入数据,中间参数代表从哪个位置开始读,len代表读取的长度
|
||||||
|
outStream.write(buffer, 0, len);
|
||||||
|
}
|
||||||
|
|
||||||
|
//得到图片的二进制数据,以二进制封装得到数据,具有通用性
|
||||||
|
byte[] dataImage = outStream.toByteArray();
|
||||||
|
|
||||||
|
//关闭输入流
|
||||||
|
inStream.close();
|
||||||
|
outStream.close();
|
||||||
|
|
||||||
|
ByteArrayInputStream bais = new ByteArrayInputStream(dataImage);
|
||||||
|
BufferedImage image = ImageIO.read(bais);
|
||||||
|
|
||||||
|
//获取图片的宽、高
|
||||||
|
// System.out.println("Width: " + image.getWidth());
|
||||||
|
// System.out.println("Height: " + image.getHeight());
|
||||||
|
int w = image.getWidth();
|
||||||
|
int h = image.getHeight();
|
||||||
|
//调整尺寸不能大于1024
|
||||||
|
if(w>1024 || h>1024){
|
||||||
|
image = ThumbnailsUtils.resizeImageOne(image,1024,1024);
|
||||||
|
}
|
||||||
|
byte[] data = ImageUtils.imageToBytes(image);
|
||||||
|
is = new ByteArrayInputStream(data);
|
||||||
|
int rl = is.available();
|
||||||
|
PutObjectOptions putObjectOptions = new PutObjectOptions(rl, -1L);
|
||||||
|
putObjectOptions.setContentType("image/jpeg");
|
||||||
|
this.minioClient.putObject(this.minioConfig
|
||||||
|
.getBucketName(), fileName, is, putObjectOptions);
|
||||||
|
} catch (Exception e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
log.error("保存图片失败:"+imgUrl+"-----------------"+e.getMessage());
|
||||||
|
fileName = "";
|
||||||
|
} finally {
|
||||||
|
if (is != null)
|
||||||
|
try {
|
||||||
|
is.close();
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
// if (httpUrl != null)
|
||||||
|
// httpUrl.disconnect();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
log.error("结束执行");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue