开发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);
} }
} }
@@ -11,61 +11,61 @@ import java.util.List;
/** /**
* @Description: 车型备案-车型基本信息 * @Description: 车型备案-车型基本信息
* @Author: jero-boot * @Author: jero-boot
* @Date: 2023-03-17 * @Date: 2023-03-17
* @Version: V1.0 * @Version: V1.0
*/ */
public interface IOtaBaCxJbxxService extends IService<OtaBaCxJbxx> { public interface IOtaBaCxJbxxService extends IService<OtaBaCxJbxx> {
/** /**
* 保存 * 保存
* *
* @param otaBaCxJbxx * @param otaBaCxJbxx
* @return * @return
*/ */
OtaBaCxJbxx add(OtaBaCxJbxx otaBaCxJbxx); OtaBaCxJbxx add(OtaBaCxJbxx otaBaCxJbxx);
/** /**
* 更新 * 更新
* *
* @param otaBaCxJbxx * @param otaBaCxJbxx
* @return * @return
*/ */
void editById(OtaBaCxJbxx otaBaCxJbxx); void editById(OtaBaCxJbxx otaBaCxJbxx);
/** /**
* 通过id删除 * 通过id删除
* *
* @param id * @param id
* @return * @return
*/ */
void deleteById(String id); void deleteById(String id);
/** /**
* 批量删除 * 批量删除
* *
* @param ids * @param ids
* @return * @return
*/ */
void deleteByIds(List<String> ids); void deleteByIds(List<String> ids);
/** /**
* 通过id查询 * 通过id查询
* *
* @param id * @param id
* @return * @return
*/ */
OtaBaCxJbxx queryById(String id); OtaBaCxJbxx queryById(String id);
/** /**
* 列表查询 * 列表查询
* *
* @return * @return
*/ */
List<OtaBaCxJbxx> queryList(); List<OtaBaCxJbxx> queryList();
OtaBaCxJbxx queryByOtaId(String otaId, String otaIdT); OtaBaCxJbxx queryByOtaId(String otaId, String otaIdT);
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;