实现亲属资产服务与导入服务
This commit is contained in:
@@ -21,6 +21,15 @@ public interface ICcdiAssetInfoService {
|
||||
*/
|
||||
List<CcdiAssetInfo> selectByFamilyId(String familyId);
|
||||
|
||||
/**
|
||||
* 按归属键查询资产列表
|
||||
*
|
||||
* @param familyId 归属员工证件号
|
||||
* @param personId 资产实际持有人证件号
|
||||
* @return 资产列表
|
||||
*/
|
||||
List<CcdiAssetInfo> selectByFamilyIdAndPersonId(String familyId, String personId);
|
||||
|
||||
/**
|
||||
* 按归属员工身份证号覆盖资产列表
|
||||
*
|
||||
@@ -29,6 +38,15 @@ public interface ICcdiAssetInfoService {
|
||||
*/
|
||||
void replaceByFamilyId(String familyId, List<CcdiAssetInfoDTO> assetInfoList);
|
||||
|
||||
/**
|
||||
* 按归属键覆盖资产列表
|
||||
*
|
||||
* @param familyId 归属员工证件号
|
||||
* @param personId 资产实际持有人证件号
|
||||
* @param assetInfoList 资产列表
|
||||
*/
|
||||
void replaceByFamilyIdAndPersonId(String familyId, String personId, List<CcdiAssetInfoDTO> assetInfoList);
|
||||
|
||||
/**
|
||||
* 删除单个员工资产
|
||||
*
|
||||
@@ -37,6 +55,15 @@ public interface ICcdiAssetInfoService {
|
||||
*/
|
||||
int deleteByFamilyId(String familyId);
|
||||
|
||||
/**
|
||||
* 按归属键删除资产
|
||||
*
|
||||
* @param familyId 归属员工证件号
|
||||
* @param personId 资产实际持有人证件号
|
||||
* @return 影响行数
|
||||
*/
|
||||
int deleteByFamilyIdAndPersonId(String familyId, String personId);
|
||||
|
||||
/**
|
||||
* 批量删除员工资产
|
||||
*
|
||||
|
||||
@@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* 员工资产信息异步导入服务层处理
|
||||
* 亲属资产信息异步导入服务层处理
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
@@ -97,10 +97,10 @@ public class CcdiAssetInfoImportServiceImpl implements ICcdiAssetInfoImportServi
|
||||
validateExcel(excel);
|
||||
Set<String> familyIds = ownerMap.get(excel.getPersonId());
|
||||
if (familyIds == null || familyIds.isEmpty()) {
|
||||
throw new RuntimeException("未找到资产归属员工");
|
||||
throw new RuntimeException("未找到亲属资产归属员工");
|
||||
}
|
||||
if (familyIds.size() > 1) {
|
||||
throw new RuntimeException("资产归属员工不唯一");
|
||||
throw new RuntimeException("亲属资产归属员工不唯一");
|
||||
}
|
||||
|
||||
CcdiAssetInfo assetInfo = new CcdiAssetInfo();
|
||||
@@ -164,8 +164,7 @@ public class CcdiAssetInfoImportServiceImpl implements ICcdiAssetInfoImportServi
|
||||
|
||||
private Map<String, Set<String>> buildOwnerMap(List<String> personIds) {
|
||||
Map<String, Set<String>> result = new LinkedHashMap<>();
|
||||
mergeOwnerMappings(result, assetInfoMapper.selectOwnerByEmployeeIdCards(personIds));
|
||||
mergeOwnerMappings(result, assetInfoMapper.selectOwnerByFamilyRelationIdCards(personIds));
|
||||
mergeOwnerMappings(result, assetInfoMapper.selectOwnerCandidatesByRelationCertNos(personIds));
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -185,7 +184,7 @@ public class CcdiAssetInfoImportServiceImpl implements ICcdiAssetInfoImportServi
|
||||
|
||||
private void validateExcel(CcdiAssetInfoExcel excel) {
|
||||
if (StringUtils.isEmpty(excel.getPersonId())) {
|
||||
throw new RuntimeException("资产实际持有人身份证号不能为空");
|
||||
throw new RuntimeException("关系人证件号不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(excel.getAssetMainType())) {
|
||||
throw new RuntimeException("资产大类不能为空");
|
||||
|
||||
@@ -30,22 +30,21 @@ public class CcdiAssetInfoServiceImpl implements ICcdiAssetInfoService {
|
||||
return assetInfoMapper.selectByFamilyId(familyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CcdiAssetInfo> selectByFamilyIdAndPersonId(String familyId, String personId) {
|
||||
return assetInfoMapper.selectByFamilyIdAndPersonId(familyId, personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public void replaceByFamilyId(String familyId, List<CcdiAssetInfoDTO> assetInfoList) {
|
||||
assetInfoMapper.deleteByFamilyId(familyId);
|
||||
if (assetInfoList == null || assetInfoList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
replaceAssets(familyId, familyId, assetInfoList, true);
|
||||
}
|
||||
|
||||
List<CcdiAssetInfo> saveList = assetInfoList.stream()
|
||||
.filter(item -> !isEmptyRow(item))
|
||||
.map(item -> toEntity(familyId, item))
|
||||
.toList();
|
||||
|
||||
if (!saveList.isEmpty()) {
|
||||
assetInfoMapper.insertBatch(saveList);
|
||||
}
|
||||
@Override
|
||||
@Transactional
|
||||
public void replaceByFamilyIdAndPersonId(String familyId, String personId, List<CcdiAssetInfoDTO> assetInfoList) {
|
||||
replaceAssets(familyId, personId, assetInfoList, false);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -53,6 +52,11 @@ public class CcdiAssetInfoServiceImpl implements ICcdiAssetInfoService {
|
||||
return assetInfoMapper.deleteByFamilyId(familyId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByFamilyIdAndPersonId(String familyId, String personId) {
|
||||
return assetInfoMapper.deleteByFamilyIdAndPersonId(familyId, personId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int deleteByFamilyIds(List<String> familyIds) {
|
||||
if (familyIds == null || familyIds.isEmpty()) {
|
||||
@@ -61,16 +65,39 @@ public class CcdiAssetInfoServiceImpl implements ICcdiAssetInfoService {
|
||||
return assetInfoMapper.deleteByFamilyIds(familyIds);
|
||||
}
|
||||
|
||||
private CcdiAssetInfo toEntity(String familyId, CcdiAssetInfoDTO dto) {
|
||||
private void replaceAssets(String familyId, String personId, List<CcdiAssetInfoDTO> assetInfoList, boolean deleteByFamilyOnly) {
|
||||
if (deleteByFamilyOnly) {
|
||||
assetInfoMapper.deleteByFamilyId(familyId);
|
||||
} else {
|
||||
assetInfoMapper.deleteByFamilyIdAndPersonId(familyId, personId);
|
||||
}
|
||||
if (assetInfoList == null || assetInfoList.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
List<CcdiAssetInfo> saveList = assetInfoList.stream()
|
||||
.filter(item -> !isEmptyRow(item))
|
||||
.map(item -> {
|
||||
validateAsset(item);
|
||||
return toEntity(familyId, personId, item);
|
||||
})
|
||||
.toList();
|
||||
|
||||
if (!saveList.isEmpty()) {
|
||||
assetInfoMapper.insertBatch(saveList);
|
||||
}
|
||||
}
|
||||
|
||||
private CcdiAssetInfo toEntity(String familyId, String personId, CcdiAssetInfoDTO dto) {
|
||||
CcdiAssetInfo assetInfo = new CcdiAssetInfo();
|
||||
BeanUtils.copyProperties(dto, assetInfo);
|
||||
assetInfo.setFamilyId(familyId);
|
||||
assetInfo.setPersonId(personId);
|
||||
return assetInfo;
|
||||
}
|
||||
|
||||
private boolean isEmptyRow(CcdiAssetInfoDTO dto) {
|
||||
return StringUtils.isEmpty(dto.getPersonId())
|
||||
&& StringUtils.isEmpty(dto.getAssetMainType())
|
||||
return StringUtils.isEmpty(dto.getAssetMainType())
|
||||
&& StringUtils.isEmpty(dto.getAssetSubType())
|
||||
&& StringUtils.isEmpty(dto.getAssetName())
|
||||
&& dto.getCurrentValue() == null
|
||||
@@ -81,4 +108,22 @@ public class CcdiAssetInfoServiceImpl implements ICcdiAssetInfoService {
|
||||
&& dto.getValuationDate() == null
|
||||
&& StringUtils.isEmpty(dto.getRemarks());
|
||||
}
|
||||
|
||||
private void validateAsset(CcdiAssetInfoDTO dto) {
|
||||
if (StringUtils.isEmpty(dto.getAssetMainType())) {
|
||||
throw new RuntimeException("资产大类不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(dto.getAssetSubType())) {
|
||||
throw new RuntimeException("资产小类不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(dto.getAssetName())) {
|
||||
throw new RuntimeException("资产名称不能为空");
|
||||
}
|
||||
if (dto.getCurrentValue() == null) {
|
||||
throw new RuntimeException("当前估值不能为空");
|
||||
}
|
||||
if (StringUtils.isEmpty(dto.getAssetStatus())) {
|
||||
throw new RuntimeException("资产状态不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user