瀏覽代碼

后端代码提交

mashengyi 3 年之前
父節點
當前提交
3469599322

+ 29 - 0
src/main/java/com/jkcredit/invoice/component/SendMailService.java

@@ -0,0 +1,29 @@
+package com.jkcredit.invoice.component;
+
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Autowired;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.mail.javamail.JavaMailSenderImpl;
+import org.springframework.mail.javamail.MimeMessageHelper;
+import org.springframework.stereotype.Component;
+import javax.mail.MessagingException;
+import javax.mail.internet.MimeMessage;
+@Slf4j
+@Component
+public class SendMailService {
+    @Autowired
+    private JavaMailSenderImpl javaMailSender;
+    @Value("${spring.mail.username}")
+    String user;
+    public void sendMail(String email,String contents,String company) throws MessagingException {
+        MimeMessage message = javaMailSender.createMimeMessage();
+        MimeMessageHelper helper = new MimeMessageHelper(message);
+        helper.setFrom(user);
+        helper.setTo(email);
+        helper.setSubject(company+"备案提交");
+        helper.setText(contents,true);
+        log.info("before send emil");
+        javaMailSender.send(message);
+        log.info("send emil");
+    }
+}

+ 1 - 1
src/main/java/com/jkcredit/invoice/mapper/customer/CustomerRecMapper.java

@@ -17,7 +17,7 @@ public interface CustomerRecMapper extends BaseMapper<CustomerRec> {
 
     int insertSelective(CustomerRec record);
 
-    CustomerRec selectByPrimaryKey(Integer id);
+    CustomerRec selectByPrimaryKey(String id);
     CustomerRec selectByPrimaryKeyHasBase64(Integer id);
     List<CustomerRec> selectByCustomerName(String customerName);
 

+ 1 - 1
src/main/java/com/jkcredit/invoice/model/entity/waybill/NoCarWayBill.java

@@ -104,7 +104,7 @@ public class NoCarWayBill implements Cloneable{
     private String updateTime;
 
     /**
-     * 运单转态 -1-导入 -2失败 -3 结束指令上传失败  1-指令开始 2-开票中  3-开票完成 4 超时作废
+     * 运单转态 -1-导入 -2上传失败 -3 结束指令上传失败  1-指令开始 2-开票中  3-开票完成 4 超时作废
      */
     private int billwayStatus;
 

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

@@ -38,6 +38,11 @@ public interface SelfCarServiceL {
     RespR<List<SelfCarInvoice>> getSelfCarInvoicesByApplyIds(ApplQueryInvVo applQueryInvVo);
 
     /**
+     *按申请id取发票
+     */
+    void getSelfCarInvoicesByApplyIds(SelfCarAppl applQueryInvVo);
+
+    /**
      *已开发票查询接口
      */
     RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo);

文件差異過大導致無法顯示
+ 22 - 0
src/main/java/com/jkcredit/invoice/service/lowerService/impl/CustomerLowerServiceImpl.java


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

@@ -215,11 +215,11 @@ public class NoCarServiceImpl implements NoCarService{
         log.info("运单上传开始:NoCarServiceImpl.noCarWaybillStart{}",noCarWayBill);
         //如果运单时间和当前时间差了三天,直接返回
         if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date())<-72){
-            return new RespR(false,"已经超过72小时,请20天后上传历史运单");
+            return new RespR(false,"失败,运单开始时间超72小时");
         }
         if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96){
             log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
-            return new RespR(false,"运单开始时间与结束时间超过96小时,请拆分");
+            return new RespR(false,"失败,承运时长超96小时");
         }
         RespR respR = checkCarWayBillAndSetInfo(noCarWayBill);
         if(respR.getCode() == 1){
@@ -316,7 +316,7 @@ public class NoCarServiceImpl implements NoCarService{
         noCarWayBill1.setBatchNumEnd(noCarWayBill.getBatchNumEnd());
         if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96){
             noCarWayBill1.setBillwayStatus(4);
-            noCarWayBill1.setFailReason("运单已经超时,请拆分");
+            noCarWayBill1.setFailReason("失败,承运时长超96小时");
             noCarWaybillMapper.updateByBillNum(noCarWayBill1);
             log.info("运单结束失败:NoCarServiceImpl.noCarWaybillEnd{},msg{}",noCarWayBill,"运单已经超时,请拆分");
             return new RespR(false,"运单已经超时,请拆分");
@@ -336,7 +336,7 @@ public class NoCarServiceImpl implements NoCarService{
             noCarWaybillMapper.updateByBillNum(noCarWayBill1);
             return new RespR(false,waybillEndResponseRespR.getMsg());
         }else if("4".equals(waybillEndResponseRespR.getData().getInfo())){
-            log.info("运单结束失败:NoCarServiceImpl.noCarWaybillEnd{},msg{}",noCarWayBill,"运单已经超时,请拆分");
+            log.info("运单结束失败:NoCarServiceImpl.noCarWaybillEnd{},msg{}",noCarWayBill,"运单已经超时");
             noCarWayBill1.setBillwayStatus(4);
             noCarWayBill1.setFailReason(waybillEndResponseRespR.getMsg());
             noCarWaybillMapper.updateByBillNum(noCarWayBill1);
@@ -359,11 +359,11 @@ public class NoCarServiceImpl implements NoCarService{
         }
         if(DateUtil.getDistanceDays(noCarWayBill.getStartTime(),new Date())>-20){
             log.info("历史运单开始上传失败:NoCarServiceImpl.noCarHisWaybillStart{},msg{}",noCarWayBill,"必须是二十天前的运单");
-            return new RespR(false,"必须是二十天前的运单");
+            return new RespR(false,"失败,运单未满20天时效");
         }
         if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.StringToDate(noCarWayBill.getPredictEndTime()))<-96){
             log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
-            return new RespR(false,"运单开始时间与结束时间超过96小时,请拆分");
+            return new RespR(false,"失败,承运时长超96小时");
         }
         RespR respR = checkCarWayBillAndSetInfo(noCarWayBill);
         if(respR.getCode() == 1){

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

@@ -258,7 +258,47 @@ public class SelfCarServiceLImpl implements SelfCarServiceL {
             return new RespR(b2BInvoiceQueryByApplyModels);
         }
     }
+    @Override
+    public void getSelfCarInvoicesByApplyIds(SelfCarAppl applQueryInvVo) {
+        log.info("申请开票开始SelfCarServiceLImpl.getSelfCarInvoicesByApplyIds{}",applQueryInvVo);
+        if(!customerService.checkMoneyEnough(applQueryInvVo.getCustomId())){
+            log.info("余额不足{}",applQueryInvVo);
+            return ;
+        }
+        CustomerRec customerRec = customerRecMapper.selectByPrimaryKey(applQueryInvVo.getCompanyNum());
+        if(customerRec == null){
+            log.info("备案信息不存在{}",applQueryInvVo);
+            return;
+        }
+        B2BInvoiceQueryByApplyRequest b2BInvoiceQueryRequest = new B2BInvoiceQueryByApplyRequest();
+
+        b2BInvoiceQueryRequest.setCardId(applQueryInvVo.getCardId());
+        b2BInvoiceQueryRequest.setCompanyNum(applQueryInvVo.getCompanyNum());
+        b2BInvoiceQueryRequest.setApplyId(applQueryInvVo.getApplId());
+        RespR<B2BInvoiceQueryByApplyResponse> responseRespR = selfCarInterface.b2bContractQuery(b2BInvoiceQueryRequest);
+        if(responseRespR.getCode() == 1){
+            log.info("申请开票失败SelfCarServiceLImpl.getSelfCarInvoicesByApplyIds{},msg{}",applQueryInvVo,responseRespR.getMsg());
+        }else{
+            B2BInvoiceQueryByApplyResponse response = responseRespR.getData();
+            List<B2BInvoiceQueryByApplyModel> b2BInvoiceQueryByApplyModels = response.getResult();
+            for(B2BInvoiceQueryByApplyModel b2BInvoiceQueryByApplyModel:b2BInvoiceQueryByApplyModels){
+                SelfCarInvoice selfCarInvoice = new SelfCarInvoice();
+                BeanUtils.copyProperties(b2BInvoiceQueryByApplyModel,selfCarInvoice);
+                selfCarInvoice.setCompanyName(customerRec.getCompanyName());
+                selfCarInvoice.setCompanyNum(applQueryInvVo.getCompanyNum());
+                selfCarInvoice.setCustomerName(applQueryInvVo.getCustomId());
+                selfCarInvoice.setBuyerTaxpayerCode(customerRec.getCompanyReferencenum());
+                selfCarInvoice.setExStation(b2BInvoiceQueryByApplyModel.getExStationName());
+                selfCarInvoice.setEnStation(b2BInvoiceQueryByApplyModel.getEnStationName());
+                selfCarInvoice.setInvoiceMakeTime(DateUtil.tTimeToDate(selfCarInvoice.getInvoiceMakeTime()));
+                selfCarInvoice.setExTime(DateUtil.tTimeToDate(selfCarInvoice.getExTime()));
+                if(selfCarInvoiceMapper.selectByTradeAndInvoiceMakeTime(selfCarInvoice)==null || selfCarInvoiceMapper.selectByTradeAndInvoiceMakeTime(selfCarInvoice).size()==0){
+                    selfCarInvoiceMapper.insert(selfCarInvoice);
+                }
 
+            }
+        }
+    }
     @Override
     public RespR<List<B2BInvoiceListModel>> getSelfCarInvoicesByTime(SelfCarDueQueryVo selfCarDueQueryVo) {
         log.info("申请开票开始SelfCarServiceLImpl.getSelfCarInvoicesByTime{}",selfCarDueQueryVo);

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

@@ -73,69 +73,74 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
         StringBuffer stringBuffer = new StringBuffer();
         //保存批次号信息
         String batchNumber = customerOperService.saveCustomerOper(customerName,1);
-        noCarWayBills.parallelStream().forEach(noCarWayBill -> {
-            //根据税号,查询备案企业
-            CustomerRec customerRec = new CustomerRec();
-            customerRec.setCustomerName(customerName);
-            customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
-            customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
-            noCarWayBill.setCompanyName(customerRec.getCompanyName());
-            noCarWayBill.setCustomerName(customerName);
-            noCarWayBill.setBatchNum(batchNumber);
-            noCarWayBill.setBillwayStatus(-1);
-            noCarWayBill.setHisFlag(0);
-            noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
-            noCarWaybillMapperImprt.insertImport(noCarWayBill);
-            insertOrUpdateBill(noCarWayBill);
-            if(customerRec == null){
-                noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案",noCarWayBill);
-                noCarWayBill.setFailReason("企业税号未备案");
-                noCarWayBill.setBillwayStatus(-2);
-                insertOrUpdateBill(noCarWayBill);
-                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
-                return;
-            }
-            //1.查询是否有车辆备案
-            CustomerCarRec customerCarRec = customerCarRecMapper.selectByCarNum(noCarWayBill.getPlateColor());
-
-            //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.setBusinessType("2");
-                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);
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+                    //根据税号,查询备案企业
+                    CustomerRec customerRec = new CustomerRec();
+                    customerRec.setCustomerName(customerName);
+                    customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
+                    customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
+                    noCarWayBill.setCompanyName(customerRec.getCompanyName());
+                    noCarWayBill.setCustomerName(customerName);
+                    noCarWayBill.setBatchNum(batchNumber);
                     noCarWayBill.setBillwayStatus(-2);
-                    noCarWayBill.setFailReason(respR.getMsg());
+                    noCarWayBill.setHisFlag(0);
+                    noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
+                    noCarWaybillMapperImprt.insertImport(noCarWayBill);
                     insertOrUpdateBill(noCarWayBill);
-                    return;
-                }
-            }
+                    if(customerRec == null){
+                        noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案",noCarWayBill);
+                        noCarWayBill.setFailReason("企业税号未备案");
+                        noCarWayBill.setBillwayStatus(-2);
+                        insertOrUpdateBill(noCarWayBill);
+                        stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
+                        return;
+                    }
+                    //1.查询是否有车辆备案
+                    CustomerCarRec customerCarRec = customerCarRecMapper.selectByCarNum(noCarWayBill.getPlateColor());
+
+                    //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.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;
+                        }
+                    }
 
-            //3.进行上传
-            RespR respR = noCarService.noCarWaybillStart(noCarWayBill);
-            if (respR.getCode() == 1){
-                noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
-                noCarWayBill.setBillwayStatus(-2);
-                noCarWayBill.setFailReason(respR.getMsg());
-                insertOrUpdateBill(noCarWayBill);
-                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+                    //3.进行上传
+                    RespR respR = noCarService.noCarWaybillStart(noCarWayBill);
+                    if (respR.getCode() == 1){
+                        noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
+                        noCarWayBill.setBillwayStatus(-2);
+                        noCarWayBill.setFailReason(respR.getMsg());
+                        insertOrUpdateBill(noCarWayBill);
+                        stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+                    }
+                    noCarWaybillMapperImprt.updateBillway(1,"",noCarWayBill);
+                });
+                log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayStart:{}",stringBuffer.toString());
             }
-            noCarWaybillMapperImprt.updateBillway(1,"",noCarWayBill);
-        });
-        log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayStart:{}",stringBuffer.toString());
-        if(!StringUtils.isEmpty(stringBuffer.toString())){
-            return new RespR(false,stringBuffer.toString());
-        }
-        return new RespR(Boolean.TRUE);
+        }).start();
+
+
+        return new RespR("批次号:"+batchNumber);
     }
 
     @Override
@@ -146,98 +151,105 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
         StringBuffer stringBuffer = new StringBuffer();
         //保存批次号信息
         String batchNumber = customerOperService.saveCustomerOper(customerName,3);
-        noCarWayBills.parallelStream().forEach(noCarWayBill -> {
-            try {
-                log.info("kai shi chu li li si yun dan"+noCarWayBill.getBillNum());
-                //根据税号,查询备案企业
-                CustomerRec customerRec = new CustomerRec();
-                customerRec.setCustomerName(customerName);
-                customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
-                customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
-                noCarWayBill.setCompanyName(customerRec.getCompanyName());
-                noCarWayBill.setCustomerName(customerName);
-                noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
-                noCarWayBill.setBatchNum(batchNumber);
-                noCarWayBill.setTitleType(2);
-                noCarWayBill.setBillwayStatus(-1);
-                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);
-                    noCarWayBill.setBillwayStatus(-2);
-                    noCarWayBill.setFailReason("企业税号未备案");
-                    insertOrUpdateBill(noCarWayBill);
-                    return;
-                }
-
-                //1.查询是否有车辆备案
-                CustomerCarRec customerCarRec = customerCarRecMapper.selectByCarNum(noCarWayBill.getPlateNum());
-
-                //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.setBusinessType("2");
-                    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("#");
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+                    try {
+                        log.info("kai shi chu li li si yun dan"+noCarWayBill.getBillNum());
+                        //根据税号,查询备案企业
+                        CustomerRec customerRec = new CustomerRec();
+                        customerRec.setCustomerName(customerName);
+                        customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
+                        customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
+                        noCarWayBill.setCompanyName(customerRec.getCompanyName());
+                        noCarWayBill.setCustomerName(customerName);
+                        noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
+                        noCarWayBill.setBatchNum(batchNumber);
+                        noCarWayBill.setTitleType(2);
                         noCarWayBill.setBillwayStatus(-2);
-                        noCarWayBill.setFailReason(respR.getMsg());
+                        noCarWayBill.setHisFlag(1);
+                        noCarWaybillMapperImprt.insertImport(noCarWayBill);
                         insertOrUpdateBill(noCarWayBill);
-                        return;
-                    }
-                }
+                        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;
+                        }
 
-                //3.kais指令上传
-                NoCarWayBill noCarWayBillClo = null;
-                try{
-                    noCarWayBillClo = noCarWayBill.clone();
-                }catch (Exception e){
-                    e.printStackTrace();
-                    noCarWayBillClo = noCarWayBill;
-                }
+                        //1.查询是否有车辆备案
+                        CustomerCarRec customerCarRec = customerCarRecMapper.selectByCarNum(noCarWayBill.getPlateNum());
 
-                RespR respR = noCarService.noCarHisWaybillStart(noCarWayBill);
-                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);
-                    log.info(noCarWayBill.getBillNum()+"#开始指令失败"+respR.getMsg());
-                }else{
-                    log.info(noCarWayBill.getBillNum()+"#开始指令成功"+respR.getMsg());
-                    //3.kais指令上传
-                    respR = noCarService.noCarHisWaybillEnd(noCarWayBillClo);
-
-                    if(respR.getCode() == 1){
-                        noCarWaybillMapperImprt.updateBillway(1,respR.getMsg(),noCarWayBill);
-                        log.info(noCarWayBill.getBillNum()+"#结束指令失败"+respR.getMsg());
-                        stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
-                    }else{
-                        noCarWaybillMapperImprt.updateBillway(2,respR.getMsg(),noCarWayBill);
-                        log.info(noCarWayBill.getBillNum()+"#结束指令成功"+respR.getMsg());
+                        //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.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;
+                            }
+                        }
+
+                        //3.kais指令上传
+                        NoCarWayBill noCarWayBillClo = null;
+                        try{
+                            noCarWayBillClo = noCarWayBill.clone();
+                        }catch (Exception e){
+                            e.printStackTrace();
+                            noCarWayBillClo = noCarWayBill;
+                        }
+
+                        RespR respR = noCarService.noCarHisWaybillStart(noCarWayBill);
+                        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);
+                            log.info(noCarWayBill.getBillNum()+"#开始指令失败"+respR.getMsg());
+                        }else{
+                            log.info(noCarWayBill.getBillNum()+"#开始指令成功"+respR.getMsg());
+                            //3.kais指令上传
+                            respR = noCarService.noCarHisWaybillEnd(noCarWayBillClo);
+
+                            if(respR.getCode() == 1){
+                                noCarWaybillMapperImprt.updateBillway(1,respR.getMsg(),noCarWayBill);
+                                log.info(noCarWayBill.getBillNum()+"#结束指令失败"+respR.getMsg());
+                                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+                            }else{
+                                noCarWaybillMapperImprt.updateBillway(2,respR.getMsg(),noCarWayBill);
+                                log.info(noCarWayBill.getBillNum()+"#结束指令成功"+respR.getMsg());
+                            }
+                        }
+                        log.info("kai shi chu li li si yun dan"+noCarWayBill.getBillNum());
+                    }catch (Exception e){
+                        e.printStackTrace();
                     }
+
+
+                });
+                if(!StringUtils.isEmpty(stringBuffer.toString())){
+                    log.error(stringBuffer.toString());
                 }
-                log.info("kai shi chu li li si yun dan"+noCarWayBill.getBillNum());
-            }catch (Exception e){
-                e.printStackTrace();
             }
+        }).start();
 
-
-        });
-        if(!StringUtils.isEmpty(stringBuffer.toString())){
-            return new RespR(false,stringBuffer.toString());
-        }
-        return new RespR(Boolean.TRUE);
+        return new RespR("批次号:"+batchNumber);
     }
 
     @Override
@@ -249,31 +261,35 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
         StringBuffer stringBuffer = new StringBuffer();
         //保存批次号信息
         String batchNumber = customerOperService.saveCustomerOper(customerName,2);
+        new Thread(new Runnable() {
+            @Override
+            public void run() {
+                noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+                    try {
+                        noCarWayBill.setBatchNum(batchNumber);
+                        noCarWayBill.setBatchNumEnd(batchNumber);
+                        noCarWayBill.setHisFlag(0);
+                        noCarWaybillMapperImprt.insertImport(noCarWayBill);
+                        RespR respR = noCarService.noCarWaybillEnd(noCarWayBill);
+                        if (respR.getCode() == 1){
+                            noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
+                            stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+                        }else{
+                            noCarWaybillMapperImprt.updateBillway(2,respR.getMsg(),noCarWayBill);
+                        }
+                    }catch (Exception e){
+                        e.printStackTrace();
+                    }
+
+                });
 
-        noCarWayBills.parallelStream().forEach(noCarWayBill -> {
-            try {
-                noCarWayBill.setBatchNum(batchNumber);
-                noCarWayBill.setBatchNumEnd(batchNumber);
-                noCarWayBill.setHisFlag(0);
-                noCarWaybillMapperImprt.insertImport(noCarWayBill);
-                RespR respR = noCarService.noCarWaybillEnd(noCarWayBill);
-                if (respR.getCode() == 1){
-                    noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
-                    stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
-                }else{
-                    noCarWaybillMapperImprt.updateBillway(2,respR.getMsg(),noCarWayBill);
+                if(!StringUtils.isEmpty(stringBuffer.toString())){
+                    log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayEnd:{}",stringBuffer.toString());
                 }
-            }catch (Exception e){
-                e.printStackTrace();
             }
+        }).start();
 
-        });
-
-        if(!StringUtils.isEmpty(stringBuffer.toString())){
-            log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayEnd:{}",stringBuffer.toString());
-            return new RespR(false,stringBuffer.toString());
-        }
-        return new RespR(Boolean.TRUE);
+        return new RespR("批次号:"+batchNumber);
     }
 
 

+ 3 - 3
src/main/java/com/jkcredit/invoice/task/ScheduledBillTask.java

@@ -36,7 +36,7 @@ public class ScheduledBillTask {
     /**
      * 实时运单开票(每天23点开始)
      */
-    @Scheduled(cron = "0 0 0/1 * * ?", zone = "Asia/Shanghai")
+    @Scheduled(cron = "0 0 23 * * ?", zone = "Asia/Shanghai")
     public void updateNocarBillInfo() {
         try {
             delGetInvoce(0);
@@ -67,7 +67,7 @@ public class ScheduledBillTask {
         }
     }
 
-   /* @Scheduled(cron = "0 0 23 * * ?", zone = "Asia/Shanghai")
+   @Scheduled(cron = "0 0 23 * * ?", zone = "Asia/Shanghai")
     public void getSefCarInvoice() {
         try {
             List<SelfCarAppl> selfCarAppls = selfCarApplMapper.selectAllNoRec();
@@ -77,5 +77,5 @@ public class ScheduledBillTask {
         }catch (Exception e){
             e.printStackTrace();
         }
-    }*/
+    }
 }

+ 18 - 2
src/main/resources/application.yml

@@ -1,3 +1,4 @@
+
 server:
   port: 18080
   tomcat:
@@ -35,6 +36,9 @@ mybatis-plus:
   global-config:
     db-config:
       table-prefix: t_
+logging:
+  config: classpath:logback-spring.xml
+  path: d:/logs
 #  configuration:
 #    log-impl: org.apache.ibatis.logging.stdout.StdOutImpl
 #debug: true
@@ -45,16 +49,27 @@ spring:
   datasource:
     #url: jdbc:mysql://172.31.1.10:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
     #username: root
-    # password: Jkxy@mysql123
+    #password: Jkxy@mysql123
     #url: jdbc:mysql://127.0.0.1:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true&allowPublicKeyRetrieval=true
     #username: root
     #password: root
-    url: jdbc:mysql://192.168.50.88:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
+    url: jdbc:mysql://192.168.50.4:3306/db_invoice?characterEncoding=utf8&zeroDateTimeBehavior=convertToNull&useSSL=false&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=Asia/Shanghai&allowMultiQueries=true
     username: root
     password: jk@123
     driver-class-name: com.mysql.jdbc.Driver
     # \u4F7F\u7528druid\u6570\u636E\u6E90
     type: com.alibaba.druid.pool.DruidDataSource
+  mail:
+    host: smtp.qq.com #邮件发送服务器
+    port: 587
+    username: 862885632@qq.com
+    password: axlmfkdxmixjbchh
+    test-connection: true #测试连接
+    properties:
+      mail:
+        smtp:
+          auth: true
+          enable: true
   redis:
     host: 127.0.0.1
     port: 6379
@@ -138,3 +153,4 @@ spring:
         max-concurrency: 10
       direct:
         acknowledge-mode: manual
+

+ 2 - 2
src/main/resources/mapper/customer/CustomerRecMapper.xml

@@ -79,11 +79,11 @@
     </where>
     ORDER by customerName
   </select>
-  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
+  <select id="selectByPrimaryKey" resultMap="BaseResultMap" parameterType="java.lang.String" >
     select 
     <include refid="Base_Column_List" />
     from t_customer_rec
-    where id = #{id,jdbcType=INTEGER}
+    where company_num = #{id,jdbcType=INTEGER}
   </select>
   <select id="selectByPrimaryKeyHasBase64" resultMap="BaseResultMap" parameterType="java.lang.Integer" >
     select

+ 3 - 0
src/main/resources/mapper/invoice/SelfCarInvoiceMapper.xml

@@ -66,6 +66,9 @@
             <if test="selfCarInvoice.tradeId != null and selfCarInvoice.tradeId != ''">
                 and tradeId = #{selfCarInvoice.tradeId}
             </if>
+            <if test="selfCarInvoice.plateNum != null and selfCarInvoice.plateNum != ''">
+                and plateNum = #{selfCarInvoice.plateNum}
+            </if>
             <if test="selfCarInvoice.buyerTaxpayerCode != null and selfCarInvoice.buyerTaxpayerCode != ''">
                 and buyerTaxpayerCode = #{selfCarInvoice.buyerTaxpayerCode}
             </if>

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

@@ -110,6 +110,9 @@
             <if test="noCarWayBill.taxplayerCode != null and noCarWayBill.taxplayerCode != ''">
                 and taxplayerCode = #{noCarWayBill.taxplayerCode}
             </if>
+            <if test="noCarWayBill.billwayStatus != null and noCarWayBill.billwayStatus != ''">
+                and billwayStatus = #{noCarWayBill.billwayStatus}
+            </if>
             <if test="noCarWayBill.startBegin != null and noCarWayBill.startBegin != ''">
                 and intfaceStartTime BETWEEN #{noCarWayBill.startBegin} and #{noCarWayBill.startEnd}
             </if>

+ 1 - 1
src/main/resources/mapper/waybill/SellCarTradeMapper.xml

@@ -59,7 +59,7 @@
                 and aclTime BETWEEN #{sellCarTrade.aclTimeBegin} and #{sellCarTrade.aclTimeEnd}
             </if>
             <if test="sellCarTrade.exceptionFlag != null and sellCarTrade.exceptionFlag != ''">
-                and  now()>date_add(aclTime,interval 10 day) and status=2
+                and  now()>date_add(aclTime,interval 10 day) and (status=2 or status =1)
             </if>
         </where>
     </select>

+ 3 - 3
src/main/resources/sdk.properties

@@ -1,5 +1,5 @@
-dtsServiceURL=https://testdts.txffp.com
-tempPath=e:/dts/tmp
+dtsServiceURL=https://dts.txffp.com
+tempPath=/home/dts/tmp
 enableGzip=true
 enableEvent=false
-authStr=110017_C1nAi1nC0i
+authStr=119901_0061nnPiC2