完成亲属资产后端联调验证
This commit is contained in:
@@ -46,7 +46,7 @@
|
|||||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||||
FROM ccdi_staff_fmy_relation r
|
FROM ccdi_staff_fmy_relation r
|
||||||
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
||||||
<where>
|
WHERE 1 = 1
|
||||||
AND r.is_emp_family = 1
|
AND r.is_emp_family = 1
|
||||||
<if test="query.personId != null and query.personId != ''">
|
<if test="query.personId != null and query.personId != ''">
|
||||||
AND r.person_id = #{query.personId}
|
AND r.person_id = #{query.personId}
|
||||||
@@ -72,7 +72,6 @@
|
|||||||
<if test="query.effectiveDateEnd != null">
|
<if test="query.effectiveDateEnd != null">
|
||||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
|
||||||
ORDER BY r.create_time DESC
|
ORDER BY r.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
@@ -101,7 +100,7 @@
|
|||||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||||
FROM ccdi_staff_fmy_relation r
|
FROM ccdi_staff_fmy_relation r
|
||||||
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
||||||
<where>
|
WHERE 1 = 1
|
||||||
AND r.is_emp_family = 1
|
AND r.is_emp_family = 1
|
||||||
<if test="query.personId != null and query.personId != ''">
|
<if test="query.personId != null and query.personId != ''">
|
||||||
AND r.person_id = #{query.personId}
|
AND r.person_id = #{query.personId}
|
||||||
@@ -127,7 +126,6 @@
|
|||||||
<if test="query.effectiveDateEnd != null">
|
<if test="query.effectiveDateEnd != null">
|
||||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||||
</if>
|
</if>
|
||||||
</where>
|
|
||||||
ORDER BY r.create_time DESC
|
ORDER BY r.create_time DESC
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package com.ruoyi.info.collection.mapper;
|
package com.ruoyi.info.collection.mapper;
|
||||||
|
|
||||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||||
|
import com.github.pagehelper.parser.defaults.DefaultCountSqlParser;
|
||||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||||
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
|
import org.apache.ibatis.builder.xml.XMLMapperBuilder;
|
||||||
import org.apache.ibatis.mapping.BoundSql;
|
import org.apache.ibatis.mapping.BoundSql;
|
||||||
@@ -35,9 +36,11 @@ class CcdiStaffFmyRelationMapperTest {
|
|||||||
"page", new Page<>(1, 10),
|
"page", new Page<>(1, 10),
|
||||||
"query", queryDTO
|
"query", queryDTO
|
||||||
));
|
));
|
||||||
|
String countSql = normalizeSql(new DefaultCountSqlParser().getSmartCountSql(sql, "0"));
|
||||||
|
|
||||||
assertTrue(sql.contains("WHERE r.is_emp_family = 1 AND r.person_id = ?"), sql);
|
assertTrue(sql.contains("WHERE 1 = 1 AND r.is_emp_family = 1 AND r.person_id = ?"), sql);
|
||||||
assertFalse(sql.contains("1AND"), sql);
|
assertFalse(sql.contains("1AND"), sql);
|
||||||
|
assertFalse(countSql.contains("1AND"), countSql);
|
||||||
}
|
}
|
||||||
|
|
||||||
private MappedStatement loadMappedStatement(String statementId) throws Exception {
|
private MappedStatement loadMappedStatement(String statementId) throws Exception {
|
||||||
@@ -57,7 +60,11 @@ class CcdiStaffFmyRelationMapperTest {
|
|||||||
|
|
||||||
private String renderSql(MappedStatement mappedStatement, Map<String, Object> params) {
|
private String renderSql(MappedStatement mappedStatement, Map<String, Object> params) {
|
||||||
BoundSql boundSql = mappedStatement.getBoundSql(new HashMap<>(params));
|
BoundSql boundSql = mappedStatement.getBoundSql(new HashMap<>(params));
|
||||||
return boundSql.getSql().replaceAll("\\s+", " ").trim();
|
return normalizeSql(boundSql.getSql());
|
||||||
|
}
|
||||||
|
|
||||||
|
private String normalizeSql(String sql) {
|
||||||
|
return sql.replaceAll("\\s+", " ").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void registerTypeAliases(TypeAliasRegistry typeAliasRegistry) {
|
private void registerTypeAliases(TypeAliasRegistry typeAliasRegistry) {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
USE ccdi;
|
USE ccdi;
|
||||||
|
|
||||||
|
-- 新建表结构(适用于首次落库)
|
||||||
CREATE TABLE IF NOT EXISTS `ccdi_asset_info` (
|
CREATE TABLE IF NOT EXISTS `ccdi_asset_info` (
|
||||||
`asset_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '资产ID',
|
`asset_id` BIGINT(20) NOT NULL AUTO_INCREMENT COMMENT '资产ID',
|
||||||
`family_id` VARCHAR(100) NOT NULL COMMENT '归属员工证件号',
|
`family_id` VARCHAR(100) NOT NULL COMMENT '归属员工证件号',
|
||||||
@@ -23,3 +24,16 @@ CREATE TABLE IF NOT EXISTS `ccdi_asset_info` (
|
|||||||
KEY `idx_person_id` (`person_id`),
|
KEY `idx_person_id` (`person_id`),
|
||||||
KEY `idx_family_person` (`family_id`, `person_id`)
|
KEY `idx_family_person` (`family_id`, `person_id`)
|
||||||
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='亲属资产信息表';
|
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='亲属资产信息表';
|
||||||
|
|
||||||
|
-- 存量环境迁移说明
|
||||||
|
-- 如果当前库中的 ccdi_asset_info 仍是旧“员工资产信息表”结构,需要至少执行以下迁移:
|
||||||
|
-- 1. 将 family_id / person_id 扩容到 VARCHAR(100),以兼容非 18 位证件号
|
||||||
|
-- 2. 补齐 idx_family_person 联合索引
|
||||||
|
-- 3. 旧索引 idx_asset_main_type 可按需保留或删除,不影响本次功能
|
||||||
|
--
|
||||||
|
-- 示例迁移语句:
|
||||||
|
-- ALTER TABLE `ccdi_asset_info`
|
||||||
|
-- MODIFY `family_id` VARCHAR(100) NOT NULL COMMENT '归属员工证件号',
|
||||||
|
-- MODIFY `person_id` VARCHAR(100) NOT NULL COMMENT '资产实际持有人证件号';
|
||||||
|
--
|
||||||
|
-- CREATE INDEX `idx_family_person` ON `ccdi_asset_info` (`family_id`, `person_id`);
|
||||||
|
|||||||
Reference in New Issue
Block a user