接口参数:
/**
* 新增出库单信息
* @author 3380
* @date 20211025
*/
@PostMapping(value = "/insertOut", name = "新增出库单信息")
Map<String,Object> insertOutStockInfo(@ModelAttribute AllotStockBillInfo info, @RequestHeader String accessToken,@RequestParam(name = "file") MultipartFile file) throws Exception;
控制层
/**
* 新增出库单信息
* @author 3380
* @date 20211025
*/
@Override
public Map<String, Object> insertOutStockInfo(@ModelAttribute AllotStockBillInfo info, @RequestHeader("accessToken") String accessToken, @RequestParam("file") MultipartFile file) throws Exception {
return allotStockService.insertOutStockInfo(info, accessToken,file);
服务层
/**
* 解析方法
*
* @param sheet
* @param info
* @throws Exception
*/
private void getGoodsInfo(Sheet sheet, AllotStockBillInfo info) throws Exception {
Row row = null;
List<AllotStockBillGoods> billGoodsList = new ArrayList<>();
Row titleRow = sheet.getRow(0);
for (int i = 1; i < sheet.getLastRowNum(); i++) {
row = sheet.getRow(i);
if (org.springframework.util.StringUtils.isEmpty(row.getCell(0, Row.MissingCellPolicy.RETURN_BLANK_AS_NULL)))
continue;
Cell firstCell = row.getCell(0);
Cell secondCell = row.getCell(1);
Cell fiveCell = row.getCell(5);
firstCell.setCellType(CellType.STRING);
secondCell.setCellType(CellType.STRING);
fiveCell.setCellType(CellType.STRING);
AllotStockBillGoods allotStockBillGoods = new AllotStockBillGoods();
allotStockBillGoods.setSpu(firstCell.getStringCellValue());
allotStockBillGoods.setSku(row.getCell(1).getStringCellValue());
allotStockBillGoods.setGoodsName(row.getCell(2).getStringCellValue());
allotStockBillGoods.setColor(row.getCell(3).getStringCellValue());
allotStockBillGoods.setSize(row.getCell(4).getStringCellValue());
allotStockBillGoods.setOutQuantity(Integer.parseInt(row.getCell(5).getStringCellValue()));
billGoodsList.add(allotStockBillGoods);
if (!CollectionUtils.isEmpty(billGoodsList)) {
info.setBillGoodsList(billGoodsList);
}
}
}
?
|