|
@@ -1,5 +1,6 @@
|
|
|
package com.jkcredit.invoice.service.nocar.impl;
|
|
|
|
|
|
+import cn.com.taiji.sdk.model.comm.protocol.tts.vehicle.VehicleQueryResponse;
|
|
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -22,6 +23,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
+import java.util.Date;
|
|
|
import java.util.List;
|
|
|
@Slf4j
|
|
|
@Service
|
|
@@ -82,47 +84,71 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
|
|
|
customerRec.setCustomerName(customerName);
|
|
|
customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
|
|
|
customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
|
|
|
+ if(customerRec == null){
|
|
|
+ noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案",noCarWayBill);
|
|
|
+ noCarWayBill.setFailReason("企业税号未备案");
|
|
|
+ noCarWayBill.setBillwayStatus(-2);
|
|
|
+ insertOrUpdateBill(noCarWayBill);
|
|
|
+ stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
|
|
|
+ return;
|
|
|
+ }
|
|
|
noCarWayBill.setCompanyName(customerRec.getCompanyName());
|
|
|
noCarWayBill.setCustomerName(customerName);
|
|
|
+ noCarWayBill.setCompanyNum(customerRec.getCompanyNum());
|
|
|
noCarWayBill.setBatchNum(batchNumber);
|
|
|
noCarWayBill.setBillwayStatus(-2);
|
|
|
noCarWayBill.setHisFlag(0);
|
|
|
noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
|
|
|
noCarWaybillMapperImprt.insertImport(noCarWayBill);
|
|
|
insertOrUpdateBill(noCarWayBill);
|
|
|
- if(customerRec == null){
|
|
|
- noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案",noCarWayBill);
|
|
|
- noCarWayBill.setFailReason("企业税号未备案");
|
|
|
+ if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date())<-72){
|
|
|
+ noCarWaybillMapperImprt.updateBillway(-2,"失败,运单开始时间超72小时#",noCarWayBill);
|
|
|
noCarWayBill.setBillwayStatus(-2);
|
|
|
+ noCarWayBill.setFailReason("失败,运单开始时间超72小时");
|
|
|
+ insertOrUpdateBill(noCarWayBill);
|
|
|
+ return;
|
|
|
+
|
|
|
+ }
|
|
|
+ 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);
|
|
|
- stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
|
|
|
return;
|
|
|
}
|
|
|
//1.查询是否有车辆备案
|
|
|
- CustomerCarRec customerCarRec = customerCarRecMapper.selectByCarNum(noCarWayBill.getPlateColor());
|
|
|
+ CustomerCarRec customerCarRec;
|
|
|
|
|
|
//2.无车车辆备案时进行车辆备案
|
|
|
- if(customerCarRec== null || customerCarRec.getRecStatus()!=1){
|
|
|
+
|
|
|
List<CustomerCarRec> customerCarRecs = new ArrayList<>();
|
|
|
customerCarRec = new CustomerCarRec();
|
|
|
customerCarRec.setCompanyName(noCarWayBill.getCompanyName());
|
|
|
customerCarRec.setCarNum(noCarWayBill.getPlateNum());
|
|
|
customerCarRec.setCarColor(noCarWayBill.getPlateColor());
|
|
|
customerCarRec.setCustomerName(customerName);
|
|
|
+ customerCarRec.setInterType(1);
|
|
|
+ customerCarRec.setCompanyNum(customerRec.getCompanyNum());
|
|
|
customerCarRec.setBusinessType("2");
|
|
|
customerCarRec.setServiceOperation(1);//默认运营车辆
|
|
|
noCarWayBill.setTitleType(2);
|
|
|
- customerCarRecs.add(customerCarRec);
|
|
|
- RespR respR = noCarService.customerCarRec(customerCarRecs);
|
|
|
- if(respR.getCode() ==1){
|
|
|
- stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
|
|
|
- noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
|
|
|
- noCarWayBill.setBillwayStatus(-2);
|
|
|
- noCarWayBill.setFailReason(respR.getMsg());
|
|
|
- insertOrUpdateBill(noCarWayBill);
|
|
|
- return;
|
|
|
+ //先查询上游是否已经备案
|
|
|
+ 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){
|
|
|
+ stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
|
|
|
+ noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
|
|
|
+ noCarWayBill.setBillwayStatus(-2);
|
|
|
+ noCarWayBill.setFailReason(respR.getMsg());
|
|
|
+ insertOrUpdateBill(noCarWayBill);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//3.进行上传
|
|
|
RespR respR = noCarService.noCarWaybillStart(noCarWayBill);
|
|
@@ -162,8 +188,17 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
|
|
|
customerRec.setCustomerName(customerName);
|
|
|
customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
|
|
|
customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
|
|
|
+ if(customerRec == null || customerRec.getRecStatus()!=1){
|
|
|
+ stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
|
|
|
+ noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案#",noCarWayBill);
|
|
|
+ noCarWayBill.setBillwayStatus(-2);
|
|
|
+ noCarWayBill.setFailReason("企业税号未备案");
|
|
|
+ insertOrUpdateBill(noCarWayBill);
|
|
|
+ return;
|
|
|
+ }
|
|
|
noCarWayBill.setCompanyName(customerRec.getCompanyName());
|
|
|
noCarWayBill.setCustomerName(customerName);
|
|
|
+ noCarWayBill.setCompanyNum(customerRec.getCompanyNum());
|
|
|
noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
|
|
|
noCarWayBill.setBatchNum(batchNumber);
|
|
|
noCarWayBill.setTitleType(2);
|
|
@@ -171,39 +206,51 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
|
|
|
noCarWayBill.setHisFlag(1);
|
|
|
noCarWaybillMapperImprt.insertImport(noCarWayBill);
|
|
|
insertOrUpdateBill(noCarWayBill);
|
|
|
- if(customerRec == null || customerRec.getRecStatus()!=1){
|
|
|
- stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
|
|
|
- noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案#",noCarWayBill);
|
|
|
+
|
|
|
+ if(DateUtil.getDistanceDays(noCarWayBill.getStartTime(),new Date())>-20){
|
|
|
+ log.info("历史运单开始上传失败:NoCarServiceImpl.noCarHisWaybillStart{},msg{}",noCarWayBill,"必须是二十天前的运单");
|
|
|
noCarWayBill.setBillwayStatus(-2);
|
|
|
- noCarWayBill.setFailReason("企业税号未备案");
|
|
|
+ noCarWayBill.setFailReason("失败,运单未满20天时效");
|
|
|
+ noCarWaybillMapperImprt.updateBillway(-2,"失败,运单未满20天时效#",noCarWayBill);
|
|
|
insertOrUpdateBill(noCarWayBill);
|
|
|
return;
|
|
|
}
|
|
|
-
|
|
|
- //1.查询是否有车辆备案
|
|
|
- CustomerCarRec customerCarRec = customerCarRecMapper.selectByCarNum(noCarWayBill.getPlateNum());
|
|
|
+ if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96){
|
|
|
+ noCarWayBill.setBillwayStatus(-2);
|
|
|
+ noCarWayBill.setFailReason("运单已经超时,请拆分");
|
|
|
+ noCarWaybillMapperImprt.updateBillway(-2,"运单已经超时,请拆分#",noCarWayBill);
|
|
|
+ log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //1.查询是否有车辆备案 /
|
|
|
+ CustomerCarRec customerCarRec;
|
|
|
|
|
|
//2.无车车辆备案时进行车辆备案
|
|
|
- if(customerCarRec== null || customerCarRec.getRecStatus()!=1){
|
|
|
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);//默认运营车辆
|
|
|
- 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());
|
|
|
- insertOrUpdateBill(noCarWayBill);
|
|
|
- return;
|
|
|
+ //先查询上游是否已经备案
|
|
|
+ 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());
|
|
|
+ insertOrUpdateBill(noCarWayBill);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
//3.kais指令上传
|
|
|
NoCarWayBill noCarWayBillClo = null;
|