Selaa lähdekoodia

优化档案柜

qianxb 2 vuotta sitten
vanhempi
commit
ac42d90c5a

+ 4 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.java

@@ -147,4 +147,8 @@ public interface ArchivesAutoMapper extends BaseMapper<ArchivesAuto> {
     Long getAllArchiveFileSize(@Param("projectId") Long projectId);
 
 	ArchivesAutoVO getArchiveFileList(@Param("id") Long id);
+
+	List<ArchivesAutoVO> getArchivesCabinet22(@Param("vo") ArchivesAutoVO archivesAuto);
+
+	List<ArchivesAutoVO> pageByArchivesAuto5(@Param("vo") ArchivesAutoVO vo);
 }

+ 98 - 10
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -615,12 +615,11 @@
     </select>
 
     <select id="pageByArchivesAuto3" resultMap="archivesAutoResultMap">
-        select uaa.*
+        select uaa.id,uaa.name,uaa.file_number,uaa.unit,uaa.storage_time,uaa.secret_level
         from
         (SELECT id FROM m_archive_tree_contract WHERE project_id =#{vo.projectId}
         and  ancestors like concat('%',#{vo.nodeId},'%')
-        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id left join u_archive_file uaf on uaa.id =
-        uaf.archive_id
+        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id
         where uaa.is_deleted = 0 and uaa.is_archive = 1
         <if test="vo.contractId != null and vo.contractId != ''">
             and uaa.contract_id = #{vo.contractId}
@@ -633,8 +632,7 @@
         select uaa.id from
         (SELECT id FROM m_archive_tree_contract WHERE project_id =#{vo.projectId}
         and  ancestors like concat('%',#{vo.nodeId},'%')
-        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id left join u_archive_file uaf on uaa.id =
-        uaf.archive_id
+        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id
         where uaa.is_deleted = 0 and uaa.is_archive = 1
         <if test="vo.contractId != null and vo.contractId != ''">
             and uaa.contract_id = #{vo.contractId}
@@ -642,6 +640,50 @@
         <if test="vo.searchType == 1 and vo.queryValue != null and vo.queryValue != ''">
             and uaa.name like concat('%',#{vo.queryValue},'%') or uaa.file_number like concat('%',#{vo.queryValue},'%')
         </if>
+        <if test="vo.storageTimes != null and vo.storageTimes != ''">
+            and uaa.storage_time in
+            <foreach collection="vo.storageTimes" item="storageTime" open="(" separator="," close=")">
+                #{storageTime}
+            </foreach>
+        </if>
+        <if test="vo.secretLevels != null and vo.secretLevels != ''">
+            and uaa.secret_level in
+            <foreach collection="vo.secretLevels" item="secretLevel" open="(" separator="," close=")">
+                #{secretLevel}
+            </foreach>
+        </if>
+        <if test="vo.carrierTypes != null and vo.carrierTypes != ''">
+            and uaa.carrier_type in
+            <foreach collection="vo.carrierTypes" item="carrierType" open="(" separator="," close=")">
+                #{carrierType}
+            </foreach>
+        </if>
+        <if test="vo.years != null and vo.years != ''">
+            and
+            <foreach collection="vo.years" item="year" separator=" or" open="(" close=")">
+                #{year} BETWEEN DATE_FORMAT(uaa.start_date,'%Y') and DATE_FORMAT(uaa.end_date ,'%Y')
+            </foreach>
+        </if>
+        <if test="vo.months != null and vo.months != ''">
+            and
+            <foreach collection="vo.months" item="month" separator=" or" open="(" close=")">
+                #{month} BETWEEN DATE_FORMAT(uaa.start_date,'%c') and DATE_FORMAT(uaa.end_date ,'%c')
+            </foreach>
+        </if>
+        GROUP BY uaa.id
+        order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
+    </select>
+
+    <select id="pageByArchivesAuto5" resultMap="archivesAutoResultMap">
+        select uaa.id from
+        (SELECT id FROM m_archive_tree_contract WHERE project_id =#{vo.projectId}
+        and  ancestors like concat('%',#{vo.nodeId},'%')
+        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id left join u_archive_file uaf on uaa.id =
+        uaf.archive_id
+        where uaa.is_deleted = 0 and uaa.is_archive = 1
+        <if test="vo.contractId != null and vo.contractId != ''">
+            and uaa.contract_id = #{vo.contractId}
+        </if>
         <if test="vo.searchType == 2 and vo.queryValue != null and vo.queryValue != ''">
             and uaf.file_name like concat('%',#{vo.queryValue},'%')
         </if>
@@ -680,11 +722,10 @@
     </select>
 
     <select id="getArchivesCabinet" resultMap="archivesAutoResultMap">
-        select uaa.* from
+        select uaa.id,uaa.name,uaa.file_number,uaa.unit from
         (SELECT id FROM m_archive_tree_contract WHERE project_id =#{vo.projectId}
         and  ancestors like concat('%',#{vo.nodeId},'%')
-        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id left join u_archive_file uaf on uaa.id =
-        uaf.archive_id
+        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id
         where uaa.is_deleted = 0 and uaa.is_archive = 1
         <if test="vo.contractId != null and vo.contractId != ''">
             and uaa.contract_id = #{vo.contractId}
@@ -695,6 +736,53 @@
     </select>
 
     <select id="getArchivesCabinet2" resultMap="archivesAutoResultMap">
+        select uaa.id from
+        (SELECT id FROM m_archive_tree_contract WHERE project_id =#{vo.projectId}
+        and  ancestors like concat('%',#{vo.nodeId},'%')
+        ) matc left join u_archives_auto uaa on matc.id = uaa.node_id
+        where uaa.is_deleted = 0 and uaa.is_archive = 1
+        <if test="vo.contractId != null and vo.contractId != ''">
+            and uaa.contract_id = #{vo.contractId}
+        </if>
+        <if test="vo.searchType == 1 and vo.queryValue != null and vo.queryValue != ''">
+            and uaa.name like concat('%',#{vo.queryValue},'%')
+        </if>
+        <if test="vo.storageTimes != null and vo.storageTimes != ''">
+            and uaa.storage_time in
+            <foreach collection="vo.storageTimes" item="storageTime" open="(" separator="," close=")">
+                #{storageTime}
+            </foreach>
+        </if>
+        <if test="vo.secretLevels != null and vo.secretLevels != ''">
+            and uaa.secret_level in
+            <foreach collection="vo.secretLevels" item="secretLevel" open="(" separator="," close=")">
+                #{secretLevel}
+            </foreach>
+        </if>
+        <if test="vo.carrierTypes != null and vo.carrierTypes != ''">
+            and uaa.carrier_type in
+            <foreach collection="vo.carrierTypes" item="carrierType" open="(" separator="," close=")">
+                #{carrierType}
+            </foreach>
+        </if>
+        <if test="vo.years != null and vo.years != ''">
+            and
+            <foreach collection="vo.years" item="year" separator=" or" open="(" close=")">
+                #{year} BETWEEN DATE_FORMAT(uaa.start_date,'%Y') and DATE_FORMAT(uaa.end_date ,'%Y')
+            </foreach>
+        </if>
+        <if test="vo.months != null and vo.months != ''">
+            and
+            <foreach collection="vo.months" item="month" separator=" or" open="(" close=")">
+                #{month} BETWEEN DATE_FORMAT(uaa.start_date,'%c') and DATE_FORMAT(uaa.end_date ,'%c')
+            </foreach>
+        </if>
+        GROUP BY uaa.id
+                order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
+--         order by uaa.id
+    </select>
+
+    <select id="getArchivesCabinet22" resultMap="archivesAutoResultMap">
         select uaa.id from
         (SELECT id FROM m_archive_tree_contract WHERE project_id =#{vo.projectId}
         and  ancestors like concat('%',#{vo.nodeId},'%')
@@ -741,8 +829,8 @@
             </foreach>
         </if>
         GROUP BY uaa.id
-                order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
---         order by uaa.id
+        order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
+        --         order by uaa.id
     </select>
 
     <select id="getAllArchiveByContractType" resultType="org.springblade.archive.vo.ArchivesAutoVO">

+ 12 - 2
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -216,7 +216,12 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 			vo.setYears(null);
 			vo.setMonths(null);
 		}
-		List<ArchivesAutoVO> selectAutos = baseMapper.pageByArchivesAuto4(vo);
+		List<ArchivesAutoVO> selectAutos = new ArrayList<>();
+		if (vo.getSearchType() == 1) {
+			selectAutos = baseMapper.pageByArchivesAuto4(vo);
+		}else {
+			selectAutos = baseMapper.pageByArchivesAuto5(vo);
+		}
 		List<Long> ids = new ArrayList<>();
 		if (selectAutos != null && selectAutos.size() > 0) {
 			ids = selectAutos.stream().map(l -> l.getId()).collect(Collectors.toList());
@@ -336,7 +341,12 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		//根据单位查询所有档案
 		List<ArchivesAutoVO> archivesAutos = baseMapper.getArchivesCabinet(archivesAuto);
 		//根据选择条件查询所有档案
-		List<ArchivesAutoVO> selectAutos = baseMapper.getArchivesCabinet2(archivesAuto);
+		List<ArchivesAutoVO> selectAutos = new ArrayList<>();
+		if (archivesAuto.getSearchType() == 1) {
+			selectAutos = baseMapper.getArchivesCabinet2(archivesAuto);
+		}else {
+			selectAutos = baseMapper.getArchivesCabinet22(archivesAuto);
+		}
 		List<Long> ids = new ArrayList<>();
 		if (selectAutos != null && selectAutos.size() > 0) {
 			ids = selectAutos.stream().map(l -> l.getId()).collect(Collectors.toList());