|
@@ -134,15 +134,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
|
|
|
|
|
IPage<StoreCommentAppealVo> storeCommentAppealPage = storeCommentAppealMapper.getStoreCommentAppealPage(new Page<>(pageNum, pageSize), wrapper);
|
|
IPage<StoreCommentAppealVo> storeCommentAppealPage = storeCommentAppealMapper.getStoreCommentAppealPage(new Page<>(pageNum, pageSize), wrapper);
|
|
|
storeCommentAppealPage.getRecords().forEach(item -> {
|
|
storeCommentAppealPage.getRecords().forEach(item -> {
|
|
|
- String[] split = item.getImgId().split(",");
|
|
|
|
|
- List<String> imgList = new ArrayList<>();
|
|
|
|
|
- for (String s : split) {
|
|
|
|
|
- StoreImg storeImg = storeImgMapper.selectById(s);
|
|
|
|
|
- if (null != storeImg) {
|
|
|
|
|
- imgList.add(storeImg.getImgUrl());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- item.setImgList(imgList);
|
|
|
|
|
|
|
+ item.setImgList(buildAppealImgList(item.getImgId()));
|
|
|
|
|
|
|
|
if (StringUtils.isNotEmpty(item.getCommentImgId())) {
|
|
if (StringUtils.isNotEmpty(item.getCommentImgId())) {
|
|
|
String[] imgId = item.getCommentImgId().split(",");
|
|
String[] imgId = item.getCommentImgId().split(",");
|
|
@@ -257,14 +249,14 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
/**
|
|
/**
|
|
|
* 新增申诉
|
|
* 新增申诉
|
|
|
*
|
|
*
|
|
|
- * @param multipartRequest 文件
|
|
|
|
|
- * @param storeId 门店id
|
|
|
|
|
- * @param commentId 评论id
|
|
|
|
|
- * @param appealReason 申诉原因
|
|
|
|
|
- * @return Integer(0 : 申诉成功, 1 : 申诉失败, 2 : 申诉已存在, 3 : 文本内容异常)
|
|
|
|
|
|
|
+ * @param imgUrls 申诉图片OSS地址,多个用英文逗号分隔
|
|
|
|
|
+ * @param storeId 门店id
|
|
|
|
|
+ * @param commentId 评论id
|
|
|
|
|
+ * @param appealReason 申诉原因
|
|
|
|
|
+ * @return StoreCommentAppealInfoVo(result: 0申诉成功, 1申诉失败, 2申诉已存在, 3文本内容异常)
|
|
|
*/
|
|
*/
|
|
|
@Override
|
|
@Override
|
|
|
- public StoreCommentAppealInfoVo addAppealNew(MultipartRequest multipartRequest, Integer storeId, Integer commentId, String appealReason) {
|
|
|
|
|
|
|
+ public StoreCommentAppealInfoVo addAppealNew(String imgUrls, Integer storeId, Integer commentId, String appealReason) {
|
|
|
StoreCommentAppealInfoVo storeCommentAppealInfoVo = new StoreCommentAppealInfoVo();
|
|
StoreCommentAppealInfoVo storeCommentAppealInfoVo = new StoreCommentAppealInfoVo();
|
|
|
try {
|
|
try {
|
|
|
Map<String, String> checkText = TextCheckUtil.check(appealReason);
|
|
Map<String, String> checkText = TextCheckUtil.check(appealReason);
|
|
@@ -283,7 +275,6 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
return storeCommentAppealInfoVo;
|
|
return storeCommentAppealInfoVo;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- List<String> fileNameSet = new ArrayList<>(multipartRequest.getMultiFileMap().keySet());
|
|
|
|
|
LambdaQueryWrapper<StoreCommentAppeal> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<StoreCommentAppeal> wrapper = new LambdaQueryWrapper<>();
|
|
|
//待审批, 已通过
|
|
//待审批, 已通过
|
|
|
List<Integer> list = new ArrayList<>();
|
|
List<Integer> list = new ArrayList<>();
|
|
@@ -302,21 +293,8 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
return 2;
|
|
return 2;
|
|
|
}*/
|
|
}*/
|
|
|
StoreCommentAppeal storeCommentAppeal = new StoreCommentAppeal();
|
|
StoreCommentAppeal storeCommentAppeal = new StoreCommentAppeal();
|
|
|
- StringBuilder imgId = new StringBuilder();
|
|
|
|
|
- for (int i = 0; i < fileNameSet.size(); i++) {
|
|
|
|
|
- MultipartFile multipartFile = multipartRequest.getFileMap().get(fileNameSet.get(i));
|
|
|
|
|
- if (null != multipartFile) {
|
|
|
|
|
- StoreImg storeImg = new StoreImg();
|
|
|
|
|
- storeImg.setStoreId(storeId);
|
|
|
|
|
- storeImg.setImgType(9);
|
|
|
|
|
- storeImg.setImgSort(i + 1);
|
|
|
|
|
- storeImg.setImgUrl(fileUploadUtil.uploadOneFile(multipartFile));
|
|
|
|
|
- storeImgMapper.insert(storeImg);
|
|
|
|
|
- imgId.append(storeImg.getId()).append(",");
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- if (!imgId.toString().isEmpty()) {
|
|
|
|
|
- storeCommentAppeal.setImgId(imgId.substring(0, imgId.length() - 1));
|
|
|
|
|
|
|
+ if (StringUtils.isNotEmpty(imgUrls)) {
|
|
|
|
|
+ storeCommentAppeal.setImgId(normalizeAppealImgUrls(imgUrls));
|
|
|
}
|
|
}
|
|
|
storeCommentAppeal.setStoreId(storeId);
|
|
storeCommentAppeal.setStoreId(storeId);
|
|
|
storeCommentAppeal.setCommentId(commentId);
|
|
storeCommentAppeal.setCommentId(commentId);
|
|
@@ -397,15 +375,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
storeCommentAppealVoQueryWrapper.eq("a.id", id);
|
|
storeCommentAppealVoQueryWrapper.eq("a.id", id);
|
|
|
StoreCommentAppealVo commentDetail = storeCommentAppealMapper.getCommentDetail(storeCommentAppealVoQueryWrapper);
|
|
StoreCommentAppealVo commentDetail = storeCommentAppealMapper.getCommentDetail(storeCommentAppealVoQueryWrapper);
|
|
|
|
|
|
|
|
- String[] split = commentDetail.getImgId().split(",");
|
|
|
|
|
- List<String> imgList = new ArrayList<>();
|
|
|
|
|
- for (String s : split) {
|
|
|
|
|
- StoreImg storeImg = storeImgMapper.selectById(s);
|
|
|
|
|
- if (null != storeImg) {
|
|
|
|
|
- imgList.add(storeImg.getImgUrl());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- commentDetail.setImgList(imgList);
|
|
|
|
|
|
|
+ commentDetail.setImgList(buildAppealImgList(commentDetail.getImgId()));
|
|
|
|
|
|
|
|
// 处理评价图片(common_rating.image_urls 已经是URL字符串,不是ID)
|
|
// 处理评价图片(common_rating.image_urls 已经是URL字符串,不是ID)
|
|
|
if (StringUtils.isNotEmpty(commentDetail.getCommentImgId())) {
|
|
if (StringUtils.isNotEmpty(commentDetail.getCommentImgId())) {
|
|
@@ -484,15 +454,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
.filter(Objects::nonNull)
|
|
.filter(Objects::nonNull)
|
|
|
.collect(Collectors.toList());
|
|
.collect(Collectors.toList());
|
|
|
item.setStoreTypeStr(String.join(",", typeDetails));
|
|
item.setStoreTypeStr(String.join(",", typeDetails));
|
|
|
- String[] split = item.getImgId().split(",");
|
|
|
|
|
- List<String> imgList = new ArrayList<>();
|
|
|
|
|
- for (String s : split) {
|
|
|
|
|
- StoreImg storeImg = storeImgMapper.selectById(s);
|
|
|
|
|
- if (null != storeImg) {
|
|
|
|
|
- imgList.add(storeImg.getImgUrl());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- item.setImgList(imgList);
|
|
|
|
|
|
|
+ item.setImgList(buildAppealImgList(item.getImgId()));
|
|
|
});
|
|
});
|
|
|
}
|
|
}
|
|
|
toExcel = storeCommentAppealPage.getRecords();
|
|
toExcel = storeCommentAppealPage.getRecords();
|
|
@@ -724,6 +686,41 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
|
|
+ * 规范化申诉图片URL(逗号分隔)
|
|
|
|
|
+ */
|
|
|
|
|
+ private String normalizeAppealImgUrls(String imgUrls) {
|
|
|
|
|
+ return Arrays.stream(imgUrls.split(","))
|
|
|
|
|
+ .map(String::trim)
|
|
|
|
|
+ .filter(StringUtils::isNotEmpty)
|
|
|
|
|
+ .collect(Collectors.joining(","));
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 解析申诉图片:新数据为OSS URL,旧数据为 store_img 主键
|
|
|
|
|
+ */
|
|
|
|
|
+ private List<String> buildAppealImgList(String imgId) {
|
|
|
|
|
+ List<String> imgList = new ArrayList<>();
|
|
|
|
|
+ if (StringUtils.isEmpty(imgId)) {
|
|
|
|
|
+ return imgList;
|
|
|
|
|
+ }
|
|
|
|
|
+ for (String item : imgId.split(",")) {
|
|
|
|
|
+ String trimmed = item.trim();
|
|
|
|
|
+ if (StringUtils.isEmpty(trimmed)) {
|
|
|
|
|
+ continue;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (trimmed.startsWith("http://") || trimmed.startsWith("https://")) {
|
|
|
|
|
+ imgList.add(trimmed);
|
|
|
|
|
+ } else {
|
|
|
|
|
+ StoreImg storeImg = storeImgMapper.selectById(trimmed);
|
|
|
|
|
+ if (storeImg != null && StringUtils.isNotEmpty(storeImg.getImgUrl())) {
|
|
|
|
|
+ imgList.add(storeImg.getImgUrl());
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return imgList;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
* 调用AI分析接口提交申诉分析任务
|
|
* 调用AI分析接口提交申诉分析任务
|
|
|
*
|
|
*
|
|
|
* @param storeCommentAppeal 申诉记录
|
|
* @param storeCommentAppeal 申诉记录
|
|
@@ -732,12 +729,12 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
private Integer invokeAiAnalyze(StoreCommentAppeal storeCommentAppeal) {
|
|
private Integer invokeAiAnalyze(StoreCommentAppeal storeCommentAppeal) {
|
|
|
log.info("开始调用AI差评申诉置信度分析接口,申诉ID: {}", storeCommentAppeal.getId());
|
|
log.info("开始调用AI差评申诉置信度分析接口,申诉ID: {}", storeCommentAppeal.getId());
|
|
|
|
|
|
|
|
- // 1. 获取访问令牌(使用工具类)
|
|
|
|
|
- String accessToken = aiAuthTokenUtil.getAccessToken();
|
|
|
|
|
- if (!org.springframework.util.StringUtils.hasText(accessToken)) {
|
|
|
|
|
- log.error("调用AI分析接口失败,获取accessToken失败,申诉ID: {}", storeCommentAppeal.getId());
|
|
|
|
|
- return null;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+// // 1. 获取访问令牌(使用工具类)
|
|
|
|
|
+// String accessToken = aiAuthTokenUtil.getAccessToken();
|
|
|
|
|
+// if (!org.springframework.util.StringUtils.hasText(accessToken)) {
|
|
|
|
|
+// log.error("调用AI分析接口失败,获取accessToken失败,申诉ID: {}", storeCommentAppeal.getId());
|
|
|
|
|
+// return null;
|
|
|
|
|
+// }
|
|
|
|
|
|
|
|
// 2. 查询评论信息(CommonRating)
|
|
// 2. 查询评论信息(CommonRating)
|
|
|
CommonRating rating = commonRatingMapper.selectById(storeCommentAppeal.getCommentId());
|
|
CommonRating rating = commonRatingMapper.selectById(storeCommentAppeal.getCommentId());
|
|
@@ -760,22 +757,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
|
|
|
|
|
// 商家图片:暂时传空数组,先测试文本分析流程
|
|
// 商家图片:暂时传空数组,先测试文本分析流程
|
|
|
// TODO: 后续需要将图片转换为Base64
|
|
// TODO: 后续需要将图片转换为Base64
|
|
|
- List<String> merchantImages = new ArrayList<>();
|
|
|
|
|
- if (org.springframework.util.StringUtils.hasText(storeCommentAppeal.getImgId())) {
|
|
|
|
|
- String[] imgIds = storeCommentAppeal.getImgId().split(",");
|
|
|
|
|
- for (String imgId : imgIds) {
|
|
|
|
|
- StoreImg storeImg = storeImgMapper.selectById(imgId.trim());
|
|
|
|
|
-// if (storeImg != null && org.springframework.util.StringUtils.hasText(storeImg.getImgUrl())) {
|
|
|
|
|
-// String base64 = convertImageToBase64(storeImg.getImgUrl());
|
|
|
|
|
-// if (org.springframework.util.StringUtils.hasText(base64)) {
|
|
|
|
|
-// merchantImages.add(base64);
|
|
|
|
|
-// }
|
|
|
|
|
-// }
|
|
|
|
|
- if (storeImg.getImgUrl() != null) {
|
|
|
|
|
- merchantImages.add(storeImg.getImgUrl());
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ List<String> merchantImages = buildAppealImgList(storeCommentAppeal.getImgId());
|
|
|
analyzeRequest.put("merchant_images", merchantImages);
|
|
analyzeRequest.put("merchant_images", merchantImages);
|
|
|
|
|
|
|
|
// 用户图片:暂时传空数组,先测试文本分析流程
|
|
// 用户图片:暂时传空数组,先测试文本分析流程
|
|
@@ -805,7 +787,7 @@ public class StoreCommentAppealServiceImpl extends ServiceImpl<StoreCommentAppea
|
|
|
// 4. 设置请求头
|
|
// 4. 设置请求头
|
|
|
HttpHeaders analyzeHeaders = new HttpHeaders();
|
|
HttpHeaders analyzeHeaders = new HttpHeaders();
|
|
|
analyzeHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
analyzeHeaders.setContentType(MediaType.APPLICATION_JSON);
|
|
|
- analyzeHeaders.set("Authorization", "Bearer " + accessToken);
|
|
|
|
|
|
|
+// analyzeHeaders.set("Authorization", "Bearer " + accessToken);
|
|
|
HttpEntity<Map<String, Object>> analyzeEntity = new HttpEntity<>(analyzeRequest, analyzeHeaders);
|
|
HttpEntity<Map<String, Object>> analyzeEntity = new HttpEntity<>(analyzeRequest, analyzeHeaders);
|
|
|
|
|
|
|
|
// 5. 调用AI接口
|
|
// 5. 调用AI接口
|