package com.jkcredit.invoice.credit.custInterface; import cn.com.taiji.sdk.model.comm.protocol.tts.trade.service.CardTradeModel; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.jkcredit.invoice.common.DataResult; import com.jkcredit.invoice.mapper.Binvoce.BillInvoiceMapper; import com.jkcredit.invoice.mapper.customer.CustomerCarRecMapper; import com.jkcredit.invoice.mapper.customer.CustomerMapper; import com.jkcredit.invoice.mapper.customer.CustomerRecMapper; import com.jkcredit.invoice.mapper.waybill.NoCarWaybillMapper; import com.jkcredit.invoice.model.entity.customer.Customer; import com.jkcredit.invoice.model.entity.customer.CustomerCarRec; import com.jkcredit.invoice.model.entity.customer.CustomerRec; import com.jkcredit.invoice.model.entity.invoice.BillInvoice; import com.jkcredit.invoice.model.entity.manager.Param; import com.jkcredit.invoice.model.entity.waybill.NoCarWayBill; import com.jkcredit.invoice.service.lowerService.NoCarService; import com.jkcredit.invoice.service.lowerService.SelfCarServiceL; import com.jkcredit.invoice.service.lowerService.vo.*; import com.jkcredit.invoice.service.manager.ParamService; import com.jkcredit.invoice.service.nocar.NoCarBillWayImportService; import com.jkcredit.invoice.util.DateUtil; import com.jkcredit.invoice.util.RespR; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import java.util.ArrayList; import java.util.List; import static java.util.stream.Collectors.toList; @Slf4j @Service("noCarInterService") public class NoCarInterServiceImpl implements NoCarInterService { @Autowired private NoCarService noCarService; @Autowired NoCarBillWayImportService noCarWaybillMapperImprt; @Autowired CustomerCarRecMapper customerCarRecMapper; @Autowired NoCarWaybillMapper noCarWaybillMapper; @Autowired CustomerRecMapper customerRecMapper; @Autowired BillInvoiceMapper billInvoiceMapper; @Autowired CustomerMapper customerMapper; @Autowired ParamService paramService; /** * 无车 车辆备案接口 * @param appKey * @param api * @param data * @return */ @Override public DataResult customerCarRec(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.customerCarRec-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); JSONObject jsonObject = JSONObject.parseObject(data); String companyName = jsonObject.getString("companyName");//企业名称 选输 String plateNumber = jsonObject.getString("plateNumber");//plateNumber 必输 String plateColor = jsonObject.getString("plateColor");//plateColor 必输 if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(plateNumber) || StringUtils.isEmpty(plateColor) ){ return result; } List customerCarRecList = new ArrayList(); CustomerCarRec customerCarRec = new CustomerCarRec(); customerCarRec.setCustomerName(appKey); if(StringUtils.isEmpty(companyName)){ String companyNum = paramService.getParamsByParamName("REQUEST_COMPANY_NUM").getParamValue(); String appKeyDemo = paramService.getParamsByParamName("REQUEST_COMPANY_NAME").getParamValue(); CustomerRec customerRec = new CustomerRec(); customerRec.setCustomerName(appKeyDemo); customerRec.setCompanyNum(companyNum); CustomerRec customerRec1 = customerRecMapper.selectByCustomerNameAndCompanyNum(customerRec); customerCarRec.setCompanyName(customerRec1.getCompanyName()); customerCarRec.setCustomerName(appKeyDemo); }else { customerCarRec.setCompanyName(companyName); } customerCarRec.setBusinessType("2");//无车 customerCarRec.setCarColor(plateColor); customerCarRec.setCarNum(plateNumber); customerCarRec.setInterType(0); if("0".equals(customerCarRec.getCarColor())){ customerCarRec.setServiceOperation(1);//默认运营车辆 } customerCarRecList.add(customerCarRec); RespR rs = noCarService.customerCarRec(customerCarRecList); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.customerCarRec-] result is " + rs.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != rs && rs.getCode() == 0){ result.setData(1); result.setCode(200); result.setMsg(rs.getData().toString()); return result; } else { result.setData(3); result.setCode(200); result.setMsg(rs.getMsg()); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.customerCarRec-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 车辆备案查询接口 * @param appKey * @param api * @param data * @return */ @Override public DataResult customeRecUpperQuery(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.customeRecUpperQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); JSONObject jsonObject = JSONObject.parseObject(data); String waybillSource = jsonObject.getString("waybillSource");//备案来源 选输 String plateNumber = jsonObject.getString("plateNumber");//plateNumber 必输 String plateColor = jsonObject.getString("plateColor");//plateColor 必输 if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(plateNumber) || StringUtils.isEmpty(plateColor) ){ return result; } CustomerCarRec customerCarRec = new CustomerCarRec(); Param param = paramService.getParamsByParamName("REQUEST_COMPANY_NUM"); customerCarRec.setCompanyNum(param.getParamValue());//无车,车辆备案,运单上传,运单查询都是统一用交科的企业编号;自有车用客户的企业编号 customerCarRec.setCarColor(plateColor); customerCarRec.setCarNum(plateNumber); customerCarRec.setCustomerName(appKey); RespR rs = noCarService.customerCarRecQueryUpper(customerCarRec); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.customeRecUpperQuery-] result is " + rs.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != rs && rs.getCode() == 0){ result.setData(1); result.setCode(200); result.setMsg(rs.getData().toString()); JSONObject jb = JSONObject.parseObject(rs.getData().toString()); if(null == jb.getJSONArray("result") || jb.getJSONArray("result").size() == 0){ result.setData(2); result.setMsg("车辆未备案"); } return result; } else { result.setData(3); result.setCode(200); result.setMsg(rs.getMsg()); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.customeRecUpperQuery-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 实时运单开始指令接口 * @param appKey * @param api * @param data * @return */ @Override public DataResult noCarBillStart(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.noCarBillStart-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); JSONObject jsonObject = JSONObject.parseObject(data); String num = jsonObject.getString("num");//运单编号 必选 String plateNumber = jsonObject.getString("plateNumber");//车牌号 必选 String plateColor = jsonObject.getString("plateColor");//车牌颜色 必选 String startTime = jsonObject.getString("startTime");//运单开始时间 必选 String sourceAddr = jsonObject.getString("sourceAddr");//运单开始地址 必选 String destAddr = jsonObject.getString("destAddr");//运单目的地址 必选 String predictEndTime = jsonObject.getString("predictEndTime");//运单预计完成时间 必选 Integer fee = jsonObject.getInteger("fee");//运单费用 必选 Integer titleType = jsonObject.getInteger("titleType");//发票抬头类型 必选 String taxplayerCode = jsonObject.getString("taxplayerCode");//税号 必选 if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(num) || StringUtils.isEmpty(plateNumber) || StringUtils.isEmpty(plateColor) || StringUtils.isEmpty(startTime) || StringUtils.isEmpty(sourceAddr) || StringUtils.isEmpty(destAddr) || StringUtils.isEmpty(predictEndTime) || null == fee || null == titleType || StringUtils.isEmpty(taxplayerCode) ){ return result; } CustomerCarRec customerCarRec1 = customerCarRecMapper.selectByCarNum(plateNumber); if (null == customerCarRec1){ return result; } NoCarWayBill noCarWayBill = new NoCarWayBill(); noCarWayBill.setCustomerName(appKey); noCarWayBill.setCompanyName(customerCarRec1.getCompanyName()); noCarWayBill.setPlateNum(plateNumber); noCarWayBill.setBillNum(num); noCarWayBill.setPlateColor(plateColor); noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime)); noCarWayBill.setSourceAddr(sourceAddr); noCarWayBill.setDestAddr(destAddr); noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime)); noCarWayBill.setFee(fee.longValue()); noCarWayBill.setTitleType(titleType); noCarWayBill.setTaxplayerCode(taxplayerCode); NoCarWayBill noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum()); if(noCarWayBillDb!=null && (noCarWayBillDb.getBillwayStatus() == 1||noCarWayBillDb.getBillwayStatus() == 2 || noCarWayBillDb.getBillwayStatus() == 3 || noCarWayBillDb.getBillwayStatus() == 4)) { noCarWaybillMapperImprt.updateBillway(-2, "失败,运单号重复", noCarWayBill); } RespR rs = noCarService.noCarWaybillStart(noCarWayBill); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.noCarBillStart-] result is " + rs.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != rs && rs.getCode() == 0){ result.setData(1); result.setCode(200); result.setMsg(rs.getData().toString()); return result; } else { result.setData(3); result.setCode(200); result.setMsg(rs.getMsg()); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.noCarBillStart-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 实时运单结束指令接口 * @param appKey * @param api * @param data * @return */ @Override public DataResult noCarBillEnd(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.noCarBillEnd-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); JSONObject jsonObject = JSONObject.parseObject(data); String num = jsonObject.getString("num");//运单号 必输 String realDestAddr = jsonObject.getString("realDestAddr");//运单实际目的地址 必输 String endTime = jsonObject.getString("endTime");//运单实际结束时间 必输 if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(num) || StringUtils.isEmpty(realDestAddr) || StringUtils.isEmpty(endTime) ){ return result; } NoCarWayBill noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num); if (null == noCarWayBill1){ result.setMsg("运单开始指令还未上传!"); return result; } NoCarWayBill noCarWayBill = new NoCarWayBill(); noCarWayBill.setBillNum(num); noCarWayBill.setDestAddr(realDestAddr); noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(endTime)); noCarWayBill.setStartTime(noCarWayBill1.getStartTime()); noCarWayBill.setHisFlag(noCarWayBill1.getHisFlag()); RespR rs = noCarService.noCarWaybillEnd(noCarWayBill); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.noCarBillEnd-] result is " + rs.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != rs && rs.getCode() == 0){ result.setData(1); result.setCode(200); result.setMsg(rs.getData().toString()); return result; } else { result.setData(3); result.setCode(200); result.setMsg(rs.getMsg()); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.noCarBillEnd-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 历史运单开始指令接口 * @param appKey * @param api * @param data * @return */ @Override public DataResult noCarHisWaybillStart(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.noCarHisWaybillStart-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); JSONObject jsonObject = JSONObject.parseObject(data); String num = jsonObject.getString("num");//运单编号 必选 String plateNumber = jsonObject.getString("plateNumber");//车牌号 必选 String plateColor = jsonObject.getString("plateColor");//车牌颜色 必选 String startTime = jsonObject.getString("startTime");//运单开始时间 必选 String sourceAddr = jsonObject.getString("sourceAddr");//运单开始地址 必选 String destAddr = jsonObject.getString("destAddr");//运单目的地址 必选 String predictEndTime = jsonObject.getString("predictEndTime");//运单预计完成时间 必选 Integer fee = jsonObject.getInteger("fee");//运单费用 必选 Integer titleType = jsonObject.getInteger("titleType");//发票抬头类型 必选 String taxplayerCode = jsonObject.getString("taxplayerCode");//税号 必选 if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(num) || StringUtils.isEmpty(plateNumber) || StringUtils.isEmpty(plateColor) || StringUtils.isEmpty(startTime) || StringUtils.isEmpty(sourceAddr) || StringUtils.isEmpty(destAddr) || StringUtils.isEmpty(predictEndTime) || null == fee || null == titleType || StringUtils.isEmpty(taxplayerCode) ){ return result; } CustomerCarRec customerCarRec1 = customerCarRecMapper.selectByCarNum(plateNumber); if (null == customerCarRec1){ return result; } NoCarWayBill noCarWayBill = new NoCarWayBill(); noCarWayBill.setCustomerName(appKey); noCarWayBill.setCompanyName(customerCarRec1.getCompanyName()); noCarWayBill.setPlateNum(plateNumber); noCarWayBill.setBillNum(num); noCarWayBill.setPlateColor(plateColor); noCarWayBill.setStartTime(DateUtil.getDistanceHoursFormat(startTime)); noCarWayBill.setSourceAddr(sourceAddr); noCarWayBill.setDestAddr(destAddr); noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(predictEndTime)); noCarWayBill.setFee(fee.longValue()); noCarWayBill.setTitleType(titleType); noCarWayBill.setTaxplayerCode(taxplayerCode); NoCarWayBill noCarWayBillDb = noCarWaybillMapper.selectByBillNum(noCarWayBill.getBillNum()); if(noCarWayBillDb!=null && (noCarWayBillDb.getBillwayStatus() == 1||noCarWayBillDb.getBillwayStatus() == 2 || noCarWayBillDb.getBillwayStatus() == 3 || noCarWayBillDb.getBillwayStatus() == 4)) { noCarWaybillMapperImprt.updateBillway(-2, "失败,运单号重复", noCarWayBill); } RespR rs = noCarService.noCarHisWaybillStart(noCarWayBill); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.noCarHisWaybillStart-] result is " + rs.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != rs && rs.getCode() == 0){ result.setData(1); result.setCode(200); result.setMsg(rs.getData().toString()); return result; } else { result.setData(3); result.setCode(200); result.setMsg(rs.getMsg()); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.noCarHisWaybillStart-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 历史运单结束指令接口 * @param appKey * @param api * @param data * @return */ @Override public DataResult noCarHisWaybillEnd(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); JSONObject jsonObject = JSONObject.parseObject(data); String num = jsonObject.getString("num");//运单号 必输 String realDestAddr = jsonObject.getString("realDestAddr");//运单实际目的地址 必输 String endTime = jsonObject.getString("endTime");//运单实际结束时间 必输 if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(num) || StringUtils.isEmpty(realDestAddr) || StringUtils.isEmpty(endTime) ){ return result; } NoCarWayBill noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num); if (null == noCarWayBill1){ return result; } NoCarWayBill noCarWayBill = new NoCarWayBill(); noCarWayBill.setBillNum(num); noCarWayBill.setDestAddr(realDestAddr); noCarWayBill.setPredictEndTime(DateUtil.getDistanceHoursFormat(endTime)); noCarWayBill.setStartTime(noCarWayBill1.getStartTime()); noCarWayBill.setHisFlag(noCarWayBill1.getHisFlag()); RespR rs = noCarService.noCarHisWaybillEnd(noCarWayBill); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] result is " + rs.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != rs && rs.getCode() == 0){ result.setData(1); result.setCode(200); result.setMsg(rs.getData().toString()); return result; } else { result.setData(3); result.setCode(200); result.setMsg(rs.getMsg()); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.noCarHisWaybillEnd-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 运单号查询发票数据 * @param appKey * @param api * @param data * @return */ @Override public DataResult noCarVoiceQuery(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.noCarVoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); JSONObject jsonObject = JSONObject.parseObject(data); String num = jsonObject.getString("num");//运单号 必输 if(StringUtils.isEmpty(data)|| null == jsonObject || StringUtils.isEmpty(num) ){ return result; } NoCarWayBill noCarWayBill1 = noCarWaybillMapper.selectByBillNum(num); if (null == noCarWayBill1){ result.setMsg("运单号异常,无法开票"); return result; } NoCarWayBill noCarWayBill = new NoCarWayBill(); noCarWayBill.setBillNum(num); noCarWayBill.setCustomerName(appKey); noCarWayBill.setCompanyName(noCarWayBill1.getCompanyName()); noCarWayBill.setPlateNum(noCarWayBill1.getPlateNum()); noCarWayBill.setInterType(0);//接口 RespR rs = noCarService.getInvoiceByWayBillNumReal(noCarWayBill,true); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.noCarVoiceQuery-] result is " + rs.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != rs && rs.getCode() == 0){ result.setData(1); result.setCode(200); result.setMsg(rs.getData().toString()); return result; } else { result.setData(3); result.setCode(200); result.setMsg(rs.getMsg()); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.noCarVoiceQuery-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 获取未查询过发票的运单编号 * @param appKey * @param api * @param data * @return */ @Override public DataResult noCarNoVoiceQuery(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); List noCarWayBills = noCarWaybillMapper.getNoCarNoVoiceQuery(appKey); List list1 = new ArrayList(); for (NoCarWayBill noCarWayBill:noCarWayBills ) { list1.add(noCarWayBill.getBillNum()); } List billInvoices = billInvoiceMapper.selectNoCarNoVoiceQuery(appKey); List list2 = new ArrayList(); for (BillInvoice billInvoice:billInvoices ) { list2.add(billInvoice.getWaybillNum()); } List reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList()); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] result is " + reduce1.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != reduce1 && reduce1.size() > 0){ result.setData(1); result.setCode(200); result.setMsg(reduce1.toString()); return result; } else { result.setData(2); result.setCode(200); result.setMsg("未查得"); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.noCarNoVoiceQuery-] get httpclient exception is " + e + ", request is " + data); } return result; } /** * 无车 账户余额查询接口 * @param appKey * @param api * @param data * @return */ @Override public DataResult balanceQuery(String appKey, String api, String data,String requestid) { long costtimestart = System.currentTimeMillis(); DataResult result = new DataResult(); result.setData(3); result.setCode(200); result.setRequestid(requestid); result.setMsg("无法认证"); try { log.info("[-NoCarInterServiceImpl.balanceQuery-] request appKey=" + appKey + " ,api=" + api + " ,data=" +data); Customer customer = customerMapper.selectByCustomerName(appKey); long costtimeend = System.currentTimeMillis(); log.info("[-NoCarInterServiceImpl.balanceQuery-] result is " + customer.toString() + ", request is " + data + " ,costtime=" + (costtimeend - costtimestart)); if(null != customer){ result.setData(1); result.setCode(200); JSONObject jb = new JSONObject(); jb.put("balance",customer.getAccountBalance()); jb.put("lastDeductionTime",customer.getInvoiceTime()); result.setMsg(jb.toString()); return result; } else { result.setData(3); result.setCode(200); result.setMsg("无法认证"); return result; } } catch (Exception e) { log.error("[-NoCarInterServiceImpl.balanceQuery-] get httpclient exception is " + e + ", request is " + data); } return result; } public static void main(String[] args) { List list1 = new ArrayList(); list1.add("1"); list1.add("2"); list1.add("3"); list1.add("5"); list1.add("6"); List list2 = new ArrayList(); list2.add("2"); list2.add("3"); list2.add("7"); list2.add("8"); // 交集 List intersection = list1.stream().filter(item -> list2.contains(item)).collect(toList()); System.out.println("---交集 intersection---"); intersection.parallelStream().forEach(System.out :: println); // 差集 (list1 - list2) List reduce1 = list1.stream().filter(item -> !list2.contains(item)).collect(toList()); System.out.println("---差集 reduce1 (list1 - list2)---"); reduce1.parallelStream().forEach(System.out :: println); // 并集 List listAll = list1.parallelStream().collect(toList()); List listAll2 = list2.parallelStream().collect(toList()); listAll.addAll(listAll2); System.out.println("---并集 listAll---"); listAll.parallelStream().forEachOrdered(System.out :: println); // 去重并集 List listAllDistinct = listAll.stream().distinct().collect(toList()); System.out.println("---得到去重并集 listAllDistinct---"); listAllDistinct.parallelStream().forEachOrdered(System.out :: println); System.out.println("---原来的List1---"); list1.parallelStream().forEachOrdered(System.out :: println); System.out.println("---原来的List2---"); list2.parallelStream().forEachOrdered(System.out :: println); } }