Selaa lähdekoodia

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

Administrator 2 vuotta sitten
vanhempi
commit
18e7155e76

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

@@ -15,6 +15,7 @@ import com.jkcredit.invoice.service.customer.CustomerService;
 import com.jkcredit.invoice.service.lowerservice.NoCarService;
 import com.jkcredit.invoice.service.nocar.NoCarBillWayImportService;
 import com.jkcredit.invoice.service.nocar.NoCarBillWayService;
+import com.jkcredit.invoice.service.thead.ThreadPoolFactory;
 import com.jkcredit.invoice.util.DateUtil;
 import com.jkcredit.invoice.util.RespR;
 import lombok.extern.slf4j.Slf4j;
@@ -25,13 +26,13 @@ import org.springframework.util.StringUtils;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
-
-import static com.jkcredit.invoice.common.CommonConst.*;
-
+import java.util.concurrent.ExecutorService;
 @Service
 @Slf4j
 public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCarWayBill> implements NoCarBillWayService{
 
+   public  static ExecutorService executorService = ThreadPoolFactory.getThreadPool("batchBillWayStart",5,10);
+
     @Autowired
     NoCarWaybillMapper noCarWaybillMapper;
 
@@ -83,203 +84,211 @@ public class NoCarBillWayServiceImpl extends ServiceImpl<NoCarWaybillMapper,NoCa
         StringBuffer stringBuffer = new StringBuffer();
         //保存批次号信息
         String batchNumber = customerOperService.saveCustomerOper(customerName,1);
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+        executorService.execute(()->{
+            noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+            //根据税号,查询备案企业
+            CustomerRec customerRec = new CustomerRec();
+            customerRec.setCustomerName(customerName);
+            customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
+            noCarWayBill.setBatchNum(batchNumber);
+            noCarWayBill.setCustomerName(customerName);
+            noCarWayBill.setBillwayStatus(-2);
+            noCarWayBill.setHisFlag(0);
+            noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
+            noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
+            noCarWaybillMapperImprt.insertImport(noCarWayBill);
+            customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
+            if(customerRec == null){
+                noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案",noCarWayBill);
+                noCarWayBill.setFailReason("企业税号未备案");
+                noCarWayBill.setBillwayStatus(-2);
+                insertOrUpdateBillStart(noCarWayBill);
+                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
+                return;
+            }
+            noCarWayBill.setCompanyName(customerRec.getCompanyName());
+            noCarWayBill.setCompanyNum(customerRec.getCompanyNum());
+            if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date())<-72){
+                noCarWaybillMapperImprt.updateBillway(-2,"失败,运单开始时间超72小时#",noCarWayBill);
+                noCarWayBill.setBillwayStatus(-2);
+                noCarWayBill.setFailReason("失败,运单开始时间超72小时");
+                insertOrUpdateBillStart(noCarWayBill);
+                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.setCustomerName(customerName);
+            customerCarRec.setInterType(1);
+            customerCarRec.setCompanyNum(customerRec.getCompanyNum());
+            customerCarRec.setBusinessType("2");
+            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){
+                    stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+                    noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
+                    noCarWayBill.setBillwayStatus(-2);
+                    noCarWayBill.setFailReason(respR.getMsg());
+                    insertOrUpdateBillStart(noCarWayBill);
+                    return;
+                }
+            }
+
+
+
+            //3.进行上传
+            RespR respR = noCarService.noCarWaybillStart(noCarWayBill);
+            if (respR.getCode() == 1){
+                noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
+                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
+            }else{
+                noCarWaybillMapperImprt.updateBillway(1,"",noCarWayBill);
+                return;
+            }
+
+        });
+        log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayStart:{}",stringBuffer.toString());
+        });
+        return new RespR("批次号:"+batchNumber);
+    }
+
+    @Override
+    public RespR batchHsitoryBillWay(List<NoCarWayBill> noCarWayBills, String customerName){
+        if(!customerService.checkMoneyEnough(customerName)){
+            return new RespR(false,"余额不足");
+        }
+        StringBuffer stringBuffer = new StringBuffer();
+        //保存批次号信息
+        String batchNumber = customerOperService.saveCustomerOper(customerName,3);
+        executorService.execute(()->{
+            noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+                try {
+                    log.info("开始处理历史运单:"+noCarWayBill.getBillNum());
                     //根据税号,查询备案企业
                     CustomerRec customerRec = new CustomerRec();
                     customerRec.setCustomerName(customerName);
                     customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
-                    noCarWayBill.setBatchNum(batchNumber);
-                    noCarWayBill.setCustomerName(customerName);
-                    noCarWayBill.setBillwayStatus(-2);
-                    noCarWayBill.setHisFlag(0);
+                    customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
                     noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
+                    noCarWayBill.setInterfaceEndTime(DateUtil.getCurrentDateStr());
                     noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
+                    noCarWayBill.setBatchNum(batchNumber);
+                    noCarWayBill.setTitleType(2);
+                    noCarWayBill.setBillwayStatus(-2);
+                    noCarWayBill.setHisFlag(1);
+                    noCarWayBill.setCustomerName(customerName);
                     noCarWaybillMapperImprt.insertImport(noCarWayBill);
-                    customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
-                    if(customerRec == null){
-                        noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案",noCarWayBill);
-                        noCarWayBill.setFailReason("企业税号未备案");
+                    if(customerRec == null || customerRec.getRecStatus()!=1){
+                        stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
+                        noCarWaybillMapperImprt.updateBillway(-2,"企业税号未备案#",noCarWayBill);
                         noCarWayBill.setBillwayStatus(-2);
+                        noCarWayBill.setFailReason("企业税号未备案");
                         insertOrUpdateBillStart(noCarWayBill);
-                        stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append("企业税号未备案#");
                         return;
                     }
                     noCarWayBill.setCompanyName(customerRec.getCompanyName());
                     noCarWayBill.setCompanyNum(customerRec.getCompanyNum());
-                    if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),new Date()) < INTONE){
-                        noCarWaybillMapperImprt.updateBillway(-2,"失败,运单开始时间超72小时#",noCarWayBill);
+                    if(DateUtil.getDistanceDays(noCarWayBill.getStartTime(),new Date())>-20){
+                        log.info("历史运单开始上传失败:NoCarServiceImpl.noCarHisWaybillStart{},msg{}",noCarWayBill,"必须是二十天前的运单");
                         noCarWayBill.setBillwayStatus(-2);
-                        noCarWayBill.setFailReason("失败,运单开始时间超72小时");
+                        noCarWayBill.setFailReason("失败,运单未满20天时效");
+                        noCarWaybillMapperImprt.updateBillway(-2,"失败,运单未满20天时效#",noCarWayBill);
                         insertOrUpdateBillStart(noCarWayBill);
                         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.setCustomerName(customerName);
-                        customerCarRec.setInterType(1);
-                        customerCarRec.setCompanyNum(customerRec.getCompanyNum());
-                        customerCarRec.setBusinessType("2");
-                        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){
-                                stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
-                                noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
-                                noCarWayBill.setBillwayStatus(-2);
-                                noCarWayBill.setFailReason(respR.getMsg());
-                                insertOrUpdateBillStart(noCarWayBill);
-                                return;
-                            }
-                        }
-                    //3.进行上传
-                    RespR respR = noCarService.noCarWaybillStart(noCarWayBill);
-                    if (respR.getCode() == 1){
-                        noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
-                        stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
-                    }else{
-                        noCarWaybillMapperImprt.updateBillway(1,"",noCarWayBill);
+                    if(DateUtil.getDistanceHours(noCarWayBill.getStartTime(),DateUtil.stringToDate(noCarWayBill.getPredictEndTime()))<-96){
+                        noCarWayBill.setBillwayStatus(-2);
+                        noCarWayBill.setFailReason("运单已经超时,请拆分");
+                        insertOrUpdateBillStart(noCarWayBill);
+                        noCarWaybillMapperImprt.updateBillway(-2,"运单已经超时,请拆分#",noCarWayBill);
+                        log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
                         return;
                     }
-                });
-                log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayStart:{}",stringBuffer.toString());
-            }
-        }).start();
-        return new RespR("批次号:"+batchNumber);
-    }
+                    //1.查询是否有车辆备案 /
+                    CustomerCarRec customerCarRec;
 
-    @Override
-    public RespR batchHsitoryBillWay(List<NoCarWayBill> noCarWayBills, String customerName){
-        if(!customerService.checkMoneyEnough(customerName)){
-            return new RespR(false,"余额不足");
-        }
-        StringBuffer stringBuffer = new StringBuffer();
-        //保存批次号信息
-        String batchNumber = customerOperService.saveCustomerOper(customerName,3);
-        new Thread(new Runnable() {
-            @Override
-            public void run() {
-                noCarWayBills.parallelStream().forEach(noCarWayBill -> {
-                    try {
-                        log.info("开始处理历史运单:"+noCarWayBill.getBillNum());
-                        //根据税号,查询备案企业
-                        CustomerRec customerRec = new CustomerRec();
-                        customerRec.setCustomerName(customerName);
-                        customerRec.setCompanyReferencenum(noCarWayBill.getTaxplayerCode());
-                        customerRec = customerRecMapper.selectByCustomerNameAndCompanyReference(customerRec);
-                        noCarWayBill.setIntfaceStartTime(DateUtil.getCurrentDateStr());
-                        noCarWayBill.setInterfaceEndTime(DateUtil.getCurrentDateStr());
-                        noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
-                        noCarWayBill.setBatchNum(batchNumber);
-                        noCarWayBill.setTitleType(2);
-                        noCarWayBill.setBillwayStatus(-2);
-                        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);
-                            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){
+                    //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("运单已经超时,请拆分");
+                            noCarWayBill.setFailReason(respR.getMsg());
                             insertOrUpdateBillStart(noCarWayBill);
-                            noCarWaybillMapperImprt.updateBillway(-2,"运单已经超时,请拆分#",noCarWayBill);
-                            log.info("运单结束失败:NoCarServiceImpl.noCarWaybillStart{},msg{}",noCarWayBill,"运单已经超时,请拆分");
                             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{
+                        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());
+                        insertOrUpdateBillStart(noCarWayBill);
+                        log.info(noCarWayBill.getBillNum()+"#开始指令失败"+respR.getMsg());
+                    }else{
+                        log.info(noCarWayBill.getBillNum()+"#开始指令成功"+respR.getMsg());
                         //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){
+                        respR = noCarService.noCarHisWaybillEnd(noCarWayBillClo);
+
+                        if(respR.getCode() == 1){
+                            noCarWaybillMapperImprt.updateBillway(-3,respR.getMsg(),noCarWayBill);
+                            log.info(noCarWayBill.getBillNum()+"#结束指令失败"+respR.getMsg());
                             stringBuffer.append("#").append(noCarWayBill.getBillNum()).append(":").append(respR.getMsg()).append("#");
-                            noCarWaybillMapperImprt.updateBillway(-2,respR.getMsg(),noCarWayBill);
-                            noCarWayBill.setBillwayStatus(-2);
-                            noCarWayBill.setFailReason(respR.getMsg());
-                            insertOrUpdateBillStart(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(-3,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());
-                            }
+                            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();
                 }
+
+
+            });
+            if(!StringUtils.isEmpty(stringBuffer.toString())){
+                log.error(stringBuffer.toString());
             }
-        }).start();
+        });
         return new RespR("批次号:"+batchNumber);
     }
 
@@ -292,37 +301,33 @@ 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.setInterfaceEndTime(DateUtil.getCurrentDateStr());
-                        noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
-                        noCarWayBill.setHisFlag(0);
-                        noCarWaybillMapperImprt.insertImport(noCarWayBill);
-                        RespR respR = noCarService.noCarWaybillEnd(noCarWayBill);
-                        noCarWayBill.setBillNum(batchNumber);
-                        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();
+        executorService.execute(()->{
+            noCarWayBills.parallelStream().forEach(noCarWayBill -> {
+                try {
+                    noCarWayBill.setBatchNum(batchNumber);
+                    noCarWayBill.setBatchNumEnd(batchNumber);
+                    noCarWayBill.setInterfaceEndTime(DateUtil.getCurrentDateStr());
+                    noCarWayBill.setUpdateTime(DateUtil.getCurrentDateStr());
+                    noCarWayBill.setHisFlag(0);
+                    noCarWaybillMapperImprt.insertImport(noCarWayBill);
+                    RespR respR = noCarService.noCarWaybillEnd(noCarWayBill);
+                    noCarWayBill.setBillNum(batchNumber);
+                    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();
+                }
 
-                });
+            });
 
-                if(!StringUtils.isEmpty(stringBuffer.toString())){
-                    log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayEnd:{}",stringBuffer.toString());
-                }
+            if(!StringUtils.isEmpty(stringBuffer.toString())){
+                log.error("开始平台指令上传失败NoCarBillWayServiceImpl.batchBillWayEnd:{}",stringBuffer.toString());
             }
-        }).start();
-
+        });
         return new RespR("批次号:"+batchNumber);
     }