Commit 07b32855a3873645af79a8629f8da0e6306b19d2

Authored by 王言钊
1 parent 32adb649

按需修改代码

src/main/java/com/cnlive/shenhe/job/TextJob.java
@@ -3,7 +3,6 @@ package com.cnlive.shenhe.job; @@ -3,7 +3,6 @@ package com.cnlive.shenhe.job;
3 import com.alibaba.fastjson.JSONObject; 3 import com.alibaba.fastjson.JSONObject;
4 import com.cnlive.shenhe.utils.YiDunAntiFraudUtil; 4 import com.cnlive.shenhe.utils.YiDunAntiFraudUtil;
5 import lombok.extern.slf4j.Slf4j; 5 import lombok.extern.slf4j.Slf4j;
6 -import org.springframework.stereotype.Component;  
7 6
8 import java.io.*; 7 import java.io.*;
9 8
@@ -12,41 +11,30 @@ import java.io.*; @@ -12,41 +11,30 @@ import java.io.*;
12 * @DateTime: 2022-06-27 10:30 11 * @DateTime: 2022-06-27 10:30
13 */ 12 */
14 @Slf4j 13 @Slf4j
15 -@Component  
16 public class TextJob { 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 BufferedReader bufferedReader = null; 18 BufferedReader bufferedReader = null;
22 BufferedWriter bufferedWriter = null; 19 BufferedWriter bufferedWriter = null;
23 String type = null; 20 String type = null;
24 String desc = null; 21 String desc = null;
25 - Integer action;  
26 try { 22 try {
27 bufferedReader = new BufferedReader(new FileReader(new File("C:\\Users\\Administrator\\Desktop\\123.txt"))); 23 bufferedReader = new BufferedReader(new FileReader(new File("C:\\Users\\Administrator\\Desktop\\123.txt")));
28 bufferedWriter = new BufferedWriter(new BufferedWriter(new FileWriter(new File("C:\\Users\\Administrator\\Desktop\\通过数据.txt")))); 24 bufferedWriter = new BufferedWriter(new BufferedWriter(new FileWriter(new File("C:\\Users\\Administrator\\Desktop\\通过数据.txt"))));
29 boolean falg = true; 25 boolean falg = true;
30 while (falg) { 26 while (falg) {
31 - if (falg = (bufferedReader.read()) != -1 ? true : false) { 27 + if (falg = (bufferedReader.readLine()) != null ? true : false) {
32 String txt = bufferedReader.readLine(); 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,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,7 +161,6 @@ public class YiDunAntiFraudUtil {
161 int action = resultJsonObject.getIntValue("action"); 161 int action = resultJsonObject.getIntValue("action");
162 String taskId = resultJsonObject.getString("taskId"); 162 String taskId = resultJsonObject.getString("taskId");
163 String labelMsg = ""; 163 String labelMsg = "";
164 - String hint = "";  
165 if (action != 0) { 164 if (action != 0) {
166 JSONArray labels = resultJsonObject.getJSONArray("labels"); 165 JSONArray labels = resultJsonObject.getJSONArray("labels");
167 labelMsg = "("; 166 labelMsg = "(";
@@ -169,9 +168,6 @@ public class YiDunAntiFraudUtil { @@ -169,9 +168,6 @@ public class YiDunAntiFraudUtil {
169 for (Object obj : labels) { 168 for (Object obj : labels) {
170 JSONObject jsonObjectone = (JSONObject) obj; 169 JSONObject jsonObjectone = (JSONObject) obj;
171 Integer label = jsonObjectone.getInteger("label"); 170 Integer label = jsonObjectone.getInteger("label");
172 - JSONObject details = jsonObjectone.getJSONObject("details");  
173 - hint = details.getString("hint");  
174 -  
175 String name = TextLabels.getName(label); 171 String name = TextLabels.getName(label);
176 labelMsg = labelMsg + name; 172 labelMsg = labelMsg + name;
177 173
@@ -182,20 +178,14 @@ public class YiDunAntiFraudUtil { @@ -182,20 +178,14 @@ public class YiDunAntiFraudUtil {
182 if (action == 0) { 178 if (action == 0) {
183 jsonObj.put("type", "PASS"); 179 jsonObj.put("type", "PASS");
184 jsonObj.put("desc", "易盾文本审核通过"); 180 jsonObj.put("desc", "易盾文本审核通过");
185 - jsonObj.put("action", 0);  
186 - jsonObj.put("hint", hint);  
187 } 181 }
188 if (action == 1) { 182 if (action == 1) {
189 jsonObj.put("type", "REJECT"); 183 jsonObj.put("type", "REJECT");
190 jsonObj.put("desc", "易盾文本审核文本嫌疑" + labelMsg + ")"); 184 jsonObj.put("desc", "易盾文本审核文本嫌疑" + labelMsg + ")");
191 - jsonObj.put("hint", hint);  
192 - jsonObj.put("action", 1);  
193 } 185 }
194 if (action == 2) { 186 if (action == 2) {
195 jsonObj.put("type", "REJECT"); 187 jsonObj.put("type", "REJECT");
196 jsonObj.put("desc", "易盾文本审核文本违规" + labelMsg + ")"); 188 jsonObj.put("desc", "易盾文本审核文本违规" + labelMsg + ")");
197 - jsonObj.put("hint", hint);  
198 - jsonObj.put("action", 2);  
199 } 189 }
200 jsonObj.put("taskId", taskId); 190 jsonObj.put("taskId", taskId);
201 logger.info("审核云文本识别处理后结果:{}", jsonObj.toString()); 191 logger.info("审核云文本识别处理后结果:{}", jsonObj.toString());