|
@ -15,7 +15,7 @@ import com.epmet.openapi.scan.common.enu.ImgSceneEnum; |
|
|
import com.epmet.openapi.scan.common.enu.SuggestionEnum; |
|
|
import com.epmet.openapi.scan.common.enu.SuggestionEnum; |
|
|
import com.epmet.openapi.scan.common.enu.SysResponseEnum; |
|
|
import com.epmet.openapi.scan.common.enu.SysResponseEnum; |
|
|
import com.epmet.openapi.scan.common.enu.TextSceneEnum; |
|
|
import com.epmet.openapi.scan.common.enu.TextSceneEnum; |
|
|
import com.epmet.openapi.scan.common.exception.ExeCuteHttpException; |
|
|
import com.epmet.openapi.scan.common.exception.ExecuteHttpException; |
|
|
import com.epmet.openapi.scan.common.util.IAcsClientUtil; |
|
|
import com.epmet.openapi.scan.common.util.IAcsClientUtil; |
|
|
import com.epmet.openapi.scan.support.param.ImgScanParam; |
|
|
import com.epmet.openapi.scan.support.param.ImgScanParam; |
|
|
import com.epmet.openapi.scan.support.param.ImgTask; |
|
|
import com.epmet.openapi.scan.support.param.ImgTask; |
|
@ -49,7 +49,6 @@ public class ScanServiceImpl implements ScanService { |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result<SyncScanResult> sendTextScan(TextScanParam textScanParam) { |
|
|
public Result<SyncScanResult> sendTextScan(TextScanParam textScanParam) { |
|
|
|
|
|
|
|
|
//默认参数
|
|
|
//默认参数
|
|
|
// 鉴黄 暴恐涉政
|
|
|
// 鉴黄 暴恐涉政
|
|
|
textScanParam.setScenes(TextSceneEnum.getTextSceneList()); |
|
|
textScanParam.setScenes(TextSceneEnum.getTextSceneList()); |
|
@ -69,7 +68,7 @@ public class ScanServiceImpl implements ScanService { |
|
|
try { |
|
|
try { |
|
|
textScanRequest.setHttpContent(JSON.toJSONString(textScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|
|
textScanRequest.setHttpContent(JSON.toJSONString(textScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|
|
} catch (UnsupportedEncodingException e) { |
|
|
} catch (UnsupportedEncodingException e) { |
|
|
log.error("sendTextScan exception", e.getMessage()); |
|
|
log.error("sendTextScan parse param exception", e); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@ -78,18 +77,18 @@ public class ScanServiceImpl implements ScanService { |
|
|
*/ |
|
|
*/ |
|
|
textScanRequest.setConnectTimeout(3000); |
|
|
textScanRequest.setConnectTimeout(3000); |
|
|
textScanRequest.setReadTimeout(6000); |
|
|
textScanRequest.setReadTimeout(6000); |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
SyncScanResult textScanResult = executeSyncText(textScanRequest); |
|
|
SyncScanResult textScanResult = executeSyncText(textScanRequest); |
|
|
return new Result<SyncScanResult>().ok(textScanResult); |
|
|
return new Result<SyncScanResult>().ok(textScanResult); |
|
|
} catch (Exception e) { |
|
|
} catch (ExecuteHttpException e) { |
|
|
log.error("sendTextScan exception", e); |
|
|
log.error("sendTextScan execute Exception", e); |
|
|
throw new ExeCuteHttpException(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); |
|
|
return new Result<SyncScanResult>().error(e.getCode(), e.getMsg()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public Result<SyncScanResult> sendSyncImgScan(ImgScanParam imgScanParam) { |
|
|
public Result<SyncScanResult> sendSyncImgScan(ImgScanParam imgScanParam) { |
|
|
|
|
|
|
|
|
ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest(); |
|
|
ImageSyncScanRequest imageSyncScanRequest = new ImageSyncScanRequest(); |
|
|
imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|
|
imageSyncScanRequest.setAcceptFormat(FormatType.JSON); // 指定api返回格式
|
|
|
imageSyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|
|
imageSyncScanRequest.setMethod(com.aliyuncs.http.MethodType.POST); // 指定请求方法
|
|
@ -109,7 +108,7 @@ public class ScanServiceImpl implements ScanService { |
|
|
try { |
|
|
try { |
|
|
imageSyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|
|
imageSyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|
|
} catch (UnsupportedEncodingException e) { |
|
|
} catch (UnsupportedEncodingException e) { |
|
|
log.error("sendSyncImgScan exception", e.getMessage()); |
|
|
log.error("sendSyncImgScan parse param exception", e); |
|
|
return new Result<SyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|
|
return new Result<SyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -122,9 +121,9 @@ public class ScanServiceImpl implements ScanService { |
|
|
try { |
|
|
try { |
|
|
SyncScanResult scanResult = executeSyncImg(imageSyncScanRequest); |
|
|
SyncScanResult scanResult = executeSyncImg(imageSyncScanRequest); |
|
|
return new Result<SyncScanResult>().ok(scanResult); |
|
|
return new Result<SyncScanResult>().ok(scanResult); |
|
|
} catch (Exception e) { |
|
|
} catch (ExecuteHttpException e) { |
|
|
log.error("sendImgScan execute Exception", e); |
|
|
log.error("sendImgScan execute exception,param:{},fail msg:{}", JSON.toJSONString(imgScanParam), e.getMsg()); |
|
|
return new Result<SyncScanResult>().error(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); |
|
|
return new Result<SyncScanResult>().error(e.getCode(), e.getMsg()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -149,7 +148,7 @@ public class ScanServiceImpl implements ScanService { |
|
|
try { |
|
|
try { |
|
|
imageAsyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|
|
imageAsyncScanRequest.setHttpContent(JSON.toJSONString(imgScanParam).getBytes(SysConstant.UTF8), SysConstant.UTF8, FormatType.JSON); |
|
|
} catch (UnsupportedEncodingException e) { |
|
|
} catch (UnsupportedEncodingException e) { |
|
|
log.error("sendASyncImgScan exception", e.getMessage()); |
|
|
log.error("sendASyncImgScan parse param exception", e); |
|
|
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|
|
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.SCAN_PARAM_ERROR.getCode(), SysResponseEnum.SCAN_PARAM_ERROR.getMsg()); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -163,7 +162,7 @@ public class ScanServiceImpl implements ScanService { |
|
|
ImgAsyncScanResult scanResult = null;//executeAsyncImg(imageAsyncScanRequest);
|
|
|
ImgAsyncScanResult scanResult = null;//executeAsyncImg(imageAsyncScanRequest);
|
|
|
return new Result<ImgAsyncScanResult>().ok(scanResult); |
|
|
return new Result<ImgAsyncScanResult>().ok(scanResult); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("sendImgScan execute Exception", e); |
|
|
//log.error("sendASyncImgScan execute exception,param:{},fail msg:{}",JSON.toJSONString(imgScanParam), e.getMsg());
|
|
|
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); |
|
|
return new Result<ImgAsyncScanResult>().error(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@ -209,15 +208,15 @@ public class ScanServiceImpl implements ScanService { |
|
|
return result; |
|
|
return result; |
|
|
} else { |
|
|
} else { |
|
|
log.warn("executeSyncText response not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|
|
log.warn("executeSyncText response not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|
|
throw new ExeCuteHttpException("executeSyncText detect not success. code:" + scrResponse.getInteger(SysConstant.CODE)); |
|
|
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus()); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
log.warn("executeSyncText response not success. status:{}", httpResponse.getStatus()); |
|
|
log.warn("executeSyncText response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse)); |
|
|
throw new ExeCuteHttpException("response not success. status:" + httpResponse.getStatus()); |
|
|
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus()); |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.warn("executeSyncText exception", e); |
|
|
log.error("executeSyncText exception IAcsClientUtil do action exception", e); |
|
|
throw new ExeCuteHttpException(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); |
|
|
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getCode(), SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getMsg()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@ -260,15 +259,15 @@ public class ScanServiceImpl implements ScanService { |
|
|
return result; |
|
|
return result; |
|
|
} else { |
|
|
} else { |
|
|
log.warn("executeSyncImg detect not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|
|
log.warn("executeSyncImg detect not success. code:{}", scrResponse.getInteger(SysConstant.CODE)); |
|
|
throw new ExeCuteHttpException("detect not success. code:" + scrResponse.getInteger(SysConstant.CODE)); |
|
|
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus()); |
|
|
} |
|
|
} |
|
|
} else { |
|
|
} else { |
|
|
log.warn("executeSyncImg response not success. status:{}", httpResponse.getStatus()); |
|
|
log.warn("executeSyncImg response status is not success. httpResponse:{}", JSON.toJSONString(httpResponse)); |
|
|
throw new ExeCuteHttpException("response not success. status:" + httpResponse.getStatus()); |
|
|
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getCode(), SysResponseEnum.EXECUTE_ALI_RETURN_CODE_NOT_OK.getMsg() + ",status:" + httpResponse.getStatus()); |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.warn("executeSyncImg exception", e); |
|
|
log.error("executeSyncImg exception IAcsClientUtil do action exception", e); |
|
|
throw new ExeCuteHttpException(SysResponseEnum.EXCEPTION.getCode(), SysResponseEnum.EXCEPTION.getMsg()); |
|
|
throw new ExecuteHttpException(SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getCode(), SysResponseEnum.EXECUTE_ALI_DO_ACTION_EXCEPTION.getMsg()); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|