InterfaceCheckServer.java 19 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333
  1. package com.jkcredit.invoice.credit;
  2. import com.jkcredit.invoice.common.DataResult;
  3. import com.jkcredit.invoice.component.StatisRequestIdTimeComp;
  4. import com.jkcredit.invoice.credit.interserver.CustomerInterLowerService;
  5. import com.jkcredit.invoice.credit.interserver.NoCarInterService;
  6. import com.jkcredit.invoice.credit.interserver.SelfCarInterService;
  7. import com.jkcredit.invoice.util.StringUtil;
  8. import lombok.extern.slf4j.Slf4j;
  9. import org.springframework.beans.factory.annotation.Autowired;
  10. import org.springframework.stereotype.Service;
  11. /**
  12. * 接口过滤器
  13. * @author mumuxigua
  14. */
  15. @Service("interfaceCheckServer")
  16. @Slf4j
  17. public class InterfaceCheckServer {
  18. @Autowired
  19. CustomerInterLowerService customerInterLowerService;
  20. @Autowired
  21. SelfCarInterService selfCarInterService;
  22. @Autowired
  23. NoCarInterService noCarInterService;
  24. @Autowired
  25. StatisRequestIdTimeComp statisRequestIdTimeComp;
  26. /**
  27. * 跳转到对应的Service服务处理逻辑
  28. * @param appKey
  29. * @param api
  30. * @param data
  31. * @param requestid
  32. * @return
  33. */
  34. public DataResult doJumpHandler(String appKey, String api, String data, String requestid) {
  35. log.info("[-InterfaceCheckServer.doJumpHandler-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
  36. long startTime = System.currentTimeMillis();
  37. DataResult resultTimeOut = new DataResult();
  38. resultTimeOut.setData(3);
  39. resultTimeOut.setCode(200);
  40. resultTimeOut.setRequestid(requestid);
  41. resultTimeOut.setMsg("网络异常");
  42. DataResult result;
  43. result = getDataResult(appKey, api, data, requestid, resultTimeOut);
  44. log.info("[-InterfaceCheckServer.doJumpHandler-] result appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + " ,result=" + result + " ,costTime=" + (System.currentTimeMillis() - startTime));
  45. return result;
  46. }
  47. private DataResult getDataResult(String appKey, String api, String data, String requestid, DataResult resultTimeOut) {
  48. DataResult result;
  49. switch (api) {
  50. //----------------------------自有车、无车公共接口---------------------------------//
  51. //无车、自有车企业注册
  52. case "COMPANY_ADD_V1":
  53. if (StatisRequestIdTimeComp.isLimit) {
  54. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  55. result = resultTimeOut;
  56. } else {
  57. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  58. result = customerInterLowerService.customeInterRec(appKey, api, data, requestid);
  59. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  60. }
  61. break;
  62. //无车、自有车协议上传
  63. case "PROTOCOL_ADD_V1":
  64. if (StatisRequestIdTimeComp.isLimit) {
  65. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  66. result = resultTimeOut;
  67. } else {
  68. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  69. result = customerInterLowerService.customeProtocolUpLoad(appKey, api, data, requestid);
  70. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  71. }
  72. break;
  73. //无车、自有车企业查询
  74. case "COMPANY_QUERY_V1":
  75. if (StatisRequestIdTimeComp.isLimit) {
  76. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  77. result = resultTimeOut;
  78. } else {
  79. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  80. result = customerInterLowerService.customeInterRecQuery(appKey, api, data, requestid);
  81. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  82. }
  83. break;
  84. //自有车 无车、协议上传状态查询
  85. case "PROTOCOL_STATUS_V1":
  86. if (StatisRequestIdTimeComp.isLimit) {
  87. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  88. result = resultTimeOut;
  89. } else {
  90. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  91. result = customerInterLowerService.customeProtocolStatus(appKey, api, data, requestid);
  92. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  93. }
  94. break;
  95. //----------------------------自有车下游接口---------------------------------//
  96. //自有车 用户卡列表查询
  97. case "CARD_BIND_QUERY_LIST_V1":
  98. if (StatisRequestIdTimeComp.isLimit) {
  99. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  100. result = resultTimeOut;
  101. } else {
  102. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  103. result = selfCarInterService.customeretcquery(appKey, api, data, requestid);
  104. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  105. }
  106. break;
  107. //自有车 卡信息查询
  108. case "CARD_QUERY_CARD_V1":
  109. if (StatisRequestIdTimeComp.isLimit) {
  110. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  111. result = resultTimeOut;
  112. } else {
  113. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  114. result = selfCarInterService.customerQueryEtcInfo(appKey, api, data, requestid);
  115. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  116. }
  117. break;
  118. //自有车 下发短信验证码
  119. case "CARD_BINDING_V1":
  120. if (StatisRequestIdTimeComp.isLimit) {
  121. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  122. result = resultTimeOut;
  123. } else {
  124. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  125. result = selfCarInterService.customeretcrec(appKey, api, data, requestid);
  126. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  127. }
  128. break;
  129. //自有车 卡绑定接口 渠道调用此接口,上传用户收到的短信验证码
  130. case "CARD_VALID_CODE_V1":
  131. if (StatisRequestIdTimeComp.isLimit) {
  132. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  133. result = resultTimeOut;
  134. } else {
  135. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  136. result = selfCarInterService.customeretcrecvalid(appKey, api, data, requestid);
  137. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  138. }
  139. break;
  140. //自有车 交易查询接口 渠道通过此接口可以查询单张卡连续90天内的交易(待开票、开票中、已开票)
  141. case "CARD_TRADE_V1":
  142. if (StatisRequestIdTimeComp.isLimit) {
  143. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  144. result = resultTimeOut;
  145. } else {
  146. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  147. result = selfCarInterService.getTradeList(appKey, api, data, requestid);
  148. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  149. }
  150. break;
  151. //自有车 申请开票接口 渠道通过此接口可以对该公司绑定的单张卡连续90天内的交易进行开票。
  152. case "B2B_INVOICE_APPLY_V1":
  153. if (StatisRequestIdTimeComp.isLimit) {
  154. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  155. result = resultTimeOut;
  156. } else {
  157. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  158. result = selfCarInterService.applInvoice(appKey, api, data, requestid);
  159. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  160. }
  161. break;
  162. //自有车 已开发票查询接口 渠道通过此接口可以根据该公司绑定的单张卡查询此卡在某个月开具的发票。
  163. case "B2B_INVOICE_QUERY_V1":
  164. if (StatisRequestIdTimeComp.isLimit) {
  165. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  166. result = resultTimeOut;
  167. } else {
  168. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  169. result = selfCarInterService.getSelfCarInvoicesByTime(appKey, api, data, requestid);
  170. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  171. }
  172. break;
  173. //自有车 已开发票查询接口 根据开票id进行查询。
  174. case "B2B_INVOICE_APPL_QUERY_V1":
  175. if (StatisRequestIdTimeComp.isLimit) {
  176. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  177. result = resultTimeOut;
  178. } else {
  179. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  180. result = selfCarInterService.getSelfCarInvoicesByAppl(appKey, api, data, requestid);
  181. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  182. }
  183. break;
  184. //自有车 发票下载 渠道通过此接口可以下载某公司某个月份开具的发票。
  185. case "B2B_INVOICE_PACKAGE_V1":
  186. if (StatisRequestIdTimeComp.isLimit) {
  187. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  188. result = resultTimeOut;
  189. } else {
  190. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  191. result = selfCarInterService.getSelfCarInvoicePackage(appKey, api, data, requestid);
  192. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  193. }
  194. break;
  195. //自有车 卡解绑接口。
  196. case "CARD_UNBIND_V1":
  197. result = selfCarInterService.customerCarUnRec(appKey, api, data, requestid);
  198. break;
  199. //自有车 用户卡换绑。
  200. case "B2B_CHANGE_CARD_V1":
  201. result = selfCarInterService.customerCardChange(appKey, api, data, requestid);
  202. break;
  203. //自有车 用户卡换绑查询。
  204. case "B2B_CHANGE_CARD_QUERY_V1":
  205. result = selfCarInterService.customerCardChangeQuery(appKey, api, data, requestid);
  206. break;
  207. //自有车 按交易查申请。
  208. case "B2B_QUERY_TRADE_APPLY_V1":
  209. result = selfCarInterService.tradeApplyQuery(appKey, api, data, requestid);
  210. break;
  211. //----------------------------无车下游接口---------------------------------//
  212. //无车 车辆备案接口
  213. case "VEHICLE_REGISTER":
  214. if (StatisRequestIdTimeComp.isLimit) {
  215. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  216. result = resultTimeOut;
  217. } else {
  218. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  219. result = noCarInterService.customerCarRec(appKey, api, data, requestid);
  220. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  221. }
  222. break;
  223. //无车 车辆备案查询接口
  224. case "VEHICLE_REGISTER_QUERY":
  225. if (StatisRequestIdTimeComp.isLimit) {
  226. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  227. result = resultTimeOut;
  228. } else {
  229. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  230. result = noCarInterService.customeRecUpperQuery(appKey, api, data, requestid);
  231. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  232. }
  233. break;
  234. //无车 实时运单开始指令
  235. case "WAY_BILL_START":
  236. if (StatisRequestIdTimeComp.isLimit) {
  237. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
  238. result = resultTimeOut;
  239. } else {
  240. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  241. result = noCarInterService.noCarBillStart(appKey, api, data, requestid);
  242. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  243. }
  244. break;
  245. //无车 实时运单结束指令
  246. case "WAY_BILL_END":
  247. if (StatisRequestIdTimeComp.isLimit) {
  248. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
  249. result = resultTimeOut;
  250. } else {
  251. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  252. result = noCarInterService.noCarBillEnd(appKey, api, data, requestid);
  253. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  254. }
  255. break;
  256. //无车 历史运单开始指令
  257. case "WAY_BILL_HISTORY_START":
  258. if (StatisRequestIdTimeComp.isLimit) {
  259. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
  260. result = resultTimeOut;
  261. } else {
  262. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  263. result = noCarInterService.noCarHisWaybillStart(appKey, api, data, requestid);
  264. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  265. }
  266. break;
  267. //无车 历史运单结束指令
  268. case "WAY_BILL_HISTORY_END":
  269. if (StatisRequestIdTimeComp.isLimit) {
  270. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
  271. result = resultTimeOut;
  272. } else {
  273. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  274. result = noCarInterService.noCarHisWaybillEnd(appKey, api, data, requestid);
  275. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  276. }
  277. break;
  278. //无车 运单号查询发票数据
  279. case "WAY_BILL_NUM_FIND_INVOICE":
  280. result = noCarInterService.noCarVoiceQuery(appKey, api, data, requestid);
  281. break;
  282. //无车 获取未查询过发票的运单编号
  283. case "FIND_NO_SEARCH_NUM":
  284. if (StatisRequestIdTimeComp.isLimit) {
  285. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  286. result = resultTimeOut;
  287. } else {
  288. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  289. result = noCarInterService.noCarNoVoiceQuery(appKey, api, data, requestid);
  290. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  291. }
  292. break;
  293. //无车 账号余额查询接口
  294. case "BALANCE_QUERY":
  295. if (StatisRequestIdTimeComp.isLimit) {
  296. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  297. result = resultTimeOut;
  298. } else {
  299. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  300. result = noCarInterService.balanceQuery(appKey, api, data, requestid);
  301. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  302. }
  303. break;
  304. //无车 红冲发票查询接口
  305. case "RED_INK_INVOICE_QUERY":
  306. if (StatisRequestIdTimeComp.isLimit) {
  307. log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
  308. result = resultTimeOut;
  309. } else {
  310. statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
  311. result = noCarInterService.redInkInvoiceQuery(appKey, api, data, requestid);
  312. statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
  313. }
  314. break;
  315. //无车 运单号查询发票数据 透传上游
  316. case "WAY_BILL_NUM_FIND_OWNER_INVOICE":
  317. result = noCarInterService.noCarVoiceOwnerQuery(appKey, api, data, requestid);
  318. break;
  319. default:
  320. result = null;
  321. break;
  322. }
  323. return result;
  324. }
  325. }