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

档案利用-档案查询

qianxb 2 жил өмнө
parent
commit
f44bcd2435

+ 21 - 0
blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/vo/ArchivesAutoVO.java

@@ -59,12 +59,16 @@ public class ArchivesAutoVO extends ArchivesAuto {
 	@ApiModelProperty("年")
 	private String year;
 
+	private List<String> years;
+
 	/**
 	 * 年
 	 */
 	@ApiModelProperty("月")
 	private String month;
 
+	private List<String> months;
+
 	/**
 	 * 输入框查询条件
 	 */
@@ -84,11 +88,26 @@ public class ArchivesAutoVO extends ArchivesAuto {
 	 */
 	private String secretLevelValue;
 
+	/**
+	 * 搜索密级集合
+	 */
+	private List<String> secretLevels;
+
 	/**
 	 * 保管期限(单位/年)
 	 */
 	private String storageTimeValue;
 
+	/**
+	 * 搜索期限集合
+	 */
+	private List<String> storageTimes;
+
+	/**
+	 * 搜索类别集合
+	 */
+	private List<String> carrierTypes;
+
 	@ApiModelProperty("批量保存")
 	private List<ArchivesAutoVO> list;
 	/**
@@ -152,5 +171,7 @@ public class ArchivesAutoVO extends ArchivesAuto {
 		 * 责任者
 		 */
 		private String dutyUser;
+
+		private  String archiveId;
 	}
 }

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

@@ -56,4 +56,6 @@ public interface ArchivesAutoMapper extends BaseMapper<ArchivesAuto> {
 	 *  根据项目id获取所有档案
 	 */
 	List<ArchivesAutoDTO> getListByProjectId(@Param("projectId") Long projectId);
+
+    List<ArchivesAuto> pageByArchivesAuto(IPage page, @Param("vo") ArchivesAutoVO vo);
 }

+ 55 - 1
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -3,7 +3,7 @@
 <mapper namespace="org.springblade.archive.mapper.ArchivesAutoMapper">
 
     <!-- 通用查询映射结果 -->
-    <resultMap id="archivesAutoResultMap" type="org.springblade.archive.entity.ArchivesAuto">
+    <resultMap id="archivesAutoResultMap" type="org.springblade.archive.vo.ArchivesAutoVO">
         <result column="id" property="id"/>
         <result column="create_user" property="createUser"/>
         <result column="create_dept" property="createDept"/>
@@ -47,8 +47,18 @@
         <result column="is_auto_file" property="isAutoFile"/>
         <result column="auto_file_sort" property="autoFileSort"/>
         <result column="filing_unit" property="filingUnit"/>
+        <collection property="approvalFileList" javaType="java.util.List"
+                    select="approvalFile"
+                    column="{archiveId=id}">
+        </collection>
     </resultMap>
 
+    <select id="approvalFile" resultType="org.springblade.archive.vo.ArchivesAutoVO$ApprovalFile">
+        <if test="archiveId!=null">
+            select * from u_archive_file where archive_id = #{archiveId}
+        </if>
+    </select>
+
 
     <select id="selectArchivesAutoPage" resultMap="archivesAutoResultMap">
         select * from u_archives_auto where is_deleted = 0
@@ -124,6 +134,50 @@
         from u_archives_auto
         where project_id=#{projectId};
     </select>
+    <select id="pageByArchivesAuto" resultMap="archivesAutoResultMap">
+        select uaa.* from u_archives_auto uaa left join u_archive_file uaf on uaa.id = uaf.archive_id
+        where uaa.is_deleted = 0
+        <if test="vo.projectId != null and vo.projectId != ''">
+            and uaa.project_id = #{vo.projectId}
+        </if>
+        <if test="vo.searchType == 1 and vo.queryValue != null and vo.queryValue != ''">
+            and uaa.name like concat('%',#{vo.queryValue},'%')
+        </if>
+        <if test="vo.searchType == 2 and vo.queryValue != null and vo.queryValue != ''">
+            and uaf.file_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
+    </select>
 
 
 </mapper>

+ 15 - 56
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -69,64 +69,23 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 
 	@Override
 	public IPage<ArchivesAuto> pageByArchivesAuto(ArchivesAutoVO vo) {
-		IPage<ArchivesAuto> page = new Page<>(vo.getCurrent(),vo.getSize());
-		LambdaQueryWrapper<ArchivesAuto> lqw = new LambdaQueryWrapper<>();
-		lqw.eq(ArchivesAuto::getProjectId,vo.getProjectId());
-		//过滤日期
-		if (StringUtils.isNotBlank(vo.getYear())){
-			if (StringUtils.isNotBlank(vo.getMonth())){
-				int day;
-				if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(vo.getMonth())){
-					day = 31;
-				}else if (Arrays.asList("1,3,5,7,8,10,12".split(",")).contains(vo.getMonth())){
-					day = 30;
-				}else {
-					if (Integer.parseInt(vo.getYear()) % 4 == 0){
-						day = 29;
-					}else {
-						day = 28;
-					}
-				}
-				lqw.ge(ArchivesAuto::getStartDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), Integer.parseInt(vo.getMonth()), 1, 0, 0, 0));
-				lqw.le(ArchivesAuto::getEndDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), Integer.parseInt(vo.getMonth()), day, 0, 0, 0));
-			}else {
-				lqw.ge(ArchivesAuto::getStartDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), 1, 1, 0, 0, 0));
-				lqw.ge(ArchivesAuto::getEndDate,LocalDateTime.of(Integer.parseInt(vo.getYear()), 12, 31, 0, 0, 0));
-			}
-		}else if (StringUtils.isNotBlank(vo.getMonth())){
-			throw new RuntimeException("请选择年");
+		IPage<ArchivesAuto> page = new Page<>();
+		if (StringUtils.isNotBlank(vo.getStorageTime())) {
+			vo.setStorageTimes(Arrays.asList(vo.getStorageTime().split(",")));
 		}
-		lqw.eq(StringUtils.isNotBlank(vo.getStorageTime()),ArchivesAuto::getStorageTime,vo.getStorageTime())
-				.eq(StringUtils.isNotBlank(vo.getSecretLevel()),ArchivesAuto::getSecretLevel,vo.getSecretLevel())
-					.eq(StringUtils.isNotBlank(vo.getCarrierType()),ArchivesAuto::getCarrierType,vo.getCarrierType());
-		//按案卷搜索完成,判断是否按文件搜索
-		if (vo.getSearchType() == 1){
-			lqw.like(StringUtils.isNotBlank(vo.getQueryValue()),ArchivesAuto::getName,vo.getQueryValue());
-			this.page(page,lqw);
-			return page;
-		}else {
-			List<ArchivesAuto> list = this.list(lqw);
-			list = list.stream().filter(auto -> {
-				List<ArchiveFile> files = archiveFileClient.getArchiveFileByArchivesId(auto.getId() + "", "");
-				if (files != null && files.size() > 0){
-					files = files.stream().filter(file->file.getFileName().contains(vo.getQueryValue())).collect(Collectors.toList());
-				}
-				if (files != null && files.size() > 0){
-					return true;
-				}else {
-					return false;
-				}
-			}).collect(Collectors.toList());
-			if (list != null && list.size() > 0){
-				List<Long> ids = list.stream().map(l -> l.getId()).collect(Collectors.toList());
-				this.page(page,new LambdaQueryWrapper<ArchivesAuto>().in(ArchivesAuto::getId,ids));
-				return page;
-			}else {
-				return  null;
-			}
-
+		if (StringUtils.isNotBlank(vo.getSecretLevel())){
+			vo.setSecretLevels(Arrays.asList(vo.getSecretLevel().split(",")));
 		}
-
+		if (StringUtils.isNotBlank(vo.getCarrierType())) {
+			vo.setCarrierTypes(Arrays.asList(vo.getCarrierType().split(",")));
+		}
+		if (StringUtils.isNotBlank(vo.getYear())) {
+			vo.setYears(Arrays.asList(vo.getYear().split(",")));
+		}
+		if (StringUtils.isNotBlank(vo.getMonth())) {
+			vo.setMonths(Arrays.asList(vo.getMonth().split(",")));
+		}
+		return page.setRecords(baseMapper.pageByArchivesAuto(page,vo));
 	}
 
 	@Override