|
@@ -5,6 +5,8 @@ import com.platform.common.util.R;
|
|
|
import com.platform.dao.util.ExcelUtil;
|
|
|
import com.platform.dao.vo.export.sb.ExportSbTypeVO;
|
|
|
import com.platform.rest.log.annotation.SysLog;
|
|
|
+import com.platform.service.activiti.ActivitiAssignStrategy;
|
|
|
+import com.platform.service.excel.ExcelImportStrategy;
|
|
|
import com.platform.service.sb.SbInfoService;
|
|
|
import com.platform.service.sb.impl.SbInfoServiceImpl;
|
|
|
import lombok.AllArgsConstructor;
|
|
@@ -13,6 +15,7 @@ import org.springframework.web.bind.annotation.*;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description 设备基础信息 控制器
|
|
@@ -26,7 +29,10 @@ import java.util.List;
|
|
|
@Slf4j
|
|
|
public class ExcelImportController {
|
|
|
|
|
|
- private final SbInfoService sbInfoService;
|
|
|
+ /**
|
|
|
+ * 通过spring获取所有策略类
|
|
|
+ */
|
|
|
+ private List<ExcelImportStrategy> importStrategyList;
|
|
|
|
|
|
/**
|
|
|
* 导入设备类型
|
|
@@ -34,14 +40,12 @@ public class ExcelImportController {
|
|
|
* @param file bom excel文件
|
|
|
* @return R
|
|
|
*/
|
|
|
- @SysLog("新增导入设备类型")
|
|
|
- @PostMapping("/sb/type")
|
|
|
- public R importExcel(@RequestParam("file") MultipartFile file) throws Exception {
|
|
|
- List<ExportSbTypeVO> list = ExcelUtil.importExcel(file.getInputStream(), ExportSbTypeVO.class, 1);
|
|
|
- if(CollectionUtil.isNotEmpty(list)){
|
|
|
- list.forEach(item->log.info(item.toString()));
|
|
|
- }
|
|
|
- int i = list.size();
|
|
|
+ @SysLog("初始化导入")
|
|
|
+ @PostMapping("/import")
|
|
|
+ public R importExcel(@RequestParam("type") Integer type, @RequestParam("file") MultipartFile file) throws Exception {
|
|
|
+ ExcelImportStrategy excelImportStrategy =
|
|
|
+ importStrategyList.stream().filter(strategy -> strategy.getType().equals(type)).collect(Collectors.toList()).get(0);
|
|
|
+ int i = excelImportStrategy.handler(file.getInputStream());
|
|
|
if (i != 0) {
|
|
|
return new R("导入成功");
|
|
|
} else {
|