|
@@ -60,23 +60,26 @@ public class PmsProductExcelListener extends AnalysisEventListener<PmsProductExc
|
|
@Override
|
|
@Override
|
|
public void invoke(PmsProductExcel pmsProductExcel, AnalysisContext analysisContext) {
|
|
public void invoke(PmsProductExcel pmsProductExcel, AnalysisContext analysisContext) {
|
|
LOGGER.info("解析到一条数据:{}", JSONArray.toJSONString(pmsProductExcel));
|
|
LOGGER.info("解析到一条数据:{}", JSONArray.toJSONString(pmsProductExcel));
|
|
- String productCategoryName = pmsProductExcel.getProductCategoryName();
|
|
+
|
|
- if (StringUtils.isEmpty(productCategoryName)) {
|
|
+ addData(pmsProductExcel, analysisContext);
|
|
- 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) {
|
|
private String getParm(PmsProductExcel pmsProductExcel) {
|
|
@@ -149,16 +152,16 @@ public class PmsProductExcelListener extends AnalysisEventListener<PmsProductExc
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
|
saveData();
|
|
saveData();
|
|
LOGGER.info("所有数据解析完成!");
|
|
LOGGER.info("所有数据解析完成!");
|
|
- if (erroList.size() > 0) {
|
|
+
|
|
- String fileName = "导入失败数据" + System.currentTimeMillis();
|
|
+
|
|
-
|
|
+
|
|
- response.setContentType("application/vnd.ms-excel");
|
|
+
|
|
- response.setCharacterEncoding("utf-8");
|
|
+
|
|
-
|
|
+
|
|
- 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);
|
|
+
|
|
- }
|
|
+
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|