xqj 10 månader sedan
förälder
incheckning
bfdc1a08ef

+ 3 - 0
blade-service-api/blade-business-api/src/main/java/org/springblade/business/entity/ImageClassificationFile.java

@@ -133,4 +133,7 @@ public class ImageClassificationFile extends BaseEntity {
     @ApiModelProperty("图片或视频的垂直分辨率")
     private Integer fileHeight;
 
+    @ApiModelProperty("文件页数")
+    private Integer filePage;
+
 }

+ 40 - 4
blade-service/blade-business/src/main/java/org/springblade/business/controller/ImageClassificationFileController.java

@@ -31,6 +31,7 @@ import org.springblade.core.mp.support.Query;
 import org.springblade.core.oss.model.BladeFile;
 import org.springblade.core.secure.utils.AuthUtil;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.api.ResultCode;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.core.tool.utils.IoUtil;
 import org.springblade.core.tool.utils.ObjectUtil;
@@ -49,6 +50,7 @@ import org.springblade.resource.vo.NewBladeFile;
 import org.springblade.system.entity.Dict;
 import org.springblade.system.feign.IDictClient;
 import org.springframework.beans.BeanUtils;
+import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.mock.web.MockMultipartFile;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.bind.annotation.RequestParam;
@@ -80,6 +82,7 @@ import static org.springblade.common.utils.CommonUtil.replaceOssUrl;
 @Api(tags = "影音资料接口(客户端)")
 public class ImageClassificationFileController extends BladeController {
 
+    @Autowired
     private final IImageClassificationFileService imageClassificationFileService;
 
     private final ImageClassificationShowService imageClassificationShowService;
@@ -160,7 +163,8 @@ public class ImageClassificationFileController extends BladeController {
         List<String> result = new ArrayList<>();
         if (excelTab != null) {
             //获取数据
-            List<ImageClassificationFile> fileResult = this.imageClassificationFileService.list(Wrappers.<ImageClassificationFile>lambdaQuery().in(ImageClassificationFile::getId, Arrays.asList(ids.split(","))));
+            List<String> strings = Arrays.asList(ids.split(","));
+            List<ImageClassificationFile> fileResult = this.imageClassificationFileService.list(Wrappers.<ImageClassificationFile>query().lambda().in(ImageClassificationFile::getId, strings));
 
             try {
                 if (fileResult != null && fileResult.size() > 0) {
@@ -609,8 +613,10 @@ public class ImageClassificationFileController extends BladeController {
     @ApiOperation(value = "修改影音资料信息", notes = "传入表单数据")
     public R<Boolean> update(@Valid @RequestBody ImageClassificationFileVO fileVO) {
         ImageClassificationFile newData = this.copyBeanData(fileVO, false);
-        newData.setMargePdfUrl("");
-        return R.data(this.imageClassificationFileService.updateById(newData));
+        boolean update = this.imageClassificationFileService.updateById(newData);
+        // 生成合并pdfUrl
+        generateMergePdfUrl(update, newData);
+        return R.data(update);
     }
 
     /**
@@ -637,8 +643,12 @@ public class ImageClassificationFileController extends BladeController {
             newFile.setClassifyId(fileVO.getClassifyId());
             newFile.setContractId(fileVO.getContractId());
             newFile.setProjectId(fileVO.getProjectId());
+            // 新增操作
+            boolean save = this.imageClassificationFileService.save(newFile);
+            // 生成合并pdfUrl
+            generateMergePdfUrl(save, newFile);
             //落库数据
-            return R.status(this.imageClassificationFileService.save(newFile));
+            return R.status(save);
         } catch (Exception e) {
             e.printStackTrace();
         }
@@ -777,4 +787,30 @@ public class ImageClassificationFileController extends BladeController {
         return R.data(this.imageClassificationFileService.getFileTitleName(pKeyId));
     }
 
+    /**
+     * 生成合并PdfUrl
+     * 写这个方法是因为声像资料同步那边,一定要有可以预览的东西,
+     * 以前的逻辑是有前端点击查看按钮时,才会根据type等条件调用preview()这个方法
+     */
+    private void generateMergePdfUrl(Boolean flag, ImageClassificationFile newFile){
+        if(true){
+            // 文件类型为图片时
+            if(newFile.getType() == 2){
+                // 生成合并的pdfUrl
+                R<String> preview = preview(newFile.getId().toString());
+                if(preview.getCode() == ResultCode.SUCCESS.getCode()){
+                    // 获得合并后的pdfUrl
+                    /**后续要多注意preview()这个方法所返回回来的值,现在固定的返回集合中的第一个**/
+                    String data = preview.getData();
+                    // 获取pdf页码
+                    String pdfPage  = commonFileClient.getPdfNum(data);
+                    // 更新mergePdfUrl
+                    this.imageClassificationFileService.update(Wrappers.<ImageClassificationFile>lambdaUpdate()
+                            .set(ImageClassificationFile::getMargePdfUrl, preview.getData())
+                            .set(ImageClassificationFile::getFilePage, Integer.valueOf(pdfPage))
+                            .eq(ImageClassificationFile::getId, newFile.getId()));
+                }
+            }
+        }
+    }
 }

+ 2 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ImageClassificationFileMapper.xml

@@ -32,6 +32,7 @@
         <result column="marge_pdf_url" property="margePdfUrl"/>
         <result column="file_width" property="fileWidth"/>
         <result column="file_height" property="fileHeight"/>
+        <result column="file_page" property="filePage"/>
     </resultMap>
     <update id="recoveryByIds">
         update u_image_classification_file set is_deleted = 0 where
@@ -162,6 +163,7 @@
             u_image_classification_file.marge_pdf_url,
             u_image_classification_file.file_width,
             u_image_classification_file.file_height,
+            u_image_classification_file.file_page,
             m_image_classification_config.storage_directory_format
         from
             u_image_classification_file u_image_classification_file

+ 1 - 1
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ArchiveTreeContractMapper.xml

@@ -189,7 +189,7 @@
         SELECT
         d.id,
         d.parent_id,
-        d.node_name AS title,
+        IFNULL(if(length(trim(d.full_name))>0,d.full_name,d.node_name),d.node_name)AS title,
         d.id AS "value",
         d.id AS "key",
         d.major_data_type AS "majorDataType",

+ 1 - 0
blade-service/blade-manager/src/main/java/org/springblade/manager/mapper/ContractInfoMapper.xml

@@ -460,6 +460,7 @@
         d.parent_id AS "parentId",
         IFNULL(if(length(trim(full_name)) > 0, full_name, node_name),node_name) AS title,
         d.node_name AS "nodeName",
+        d.full_name AS "fullName",
         d.node_type ,
         d.id AS "value",
         d.id AS "key",

+ 8 - 3
blade-service/blade-manager/src/main/java/org/springblade/manager/service/impl/ArchiveTreeContractSyncImpl.java

@@ -1261,8 +1261,13 @@ public class ArchiveTreeContractSyncImpl {
         archiveFile.setFileName(file.getTitle());
         archiveFile.setFileTime(file.getUploadTime());
         archiveFile.setFileUrl(file.getImageUrl());
-        archiveFile.setPdfFileUrl(file.getMargePdfUrl());
-        archiveFile.setFilePage(1);
+        // 根据type判断,设置pdfUrl, 1=视频格式,取原本的视频地址就好,2=图片格式,就取合并后的pdfUrl
+        if(file.getType() == 1){
+            archiveFile.setPdfFileUrl(file.getImageUrl());
+        }else{
+            archiveFile.setPdfFileUrl(StringUtils.isNotEmpty(file.getMargePdfUrl()) ? file.getMargePdfUrl() : file.getPdfUrl());
+        }
+        archiveFile.setFilePage(file.getFilePage());
         archiveFile.setIsApproval(0);
         archiveFile.setIsCertification(1);
         archiveFile.setIsNeedCertification(0);
@@ -1289,7 +1294,7 @@ public class ArchiveTreeContractSyncImpl {
         archiveFile.setFtime(localDateTime);
         archiveFile.setUtime(localDateTime);
         archiveFile.setSort(0);
-        archiveFile.setPageNum("1");
+        archiveFile.setPageNum(String.valueOf(file.getFilePage()));
         archiveFile.setFileSize(convertSizeToBytes(file.getFileSize()));
         archiveFile.setSourceType(1);
         archiveFile.setIsElement(0);