Browse Source

证书管理及台账导入

Zimo 2 ngày trước cách đây
mục cha
commit
db326b8f6d

+ 7 - 0
yudao-framework/yudao-spring-boot-starter-excel/src/main/java/cn/iocoder/yudao/framework/excel/core/util/ExcelUtils.java

@@ -54,6 +54,13 @@ public class ExcelUtils {
                 .autoCloseStream(false)  // 不要自动关闭,交给 Servlet 自己处理
                 .doReadAllSync();
     }
+    public static <T> List<T> readExcel(MultipartFile file, Class<T> head) throws IOException {
+        return EasyExcel.read(file.getInputStream(), head, null)
+                .autoCloseStream(false)
+                // 强制指定为 XLSX,不走 CSV 解析
+                .excelType(ExcelTypeEnum.XLSX)
+                .doReadAllSync();
+    }
 
     public static void downloadTemplate(HttpServletResponse response, String fileName, Class<?> clazz) {
         try {

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/vo/IotMeasureCertPageReqVO.java

@@ -23,6 +23,9 @@ public class IotMeasureCertPageReqVO extends PageParam {
     @Schema(description = "证书所属公司/个人")
     private String certBelong;
 
+    @Schema(description = "证件名称")
+    private String certName;
+
     @Schema(description = "证书颁发机构")
     private String certOrg;
 

+ 2 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/vo/IotMeasureCertRespVO.java

@@ -27,6 +27,8 @@ public class IotMeasureCertRespVO {
     @Schema(description = "证书所属公司/个人", requiredMode = Schema.RequiredMode.REQUIRED)
 //    @ExcelProperty("证书所属公司/个人")
     private String certBelong;
+    @Schema(description = "证件名称")
+    private String certName;
 
     @Schema(description = "证书颁发机构")
     @ExcelProperty("证书颁发机构")

+ 3 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/cert/vo/IotMeasureCertSaveReqVO.java

@@ -25,6 +25,9 @@ public class IotMeasureCertSaveReqVO {
 //    @NotEmpty(message = "证书所属公司/个人不能为空")
     private String certBelong;
 
+    @Schema(description = "证件名称")
+    private String certName;
+
     @Schema(description = "证书颁发机构")
     private String certOrg;
 

+ 3 - 4
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/controller/admin/qhse/measure/IotMeasureBookController.java

@@ -59,10 +59,9 @@ public class IotMeasureBookController {
             @Parameter(name = "updateSupport", description = "是否支持更新,默认为 false", example = "true")
     })
     @PreAuthorize("@ss.hasPermission('system:user:import')")
-    public CommonResult<UserImportRespVO> importExcel(@RequestParam("file") MultipartFile file,
-                                                      @RequestParam(value = "updateSupport", required = false, defaultValue = "false") Boolean updateSupport) throws Exception {
-        List<IotMeasureBookRespVO> list = ExcelUtils.read(file, IotMeasureBookRespVO.class);
-        return success(iotMeasureBookService.importBookList(list, updateSupport));
+    public CommonResult<UserImportRespVO> importExcel(@RequestParam("file") MultipartFile file) throws Exception {
+        List<IotMeasureBookRespVO> list = ExcelUtils.readExcel(file, IotMeasureBookRespVO.class);
+        return success(iotMeasureBookService.importBookList(list));
     }
 
     @PutMapping("/update")

+ 4 - 0
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/dal/dataobject/qhse/cert/IotMeasureCertDO.java

@@ -40,6 +40,10 @@ public class IotMeasureCertDO extends BaseDO {
      * 证书所属公司/个人
      */
     private String certBelong;
+    /**
+     * 证件名称
+     */
+    private String certName;
     /**
      * 部门id
      */

+ 1 - 1
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/measure/IotMeasureBookService.java

@@ -16,7 +16,7 @@ import java.util.List;
  * @author 超级管理员
  */
 public interface IotMeasureBookService {
-    UserImportRespVO importBookList(List<IotMeasureBookRespVO> importUsers, boolean isUpdateSupport);
+    UserImportRespVO importBookList(List<IotMeasureBookRespVO> importUsers);
 
     /**
      * 创建计量器具台账

+ 4 - 2
yudao-module-pms/yudao-module-pms-biz/src/main/java/cn/iocoder/yudao/module/pms/service/qhse/measure/IotMeasureBookServiceImpl.java

@@ -38,11 +38,12 @@ public class IotMeasureBookServiceImpl implements IotMeasureBookService {
     private DeptService deptService;
 
     @Override
-    public UserImportRespVO importBookList(List<IotMeasureBookRespVO> importBooks, boolean isUpdateSupport) {
+    public UserImportRespVO importBookList(List<IotMeasureBookRespVO> importBooks) {
         // 1.1 参数校验
         if (CollUtil.isEmpty(importBooks)) {
             throw exception(USER_IMPORT_LIST_IS_EMPTY);
         }
+        List<IotMeasureBookDO> bookDOList = new ArrayList<>();
         // 2. 遍历,逐个创建 or 更新
         UserImportRespVO respVO = UserImportRespVO.builder().createUsernames(new ArrayList<>()).updateUsernames(new ArrayList<>()).failureUsernames(new LinkedHashMap<>()).build();
         Long loginUserDeptId = SecurityFrameworkUtils.getLoginUserDeptId();
@@ -51,8 +52,9 @@ public class IotMeasureBookServiceImpl implements IotMeasureBookService {
             BeanUtils.copyProperties(importBook, iotMeasureBookDO);
             iotMeasureBookDO.setDeleted(false);
             iotMeasureBookDO.setDeptId(loginUserDeptId);
-
+            bookDOList.add(iotMeasureBookDO);
         });
+        iotMeasureBookMapper.insertBatch(bookDOList);
         return respVO;
     }