|
@@ -21,6 +21,7 @@ import org.springframework.stereotype.Component;
|
|
|
import java.net.InetAddress;
|
|
|
import java.text.DateFormat;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.Arrays;
|
|
|
import java.util.Date;
|
|
|
import java.util.List;
|
|
|
|
|
@@ -58,9 +59,9 @@ public class ScheduledBillTask {
|
|
|
@Autowired
|
|
|
SelfCarTradeService selfCarTradeService;
|
|
|
/**
|
|
|
- * 实时运单开票(每天23点开始)
|
|
|
+ * 实时运单开票(每三小时开始)
|
|
|
*/
|
|
|
- @Scheduled(cron = "0 0 23 * * ?", zone = "Asia/Shanghai")
|
|
|
+ @Scheduled(cron = "0 0 0/3 * * ?", zone = "Asia/Shanghai")
|
|
|
public void updateNocarBillInfo() throws Exception{
|
|
|
InetAddress addr = InetAddress.getLocalHost();
|
|
|
String ip = paramService.getParamsByParamName("CURR_SELF_IP").getParamValue();
|
|
@@ -81,13 +82,36 @@ public class ScheduledBillTask {
|
|
|
public void delGetInvoce(Integer historyFlag){
|
|
|
NoCarWayBill carWayBill = new NoCarWayBill();
|
|
|
carWayBill.setHisFlag(historyFlag);
|
|
|
- carWayBill.setInterType(1);
|
|
|
carWayBill.setBillwayStatus(2);
|
|
|
List<NoCarWayBill> noCarWayBillsMdEnd = noCarWaybillMapper.selectByHisFlagAndBillStatus(carWayBill);
|
|
|
if(noCarWayBillsMdEnd!=null && noCarWayBillsMdEnd.size()>0){
|
|
|
- noCarWayBillsMdEnd.parallelStream().forEach(noCarWayBill -> {
|
|
|
- noCarService.getInvoiceByWayBillNumReal(noCarWayBill,false);
|
|
|
- });
|
|
|
+ int total = noCarWayBillsMdEnd.size();
|
|
|
+ log.info("实时取票数量"+total);
|
|
|
+ int pageSize =5000;
|
|
|
+ //线程去取
|
|
|
+ for(int page=0;page<=total/pageSize;page++){
|
|
|
+ List<NoCarWayBill> noCarWayBillsMdEndi = noCarWayBillsMdEnd.subList(page*pageSize,(page+1)*pageSize>total?total:(page+1)*pageSize);
|
|
|
+ if(noCarWayBillsMdEndi == null || noCarWayBillsMdEndi.size()==0){
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ new Thread(new Runnable() {
|
|
|
+ @Override
|
|
|
+ public void run() {
|
|
|
+ log.info("qupiaoshumu"+noCarWayBillsMdEndi.size());
|
|
|
+ for(NoCarWayBill noCarWayBill:noCarWayBillsMdEndi){
|
|
|
+ log.info("实时取票运单"+noCarWayBill.getBillNum());
|
|
|
+ try {
|
|
|
+ noCarService.getInvoiceByWayBillNumReal(noCarWayBill,false);
|
|
|
+ }catch (Exception e){
|
|
|
+ log.debug("取票失败"+noCarWayBill.getBillNum()+e.getMessage());
|
|
|
+ }
|
|
|
+ }
|
|
|
+ log.info("qupiaoshumujiesu"+noCarWayBillsMdEndi.size());
|
|
|
+ }
|
|
|
+ },"qupaioxiancheng"+page).start();
|
|
|
+ }
|
|
|
+
|
|
|
+ log.info("实时取票数量"+noCarWayBillsMdEnd.size()+"jiesula");
|
|
|
}
|
|
|
}
|
|
|
/**
|
|
@@ -164,4 +188,15 @@ public class ScheduledBillTask {
|
|
|
e.printStackTrace();
|
|
|
}*/
|
|
|
}
|
|
|
+ public static void main(String [] args){
|
|
|
+ List<Integer> list = Arrays.asList(new Integer[]{0,1,2,3,4,5,6,8,9,10,11,12,13,14,15});
|
|
|
+ int total= list.size();
|
|
|
+ int pageSize =3;
|
|
|
+ //分四个线程去取
|
|
|
+ for(int page=0;page<=total/pageSize;page++){
|
|
|
+ List<Integer> noCarWayBillsMdEndi = list.subList(page*pageSize,(page+1)*pageSize>total?total:(page+1)*pageSize);
|
|
|
+ System.out.print(noCarWayBillsMdEndi.toString()+"\n");
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
}
|