Browse Source

代码规范调整-120220116

mashengyi 2 years ago
parent
commit
74de197083

+ 6 - 6
src/main/java/com/jkcredit/invoice/controller/business/SelfCarController.java

@@ -25,8 +25,8 @@ import com.jkcredit.invoice.service.lowerservice.CheckHasAuthRole;
 import com.jkcredit.invoice.service.lowerservice.SelfCarCustService;
 import com.jkcredit.invoice.service.lowerservice.vo.*;
 import com.jkcredit.invoice.service.selfcar.SelfCarApplyService;
+import com.jkcredit.invoice.service.selfcar.SelfCarBussService;
 import com.jkcredit.invoice.service.selfcar.SelfCarInvoiceService;
-import com.jkcredit.invoice.service.selfcar.SelfCarService;
 import com.jkcredit.invoice.service.selfcar.SelfCarTradeService;
 import com.jkcredit.invoice.util.RespR;
 import io.swagger.annotations.Api;
@@ -58,7 +58,7 @@ public class SelfCarController {
     @Autowired
     SelfCarCustService selfCarCustService;
     @Autowired
-    SelfCarService selfCarService;
+    SelfCarBussService selfCarBussService;
     @Autowired
     SelfCarCustService selfCarCustServicel;
     @Autowired
@@ -91,7 +91,7 @@ public class SelfCarController {
     @LoginRequired(role = AuthenticationInterceptor.AUTH_ADMIN)
     public RespR selfCarUnBind(String etcNum) {
         try {
-            RespR respR = selfCarService.selfCarUnBind(etcNum);
+            RespR respR = selfCarBussService.selfCarUnBind(etcNum);
             return respR;
         } catch (Exception e) {
             e.printStackTrace();
@@ -152,7 +152,7 @@ public class SelfCarController {
             //0 接口
             tradeRequestVo.setInterType(1);
             if (StringUtils.isEmpty(selfCarTrade.getCardId())) {
-                List<CustomerCarRec> customerCarRecs = selfCarService.getEtcsByCompany(selfCarTrade.getCompanyName());
+                List<CustomerCarRec> customerCarRecs = selfCarBussService.getEtcsByCompany(selfCarTrade.getCompanyName());
                 if (customerCarRecs != null && customerCarRecs.size() > 0) {
                     for (CustomerCarRec customerCarRec : customerCarRecs) {
                         tradeRequestVo.setEtcId(customerCarRec.getEtcNum());
@@ -380,7 +380,7 @@ public class SelfCarController {
     public RespR getTradeList(@RequestBody TradeRequestCarNumVo tradeRequestCarNumVo, User user) {
         checkHasAuthRole.checkCompanyRole(user, tradeRequestCarNumVo.getCompanyName());
         //通过车牌号查询所有的Etc卡号
-        List<CustomerCarRec> customerCarRecs = selfCarService.getEtcsByCarNum(tradeRequestCarNumVo.getCarNum());
+        List<CustomerCarRec> customerCarRecs = selfCarBussService.getEtcsByCarNum(tradeRequestCarNumVo.getCarNum());
         if (customerCarRecs == null || customerCarRecs.size() <= 0) {
             return new RespR(false, "请输入有绑定ETC卡号的车牌");
         }
@@ -464,7 +464,7 @@ public class SelfCarController {
             //通过车牌号查询所有的Etc卡号
             List<CustomerCarRec> customerCarRecs = null;
             if (selfcarInvoiceByTimeVo.getCarNum() != null && selfcarInvoiceByTimeVo.getCarNum() != "") {
-                customerCarRecs = selfCarService.getEtcsByCarNum(selfcarInvoiceByTimeVo.getCarNum());
+                customerCarRecs = selfCarBussService.getEtcsByCarNum(selfcarInvoiceByTimeVo.getCarNum());
             } else {
                 customerCarRecs = customerCarRecMapper.selectAllEtcByCompany(selfcarInvoiceByTimeVo.getCompanyName());
             }

+ 105 - 140
src/main/java/com/jkcredit/invoice/credit/interserver/NoCarInterServiceImpl.java

@@ -166,22 +166,7 @@ public class NoCarInterServiceImpl implements NoCarInterService {
 
             customerCarRecList.add(customerCarRec);
 
-            RespR rs = noCarService.customerCarRec(customerCarRecList);
-            long costtimeend = System.currentTimeMillis();
-            log.info("[-NoCarInterServiceImpl.customerCarRec-] result is "
-                    + rs.toString() + ", request is " + data + " ,costtime="
-                    + (costtimeend - costtimestart));
-            if (null != rs && rs.getCode() == 0) {
-                result.setData(1);
-                result.setCode(200);
-                result.setMsg(rs.getData().toString());
-                return result;
-            } else {
-                result.setData(3);
-                result.setCode(200);
-                result.setMsg(rs.getMsg());
-                return result;
-            }
+            return getDataResultss(data, costtimestart, result, noCarService.customerCarRec(customerCarRecList), "[-NoCarInterServiceImpl.customerCarRec-] result is ");
         } catch (Exception e) {
             log.error("[-NoCarInterServiceImpl.customerCarRec-] get httpclient exception is "
                     + e + ", request is " + data);
@@ -340,37 +325,8 @@ public class NoCarInterServiceImpl implements NoCarInterService {
                 result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
                 return result;
             }
-            NoCarWayBill noCarWayBill = new NoCarWayBill();
-            noCarWayBill.setCustomerName(appKey);
-            noCarWayBill.setCompanyName(customerRec.getCompanyName());
-            noCarWayBill.setPlateNum(plateNumber);
-            noCarWayBill.setBillNum(num);
-            noCarWayBill.setPlateColor(plateColor);
-            noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
-            noCarWayBill.setSourceAddr(sourceAddr);
-            noCarWayBill.setDestAddr(destAddr);
-            noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
-            noCarWayBill.setFee(fee.longValue());
-            noCarWayBill.setTitleType(titleType);
-            noCarWayBill.setTaxplayerCode(taxplayerCode);
-            noCarWayBill.setHisFlag(0);
-            noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
-            List<CustomerCarRec> customerCarRecs = new ArrayList<>();
-            CustomerCarRec customerCarRec = new CustomerCarRec();
-            customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
-            customerCarRec.setCarNum(noCarWayBill.getPlateNum());
-            customerCarRec.setCarColor(noCarWayBill.getPlateColor());
-            customerCarRec.setCustomerName(appKey);
-            //接口
-            customerCarRec.setInterType(0);
-            customerCarRec.setCompanyNum(customerRec.getCompanyNum());
-            customerCarRec.setBusinessType("2");
-            //默认运营车辆
-            customerCarRec.setServiceOperation(1);
-            noCarWayBill.setTitleType(2);
-            //接口
-            noCarWayBill.setInterType(0);
-            return getDataResult(data, costtimestart, result, noCarWayBill, customerCarRecs, customerCarRec);
+            NoCarWayBill noCarWayBill = getNoCarWayBill(appKey, num, plateNumber, plateColor, startTime, sourceAddr, destAddr, predictEndTime, fee, titleType, taxplayerCode, customerRec);
+            return getDataResult(appKey, data, costtimestart, result, customerRec, noCarWayBill);
         } catch (Exception e) {
             log.error("[-NoCarInterServiceImpl.noCarBillStart-] get httpclient exception is "
                     + e + ", request is " + data);
@@ -378,6 +334,44 @@ public class NoCarInterServiceImpl implements NoCarInterService {
         return result;
     }
 
+    private DataResult getDataResult(String appKey, String data, long costtimestart, DataResult result, CustomerRec customerRec, NoCarWayBill noCarWayBill) {
+        List<CustomerCarRec> customerCarRecs = new ArrayList<>();
+        CustomerCarRec customerCarRec = new CustomerCarRec();
+        customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
+        customerCarRec.setCarNum(noCarWayBill.getPlateNum());
+        customerCarRec.setCarColor(noCarWayBill.getPlateColor());
+        customerCarRec.setCustomerName(appKey);
+        //接口
+        customerCarRec.setInterType(0);
+        customerCarRec.setCompanyNum(customerRec.getCompanyNum());
+        customerCarRec.setBusinessType("2");
+        //默认运营车辆
+        customerCarRec.setServiceOperation(1);
+        noCarWayBill.setTitleType(2);
+        //接口
+        noCarWayBill.setInterType(0);
+        return getDataResult(data, costtimestart, result, noCarWayBill, customerCarRecs, customerCarRec);
+    }
+
+    private NoCarWayBill getNoCarWayBill(String appKey, String num, String plateNumber, String plateColor, String startTime, String sourceAddr, String destAddr, String predictEndTime, Integer fee, Integer titleType, String taxplayerCode, CustomerRec customerRec) {
+        NoCarWayBill noCarWayBill = new NoCarWayBill();
+        noCarWayBill.setCustomerName(appKey);
+        noCarWayBill.setCompanyName(customerRec.getCompanyName());
+        noCarWayBill.setPlateNum(plateNumber);
+        noCarWayBill.setBillNum(num);
+        noCarWayBill.setPlateColor(plateColor);
+        noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
+        noCarWayBill.setSourceAddr(sourceAddr);
+        noCarWayBill.setDestAddr(destAddr);
+        noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
+        noCarWayBill.setFee(fee.longValue());
+        noCarWayBill.setTitleType(titleType);
+        noCarWayBill.setTaxplayerCode(taxplayerCode);
+        noCarWayBill.setHisFlag(0);
+        noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
+        return noCarWayBill;
+    }
+
     private DataResult getDataResult(String data, long costtimestart, DataResult result, NoCarWayBill noCarWayBill, List<CustomerCarRec> customerCarRecs, CustomerCarRec customerCarRec) {
         //先查询上游是否已经备案
         RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
@@ -392,22 +386,7 @@ public class NoCarInterServiceImpl implements NoCarInterService {
                 return result;
             }
         }
-        RespR rs = noCarService.noCarWaybillStart(noCarWayBill);
-        long costtimeend = System.currentTimeMillis();
-        log.info("[-NoCarInterServiceImpl.noCarBillStart-] result is "
-                + rs.toString() + ", request is " + data + " ,costtime="
-                + (costtimeend - costtimestart));
-        if (null != rs && rs.getCode() == 0) {
-            result.setData(1);
-            result.setCode(200);
-            result.setMsg(rs.getData().toString());
-            return result;
-        } else {
-            result.setData(3);
-            result.setCode(200);
-            result.setMsg(rs.getMsg());
-            return result;
-        }
+        return getDataResultss(data, costtimestart, result, noCarService.noCarWaybillStart(noCarWayBill), "[-NoCarInterServiceImpl.noCarBillStart-] result is ");
     }
 
     /**
@@ -462,22 +441,7 @@ public class NoCarInterServiceImpl implements NoCarInterService {
             noCarWayBill.setHisFlag(0);
             //接口
             noCarWayBill.setInterType(0);
-            RespR rs = noCarService.noCarWaybillEnd(noCarWayBill);
-            long costtimeend = System.currentTimeMillis();
-            log.info("[-NoCarInterServiceImpl.noCarBillEnd-] result is "
-                    + rs.toString() + ", request is " + data + " ,costtime="
-                    + (costtimeend - costtimestart));
-            if (null != rs && rs.getCode() == 0) {
-                result.setData(1);
-                result.setCode(200);
-                result.setMsg(rs.getData().toString());
-                return result;
-            } else {
-                result.setData(3);
-                result.setCode(200);
-                result.setMsg(rs.getMsg());
-                return result;
-            }
+            return getDataResultss(data, costtimestart, result, noCarService.noCarWaybillEnd(noCarWayBill), "[-NoCarInterServiceImpl.noCarBillEnd-] result is ");
         } catch (Exception e) {
             log.error("[-NoCarInterServiceImpl.noCarBillEnd-] get httpclient exception is "
                     + e + ", request is " + data);
@@ -555,24 +519,7 @@ public class NoCarInterServiceImpl implements NoCarInterService {
                 result.setMsg("客户:" + appKey + ";税号" + taxplayerCode + "未在平台备案成功,请先做备案");
                 return result;
             }
-            NoCarWayBill noCarWayBill = new NoCarWayBill();
-            noCarWayBill.setCustomerName(appKey);
-            noCarWayBill.setCompanyName(customerRec.getCompanyName());
-            noCarWayBill.setPlateNum(plateNumber);
-            noCarWayBill.setBillNum(num);
-            noCarWayBill.setPlateColor(plateColor);
-            noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
-            noCarWayBill.setSourceAddr(sourceAddr);
-            noCarWayBill.setDestAddr(destAddr);
-            noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
-            noCarWayBill.setFee(fee.longValue());
-            noCarWayBill.setTitleType(titleType);
-            noCarWayBill.setTaxplayerCode(taxplayerCode);
-            noCarWayBill.setHisFlag(1);
-            noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
-            noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
-            //接口
-            noCarWayBill.setInterType(0);
+            NoCarWayBill noCarWayBill = getNoCarWayBills(appKey, num, plateNumber, plateColor, startTime, sourceAddr, destAddr, predictEndTime, fee, titleType, taxplayerCode, customerRec);
             List<CustomerCarRec> customerCarRecs = new ArrayList<>();
             CustomerCarRec customerCarRec = new CustomerCarRec();
             customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
@@ -585,35 +532,10 @@ public class NoCarInterServiceImpl implements NoCarInterService {
             //默认运营车辆
             customerCarRec.setServiceOperation(1);
             noCarWayBill.setTitleType(2);
-            //先查询上游是否已经备案
-            RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
-            if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
-                customerCarRecs.add(customerCarRec);
-                RespR respR = noCarService.customerCarRec(customerCarRecs);
-                if (respR.getCode() == 1) {
-                    result.setMsg("车牌号备案失败,失败原因:" + respR.getMsg());
-                    noCarWayBill.setFailReason(respR.getMsg());
-                    noCarWayBill.setBillwayStatus(-2);
-                    insertOrUpdateBillStart(noCarWayBill);
-                    return result;
-                }
-            }
-            RespR rs = noCarService.noCarHisWaybillStart(noCarWayBill);
-            long costtimeend = System.currentTimeMillis();
-            log.info("[-NoCarInterServiceImpl.noCarHisWaybillStart-] result is "
-                    + rs.toString() + ", request is " + data + " ,costtime="
-                    + (costtimeend - costtimestart));
-            if (null != rs && rs.getCode() == 0) {
-                result.setData(1);
-                result.setCode(200);
-                result.setMsg(rs.getData().toString());
-                return result;
-            } else {
-                result.setData(3);
-                result.setCode(200);
-                result.setMsg(rs.getMsg());
+            if (checkCustomerCarRecQueryResult(result, noCarWayBill, customerCarRecs, customerCarRec)) {
                 return result;
             }
+            return getDataResultss(data, costtimestart, result, noCarService.noCarHisWaybillStart(noCarWayBill), "[-NoCarInterServiceImpl.noCarHisWaybillStart-] result is ");
         } catch (Exception e) {
             log.error("[-NoCarInterServiceImpl.noCarHisWaybillStart-] get httpclient exception is "
                     + e + ", request is " + data);
@@ -621,6 +543,64 @@ public class NoCarInterServiceImpl implements NoCarInterService {
         return result;
     }
 
+    private DataResult getDataResultss(String data, long costtimestart, DataResult result, RespR respR, String s) {
+        RespR rs = respR;
+        long costtimeend = System.currentTimeMillis();
+        log.info(s
+                + rs.toString() + ", request is " + data + " ,costtime="
+                + (costtimeend - costtimestart));
+        if (null != rs && rs.getCode() == 0) {
+            result.setData(1);
+            result.setCode(200);
+            result.setMsg(rs.getData().toString());
+            return result;
+        } else {
+            result.setData(3);
+            result.setCode(200);
+            result.setMsg(rs.getMsg());
+            return result;
+        }
+    }
+
+    private boolean checkCustomerCarRecQueryResult(DataResult result, NoCarWayBill noCarWayBill, List<CustomerCarRec> customerCarRecs, CustomerCarRec customerCarRec) {
+        //先查询上游是否已经备案
+        RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
+        if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
+            customerCarRecs.add(customerCarRec);
+            RespR respR = noCarService.customerCarRec(customerCarRecs);
+            if (respR.getCode() == 1) {
+                result.setMsg("车牌号备案失败,失败原因:" + respR.getMsg());
+                noCarWayBill.setFailReason(respR.getMsg());
+                noCarWayBill.setBillwayStatus(-2);
+                insertOrUpdateBillStart(noCarWayBill);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private NoCarWayBill getNoCarWayBills(String appKey, String num, String plateNumber, String plateColor, String startTime, String sourceAddr, String destAddr, String predictEndTime, Integer fee, Integer titleType, String taxplayerCode, CustomerRec customerRec) {
+        NoCarWayBill noCarWayBill = new NoCarWayBill();
+        noCarWayBill.setCustomerName(appKey);
+        noCarWayBill.setCompanyName(customerRec.getCompanyName());
+        noCarWayBill.setPlateNum(plateNumber);
+        noCarWayBill.setBillNum(num);
+        noCarWayBill.setPlateColor(plateColor);
+        noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime));
+        noCarWayBill.setSourceAddr(sourceAddr);
+        noCarWayBill.setDestAddr(destAddr);
+        noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime));
+        noCarWayBill.setFee(fee.longValue());
+        noCarWayBill.setTitleType(titleType);
+        noCarWayBill.setTaxplayerCode(taxplayerCode);
+        noCarWayBill.setHisFlag(1);
+        noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
+        noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
+        //接口
+        noCarWayBill.setInterType(0);
+        return noCarWayBill;
+    }
+
     /**
      * 插入或者更新运单
      * @param noCarWayBill
@@ -691,22 +671,7 @@ public class NoCarInterServiceImpl implements NoCarInterService {
             noCarWayBill.setCustomerName(appKey);
             //接口
             noCarWayBill.setInterType(0);
-            RespR rs = noCarService.noCarHisWaybillEnd(noCarWayBill);
-            long costtimeend = System.currentTimeMillis();
-            log.info("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] result is "
-                    + rs.toString() + ", request is " + data + " ,costtime="
-                    + (costtimeend - costtimestart));
-            if (null != rs && rs.getCode() == 0) {
-                result.setData(1);
-                result.setCode(200);
-                result.setMsg(rs.getData().toString());
-                return result;
-            } else {
-                result.setData(3);
-                result.setCode(200);
-                result.setMsg(rs.getMsg());
-                return result;
-            }
+            return getDataResultss(data, costtimestart, result, noCarService.noCarHisWaybillEnd(noCarWayBill), "[-NoCarInterServiceImpl.noCarHisWaybillEnd-] result is ");
         } catch (Exception e) {
             log.error("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] get httpclient exception is "
                     + e + ", request is " + data);

+ 73 - 61
src/main/java/com/jkcredit/invoice/credit/interserver/SelfCarInterServiceImpl.java

@@ -201,26 +201,7 @@ public class SelfCarInterServiceImpl implements SelfCarInterService {
                 cards.add(carVo);
             }
             etcQueryVo.setCards(cards);
-            RespR rs = selfCarService.queryEtcInfo(etcQueryVo);
-
-            long costtimeend = System.currentTimeMillis();
-            log.info("[-SelfCarInterServiceImpl.customerQueryEtcInfo-] result is "
-                    + rs.toString() + ", request is " + data + " ,costtime="
-                    + (costtimeend - costtimestart));
-            if (null != rs && rs.getCode() == 0) {
-                result.setData(1);
-                result.setCode(200);
-                result.setMsg(rs.getData().toString());
-                return result;
-            } else {
-                result.setData(3);
-                result.setCode(200);
-                result.setMsg(rs.getMsg());
-                if (NOT_FOUND.equals(rs.getMsg())) {
-                    result.setData(2);
-                }
-                return result;
-            }
+            return getDataResult(data, costtimestart, result, etcQueryVo);
         } catch (Exception e) {
             log.error("[-SelfCarInterServiceImpl.customerQueryEtcInfo-] get httpclient exception is "
                     + e + ", request is " + data);
@@ -228,6 +209,29 @@ public class SelfCarInterServiceImpl implements SelfCarInterService {
         return result;
     }
 
+    private DataResult getDataResult(String data, long costtimestart, DataResult result, EtcBindVo etcQueryVo) {
+        RespR rs = selfCarService.queryEtcInfo(etcQueryVo);
+
+        long costtimeend = System.currentTimeMillis();
+        log.info("[-SelfCarInterServiceImpl.customerQueryEtcInfo-] result is "
+                + rs.toString() + ", request is " + data + " ,costtime="
+                + (costtimeend - costtimestart));
+        if (null != rs && rs.getCode() == 0) {
+            result.setData(1);
+            result.setCode(200);
+            result.setMsg(rs.getData().toString());
+            return result;
+        } else {
+            result.setData(3);
+            result.setCode(200);
+            result.setMsg(rs.getMsg());
+            if (NOT_FOUND.equals(rs.getMsg())) {
+                result.setData(2);
+            }
+            return result;
+        }
+    }
+
 
     /**
      * 自有车下发短信通知接口
@@ -482,48 +486,9 @@ public class SelfCarInterServiceImpl implements SelfCarInterService {
             tradeRequestVo.setInterType(0);
 
             if (tradeRequestVo.getTradeStatus() == null) {
-                tradeRequestVo.setTradeStatus(1);
-                RespR<List<CardTradeModel>> respRbefore = selfCarService.getTradeList(tradeRequestVo);
-                tradeRequestVo.setTradeStatus(2);
-                RespR<List<CardTradeModel>> listRespR = selfCarService.getTradeList(tradeRequestVo);
-                tradeRequestVo.setTradeStatus(3);
-                RespR<List<CardTradeModel>> tradeList = selfCarService.getTradeList(tradeRequestVo);
-                //合并展示
-                List<CardTradeModel> cardTradeModels = new ArrayList<>();
-                if (respRbefore.getCode() == 0) {
-                    cardTradeModels.addAll(respRbefore.getData());
-                }
-                if (listRespR.getCode() == 0) {
-                    cardTradeModels.addAll(listRespR.getData());
-                }
-                if (tradeList.getCode() == 0) {
-                    cardTradeModels.addAll(tradeList.getData());
-                }
-
-                result.setData(1);
-                result.setCode(200);
-                result.setMsg(cardTradeModels.toString());
-                return result;
-            }
-            RespR rs = selfCarService.getTradeList(tradeRequestVo);
-            long costtimeend = System.currentTimeMillis();
-            log.info("[-SelfCarInterServiceImpl.getTradeList-] result is "
-                    + rs.toString() + ", request is " + data + " ,costtime="
-                    + (costtimeend - costtimestart));
-            if (null != rs && rs.getCode() == 0) {
-                result.setData(1);
-                result.setCode(200);
-                result.setMsg(rs.getData().toString());
-                return result;
-            } else {
-                result.setData(3);
-                if (NOT_FOUND.equals(rs.getMsg())) {
-                    result.setData(2);
-                }
-                result.setCode(200);
-                result.setMsg(rs.getMsg());
-                return result;
+                return getDataResult(result, tradeRequestVo);
             }
+            return getDataResult(data, costtimestart, result, tradeRequestVo);
         } catch (Exception e) {
             log.error("[-SelfCarInterServiceImpl.getTradeList-] get httpclient exception is "
                     + e + ", request is " + data);
@@ -531,6 +496,53 @@ public class SelfCarInterServiceImpl implements SelfCarInterService {
         return result;
     }
 
+    private DataResult getDataResult(DataResult result, TradeRequestVo tradeRequestVo) {
+        tradeRequestVo.setTradeStatus(1);
+        RespR<List<CardTradeModel>> respRbefore = selfCarService.getTradeList(tradeRequestVo);
+        tradeRequestVo.setTradeStatus(2);
+        RespR<List<CardTradeModel>> listRespR = selfCarService.getTradeList(tradeRequestVo);
+        tradeRequestVo.setTradeStatus(3);
+        RespR<List<CardTradeModel>> tradeList = selfCarService.getTradeList(tradeRequestVo);
+        //合并展示
+        List<CardTradeModel> cardTradeModels = new ArrayList<>();
+        if (respRbefore.getCode() == 0) {
+            cardTradeModels.addAll(respRbefore.getData());
+        }
+        if (listRespR.getCode() == 0) {
+            cardTradeModels.addAll(listRespR.getData());
+        }
+        if (tradeList.getCode() == 0) {
+            cardTradeModels.addAll(tradeList.getData());
+        }
+
+        result.setData(1);
+        result.setCode(200);
+        result.setMsg(cardTradeModels.toString());
+        return result;
+    }
+
+    private DataResult getDataResult(String data, long costtimestart, DataResult result, TradeRequestVo tradeRequestVo) {
+        RespR rs = selfCarService.getTradeList(tradeRequestVo);
+        long costtimeend = System.currentTimeMillis();
+        log.info("[-SelfCarInterServiceImpl.getTradeList-] result is "
+                + rs.toString() + ", request is " + data + " ,costtime="
+                + (costtimeend - costtimestart));
+        if (null != rs && rs.getCode() == 0) {
+            result.setData(1);
+            result.setCode(200);
+            result.setMsg(rs.getData().toString());
+            return result;
+        } else {
+            result.setData(3);
+            if (NOT_FOUND.equals(rs.getMsg())) {
+                result.setData(2);
+            }
+            result.setCode(200);
+            result.setMsg(rs.getMsg());
+            return result;
+        }
+    }
+
 
     /**
      * 自有车 交易查询接口 渠道通过此接口可以查询单张卡连续90天内的交易(待开票、开票中、已开票)

+ 52 - 48
src/main/java/com/jkcredit/invoice/service/lowerservice/impl/SelfCarCustServiceImpl.java

@@ -181,58 +181,62 @@ public class SelfCarCustServiceImpl implements SelfCarCustService {
             log.info("申请开票失败SelfCarServiceLImpl.applInvoice{},msg{}", invoiceApplVo, respR.getMsg());
             return new RespR(false, respR.getMsg());
         } else {
-            B2BInvoiceApplyResponse data = respR.getData();
-            SelfCarAppl selfCarAppl = new SelfCarAppl();
-            selfCarAppl.setApplId(data.getApplyId());
-            selfCarAppl.setApplTime(data.getReceiveTime());
-            selfCarAppl.setCompanyNum(b2bInvoiceApplyRequest.getCompanyNum());
-            selfCarAppl.setCustomId(customer.getCustomerName());
-            selfCarAppl.setCardId(invoiceApplVo.getCardId());
-            selfCarAppl.setInvoiceAmount(data.getInvoiceAmount());
-            selfCarAppl.setInvoiceCount(data.getInvoiceCount());
-            selfCarAppl.setInvoiceTaxAmount(data.getInvoiceTaxAmount());
-            selfCarAppl.setInterType(invoiceApplVo.getInterType());
-            selfCarApplMapper.insert(selfCarAppl);
-            double needFee = 0;
-            //更新交易id申请开票时间,并将转态改为开票中
-            for (String tradeId : tradeIds) {
-                List<SelfCarTrade> selfCarTrades = sellCarTradeMapper.selectByTradeId(tradeId);
-                if (selfCarTrades == null || selfCarTrades.size() == 0) {
-                    continue;
-                }
-                SelfCarTrade selfCarTrade = selfCarTrades.get(0);
-                selfCarTrade.setStatus(2);
-                selfCarTrade.setAclTime(DateUtil.getCurrentDateStr());
-                selfCarTrade.setApplId(data.getApplyId());
-                selfCarTrade.setInterType(invoiceApplVo.getInterType());
-                sellCarTradeMapper.updateByTradeId(selfCarTrade);
-                //计费
-                SelfCarCalculateInfor carCalculateInfor = new SelfCarCalculateInfor();
-                carCalculateInfor.setCustomId(customerRec.getCustomerName());
-                carCalculateInfor.setCompanyNum(customerRec.getCompanyNum());
-                //公司名称
-                carCalculateInfor.setCompanyName(customerRec.getCompanyName());
-                //主体名称
-                carCalculateInfor.setCompanyLongName(customerRec.getCompanyBelongName());
-                carCalculateInfor.setCalTime(StringUtils.substring(selfCarTrade.getExTime(), 0, 7));
-                carCalculateInfor.setFee(customer.getFee());
-                carCalculateInfor.setCompanyReferencenum(customerRec.getCompanyReferencenum());
-                carCalculateInfor.setEtcNum(selfCarTrade.getCardId());
-                if (calculateInforMapper.selectByEtcAndTime(carCalculateInfor) == null) {
-                    needFee = MathUtil.add(needFee, carCalculateInfor.getFee());
-                    calculateInforMapper.insert(carCalculateInfor);
-                }
-            }
-            customer = customerMapper.selectByCustomerNameForLock(invoiceApplVo.getCustomerName());
-            //客户统一扣费
-            customer.setInvoiceTime(DateUtil.getCurrentDateStr());
-            customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(), needFee));
-            customerMapper.updateByPrimaryKeySelective(customer);
-            return new RespR(respR.getData());
+            return getStringRespR(invoiceApplVo, customer, customerRec, b2bInvoiceApplyRequest, tradeIds, respR);
         }
 
     }
 
+    private RespR<String> getStringRespR(InvoiceApplVo invoiceApplVo, Customer customer, CustomerRec customerRec, B2BInvoiceApplyRequest b2bInvoiceApplyRequest, List<String> tradeIds, RespR<B2BInvoiceApplyResponse> respR) {
+        B2BInvoiceApplyResponse data = respR.getData();
+        SelfCarAppl selfCarAppl = new SelfCarAppl();
+        selfCarAppl.setApplId(data.getApplyId());
+        selfCarAppl.setApplTime(data.getReceiveTime());
+        selfCarAppl.setCompanyNum(b2bInvoiceApplyRequest.getCompanyNum());
+        selfCarAppl.setCustomId(customer.getCustomerName());
+        selfCarAppl.setCardId(invoiceApplVo.getCardId());
+        selfCarAppl.setInvoiceAmount(data.getInvoiceAmount());
+        selfCarAppl.setInvoiceCount(data.getInvoiceCount());
+        selfCarAppl.setInvoiceTaxAmount(data.getInvoiceTaxAmount());
+        selfCarAppl.setInterType(invoiceApplVo.getInterType());
+        selfCarApplMapper.insert(selfCarAppl);
+        double needFee = 0;
+        //更新交易id申请开票时间,并将转态改为开票中
+        for (String tradeId : tradeIds) {
+            List<SelfCarTrade> selfCarTrades = sellCarTradeMapper.selectByTradeId(tradeId);
+            if (selfCarTrades == null || selfCarTrades.size() == 0) {
+                continue;
+            }
+            SelfCarTrade selfCarTrade = selfCarTrades.get(0);
+            selfCarTrade.setStatus(2);
+            selfCarTrade.setAclTime(DateUtil.getCurrentDateStr());
+            selfCarTrade.setApplId(data.getApplyId());
+            selfCarTrade.setInterType(invoiceApplVo.getInterType());
+            sellCarTradeMapper.updateByTradeId(selfCarTrade);
+            //计费
+            SelfCarCalculateInfor carCalculateInfor = new SelfCarCalculateInfor();
+            carCalculateInfor.setCustomId(customerRec.getCustomerName());
+            carCalculateInfor.setCompanyNum(customerRec.getCompanyNum());
+            //公司名称
+            carCalculateInfor.setCompanyName(customerRec.getCompanyName());
+            //主体名称
+            carCalculateInfor.setCompanyLongName(customerRec.getCompanyBelongName());
+            carCalculateInfor.setCalTime(StringUtils.substring(selfCarTrade.getExTime(), 0, 7));
+            carCalculateInfor.setFee(customer.getFee());
+            carCalculateInfor.setCompanyReferencenum(customerRec.getCompanyReferencenum());
+            carCalculateInfor.setEtcNum(selfCarTrade.getCardId());
+            if (calculateInforMapper.selectByEtcAndTime(carCalculateInfor) == null) {
+                needFee = MathUtil.add(needFee, carCalculateInfor.getFee());
+                calculateInforMapper.insert(carCalculateInfor);
+            }
+        }
+        customer = customerMapper.selectByCustomerNameForLock(invoiceApplVo.getCustomerName());
+        //客户统一扣费
+        customer.setInvoiceTime(DateUtil.getCurrentDateStr());
+        customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(), needFee));
+        customerMapper.updateByPrimaryKeySelective(customer);
+        return new RespR(respR.getData());
+    }
+
     @Override
     public RespR<List<B2BInvoiceQueryByApplyModel>> getSelfCarInvoicesByApplyIds(ApplQueryInvVo applQueryInvVo) {
         log.info("申请开票开始SelfCarServiceLImpl.getSelfCarInvoicesByApplyIds{}", applQueryInvVo);

+ 63 - 54
src/main/java/com/jkcredit/invoice/service/nocar/impl/NoCarBillWayServiceImpl.java

@@ -203,61 +203,12 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
                     noCarWayBill.setHisFlag(1);
                     noCarWayBill.setCustomerName(customerName);
                     noCarWaybillMapperImprt.insertImport(noCarWayBill);
-                    if (customerRec == null || customerRec.getRecStatus() != 1) {
-                        stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
-                        noCarWaybillMapperImprt.updateBillway(-2, "企业税号未备案#", noCarWayBill);
-                        noCarWayBill.setBillwayStatus(-2);
-                        noCarWayBill.setFailReason("企业税号未备案");
-                        insertOrUpdateBillStart(noCarWayBill);
+                    if (checkBatchHsitoryBillWay(stringBuffer, noCarWayBill, customerRec)) {
                         return;
                     }
-                    noCarWayBill.setCompanyName(customerRec.getCompanyName());
-                    noCarWayBill.setCompanyNum(customerRec.getCompanyNum());
-                    if (DateUtil.getDistanceDays(noCarWayBill.getStartTime(), new Date()) > INTTOW) {
-                        log.info("历史运单开始上传失败:NoCarServiceImpl.noCarHisWaybillStart{},msg{}", noCarWayBill, "必须是二十天前的运单");
-                        noCarWayBill.setBillwayStatus(-2);
-                        noCarWayBill.setFailReason("失败,运单未满20天时效");
-                        noCarWaybillMapperImprt.updateBillway(-2, "失败,运单未满20天时效#", noCarWayBill);
-                        insertOrUpdateBillStart(noCarWayBill);
-                        return;
-                    }
-                    if (DateUtil.getDistanceHours(noCarWayBill.getStartTime(), DateUtil.stringToDate(noCarWayBill.getPredictEndTime())) < INTTHREE) {
-                        noCarWayBill.setBillwayStatus(-2);
-                        noCarWayBill.setFailReason("运单已经超时,请拆分");
-                        insertOrUpdateBillStart(noCarWayBill);
-                        noCarWaybillMapperImprt.updateBillway(-2, "运单已经超时,请拆分#", noCarWayBill);
-                        log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}", noCarWayBill, "运单已经超时,请拆分");
+                    if (checkCustomerCarRec(customerName, stringBuffer, noCarWayBill, customerRec)) {
                         return;
                     }
-                    //1.查询是否有车辆备案 /
-                    CustomerCarRec customerCarRec;
-
-                    //2.无车车辆备案时进行车辆备案
-                    List<CustomerCarRec> customerCarRecs = new ArrayList<>();
-                    customerCarRec = new CustomerCarRec();
-                    customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
-                    customerCarRec.setCarNum(noCarWayBill.getPlateNum());
-                    customerCarRec.setCarColor(noCarWayBill.getPlateColor());
-                    customerCarRec.setCompanyNum(customerRec.getCompanyNum());
-                    customerCarRec.setCustomerName(customerName);
-                    customerCarRec.setBusinessType("2");
-                    customerCarRec.setServiceOperation(1);//默认运营车辆
-                    //先查询上游是否已经备案
-                    RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
-                    if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
-                        customerCarRecs.add(customerCarRec);
-                        RespR respR = noCarService.customerCarRec(customerCarRecs);
-                        if (respR.getCode() == 1) {
-                            noCarWaybillMapperImprt.updateBillway(-2, respR.getMsg(), noCarWayBill);
-                            stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
-                            noCarWayBill.setBillwayStatus(-2);
-                            noCarWayBill.setFailReason(respR.getMsg());
-                            insertOrUpdateBillStart(noCarWayBill);
-                            return;
-                        }
-                    }
-
-
                     //3.kais指令上传
                     NoCarWayBill noCarWayBillClo = null;
                     try {
@@ -266,7 +217,6 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
                         e.printStackTrace();
                         noCarWayBillClo = noCarWayBill;
                     }
-
                     RespR respR = noCarService.noCarHisWaybillStart(noCarWayBill);
                     if (respR.getCode() == 1) {
                         stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
@@ -293,8 +243,6 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
                 } catch (Exception e) {
                     e.printStackTrace();
                 }
-
-
             });
             if (!StringUtils.isEmpty(stringBuffer.toString())) {
                 log.error(stringBuffer.toString());
@@ -303,6 +251,67 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper, NoC
         return new RespR("批次号:" + batchNumber);
     }
 
+    private boolean checkCustomerCarRec(String customerName, StringBuffer stringBuffer, NoCarWayBill noCarWayBill, CustomerRec customerRec) {
+        //1.查询是否有车辆备案 /
+        CustomerCarRec customerCarRec;
+        //2.无车车辆备案时进行车辆备案
+        List<CustomerCarRec> customerCarRecs = new ArrayList<>();
+        customerCarRec = new CustomerCarRec();
+        customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
+        customerCarRec.setCarNum(noCarWayBill.getPlateNum());
+        customerCarRec.setCarColor(noCarWayBill.getPlateColor());
+        customerCarRec.setCompanyNum(customerRec.getCompanyNum());
+        customerCarRec.setCustomerName(customerName);
+        customerCarRec.setBusinessType("2");
+        //默认运营车辆
+        customerCarRec.setServiceOperation(1);
+        //先查询上游是否已经备案
+        RespR<VehicleQueryResponse> respRquery = noCarService.customerCarRecQueryUpper(customerCarRec);
+        if (respRquery.getCode() == 1 || respRquery.getData() == null || respRquery.getData().getResult() == null || respRquery.getData().getResult().size() <= 0) {
+            customerCarRecs.add(customerCarRec);
+            RespR respR = noCarService.customerCarRec(customerCarRecs);
+            if (respR.getCode() == 1) {
+                noCarWaybillMapperImprt.updateBillway(-2, respR.getMsg(), noCarWayBill);
+                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+                noCarWayBill.setBillwayStatus(-2);
+                noCarWayBill.setFailReason(respR.getMsg());
+                insertOrUpdateBillStart(noCarWayBill);
+                return true;
+            }
+        }
+        return false;
+    }
+
+    private boolean checkBatchHsitoryBillWay(StringBuffer stringBuffer, NoCarWayBill noCarWayBill, CustomerRec customerRec) {
+        if (customerRec == null || customerRec.getRecStatus() != 1) {
+            stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
+            noCarWaybillMapperImprt.updateBillway(-2, "企业税号未备案#", noCarWayBill);
+            noCarWayBill.setBillwayStatus(-2);
+            noCarWayBill.setFailReason("企业税号未备案");
+            insertOrUpdateBillStart(noCarWayBill);
+            return true;
+        }
+        noCarWayBill.setCompanyName(customerRec.getCompanyName());
+        noCarWayBill.setCompanyNum(customerRec.getCompanyNum());
+        if (DateUtil.getDistanceDays(noCarWayBill.getStartTime(), new Date()) > INTTOW) {
+            log.info("历史运单开始上传失败:NoCarServiceImpl.noCarHisWaybillStart{},msg{}", noCarWayBill, "必须是二十天前的运单");
+            noCarWayBill.setBillwayStatus(-2);
+            noCarWayBill.setFailReason("失败,运单未满20天时效");
+            noCarWaybillMapperImprt.updateBillway(-2, "失败,运单未满20天时效#", noCarWayBill);
+            insertOrUpdateBillStart(noCarWayBill);
+            return true;
+        }
+        if (DateUtil.getDistanceHours(noCarWayBill.getStartTime(), DateUtil.stringToDate(noCarWayBill.getPredictEndTime())) < INTTHREE) {
+            noCarWayBill.setBillwayStatus(-2);
+            noCarWayBill.setFailReason("运单已经超时,请拆分");
+            insertOrUpdateBillStart(noCarWayBill);
+            noCarWaybillMapperImprt.updateBillway(-2, "运单已经超时,请拆分#", noCarWayBill);
+            log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}", noCarWayBill, "运单已经超时,请拆分");
+            return true;
+        }
+        return false;
+    }
+
     @Override
     public RespR batchBillWayEnd(List<NoCarWayBill> noCarWayBills, String customerName) {
         log.error("结束平台指令上传数量NoCarBillWayServiceImpl.batchBillWayEnd:{}", noCarWayBills.size());

+ 1 - 1
src/main/java/com/jkcredit/invoice/service/selfcar/SelfCarService.java

@@ -9,7 +9,7 @@ import java.util.List;
  * 自有车操作接口
  * @author mumuxigua
  */
-public interface SelfCarService {
+public interface SelfCarBussService {
 
     /**
      * 自有车解绑操作

+ 2 - 2
src/main/java/com/jkcredit/invoice/service/selfcar/impl/SelfCarServiceImpl.java

@@ -3,7 +3,7 @@ package com.jkcredit.invoice.service.selfcar.impl;
 import com.jkcredit.invoice.mapper.customer.CustomerCarRecMapper;
 import com.jkcredit.invoice.model.entity.customer.CustomerCarRec;
 import com.jkcredit.invoice.service.lowerservice.SelfCarCustService;
-import com.jkcredit.invoice.service.selfcar.SelfCarService;
+import com.jkcredit.invoice.service.selfcar.SelfCarBussService;
 import com.jkcredit.invoice.util.RespR;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
@@ -17,7 +17,7 @@ import java.util.List;
  * @author mumuxigua
  */
 @Service
-public class SelfCarServiceImpl implements SelfCarService {
+public class SelfCarBussServiceImpl implements SelfCarBussService {
     @Autowired
     SelfCarCustService selfCarService;
     @Autowired