FindTask.java 30 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679
  1. package com.juxin.client.websocket;
  2. import cn.hutool.core.date.DatePattern;
  3. import cn.hutool.core.date.DateUtil;
  4. import cn.hutool.core.io.FileUtil;
  5. import cn.hutool.core.util.IdUtil;
  6. import cn.hutool.core.util.RandomUtil;
  7. import cn.hutool.core.util.StrUtil;
  8. import cn.hutool.json.JSONObject;
  9. import cn.hutool.json.JSONUtil;
  10. import com.juxin.client.websocket.constant.GfConstants;
  11. import com.juxin.client.websocket.enums.WebsocketTypeEnum;
  12. import com.juxin.client.websocket.ppojo.WebsocketInfo;
  13. import org.springframework.beans.factory.annotation.Autowired;
  14. import org.springframework.context.annotation.Bean;
  15. import org.springframework.scheduling.annotation.Scheduled;
  16. import org.springframework.stereotype.Component;
  17. import org.springframework.util.StringUtils;
  18. import org.springframework.web.socket.client.WebSocketClient;
  19. import javax.annotation.PostConstruct;
  20. import javax.websocket.ContainerProvider;
  21. import javax.websocket.Session;
  22. import javax.websocket.WebSocketContainer;
  23. import java.net.URI;
  24. import java.util.*;
  25. @Component
  26. public class FindTask {
  27. public static String Address1 = "ws://127.0.0.1:9990/pythonInteractive/websocket/pythonClient";
  28. public static final String[] status = {"success", "success", "fail", "success", "success", "stop", "success"};
  29. //机构已反馈 机构暂未反馈 机构反馈失败,失败原因xxx 国反异常,获取结果失败
  30. public static final String[] SPLIT_RESULT =
  31. {"机构已反馈", "机构暂未反馈", "机构反馈失败,失败原因1", "机构已反馈",
  32. "国反异常,获取结果失败", "机构已反馈",
  33. "机构反馈失败,失败原因2", "机构已反馈", "机构反馈失败,失败原因3", "机构已反馈", "机构已反馈"};
  34. @Autowired
  35. private com.juxin.client.websocket.WebSocketClient client;
  36. public void init() {
  37. try {
  38. WebSocketContainer container = ContainerProvider.getWebSocketContainer();
  39. client = new com.juxin.client.websocket.WebSocketClient();
  40. Session session = container.connectToServer(client, new URI(Address1));
  41. client.setUserSession(session);
  42. // client.sendMessage("{ \"infoType\": \"heart\", \"postType\": \"python\", \"methodType\": \"heart\", \"reqJson\": { \"receiveJobStatus\": \"1\", \"msg\": \"ping\" } }");
  43. } catch (Exception e) {
  44. e.printStackTrace();
  45. }
  46. }
  47. @Scheduled(cron = "*/20 * * * * ?")
  48. public void heart() throws Exception {
  49. if (client == null || client.getUserSession() == null) {
  50. init();
  51. }
  52. try {
  53. // 发送消息
  54. client.sendMessage("{ \"infoType\": \"heart\", \"postType\": \"python\", \"methodType\": \"heart\", \"reqJson\": { \"receiveJobStatus\": \"1\", \"msg\": \"ping\" } }");
  55. } catch (Exception e) {
  56. e.printStackTrace();
  57. }
  58. }
  59. @Scheduled(cron = "*/5 * * * * ?")
  60. public void findResultTask() {
  61. if (client == null || client.getUserSession() == null) {
  62. return;
  63. }
  64. if (!GfConstants.FIND_RESULT_FLAG) {
  65. System.out.println("不具备获取结果状态,获取任务标志为false,证明有回捞任务在运行中**********************************");
  66. return;
  67. }
  68. try {
  69. // 发送消息
  70. client.sendMessage("{ \"infoType\": \"getResultQueueJob\", \"postType\": \"python\", \"methodType\": \"getResultQueueJob\" }");
  71. GfConstants.FIND_RESULT_FLAG = false;
  72. // 保持连接一段时间
  73. } catch (Exception e) {
  74. e.printStackTrace();
  75. }
  76. }
  77. @Scheduled(cron = "*/20 * * * * ?")
  78. public void findTask() {
  79. if (client == null || client.getUserSession() == null) {
  80. return;
  81. }
  82. if (!GfConstants.FIND_FLAG) {
  83. System.out.println("不具备获取任务状态,获取任务标志为false,证明有任务在运行中**********************************");
  84. return;
  85. }
  86. try {
  87. // 发送消息
  88. client.sendMessage("{ \"infoType\": \"getQueueJob\", \"postType\": \"python\", \"methodType\": \"getQueueJob\" }");
  89. GfConstants.FIND_FLAG = false;
  90. // 保持连接一段时间
  91. } catch (Exception e) {
  92. e.printStackTrace();
  93. }
  94. }
  95. public void dealTask(String message) {
  96. try {
  97. String result = "";
  98. WebsocketInfo bean = JSONUtil.toBean(message, WebsocketInfo.class);
  99. WebsocketTypeEnum enumByType = WebsocketTypeEnum.getEnumByType(bean.getInfoType());
  100. int i = RandomUtil.randomInt(0, 3);
  101. System.out.println("开始睡眠,睡眠时间" + i + "*********************************************");
  102. //Thread.sleep(i * 1000);
  103. switch (enumByType) {
  104. case COMMIT_MSG:
  105. result = commitTask(bean);
  106. if (result == null || result == "") {
  107. GfConstants.FIND_FLAG = true;
  108. } else {
  109. try {
  110. client.sendMessage(result);
  111. } finally {
  112. GfConstants.FIND_FLAG = true;
  113. }
  114. }
  115. break;
  116. case RESULT_LIST_MSG:
  117. result = searchTask(bean);
  118. if (result == "") {
  119. System.out.println("无回捞结果任务");
  120. return;
  121. }
  122. try {
  123. client.sendMessage(result);
  124. } finally {
  125. GfConstants.FIND_RESULT_FLAG = true;
  126. }
  127. break;
  128. case GET_RESULT_QUEUE_JOB:
  129. result = searchTask(bean);
  130. if (result == "") {
  131. return;
  132. }
  133. break;
  134. case ALARM_DATA:
  135. result = alarmWork(bean);
  136. if (result == "") {
  137. return;
  138. }
  139. break;
  140. default:
  141. return;
  142. }
  143. } catch (Exception e) {
  144. System.out.println("出现位置异常*******************:" + message);
  145. throw new RuntimeException(e);
  146. }
  147. }
  148. /**
  149. * 提交任务
  150. *
  151. * @param bean
  152. * @return
  153. */
  154. public String commitTask(WebsocketInfo bean) {
  155. String result = "";
  156. String methodType = bean.getMethodType();
  157. Object reqJson = bean.getReqJson();
  158. if (Objects.isNull(reqJson) || reqJson == "") {
  159. return result;
  160. }
  161. if (StrUtil.isBlankIfStr(methodType) || StrUtil.isBlankIfStr(reqJson) || reqJson == "" || reqJson == null) {
  162. return result;
  163. }
  164. switch (methodType) {
  165. case "bankCommit":
  166. result = bankCommitTask(reqJson);
  167. break;
  168. case "thirdCommit":
  169. result = thirdCommitTask(reqJson);
  170. break;
  171. case "serialCommit":
  172. result = serialCommitTask(reqJson);
  173. break;
  174. case "allAccountCommit":
  175. result = allAccountCommitTask(reqJson);
  176. break;
  177. case "bankAllAccountCommit":
  178. result = bankAllAccountCommitTask(reqJson);
  179. break;
  180. case "thirdSubjectCommit":
  181. result = thirdSubjectCommitTask(reqJson);
  182. break;
  183. default:
  184. break;
  185. }
  186. return result;
  187. }
  188. public String bankCommitTask(Object reqJson) {
  189. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  190. Map<String, Object> result = new HashMap<>();
  191. result.put("infoType", "over");
  192. result.put("postType", "python");
  193. result.put("methodType", "bankCommit");
  194. Map<String, Object> req = new HashMap<>();
  195. req.put("recordId", jsonObject.get("groupId"));
  196. req.put("groupId", jsonObject.get("groupId"));
  197. String jobState = status[RandomUtil.randomInt(0, 6)];
  198. req.put("jobState", jobState);
  199. if (Objects.equals(jobState, "success")) {
  200. List<Map<String, String>> split = new ArrayList<>();
  201. List<Map<String, String>> list = jsonObject.get("list", List.class);
  202. list.forEach(e -> {
  203. Map<String, String> map = new HashMap<>();
  204. map.put("applicationid", IdUtil.fastSimpleUUID());
  205. map.put("bankCard", e.get("bankCard"));
  206. map.put("result", "0000");
  207. map.put("maninBodyType", e.get("maninBodyType"));
  208. map.put("bankName", Objects.toString(jsonObject.get("bankname")));
  209. map.put("splitTime", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + "-"
  210. + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN));
  211. split.add(map);
  212. });
  213. req.put("bankSplits", split);
  214. }
  215. result.put("reqJson", req);
  216. return JSONUtil.toJsonStr(result);
  217. }
  218. public String thirdCommitTask(Object reqJson) {
  219. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  220. Map<String, Object> result = new HashMap<>();
  221. result.put("infoType", "over");
  222. result.put("postType", "python");
  223. result.put("methodType", "thirdCommit");
  224. Map<String, Object> req = new HashMap<>();
  225. req.put("recordId", jsonObject.get("groupId"));
  226. req.put("groupId", jsonObject.get("groupId"));
  227. String jobState = status[RandomUtil.randomInt(0, 6)];
  228. req.put("jobState", jobState);
  229. if (Objects.equals(jobState, "success")) {
  230. List<Map<String, String>> split = new ArrayList<>();
  231. List<Map<String, String>> list = jsonObject.get("list", List.class);
  232. list.forEach(e -> {
  233. Map<String, String> map = new HashMap<>();
  234. map.put("applicationid", IdUtil.fastSimpleUUID());
  235. map.put("data", e.get("accountNo"));
  236. map.put("searchAgency", Objects.toString(jsonObject.get("searchAgency")));
  237. map.put("result", "0000");
  238. map.put("accountSearchType", e.get("accountSearchType"));
  239. map.put("splitTime", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + "-"
  240. + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN));
  241. split.add(map);
  242. });
  243. req.put("thirdFundsSplits", split);
  244. }
  245. result.put("reqJson", req);
  246. return JSONUtil.toJsonStr(result);
  247. }
  248. public String serialCommitTask(Object reqJson) {
  249. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  250. Map<String, Object> result = new HashMap<>();
  251. result.put("infoType", "over");
  252. result.put("postType", "python");
  253. result.put("methodType", "serialCommit");
  254. Map<String, Object> req = new HashMap<>();
  255. req.put("recordId", jsonObject.get("groupId"));
  256. req.put("groupId", jsonObject.get("groupId"));
  257. String jobState = status[RandomUtil.randomInt(0, 6)];
  258. req.put("jobState", jobState);
  259. if (Objects.equals(jobState, "success")) {
  260. List<Map<String, String>> split = new ArrayList<>();
  261. List<Map<String, String>> list = jsonObject.get("list", List.class);
  262. list.forEach(e -> {
  263. Map<String, String> map = new HashMap<>();
  264. map.put("applicationid", IdUtil.fastSimpleUUID());
  265. map.put("data", e.get("accountNo"));
  266. map.put("searchAgency", Objects.toString(jsonObject.get("searchAgency")));
  267. map.put("result", "0000");
  268. map.put("splitTime", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + "-"
  269. + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN));
  270. split.add(map);
  271. });
  272. req.put("serialNumberSplits", split);
  273. }
  274. result.put("reqJson", req);
  275. return JSONUtil.toJsonStr(result);
  276. }
  277. public String allAccountCommitTask(Object reqJson) {
  278. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  279. Map<String, Object> result = new HashMap<>();
  280. result.put("infoType", "over");
  281. result.put("postType", "python");
  282. result.put("methodType", "allAccountCommit");
  283. Map<String, Object> req = new HashMap<>();
  284. req.put("recordId", jsonObject.get("groupId"));
  285. req.put("groupId", jsonObject.get("groupId"));
  286. String jobState = status[RandomUtil.randomInt(0, 6)];
  287. req.put("jobState", jobState);
  288. if (Objects.equals(jobState, "success")) {
  289. List<Map<String, String>> split = new ArrayList<>();
  290. List<Map<String, String>> list = jsonObject.get("list", List.class);
  291. list.forEach(e -> {
  292. Map<String, String> map = new HashMap<>();
  293. map.put("applicationid", IdUtil.fastSimpleUUID());
  294. map.put("data", e.get("accountNo"));
  295. map.put("searchAgency", Objects.toString(jsonObject.get("searchAgency")));
  296. map.put("peopleName", e.get("peopleName"));
  297. map.put("result", "0000");
  298. map.put("accountSearchType", e.get("accountSearchType"));
  299. map.put("splitTime", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + "-"
  300. + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN));
  301. split.add(map);
  302. });
  303. req.put("allAccountSplits", split);
  304. }
  305. result.put("reqJson", req);
  306. return JSONUtil.toJsonStr(result);
  307. }
  308. public String bankAllAccountCommitTask(Object reqJson) {
  309. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  310. Map<String, Object> result = new HashMap<>();
  311. result.put("infoType", "over");
  312. result.put("postType", "python");
  313. result.put("methodType", "bankAllAccountCommit");
  314. Map<String, Object> req = new HashMap<>();
  315. req.put("recordId", jsonObject.get("groupId"));
  316. req.put("groupId", jsonObject.get("groupId"));
  317. String jobState = status[RandomUtil.randomInt(0, 6)];
  318. req.put("jobState", jobState);
  319. if (Objects.equals(jobState, "success")) {
  320. List<Map<String, String>> split = new ArrayList<>();
  321. List<Map<String, String>> list = jsonObject.get("list", List.class);
  322. list.forEach(e -> {
  323. Map<String, String> map = new HashMap<>();
  324. map.put("applicationid", IdUtil.fastSimpleUUID());
  325. map.put("result", "0000");
  326. map.put("maninBodyType", e.get("maninBodyType"));
  327. map.put("accountNo", e.get("accountNo"));
  328. map.put("accountName", e.get("accountName"));
  329. map.put("bankName", Objects.toString(jsonObject.get("bankname")));
  330. map.put("splitTime", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + "-"
  331. + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN));
  332. split.add(map);
  333. });
  334. req.put("bankAllAccountSplits", split);
  335. }
  336. result.put("reqJson", req);
  337. return JSONUtil.toJsonStr(result);
  338. }
  339. /**
  340. * 第三方主体 提交over接口
  341. * @param reqJson
  342. * @return
  343. */
  344. public String thirdSubjectCommitTask(Object reqJson) {
  345. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  346. Map<String, Object> result = new HashMap<>();
  347. result.put("infoType", "over");
  348. result.put("postType", "python");
  349. result.put("methodType", "thirdSubjectCommit");
  350. Map<String, Object> req = new HashMap<>();
  351. req.put("recordId", jsonObject.get("groupId"));
  352. req.put("groupId", jsonObject.get("groupId"));
  353. req.put("jobState", status[RandomUtil.randomInt(0, 6)]);
  354. List<Map<String, String>> split = new ArrayList<>();
  355. List<Map<String, String>> list = jsonObject.get("list", List.class);
  356. list.forEach(e -> {
  357. Map<String, String> map = new HashMap<>();
  358. map.put("applicationid", IdUtil.fastSimpleUUID());
  359. map.put("data", e.get("accountNo"));
  360. map.put("searchAgency", Objects.toString(jsonObject.get("searchAgency")));
  361. map.put("result", "0000");
  362. map.put("accountSearchType", e.get("accountSearchType"));
  363. split.add(map);
  364. });
  365. req.put("thirdSubjectSplits", split);
  366. result.put("reqJson", req);
  367. return JSONUtil.toJsonStr(result);
  368. }
  369. /**
  370. * 回捞任务
  371. *
  372. * @param bean
  373. * @return
  374. */
  375. public String searchTask(WebsocketInfo bean) {
  376. String result = "";
  377. String methodType = bean.getMethodType();
  378. if (methodType == null || methodType.equals("")) {
  379. return result;
  380. }
  381. Object reqJson = bean.getReqJson();
  382. switch (methodType) {
  383. case "bankResult":
  384. result = bankResultTask(reqJson);
  385. break;
  386. case "thirdResult":
  387. result = thirdResultTask(reqJson);
  388. break;
  389. case "serialResult":
  390. result = serialResultTask(reqJson);
  391. break;
  392. case "allAccountResult":
  393. result = allAccountResultTask(reqJson);
  394. break;
  395. case "bankAllAccountResult":
  396. result = bankAllAccountResultTask(reqJson);
  397. break;
  398. case "thirdOwnerResult":
  399. result = thirdSubjectResultTask(reqJson);
  400. break;
  401. default:
  402. break;
  403. }
  404. return result;
  405. }
  406. public String bankResultTask(Object reqJson) {
  407. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  408. JSONObject param = jsonObject.get("params", JSONObject.class);
  409. Map<String, Object> result = new HashMap<>();
  410. result.put("infoType", "result");
  411. result.put("postType", "python");
  412. result.put("methodType", "bankResult");
  413. Map<String, Object> req = new HashMap<>();
  414. req.put("applicationId", param.get("applicationid"));
  415. String splitResult = SPLIT_RESULT[RandomUtil.randomInt(0, 10)];
  416. req.put("status", splitResult);
  417. if (Objects.equals(splitResult, "机构已反馈")) {
  418. req.put("valueCount", RandomUtil.randomInt(0, 10000));
  419. result.put("reqJson", req);
  420. FileUtil.copy(FileUtil.file("excel/流水文件.xlsx")
  421. , FileUtil.file(Objects.toString(param.get("file_path")))
  422. , true);
  423. } else {
  424. req.put("valueCount", 0);
  425. result.put("reqJson", req);
  426. FileUtil.copy(FileUtil.file("excel/流水空文件.xlsx")
  427. , FileUtil.file(Objects.toString(param.get("file_path")))
  428. , true);
  429. }
  430. return JSONUtil.toJsonStr(result);
  431. }
  432. public String thirdResultTask(Object reqJson) {
  433. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  434. JSONObject param = jsonObject.get("params", JSONObject.class);
  435. Map<String, Object> result = new HashMap<>();
  436. result.put("infoType", "result");
  437. result.put("postType", "python");
  438. result.put("methodType", "thirdResult");
  439. Map<String, Object> req = new HashMap<>();
  440. req.put("applicationId", param.get("applicationid"));
  441. String splitResult = SPLIT_RESULT[RandomUtil.randomInt(0, 10)];
  442. req.put("status", splitResult);
  443. if (Objects.equals(splitResult, "机构已反馈")) {
  444. req.put("valueCount", RandomUtil.randomInt(0, 10000));
  445. result.put("reqJson", req);
  446. FileUtil.copy(FileUtil.file("excel/流水文件.xlsx")
  447. , FileUtil.file(Objects.toString(param.get("file_path")))
  448. , true);
  449. } else {
  450. req.put("valueCount", 0);
  451. result.put("reqJson", req);
  452. FileUtil.copy(FileUtil.file("excel/流水空文件.xlsx")
  453. , FileUtil.file(Objects.toString(param.get("file_path")))
  454. , true);
  455. }
  456. return JSONUtil.toJsonStr(result);
  457. }
  458. public String serialResultTask(Object reqJson) {
  459. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  460. JSONObject param = jsonObject.get("params", JSONObject.class);
  461. Map<String, Object> result = new HashMap<>();
  462. result.put("infoType", "result");
  463. result.put("postType", "python");
  464. result.put("methodType", "serialResult");
  465. Map<String, Object> req = new HashMap<>();
  466. req.put("applicationId", param.get("applicationid"));
  467. String splitResult = SPLIT_RESULT[RandomUtil.randomInt(0, 10)];
  468. req.put("status", splitResult);
  469. if (Objects.equals(splitResult, "机构已反馈")) {
  470. req.put("valueCount", RandomUtil.randomInt(0, 10000));
  471. result.put("reqJson", req);
  472. FileUtil.copy(FileUtil.file("excel/流水文件.xlsx")
  473. , FileUtil.file(Objects.toString(param.get("file_path")))
  474. , true);
  475. } else {
  476. req.put("valueCount", 0);
  477. result.put("reqJson", req);
  478. FileUtil.copy(FileUtil.file("excel/流水空文件.xlsx")
  479. , FileUtil.file(Objects.toString(param.get("file_path")))
  480. , true);
  481. }
  482. return JSONUtil.toJsonStr(result);
  483. }
  484. public String allAccountResultTask(Object reqJson) {
  485. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  486. JSONObject param = jsonObject.get("params", JSONObject.class);
  487. Map<String, Object> result = new HashMap<>();
  488. result.put("infoType", "result");
  489. result.put("postType", "python");
  490. result.put("methodType", "allAccountResult");
  491. result.put("combineSearchFlag", "是");
  492. result.put("combineSearchStart", "2025-03-05");
  493. result.put("combineSearchEnd", "2025-05-05");
  494. Map<String, Object> req = new HashMap<>();
  495. req.put("applicationId", param.get("applicationid"));
  496. String splitResult = SPLIT_RESULT[RandomUtil.randomInt(0, 10)];
  497. req.put("status", splitResult);
  498. if (Objects.equals(splitResult, "机构已反馈")) {
  499. req.put("valueCount", RandomUtil.randomInt(0, 10000));
  500. result.put("reqJson", req);
  501. FileUtil.copy(FileUtil.file("excel/第三方全账户.xlsx")
  502. , FileUtil.file(Objects.toString(param.get("file_path")))
  503. , true);
  504. } else {
  505. req.put("valueCount", 0);
  506. result.put("reqJson", req);
  507. FileUtil.copy(FileUtil.file("excel/第三方全账户空文件.xlsx")
  508. , FileUtil.file(Objects.toString(param.get("file_path")))
  509. , true);
  510. }
  511. return JSONUtil.toJsonStr(result);
  512. }
  513. public String bankAllAccountResultTask(Object reqJson) {
  514. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  515. JSONObject param = jsonObject.get("params", JSONObject.class);
  516. Map<String, Object> result = new HashMap<>();
  517. result.put("infoType", "result");
  518. result.put("postType", "python");
  519. result.put("methodType", "bankAllAccountResult");
  520. result.put("combineSearchFlag", "是");
  521. result.put("combineSearchStart", "2025-03-05");
  522. result.put("combineSearchEnd", "2025-05-05");
  523. Map<String, Object> req = new HashMap<>();
  524. req.put("applicationId", param.get("applicationid"));
  525. String splitResult = SPLIT_RESULT[RandomUtil.randomInt(0, 10)];
  526. req.put("status", splitResult);
  527. if (Objects.equals(splitResult, "机构已反馈")) {
  528. req.put("valueCount", RandomUtil.randomInt(0, 10000));
  529. result.put("reqJson", req);
  530. FileUtil.copy(FileUtil.file("excel/银行卡全账户.xlsx")
  531. , FileUtil.file(Objects.toString(param.get("file_path")))
  532. , true);
  533. } else {
  534. req.put("valueCount", 0);
  535. result.put("reqJson", req);
  536. FileUtil.copy(FileUtil.file("excel/银行卡全账户空文件.xlsx")
  537. , FileUtil.file(Objects.toString(param.get("file_path")))
  538. , true);
  539. }
  540. return JSONUtil.toJsonStr(result);
  541. }
  542. /**
  543. * 第三方主体 回捞结果 数据
  544. * @param reqJson
  545. * @return
  546. */
  547. public String thirdSubjectResultTask(Object reqJson){
  548. String thirdSubjectResult=" {\n" +
  549. " \n" +
  550. " \"applicationid\":\"0303A2002331253012019FZ2505151353210\",\n" +
  551. " \"result\":\"0000\",\n" +
  552. " \n" +
  553. " \"datatype\":\"01\",\n" +
  554. " \"data\":\"Cl19850404(085e9858e9a060738bd691107@wx.tenpay.com)\",\n" +
  555. " \"subjecttype\":\"01\",\n" +
  556. " \"accountownername\":\"陈林\",\n" +
  557. " \"accountowneridtype\":\"01\",\n" +
  558. " \"accountownerid\":\"320922198504045025\",\n" +
  559. " \"credentialvalidity\":\"20160405-20360405\",\n" +
  560. " \"telnumber\":\"15190380742\",\n" +
  561. " \"bindingdatatype\":\"03\",\n" +
  562. " \"bindingdata\":\"Cl19850404\",\n" +
  563. " \"bankcard\":[\n" +
  564. " {\n" +
  565. " \"applicationid\":\"0303A2002331253012019FZ2505151353210\",\n" +
  566. " \"bankid\":\"2702\",\n" +
  567. " \"bankname\":\"江苏农商联合银行\",\n" +
  568. " \"bankaccount\":\"6230661635027269745\",\n" +
  569. " \"cardtype\":\"1\",\n" +
  570. " \"cardvalidation\":\"1\",\n" +
  571. " \"cardexpirydate\":\"-\",\n" +
  572. " \"cardinfo\":\"-\",\n" +
  573. " \"txcode\":null,\n" +
  574. " \"pk\":\"0303A2002331253012019FZ2505151353210\"\n" +
  575. " },\n" +
  576. " {\n" +
  577. "\n" +
  578. " \"applicationid\":\"1111\",\n" +
  579. " \"bankid\":\"1111\",\n" +
  580. " \"bankname\":\"1111银行\",\n" +
  581. " \"bankaccount\":\"111111111115\",\n" +
  582. " \"cardtype\":\"2\",\n" +
  583. " \"cardvalidation\":\"2\",\n" +
  584. " \"cardexpirydate\":\"-\",\n" +
  585. " \"cardinfo\":\"-\",\n" +
  586. " \"txcode\":null,\n" +
  587. " \"pk\":\"0303A2002331253012019FZ2505151353210\"\n" +
  588. " }\n" +
  589. " ]\n" +
  590. " }";
  591. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  592. JSONObject param = jsonObject.get("params", JSONObject.class);
  593. Map<String, Object> result = new HashMap<>();
  594. result.put("infoType", "result");
  595. result.put("postType", "python");
  596. result.put("methodType", "thirdOwnerResult");
  597. Map<String, Object> req = new HashMap<>();
  598. req.put("applicationId", param.get("applicationid"));
  599. req.put("accountSearchType",param.get("accountSearchType"));
  600. req.put("status", SPLIT_RESULT[RandomUtil.randomInt(0, 10)]);
  601. req.put("valueCount", RandomUtil.randomInt(0, 10000));
  602. JSONObject thirdSubject=JSONUtil.parseObj(thirdSubjectResult);
  603. thirdSubject.put("applicationid", param.get("applicationid"));
  604. thirdSubject.put("data",param.get("data"));
  605. req.put("thirdSubjectResult",thirdSubject);
  606. result.put("reqJson", req);
  607. System.out.println(result);
  608. return JSONUtil.toJsonStr(result);
  609. }
  610. public static void main(String[] args) {
  611. FileUtil.copy(FileUtil.file("excel/6226890438342486.xlsx")
  612. , FileUtil.file("C:\\Users\\EDY\\Desktop\\需求\\银行卡查询\\test.xlsx")
  613. , true);
  614. }
  615. public String alarmWork(WebsocketInfo bean) {
  616. String methodType = bean.getMethodType();
  617. if (methodType == null || methodType.equals("")) {
  618. return "";
  619. }
  620. Object reqJson = bean.getReqJson();
  621. JSONObject jsonObject = JSONUtil.parseObj(reqJson);
  622. Map<String, Object> result = new HashMap<>();
  623. result.put("infoType", "alarmData");
  624. result.put("postType", "python");
  625. result.put("methodType", "bankCommit");
  626. Map<String, Object> req = new HashMap<>();
  627. req.put("recordId", jsonObject.get("groupId"));
  628. req.put("groupId", jsonObject.get("groupId"));
  629. req.put("jobState", status[RandomUtil.randomInt(0, 6)]);
  630. // List<Map<String, String>> split = new ArrayList<>();
  631. // List<Map<String, String>> list = jsonObject.get("list", List.class);
  632. // list.forEach(e -> {
  633. // Map<String, String> map = new HashMap<>();
  634. // map.put("applicationid", IdUtil.fastSimpleUUID());
  635. // map.put("bankCard", e.get("bankCard"));
  636. // map.put("result", "0000");
  637. // map.put("maninBodyType", e.get("maninBodyType"));
  638. // map.put("bankName", Objects.toString(jsonObject.get("bankname")));
  639. // map.put("splitTime", DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN) + "-"
  640. // + DateUtil.format(new Date(), DatePattern.PURE_DATETIME_MS_PATTERN));
  641. // split.add(map);
  642. // });
  643. // req.put("bankSplits", split);
  644. // result.put("reqJson", req);
  645. return JSONUtil.toJsonStr(result);
  646. }
  647. }