|
@ -5,7 +5,10 @@ import cn.hutool.http.HttpResponse; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.form.CheckContentFormDTO; |
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.form.CheckContentFormDTO; |
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.form.CheckDataFromDTO; |
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.form.CheckDataFromDTO; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckDetailResultsDTO; |
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultDTO; |
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultDTO; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultDetailsDTO; |
|
|
|
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultMessageDTO; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
import org.apache.logging.log4j.LogManager; |
|
|
import org.apache.logging.log4j.LogManager; |
|
|
import org.apache.logging.log4j.Logger; |
|
|
import org.apache.logging.log4j.Logger; |
|
@ -28,18 +31,36 @@ public class CheckDataUtils{ |
|
|
//图片审核地址
|
|
|
//图片审核地址
|
|
|
private static String imgUrl = "https://epmet-dev.elinkservice.cn/epmetscan/api/imgSyncScan"; |
|
|
private static String imgUrl = "https://epmet-dev.elinkservice.cn/epmetscan/api/imgSyncScan"; |
|
|
|
|
|
|
|
|
|
|
|
//文本正常
|
|
|
|
|
|
private static String pass = "pass"; |
|
|
|
|
|
|
|
|
|
|
|
//文本需要进一步人工审核
|
|
|
|
|
|
public static String review = "review"; |
|
|
|
|
|
|
|
|
|
|
|
//文本违规,可以直接删除或者限制公开
|
|
|
|
|
|
private static String block = "block"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//识别图片中的色情内容
|
|
|
|
|
|
private static String porn = "porn"; |
|
|
|
|
|
|
|
|
|
|
|
//识别图片中的暴恐涉政内容
|
|
|
|
|
|
private static String terrorism = "terrorism"; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static Logger log = LogManager.getLogger(HttpClientUtils.class); |
|
|
private static Logger log = LogManager.getLogger(HttpClientUtils.class); |
|
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
public static void main(String[] args) { |
|
|
checkContent(null,"bbb"); |
|
|
// checkContent(null,"bbb");
|
|
|
// checkImgs("https://epdc-shibei.elinkservice.cn/epdcFile/M00/06/80/rBAAM17wjcKACqqXAAIyYyB0O-8107.png,,https://epdc-shibei.elinkservice.cn/epdcFile/M00/06/80/rBAAM17wjcKACqqXAAIyYyB0O-8107.png,");
|
|
|
checkImgs("https://epdc-shibei.elinkservice.cn/epdcFile/M00/06/80/rBAAM17wjcKACqqXAAIyYyB0O-8107.png,,https://epdc-shibei.elinkservice.cn/epdcFile/M00/06/80/rBAAM17wjcKACqqXAAIyYyB0O-8107.png,",null); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* @describe:内容审核 |
|
|
* @describe:内容审核 |
|
|
* @author wangtong |
|
|
* @author wangtong |
|
|
* @date 2020/7/6 10:13 |
|
|
* @date 2020/7/6 10:13 |
|
|
* @param [title, content] |
|
|
* @param :[ title :文本标题, content:文本内容] |
|
|
* @return java.lang.Object |
|
|
* @return java.lang.Object |
|
|
*/ |
|
|
*/ |
|
|
public static CheckResultDTO checkContent(String title, String content) { |
|
|
public static CheckResultDTO checkContent(String title, String content) { |
|
@ -78,22 +99,38 @@ public class CheckDataUtils{ |
|
|
/** |
|
|
/** |
|
|
* @describe: 图片审核:只要有一张图片被驳回,本次审核判定为不通过 |
|
|
* @describe: 图片审核:只要有一张图片被驳回,本次审核判定为不通过 |
|
|
* @author wangtong |
|
|
* @author wangtong |
|
|
* @date 2020/7/6 9:09 |
|
|
* @date 2020/7/7 17:42 |
|
|
* @param [imgs] |
|
|
* @param :[ imgs:字符串拼接的图片地址, imgArray:集合类型的图片地址] |
|
|
* @return java.lang.Object |
|
|
* @return com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultDTO |
|
|
*/ |
|
|
*/ |
|
|
public static CheckResultDTO checkImgs(String imgs){ |
|
|
public static CheckResultDTO checkImgs(String imgs,List<String> imgArray){ |
|
|
String[] imgList = imgs.split(","); |
|
|
|
|
|
CheckDataFromDTO tasks = new CheckDataFromDTO(); |
|
|
CheckDataFromDTO tasks = new CheckDataFromDTO(); |
|
|
List<CheckContentFormDTO> contentList = new ArrayList<>(); |
|
|
List<CheckContentFormDTO> contentList = new ArrayList<>(); |
|
|
for(int i = 0;i<imgList.length;i++){ |
|
|
if(StringUtils.isNotBlank(imgs)){ |
|
|
if(StringUtils.isNotBlank(imgList[i])){//图片地址为空会报错
|
|
|
String[] imgList = imgs.split(","); |
|
|
CheckContentFormDTO imgDto = new CheckContentFormDTO(); |
|
|
for(int i = 0;i<imgList.length;i++){ |
|
|
imgDto.setDataId(i+""); |
|
|
if(StringUtils.isNotBlank(imgList[i])){//图片地址为空会报错
|
|
|
imgDto.setUrl(imgList[i]); |
|
|
CheckContentFormDTO imgDto = new CheckContentFormDTO(); |
|
|
contentList.add(imgDto); |
|
|
imgDto.setDataId(i+""); |
|
|
|
|
|
imgDto.setUrl(imgList[i]); |
|
|
|
|
|
contentList.add(imgDto); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
}else if(imgArray != null && imgArray.size()>0){ |
|
|
|
|
|
int i = 1; |
|
|
|
|
|
for(String url : imgArray){ |
|
|
|
|
|
if(StringUtils.isNotBlank(url)){//图片地址为空会报错
|
|
|
|
|
|
CheckContentFormDTO imgDto = new CheckContentFormDTO(); |
|
|
|
|
|
imgDto.setDataId(i+""); |
|
|
|
|
|
imgDto.setUrl(url); |
|
|
|
|
|
contentList.add(imgDto); |
|
|
|
|
|
i++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
}else{ |
|
|
|
|
|
return null; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
tasks.setTasks(contentList); |
|
|
tasks.setTasks(contentList); |
|
|
String json = JSONObject.toJSONString(tasks); |
|
|
String json = JSONObject.toJSONString(tasks); |
|
|
log.info("审核组装json:" + json); |
|
|
log.info("审核组装json:" + json); |
|
@ -111,4 +148,67 @@ public class CheckDataUtils{ |
|
|
return null; |
|
|
return null; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @describe: 获取违规记录的分类占比,所属类别,审核状态 |
|
|
|
|
|
* @author wangtong |
|
|
|
|
|
* @date 2020/7/7 16:18 |
|
|
|
|
|
* @param :[ contentResult:文本审核结果, imgResult:图片审核结果] |
|
|
|
|
|
* @return com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultMessageDTO |
|
|
|
|
|
*/ |
|
|
|
|
|
public static CheckResultMessageDTO getCheckResultMessage(CheckResultDTO contentResult, CheckResultDTO imgResult) { |
|
|
|
|
|
CheckResultMessageDTO result = new CheckResultMessageDTO(); |
|
|
|
|
|
//如果是文字违规
|
|
|
|
|
|
if (contentResult != null && !contentResult.getAllPass()) { |
|
|
|
|
|
result.setSuggestion(contentResult.getDetails().get(0).getResults().get(0).getSuggestion()); |
|
|
|
|
|
result.setLabel(contentResult.getDetails().get(0).getResults().get(0).getLabel()); |
|
|
|
|
|
result.setRate(contentResult.getDetails().get(0).getResults().get(0).getRate()); |
|
|
|
|
|
return result; |
|
|
|
|
|
} else if (imgResult != null && !imgResult.getAllPass()) {//如果是图片违规
|
|
|
|
|
|
for (CheckResultDetailsDTO details : imgResult.getDetails()) { |
|
|
|
|
|
for (CheckDetailResultsDTO detailResult : details.getResults()) { |
|
|
|
|
|
if (block.equals(detailResult.getSuggestion())) { |
|
|
|
|
|
result.setSuggestion(block); |
|
|
|
|
|
result.setLabel(detailResult.getLabel()); |
|
|
|
|
|
result.setRate(detailResult.getRate()); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* @describe: 判断审核结果是review还是pass |
|
|
|
|
|
* @author wangtong |
|
|
|
|
|
* @date 2020/7/7 17:19 |
|
|
|
|
|
* @param :[ contentResult:文本审核结果, imgResult:图片审核结果] |
|
|
|
|
|
* @return com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultMessageDTO |
|
|
|
|
|
*/ |
|
|
|
|
|
public static CheckResultMessageDTO checkTwoTypes(CheckResultDTO contentResult, CheckResultDTO imgResult){ |
|
|
|
|
|
CheckResultMessageDTO result = new CheckResultMessageDTO(); |
|
|
|
|
|
//如果是文字待审核
|
|
|
|
|
|
if (contentResult != null) { |
|
|
|
|
|
if (review.equals(contentResult.getDetails().get(0).getResults().get(0).getSuggestion())) { |
|
|
|
|
|
result.setSuggestion(review); |
|
|
|
|
|
result.setLabel(contentResult.getDetails().get(0).getResults().get(0).getLabel()); |
|
|
|
|
|
result.setRate(contentResult.getDetails().get(0).getResults().get(0).getRate()); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
} else if (imgResult != null) {//如果是图片待审核
|
|
|
|
|
|
for (CheckResultDetailsDTO details : imgResult.getDetails()) { |
|
|
|
|
|
for (CheckDetailResultsDTO detailResult : details.getResults()) { |
|
|
|
|
|
if (review.equals(detailResult.getSuggestion())) { |
|
|
|
|
|
result.setSuggestion(review); |
|
|
|
|
|
result.setLabel(detailResult.getLabel()); |
|
|
|
|
|
result.setRate(detailResult.getRate()); |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
} |
|
|
} |