mirror of
https://codeup.aliyun.com/67c68d4e484ca2f0a13ac3c1/ydc/jsowell-charger-web.git
synced 2026-06-13 03:39:55 +08:00
Merge branch 'dev-new' of http://192.168.2.2:8099/jsowell/jsowell-charger-web into dev-new
This commit is contained in:
@@ -219,4 +219,29 @@ public class CommonController {
|
|||||||
return AjaxResult.error(e.getMessage());
|
return AjaxResult.error(e.getMessage());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 上传蓝牙升级程序到阿里云oss
|
||||||
|
* http://localhost:8080/common/uploadBlueToothFile2OSS
|
||||||
|
* @param file
|
||||||
|
* @return
|
||||||
|
* @throws Exception
|
||||||
|
*/
|
||||||
|
@CrossOrigin
|
||||||
|
@PostMapping("/uploadBlueToothFile2OSS")
|
||||||
|
public AjaxResult uploadBlueToothFile2OSS(MultipartFile file) throws Exception {
|
||||||
|
try {
|
||||||
|
String url = AliyunOssUploadUtils.uploadBlueToothFile(file);
|
||||||
|
AjaxResult ajax = AjaxResult.success();
|
||||||
|
ajax.put("url", url);
|
||||||
|
ajax.put("fileName", FileUtils.getName(url));
|
||||||
|
ajax.put("newFileName", FileUtils.getName(url));
|
||||||
|
ajax.put("originalFilename", file.getOriginalFilename());
|
||||||
|
log.info("固件上传成功 url:{}", url);
|
||||||
|
return ajax;
|
||||||
|
}catch (Exception e){
|
||||||
|
log.error("上传到阿里云oss error, ", e);
|
||||||
|
return AjaxResult.error(e.getMessage());
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -98,12 +98,12 @@ public class PileFirmwareInfoController extends BaseController {
|
|||||||
* @param file
|
* @param file
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
@PostMapping("/uploadBlueToothFile")
|
// @PostMapping("/uploadBlueToothFile")
|
||||||
public AjaxResult uploadBlueToothFile(@RequestParam("avatarfile") MultipartFile file) {
|
// public AjaxResult uploadBlueToothFile(@RequestParam("blueToothFile") MultipartFile file) {
|
||||||
if (!file.isEmpty()) {
|
// if (!file.isEmpty()) {
|
||||||
String result = AliyunOssUploadUtils.uploadBlueToothFile(file);
|
// String result = AliyunOssUploadUtils.uploadBlueToothFile(file);
|
||||||
return AjaxResult.success();
|
// return AjaxResult.success();
|
||||||
}
|
// }
|
||||||
return AjaxResult.error("上传文件错误!!");
|
// return AjaxResult.error("上传文件错误!!");
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -144,7 +144,7 @@ aliyunoss:
|
|||||||
# 蓝牙小程序文件保存路径
|
# 蓝牙小程序文件保存路径
|
||||||
bluetoothFileHost: bluetooth
|
bluetoothFileHost: bluetooth
|
||||||
# 访问域名
|
# 访问域名
|
||||||
# url: https://ydc-oss-dev.oss-cn-shanghai.aliyuncs.com
|
interviewUrl: https://ydc-oss-prod.oss-cn-shanghai.aliyuncs.com
|
||||||
url: http://img.sit.jsowellcloud.com
|
url: http://img.sit.jsowellcloud.com
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ aliyunoss:
|
|||||||
# 蓝牙小程序文件保存路径
|
# 蓝牙小程序文件保存路径
|
||||||
bluetoothFileHost: bluetooth
|
bluetoothFileHost: bluetooth
|
||||||
# 访问域名
|
# 访问域名
|
||||||
# url: https://ydc-oss-prod.oss-cn-shanghai.aliyuncs.com
|
interviewUrl: https://ydc-oss-prod.oss-cn-shanghai.aliyuncs.com
|
||||||
url: https://img.jsowellcloud.com
|
url: https://img.jsowellcloud.com
|
||||||
|
|
||||||
########################微信支付参数#######################################
|
########################微信支付参数#######################################
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ aliyunoss:
|
|||||||
# 蓝牙小程序文件保存路径
|
# 蓝牙小程序文件保存路径
|
||||||
bluetoothFileHost: bluetooth
|
bluetoothFileHost: bluetooth
|
||||||
# 访问域名
|
# 访问域名
|
||||||
# url: https://ydc-oss-prod.oss-cn-shanghai.aliyuncs.com
|
interviewUrl: https://ydc-oss-prod.oss-cn-shanghai.aliyuncs.com
|
||||||
url: https://img.jsowellcloud.com
|
url: https://img.jsowellcloud.com
|
||||||
|
|
||||||
########################微信支付参数#######################################
|
########################微信支付参数#######################################
|
||||||
|
|||||||
@@ -143,7 +143,7 @@ aliyunoss:
|
|||||||
# 蓝牙小程序文件保存路径
|
# 蓝牙小程序文件保存路径
|
||||||
bluetoothFileHost: bluetooth
|
bluetoothFileHost: bluetooth
|
||||||
# 访问域名
|
# 访问域名
|
||||||
# url: https://ydc-oss-dev.oss-cn-shanghai.aliyuncs.com
|
interviewUrl: https://ydc-oss-prod.oss-cn-shanghai.aliyuncs.com
|
||||||
url: http://img.sit.jsowellcloud.com
|
url: http://img.sit.jsowellcloud.com
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -37,6 +37,11 @@ public class AliyunOssConfig {
|
|||||||
*/
|
*/
|
||||||
private String bluetoothFileHost;
|
private String bluetoothFileHost;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 访问域名(上传蓝牙固件时用)
|
||||||
|
*/
|
||||||
|
private String interviewUrl;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 访问域名
|
* 访问域名
|
||||||
*/
|
*/
|
||||||
@@ -90,6 +95,14 @@ public class AliyunOssConfig {
|
|||||||
this.bluetoothFileHost = bluetoothFileHost;
|
this.bluetoothFileHost = bluetoothFileHost;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getInterviewUrl() {
|
||||||
|
return interviewUrl;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInterviewUrl(String interviewUrl) {
|
||||||
|
this.interviewUrl = interviewUrl;
|
||||||
|
}
|
||||||
|
|
||||||
public String getUrl() {
|
public String getUrl() {
|
||||||
return url;
|
return url;
|
||||||
}
|
}
|
||||||
@@ -107,6 +120,7 @@ public class AliyunOssConfig {
|
|||||||
.append("bucketName", bucketName)
|
.append("bucketName", bucketName)
|
||||||
.append("filehost", filehost)
|
.append("filehost", filehost)
|
||||||
.append("bluetoothFileHost", bluetoothFileHost)
|
.append("bluetoothFileHost", bluetoothFileHost)
|
||||||
|
.append("interviewUrl", interviewUrl)
|
||||||
.append("url", url)
|
.append("url", url)
|
||||||
.toString();
|
.toString();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
package com.jsowell.common.util.file;
|
package com.jsowell.common.util.file;
|
||||||
|
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.aliyun.oss.OSS;
|
import com.aliyun.oss.OSS;
|
||||||
import com.aliyun.oss.OSSClientBuilder;
|
import com.aliyun.oss.OSSClientBuilder;
|
||||||
import com.aliyun.oss.model.ObjectMetadata;
|
import com.aliyun.oss.model.ObjectMetadata;
|
||||||
@@ -59,7 +60,7 @@ public class AliyunOssUploadUtils {
|
|||||||
filePathName = aliyunOssConfig.getFilehost() + "/" + dir_name + randomNumber + filePathName;
|
filePathName = aliyunOssConfig.getFilehost() + "/" + dir_name + randomNumber + filePathName;
|
||||||
try {
|
try {
|
||||||
PutObjectResult putObjectResult = ossClient.putObject(aliyunOssConfig.getBucketName(), filePathName, file.getInputStream());
|
PutObjectResult putObjectResult = ossClient.putObject(aliyunOssConfig.getBucketName(), filePathName, file.getInputStream());
|
||||||
log.info("上传OSS成功, url:{}", putObjectResult.getResponse().getUri());
|
// log.info("上传OSS成功, url:{}", putObjectResult.getResponse().getUri());
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -86,7 +87,7 @@ public class AliyunOssUploadUtils {
|
|||||||
filePathName = aliyunOssConfig.getBluetoothFileHost() + "/files/" + filePathName;
|
filePathName = aliyunOssConfig.getBluetoothFileHost() + "/files/" + filePathName;
|
||||||
try {
|
try {
|
||||||
PutObjectResult putObjectResult = ossClient.putObject(aliyunOssConfig.getBucketName(), filePathName, file.getInputStream());
|
PutObjectResult putObjectResult = ossClient.putObject(aliyunOssConfig.getBucketName(), filePathName, file.getInputStream());
|
||||||
log.info("上传OSS成功, url:{}", putObjectResult.getResponse().getUri());
|
// log.info("上传蓝牙升级文件到OSS成功, putObjectResult:{}", JSONObject.toJSONString(putObjectResult));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} finally {
|
} finally {
|
||||||
@@ -94,7 +95,7 @@ public class AliyunOssUploadUtils {
|
|||||||
ossClient.shutdown();
|
ossClient.shutdown();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return aliyunOssConfig.getUrl() + "/" + filePathName;
|
return aliyunOssConfig.getInterviewUrl() + "/" + filePathName;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.jsowell.pile.service;
|
package com.jsowell.pile.service;
|
||||||
|
|
||||||
import com.jsowell.pile.domain.PileFirmwareInfo;
|
import com.jsowell.pile.domain.PileFirmwareInfo;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,13 @@
|
|||||||
package com.jsowell.pile.service.impl;
|
package com.jsowell.pile.service.impl;
|
||||||
|
|
||||||
import com.jsowell.common.util.DateUtils;
|
import com.jsowell.common.util.DateUtils;
|
||||||
|
import com.jsowell.common.util.file.AliyunOssUploadUtils;
|
||||||
import com.jsowell.pile.domain.PileFirmwareInfo;
|
import com.jsowell.pile.domain.PileFirmwareInfo;
|
||||||
import com.jsowell.pile.mapper.PileFirmwareInfoMapper;
|
import com.jsowell.pile.mapper.PileFirmwareInfoMapper;
|
||||||
import com.jsowell.pile.service.PileFirmwareInfoService;
|
import com.jsowell.pile.service.PileFirmwareInfoService;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
|||||||
@@ -129,12 +129,10 @@ public class HttpRequestUtil {
|
|||||||
if(StringUtils.isBlank(label)) {
|
if(StringUtils.isBlank(label)) {
|
||||||
label = operatorId + "(" + url + ")";
|
label = operatorId + "(" + url + ")";
|
||||||
}
|
}
|
||||||
log.info(label + "发送请求 data:{}", data);
|
|
||||||
//加密
|
//加密
|
||||||
byte[] encryptText = Cryptos.aesEncrypt(data.getBytes(),
|
byte[] encryptText = Cryptos.aesEncrypt(data.getBytes(),
|
||||||
dataSecret.getBytes(), dataSecretIV.getBytes());
|
dataSecret.getBytes(), dataSecretIV.getBytes());
|
||||||
String encryptData = Encodes.encodeBase64(encryptText);
|
String encryptData = Encodes.encodeBase64(encryptText);
|
||||||
log.info(label + "发送请求 加密数据:" + encryptData);
|
|
||||||
|
|
||||||
Map<String, String> params = Maps.newLinkedHashMap();
|
Map<String, String> params = Maps.newLinkedHashMap();
|
||||||
params.put("OperatorID", operatorId);
|
params.put("OperatorID", operatorId);
|
||||||
@@ -151,19 +149,18 @@ public class HttpRequestUtil {
|
|||||||
params.put("Sig", sign);
|
params.put("Sig", sign);
|
||||||
|
|
||||||
String postData = JSON.toJSONString(params);
|
String postData = JSON.toJSONString(params);
|
||||||
log.info(label + "发送请求 最终提交数据:{}, 加密数据:{}", params, postData);
|
// log.info(label + "发送请求 最终提交数据:{}, 加密数据:{}", params, postData);
|
||||||
// System.out.println("最终提交数据:" + postData);
|
log.info("[{}]准备发送请求, 原始data:{}, 请求param:{}", label, data, postData);
|
||||||
|
|
||||||
String hutoolRequest = HttpRequest.post(url).header("Authorization", "Bearer " + token).body(postData).execute().body();
|
String response = HttpRequest.post(url).header("Authorization", "Bearer " + token).body(postData).execute().body();
|
||||||
|
|
||||||
log.info(label + "发送请求 接收到返回数据:{}", hutoolRequest);
|
// log.info(label + "发送请求 接收到返回数据:{}", response);
|
||||||
|
log.info("[{}]发送请求成功, params:{}, response:{}", label, postData, response);
|
||||||
|
|
||||||
if (StringUtils.isBlank(hutoolRequest)) {
|
if (StringUtils.isBlank(response)) {
|
||||||
return "返回数据为空";
|
return "返回数据为空";
|
||||||
}
|
}
|
||||||
Map<String, Object> map = (Map<String, Object>) JSON.parse(hutoolRequest);
|
Map<String, Object> map = (Map<String, Object>) JSON.parse(response);
|
||||||
|
|
||||||
// log.info("联联平台发送请求 返回数据map:{}", JSON.toJSONString(map));
|
|
||||||
|
|
||||||
int ret = Integer.parseInt(String.valueOf(map.get("Ret")));
|
int ret = Integer.parseInt(String.valueOf(map.get("Ret")));
|
||||||
String resultMsg = (String) map.get("Msg");
|
String resultMsg = (String) map.get("Msg");
|
||||||
@@ -182,7 +179,7 @@ public class HttpRequestUtil {
|
|||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
log.info(label + "发送请求 返回数据map:{}, 解密数据:{}", JSON.toJSONString(map), plainData);
|
log.info("[{}]解密返参, 返回数据map:{}, 解密数据:{}", label, JSON.toJSONString(map), plainData);
|
||||||
return resultMsg;
|
return resultMsg;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user