Commit ea7dcd21bc1945c31ff7ea4789f21c8e887f35ff
1 parent
4db67ee6
作业作品 家庭相册 改为免审、优化图文定时任务
Showing
3 changed files
with
35 additions
and
36 deletions
src/main/java/com/cnlive/shenhe/job/ContentJob.java
| ... | ... | @@ -40,7 +40,7 @@ public class ContentJob { |
| 40 | 40 | logger.info("当前白名单通过的content_id:" + content.getId()); |
| 41 | 41 | content.setUpdater("白名单"); |
| 42 | 42 | // 更新点播和审核的视频状态 |
| 43 | - contentService.callback(content.getId() + "", "白名单审核通过", CommonConst.AUDIT_SUCCESS, "", "白名单"); | |
| 43 | + contentService.callback(content.getId() + "", "白名单审核通过", CommonConst.AUDIT_SUCCESS, "", content.getUpdater()); | |
| 44 | 44 | } |
| 45 | 45 | } |
| 46 | 46 | } |
| ... | ... | @@ -56,6 +56,7 @@ public class ContentJob { |
| 56 | 56 | if (shyContentList != null && shyContentList.size() > 0) { |
| 57 | 57 | logger.info("审核云提交网页审核到易盾数据个数:{}", shyContentList.size()); |
| 58 | 58 | for (ShyContent content : shyContentList) { |
| 59 | + content.setUpdater("机审"); | |
| 59 | 60 | contentService.contentFilter(content); |
| 60 | 61 | } |
| 61 | 62 | } | ... | ... |
src/main/java/com/cnlive/shenhe/job/YiDunUrlResultJob.java
| ... | ... | @@ -57,7 +57,7 @@ public class YiDunUrlResultJob { |
| 57 | 57 | * 每分钟一次 |
| 58 | 58 | */ |
| 59 | 59 | @Scheduled(cron = "0 0/1 * * * ? ") |
| 60 | - public void YiDunUrl() { | |
| 60 | + public void yiDunUrl() { | |
| 61 | 61 | try { |
| 62 | 62 | Map<String, String> params = new HashMap<>(5); |
| 63 | 63 | // 1.设置公共参数 |
| ... | ... | @@ -79,14 +79,14 @@ public class YiDunUrlResultJob { |
| 79 | 79 | int code = resultObject.getIntValue("code"); |
| 80 | 80 | String msg = resultObject.getString("msg"); |
| 81 | 81 | if (code == 200 && "ok".equals(msg)) { |
| 82 | - JSONArray resultJSONArray = resultObject.getJSONArray("result"); | |
| 83 | - if (resultJSONArray != null && resultJSONArray.size() > 0) { | |
| 84 | - for (int i = 0; i < resultJSONArray.size(); i++) { | |
| 85 | - String desc = "易盾网站审核"; | |
| 82 | + JSONArray resultJsonArray = resultObject.getJSONArray("result"); | |
| 83 | + if (resultJsonArray != null && resultJsonArray.size() > 0) { | |
| 84 | + for (int i = 0; i < resultJsonArray.size(); i++) { | |
| 85 | + StringBuilder desc = new StringBuilder("易盾网站审核"); | |
| 86 | 86 | ShyYidun newYiDunMsg = new ShyYidun(); |
| 87 | 87 | ShyContent shyContent = new ShyContent(); |
| 88 | 88 | try { |
| 89 | - JSONObject jsonObject = resultJSONArray.getJSONObject(i); | |
| 89 | + JSONObject jsonObject = resultJsonArray.getJSONObject(i); | |
| 90 | 90 | String dataId = jsonObject.getString("dataId"); |
| 91 | 91 | ShyYidun yiDunMsg = yiDunServiceImpl.getYiDunMsg(dataId); |
| 92 | 92 | if (yiDunMsg == null) { |
| ... | ... | @@ -96,17 +96,16 @@ public class YiDunUrlResultJob { |
| 96 | 96 | newYiDunMsg.setDuration(-1); |
| 97 | 97 | newYiDunMsg.setUpdate_time(new Date()); |
| 98 | 98 | shyContent.setId(Integer.valueOf(yiDunMsg.getContent_id())); |
| 99 | + shyContent.setUpdater("机审"); | |
| 99 | 100 | //检测结果, 1:正常(建议通过) 2:异常(建议拦截) 3:疑似(建议人工确认)0:无结果(检测失败) |
| 100 | 101 | int result = jsonObject.getIntValue("result"); |
| 101 | 102 | newYiDunMsg.setResult_type(String.valueOf(result)); |
| 102 | 103 | if (result == 1) { |
| 103 | - desc = "易盾网站审核通过了"; | |
| 104 | - shyContent.setReceive_status(2); | |
| 105 | - shyContent.setShenhe_msg(desc); | |
| 106 | - newYiDunMsg.setDesc_msg(desc); | |
| 104 | + desc = new StringBuilder("易盾网站审核通过了"); | |
| 105 | + newYiDunMsg.setDesc_msg(desc.toString()); | |
| 107 | 106 | newYiDunMsg.setCheck_status(0); |
| 108 | 107 | //修改图文状态 |
| 109 | - contentServiceImpl.callback(yiDunMsg.getContent_id(), desc, CommonConst.AUDIT_SUCCESS, "", "机审"); | |
| 108 | + contentServiceImpl.callback(String.valueOf(shyContent.getId()), desc.toString(), CommonConst.AUDIT_SUCCESS, "", shyContent.getUpdater()); | |
| 110 | 109 | logger.info("审核云结果回调业务对接方:dataId={}", dataId); |
| 111 | 110 | } else { |
| 112 | 111 | JSONObject evidences = jsonObject.getJSONObject("evidences"); |
| ... | ... | @@ -116,28 +115,28 @@ public class YiDunUrlResultJob { |
| 116 | 115 | JSONObject jsonObject1 = texts.getJSONObject(j); |
| 117 | 116 | //检测结果,0:通过,1:嫌疑,2:不通过 |
| 118 | 117 | int action = jsonObject1.getIntValue("action"); |
| 119 | - String labelMsg = ""; | |
| 118 | + StringBuilder labelMsg = new StringBuilder(); | |
| 120 | 119 | if (action != 0) { |
| 121 | 120 | JSONArray labels = jsonObject1.getJSONArray("labels"); |
| 122 | - labelMsg = "("; | |
| 121 | + labelMsg = new StringBuilder("("); | |
| 123 | 122 | if (labels != null && labels.size() > 0) { |
| 124 | 123 | for (Object obj : labels) { |
| 125 | 124 | JSONObject jsonObjectone = (JSONObject) obj; |
| 126 | 125 | Integer label = jsonObjectone.getInteger("label"); |
| 127 | 126 | String name = TextLabels.getName(label); |
| 128 | - labelMsg = labelMsg + name; | |
| 127 | + labelMsg.append(name); | |
| 129 | 128 | |
| 130 | 129 | } |
| 131 | 130 | } |
| 132 | 131 | } |
| 133 | 132 | if (action == 1) { |
| 134 | - desc = desc + "文字嫌疑" + labelMsg + ")"; | |
| 133 | + desc.append("文字嫌疑").append(labelMsg).append(")"); | |
| 135 | 134 | break; |
| 136 | 135 | } else if (action == 2) { |
| 137 | - desc = desc + "文字违规" + labelMsg + ")"; | |
| 136 | + desc.append("文字违规").append(labelMsg).append(")"); | |
| 138 | 137 | break; |
| 139 | 138 | } else { |
| 140 | - desc = desc + labelMsg + ")"; | |
| 139 | + desc.append(labelMsg).append(")"); | |
| 141 | 140 | } |
| 142 | 141 | } |
| 143 | 142 | } |
| ... | ... | @@ -147,10 +146,10 @@ public class YiDunUrlResultJob { |
| 147 | 146 | JSONObject jsonObject1 = images.getJSONObject(k); |
| 148 | 147 | //0:正常,1:不确定,2:确定 |
| 149 | 148 | int level = jsonObject1.getIntValue("level"); |
| 150 | - String labelMsg = ""; | |
| 149 | + StringBuilder labelMsg = new StringBuilder(); | |
| 151 | 150 | if (level != 0) { |
| 152 | 151 | JSONArray labels = jsonObject1.getJSONArray("labels"); |
| 153 | - labelMsg = "("; | |
| 152 | + labelMsg = new StringBuilder("("); | |
| 154 | 153 | if (labels != null && labels.size() > 0) { |
| 155 | 154 | for (Object obj : labels) { |
| 156 | 155 | JSONObject jsonObjectone = (JSONObject) obj; |
| ... | ... | @@ -159,40 +158,40 @@ public class YiDunUrlResultJob { |
| 159 | 158 | if (labelsLevel != 0) { |
| 160 | 159 | Integer label = jsonObjectone.getInteger("label"); |
| 161 | 160 | String name = ImageLabels.getName(label); |
| 162 | - labelMsg = labelMsg + name; | |
| 161 | + labelMsg.append(name); | |
| 163 | 162 | } |
| 164 | 163 | } |
| 165 | 164 | } |
| 166 | 165 | |
| 167 | 166 | } |
| 168 | 167 | if (level == 1) { |
| 169 | - desc = desc + "第" + (i + 1) + "张图片嫌疑" + labelMsg + ")"; | |
| 168 | + desc.append("第").append(i + 1).append("张图片嫌疑").append(labelMsg).append(")"); | |
| 170 | 169 | break; |
| 171 | - } | |
| 172 | - if (level == 2) { | |
| 173 | - desc = desc + "第" + (i + 1) + "张图片违规" + labelMsg + ")"; | |
| 170 | + } else if (level == 2) { | |
| 171 | + desc.append("第").append(i + 1).append("张图片违规").append(labelMsg).append(")"); | |
| 174 | 172 | break; |
| 173 | + } else { | |
| 174 | + desc.append(labelMsg).append(")"); | |
| 175 | 175 | } |
| 176 | 176 | } |
| 177 | 177 | } |
| 178 | - // 领取状态为已审核 | |
| 179 | - shyContent.setReceive_status(CommonConst.RECEIVE_AUDIT); | |
| 180 | - shyContent.setShenhe_msg(desc); | |
| 181 | - shyContent.setContent_status(CommonConst.AUDIT_REFUSE); | |
| 182 | - newYiDunMsg.setDesc_msg(desc); | |
| 178 | + newYiDunMsg.setDesc_msg(desc.toString()); | |
| 183 | 179 | newYiDunMsg.setCheck_status(2); |
| 184 | 180 | //修改图文状态 |
| 185 | - contentServiceImpl.callback(yiDunMsg.getContent_id(), "机审审核拒绝", CommonConst.AUDIT_REFUSE, "", "机审"); | |
| 181 | + contentServiceImpl.callback(String.valueOf(shyContent.getId()), desc.toString(), CommonConst.AUDIT_REFUSE, "", shyContent.getUpdater()); | |
| 186 | 182 | } |
| 187 | 183 | } catch (NumberFormatException e) { |
| 188 | 184 | e.printStackTrace(); |
| 185 | + // 领取状态为已审 | |
| 186 | + shyContent.setReceive_status(CommonConst.RECEIVE_AUDIT); | |
| 187 | + shyContent.setContent_status(CommonConst.AUDIT_REFUSE); | |
| 189 | 188 | //审核类型改为人工审核 |
| 190 | 189 | shyContent.setShenhe_type(CommonConst.AUDIT_TYPE_USER); |
| 191 | 190 | //拒绝原因 |
| 192 | 191 | shyContent.setShenhe_msg("易盾网站识别其它问题需排查"); |
| 193 | 192 | newYiDunMsg.setDesc_msg("易盾网站识别其它问题需排查"); |
| 193 | + contentServiceImpl.updateshyContent(shyContent); | |
| 194 | 194 | } |
| 195 | - contentServiceImpl.updateshyContent(shyContent); | |
| 196 | 195 | yiDunServiceImpl.updateYiDunMsg(newYiDunMsg); |
| 197 | 196 | } |
| 198 | 197 | } | ... | ... |
src/main/java/com/cnlive/shenhe/serviceImpl/ContentServiceImpl.java
| ... | ... | @@ -419,11 +419,11 @@ public class ContentServiceImpl { |
| 419 | 419 | //审核类型,1:免审,2:机审,3:人工审 默认人工审 |
| 420 | 420 | Integer shenheType = CommonConst.AUDIT_TYPE_USER; |
| 421 | 421 | //如果当前sp是免审sp |
| 422 | - if (sites.contains(spId)) { | |
| 422 | + if (sites.contains(spId) || ContentTag.startsWith("cms_") || ContentTag.startsWith("edu_")) { | |
| 423 | 423 | //免审 |
| 424 | 424 | shenheType = CommonConst.AUDIT_TYPE_FREE; |
| 425 | 425 | } else { |
| 426 | - if ("content".equals(ContentTag) || ContentTag.startsWith("cms_") || ContentTag.startsWith("edu_")) { | |
| 426 | + if ("content".equals(ContentTag)) { | |
| 427 | 427 | //机审 |
| 428 | 428 | shenheType = CommonConst.AUDIT_TYPE_MACHANE; |
| 429 | 429 | } |
| ... | ... | @@ -445,13 +445,12 @@ public class ContentServiceImpl { |
| 445 | 445 | logger.info("审核云向易盾网站检测接口提交的url:{}", contentUrl); |
| 446 | 446 | //调用易盾网站检测接口 |
| 447 | 447 | JSONObject jsonObject = YiDunAntiFraudUtil.submitYiDunUrl(contentUrl); |
| 448 | - | |
| 449 | 448 | if (jsonObject != null) { |
| 450 | 449 | Integer code = jsonObject.getInteger("code"); |
| 451 | 450 | String msg = jsonObject.getString("msg"); |
| 452 | 451 | if (code != 200) { |
| 453 | 452 | // |0待发布 |1已发布 |2已下线 |
| 454 | - callback(String.valueOf(shyContent.getId()), "机审审核拒绝", CommonConst.AUDIT_REFUSE, "", "机审"); | |
| 453 | + callback(String.valueOf(shyContent.getId()), "机审审核拒绝", CommonConst.AUDIT_REFUSE, "", shyContent.getUpdater()); | |
| 455 | 454 | } |
| 456 | 455 | JSONObject result = jsonObject.getJSONObject("result"); |
| 457 | 456 | String dataId = result.getString("dataId"); | ... | ... |