Эх сурвалжийг харах

档案统计-原生数字化文件数量 接口调整

LHB 3 сар өмнө
parent
commit
cba81781a3

+ 25 - 82
blade-service/blade-business/src/main/java/org/springblade/business/feignClient/ArchiveFileClientImpl.java

@@ -22,6 +22,7 @@ import org.springblade.manager.feign.ContractClient;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.math.BigDecimal;
 import java.util.*;
 import java.util.function.Function;
 import java.util.stream.Collectors;
@@ -130,99 +131,41 @@ public class ArchiveFileClientImpl implements ArchiveFileClient {
 
     @Override
     public List<Map<String, Object>> getAllArchiveFileByContractType(Long projectId) {
-        List<ArchiveFileVO> list = fileMapper.getAllArchiveFileByContractType(projectId);
-        List<ContractInfo> infos = contractClient.queryContractListByIds(Arrays.asList(projectId));
+        Integer count = fileMapper.getAllArchiveFileByContractTypeCount(projectId);
+        Map<String, BigDecimal> mapSummary = fileMapper.getAllArchiveFileByContractTypeSummary(projectId);
         int key1 = 0, key2 = 0, key3 = 0;
         int key4 = 0, key5 = 0, key6 = 0;
-        //判断文件属于1施工,2监理,还是3业主
-        if (list != null && list.size() > 0) {
-            for (ArchiveFileVO l : list) {
-                String type = l.getContractType();
-                if (StringUtils.isBlank(type)) {
-                    //业主
-                    if (l.getSourceType() != null && l.getSourceType() == 1){
-                        key4++;
-                    }else {
-                        key3++;
-                    }
-                } else if ("S".equals(type)) {
-                    //监理
-                    if (l.getSourceType() != null && l.getSourceType() == 1){
-                        key5++;
-                    }else {
-                        key2++;
-                    }
-
-                } else if ("C".equals(type)) {
-                    //施工
-                    if (l.getSourceType() != null && l.getSourceType() == 1){
-                        key6++;
-                    }else {
-                        key1++;
-                    }
-                } else if (type.length() > 10) {
-                    for (ContractInfo info : infos) {
-                        if (type.equals(info.getId() + "")) {
-                            Integer t = info.getContractType();
-                            if (t == 1) {
-                                key1++;
-                            } else if (t == 2) {
-                                key2++;
-                            } else {
-                                key3++;
-                            }
-                            break;
-                        }
-                    }
-                } else {
-                    System.out.println(type);
-                }
-            }
-        }else {
-            List<ArchivesAutoVO> autos = fileMapper.getAllArchiveAutoByContractType(projectId);
-            for (ArchivesAutoVO l : autos) {
-                String type = l.getContractType();
-                if (StringUtils.isBlank(type)) {
-                    //业主
-                    key3++;
-                } else if ("S".equals(type)) {
-                    //监理
-                    key2++;
-                } else if ("C".equals(type)) {
-                    //施工
-                    key1++;
-                } else if (type.length() > 10) {
-                    for (ContractInfo info : infos) {
-                        if (type.equals(info.getId() + "")) {
-                            Integer t = info.getContractType();
-                            if (t == 1) {
-                                key1++;
-                            } else if (t == 2) {
-                                key2++;
-                            } else {
-                                key3++;
-                            }
-                            break;
-                        }
-                    }
-                } else {
-                    System.out.println(type);
-                }
+        if(count> 0 && mapSummary != null){
+            key1 += mapSummary.get("key1") != null ? mapSummary.get("key1").intValue() : 0;
+            key2 += mapSummary.get("key2") != null ? mapSummary.get("key2").intValue() : 0;
+            key3 += mapSummary.get("key3") != null ? mapSummary.get("key3").intValue() : 0;
+            key4 += mapSummary.get("key4") != null ? mapSummary.get("key4").intValue() : 0;
+            key5 += mapSummary.get("key5") != null ? mapSummary.get("key5").intValue() : 0;
+            key6 += mapSummary.get("key6") != null ? mapSummary.get("key6").intValue() : 0;
+        } else {
+            Map<String,BigDecimal>  mapAutoSummary = fileMapper.getAllArchiveAutoByContractTypeSummary(projectId);
+            if(mapAutoSummary != null){
+                key1 += mapAutoSummary.get("key1") != null ? mapAutoSummary.get("key1").intValue() : 0;
+                key2 += mapAutoSummary.get("key2") != null ? mapAutoSummary.get("key2").intValue() : 0;
+                key3 += mapAutoSummary.get("key3") != null ? mapAutoSummary.get("key3").intValue() : 0;
+                key4 += mapAutoSummary.get("key4") != null ? mapAutoSummary.get("key4").intValue() : 0;
+                key5 += mapAutoSummary.get("key5") != null ? mapAutoSummary.get("key5").intValue() : 0;
+                key6 += mapAutoSummary.get("key6") != null ? mapAutoSummary.get("key6").intValue() : 0;
             }
         }
         List<Map<String, Object>> mapList = new ArrayList<>();
         Map<String, Object> map = new HashMap<>();
         map.put("title", "施工");
-        map.put("key1", key6);
-        map.put("key2", key1);
+        map.put("key1", key6);//原生
+        map.put("key2", key1);//数据化
         Map<String, Object> map2 = new HashMap<>();
         map2.put("title", "监理");
-        map2.put("key1", key5);
-        map2.put("key2", key2);
+        map2.put("key1", key5);//原生
+        map2.put("key2", key2);//数据化
         Map<String, Object> map3 = new HashMap<>();
         map3.put("title", "业主");
-        map3.put("key1", key4);
-        map3.put("key2", key3);
+        map3.put("key1", key4);//原生
+        map3.put("key2", key3);//数据化
         mapList.add(map);
         mapList.add(map2);
         mapList.add(map3);

+ 21 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ArchiveFileMapper.java

@@ -24,6 +24,7 @@ import org.springblade.business.vo.ArchiveFileVO;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 
+import java.math.BigDecimal;
 import java.util.List;
 import java.util.Map;
 
@@ -99,4 +100,24 @@ public interface ArchiveFileMapper extends BaseMapper<ArchiveFile> {
 
 
     List<ArchivesAutoVO> getAllArchiveAutoByContractType(@Param("projectId") Long projectId);
+
+    /**
+     * 档案统计-案卷统计-原生、数字化文件数量(份)
+     * @param projectId
+     * @return
+     */
+    Map<String, BigDecimal> getAllArchiveFileByContractTypeSummary(@Param("projectId") Long projectId);
+
+    /**
+     * 统计
+     * @param projectId
+     * @return
+     */
+    Integer getAllArchiveFileByContractTypeCount(Long projectId);
+    /**
+     * 档案统计-案卷统计-原生、数字化文件数量(份)
+     * @param projectId
+     * @return
+     */
+    Map<String, BigDecimal> getAllArchiveAutoByContractTypeSummary(@Param("projectId") Long projectId);
 }

+ 53 - 0
blade-service/blade-business/src/main/java/org/springblade/business/mapper/ArchiveFileMapper.xml

@@ -473,4 +473,57 @@
                  left join m_archive_tree_contract matc on uaa.node_id = matc.id
         WHERE uaa.project_id = #{projectId} and uaa.is_deleted = 0
     </select>
+    <select id="getAllArchiveFileByContractTypeSummary" resultType="java.util.Map">
+        select sum(a.key1 + a.key11) key1,sum(a.key2 + a.key12) key2,sum(a.key3 +a.key13) key3 ,a.key4,a.key5,a.key6 from (
+          SELECT
+              sum(uaf.source_type = 1 and matc.tree_code is null) key4,
+              sum((uaf.source_type != 1 or uaf.source_type is null ) and matc.tree_code is null) key3,
+              sum(uaf.source_type = 1 and matc.tree_code = 'S') key5,
+              sum((uaf.source_type != 1 or uaf.source_type is null ) and matc.tree_code = 'S') key2,
+              sum(uaf.source_type = 1 and matc.tree_code = 'C') key6,
+              sum((uaf.source_type != 1 or uaf.source_type is null ) and matc.tree_code = 'C') key1,
+              sum(mci.id is not null and mci.contract_type = 1) key11,
+              sum(mci.id is not null and mci.contract_type = 2) key12,
+              sum(mci.id is not null and mci.contract_type not in(1,2)) key13
+
+          FROM
+              u_archive_file uaf
+                  LEFT JOIN m_archive_tree_contract matc ON uaf.node_id = matc.id
+                  left join m_contract_info mci on matc.tree_code = mci.id
+          WHERE
+              uaf.project_id = #{projectId}
+            AND matc.is_deleted = 0
+            AND uaf.is_deleted = 0
+            AND ( uaf.is_auto_file IS NULL OR uaf.is_auto_file != 1 )
+      ) a
+    </select>
+    <select id="getAllArchiveFileByContractTypeCount" resultType="java.lang.Integer">
+        SELECT count(0) `count`
+        FROM u_archive_file uaf
+                 left join m_archive_tree_contract matc on uaf.node_id = matc.id
+        WHERE uaf.project_id = #{projectId} and matc.is_deleted = 0  and uaf.is_deleted = 0
+          and (uaf.is_auto_file is null or uaf.is_auto_file != 1);
+    </select>
+    <select id="getAllArchiveAutoByContractTypeSummary" resultType="java.util.Map">
+
+        select sum(a.key1 + a.key11) key1,sum(a.key2 + a.key12) key2,sum(a.key3 +a.key13) key3 ,a.key4,a.key5,a.key6 from (
+          SELECT
+
+              sum(matc.tree_code is null) key4,
+              sum(matc.tree_code is null) key3,
+              sum(matc.tree_code = 'S') key5,
+              sum(matc.tree_code = 'S') key2,
+              sum( matc.tree_code = 'C') key6,
+              sum(matc.tree_code = 'C') key1,
+              sum(mci.contract_type = 1) key11,
+              sum(mci.contract_type = 2) key12,
+              sum(mci.contract_type not in(1,2)) key13
+
+          FROM u_archives_auto uaa
+                   left join m_archive_tree_contract matc on uaa.node_id = matc.id
+                   left join m_contract_info mci on matc.tree_code = mci.id
+          WHERE uaa.project_id = #{projectId} and uaa.is_deleted = 0
+      ) a
+
+    </select>
 </mapper>