Explorar o código

Merge branch 'test-merge-02' of http://219.151.181.73:3000/zhuwei/bladex into test-merge-02

lvy hai 3 meses
pai
achega
8b8294d96b

+ 10 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/dto/PrivateStandardDTO.java

@@ -29,4 +29,14 @@ public class PrivateStandardDTO extends PrivateStandard {
      * 当前规范文件下文件的数量
      */
     private Integer filesCount;
+
+    /**
+     * 单个文件
+     */
+    private MultipartFile file;
+
+    /**
+     * 单个文件
+     */
+    private StandardFile standardFile;
 }

+ 16 - 2
blade-service/blade-business/src/main/java/org/springblade/business/controller/PrivateStandardController.java

@@ -3,6 +3,7 @@ package org.springblade.business.controller;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import io.swagger.annotations.Api;
@@ -19,6 +20,7 @@ import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.SecureUtil;
 import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.utils.BeanUtil;
+import org.springblade.core.tool.utils.CollectionUtil;
 import org.springframework.validation.annotation.Validated;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
@@ -54,10 +56,21 @@ public class PrivateStandardController {
      */
     @GetMapping("page")
     @ApiOperation(value = "分页查询所有数据", notes = "传入分页对象和高级查询对象")
-    public R<IPage<PrivateStandard>> selectAll(Query query, PrivateStandard privateStandard) {
+    public R<IPage<PrivateStandardDTO>> selectAll(Query query, PrivateStandard privateStandard) {
         try {
             Page page = new Page(query.getCurrent(), query.getSize());
-            IPage<PrivateStandard> resultPage = this.privateStandardService.page(page, new QueryWrapper<>(privateStandard));
+            IPage<PrivateStandardDTO> resultPage = this.privateStandardService.page(page, new QueryWrapper<>(privateStandard));
+            if(privateStandard.getType() != null && privateStandard.getType() == 2){
+                List<PrivateStandardDTO> privateStandardDTOS = BeanUtil.copyProperties(resultPage.getRecords(), PrivateStandardDTO.class);
+                for (PrivateStandardDTO record : privateStandardDTOS) {
+                    List<StandardFile> list = standardFileService.list(Wrappers.<StandardFile>lambdaQuery()
+                            .eq(StandardFile::getStandardId, record.getId())
+                            .eq(StandardFile::getIsDeleted, 0)
+                            .last("limit 1"));
+                    record.setStandardFile(CollectionUtils.isNotEmpty(list) ? list.get(0) : null);
+                }
+                resultPage.setRecords(privateStandardDTOS);
+            }
             return R.data(resultPage);
         } catch (Exception e) {
             // 可根据实际需求记录日志或返回特定错误信息
@@ -80,6 +93,7 @@ public class PrivateStandardController {
         List<StandardFile> list = standardFileService.list(Wrappers.<StandardFile>lambdaQuery()
                 .eq(StandardFile::getStandardId, id)
                 .eq(StandardFile::getIsDeleted, 0));
+
         PrivateStandardDTO privateStandardDTO = BeanUtil.copyProperties(byId, PrivateStandardDTO.class);
         privateStandardDTO.setStandardFiles(list);
         return R.data(privateStandardDTO);

+ 33 - 29
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/PrivateStandardServiceImpl.java

@@ -1,6 +1,7 @@
 package org.springblade.business.service.impl;
 
 import cn.hutool.core.util.ReflectUtil;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import org.springblade.business.entity.StandardFile;
@@ -200,53 +201,56 @@ public class PrivateStandardServiceImpl extends ServiceImpl<PrivateStandardMappe
         //先删除文件
         try {
             List<StandardFile> standardFiles = standardFileService.listByIds(delFileIds);
-            for (StandardFile standardFile : standardFiles) {
-                this.deleteFile(standardFile.getId());
+            if(CollectionUtils.isNotEmpty(standardFiles)){
+                for (StandardFile standardFile : standardFiles) {
+                    this.deleteFile(standardFile.getId());
+                }
             }
             //删除规范文件
-            for (Long delId : delIds) {
-                delete(delId);
+            if(CollectionUtils.isNotEmpty(delIds)){
+                for (Long delId : delIds) {
+                    delete(delId);
+                }
             }
         } catch (Exception e) {
             throw new ServiceException("Oss删除文件失败");
         }
         try {
+
             // 文件索引计数器
             int fileIndex = 0;
             for (PrivateStandardDTO dto : data) {
                 // 获取当前对象需要的文件数量
                 int fileCount = dto.getFilesCount();
-
-                // 为当前对象分配文件
-                MultipartFile[] objectFiles = new MultipartFile[fileCount];
-                for (int i = 0; i < fileCount; i++) {
-                    objectFiles[i] = allFiles[fileIndex++];
+                if(allFiles != null && allFiles.length > 0){
+                    if(fileCount > 0 && fileIndex < allFiles.length){
+                        dto.setFile(allFiles[fileIndex++]);
+                    }
+                    //先上传文件,上传成功在执行添加
+                    if(dto.getFile() != null){
+                        MultipartFile file = dto.getFile();
+                        StandardFile standardFile = new StandardFile();
+                        standardFile.setId(SnowFlakeUtil.getId());
+                        standardFile.setStandardId(dto.getId());
+                        standardFile.setCreateUser(user.getUserId());
+                        String originalFilename = file.getOriginalFilename();
+                        standardFile.setFileName(originalFilename);
+                        originalFilename = "standard/" + dto.getId() + "|" + originalFilename;
+                        MockMultipartFile multipartFile = new MockMultipartFile("file", originalFilename, "application/pdf", file.getInputStream());
+
+                        //Oss上传 传特殊文件名 在oss中做特殊路径处理
+                        BladeFile bladeFile = newIOSSClient.uploadFileByInputStream(multipartFile);
+                        standardFile.setStandardFileUrl(bladeFile.getLink());
+
+                        //添加新文件
+                        standardFileService.save(standardFile);
+                    }
                 }
-                dto.setFiles(objectFiles);
 
-                //先上传文件,上传成功在执行添加
-                List<StandardFile> standardFiles = new ArrayList<>();
-                for (MultipartFile file : dto.getFiles()) {
-                    StandardFile standardFile = new StandardFile();
-                    standardFile.setId(SnowFlakeUtil.getId());
-                    standardFile.setStandardId(dto.getId());
-                    standardFile.setCreateUser(user.getUserId());
-                    String originalFilename = file.getOriginalFilename();
-                    standardFile.setFileName(originalFilename);
-                    originalFilename = "standard/" + dto.getId() + "|" + originalFilename;
-                    MockMultipartFile multipartFile = new MockMultipartFile("file", originalFilename, "application/pdf", file.getInputStream());
-                    //Oss上传 传特殊文件名 在oss中做特殊路径处理
-                    BladeFile bladeFile = newIOSSClient.uploadFileByInputStream(multipartFile);
 
-                    standardFile.setStandardFileUrl(bladeFile.getLink());
-                    standardFiles.add(standardFile);
-                }
 
                 //创建数据
                 PrivateStandard privateStandard = BeanUtil.copyProperties(dto, PrivateStandard.class);
-
-                //添加新文件
-                standardFileService.saveBatch(standardFiles);
                 //修改
                 baseMapper.updateById(privateStandard);
                 return true;

+ 3 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/controller/ExcelTabController.java

@@ -2004,7 +2004,6 @@ public class ExcelTabController extends BladeController {
             throw new RuntimeException(e);
         }
 
-
         //公式填充
         executionTime.info("----公式填充执行----");
         this.excelTabService.formulaFillData(tableInfoList, Long.parseLong(nodeId), ExecuteType.INSPECTION);
@@ -2014,6 +2013,9 @@ public class ExcelTabController extends BladeController {
             R.success("数据未发生变化");
         }
         executionTime.info("----公式填充执行完毕----");
+
+        //把CL08 和CL10 的监理表添加进去
+
         //保存数据到数据库
         R<Object> result = this.excelTabService.saveOrUpdateInfo(tableInfoList);
         RandomNumberHolder.RandomTemplateTypeclear();