Commit 07b32855a3873645af79a8629f8da0e6306b19d2
1 parent
32adb649
按需修改代码
Showing
2 changed files
with
10 additions
and
33 deletions
src/main/java/com/cnlive/shenhe/job/TextJob.java
| ... | ... | @@ -3,7 +3,6 @@ package com.cnlive.shenhe.job; |
| 3 | 3 | import com.alibaba.fastjson.JSONObject; |
| 4 | 4 | import com.cnlive.shenhe.utils.YiDunAntiFraudUtil; |
| 5 | 5 | import lombok.extern.slf4j.Slf4j; |
| 6 | -import org.springframework.stereotype.Component; | |
| 7 | 6 | |
| 8 | 7 | import java.io.*; |
| 9 | 8 | |
| ... | ... | @@ -12,41 +11,30 @@ import java.io.*; |
| 12 | 11 | * @DateTime: 2022-06-27 10:30 |
| 13 | 12 | */ |
| 14 | 13 | @Slf4j |
| 15 | -@Component | |
| 16 | 14 | public class TextJob { |
| 17 | 15 | |
| 18 | 16 | |
| 19 | - //@Scheduled(cron = "0 0/2 * * * ? ") | |
| 20 | - public String TestFilter() { | |
| 17 | + public static void main(String[] args) { | |
| 21 | 18 | BufferedReader bufferedReader = null; |
| 22 | 19 | BufferedWriter bufferedWriter = null; |
| 23 | 20 | String type = null; |
| 24 | 21 | String desc = null; |
| 25 | - Integer action; | |
| 26 | 22 | try { |
| 27 | 23 | bufferedReader = new BufferedReader(new FileReader(new File("C:\\Users\\Administrator\\Desktop\\123.txt"))); |
| 28 | 24 | bufferedWriter = new BufferedWriter(new BufferedWriter(new FileWriter(new File("C:\\Users\\Administrator\\Desktop\\通过数据.txt")))); |
| 29 | 25 | boolean falg = true; |
| 30 | 26 | while (falg) { |
| 31 | - if (falg = (bufferedReader.read()) != -1 ? true : false) { | |
| 27 | + if (falg = (bufferedReader.readLine()) != null ? true : false) { | |
| 32 | 28 | String txt = bufferedReader.readLine(); |
| 33 | - String[] split = txt.split(","); | |
| 34 | - JSONObject textFilter = null; | |
| 35 | - for (String s : split) { | |
| 36 | - textFilter = YiDunAntiFraudUtil.getTextFilter(s); | |
| 37 | - type = textFilter.getString("type"); | |
| 38 | - desc = textFilter.getString("desc"); | |
| 39 | - action = textFilter.getInteger("action"); | |
| 40 | - | |
| 41 | - if (action == 0) { | |
| 42 | - String hint = textFilter.getString("hint"); | |
| 43 | - bufferedWriter.write(hint); | |
| 44 | - bufferedWriter.newLine(); | |
| 45 | - | |
| 46 | - } | |
| 47 | - log.info("type:{}" + type); | |
| 48 | - log.info("desc:{}" + desc); | |
| 29 | + JSONObject textFilter = YiDunAntiFraudUtil.getTextFilter(txt); | |
| 30 | + type = textFilter.getString("type"); | |
| 31 | + desc = textFilter.getString("desc"); | |
| 32 | + if (type.equals("PASS")) { | |
| 33 | + bufferedWriter.write(txt); | |
| 34 | + bufferedWriter.newLine(); | |
| 49 | 35 | } |
| 36 | + log.info("type:{}" + type); | |
| 37 | + log.info("desc:{}" + desc); | |
| 50 | 38 | } |
| 51 | 39 | } |
| 52 | 40 | |
| ... | ... | @@ -68,7 +56,6 @@ public class TextJob { |
| 68 | 56 | } |
| 69 | 57 | } |
| 70 | 58 | } |
| 71 | - return "type:{}" + type + "desc:{}" + desc; | |
| 72 | 59 | } |
| 73 | 60 | |
| 74 | 61 | } | ... | ... |
src/main/java/com/cnlive/shenhe/utils/YiDunAntiFraudUtil.java
| ... | ... | @@ -161,7 +161,6 @@ public class YiDunAntiFraudUtil { |
| 161 | 161 | int action = resultJsonObject.getIntValue("action"); |
| 162 | 162 | String taskId = resultJsonObject.getString("taskId"); |
| 163 | 163 | String labelMsg = ""; |
| 164 | - String hint = ""; | |
| 165 | 164 | if (action != 0) { |
| 166 | 165 | JSONArray labels = resultJsonObject.getJSONArray("labels"); |
| 167 | 166 | labelMsg = "("; |
| ... | ... | @@ -169,9 +168,6 @@ public class YiDunAntiFraudUtil { |
| 169 | 168 | for (Object obj : labels) { |
| 170 | 169 | JSONObject jsonObjectone = (JSONObject) obj; |
| 171 | 170 | Integer label = jsonObjectone.getInteger("label"); |
| 172 | - JSONObject details = jsonObjectone.getJSONObject("details"); | |
| 173 | - hint = details.getString("hint"); | |
| 174 | - | |
| 175 | 171 | String name = TextLabels.getName(label); |
| 176 | 172 | labelMsg = labelMsg + name; |
| 177 | 173 | |
| ... | ... | @@ -182,20 +178,14 @@ public class YiDunAntiFraudUtil { |
| 182 | 178 | if (action == 0) { |
| 183 | 179 | jsonObj.put("type", "PASS"); |
| 184 | 180 | jsonObj.put("desc", "易盾文本审核通过"); |
| 185 | - jsonObj.put("action", 0); | |
| 186 | - jsonObj.put("hint", hint); | |
| 187 | 181 | } |
| 188 | 182 | if (action == 1) { |
| 189 | 183 | jsonObj.put("type", "REJECT"); |
| 190 | 184 | jsonObj.put("desc", "易盾文本审核文本嫌疑" + labelMsg + ")"); |
| 191 | - jsonObj.put("hint", hint); | |
| 192 | - jsonObj.put("action", 1); | |
| 193 | 185 | } |
| 194 | 186 | if (action == 2) { |
| 195 | 187 | jsonObj.put("type", "REJECT"); |
| 196 | 188 | jsonObj.put("desc", "易盾文本审核文本违规" + labelMsg + ")"); |
| 197 | - jsonObj.put("hint", hint); | |
| 198 | - jsonObj.put("action", 2); | |
| 199 | 189 | } |
| 200 | 190 | jsonObj.put("taskId", taskId); |
| 201 | 191 | logger.info("审核云文本识别处理后结果:{}", jsonObj.toString()); | ... | ... |