| | |
| | | public void importExpress(String url) { |
| | | URL url1 = new URL(url); |
| | | try (InputStream fileInputStream = url1.openStream()) { |
| | | Workbook workbook = new SXSSFWorkbook(new XSSFWorkbook(fileInputStream)); |
| | | Workbook workbook = new XSSFWorkbook(fileInputStream); |
| | | Sheet sheet = workbook.getSheetAt(0); // 获取第一个Sheet |
| | | int lastRowNum = sheet.getLastRowNum(); |
| | | for (int i = 2; i <= lastRowNum; i++) { |
| | | Row row = sheet.getRow(i); |
| | | row.getCell(1).setCellType(CellType.STRING); |
| | | String orderNum = row.getCell(1).getStringCellValue(); |
| | | // 快递单号 |
| | | row.getCell(7).setCellType(CellType.STRING); |
| | |
| | | String cityCode = row.getCell(12).getStringCellValue(); |
| | | Order order = this.getOne(new LambdaQueryWrapper<Order>() |
| | | .eq(Order::getOrderNumber, orderNum) |
| | | .eq(Order::getOrderType, 2) |
| | | .eq(Order::getDistributionMode,2) |
| | | .eq(Order::getOrderStatus, 1) |
| | | ); |
| | | if (order == null){ |
| | | throw new ServiceException("订单不存在:"+orderNum, 500); |
| | | } |
| | | |
| | | Integer orderType = order.getOrderType(); |
| | | if (orderType != 2){ |
| | | throw new ServiceException("该订单:"+orderNum+"类型不为单品订单", 500); |
| | | } |
| | | if (order.getDistributionMode() != 2){ |
| | | throw new ServiceException("该订单:"+orderNum+"配送方式不为快递", 500); |
| | | } |
| | | Integer orderStatus = order.getOrderStatus(); |
| | | if (orderStatus != 1){ |
| | | throw new ServiceException("该订单:"+orderNum+"状态不为待发货", 500); |
| | | } |
| | | |
| | | String companyNameByCode = ExpressCompanyMap.getCompanyNameByCode(expressName); |
| | | if(StringUtils.isEmpty(companyNameByCode)){ |
| | | throw new ServiceException("快递公司编码错误:"+expressName, 500); |