FindTask.java 31 KB

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