修复图片审核
parent
382f32de5f
commit
7a742d7338
|
@ -1,6 +1,8 @@
|
||||||
package com.mcwl.resource.service.impl;
|
package com.mcwl.resource.service.impl;
|
||||||
|
|
||||||
import cn.hutool.core.bean.BeanUtil;
|
import cn.hutool.core.bean.BeanUtil;
|
||||||
|
import com.alibaba.fastjson2.JSONArray;
|
||||||
|
import com.alibaba.fastjson2.JSONObject;
|
||||||
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||||
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
import com.baomidou.mybatisplus.core.metadata.OrderItem;
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
@ -11,6 +13,7 @@ import com.mcwl.common.core.domain.entity.SysUser;
|
||||||
import com.mcwl.common.core.page.TableDataInfo;
|
import com.mcwl.common.core.page.TableDataInfo;
|
||||||
import com.mcwl.common.utils.SecurityUtils;
|
import com.mcwl.common.utils.SecurityUtils;
|
||||||
import com.mcwl.common.utils.StringUtils;
|
import com.mcwl.common.utils.StringUtils;
|
||||||
|
import com.mcwl.common.utils.baidu.BaiduCensor;
|
||||||
import com.mcwl.resource.domain.ModelImage;
|
import com.mcwl.resource.domain.ModelImage;
|
||||||
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
import com.mcwl.resource.domain.dto.ModelImagePageRes;
|
||||||
import com.mcwl.resource.domain.dto.ModelImageRes;
|
import com.mcwl.resource.domain.dto.ModelImageRes;
|
||||||
|
@ -22,12 +25,16 @@ import com.mcwl.system.init.DictInit;
|
||||||
import com.mcwl.system.service.ISysDictDataService;
|
import com.mcwl.system.service.ISysDictDataService;
|
||||||
import com.mcwl.system.service.ISysUserService;
|
import com.mcwl.system.service.ISysUserService;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelImage> implements ModelImageService {
|
public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelImage> implements ModelImageService {
|
||||||
|
@ -40,6 +47,8 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
||||||
|
|
||||||
private final ISysDictDataService sysDictDataService;
|
private final ISysDictDataService sysDictDataService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private ThreadPoolTaskExecutor threadPoolTaskExecutor;
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -61,11 +70,98 @@ public class ModelImageServiceImpl extends ServiceImpl<ModelImageMapper, ModelIm
|
||||||
modelImage.setStatus(3);
|
modelImage.setStatus(3);
|
||||||
modelImageMapper.insert(modelImage);
|
modelImageMapper.insert(modelImage);
|
||||||
|
|
||||||
|
audit(modelImage);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void audit(ModelImage modelImage) {
|
||||||
|
|
||||||
|
// 执行审核操作
|
||||||
|
threadPoolTaskExecutor.submit(() -> {
|
||||||
|
if (modelImage != null) {
|
||||||
|
|
||||||
|
if (modelImage.getTitle() != null) {
|
||||||
|
|
||||||
|
//审核名称
|
||||||
|
String s = BaiduCensor.TextCensor(modelImage.getTitle() + "," + modelImage.getTags() + ","
|
||||||
|
+ modelImage.getDescription());
|
||||||
|
// 解析 JSON 字符串
|
||||||
|
JSONObject jsonObject = JSONObject.parseObject(s);
|
||||||
|
// 获取 'conclusion' 字段的值
|
||||||
|
String conclusion = jsonObject.getString("conclusion");
|
||||||
|
|
||||||
|
if (conclusion.equals("不合规")) {
|
||||||
|
|
||||||
|
//更改状态,添加原因 -> 结束任务
|
||||||
|
// 获取 'data' 数组
|
||||||
|
JSONArray dataArray = jsonObject.getJSONArray("data");
|
||||||
|
|
||||||
|
// 存储所有的失败原因
|
||||||
|
List<String> failureReasons = new ArrayList<>();
|
||||||
|
// 遍历 'data' 数组中的每个元素
|
||||||
|
for (Object itemObj : dataArray) {
|
||||||
|
JSONObject item = (JSONObject) itemObj;
|
||||||
|
String msg = item.getString("msg");
|
||||||
|
failureReasons.add(msg);
|
||||||
|
}
|
||||||
|
// 使用逗号拼接所有的失败原因
|
||||||
|
String concatenatedReasons = String.join(", ", failureReasons);
|
||||||
|
modelImage.setAuditText(concatenatedReasons);
|
||||||
|
|
||||||
|
//修改状态以及失败原因
|
||||||
|
modelImage.setStatus(4);
|
||||||
|
log.info("执行111");
|
||||||
|
modelImageMapper.updateById(modelImage);
|
||||||
|
log.info("图片审核未通过");
|
||||||
|
//结束任务
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改为合格
|
||||||
|
modelImage.setAuditText("");
|
||||||
|
modelImage.setStatus(1);
|
||||||
|
baseMapper.updateById(modelImage);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (modelImage.getImagePaths() == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
//审核图片
|
||||||
|
String[] split = modelImage.getImagePaths().split(",");
|
||||||
|
for (String path : split) {
|
||||||
|
String s2 = BaiduCensor.ImageCnesor(path);
|
||||||
|
JSONObject jsonObject2 = JSONObject.parseObject(s2);
|
||||||
|
if (jsonObject2.getString("conclusion").equals("不合规")) {
|
||||||
|
|
||||||
|
//修改状态->跳出循环 判断下一个版本
|
||||||
|
// 获取 'data' 数组
|
||||||
|
JSONArray dataArray2 = jsonObject2.getJSONArray("data");
|
||||||
|
// 存储所有的失败原因
|
||||||
|
List<String> failureReasons = new ArrayList<>();
|
||||||
|
// 遍历 'data' 数组中的每个元素
|
||||||
|
for (Object itemObj : dataArray2) {
|
||||||
|
JSONObject item = (JSONObject) itemObj;
|
||||||
|
String msg = item.getString("msg");
|
||||||
|
failureReasons.add(msg);
|
||||||
|
}
|
||||||
|
// 使用逗号拼接所有的失败原因
|
||||||
|
String concatenatedReasons = String.join(", ", failureReasons);
|
||||||
|
modelImage.setAuditText(concatenatedReasons);
|
||||||
|
modelImage.setStatus(4);
|
||||||
|
baseMapper.updateById(modelImage);
|
||||||
|
log.info("图片审核未通过");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//修改版本成功审核状态
|
||||||
|
modelImage.setAuditText("");
|
||||||
|
modelImage.setStatus(1);
|
||||||
|
baseMapper.updateById(modelImage);
|
||||||
|
log.info("全部通过审核");
|
||||||
|
});
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in New Issue