新增亲属资产领域对象与映射
This commit is contained in:
@@ -13,7 +13,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工资产信息对象 ccdi_asset_info
|
||||
* 资产信息对象 ccdi_asset_info
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
@@ -29,10 +29,10 @@ public class CcdiAssetInfo implements Serializable {
|
||||
@TableId(type = IdType.AUTO)
|
||||
private Long assetId;
|
||||
|
||||
/** 归属员工身份证号 */
|
||||
/** 归属员工证件号 */
|
||||
private String familyId;
|
||||
|
||||
/** 资产实际持有人身份证号 */
|
||||
/** 资产实际持有人证件号 */
|
||||
private String personId;
|
||||
|
||||
/** 资产大类 */
|
||||
|
||||
@@ -4,7 +4,6 @@ import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import io.swagger.v3.oas.annotations.media.Schema;
|
||||
import jakarta.validation.constraints.NotBlank;
|
||||
import jakarta.validation.constraints.NotNull;
|
||||
import jakarta.validation.constraints.Pattern;
|
||||
import jakarta.validation.constraints.Size;
|
||||
import lombok.Data;
|
||||
|
||||
@@ -14,24 +13,18 @@ import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工资产信息DTO
|
||||
* 亲属资产信息DTO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "员工资产信息")
|
||||
@Schema(description = "亲属资产信息")
|
||||
public class CcdiAssetInfoDTO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 资产实际持有人身份证号 */
|
||||
@NotBlank(message = "资产实际持有人身份证号不能为空")
|
||||
@Pattern(regexp = "^[1-9]\\d{5}(18|19|20)\\d{2}(0[1-9]|1[0-2])(0[1-9]|[12]\\d|3[01])\\d{3}[0-9Xx]$", message = "资产实际持有人身份证号格式不正确")
|
||||
@Schema(description = "资产实际持有人身份证号")
|
||||
private String personId;
|
||||
|
||||
/** 资产大类 */
|
||||
@NotBlank(message = "资产大类不能为空")
|
||||
@Size(max = 20, message = "资产大类长度不能超过20个字符")
|
||||
|
||||
@@ -11,7 +11,7 @@ import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工资产信息Excel导入导出对象
|
||||
* 亲属资产信息Excel导入导出对象
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
@@ -22,8 +22,8 @@ public class CcdiAssetInfoExcel implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 资产实际持有人身份证号 */
|
||||
@ExcelProperty(value = "资产实际持有人身份证号*", index = 0)
|
||||
/** 关系人证件号 */
|
||||
@ExcelProperty(value = "关系人证件号*", index = 0)
|
||||
@ColumnWidth(22)
|
||||
@Required
|
||||
private String personId;
|
||||
|
||||
@@ -6,17 +6,17 @@ import lombok.Data;
|
||||
import java.math.BigDecimal;
|
||||
|
||||
/**
|
||||
* 员工资产信息导入失败记录VO
|
||||
* 亲属资产信息导入失败记录VO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "员工资产信息导入失败记录")
|
||||
@Schema(description = "亲属资产信息导入失败记录")
|
||||
public class AssetImportFailureVO {
|
||||
|
||||
/** 资产实际持有人身份证号 */
|
||||
@Schema(description = "资产实际持有人身份证号")
|
||||
/** 关系人证件号 */
|
||||
@Schema(description = "关系人证件号")
|
||||
private String personId;
|
||||
|
||||
/** 资产大类 */
|
||||
|
||||
@@ -10,20 +10,20 @@ import java.math.BigDecimal;
|
||||
import java.util.Date;
|
||||
|
||||
/**
|
||||
* 员工资产信息VO
|
||||
* 资产信息VO
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
*/
|
||||
@Data
|
||||
@Schema(description = "员工资产信息")
|
||||
@Schema(description = "资产信息")
|
||||
public class CcdiAssetInfoVO implements Serializable {
|
||||
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
/** 资产实际持有人身份证号 */
|
||||
@Schema(description = "资产实际持有人身份证号")
|
||||
/** 资产实际持有人证件号 */
|
||||
@Schema(description = "资产实际持有人证件号")
|
||||
private String personId;
|
||||
|
||||
/** 资产大类 */
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* 员工资产信息 数据层
|
||||
* 资产信息 数据层
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
@@ -23,6 +23,16 @@ public interface CcdiAssetInfoMapper extends BaseMapper<CcdiAssetInfo> {
|
||||
*/
|
||||
List<CcdiAssetInfo> selectByFamilyId(@Param("familyId") String familyId);
|
||||
|
||||
/**
|
||||
* 按归属键查询资产列表
|
||||
*
|
||||
* @param familyId 归属员工证件号
|
||||
* @param personId 资产实际持有人证件号
|
||||
* @return 资产列表
|
||||
*/
|
||||
List<CcdiAssetInfo> selectByFamilyIdAndPersonId(@Param("familyId") String familyId,
|
||||
@Param("personId") String personId);
|
||||
|
||||
/**
|
||||
* 按归属员工身份证号删除资产
|
||||
*
|
||||
@@ -31,6 +41,16 @@ public interface CcdiAssetInfoMapper extends BaseMapper<CcdiAssetInfo> {
|
||||
*/
|
||||
int deleteByFamilyId(@Param("familyId") String familyId);
|
||||
|
||||
/**
|
||||
* 按归属键删除资产
|
||||
*
|
||||
* @param familyId 归属员工证件号
|
||||
* @param personId 资产实际持有人证件号
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteByFamilyIdAndPersonId(@Param("familyId") String familyId,
|
||||
@Param("personId") String personId);
|
||||
|
||||
/**
|
||||
* 批量删除归属员工资产
|
||||
*
|
||||
@@ -56,18 +76,10 @@ public interface CcdiAssetInfoMapper extends BaseMapper<CcdiAssetInfo> {
|
||||
int insertBatch(@Param("list") List<CcdiAssetInfo> list);
|
||||
|
||||
/**
|
||||
* 按员工身份证号查询归属信息
|
||||
* 按关系人证件号查询归属员工候选
|
||||
*
|
||||
* @param personIds 资产实际持有人身份证号列表
|
||||
* @param relationCertNos 关系人证件号列表
|
||||
* @return 归属映射
|
||||
*/
|
||||
List<Map<String, String>> selectOwnerByEmployeeIdCards(@Param("personIds") List<String> personIds);
|
||||
|
||||
/**
|
||||
* 按员工家庭关系身份证号查询归属信息
|
||||
*
|
||||
* @param personIds 资产实际持有人身份证号列表
|
||||
* @return 归属映射
|
||||
*/
|
||||
List<Map<String, String>> selectOwnerByFamilyRelationIdCards(@Param("personIds") List<String> personIds);
|
||||
List<Map<String, String>> selectOwnerCandidatesByRelationCertNos(@Param("relationCertNos") List<String> relationCertNos);
|
||||
}
|
||||
|
||||
@@ -34,13 +34,14 @@
|
||||
ORDER BY create_time DESC, asset_id DESC
|
||||
</select>
|
||||
|
||||
<select id="selectByPersonId" resultMap="CcdiAssetInfoResultMap">
|
||||
<select id="selectByFamilyIdAndPersonId" resultMap="CcdiAssetInfoResultMap">
|
||||
SELECT
|
||||
asset_id, family_id, person_id, asset_main_type, asset_sub_type, asset_name,
|
||||
ownership_ratio, purchase_eval_date, original_value, current_value,
|
||||
valuation_date, asset_status, remarks, create_by, create_time, update_by, update_time
|
||||
FROM ccdi_asset_info
|
||||
WHERE person_id = #{personId}
|
||||
WHERE family_id = #{familyId}
|
||||
AND person_id = #{personId}
|
||||
ORDER BY create_time DESC, asset_id DESC
|
||||
</select>
|
||||
|
||||
@@ -49,6 +50,12 @@
|
||||
WHERE family_id = #{familyId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByFamilyIdAndPersonId">
|
||||
DELETE FROM ccdi_asset_info
|
||||
WHERE family_id = #{familyId}
|
||||
AND person_id = #{personId}
|
||||
</delete>
|
||||
|
||||
<delete id="deleteByFamilyIds">
|
||||
DELETE FROM ccdi_asset_info
|
||||
WHERE family_id IN
|
||||
@@ -70,26 +77,15 @@
|
||||
</foreach>
|
||||
</insert>
|
||||
|
||||
<select id="selectOwnerByEmployeeIdCards" resultType="map">
|
||||
SELECT
|
||||
id_card AS personId,
|
||||
id_card AS familyId
|
||||
FROM ccdi_base_staff
|
||||
WHERE id_card IN
|
||||
<foreach collection="personIds" item="personId" open="(" separator="," close=")">
|
||||
#{personId}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
<select id="selectOwnerByFamilyRelationIdCards" resultType="map">
|
||||
<select id="selectOwnerCandidatesByRelationCertNos" resultType="map">
|
||||
SELECT
|
||||
relation_cert_no AS personId,
|
||||
person_id AS familyId
|
||||
FROM ccdi_staff_fmy_relation
|
||||
WHERE is_emp_family = 1
|
||||
AND relation_cert_no IN
|
||||
<foreach collection="personIds" item="personId" open="(" separator="," close=")">
|
||||
#{personId}
|
||||
<foreach collection="relationCertNos" item="relationCertNo" open="(" separator="," close=")">
|
||||
#{relationCertNo}
|
||||
</foreach>
|
||||
</select>
|
||||
|
||||
|
||||
@@ -26,37 +26,33 @@ class CcdiAssetInfoMapperTest {
|
||||
private static final String RESOURCE = "mapper/info/collection/CcdiAssetInfoMapper.xml";
|
||||
|
||||
@Test
|
||||
void selectByFamilyId_shouldFilterByFamilyId() throws Exception {
|
||||
void selectByFamilyIdAndPersonId_shouldFilterByOwnershipKey() throws Exception {
|
||||
MappedStatement mappedStatement = loadMappedStatement(
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.selectByFamilyId");
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.selectByFamilyIdAndPersonId");
|
||||
|
||||
String sql = renderSql(mappedStatement, Map.of("familyId", "320101199001010011"));
|
||||
String sql = renderSql(mappedStatement, Map.of(
|
||||
"familyId", "320101199001010011",
|
||||
"personId", "320101199201010022"
|
||||
));
|
||||
|
||||
assertTrue(sql.contains("FROM ccdi_asset_info"), sql);
|
||||
assertTrue(sql.contains("WHERE family_id = ?"), sql);
|
||||
assertTrue(sql.contains("AND person_id = ?"), sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
void selectByPersonId_shouldFilterByPersonId() throws Exception {
|
||||
void deleteByFamilyIdAndPersonId_shouldFilterByOwnershipKey() throws Exception {
|
||||
MappedStatement mappedStatement = loadMappedStatement(
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.selectByPersonId");
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.deleteByFamilyIdAndPersonId");
|
||||
|
||||
String sql = renderSql(mappedStatement, Map.of("personId", "320101199201010022"));
|
||||
|
||||
assertTrue(sql.contains("FROM ccdi_asset_info"), sql);
|
||||
assertTrue(sql.contains("WHERE person_id = ?"), sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
void deleteByFamilyIds_shouldRenderInClause() throws Exception {
|
||||
MappedStatement mappedStatement = loadMappedStatement(
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.deleteByFamilyIds");
|
||||
|
||||
String sql = renderSql(mappedStatement, Map.of("familyIds", List.of("A", "B")));
|
||||
String sql = renderSql(mappedStatement, Map.of(
|
||||
"familyId", "320101199001010011",
|
||||
"personId", "320101199201010022"
|
||||
));
|
||||
|
||||
assertTrue(sql.contains("DELETE FROM ccdi_asset_info"), sql);
|
||||
assertTrue(sql.contains("family_id IN"), sql);
|
||||
assertFalse(sql.contains("IN ()"), sql);
|
||||
assertTrue(sql.contains("WHERE family_id = ?"), sql);
|
||||
assertTrue(sql.contains("AND person_id = ?"), sql);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -84,23 +80,18 @@ class CcdiAssetInfoMapperTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
void ownerLookupQueries_shouldResolveFromEmployeeAndFamilyRelation() throws Exception {
|
||||
MappedStatement employeeStatement = loadMappedStatement(
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.selectOwnerByEmployeeIdCards");
|
||||
void ownerLookupQuery_shouldResolveFromFamilyRelationOnly() throws Exception {
|
||||
MappedStatement familyStatement = loadMappedStatement(
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.selectOwnerByFamilyRelationIdCards");
|
||||
"com.ruoyi.info.collection.mapper.CcdiAssetInfoMapper.selectOwnerCandidatesByRelationCertNos");
|
||||
|
||||
String employeeSql = renderSql(employeeStatement, Map.of("personIds", List.of("A")));
|
||||
String familySql = renderSql(familyStatement, Map.of("personIds", List.of("B")));
|
||||
|
||||
assertTrue(employeeSql.contains("FROM ccdi_base_staff"), employeeSql);
|
||||
assertTrue(employeeSql.contains("id_card AS personId"), employeeSql);
|
||||
assertTrue(employeeSql.contains("id_card AS familyId"), employeeSql);
|
||||
String familySql = renderSql(familyStatement, Map.of("relationCertNos", List.of("B")));
|
||||
|
||||
assertTrue(familySql.contains("FROM ccdi_staff_fmy_relation"), familySql);
|
||||
assertTrue(familySql.contains("relation_cert_no AS personId"), familySql);
|
||||
assertTrue(familySql.contains("person_id AS familyId"), familySql);
|
||||
assertTrue(familySql.contains("relation_cert_no IN"), familySql);
|
||||
assertTrue(familySql.contains("is_emp_family = 1"), familySql);
|
||||
assertFalse(familySql.contains("FROM ccdi_base_staff"), familySql);
|
||||
}
|
||||
|
||||
private MappedStatement loadMappedStatement(String statementId) throws Exception {
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.ruoyi.info.collection.service;
|
||||
|
||||
import com.ruoyi.info.collection.domain.dto.CcdiAssetInfoDTO;
|
||||
import com.ruoyi.info.collection.domain.excel.CcdiAssetInfoExcel;
|
||||
import org.junit.jupiter.api.Test;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static org.junit.jupiter.api.Assertions.assertFalse;
|
||||
import static org.junit.jupiter.api.Assertions.assertTrue;
|
||||
|
||||
class CcdiAssetInfoDesignContractTest {
|
||||
|
||||
@Test
|
||||
void aggregateSaveDto_shouldNotExposePersonId() {
|
||||
Set<String> fieldNames = Arrays.stream(CcdiAssetInfoDTO.class.getDeclaredFields())
|
||||
.map(field -> field.getName())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertFalse(fieldNames.contains("personId"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void importExcel_shouldStillExposePersonIdForRelationCertNoMatching() {
|
||||
Set<String> fieldNames = Arrays.stream(CcdiAssetInfoExcel.class.getDeclaredFields())
|
||||
.map(field -> field.getName())
|
||||
.collect(Collectors.toSet());
|
||||
|
||||
assertTrue(fieldNames.contains("personId"));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user