开发OTA备案工具-导入导出

This commit is contained in:
高嵩
2023-03-27 00:52:08 +08:00
parent 74b8efa197
commit 0754af609c
3 changed files with 46 additions and 43 deletions
@@ -194,14 +194,16 @@ public class OtaBaCxJbxxController extends JeroController<OtaBaCxJbxx, IOtaBaCxJ
@PostMapping(value = "/importData") @PostMapping(value = "/importData")
// @RequiresPermissions("otaBaCx:importData") // @RequiresPermissions("otaBaCx:importData")
public Result<?> importData(@RequestParam(value = "file", required = false) MultipartFile file, public Result<?> importData(@RequestParam(value = "file", required = false) MultipartFile file,
@RequestParam(value = "cut", required = false) String cut) throws Exception { @RequestParam(value = "cut", required = false) String cut,
@RequestParam(value = "otaId", required = false) String otaId) throws Exception {
OtaBaCxJbxx res;
try { try {
this.otaBaCxJbxxService.importData(file, cut); res = this.otaBaCxJbxxService.importData(file, otaId, cut);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
return Result.error(e.getMessage()); return Result.error(e.getMessage());
} }
return Result.OK("导入成功"); return Result.OK(res);
} }
} }
@@ -67,5 +67,5 @@ public interface IOtaBaCxJbxxService extends IService<OtaBaCxJbxx> {
void exportTemplate(HttpServletResponse response, HttpServletRequest request); void exportTemplate(HttpServletResponse response, HttpServletRequest request);
void importData(MultipartFile file, String cut); OtaBaCxJbxx importData(MultipartFile file, String otaId, String cut);
} }
@@ -166,10 +166,11 @@ public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBa
} }
@Override @Override
public void importData(MultipartFile file, String cut) { public OtaBaCxJbxx importData(MultipartFile file, String otaId, String cut) {
File upLoadFile = ImportFileUtil.importFile(file, cut, uploadPath, "xlsx"); File upLoadFile = ImportFileUtil.importFile(file, cut, uploadPath, "xlsx");
OtaBaCxJbxx jbxx = parseFile(upLoadFile, cut); OtaBaCxJbxx jbxx = parseFile(upLoadFile, cut);
add(jbxx); jbxx.setOtaId(otaId);
return add(jbxx);
} }
public static String getCellValue(Cell cell, Workbook workbook) { public static String getCellValue(Cell cell, Workbook workbook) {
@@ -220,7 +221,7 @@ public class OtaBaCxJbxxServiceImpl extends ServiceImpl<OtaBaCxJbxxMapper, OtaBa
row = s.getRow(11); row = s.getRow(11);
cell = row.getCell(1); cell = row.getCell(1);
jbxx.setCdotasj(getCellValue(cell, wb)); jbxx.setCdotasj(getCellValue(cell, wb));
} catch (IndexOutOfBoundsException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return jbxx; return jbxx;