Преглед на файлове

Merge branch 'refs/heads/feature-lihb-20250715' into dev

# Conflicts:
#	blade-service/blade-archive/src/main/java/org/springblade/archive/service/IArchivesAutoService.java
LHB преди 3 седмици
родител
ревизия
247250e7ff

+ 65 - 0
blade-service-api/blade-archive-api/src/main/java/org/springblade/archive/entity/ArchivesSortRule.java

@@ -0,0 +1,65 @@
+package org.springblade.archive.entity;
+
+import com.baomidou.mybatisplus.annotation.IdType;
+import com.baomidou.mybatisplus.annotation.TableId;
+import com.baomidou.mybatisplus.annotation.TableName;
+import java.util.Date;
+
+import io.swagger.annotations.ApiModelProperty;
+import lombok.Data;
+
+/**
+ * 档案案卷排序规则
+ * @author LHB
+ * @TableName u_archives_sort_rule
+ */
+@TableName(value ="u_archives_sort_rule")
+@Data
+public class ArchivesSortRule {
+    /**
+     * 
+     */
+    @ApiModelProperty(value = "主键id")
+    @TableId(type = IdType.INPUT)
+    private Long id;
+
+    /**
+     * 项目id
+     */
+    @ApiModelProperty(value = "项目id")
+    private Long projectId;
+
+    /**
+     *  类型(1-节点配许,2-流水号排序)
+     */
+    @ApiModelProperty(value = "类型(1-节点配许,2-流水号排序)")
+    private Integer type;
+
+    /**
+     *  创建时间
+     */
+    @org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @com.fasterxml.jackson.annotation.JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "创建时间")
+    private Date createTime;
+
+    /**
+     *  创建人
+     */
+    @ApiModelProperty(value = "创建人")
+    private Long createUser;
+
+    /**
+     *  修改时间
+     */
+    @org.springframework.format.annotation.DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @com.fasterxml.jackson.annotation.JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
+    @ApiModelProperty(value = "修改时间")
+    private Date updateTime;
+
+    /**
+     *  修改人
+     */
+    @ApiModelProperty(value = "修改人")
+    private Long updateUser;
+}

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

@@ -170,6 +170,11 @@ public class ArchivesAutoVO extends ArchivesAuto {
 	 */
 	private String innerSearch;
 
+	/**
+	 * 排序规则
+	 */
+	private Integer sortRuleType;
+
 	@ApiModelProperty("批量保存")
 	private List<ArchivesAutoVO> list;
 	/**

+ 16 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/controller/ArchivesAutoController.java

@@ -1090,5 +1090,21 @@ public class ArchivesAutoController extends BladeController {
         return R.status(archivesAutoService.reBuildArchiveFrontPdfs(archiveIds,projectId));
     }
 
+    @GetMapping("/sortRule")
+    @ApiOperationSupport(order = 42)
+    @ApiModelProperty(value = "排序规则")
+	@ApiImplicitParams(value = {
+			@ApiImplicitParam(name = "projectId", value = "项目id", required = true),
+			@ApiImplicitParam(name = "type", value = "排序类型:1-节点排序,2-流水号排序", required = true)
+	})
+    public R sortRule(Long projectId,Integer type){
+		if(projectId == null){
+			return R.fail("项目id不能为空");
+		}
+		if(type == null || type < 1 || type > 2){
+			return R.fail("排序类型错误");
+		}
+        return R.status(archivesAutoService.sortRule(projectId,type));
+    }
 
 }

+ 67 - 8
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesAutoMapper.xml

@@ -262,16 +262,13 @@
 
 
     <select id="selectArchivesAutoFileCount" resultType="java.lang.Integer">
-        select count(id) from u_archives_auto u where u.is_deleted = 0
+        select count(0) from u_archives_auto u LEFT JOIN m_archive_tree_contract m ON u.node_id = m.id where u.is_deleted = 0
         <if test="vo.projectId != null and vo.projectId != ''">
             and u.project_id = #{vo.projectId}
         </if>
         <if test="vo.queryValue != null and vo.queryValue != ''">
             and (u.name like concat('%',#{vo.queryValue},'%') or u.file_number like concat('%',#{vo.queryValue},'%'))
         </if>
-        <if test="vo.isAutoFile != null and vo.isAutoFile != ''">
-            and u.is_auto_file = #{vo.isAutoFile}
-        </if>
         <choose>
             <when test="vo.isArchive != null and vo.isArchive != ''">
                 and u.is_archive = #{vo.isArchive}
@@ -289,6 +286,22 @@
                 #{nodeId}
             </foreach>
         </if>
+        <if test="vo.queryValueSize != null and vo.queryValueSize != ''">
+            <choose>
+                <when test="vo.queryValueSize == 1">
+                    and CHAR_LENGTH(u.name) <![CDATA[ < ]]> 80
+                </when>
+                <when test="vo.queryValueSize == 2">
+                    and CHAR_LENGTH(u.name) >= 80 and CHAR_LENGTH(u.name) <![CDATA[ < ]]> 120
+                </when>
+                <when test="vo.queryValueSize == 3">
+                    and CHAR_LENGTH(u.name) >= 120 and CHAR_LENGTH(u.name) <![CDATA[ < ]]> 150
+                </when>
+                <when test="vo.queryValueSize == 4">
+                    and CHAR_LENGTH(u.name) >= 150
+                </when>
+            </choose>
+        </if>
     </select>
 
     <select id="selectArchivesAutoFilePage" resultMap="archivesAutoResultMap">
@@ -332,8 +345,23 @@
                 </when>
             </choose>
         </if>
-        order by m.tree_sort,u.auto_file_sort is null ,u.auto_file_sort,u.file_number is null,
-        SUBSTRING_INDEX(u.file_number, '_', 1), SUBSTRING_INDEX(u.file_number, '_', -1) + 0 ,u.create_time asc
+        <choose>
+            <when test="vo.sortRuleType != null and vo.sortRuleType == 1 and vo.isArchive != null and vo.isArchive != ''">
+                ORDER BY
+                    m.tree_sort,
+                    CASE WHEN u.file_number IS NULL THEN 1 ELSE 0 END,
+                    CAST(SUBSTRING_INDEX(file_number, '_', -1) AS SIGNED)
+            </when>
+            <when test="vo.sortRuleType != null and vo.sortRuleType == 2 and vo.isArchive != null and vo.isArchive != ''">
+                order by
+                    CASE WHEN u.file_number IS NULL THEN 1 ELSE 0 END,
+                    CAST(SUBSTRING_INDEX(file_number, '_', -1) AS SIGNED)
+            </when>
+            <otherwise>
+                order by m.tree_sort,u.auto_file_sort is null ,u.auto_file_sort,u.file_number is null,
+                SUBSTRING_INDEX(u.file_number, '_', 1), SUBSTRING_INDEX(u.file_number, '_', -1) + 0 ,u.create_time asc
+            </otherwise>
+        </choose>
         limit #{current}, #{size}
     </select>
 
@@ -663,7 +691,23 @@
             </foreach>
         </if>
         GROUP BY uaa.id
-        order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
+
+        <choose>
+            <when test="vo.sortRuleType != null and vo.sortRuleType == 1">
+                ORDER BY
+                matc.tree_sort,
+                CASE WHEN uaa.file_number IS NULL THEN 1 ELSE 0 END,
+                CAST(SUBSTRING_INDEX(uaa.file_number, '_', -1) AS SIGNED)
+            </when>
+            <when test="vo.sortRuleType != null and vo.sortRuleType == 2">
+                ORDER BY
+                CASE WHEN uaa.file_number IS NULL THEN 1 ELSE 0 END,
+                CAST(SUBSTRING_INDEX(uaa.file_number, '_', -1) AS SIGNED)
+            </when>
+            <otherwise>
+                order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
+            </otherwise>
+        </choose>
     </select>
 
     <select id="pageByArchivesAuto11" resultMap="archivesAutoResultMap">
@@ -722,7 +766,22 @@
             </foreach>
         </if>
         GROUP BY uaa.id
-        order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
+        <choose>
+            <when test="vo.sortRuleType != null and vo.sortRuleType == 1">
+                ORDER BY
+                matc.tree_sort,
+                CASE WHEN uaa.file_number IS NULL THEN 1 ELSE 0 END,
+                CAST(SUBSTRING_INDEX(uaa.file_number, '_', -1) AS SIGNED)
+            </when>
+            <when test="vo.sortRuleType != null and vo.sortRuleType == 2">
+                ORDER BY
+                CASE WHEN uaa.file_number IS NULL THEN 1 ELSE 0 END,
+                CAST(SUBSTRING_INDEX(uaa.file_number, '_', -1) AS SIGNED)
+            </when>
+            <otherwise>
+                order by uaa.tree_sort,uaa.auto_file_sort,uaa.file_number asc
+            </otherwise>
+        </choose>
     </select>
 
     <select id="pageByArchivesAuto2" resultMap="archivesAutoResultMap">

+ 18 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesSortRuleMapper.java

@@ -0,0 +1,18 @@
+package org.springblade.archive.mapper;
+
+import org.springblade.archive.entity.ArchivesSortRule;
+import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+
+/**
+* @author LHB
+* @description 针对表【u_archives_sort_rule(档案案卷排序规则)】的数据库操作Mapper
+* @createDate 2025-07-15 11:37:52
+* @Entity generator.domain.UArchivesSortRule
+*/
+public interface ArchivesSortRuleMapper extends BaseMapper<ArchivesSortRule> {
+
+}
+
+
+
+

+ 21 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/mapper/ArchivesSortRuleMapper.xml

@@ -0,0 +1,21 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!DOCTYPE mapper
+        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
+        "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
+<mapper namespace="org.springblade.archive.mapper.ArchivesSortRuleMapper">
+
+    <resultMap id="BaseResultMap" type="org.springblade.archive.entity.ArchivesSortRule">
+            <id property="id" column="id" />
+            <result property="projectId" column="project_id" />
+            <result property="type" column="type" />
+            <result property="createTime" column="create_time" />
+            <result property="createUser" column="create_user" />
+            <result property="updateTime" column="update_time" />
+            <result property="updateUser" column="update_user" />
+    </resultMap>
+
+    <sql id="Base_Column_List">
+        id,project_id,type,create_time,create_user,update_time,
+        update_user
+    </sql>
+</mapper>

+ 13 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/ArchivesSortRuleService.java

@@ -0,0 +1,13 @@
+package org.springblade.archive.service;
+
+import org.springblade.archive.entity.ArchivesSortRule;
+import com.baomidou.mybatisplus.extension.service.IService;
+
+/**
+* @author LHB
+* @description 针对表【u_archives_sort_rule(档案案卷排序规则)】的数据库操作Service
+* @createDate 2025-07-15 11:37:52
+*/
+public interface ArchivesSortRuleService extends IService<ArchivesSortRule> {
+
+}

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

@@ -171,4 +171,6 @@ public interface IArchivesAutoService extends BaseService<ArchivesAuto> {
 	boolean creatFileNameFormAI(String ids, Long projectId, Long contractId) throws IOException;
 
 	List<ArchivesAutoVO5> selectArchivesAutoFileFormDownload(Long projectId, Long contractId, List<String> ids);
+
+	boolean sortRule(Long projectId, Integer type);
 }

+ 38 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesAutoServiceImpl.java

@@ -25,6 +25,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 
 import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
 import com.baomidou.mybatisplus.core.toolkit.Wrappers;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.itextpdf.text.*;
@@ -156,6 +157,8 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 
 	private final IArchiveAiNameService aiNameService;
 
+	private final ArchivesSortRuleService archivesSortRuleService;
+
 
 	@Override
 	public IPage<ArchivesAutoVO> selectArchivesAutoPage(IPage<ArchivesAutoVO> page, ArchivesAutoVO archivesAuto) {
@@ -212,6 +215,15 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 				vo.setContractId(null);
 			}
 		}
+		//添加排序规则
+		if(vo.getProjectId() != null){
+			ArchivesSortRule one = archivesSortRuleService.getOne(Wrappers.<ArchivesSortRule>lambdaQuery()
+					.eq(ArchivesSortRule::getProjectId, vo.getProjectId()));
+			if(one != null){
+				//添加排序类型
+				vo.setSortRuleType(one.getType());
+			}
+		}
 		if (StringUtils.isNotBlank(vo.getNodeIds())) {
 			vo.setNodeIdArray(Arrays.asList(vo.getNodeIds().split(",")));
 			//如果搜索类型不为文件,就不连接文件表
@@ -633,6 +645,15 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 			fixArchivesAutoFile(vo);
 		}
 
+		//添加排序规则
+		if(vo.getProjectId() != null){
+			ArchivesSortRule one = archivesSortRuleService.getOne(Wrappers.<ArchivesSortRule>lambdaQuery()
+					.eq(ArchivesSortRule::getProjectId, vo.getProjectId()));
+			if(one != null){
+				//添加排序类型
+				vo.setSortRuleType(one.getType());
+			}
+		}
 		List<ArchivesAuto> pageList = this.baseMapper.selectArchivesAutoFilePage(current, vo.getSize(), vo);
 		//设置分页信息
 		iPage.setTotal(total);
@@ -4916,4 +4937,21 @@ public class ArchivesAutoServiceImpl extends BaseServiceImpl<ArchivesAutoMapper,
 		}
 	}
 
+	@Override
+	public boolean sortRule(Long projectId, Integer type) {
+		//根据项目id查询如果没有就新增,如果有就修改
+		ArchivesSortRule one = archivesSortRuleService.getOne(Wrappers.<ArchivesSortRule>lambdaQuery()
+				.eq(ArchivesSortRule::getProjectId, projectId));
+		if (one == null) {
+			one = new ArchivesSortRule();
+			one.setId(SnowFlakeUtil.getId());
+			one.setProjectId(projectId);
+			one.setCreateUser(AuthUtil.getUserId());
+		} else {
+			one.setUpdateUser(AuthUtil.getUserId());
+		}
+		one.setType(type);
+		archivesSortRuleService.saveOrUpdate(one);
+		return true;
+	}
 }

+ 22 - 0
blade-service/blade-archive/src/main/java/org/springblade/archive/service/impl/ArchivesSortRuleServiceImpl.java

@@ -0,0 +1,22 @@
+package org.springblade.archive.service.impl;
+
+import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import org.springblade.archive.entity.ArchivesSortRule;
+import org.springblade.archive.mapper.ArchivesSortRuleMapper;
+import org.springblade.archive.service.ArchivesSortRuleService;
+import org.springframework.stereotype.Service;
+
+/**
+* @author LHB
+* @description 针对表【u_archives_sort_rule(档案案卷排序规则)】的数据库操作Service实现
+* @createDate 2025-07-15 11:37:52
+*/
+@Service
+public class ArchivesSortRuleServiceImpl extends ServiceImpl<ArchivesSortRuleMapper, ArchivesSortRule>
+    implements ArchivesSortRuleService {
+
+}
+
+
+
+