|
@@ -276,7 +276,7 @@ public class WechatServiceImpl implements IWechatService { |
|
@@ -276,7 +276,7 @@ public class WechatServiceImpl implements IWechatService { |
276
|
try {
|
276
|
try {
|
277
|
//下载网络图片
|
277
|
//下载网络图片
|
278
|
String fileName = String.valueOf(System.currentTimeMillis()) + MessageSenderConstant.IMG_SUFFIX;
|
278
|
String fileName = String.valueOf(System.currentTimeMillis()) + MessageSenderConstant.IMG_SUFFIX;
|
279
|
- String pathFile = MessageSenderConstant.TEMP_FILE_PATH + fileName;
|
279
|
+ String pathFile = MessageSenderConstant.TEMP_FILE_PATH + '/' + fileName;
|
280
|
HttpClientUtil.downFromPicUrl(customMsgBO.getSendContent(), MessageSenderConstant.TEMP_FILE_PATH, fileName);
|
280
|
HttpClientUtil.downFromPicUrl(customMsgBO.getSendContent(), MessageSenderConstant.TEMP_FILE_PATH, fileName);
|
281
|
//上传微信 获取 media_id
|
281
|
//上传微信 获取 media_id
|
282
|
String addMediaUrl = getMediaUrl(accessToken);
|
282
|
String addMediaUrl = getMediaUrl(accessToken);
|
|
@@ -289,7 +289,7 @@ public class WechatServiceImpl implements IWechatService { |
|
@@ -289,7 +289,7 @@ public class WechatServiceImpl implements IWechatService { |
289
|
JSONObject resultObj = JSONObject.parseObject(mediaIdResult);
|
289
|
JSONObject resultObj = JSONObject.parseObject(mediaIdResult);
|
290
|
|
290
|
|
291
|
//校验返回结果
|
291
|
//校验返回结果
|
292
|
- if (!checkResult(customMsgBO, resultObj,fileName)) return false;
|
292
|
+ if (!checkResult(customMsgBO, resultObj,pathFile)) return false;
|
293
|
|
293
|
|
294
|
//删除下载的图片
|
294
|
//删除下载的图片
|
295
|
deleteFile(pathFile);
|
295
|
deleteFile(pathFile);
|
|
@@ -315,12 +315,12 @@ public class WechatServiceImpl implements IWechatService { |
|
@@ -315,12 +315,12 @@ public class WechatServiceImpl implements IWechatService { |
315
|
return Consts.ADD_MATERIAL_URL.replace("ACCESSTOKEN",accessToken.getToken()).replace("TYPE", WechatCustomMsgTypeEnum.IMAGE.getText());
|
315
|
return Consts.ADD_MATERIAL_URL.replace("ACCESSTOKEN",accessToken.getToken()).replace("TYPE", WechatCustomMsgTypeEnum.IMAGE.getText());
|
316
|
}
|
316
|
}
|
317
|
|
317
|
|
318
|
- private boolean checkResult(WechatCustomMsgBO customMsgBO, JSONObject resultObj,String fileName) throws KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
|
318
|
+ private boolean checkResult(WechatCustomMsgBO customMsgBO, JSONObject resultObj,String pathFile) throws KeyManagementException, NoSuchAlgorithmException, NoSuchProviderException, IOException {
|
319
|
if(resultObj.get("errcode") != null){
|
319
|
if(resultObj.get("errcode") != null){
|
320
|
//这里重新获取token再调用一次
|
320
|
//这里重新获取token再调用一次
|
321
|
String newAccessToken = sendWechatRequest.getNewToken(customMsgBO.getPublicNumCode());
|
321
|
String newAccessToken = sendWechatRequest.getNewToken(customMsgBO.getPublicNumCode());
|
322
|
String addMateralUrl = Consts.ADD_MATERIAL_URL.replace("ACCESSTOKEN",newAccessToken).replace("TYPE", WechatCustomMsgTypeEnum.IMAGE.getText());
|
322
|
String addMateralUrl = Consts.ADD_MATERIAL_URL.replace("ACCESSTOKEN",newAccessToken).replace("TYPE", WechatCustomMsgTypeEnum.IMAGE.getText());
|
323
|
- String mediaIdResult = HttpClientUtil.connectHttpsByPost(addMateralUrl,new File(MessageSenderConstant.TEMP_FILE_PATH + fileName));
|
323
|
+ String mediaIdResult = HttpClientUtil.connectHttpsByPost(addMateralUrl,new File(pathFile));
|
324
|
if(StringUtils.isEmpty(mediaIdResult) || JSONObject.parseObject(mediaIdResult).get("errcode") != null){
|
324
|
if(StringUtils.isEmpty(mediaIdResult) || JSONObject.parseObject(mediaIdResult).get("errcode") != null){
|
325
|
logger.warn("checkResult with try again error,sceneKey is {},error is {}",customMsgBO.getSendKey(),mediaIdResult);
|
325
|
logger.warn("checkResult with try again error,sceneKey is {},error is {}",customMsgBO.getSendKey(),mediaIdResult);
|
326
|
return false;
|
326
|
return false;
|