Explorar o código

无车优化,自有车接口返回

Administrator %!s(int64=3) %!d(string=hai) anos
pai
achega
189d939891

+ 49 - 9
src/main/java/com/jkcredit/invoice/credit/custInterface/NoCarInterServiceImpl.java

@@ -24,6 +24,7 @@ import net.sf.json.JSONArray;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
 
 import java.util.ArrayList;
 import java.util.List;
@@ -229,6 +230,7 @@ public class NoCarInterServiceImpl implements NoCarInterService {
      * @return
      */
     @Override
+    @Transactional
     public DataResult noCarBillStart(String appKey, String api, String data,String requestid) {
 
         long costtimestart = System.currentTimeMillis();
@@ -296,8 +298,14 @@ public class NoCarInterServiceImpl implements NoCarInterService {
             noCarWayBill.setTaxplayerCode(taxplayerCode);
             noCarWayBill.setHisFlag(0);
             noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
-            NoCarWayBill noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
-
+            NoCarWayBill noCarWayBillDb =null ;
+            try {
+                noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
+            }catch (Exception e){
+                log.info("xuyaoshanchuyundan:"+num);
+                result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
+                return result;
+            }
             if(noCarWayBillDb!=null && (noCarWayBillDb.getBillwayStatus() == 1||noCarWayBillDb.getBillwayStatus() == 2 || noCarWayBillDb.getBillwayStatus() == 3 || noCarWayBillDb.getBillwayStatus() == 4)) {
                 log.info("chongfuyundanhao:"+noCarWayBillDb.getBillNum());
                 result.setMsg("运单号重复");
@@ -390,7 +398,14 @@ public class NoCarInterServiceImpl implements NoCarInterService {
             }
 
 
-            NoCarWayBill noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
+            NoCarWayBill noCarWayBill1 =null ;
+            try {
+                noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
+            }catch (Exception e){
+                log.info("xuyaoshanchuyundan:"+num);
+                result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
+                return result;
+            }
             if (null == noCarWayBill1){
                 log.info("chongfuyundanhao1:"+num);
                 result.setMsg("运单开始指令还未上传!");
@@ -441,6 +456,7 @@ public class NoCarInterServiceImpl implements NoCarInterService {
      * @return
      */
     @Override
+    @Transactional
     public DataResult noCarHisWaybillStart(String appKey, String api, String data,String requestid) {
 
         long costtimestart = System.currentTimeMillis();
@@ -507,8 +523,15 @@ public class NoCarInterServiceImpl implements NoCarInterService {
             noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
             noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
             noCarWayBill.setInterType(0);//接口
-            NoCarWayBill noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
 
+            NoCarWayBill noCarWayBillDb =null ;
+            try {
+                noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum());
+            }catch (Exception e){
+                 log.info("xuyaoshanchuyundan:"+noCarWayBillDb.getBillNum());
+                result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
+                return result;
+            }
             if(noCarWayBillDb!=null && (noCarWayBillDb.getBillwayStatus() == 1||noCarWayBillDb.getBillwayStatus() == 2 || noCarWayBillDb.getBillwayStatus() == 3 || noCarWayBillDb.getBillwayStatus() == 4)) {
                 log.info("chongfuyundanhao1:"+noCarWayBillDb.getBillNum());
                 result.setMsg("运单号重复");
@@ -567,10 +590,11 @@ public class NoCarInterServiceImpl implements NoCarInterService {
 
     //插入或者更新运单
     public void insertOrUpdateBill(NoCarWayBill noCarWayBill,NoCarWayBill noCarWayBillDb){
-
-        if(noCarWayBillDb == null){
+        NoCarWayBill noCarWayBillDb1 = noCarWaybillMapper.selectByBillNumforLock(noCarWayBill.getBillNum());
+        if(noCarWayBillDb1 == null){
             noCarWaybillMapper.insert(noCarWayBill);
         }else{
+            if(noCarWayBillDb1.getBillwayStatus()<0)
             noCarWaybillMapper.updateByBillNum(noCarWayBill);
         }
     }
@@ -611,7 +635,14 @@ public class NoCarInterServiceImpl implements NoCarInterService {
             }
 
 
-            NoCarWayBill noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
+            NoCarWayBill noCarWayBill1 =null ;
+            try {
+                noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
+            }catch (Exception e){
+                log.info("xuyaoshanchuyundan:"+num);
+                result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
+                return result;
+            }
             if (null == noCarWayBill1){
                 result.setMsg("未上传开始运单");
                 return result;
@@ -682,8 +713,14 @@ public class NoCarInterServiceImpl implements NoCarInterService {
                 return  result;
             }
 
-
-            NoCarWayBill noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
+            NoCarWayBill noCarWayBill1 =null ;
+            try {
+                noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num);
+            }catch (Exception e){
+                log.info("xuyaoshanchuyundan:"+num);
+                result.setMsg("平台运单号存在多条,请联系管理员删除无效运单");
+                return result;
+            }
             if (null == noCarWayBill1){
                 result.setMsg("运单号异常,无法开票");
                 return result;
@@ -702,6 +739,9 @@ public class NoCarInterServiceImpl implements NoCarInterService {
                 return result;
             } else {
                 result.setData(3);
+                if("未查得".equals(result.getMsg())){
+                    result.setData(2);
+                }
                 result.setCode(200);
                 result.setMsg(rs.getMsg());
                 return result;

+ 1 - 1
src/main/java/com/jkcredit/invoice/mapper/waybill/NoCarWaybillMapper.java

@@ -24,7 +24,7 @@ public interface NoCarWaybillMapper extends BaseMapper<NoCarWayBill>{
     int updateByBillNum(NoCarWayBill record);
     int updateByBillNumTimeRes(NoCarWayBill record);
     NoCarWayBill selectByBillNum(String wayBillNum);
-
+    NoCarWayBill selectByBillNumforLock(String wayBillNum);
     List<NoCarWayBill> selectByHisFlagAndBillStatus(NoCarWayBill noCarWayBill);
 
     int upDateCompany(CompanyVo companyVo);

+ 29 - 16
src/main/java/com/jkcredit/invoice/service/lowerService/impl/NoCarServiceImpl.java

@@ -225,10 +225,10 @@ public class NoCarServiceImpl implements NoCarService{
         if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date())<-72){
             return new RespR(false,"失败,运单开始时间超72小时");
         }
-        if((DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
+       /* if((DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
             log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
             return new RespR(false,"失败,承运时长超96小时");
-        }
+        }*/
         RespR respR = checkCarWayBillAndSetInfo(noCarWayBill);
         if(respR.getCode() == 1){
             log.info("运单上传失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,respR.getMsg());
@@ -251,7 +251,7 @@ public class NoCarServiceImpl implements NoCarService{
     //插入或者更新运单
     public void insertOrUpdateBill(NoCarWayBill noCarWayBill,NoCarWayBill noCarWayBillDb){
 
-        if(noCarWayBillDb == null){
+        if(noCarWaybillMapper.selectByBillNumforLock(noCarWayBill.getBillNum()) == null){
             noCarWaybillMapper.insert(noCarWayBill);
         }else{
             noCarWaybillMapper.updateByBillNum(noCarWayBill);
@@ -306,7 +306,7 @@ public class NoCarServiceImpl implements NoCarService{
         log.info("运单结束开始:NoCarServiceImpl.noCarWaybillEnd{}",noCarWayBill);
         if(noCarWayBill1 == null || noCarWayBill1.getBillwayStatus() !=1 || noCarWayBill1.getHisFlag() ==1 ){
             log.info("运单结束失败:NoCarServiceImpl.noCarWaybillEnd{},msg{}",noCarWayBill,"当前运单状态无法结束,请检查当前指令状态");
-            noCarWayBill.setFailReason("当前运单状态无法结束,请检查当前指令状态");
+            noCarWayBill.setFailReason((noCarWayBill1 == null?"":noCarWayBill1.getFailReason())+";当前运单状态无法结束,请检查当前指令状态");
             noCarWaybillMapper.updateByBillNumTimeRes(noCarWayBill);
             return new RespR(false,"当前运单状态无法结束,请检查当前指令状态");
         }
@@ -314,13 +314,13 @@ public class NoCarServiceImpl implements NoCarService{
         noCarWayBill1.setPredictEndTime(noCarWayBill.getPredictEndTime());
         noCarWayBill1.setBatchNumEnd(noCarWayBill.getBatchNumEnd());
         noCarWayBill1.setInterType(noCarWayBill.getInterType());
-        if((DateUtil.getDistanceHours(noCarWayBill1.getStartTime(),DateUtil.StringToDate(noCarWayBill1.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
+        /*if((DateUtil.getDistanceHours(noCarWayBill1.getStartTime(),DateUtil.StringToDate(noCarWayBill1.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
             //noCarWayBill1.setBillwayStatus(4);
             noCarWayBill1.setFailReason("失败,承运时长超96小时");
             noCarWaybillMapper.updateByBillNumTimeRes(noCarWayBill);
             log.info("运单结束失败:NoCarServiceImpl.noCarWaybillEnd{},msg{}",noCarWayBill,"运单已经超时,请拆分");
             return new RespR(false,"失败,承运时长超96小时");
-        }
+        }*/
 
         WaybillEndRequest waybillEndRequest = new WaybillEndRequest();
         String companyNum = paramService.getParamsByParamName("REQUEST_COMPANY_NUM").getParamValue();
@@ -359,10 +359,10 @@ public class NoCarServiceImpl implements NoCarService{
             log.info("历史运单开始上传失败:NoCarServiceImpl.noCarHisWaybillStart{},msg{}",noCarWayBill,"必须是二十天前的运单");
             return new RespR(false,"失败,运单未满20天时效");
         }
-        if((DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
+       /* if((DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
             log.info("历史运单开始上传失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
             return new RespR(false,"失败,承运时长超96小时");
-        }
+        }*/
 
         RespR respR = checkCarWayBillAndSetInfo(noCarWayBill);
         if(respR.getCode() == 1){
@@ -411,19 +411,19 @@ public class NoCarServiceImpl implements NoCarService{
         log.info("历史运单结束上传:NoCarServiceImpl.noCarHisWaybillEnd{},msg{}",noCarWayBill,"开始");
         if(noCarWayBill1 == null || noCarWayBill1.getBillwayStatus() !=1 || noCarWayBill.getHisFlag() ==0 || noCarWayBill1.getBillwayStatus() == -3 ){
             log.info("运单结束失败:NoCarServiceImpl.noCarWaybillEnd{},msg{}",noCarWayBill,"当前运单状态无法结束,请检查当前指令状态");
-            noCarWayBill.setFailReason("当前运单状态无法结束,请检查当前指令状态");
+            noCarWayBill.setFailReason((noCarWayBill1 == null?"":noCarWayBill1.getFailReason())+"当前运单状态无法结束,请检查当前指令状态");
             noCarWaybillMapper.updateByBillNumTimeRes(noCarWayBill);
             return new RespR(false,"当前运单状态无法结束,请检查当前指令状态");
         }
         noCarWayBill1.setDestAddr(noCarWayBill.getDestAddr());
         noCarWayBill1.setPredictEndTime(noCarWayBill.getPredictEndTime());
         noCarWayBill1.setInterType(noCarWayBill.getInterType());
-        if((DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
+        /*if((DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96) && (noCarWayBill.getInterType() != 0)){
             log.info("历史运单结束上传失败:NoCarServiceImpl.noCarHisWaybillEnd{},msg{}",noCarWayBill,"运单已经超时,请拆分");
             noCarWayBill.setFailReason("失败,承运时长超96小时");
             noCarWaybillMapper.updateByBillNumTimeRes(noCarWayBill);
             return new RespR(false,"失败,承运时长超96小时");
-        }
+        }*/
         WaybillEndRequest waybillEndRequest = new WaybillEndRequest();
         String companyNum = paramService.getParamsByParamName("REQUEST_COMPANY_NUM").getParamValue();
         waybillEndRequest.setCompanyNum(companyNum);
@@ -457,16 +457,21 @@ public class NoCarServiceImpl implements NoCarService{
             billInvoices.stream().forEach(billInvoice -> {
                 InvoiceProcessingListModel invoiceProcessingListModel = new InvoiceProcessingListModel();
                 BeanUtils.copyProperties(billInvoice,invoiceProcessingListModel);
+                invoiceProcessingListModel.setExTime(DateUtil.dateToTime(invoiceProcessingListModel.getExTime()));
+                invoiceProcessingListModel.setInvoiceMakeTime(DateUtil.dateToTime(invoiceProcessingListModel.getInvoiceMakeTime()));
+                invoiceProcessingListModel.setTradeMatchTime(DateUtil.dateToTime(invoiceProcessingListModel.getTradeMatchTime()));
                 invoiceProcessingListModels.add(invoiceProcessingListModel);
             });
+        }else{
+            return null;
         }
         waybillNumFindInvoiceResponse.setResult(invoiceProcessingListModels);
         waybillNumFindInvoiceResponse.setPlateNum(noCarWayBill.getPlateNum());
         waybillNumFindInvoiceResponse.setInfo("成功");
-        waybillNumFindInvoiceResponse.setWaybillStartTime(noCarWayBill.getStartTime());
-        waybillNumFindInvoiceResponse.setWaybillEndTime(noCarWayBill.getPredictEndTime());
+        waybillNumFindInvoiceResponse.setWaybillStartTime(DateUtil.dateToTime(noCarWayBill.getStartTime()));
+        waybillNumFindInvoiceResponse.setWaybillEndTime(DateUtil.dateToTime(noCarWayBill.getPredictEndTime()));
         waybillNumFindInvoiceResponse.setWaybillStatus(noCarWayBill.getBillwayStatus());
-        waybillNumFindInvoiceResponse.setReceiveTime(DateUtil.getCurrentDateStr());
+        waybillNumFindInvoiceResponse.setReceiveTime(DateUtil.dateToTime(DateUtil.getCurrentDateStr()));
         waybillNumFindInvoiceResponse.setWaybillNum(noCarWayBill.getBillNum());
         return waybillNumFindInvoiceResponse;
     }
@@ -479,7 +484,11 @@ public class NoCarServiceImpl implements NoCarService{
             if(isInterface){
                 //直接返回发票信息
                 List<BillInvoice> billInvoices = billInvoiceMapper.selectByBillNum(noCarWayBill.getBillNum());
-                return new RespR(buildInterFaceVoiceData(noCarWayBill,billInvoices));
+                WaybillNumFindInvoiceResponse waybillNumFindInvoiceResponse = buildInterFaceVoiceData(noCarWayBill,billInvoices);
+                if(waybillNumFindInvoiceResponse == null){
+                    return new RespR(false,"未查得");
+                }
+                return new RespR(waybillNumFindInvoiceResponse);
             }else{
                 return new RespR("success");
             }
@@ -490,7 +499,11 @@ public class NoCarServiceImpl implements NoCarService{
             if(isInterface){
                 //直接返回发票信息
                 List<BillInvoice> billInvoices = billInvoiceMapper.selectByBillNum(noCarWayBill.getBillNum());
-                return new RespR(buildInterFaceVoiceData(noCarWayBill,billInvoices));
+                WaybillNumFindInvoiceResponse waybillNumFindInvoiceResponse = buildInterFaceVoiceData(noCarWayBill,billInvoices);
+                if(waybillNumFindInvoiceResponse == null){
+                    return new RespR(false,"未查得");
+                }
+                return new RespR(waybillNumFindInvoiceResponse);
             }
         }
         int status = noCarWayBill.getBillwayStatus();

+ 0 - 5
src/main/java/com/jkcredit/invoice/service/lowerService/impl/SelfCarServiceLImpl.java

@@ -82,11 +82,6 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
             log.info("获取交易失败SelfCarServiceLImpl.getTradeList{},msg{}",tradeRequestVo,"客户未备案");
             return new RespR(false,"客户未备案");
         }
-        CustomerCarRec customerCarRec = customerCarRecMapper.selectByETC(tradeRequestVo.getEtcId());
-        if(customerCarRec == null || customerCarRec.getRecStatus() != 1){
-            log.info("获取交易失败SelfCarServiceLImpl.getTradeList{},msg{}",tradeRequestVo,"业务校验错误:该卡号不在该企业下绑定!\\n:803");
-            return new RespR(false,"业务校验错误:该卡号不在该企业下绑定!\\n:803");
-        }
         CardTradeRequest cardTradeRequest = new CardTradeRequest();
         cardTradeRequest.setCardId(tradeRequestVo.getEtcId());
         cardTradeRequest.setCompanyNum(customerRec.getCompanyNum());

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

@@ -114,14 +114,14 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
                         return;
 
                     }
-                    if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96){
+                   /* if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96){
                         log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
                         noCarWaybillMapperImprt.updateBillway(-2,"失败,承运时长超96小时#",noCarWayBill);
                         noCarWayBill.setBillwayStatus(-2);
                         noCarWayBill.setFailReason("失败,承运时长超96小时");
                         insertOrUpdateBill(noCarWayBill,noCarWayBillDb);
                         return;
-                    }
+                    }*/
                     //1.查询是否有车辆备案
                     CustomerCarRec customerCarRec;
 

+ 6 - 0
src/main/resources/mapper/waybill/NoCarWaybillMapper.xml

@@ -221,6 +221,12 @@
         from t_waybill_no
         where  billNum = BINARY #{billNum,jdbcType=VARCHAR}
     </select>
+    <select id="selectByBillNumforLock" resultMap="BaseResultMap" parameterType="java.lang.String" >
+        select
+        <include refid="baseSql" />
+        from t_waybill_no
+        where  billNum = BINARY #{billNum,jdbcType=VARCHAR} for update
+    </select>
     <select id="selectByHisFlagAndBillStatus" resultMap="BaseResultMap" parameterType="com.jkcredit.invoice.model.entity.waybill.NoCarWayBill" >
         select
         <include refid="baseSql" />