123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333 |
- package com.jkcredit.invoice.credit;
- import com.jkcredit.invoice.common.DataResult;
- import com.jkcredit.invoice.component.StatisRequestIdTimeComp;
- import com.jkcredit.invoice.credit.interserver.CustomerInterLowerService;
- import com.jkcredit.invoice.credit.interserver.NoCarInterService;
- import com.jkcredit.invoice.credit.interserver.SelfCarInterService;
- import com.jkcredit.invoice.util.StringUtil;
- import lombok.extern.slf4j.Slf4j;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- /**
- * 接口过滤器
- * @author mumuxigua
- */
- @Service("interfaceCheckServer")
- @Slf4j
- public class InterfaceCheckServer {
- @Autowired
- CustomerInterLowerService customerInterLowerService;
- @Autowired
- SelfCarInterService selfCarInterService;
- @Autowired
- NoCarInterService noCarInterService;
- @Autowired
- StatisRequestIdTimeComp statisRequestIdTimeComp;
- /**
- * 跳转到对应的Service服务处理逻辑
- * @param appKey
- * @param api
- * @param data
- * @param requestid
- * @return
- */
- public DataResult doJumpHandler(String appKey, String api, String data, String requestid) {
- log.info("[-InterfaceCheckServer.doJumpHandler-] request appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid);
- long startTime = System.currentTimeMillis();
- DataResult resultTimeOut = new DataResult();
- resultTimeOut.setData(3);
- resultTimeOut.setCode(200);
- resultTimeOut.setRequestid(requestid);
- resultTimeOut.setMsg("网络异常");
- DataResult result;
- result = getDataResult(appKey, api, data, requestid, resultTimeOut);
- log.info("[-InterfaceCheckServer.doJumpHandler-] result appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + " ,result=" + result + " ,costTime=" + (System.currentTimeMillis() - startTime));
- return result;
- }
- private DataResult getDataResult(String appKey, String api, String data, String requestid, DataResult resultTimeOut) {
- DataResult result;
- switch (api) {
- //----------------------------自有车、无车公共接口---------------------------------//
- //无车、自有车企业注册
- case "COMPANY_ADD_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = customerInterLowerService.customeInterRec(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车、自有车协议上传
- case "PROTOCOL_ADD_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = customerInterLowerService.customeProtocolUpLoad(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车、自有车企业查询
- case "COMPANY_QUERY_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = customerInterLowerService.customeInterRecQuery(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 无车、协议上传状态查询
- case "PROTOCOL_STATUS_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = customerInterLowerService.customeProtocolStatus(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //----------------------------自有车下游接口---------------------------------//
- //自有车 用户卡列表查询
- case "CARD_BIND_QUERY_LIST_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.customeretcquery(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 卡信息查询
- case "CARD_QUERY_CARD_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.customerQueryEtcInfo(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 下发短信验证码
- case "CARD_BINDING_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.customeretcrec(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 卡绑定接口 渠道调用此接口,上传用户收到的短信验证码
- case "CARD_VALID_CODE_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.customeretcrecvalid(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 交易查询接口 渠道通过此接口可以查询单张卡连续90天内的交易(待开票、开票中、已开票)
- case "CARD_TRADE_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.getTradeList(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 申请开票接口 渠道通过此接口可以对该公司绑定的单张卡连续90天内的交易进行开票。
- case "B2B_INVOICE_APPLY_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.applInvoice(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 已开发票查询接口 渠道通过此接口可以根据该公司绑定的单张卡查询此卡在某个月开具的发票。
- case "B2B_INVOICE_QUERY_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.getSelfCarInvoicesByTime(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 已开发票查询接口 根据开票id进行查询。
- case "B2B_INVOICE_APPL_QUERY_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.getSelfCarInvoicesByAppl(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 发票下载 渠道通过此接口可以下载某公司某个月份开具的发票。
- case "B2B_INVOICE_PACKAGE_V1":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = selfCarInterService.getSelfCarInvoicePackage(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //自有车 卡解绑接口。
- case "CARD_UNBIND_V1":
- result = selfCarInterService.customerCarUnRec(appKey, api, data, requestid);
- break;
- //自有车 用户卡换绑。
- case "B2B_CHANGE_CARD_V1":
- result = selfCarInterService.customerCardChange(appKey, api, data, requestid);
- break;
- //自有车 用户卡换绑查询。
- case "B2B_CHANGE_CARD_QUERY_V1":
- result = selfCarInterService.customerCardChangeQuery(appKey, api, data, requestid);
- break;
- //自有车 按交易查申请。
- case "B2B_QUERY_TRADE_APPLY_V1":
- result = selfCarInterService.tradeApplyQuery(appKey, api, data, requestid);
- break;
- //----------------------------无车下游接口---------------------------------//
- //无车 车辆备案接口
- case "VEHICLE_REGISTER":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.customerCarRec(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 车辆备案查询接口
- case "VEHICLE_REGISTER_QUERY":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.customeRecUpperQuery(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 实时运单开始指令
- case "WAY_BILL_START":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.noCarBillStart(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 实时运单结束指令
- case "WAY_BILL_END":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.noCarBillEnd(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 历史运单开始指令
- case "WAY_BILL_HISTORY_START":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.noCarHisWaybillStart(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 历史运单结束指令
- case "WAY_BILL_HISTORY_END":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + StringUtil.removeJSonField(data,"base64Str") + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.noCarHisWaybillEnd(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 运单号查询发票数据
- case "WAY_BILL_NUM_FIND_INVOICE":
- result = noCarInterService.noCarVoiceQuery(appKey, api, data, requestid);
- break;
- //无车 获取未查询过发票的运单编号
- case "FIND_NO_SEARCH_NUM":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.noCarNoVoiceQuery(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 账号余额查询接口
- case "BALANCE_QUERY":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.balanceQuery(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 红冲发票查询接口
- case "RED_INK_INVOICE_QUERY":
- if (StatisRequestIdTimeComp.isLimit) {
- log.info("InterfaceCheckServer.doJumpHandler,appKey=" + appKey + " ,api=" + api + " ,data=" + data + " ,requestid=" + requestid + "=被拒绝");
- result = resultTimeOut;
- } else {
- statisRequestIdTimeComp.putReQuestIdAndTime(requestid);
- result = noCarInterService.redInkInvoiceQuery(appKey, api, data, requestid);
- statisRequestIdTimeComp.removeReQuestIdAndTime(requestid);
- }
- break;
- //无车 运单号查询发票数据 透传上游
- case "WAY_BILL_NUM_FIND_OWNER_INVOICE":
- result = noCarInterService.noCarVoiceOwnerQuery(appKey, api, data, requestid);
- break;
- default:
- result = null;
- break;
- }
- return result;
- }
- }
|