|
@@ -2,6 +2,7 @@ package com.sooka.sponest.dataexchange.exchange.controller;
|
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.ruoyi.common.core.exception.file.FileException;
|
|
|
import com.ruoyi.common.core.utils.file.FilePrefixUtils;
|
|
|
import com.ruoyi.system.api.RemoteConfigService;
|
|
|
import com.ruoyi.system.api.RemoteFileService;
|
|
@@ -38,7 +39,7 @@ public class ExchangeController {
|
|
|
@Resource
|
|
|
private RemoteConfigService remoteConfigService;
|
|
|
|
|
|
-// @Value("${}")
|
|
|
+ // @Value("${}")
|
|
|
private String url;
|
|
|
|
|
|
/**
|
|
@@ -73,27 +74,32 @@ public class ExchangeController {
|
|
|
@PostMapping("/straightPushData")
|
|
|
@ResponseBody
|
|
|
public R<?> straightPushData(@RequestBody DataExchangeEntity dataExchangeEntity) {
|
|
|
- log.info("dataExchangeEntity:{}",dataExchangeEntity);
|
|
|
+ log.info("dataExchangeEntity:{}", dataExchangeEntity);
|
|
|
List<String> pictureList = new ArrayList<>();
|
|
|
if (StringUtils.isNotEmpty(SecurityUtils.getToken()) && !CollectionUtils.isEmpty(dataExchangeEntity.getEventPicture())) {
|
|
|
- log.info("token:{}",StringUtils.isNotEmpty(SecurityUtils.getToken()));
|
|
|
+ log.info("token:{}", StringUtils.isNotEmpty(SecurityUtils.getToken()));
|
|
|
for (String picture : dataExchangeEntity.getEventPicture()) {
|
|
|
if (!"image".equals(FilePrefixUtils.getUrlSuffix(picture))) {
|
|
|
log.error("事件图片必须为图片格式---{}", dataExchangeEntity);
|
|
|
return R.fail("事件图片必须为图片格式");
|
|
|
} else {
|
|
|
MultipartFile multipartFile = FilePrefixUtils.urlToMultipartFile(picture, System.currentTimeMillis() + ".jpg");
|
|
|
- log.info("multipartFile:{}",multipartFile);
|
|
|
- SysFile sysFile = SpringUtils.getBean(RemoteFileService.class).upload(multipartFile).getData();
|
|
|
- log.info("sysFile:{}",sysFile);
|
|
|
- pictureList.add(sysFile.getUrl());
|
|
|
+ log.info("multipartFile:{}", multipartFile);
|
|
|
+ try {
|
|
|
+ SysFile sysFile = SpringUtils.getBean(RemoteFileService.class).upload(multipartFile).getData();
|
|
|
+ log.info("sysFile:{}", sysFile);
|
|
|
+ pictureList.add(sysFile.getUrl());
|
|
|
+ } catch (FileException e) {
|
|
|
+ log.info("上传附件失败");
|
|
|
+ }
|
|
|
+
|
|
|
}
|
|
|
}
|
|
|
dataExchangeEntity.setPictureUrlList(pictureList);
|
|
|
R<?> result = remoteEventBaseService.insert3rdSystemEvent(dataExchangeEntity);
|
|
|
- log.info("insert3rdSystemEvent:{}",result);
|
|
|
+ log.info("insert3rdSystemEvent:{}", result);
|
|
|
if (result.getCode() == 200) {
|
|
|
- return R.ok(null,"推送成功");
|
|
|
+ return R.ok(null, "推送成功");
|
|
|
} else {
|
|
|
return R.fail(result.getMsg());
|
|
|
}
|
|
@@ -118,11 +124,11 @@ public class ExchangeController {
|
|
|
jsonObject.put("", dataExchangeEntity);
|
|
|
try {
|
|
|
JSONObject result = RestUtil.post(url, jsonObject);
|
|
|
- log.info("远程调用119:{}",result);
|
|
|
+ log.info("远程调用119:{}", result);
|
|
|
} catch (Exception e) {
|
|
|
log.info("远程调用119报错");
|
|
|
}
|
|
|
- return R.ok(null,"接收成功");
|
|
|
+ return R.ok(null, "接收成功");
|
|
|
}
|
|
|
|
|
|
}
|