Parcourir la source

文件元数据捕获

xqj il y a 11 mois
Parent
commit
f2e5d03959

+ 51 - 0
blade-service-api/blade-manager-api/src/main/java/org/springblade/manager/enums/StorageTypeEnum.java

@@ -0,0 +1,51 @@
+package org.springblade.manager.enums;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+import org.springblade.core.tool.utils.ObjectUtil;
+
+/**
+ * 储存类型枚举
+ * @author xingqianji
+ */
+@Getter
+@AllArgsConstructor
+public enum StorageTypeEnum {
+
+    UNKNOWN(-1, ""),
+    ORDINARY(1, "普通"),
+    AS_BUILT_DRAWINGS(2, "竣工图"),
+    METERING(3, "计量"),
+    QUALITY_INSPECTION(4, "质检"),
+    SOUND_IMAGE(5, "声像"),
+    TRIAL(6, "试验"),
+    HIDE(7, "隐蔽"),
+    MANAGE_FILES(8, "管理文件"),
+    CHANGE_ORDER(9, "变更令");
+
+    /**
+     * 编码
+     */
+    private Integer code;
+
+    /**
+     * 描述
+     */
+    private String desc;
+
+    /**
+     * 根据编码获取枚举描述
+     */
+    public static String getByCode(int code) {
+        // 判断code
+        if(ObjectUtil.isNotEmpty(code)){
+            for (StorageTypeEnum storageTypeEnum : StorageTypeEnum.values()) {
+                if (storageTypeEnum.getCode() == code) {
+                    return storageTypeEnum.getDesc();
+                }
+            }
+        }
+        return StorageTypeEnum.UNKNOWN.getDesc();
+    }
+
+}

+ 1 - 1
blade-service/blade-business/src/main/java/org/springblade/business/mapper/TaskParallelMapper.xml

@@ -22,7 +22,7 @@
     </resultMap>
 
     <select id="queryApprovalUser" resultMap="taskParallelResultMap">
-        select task_user, task_user_name, e_visa_status, status
+        select task_user, task_user_name, e_visa_status, status, update_time
         from u_task_parallel
         where process_instance_id =
               #{processInstanceId}

+ 5 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/ITaskService.java

@@ -99,4 +99,9 @@ public interface ITaskService extends BaseService<Task> {
 
     @Async
     void reSigningEVisa(String classify, String taskIds, String contractId, String projectId, String header);
+
+    /**
+     * 根据数据源id查询任务
+     */
+    Task getTaskByFormDataId(String formDataId);
 }

+ 125 - 9
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/MetadataClassificationServiceImpl.java

@@ -3,36 +3,42 @@ package org.springblade.business.service.impl;
 
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import lombok.AllArgsConstructor;
-
+import org.apache.commons.lang.StringUtils;
 import org.springblade.archive.entity.ArchivesAuto;
 import org.springblade.archive.feign.ArchiveAutoClient;
 import org.springblade.business.entity.ArchiveFile;
 import org.springblade.business.entity.MetadataClassification;
+import org.springblade.business.entity.Task;
+import org.springblade.business.entity.TaskParallel;
 import org.springblade.business.mapper.MetadataClassificationMapper;
 import org.springblade.business.service.IArchiveFileService;
 import org.springblade.business.service.IMetadataClassificationService;
-
+import org.springblade.business.service.ITaskParallelService;
+import org.springblade.business.service.ITaskService;
 import org.springblade.business.vo.MetadataClassificationVO;
 import org.springblade.common.utils.SnowFlakeUtil;
 import org.springblade.core.mp.base.BaseServiceImpl;
 import org.springblade.core.secure.BladeUser;
 import org.springblade.core.secure.utils.AuthUtil;
+import org.springblade.core.tool.api.R;
 import org.springblade.core.tool.constant.BladeConstant;
-import org.springblade.core.tool.utils.BeanUtil;
-import org.springblade.core.tool.utils.DateUtil;
-import org.springblade.core.tool.utils.ObjectUtil;
+import org.springblade.core.tool.utils.*;
 import org.springblade.manager.entity.ArchiveTreeContract;
 import org.springblade.manager.entity.ContractInfo;
+import org.springblade.manager.enums.StorageTypeEnum;
 import org.springblade.manager.feign.ArchiveTreeContractClient;
 import org.springblade.manager.feign.ContractClient;
-import org.springblade.manager.vo.WbsTreeVO;
 import org.springblade.system.entity.DictBiz;
 import org.springblade.system.feign.IDictBizClient;
+import org.springblade.system.feign.ISysClient;
+import org.springblade.system.user.entity.User;
+import org.springblade.system.user.feign.IUserClient;
 import org.springframework.dao.DataAccessException;
 import org.springframework.jdbc.core.JdbcTemplate;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.stream.Collectors;
 
 @Service
 @AllArgsConstructor
@@ -46,6 +52,15 @@ public class MetadataClassificationServiceImpl
     private final JdbcTemplate jdbcTemplate;
     private final IDictBizClient iDictBizClient;
 
+    private final ITaskService iTaskService;
+
+    private final ITaskParallelService iTaskParallelService;
+
+    private final IUserClient iUserClient;
+
+    private final ISysClient iSysClient;
+
+
     @Override
     public MetadataClassification classificationDetail(Integer type) {
         return baseMapper.classificationDetail(type);
@@ -276,7 +291,20 @@ public class MetadataClassificationServiceImpl
             List<ArchiveTreeContract> list = archiveTreeContractClient.getArchiveTreeContractListByIds(ancestors);
             StringBuffer paperAddress= new StringBuffer();
             StringBuffer nameStr = new StringBuffer();
+            // 单位工程
+            StringBuffer unitProjectString = new StringBuffer();
+            // 单位工程编码
+            StringBuffer unitProjectIdString = new StringBuffer();
+            // 分部工程
+            StringBuffer divisionProjectString = new StringBuffer();
+            // 分部工程编码
+            StringBuffer divisionProjectIdString = new StringBuffer();
+            // 分项工程
+            StringBuffer itemizedProjectString = new StringBuffer();
+            // 分项工程编码
+            StringBuffer itemizedProjectIdString = new StringBuffer();
             for (int i = 0 ;i<list.size();i++) {
+                metadataSetting(list.get(i), unitProjectString, unitProjectIdString, divisionProjectString, divisionProjectIdString, itemizedProjectString, itemizedProjectIdString);
                 if(i == 0){
                     continue;
                 }
@@ -310,7 +338,7 @@ public class MetadataClassificationServiceImpl
             keyValue.put("元数据目录文件", nameStr.toString());
 
             /**电子文件号**/
-//            keyValue.put("电子文件号", byId.getFilePage());
+            keyValue.put("电子文件号", fileId);
 
             /**文件页数**/
             keyValue.put("文件页数", byId.getFilePage());
@@ -346,14 +374,14 @@ public class MetadataClassificationServiceImpl
                 keyValue.put("文件件数",archivesAuto.getFileN());
 
                 /**验证码**/
-//                keyValue.put("验证码",archivesAuto.getFileN());
+                keyValue.put("验证码",archivesAuto.getId());
             }
 
 
             /**文号**/
             keyValue.put("文号", byId.getFileNumber());
             /**表单标识码**/
-//            keyValue.put("表单标识码", byId.getFileNumber());
+//            keyValue.put("表单标识码", fileId);
 
             /**主题**/
             keyValue.put("主题", byId.getFileName());
@@ -403,8 +431,63 @@ public class MetadataClassificationServiceImpl
                 keyValue.put("引用变更令 编号", byId.getCiteChangeNumber());
             }
 
+            /**业务事项**/
+            keyValue.put("业务事项", StorageTypeEnum.getByCode(archiveTreeContractById.getStorageType()));
+            /**单位工程**/
+            keyValue.put("单位工程", StringUtils.isNotBlank(unitProjectString.toString()) ? unitProjectString.substring(0, unitProjectString.length()-1) : null);
+            /**单位工程编码**/
+            keyValue.put("单位工程编码", StringUtils.isNotBlank(unitProjectIdString.toString()) ? unitProjectIdString.substring(0, unitProjectIdString.length()-1) : null);
+            /**分部工程**/
+            keyValue.put("分部工程", StringUtils.isNotBlank(divisionProjectString.toString()) ? divisionProjectString.substring(0, divisionProjectString.length()-1) : null);
+            /**分部工程编码**/
+            keyValue.put("分部工程编码", StringUtils.isNotBlank(divisionProjectIdString.toString()) ? divisionProjectIdString.substring(0, divisionProjectIdString.length()-1) : null);
+            /**分项工程**/
+            keyValue.put("分项工程", StringUtils.isNotBlank(itemizedProjectString.toString()) ? itemizedProjectString.substring(0, itemizedProjectString.length()-1) : null);
+            /**分项工程编码**/
+            keyValue.put("分项工程编码", StringUtils.isNotBlank(itemizedProjectIdString.toString()) ? itemizedProjectIdString.substring(0, itemizedProjectIdString.length()-1) : null);
+
             /**责任者名称**/
             keyValue.put("责任者名称", byId.getDutyUser());
+            /**关系**/
+            keyValue.put("关系", "引用");
+
+            // 获取签名信息
+            Task task = iTaskService.getTaskByFormDataId(byId.getId().toString());
+            if(ObjectUtil.isNotEmpty(task)){
+                // 拿到processInstanceId,查询电签信息
+                List<TaskParallel> taskParallelList = iTaskParallelService.queryApprovalUser(task.getProcessInstanceId());
+                taskParallelList = taskParallelList.stream().filter(taskParallel -> taskParallel.getEVisaStatus() == 1).collect(Collectors.toList());
+                if(CollectionUtil.isNotEmpty(taskParallelList)){
+                    // 签名者
+                    StringBuffer nameString = new StringBuffer();
+                    // 签名时间
+                    StringBuffer dateString = new StringBuffer();
+                    // 用户id集合
+                    List<Long> userIdList = new ArrayList<>();
+                    for (TaskParallel taskParallel : taskParallelList) {
+                        nameString.append(taskParallel.getTaskUserName());
+                        nameString.append("、");
+                        dateString.append(taskParallel.getUpdateTime());
+                        dateString.append("、");
+                        userIdList.add(Long.valueOf(task.getTaskUser()));
+                    }
+                    // 查询用户
+                    List<User> userList = iUserClient.userInfoByIds(userIdList);
+                    // 岗位id集合
+                    List<String> postIds = userList.stream().map(User::getPostId).collect(Collectors.toList());
+                    R<List<String>> postNames = iSysClient.getPostNames(Func.join(postIds));
+                    if(postNames.getCode() == 200){
+                        /**签名项**/
+                        keyValue.put("签名项", Func.join(postNames.getData()));
+                    }
+                    /**签名者**/
+                    keyValue.put("签名者", StringUtils.isNotBlank(nameString.toString()) ? nameString.substring(0, nameString.length()-1) : null);
+                    /**签名时间**/
+                    keyValue.put("签名时间", StringUtils.isNotBlank(dateString.toString()) ? dateString.substring(0, nameString.length()-1) : null);
+                }
+            }
+
+            // 更新判断
             if (isAdd) {
                 sqlBuild.append("insert into u_metadata_file ");
                 for (MetadataClassification key : metadataClassifications) {
@@ -440,7 +523,40 @@ public class MetadataClassificationServiceImpl
                 sqlBuild.append(" update_time = '" + DateUtil.formatDateTime(new Date()) + "' ");
                 sqlBuild.append(" where id = " + metadataMap.get("id"));
             }
+            System.out.println(sqlBuild.toString().replaceAll("\\\\",""));
             jdbcTemplate.execute(sqlBuild.toString().replaceAll("\\\\",""));
         }
     }
+
+    /**
+     * 元数据-M56-M61数据设置
+     */
+    private void metadataSetting(ArchiveTreeContract archiveTreeContract,
+                                 StringBuffer unitProjectString,
+                                 StringBuffer unitProjectIdString,
+                                 StringBuffer divisionProjectString,
+                                 StringBuffer divisionProjectIdString,
+                                 StringBuffer itemizedProjectString,
+                                 StringBuffer itemizedProjectIdString){
+        // 判断archiveTreeContract中displayHierarchy属性值
+        String displayHierarchy = archiveTreeContract.getDisplayHierarchy();
+        String nodeName = archiveTreeContract.getNodeName();
+        Long id = archiveTreeContract.getId();
+        if(displayHierarchy.equals("1")){// 单位工程
+            unitProjectString.append(nodeName);
+            unitProjectString.append("/");
+            unitProjectIdString.append(id);
+            unitProjectIdString.append("/");
+        }else if(displayHierarchy.equals("2")){// 分部工程
+            divisionProjectString.append(nodeName);
+            divisionProjectString.append("/");
+            divisionProjectIdString.append(id);
+            divisionProjectIdString.append("/");
+        }else if(displayHierarchy.equals("4")){// 分项工程
+            itemizedProjectString.append(nodeName);
+            itemizedProjectString.append("/");
+            itemizedProjectIdString.append(id);
+            itemizedProjectIdString.append("/");
+        }
+    }
 }

+ 7 - 0
blade-service/blade-business/src/main/java/org/springblade/business/service/impl/TaskServiceImpl.java

@@ -1467,4 +1467,11 @@ public class TaskServiceImpl extends BaseServiceImpl<TaskMapper, Task> implement
         return excelTabClient.synPDFInfo(contractId, nodePKeyIds, classify, projectId, header);
     }
 
+    @Override
+    public Task getTaskByFormDataId(String formDataId) {
+        return getOne(Wrappers.<Task>lambdaQuery()
+                .eq(Task::getIsDeleted, 0)
+                .eq(Task::getFormDataId, formDataId));
+    }
+
 }