Quellcode durchsuchen

故障字典导入导出
新增

Gaokun Wang vor 4 Monaten
Ursprung
Commit
636f6679a0

+ 11 - 10
als-modules/agile-assurance/src/main/java/org/eco/als/controller/FaultCaseController.java

@@ -6,6 +6,11 @@ import cn.hutool.core.collection.CollUtil;
 import cn.dev33.satoken.annotation.SaCheckPermission;
 import org.dromara.easyes.core.biz.EsPageInfo;
 import org.eco.als.domain.FaultCase;
+import org.eco.als.domain.vo.AirConfigurationImportVo;
+import org.eco.als.domain.vo.AirConfigurationVo;
+import org.eco.als.listener.AirConfigurationImportListener;
+import org.eco.als.listener.FaultCaseImportListener;
+import org.eco.common.excel.core.ExcelResult;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.validation.annotation.Validated;
 import org.eco.common.core.core.domain.CommonResult;
@@ -24,6 +29,7 @@ import org.eco.als.service.IFaultCaseService;
 import org.springframework.web.multipart.MultipartFile;
 import org.eco.common.core.core.page.PageResult;
 
+import java.io.IOException;
 import java.util.List;
 import java.util.ArrayList;
 
@@ -65,14 +71,9 @@ public class FaultCaseController extends BaseController {
     @SaCheckPermission("als:faultCase:export")
     @Log(title = "故障案例", businessType = BusinessType.EXPORT)
     @PostMapping("/export")
-    public CommonResult<Void> export(FaultCaseBo faultCaseBo) {
-        LoginUser loginUser = LoginHelper.getLoginUser();
+    public void export(HttpServletResponse response, FaultCaseBo faultCaseBo) {
         List<FaultCaseVo> list = faultCaseService.selectList(faultCaseBo);
-        if (CollUtil.isEmpty(list)) {
-            return CommonResult.fail("导出列表为空");
-        }
-        faultCaseService.asyncExport(list, "故障案例", loginUser);
-        return CommonResult.success();
+        ExcelUtil.exportExcel(list, "飞机构型", FaultCaseVo.class, response);
     }
 
     @SaCheckPermission("als:faultCase:import")
@@ -87,10 +88,10 @@ public class FaultCaseController extends BaseController {
     @Log(title = "故障案例", businessType = BusinessType.IMPORT)
     @SaCheckPermission("als:faultCase:import")
     @PostMapping("/importData")
-    public CommonResult<Void> importData(MultipartFile file, boolean updateSupport) {
+    public CommonResult<Void> importData(MultipartFile file, boolean updateSupport) throws IOException {
         LoginUser loginUser = LoginHelper.getLoginUser();
-        faultCaseService.asyncImportData(file, updateSupport, loginUser);
-        return CommonResult.success();
+        ExcelResult<FaultCaseImportVo> result = ExcelUtil.importExcel(file.getInputStream(), FaultCaseImportVo.class, new FaultCaseImportListener(updateSupport, loginUser));
+        return CommonResult.success(result.getAnalysis().getLogInfo());
     }
 
     /**

+ 30 - 8
als-modules/agile-assurance/src/main/java/org/eco/als/domain/FaultCase.java

@@ -5,9 +5,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
 import com.mybatisflex.annotation.Id;
 import com.mybatisflex.annotation.Table;
 import lombok.Data;
-import lombok.EqualsAndHashCode;
-import java.io.Serial;
-import java.util.Date;
 import org.dromara.easyes.annotation.HighLight;
 import org.dromara.easyes.annotation.IndexField;
 import org.dromara.easyes.annotation.IndexId;
@@ -16,7 +13,10 @@ import org.dromara.easyes.annotation.rely.Analyzer;
 import org.dromara.easyes.annotation.rely.FieldStrategy;
 import org.dromara.easyes.annotation.rely.FieldType;
 import org.dromara.easyes.annotation.rely.IdType;
-import org.eco.common.orm.core.domain.BaseEntity;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.Date;
 
 /**
  * 故障案例对象 als_fault_case_t
@@ -25,10 +25,9 @@ import org.eco.common.orm.core.domain.BaseEntity;
  * @date 2024-11-14
  */
 @Data
-@EqualsAndHashCode(callSuper = true)
 @Table(value = "als_fault_case_t")
 @IndexName("fault_case_index")
-public class FaultCase extends BaseEntity {
+public class FaultCase implements Serializable {
     @Serial
     private static final long serialVersionUID = 1L;
 
@@ -79,7 +78,7 @@ public class FaultCase extends BaseEntity {
     @ExcelProperty(value = "故障现象")
     @IndexField(value = "pContent", fieldType = FieldType.TEXT, strategy = FieldStrategy.NOT_EMPTY,
         analyzer = Analyzer.IK_MAX_WORD, searchAnalyzer = Analyzer.IK_MAX_WORD)
-    @HighLight( preTag = "<font color=\"red\" >", postTag = "</font>")
+    @HighLight(preTag = "<font color=\"red\" >", postTag = "</font>")
     private String faultPhenomenon;
 
     /**
@@ -116,14 +115,37 @@ public class FaultCase extends BaseEntity {
     private String troubleshootingMethodPath;
 
 
-
     /**
      * 浏览次数
      */
     @ExcelProperty(value = "浏览次数")
     @IndexField(fieldType = FieldType.LONG, strategy = FieldStrategy.NOT_EMPTY)
     private Long viewCount;
+    /**
+     * 创建者
+     */
+    @IndexField(fieldType = FieldType.TEXT)
+    private String createBy;
 
+    /**
+     * 创建时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")
+    private Date createTime;
+
+    /**
+     * 更新者
+     */
+    @IndexField(fieldType = FieldType.TEXT)
+    private String updateBy;
+
+    /**
+     * 更新时间
+     */
+    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @IndexField(fieldType = FieldType.DATE, dateFormat = "yyyy-MM-dd HH:mm:ss||yyyy-MM-dd||epoch_millis")
+    private Date updateTime;
     private String orderBy;
 
 

+ 0 - 21
als-modules/agile-assurance/src/main/java/org/eco/als/service/IFaultCaseService.java

@@ -74,25 +74,4 @@ public interface IFaultCaseService extends IBaseService<FaultCase> {
      * @return 结果:true 删除成功,false 删除失败
      */
     boolean deleteByIds(Long[] ids);
-
-    /**
-     * 异步导入
-     *
-     * @param file          导入的文件
-     * @param updateSupport 是否覆盖
-     * @param user          用户上下文信息
-     */
-    @Async
-    void asyncImportData(MultipartFile file, boolean updateSupport, LoginUser user);
-
-    /**
-     * asyncExport 异步导出
-     *
-     * @param listVo    数据列表
-     * @param sheetName 文件名称
-     * @param user      上下文
-     */
-    @Async
-    void asyncExport(List<FaultCaseVo> listVo, String sheetName, LoginUser user);
-
 }

+ 2 - 26
als-modules/agile-assurance/src/main/java/org/eco/als/service/impl/FaultCaseServiceImpl.java

@@ -165,8 +165,8 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
     @Override
     public boolean insert(FaultCaseBo faultCaseBo) {
         FaultCase faultCase = MapstructUtils.convert(faultCaseBo, FaultCase.class);
-        esFaultCaseMapper.insert(faultCase);
-        return this.save(faultCase);//使用全局配置的雪花算法主键生成器生成ID值
+        this.save(faultCase);//使用全局配置的雪花算法主键生成器生成ID值
+        return esFaultCaseMapper.insert(faultCase) > 0;
     }
 
     /**
@@ -199,30 +199,6 @@ public class FaultCaseServiceImpl extends BaseServiceImpl<FaultCaseMapper, Fault
         return false;
     }
 
-    @Override
-    public void asyncImportData(MultipartFile file, boolean updateSupport, LoginUser loginUser) {
-        ExcelResultRes result;
-        try {
-            String name = file.getOriginalFilename();
-            result = excelService.importExcel(file.getInputStream(), name, FaultCaseImportVo.class, new FaultCaseImportListener(updateSupport, loginUser));
-        } catch (IOException e) {
-            throw new RuntimeException(e);
-        }
-        boolean flag = importExportService.saveInfo(result, loginUser, "0");
-        if (flag) {
-            log.info("异步导入日志写入成功");
-        }
-    }
-
-    @Override
-    public void asyncExport(List<FaultCaseVo> listVo, String sheetName, LoginUser loginUser) {
-        ExcelResultRes result = excelService.exportExcel(listVo, sheetName, FaultCaseVo.class);
-        boolean flag = importExportService.saveInfo(result, loginUser, "1");
-        if (flag) {
-            log.info("异步导出日志写入成功");
-        }
-    }
-
     /**
      * 批量删除故障案例
      *