|
@@ -31,7 +31,7 @@ import com.jkcredit.invoice.service.lowerservice.vo.MonthAccountQueryVo;
|
|
|
import com.jkcredit.invoice.service.manager.ParamService;
|
|
|
import com.jkcredit.invoice.service.nocar.HcInvoiceService;
|
|
|
import com.jkcredit.invoice.service.nocar.NoCarRecService;
|
|
|
-import com.jkcredit.invoice.service.upService.NoCarInterface;
|
|
|
+import com.jkcredit.invoice.service.upservice.NoCarInterface;
|
|
|
import com.jkcredit.invoice.util.DateUtil;
|
|
|
import com.jkcredit.invoice.util.MathUtil;
|
|
|
import com.jkcredit.invoice.util.RespR;
|
|
@@ -45,6 +45,8 @@ import org.springframework.util.StringUtils;
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
+import static com.jkcredit.invoice.common.CommonConst.*;
|
|
|
+
|
|
|
@Repository("noCarService")
|
|
|
@Slf4j
|
|
|
public class NoCarServiceImpl implements NoCarService{
|
|
@@ -195,7 +197,7 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
RespR<VehicleQueryResponse> respR = noCarInterface.vehicleQuery(vehicleQueryRequest);
|
|
|
if(respR.getCode() == 1){
|
|
|
log.info("车辆备案查询失败NoCarServiceImpl.customerCarRecQueryUpper{},msg{}",customerCarRec,respR.getMsg());
|
|
|
- }else if(8 != customerCarRec.getInterType()){//此处表示仅适用接口查询,不走业务逻辑
|
|
|
+ }else if(EIGHT_NUM != customerCarRec.getInterType()){//此处表示仅适用接口查询,不走业务逻辑
|
|
|
customerCarRec.setRecStatus(1);
|
|
|
updateCustomerCarRec(customerCarRec);
|
|
|
}
|
|
@@ -237,7 +239,7 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
return new RespR(false,"开始指令已经上传成功");
|
|
|
}
|
|
|
//如果运单时间和当前时间差了三天,直接返回
|
|
|
- if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date())<-72){
|
|
|
+ if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date())<INTONE){
|
|
|
noCarWayBill.setFailReason("失败,运单开始时间超72小时");
|
|
|
noCarWayBill.setBillwayStatus(-2);
|
|
|
insertOrUpdateBillStart(noCarWayBill);
|
|
@@ -375,7 +377,7 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
noCarWayBillDb.setFailReason(waybillEndResponseRespR.getMsg());
|
|
|
insertOrUpdateBillEnd(noCarWayBillDb);
|
|
|
return new RespR(false,waybillEndResponseRespR.getMsg());
|
|
|
- }else if("4".equals(waybillEndResponseRespR.getData().getInfo())){
|
|
|
+ }else if(FOR.equals(waybillEndResponseRespR.getData().getInfo())){
|
|
|
log.info("运单结束失败:NoCarServiceImpl.noCarWaybillEnd{},msg{}",noCarWayBill,"运单已经超时");
|
|
|
noCarWayBillDb.setBillwayStatus(4);
|
|
|
noCarWayBillDb.setFailReason(waybillEndResponseRespR.getMsg());
|
|
@@ -409,7 +411,7 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
if(curr == null){
|
|
|
noCarWaybillMapper.insert(noCarWayBill);
|
|
|
}else{
|
|
|
- if(curr.getBillwayStatus()>2){
|
|
|
+ if(curr.getBillwayStatus() > TWO_NUM){
|
|
|
return;
|
|
|
}
|
|
|
noCarWaybillMapper.updateByBillNum(noCarWayBill);
|
|
@@ -432,7 +434,7 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
if(noCarWayBillDb!=null && noCarWayBillDb.getBillwayStatus()>0){
|
|
|
return new RespR(false,"开始指令已经上传成功,请勿重复上传");
|
|
|
}
|
|
|
- if(DateUtil.getDistanceDays(noCarWayBill.getStartTime(),new Date())>-20){
|
|
|
+ if(DateUtil.getDistanceDays(noCarWayBill.getStartTime(),new Date()) > INTTOW){
|
|
|
log.info("历史运单开始上传失败:NoCarServiceImpl.noCarHisWaybillStart{},msg{}",noCarWayBill,"必须是二十天前的运单");
|
|
|
noCarWayBill.setBillwayStatus(-2);
|
|
|
noCarWayBill.setFailReason("失败,运单未满20天时效");
|
|
@@ -532,7 +534,7 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
log.info("历史运单结束上传失败:NoCarServiceImpl.noCarHisWaybillEnd{},msg{}",noCarWayBillDb,waybillEndResponseRespR.getMsg());
|
|
|
|
|
|
return new RespR(false,waybillEndResponseRespR.getMsg());
|
|
|
- }else if("4".equals(waybillEndResponseRespR.getData().getInfo())){
|
|
|
+ }else if(FOR.equals(waybillEndResponseRespR.getData().getInfo())){
|
|
|
noCarWayBill.setBillwayStatus(4);
|
|
|
insertOrUpdateBillEnd(noCarWayBillDb);
|
|
|
log.info("历史运单结束上传失败:NoCarServiceImpl.noCarHisWaybillEnd{},msg{}",noCarWayBillDb,"运单已经超时,请拆分");
|
|
@@ -574,18 +576,18 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
/**
|
|
|
* 迁移数据
|
|
|
*/
|
|
|
- if(noCarWayBill.getInterType() == 3){
|
|
|
+ if(noCarWayBill.getInterType() == THREE_NUM){
|
|
|
isKf = 3;
|
|
|
}
|
|
|
/**
|
|
|
* 特殊处理数据
|
|
|
*/
|
|
|
- if(noCarWayBill.getInterType() == 5){
|
|
|
+ if(noCarWayBill.getInterType() == FIVE_NUM){
|
|
|
isKf = 5;
|
|
|
}
|
|
|
log.info("取票啦:NoCarServiceImpl.getInvoiceByWayBillNumReal{},isCurr{}",noCarWayBill,isInterface);
|
|
|
- if(isInterface && (noCarWayBill.getBillwayStatus()!=-5 || noCarWayBill.getInterType() == 4)){
|
|
|
- if(noCarWayBill.getBillwayStatus() == 1 || noCarWayBill.getBillwayStatus() == 2 || noCarWayBill.getBillwayStatus() == 3 || noCarWayBill.getBillwayStatus() == 4){
|
|
|
+ if(isInterface && (noCarWayBill.getBillwayStatus() != NE_FIVE_NUM || noCarWayBill.getInterType() == FOR_NUM)){
|
|
|
+ if(noCarWayBill.getBillwayStatus() == ONE_NUM || noCarWayBill.getBillwayStatus() == TWO_NUM || noCarWayBill.getBillwayStatus() == THREE_NUM || noCarWayBill.getBillwayStatus() == FOR_NUM){
|
|
|
//直接返回发票信息
|
|
|
List<BillInvoice> billInvoices = billInvoiceMapper.selectByBillNum(noCarWayBill.getBillNum());
|
|
|
WaybillNumFindInvoiceResponse waybillNumFindInvoiceResponse = buildInterFaceVoiceData(noCarWayBill,billInvoices);
|
|
@@ -594,7 +596,7 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
return new RespR(false,noCarWayBill.getFailReason()==null?"运单未知异常":noCarWayBill.getFailReason());
|
|
|
}
|
|
|
}
|
|
|
- if(noCarWayBill.getBillwayStatus()!=2 && noCarWayBill.getBillwayStatus()!=-5){
|
|
|
+ if(noCarWayBill.getBillwayStatus() != TWO_NUM && noCarWayBill.getBillwayStatus() != NE_FIVE_NUM){
|
|
|
return new RespR(false,"不是开票中的状态,别取票啦");
|
|
|
}
|
|
|
RespR respR = checkCarWayBillAndSetInfo(noCarWayBill);
|
|
@@ -602,7 +604,6 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
log.info("取票失败啦:NoCarServiceImpl.getInvoiceByWayBillNumReal{},isCurr{},msg{}",noCarWayBill,isInterface,respR.getMsg());
|
|
|
return respR;
|
|
|
}
|
|
|
-
|
|
|
//进行取票操作
|
|
|
WaybillNumFindInvoiceRequest waybillNumFindInvoiceRequest = new WaybillNumFindInvoiceRequest();
|
|
|
String companyNum = paramService.getParamsByParamName("REQUEST_COMPANY_NUM").getParamValue();
|
|
@@ -614,11 +615,11 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
return new RespR(false,responseRespR.getMsg());
|
|
|
}else{
|
|
|
int tempStatus = responseRespR.getData().getWaybillStatus().intValue();
|
|
|
- if(noCarWayBill.getBillwayStatus()==-5){
|
|
|
- if(isKf != 3){
|
|
|
+ if(noCarWayBill.getBillwayStatus() == NE_FIVE_NUM){
|
|
|
+ if(isKf != THREE_NUM){
|
|
|
noCarWayBill.setInterType(0);
|
|
|
}else{
|
|
|
- if(tempStatus == 3){
|
|
|
+ if(tempStatus == THREE_NUM){
|
|
|
noCarWayBill.setInterType(4);
|
|
|
}
|
|
|
}
|
|
@@ -628,7 +629,6 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
//更改票状态
|
|
|
noCarWayBill.setBillwayStatus(tempStatus);
|
|
|
insertOrUpdateBill(noCarWayBill);
|
|
|
-
|
|
|
}else {
|
|
|
//更改票状态
|
|
|
noCarWayBill.setPlateNum(responseRespR.getData().getPlateNum());
|
|
@@ -639,64 +639,10 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
noCarWaybillMapper.updateByBillNum(noCarWayBill);
|
|
|
}
|
|
|
|
|
|
- if(tempStatus == 2 || tempStatus==3){
|
|
|
- //删除已有发票
|
|
|
- billInvoiceMapper.deleteByBillNum(noCarWayBill.getBillNum());
|
|
|
- //发票入库
|
|
|
- List<InvoiceProcessingListModel> invoiceProcessingListModels = responseRespR.getData().getResult();
|
|
|
- //用set来去重计费信息
|
|
|
- Set<NoCarCalculateInfor> carCalculateInfors = new HashSet<>();
|
|
|
- invoiceProcessingListModels.stream().forEach(invoiceProcessingListModel -> {
|
|
|
- log.info("44444{}",invoiceProcessingListModel.getTransactionId());
|
|
|
- BillInvoice billInvoice = buildFromInvoiceProcessingListModel(invoiceProcessingListModel);
|
|
|
- billInvoice.setCompanyName(noCarWayBill.getCompanyName());
|
|
|
- billInvoice.setCompanyNum(noCarWayBill.getCompanyNum());
|
|
|
- billInvoice.setCustomerName(noCarWayBill.getCustomerName());
|
|
|
- //扣费明细入账
|
|
|
- NoCarCalculateInfor calculateInfor = new NoCarCalculateInfor();
|
|
|
- if(noCarWayBill.getInterType()!=4 && noCarWayBill.getInterType()!=3){
|
|
|
- calculateInfor.setCalculateTime(DateUtil.getCurrentDateStr());
|
|
|
- }else{
|
|
|
- calculateInfor.setCalculateTime("2021-01-11 00:00:00");
|
|
|
- }
|
|
|
-
|
|
|
- calculateInfor.setCompanyNum(noCarWayBill.getCompanyNum());
|
|
|
- calculateInfor.setCtype(1);
|
|
|
- calculateInfor.setCustomId(noCarWayBill.getCustomerName());
|
|
|
- calculateInfor.setBuyerName(invoiceProcessingListModel.getBuyerName());
|
|
|
- calculateInfor.setBuyerTaxpayerCode(invoiceProcessingListModel.getBuyerTaxpayerCode());
|
|
|
- calculateInfor.setInvoiceMakeTime(billInvoice.getInvoiceMakeTime());
|
|
|
- calculateInfor.setTradeId(billInvoice.getTransactionId());
|
|
|
- NoCarCalculateInfor noCarCalculateInfor = calculateInforMapper.selectByTradeId(billInvoice.getTransactionId());
|
|
|
- if(noCarCalculateInfor!=null){
|
|
|
- billInvoice.setCalculateTime(noCarCalculateInfor.getCalculateTime());
|
|
|
- }else{
|
|
|
- carCalculateInfors.add(calculateInfor);
|
|
|
- billInvoice.setCalculateTime(calculateInfor.getCalculateTime());
|
|
|
- }
|
|
|
- billInvoiceMapper.insert(billInvoice);
|
|
|
- });
|
|
|
- log.info("6666666{}",noCarWayBill.getBillNum());
|
|
|
- if(isKf == 3) { return new RespR(responseRespR.getData());}
|
|
|
- //统一插入交易id 和 和计费信息
|
|
|
- Param param = paramService.getParamsByParamName("CUST_NOCAR_FEE");
|
|
|
- Double fee = Double.parseDouble(param.getParamValue());
|
|
|
- Customer customer = customerMapper.selectByCustomerNameForLock(noCarWayBill.getCustomerName());
|
|
|
- customer.setInvoiceTime(DateUtil.getCurrentDateStr());
|
|
|
- carCalculateInfors.stream().forEach(calculateInfor -> {
|
|
|
- try {
|
|
|
- calculateInfor.setCompanyLongName(customer.getCompany());
|
|
|
- calculateInfor.setFee(fee);
|
|
|
- calculateInforMapper.insert(calculateInfor);
|
|
|
- customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),calculateInfor.getFee()));
|
|
|
- }catch (Exception e){
|
|
|
- log.error("重复数据来啦"+calculateInfor.getTradeId());
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- });
|
|
|
- if(isKf==1){
|
|
|
- customerMapper.updateByPrimaryKeySelective(customer);}
|
|
|
+ if(tempStatus == TWO_NUM || tempStatus == THREE_NUM){
|
|
|
+ if (countCalculateInfo(noCarWayBill, isKf, responseRespR)) {
|
|
|
+ return new RespR(responseRespR.getData());
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
if(isInterface){
|
|
@@ -706,6 +652,70 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
log.info("99999999{}",noCarWayBill.getBillNum());
|
|
|
return new RespR("success");
|
|
|
}
|
|
|
+
|
|
|
+ private boolean countCalculateInfo(NoCarWayBill noCarWayBill, byte isKf, RespR<WaybillNumFindInvoiceResponse> responseRespR) {
|
|
|
+ //删除已有发票
|
|
|
+ billInvoiceMapper.deleteByBillNum(noCarWayBill.getBillNum());
|
|
|
+ //发票入库
|
|
|
+ List<InvoiceProcessingListModel> invoiceProcessingListModels = responseRespR.getData().getResult();
|
|
|
+ //用set来去重计费信息
|
|
|
+ Set<NoCarCalculateInfor> carCalculateInfors = new HashSet<>();
|
|
|
+ invoiceProcessingListModels.stream().forEach(invoiceProcessingListModel -> {
|
|
|
+ log.info("44444{}",invoiceProcessingListModel.getTransactionId());
|
|
|
+ BillInvoice billInvoice = buildFromInvoiceProcessingListModel(invoiceProcessingListModel);
|
|
|
+ billInvoice.setCompanyName(noCarWayBill.getCompanyName());
|
|
|
+ billInvoice.setCompanyNum(noCarWayBill.getCompanyNum());
|
|
|
+ billInvoice.setCustomerName(noCarWayBill.getCustomerName());
|
|
|
+ //扣费明细入账
|
|
|
+ NoCarCalculateInfor calculateInfor = new NoCarCalculateInfor();
|
|
|
+ if(noCarWayBill.getInterType() != FOR_NUM && noCarWayBill.getInterType() != THREE_NUM){
|
|
|
+ calculateInfor.setCalculateTime(DateUtil.getCurrentDateStr());
|
|
|
+ }else{
|
|
|
+ calculateInfor.setCalculateTime("2021-01-11 00:00:00");
|
|
|
+ }
|
|
|
+
|
|
|
+ calculateInfor.setCompanyNum(noCarWayBill.getCompanyNum());
|
|
|
+ calculateInfor.setCtype(1);
|
|
|
+ calculateInfor.setCustomId(noCarWayBill.getCustomerName());
|
|
|
+ calculateInfor.setBuyerName(invoiceProcessingListModel.getBuyerName());
|
|
|
+ calculateInfor.setBuyerTaxpayerCode(invoiceProcessingListModel.getBuyerTaxpayerCode());
|
|
|
+ calculateInfor.setInvoiceMakeTime(billInvoice.getInvoiceMakeTime());
|
|
|
+ calculateInfor.setTradeId(billInvoice.getTransactionId());
|
|
|
+ NoCarCalculateInfor noCarCalculateInfor = calculateInforMapper.selectByTradeId(billInvoice.getTransactionId());
|
|
|
+ if(noCarCalculateInfor!=null){
|
|
|
+ billInvoice.setCalculateTime(noCarCalculateInfor.getCalculateTime());
|
|
|
+ }else{
|
|
|
+ carCalculateInfors.add(calculateInfor);
|
|
|
+ billInvoice.setCalculateTime(calculateInfor.getCalculateTime());
|
|
|
+ }
|
|
|
+ billInvoiceMapper.insert(billInvoice);
|
|
|
+ });
|
|
|
+ log.info("6666666{}",noCarWayBill.getBillNum());
|
|
|
+ if(isKf == THREE_NUM) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ //统一插入交易id 和 和计费信息
|
|
|
+ Param param = paramService.getParamsByParamName("CUST_NOCAR_FEE");
|
|
|
+ Double fee = Double.parseDouble(param.getParamValue());
|
|
|
+ Customer customer = customerMapper.selectByCustomerNameForLock(noCarWayBill.getCustomerName());
|
|
|
+ customer.setInvoiceTime(DateUtil.getCurrentDateStr());
|
|
|
+ carCalculateInfors.stream().forEach(calculateInfor -> {
|
|
|
+ try {
|
|
|
+ calculateInfor.setCompanyLongName(customer.getCompany());
|
|
|
+ calculateInfor.setFee(fee);
|
|
|
+ calculateInforMapper.insert(calculateInfor);
|
|
|
+ customer.setAccountBalance(MathUtil.sub(customer.getAccountBalance(),calculateInfor.getFee()));
|
|
|
+ }catch (Exception e){
|
|
|
+ log.error("重复数据来啦"+calculateInfor.getTradeId());
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ });
|
|
|
+ if(isKf==1){
|
|
|
+ customerMapper.updateByPrimaryKeySelective(customer);}
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
public BillInvoice buildFromInvoiceProcessingListModel(InvoiceProcessingListModel invoiceProcessingListModel){
|
|
|
BillInvoice billInvoice = new BillInvoice();
|
|
|
BeanUtils.copyProperties(invoiceProcessingListModel,billInvoice);
|
|
@@ -850,9 +860,9 @@ public class NoCarServiceImpl implements NoCarService{
|
|
|
if(waybillCountQueryResponseRespR.getCode() != 1){
|
|
|
dealMouthAcc(waybillCountQueryResponseRespR,customerRec);
|
|
|
log.info(waybillCountQueryResponseRespR.getData().getTotalCount()+"---hehhe----"+monthAccountQueryVo.getCompanyName());
|
|
|
- if(waybillCountQueryResponseRespR.getData().getTotalCount()>1000){
|
|
|
+ if(waybillCountQueryResponseRespR.getData().getTotalCount() > A_THOUSAND){
|
|
|
long pages = waybillCountQueryResponseRespR.getData().getTotalCount()%1000==0?waybillCountQueryResponseRespR.getData().getTotalCount()/1000-1:waybillCountQueryResponseRespR.getData().getTotalCount()/1000;
|
|
|
- for(int i=2;i<pages+2;i++){
|
|
|
+ for(int i= TWO_NUM ;i<pages+TWO_NUM;i++){
|
|
|
waybillCountQueryRequest.setPageNo(i);
|
|
|
RespR<WaybillCountQueryResponse> waybillCountQueryResponseRespR1 = noCarInterface.waybillCountQuery(waybillCountQueryRequest);
|
|
|
dealMouthAcc(waybillCountQueryResponseRespR1,customerRec);
|