|
@@ -2,6 +2,7 @@ package com.example.xiaoshiweixinback.service.importPatent.excel;
|
|
|
|
|
|
import cn.hutool.core.util.IdUtil;
|
|
|
import com.example.xiaoshiweixinback.business.exception.BusinessException;
|
|
|
+import com.example.xiaoshiweixinback.business.utils.CacheUtil;
|
|
|
import com.example.xiaoshiweixinback.business.utils.FileUtils;
|
|
|
import com.example.xiaoshiweixinback.business.utils.ReadExcelUtils;
|
|
|
import com.example.xiaoshiweixinback.domain.ImportTask;
|
|
@@ -22,6 +23,7 @@ import org.apache.poi.ss.usermodel.PictureData;
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
+import org.springframework.scheduling.annotation.Async;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
@@ -42,17 +44,24 @@ public class ImportProductCategoryService {
|
|
|
|
|
|
@Autowired
|
|
|
private ProductCategoryService productCategoryService;
|
|
|
- @Autowired
|
|
|
- private MessageService messageService;
|
|
|
+ @Autowired
|
|
|
+ private MessageService messageService;
|
|
|
+ @Autowired
|
|
|
+ private CacheUtil cacheUtil;
|
|
|
+
|
|
|
+ @Async("taskExecutor")
|
|
|
public void importProductCategory(File tempFile, ImportTask importTask) {
|
|
|
try {
|
|
|
- PersonnelVO personnelVO = new PersonnelVO();
|
|
|
- personnelVO.setUuid("123");
|
|
|
Sheet sheet = ReadExcelUtils.readExcel(tempFile);
|
|
|
Integer total = ReadExcelUtils.getExcelTotal(sheet);
|
|
|
|
|
|
List<UploadSettingVO.Column> jsonData = excuteUploadSettingService.ExcuteUploadSetting("1", "uploadCategory.json");
|
|
|
|
|
|
+ WebSocketMessageVO webSocketMessageVO = new WebSocketMessageVO();
|
|
|
+ webSocketMessageVO.setType(importTask.getImportType());
|
|
|
+ webSocketMessageVO.setCreateId(importTask.getCreateId());
|
|
|
+ webSocketMessageVO.setTaskId(importTask.getId());
|
|
|
+ webSocketMessageVO.setAllNum(total);
|
|
|
for (int i = 1; i < total; i++) {
|
|
|
PatentData patentData = ReadExcelUtils.readExcelOneRow2(tempFile, sheet, i);
|
|
|
Map<Object, Object> map = patentData.getMap();
|
|
@@ -63,24 +72,25 @@ public class ImportProductCategoryService {
|
|
|
List<PictureData> pictureDataList = patentData.getPictureDataList();
|
|
|
List<String> names = uploadParamsVO.getCategoryList();
|
|
|
if (names == null || names.size() == 0) {
|
|
|
- return;
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
|
|
|
-
|
|
|
EditCategoryDTO editCategoryDTO = this.loadCategoryAddVO(uploadParamsVO, pictureDataList);
|
|
|
try {
|
|
|
productCategoryService.editCategory(editCategoryDTO);
|
|
|
} catch (Exception e) {
|
|
|
continue;
|
|
|
}
|
|
|
- WebSocketMessageVO webSocketMessageVO =new WebSocketMessageVO();
|
|
|
- webSocketMessageVO.setTaskId(importTask.getId());
|
|
|
- webSocketMessageVO.setAllNum(total);
|
|
|
- webSocketMessageVO.setState(2);
|
|
|
- webSocketMessageVO.setCreateId(importTask.getCreateId());
|
|
|
- messageService.sendImportTaskDone(webSocketMessageVO);
|
|
|
+
|
|
|
+ webSocketMessageVO.setIfComplete(false);
|
|
|
+ webSocketMessageVO.setCurrentNum(i);
|
|
|
+ messageService.sendImportTaskDone(webSocketMessageVO);
|
|
|
}
|
|
|
+
|
|
|
+ webSocketMessageVO.setIfComplete(true);
|
|
|
+ webSocketMessageVO.setCurrentNum(total);
|
|
|
+ messageService.sendImportTaskDone(webSocketMessageVO);
|
|
|
} catch (Exception e) {
|
|
|
}
|
|
|
|
|
@@ -108,8 +118,8 @@ public class ImportProductCategoryService {
|
|
|
|
|
|
}
|
|
|
editCategoryDTO.setFileGuids(fileIds);
|
|
|
- editCategoryDTO.setName(productCategory.getName());
|
|
|
- if(productCategory!=null) {
|
|
|
+ editCategoryDTO.setName(productCategory.getName());
|
|
|
+ if (productCategory != null) {
|
|
|
editCategoryDTO.setId(productCategory.getId());
|
|
|
editCategoryDTO.setParentId(productCategory.getParentId());
|
|
|
}
|