合并员工亲属资产后端实施
This commit is contained in:
@@ -28,12 +28,12 @@ import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工资产信息Controller
|
||||
* 亲属资产信息Controller
|
||||
*
|
||||
* @author ruoyi
|
||||
* @date 2026-03-12
|
||||
*/
|
||||
@Tag(name = "员工资产信息管理")
|
||||
@Tag(name = "亲属资产信息管理")
|
||||
@RestController
|
||||
@RequestMapping("/ccdi/assetInfo")
|
||||
public class CcdiAssetInfoController extends BaseController {
|
||||
@@ -44,18 +44,18 @@ public class CcdiAssetInfoController extends BaseController {
|
||||
/**
|
||||
* 下载导入模板
|
||||
*/
|
||||
@Operation(summary = "下载资产导入模板")
|
||||
@Operation(summary = "下载亲属资产导入模板")
|
||||
@PostMapping("/importTemplate")
|
||||
public void importTemplate(HttpServletResponse response) {
|
||||
EasyExcelUtil.importTemplateWithDictDropdown(response, CcdiAssetInfoExcel.class, "员工资产信息");
|
||||
EasyExcelUtil.importTemplateWithDictDropdown(response, CcdiAssetInfoExcel.class, "亲属资产信息");
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入员工资产信息
|
||||
* 导入亲属资产信息
|
||||
*/
|
||||
@Operation(summary = "导入员工资产信息")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:baseStaff:import')")
|
||||
@Log(title = "员工资产信息", businessType = BusinessType.IMPORT)
|
||||
@Operation(summary = "导入亲属资产信息")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:import')")
|
||||
@Log(title = "亲属资产信息", businessType = BusinessType.IMPORT)
|
||||
@PostMapping("/importData")
|
||||
public AjaxResult importData(MultipartFile file) throws Exception {
|
||||
List<CcdiAssetInfoExcel> list = EasyExcelUtil.importExcel(file.getInputStream(), CcdiAssetInfoExcel.class);
|
||||
@@ -74,8 +74,8 @@ public class CcdiAssetInfoController extends BaseController {
|
||||
/**
|
||||
* 查询导入状态
|
||||
*/
|
||||
@Operation(summary = "查询员工资产导入状态")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:baseStaff:import')")
|
||||
@Operation(summary = "查询亲属资产导入状态")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:import')")
|
||||
@GetMapping("/importStatus/{taskId}")
|
||||
public AjaxResult getImportStatus(@PathVariable String taskId) {
|
||||
return success(assetInfoImportService.getImportStatus(taskId));
|
||||
@@ -84,8 +84,8 @@ public class CcdiAssetInfoController extends BaseController {
|
||||
/**
|
||||
* 查询导入失败记录
|
||||
*/
|
||||
@Operation(summary = "查询员工资产导入失败记录")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:baseStaff:import')")
|
||||
@Operation(summary = "查询亲属资产导入失败记录")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:staffFmyRelation:import')")
|
||||
@GetMapping("/importFailures/{taskId}")
|
||||
public TableDataInfo getImportFailures(
|
||||
@PathVariable String taskId,
|
||||
|
||||
@@ -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个字符")
|
||||
|
||||
@@ -10,6 +10,7 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工亲属关系新增DTO
|
||||
@@ -116,4 +117,8 @@ public class CcdiStaffFmyRelationAddDTO implements Serializable {
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/** 亲属资产列表 */
|
||||
@Schema(description = "亲属资产列表")
|
||||
private List<CcdiAssetInfoDTO> assetInfoList;
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工亲属关系编辑DTO
|
||||
@@ -122,4 +123,8 @@ public class CcdiStaffFmyRelationEditDTO implements Serializable {
|
||||
/** 备注 */
|
||||
@Schema(description = "备注")
|
||||
private String remark;
|
||||
|
||||
/** 亲属资产列表 */
|
||||
@Schema(description = "亲属资产列表")
|
||||
private List<CcdiAssetInfoDTO> assetInfoList;
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
|
||||
/** 资产大类 */
|
||||
|
||||
@@ -7,6 +7,7 @@ import lombok.Data;
|
||||
import java.io.Serial;
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 员工亲属关系VO
|
||||
@@ -141,4 +142,8 @@ public class CcdiStaffFmyRelationVO implements Serializable {
|
||||
/** 更新人 */
|
||||
@Schema(description = "更新人")
|
||||
private String updatedBy;
|
||||
|
||||
/** 亲属资产列表 */
|
||||
@Schema(description = "亲属资产列表")
|
||||
private List<CcdiAssetInfoVO> assetInfoList;
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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("资产状态不能为空");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
package com.ruoyi.info.collection.service.impl;
|
||||
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.info.collection.domain.CcdiAssetInfo;
|
||||
import com.ruoyi.info.collection.domain.CcdiStaffFmyRelation;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiAssetInfoVO;
|
||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationAddDTO;
|
||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationEditDTO;
|
||||
import com.ruoyi.info.collection.domain.dto.CcdiStaffFmyRelationQueryDTO;
|
||||
import com.ruoyi.info.collection.domain.excel.CcdiStaffFmyRelationExcel;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiStaffFmyRelationVO;
|
||||
import com.ruoyi.info.collection.mapper.CcdiStaffFmyRelationMapper;
|
||||
import com.ruoyi.info.collection.service.ICcdiAssetInfoService;
|
||||
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationImportService;
|
||||
import com.ruoyi.info.collection.service.ICcdiStaffFmyRelationService;
|
||||
import com.ruoyi.common.utils.SecurityUtils;
|
||||
@@ -19,6 +22,7 @@ import org.springframework.stereotype.Service;
|
||||
import org.springframework.transaction.annotation.Transactional;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -42,6 +46,9 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
||||
@Resource
|
||||
private RedisTemplate<String, Object> redisTemplate;
|
||||
|
||||
@Resource
|
||||
private ICcdiAssetInfoService assetInfoService;
|
||||
|
||||
/**
|
||||
* 查询员工亲属关系列表
|
||||
*
|
||||
@@ -90,7 +97,19 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
||||
*/
|
||||
@Override
|
||||
public CcdiStaffFmyRelationVO selectRelationById(Long id) {
|
||||
return relationMapper.selectRelationById(id);
|
||||
CcdiStaffFmyRelationVO relationVO = relationMapper.selectRelationById(id);
|
||||
if (relationVO == null) {
|
||||
return null;
|
||||
}
|
||||
if (StringUtils.isNotEmpty(relationVO.getPersonId()) && StringUtils.isNotEmpty(relationVO.getRelationCertNo())) {
|
||||
List<CcdiAssetInfoVO> assetInfoList = assetInfoService
|
||||
.selectByFamilyIdAndPersonId(relationVO.getPersonId(), relationVO.getRelationCertNo())
|
||||
.stream()
|
||||
.map(this::toAssetInfoVO)
|
||||
.toList();
|
||||
relationVO.setAssetInfoList(assetInfoList);
|
||||
}
|
||||
return relationVO;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -114,6 +133,7 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
||||
}
|
||||
|
||||
int result = relationMapper.insert(relation);
|
||||
assetInfoService.replaceByFamilyIdAndPersonId(addDTO.getPersonId(), addDTO.getRelationCertNo(), addDTO.getAssetInfoList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -126,9 +146,19 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateRelation(CcdiStaffFmyRelationEditDTO editDTO) {
|
||||
CcdiStaffFmyRelation existing = relationMapper.selectById(editDTO.getId());
|
||||
if (existing == null) {
|
||||
throw new RuntimeException("员工亲属关系不存在");
|
||||
}
|
||||
if (!StringUtils.equals(existing.getRelationCertType(), editDTO.getRelationCertType())
|
||||
|| !StringUtils.equals(existing.getRelationCertNo(), editDTO.getRelationCertNo())) {
|
||||
throw new RuntimeException("关系人证件类型/证件号码不允许修改");
|
||||
}
|
||||
|
||||
CcdiStaffFmyRelation relation = new CcdiStaffFmyRelation();
|
||||
BeanUtils.copyProperties(editDTO, relation);
|
||||
int result = relationMapper.updateById(relation);
|
||||
assetInfoService.replaceByFamilyIdAndPersonId(editDTO.getPersonId(), editDTO.getRelationCertNo(), editDTO.getAssetInfoList());
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -141,7 +171,15 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteRelationByIds(Long[] ids) {
|
||||
return relationMapper.deleteBatchIds(java.util.List.of(ids));
|
||||
List<Long> idList = java.util.List.of(ids);
|
||||
List<CcdiStaffFmyRelation> relationList = relationMapper.selectBatchIds(idList);
|
||||
for (CcdiStaffFmyRelation relation : relationList) {
|
||||
if (StringUtils.isEmpty(relation.getPersonId()) || StringUtils.isEmpty(relation.getRelationCertNo())) {
|
||||
continue;
|
||||
}
|
||||
assetInfoService.deleteByFamilyIdAndPersonId(relation.getPersonId(), relation.getRelationCertNo());
|
||||
}
|
||||
return relationMapper.deleteBatchIds(idList);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -184,4 +222,10 @@ public class CcdiStaffFmyRelationServiceImpl implements ICcdiStaffFmyRelationSer
|
||||
|
||||
return taskId;
|
||||
}
|
||||
|
||||
private CcdiAssetInfoVO toAssetInfoVO(CcdiAssetInfo assetInfo) {
|
||||
CcdiAssetInfoVO assetInfoVO = new CcdiAssetInfoVO();
|
||||
BeanUtils.copyProperties(assetInfo, assetInfoVO);
|
||||
return assetInfoVO;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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>
|
||||
|
||||
|
||||
@@ -46,33 +46,32 @@
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||
FROM ccdi_staff_fmy_relation r
|
||||
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
||||
<where>
|
||||
r.is_emp_family = 1
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND r.person_id = #{query.personId}
|
||||
</if>
|
||||
<if test="query.personName != null and query.personName != ''">
|
||||
AND s.name LIKE CONCAT('%', #{query.personName}, '%')
|
||||
</if>
|
||||
<if test="query.relationType != null and query.relationType != ''">
|
||||
AND r.relation_type = #{query.relationType}
|
||||
</if>
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.dataSource != null and query.dataSource != ''">
|
||||
AND r.data_source = #{query.dataSource}
|
||||
</if>
|
||||
<if test="query.effectiveDateStart != null">
|
||||
AND r.effective_date >= #{query.effectiveDateStart}
|
||||
</if>
|
||||
<if test="query.effectiveDateEnd != null">
|
||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||
</if>
|
||||
</where>
|
||||
WHERE 1 = 1
|
||||
AND r.is_emp_family = 1
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND r.person_id = #{query.personId}
|
||||
</if>
|
||||
<if test="query.personName != null and query.personName != ''">
|
||||
AND s.name LIKE CONCAT('%', #{query.personName}, '%')
|
||||
</if>
|
||||
<if test="query.relationType != null and query.relationType != ''">
|
||||
AND r.relation_type = #{query.relationType}
|
||||
</if>
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.dataSource != null and query.dataSource != ''">
|
||||
AND r.data_source = #{query.dataSource}
|
||||
</if>
|
||||
<if test="query.effectiveDateStart != null">
|
||||
AND r.effective_date >= #{query.effectiveDateStart}
|
||||
</if>
|
||||
<if test="query.effectiveDateEnd != null">
|
||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||
</if>
|
||||
ORDER BY r.create_time DESC
|
||||
</select>
|
||||
|
||||
@@ -101,33 +100,32 @@
|
||||
r.created_by, r.create_time, r.updated_by, r.update_time
|
||||
FROM ccdi_staff_fmy_relation r
|
||||
LEFT JOIN ccdi_base_staff s ON r.person_id = s.id_card
|
||||
<where>
|
||||
r.is_emp_family = 1
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND r.person_id = #{query.personId}
|
||||
</if>
|
||||
<if test="query.personName != null and query.personName != ''">
|
||||
AND s.name LIKE CONCAT('%', #{query.personName}, '%')
|
||||
</if>
|
||||
<if test="query.relationType != null and query.relationType != ''">
|
||||
AND r.relation_type = #{query.relationType}
|
||||
</if>
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.dataSource != null and query.dataSource != ''">
|
||||
AND r.data_source = #{query.dataSource}
|
||||
</if>
|
||||
<if test="query.effectiveDateStart != null">
|
||||
AND r.effective_date >= #{query.effectiveDateStart}
|
||||
</if>
|
||||
<if test="query.effectiveDateEnd != null">
|
||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||
</if>
|
||||
</where>
|
||||
WHERE 1 = 1
|
||||
AND r.is_emp_family = 1
|
||||
<if test="query.personId != null and query.personId != ''">
|
||||
AND r.person_id = #{query.personId}
|
||||
</if>
|
||||
<if test="query.personName != null and query.personName != ''">
|
||||
AND s.name LIKE CONCAT('%', #{query.personName}, '%')
|
||||
</if>
|
||||
<if test="query.relationType != null and query.relationType != ''">
|
||||
AND r.relation_type = #{query.relationType}
|
||||
</if>
|
||||
<if test="query.relationName != null and query.relationName != ''">
|
||||
AND r.relation_name LIKE CONCAT('%', #{query.relationName}, '%')
|
||||
</if>
|
||||
<if test="query.status != null">
|
||||
AND r.status = #{query.status}
|
||||
</if>
|
||||
<if test="query.dataSource != null and query.dataSource != ''">
|
||||
AND r.data_source = #{query.dataSource}
|
||||
</if>
|
||||
<if test="query.effectiveDateStart != null">
|
||||
AND r.effective_date >= #{query.effectiveDateStart}
|
||||
</if>
|
||||
<if test="query.effectiveDateEnd != null">
|
||||
AND r.effective_date <= #{query.effectiveDateEnd}
|
||||
</if>
|
||||
ORDER BY r.create_time DESC
|
||||
</select>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user