oss服务器地址:ttps://k-team-pic.oss-cn-hangzhou.aliyuncs.com/guanjiaduizhang/sell/sell-order-test.xlsx
具体代码:通过文件流读取到对应需要的数据
private List getOssOrders(String path, String fileName) {
List result = new ArrayList<>();
try {
URL httpurl = new URL(path + fileName);
URLConnection urlConnection = httpurl.openConnection();
InputStream is = urlConnection.getInputStream();
XSSFWorkbook xssfWorkbook = new XSSFWorkbook(is);
for (Sheet xssfSheet : xssfWorkbook) {
if (xssfSheet == null) {
continue;
}
for (int rowNum = 1; rowNum <= xssfSheet.getLastRowNum(); rowNum++) {
Row row = xssfSheet.getRow(rowNum);
//订单号
Cell cellOrder = row.getCell(0);
//代理id
Cell cellAgentId = row.getCell(1);
cellAgentId.setCellType(CellType.STRING);
//存货编码
Cell cellPriceTsn = row.getCell(2);
cellPriceTsn.setCellType(CellType.STRING);
//数量
Cell cellNum = row.getCell(3);
cellNum.setCellType(CellType.STRING);
RiskControlFtpOrders order = new RiskControlFtpOrders();
order.setOrderSn(cellOrder.toString());
order.setAgentId(Integer.parseInt(cellAgentId.toString()));
order.setPriceTsn(cellPriceTsn.toString());
order.setTotalAmount(Integer.parseInt(cellNum.toString()));
result.add(order);
}
}
} catch (Exception e) {
log.error("读取oss文件异常:{}, url:{}", e, path + fileName);
}
return result;
}