|
|
@ -5,6 +5,7 @@ import cn.hutool.http.HttpResponse; |
|
|
|
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.CheckDataFromDTO; |
|
|
|
import com.elink.esua.epdc.commons.tools.security.content.dto.form.SaveCheckRecordsDTO; |
|
|
|
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.CheckResultDetailsDTO; |
|
|
@ -40,21 +41,22 @@ public class CheckDataUtils{ |
|
|
|
//文本违规,可以直接删除或者限制公开
|
|
|
|
private static String block = "block"; |
|
|
|
|
|
|
|
|
|
|
|
//识别图片中的色情内容
|
|
|
|
private static String porn = "porn"; |
|
|
|
|
|
|
|
//识别图片中的暴恐涉政内容
|
|
|
|
private static String terrorism = "terrorism"; |
|
|
|
|
|
|
|
//违规提示
|
|
|
|
public static String violations_message = "内容存在违规信息,请修改后重新提交!"; |
|
|
|
|
|
|
|
|
|
|
|
private static Logger log = LogManager.getLogger(HttpClientUtils.class); |
|
|
|
|
|
|
|
public static void main(String[] args) { |
|
|
|
// public static void main(String[] args) {
|
|
|
|
// 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,",null); |
|
|
|
} |
|
|
|
// 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:内容审核 |
|
|
@ -81,9 +83,16 @@ public class CheckDataUtils{ |
|
|
|
tasks.setTasks(contentList); |
|
|
|
String json = JSONObject.toJSONString(tasks); |
|
|
|
log.info("审核组装json:" + json); |
|
|
|
HttpResponse response = HttpRequest.post(contentUrl).body(json) |
|
|
|
|
|
|
|
HttpResponse response = null; |
|
|
|
try { |
|
|
|
response = HttpRequest.post(contentUrl).body(json) |
|
|
|
.header("lan", "zh") |
|
|
|
.header("Content-Type", "application/json").execute(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("内容校验接口异常:"+e.getMessage()); |
|
|
|
} |
|
|
|
log.info("审核返回数据:" + response.body()); |
|
|
|
JSONObject res = JSONObject.parseObject(response.body()); |
|
|
|
//审核成功
|
|
|
@ -100,23 +109,13 @@ public class CheckDataUtils{ |
|
|
|
* @describe: 图片审核:只要有一张图片被驳回,本次审核判定为不通过 |
|
|
|
* @author wangtong |
|
|
|
* @date 2020/7/7 17:42 |
|
|
|
* @param :[ imgs:字符串拼接的图片地址, imgArray:集合类型的图片地址] |
|
|
|
* @param :[ imgArray:集合类型的图片地址] |
|
|
|
* @return com.elink.esua.epdc.commons.tools.security.content.dto.result.CheckResultDTO |
|
|
|
*/ |
|
|
|
public static CheckResultDTO checkImgs(String imgs,List<String> imgArray){ |
|
|
|
public static CheckResultDTO checkImgs(List<String> imgArray){ |
|
|
|
CheckDataFromDTO tasks = new CheckDataFromDTO(); |
|
|
|
List<CheckContentFormDTO> contentList = new ArrayList<>(); |
|
|
|
if(StringUtils.isNotBlank(imgs)){ |
|
|
|
String[] imgList = imgs.split(","); |
|
|
|
for(int i = 0;i<imgList.length;i++){ |
|
|
|
if(StringUtils.isNotBlank(imgList[i])){//图片地址为空会报错
|
|
|
|
CheckContentFormDTO imgDto = new CheckContentFormDTO(); |
|
|
|
imgDto.setDataId(i+""); |
|
|
|
imgDto.setUrl(imgList[i]); |
|
|
|
contentList.add(imgDto); |
|
|
|
} |
|
|
|
} |
|
|
|
}else if(imgArray != null && imgArray.size()>0){ |
|
|
|
if(imgArray != null && imgArray.size()>0){ |
|
|
|
int i = 1; |
|
|
|
for(String url : imgArray){ |
|
|
|
if(StringUtils.isNotBlank(url)){//图片地址为空会报错
|
|
|
@ -134,9 +133,15 @@ public class CheckDataUtils{ |
|
|
|
tasks.setTasks(contentList); |
|
|
|
String json = JSONObject.toJSONString(tasks); |
|
|
|
log.info("审核组装json:" + json); |
|
|
|
HttpResponse response = HttpRequest.post(imgUrl).body(json) |
|
|
|
HttpResponse response = null; |
|
|
|
try { |
|
|
|
response = HttpRequest.post(imgUrl).body(json) |
|
|
|
.header("lan", "zh") |
|
|
|
.header("Content-Type", "application/json").execute(); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
log.error("内容校验接口异常:"+e.getMessage()); |
|
|
|
} |
|
|
|
log.info("审核返回数据:" + response.body()); |
|
|
|
JSONObject res = JSONObject.parseObject(response.body()); |
|
|
|
//审核成功
|
|
|
@ -211,4 +216,69 @@ public class CheckDataUtils{ |
|
|
|
return result; |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
* @describe: 组装违规记录信息 |
|
|
|
* @author wangtong |
|
|
|
* @date 2020/7/7 19:26 |
|
|
|
* @param [userId :用户ID, |
|
|
|
* userName:用户名称, |
|
|
|
* category:工作类别:1工作2居民, |
|
|
|
* module:模块编码, |
|
|
|
* content:要审核的文本, |
|
|
|
* imgUrls:要审核的图片, |
|
|
|
* contentResult:文本审核的结果, |
|
|
|
* imgResult:图片审核的结果] |
|
|
|
* @return com.elink.esua.epdc.commons.tools.security.content.dto.form.SaveCheckRecordsDTO |
|
|
|
*/ |
|
|
|
public static SaveCheckRecordsDTO getViolationsRecords(String userId,String userName,String category, |
|
|
|
String module,String content,List<String> imgUrls, |
|
|
|
CheckResultDTO contentResult, |
|
|
|
CheckResultDTO imgResult){ |
|
|
|
SaveCheckRecordsDTO record = new SaveCheckRecordsDTO(); |
|
|
|
record.setUserId(userId); |
|
|
|
record.setName(userName); |
|
|
|
record.setCategory(category);//居民
|
|
|
|
record.setDecision("1");//系统判定
|
|
|
|
record.setModule(module);//功能模块
|
|
|
|
record.setContent(content); |
|
|
|
record.setImgUrls(imgUrls); |
|
|
|
CheckResultMessageDTO messageResult = getCheckResultMessage(contentResult,imgResult); |
|
|
|
record.setSuggestion(messageResult.getSuggestion()); |
|
|
|
record.setLabel(messageResult.getLabel()); |
|
|
|
record.setRate(messageResult.getRate()); |
|
|
|
return record; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* @describe: 组装待审核信息 |
|
|
|
* @author wangtong |
|
|
|
* @date 2020/7/7 19:26 |
|
|
|
* @param [userId :用户ID, |
|
|
|
* userName:用户名称, |
|
|
|
* category:工作类别:1工作2居民, |
|
|
|
* module:模块编码, |
|
|
|
* content:要审核的文本, |
|
|
|
* imgUrls:要审核的图片, |
|
|
|
* contentResult:文本审核的结果, |
|
|
|
* imgResult:图片审核的结果] |
|
|
|
* @return com.elink.esua.epdc.commons.tools.security.content.dto.form.SaveCheckRecordsDTO |
|
|
|
*/ |
|
|
|
public static SaveCheckRecordsDTO getUnCheckRecords(String userId,String userName,String category, |
|
|
|
String module,String content,List<String> imgUrls, |
|
|
|
String relationId,CheckResultMessageDTO twoTypes){ |
|
|
|
SaveCheckRecordsDTO record = new SaveCheckRecordsDTO(); |
|
|
|
record.setUserId(userId); |
|
|
|
record.setName(userName); |
|
|
|
record.setCategory(category);//居民
|
|
|
|
record.setModule(module);//功能模块
|
|
|
|
record.setContent(content); |
|
|
|
record.setImgUrls(imgUrls); |
|
|
|
record.setRelationId(relationId); |
|
|
|
record.setSuggestion(twoTypes.getSuggestion()); |
|
|
|
record.setLabel(twoTypes.getLabel()); |
|
|
|
record.setRate(twoTypes.getRate()); |
|
|
|
return record; |
|
|
|
} |
|
|
|
|
|
|
|
} |