Selaa lähdekoodia

去除excel重复数据校验

ghost 4 vuotta sitten
vanhempi
commit
4d92b5a0dc

+ 30 - 27
forest-admin/admin-server/src/main/java/com/hwrj/cloud/admin/listener/PmsProductExcelListener.java

@@ -60,23 +60,26 @@ public class PmsProductExcelListener extends AnalysisEventListener<PmsProductExc
     @Override
     public void invoke(PmsProductExcel pmsProductExcel, AnalysisContext analysisContext) {
         LOGGER.info("解析到一条数据:{}", JSONArray.toJSONString(pmsProductExcel));
-        String productCategoryName = pmsProductExcel.getProductCategoryName();
-        if (StringUtils.isEmpty(productCategoryName)) {
-            pmsProductExcel.setErrMsg("没有商品类型无法导入!");
-            erroList.add(pmsProductExcel);
-            return;
-        }
-        String param = getParm(pmsProductExcel);
-        //判断数据是否重复
-        Long aLong = productExcelDao.checkOne(param);
-        if (aLong == 0) {
-            addData(pmsProductExcel, analysisContext);
-            return;
-        } else if (aLong > 0) {
-            pmsProductExcel.setErrMsg("数据库已存在!");
-            erroList.add(pmsProductExcel);
-            return;
-        }
+
+        addData(pmsProductExcel, analysisContext);
+
+//        String productCategoryName = pmsProductExcel.getProductCategoryName();
+//        if (StringUtils.isEmpty(productCategoryName)) {
+//            pmsProductExcel.setErrMsg("没有商品类型无法导入!");
+//            erroList.add(pmsProductExcel);
+//            return;
+//        }
+//        String param = getParm(pmsProductExcel);
+//        //判断数据是否重复
+//        Long aLong = productExcelDao.checkOne(param);
+//        if (aLong == 0) {
+//            addData(pmsProductExcel, analysisContext);
+//            return;
+//        } else if (aLong > 0) {
+//            pmsProductExcel.setErrMsg("数据库已存在!");
+//            erroList.add(pmsProductExcel);
+//            return;
+//        }
     }
 
     private String getParm(PmsProductExcel pmsProductExcel) {
@@ -149,16 +152,16 @@ public class PmsProductExcelListener extends AnalysisEventListener<PmsProductExc
     public void doAfterAllAnalysed(AnalysisContext analysisContext) {
         saveData();
         LOGGER.info("所有数据解析完成!");
-        if (erroList.size() > 0) {
-            String fileName = "导入失败数据" + System.currentTimeMillis();
-            // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
-            response.setContentType("application/vnd.ms-excel");
-            response.setCharacterEncoding("utf-8");
-            // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
-            String fileNameNew = URLEncoder.encode(fileName, "UTF-8");
-            response.setHeader("Content-disposition", "attachment;filename=" + fileNameNew + ".xlsx");
-            EasyExcel.write(response.getOutputStream(), PmsProductExcel.class).sheet("Sheet").doWrite(erroList);
-        }
+//        if (erroList.size() > 0) {
+//            String fileName = "导入失败数据" + System.currentTimeMillis();
+//            // 这里注意 有同学反应使用swagger 会导致各种问题,请直接用浏览器或者用postman
+//            response.setContentType("application/vnd.ms-excel");
+//            response.setCharacterEncoding("utf-8");
+//            // 这里URLEncoder.encode可以防止中文乱码 当然和easyexcel没有关系
+//            String fileNameNew = URLEncoder.encode(fileName, "UTF-8");
+//            response.setHeader("Content-disposition", "attachment;filename=" + fileNameNew + ".xlsx");
+//            EasyExcel.write(response.getOutputStream(), PmsProductExcel.class).sheet("Sheet").doWrite(erroList);
+//        }
 
     }