修复中介库
This commit is contained in:
@@ -72,6 +72,26 @@ public class CcdiIntermediaryController extends BaseController {
|
||||
return success(vo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询中介亲属列表
|
||||
*/
|
||||
@Operation(summary = "查询中介亲属列表")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:query')")
|
||||
@GetMapping("/{bizId}/relatives")
|
||||
public AjaxResult getRelativeList(@PathVariable String bizId) {
|
||||
return success(intermediaryService.selectIntermediaryRelativeList(bizId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询中介亲属详情
|
||||
*/
|
||||
@Operation(summary = "查询中介亲属详情")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:query')")
|
||||
@GetMapping("/relative/{relativeBizId}")
|
||||
public AjaxResult getRelativeInfo(@PathVariable String relativeBizId) {
|
||||
return success(intermediaryService.selectIntermediaryRelativeDetail(relativeBizId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体中介详情
|
||||
*/
|
||||
@@ -105,6 +125,28 @@ public class CcdiIntermediaryController extends BaseController {
|
||||
return toAjax(intermediaryService.updateIntermediaryPerson(editDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增中介亲属
|
||||
*/
|
||||
@Operation(summary = "新增中介亲属")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:add')")
|
||||
@Log(title = "中介亲属", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/{bizId}/relative")
|
||||
public AjaxResult addRelative(@PathVariable String bizId, @Validated @RequestBody CcdiIntermediaryRelativeAddDTO addDTO) {
|
||||
return toAjax(intermediaryService.insertIntermediaryRelative(bizId, addDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改中介亲属
|
||||
*/
|
||||
@Operation(summary = "修改中介亲属")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:edit')")
|
||||
@Log(title = "中介亲属", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/relative")
|
||||
public AjaxResult editRelative(@Validated @RequestBody CcdiIntermediaryRelativeEditDTO editDTO) {
|
||||
return toAjax(intermediaryService.updateIntermediaryRelative(editDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增实体中介
|
||||
*/
|
||||
@@ -127,6 +169,49 @@ public class CcdiIntermediaryController extends BaseController {
|
||||
return toAjax(intermediaryService.updateIntermediaryEntity(editDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询中介关联机构列表
|
||||
*/
|
||||
@Operation(summary = "查询中介关联机构列表")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:query')")
|
||||
@GetMapping("/{bizId}/enterprise-relations")
|
||||
public AjaxResult getEnterpriseRelationList(@PathVariable String bizId) {
|
||||
return success(intermediaryService.selectIntermediaryEnterpriseRelationList(bizId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询中介关联机构详情
|
||||
*/
|
||||
@Operation(summary = "查询中介关联机构详情")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:query')")
|
||||
@GetMapping("/enterprise-relation/{id}")
|
||||
public AjaxResult getEnterpriseRelationInfo(@PathVariable Long id) {
|
||||
return success(intermediaryService.selectIntermediaryEnterpriseRelationDetail(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增中介关联机构
|
||||
*/
|
||||
@Operation(summary = "新增中介关联机构")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:add')")
|
||||
@Log(title = "中介关联机构", businessType = BusinessType.INSERT)
|
||||
@PostMapping("/{bizId}/enterprise-relation")
|
||||
public AjaxResult addEnterpriseRelation(@PathVariable String bizId,
|
||||
@Validated @RequestBody CcdiIntermediaryEnterpriseRelationAddDTO addDTO) {
|
||||
return toAjax(intermediaryService.insertIntermediaryEnterpriseRelation(bizId, addDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 修改中介关联机构
|
||||
*/
|
||||
@Operation(summary = "修改中介关联机构")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:edit')")
|
||||
@Log(title = "中介关联机构", businessType = BusinessType.UPDATE)
|
||||
@PutMapping("/enterprise-relation")
|
||||
public AjaxResult editEnterpriseRelation(@Validated @RequestBody CcdiIntermediaryEnterpriseRelationEditDTO editDTO) {
|
||||
return toAjax(intermediaryService.updateIntermediaryEnterpriseRelation(editDTO));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除中介
|
||||
*/
|
||||
@@ -138,6 +223,28 @@ public class CcdiIntermediaryController extends BaseController {
|
||||
return toAjax(intermediaryService.deleteIntermediaryByIds(ids));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除中介亲属
|
||||
*/
|
||||
@Operation(summary = "删除中介亲属")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:remove')")
|
||||
@Log(title = "中介亲属", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/relative/{relativeBizId}")
|
||||
public AjaxResult removeRelative(@PathVariable String relativeBizId) {
|
||||
return toAjax(intermediaryService.deleteIntermediaryRelative(relativeBizId));
|
||||
}
|
||||
|
||||
/**
|
||||
* 删除中介关联机构
|
||||
*/
|
||||
@Operation(summary = "删除中介关联机构")
|
||||
@PreAuthorize("@ss.hasPermi('ccdi:intermediary:remove')")
|
||||
@Log(title = "中介关联机构", businessType = BusinessType.DELETE)
|
||||
@DeleteMapping("/enterprise-relation/{id}")
|
||||
public AjaxResult removeEnterpriseRelation(@PathVariable Long id) {
|
||||
return toAjax(intermediaryService.deleteIntermediaryEnterpriseRelation(id));
|
||||
}
|
||||
|
||||
/**
|
||||
* 校验人员ID唯一性
|
||||
*/
|
||||
|
||||
@@ -19,12 +19,15 @@ public class CcdiIntermediaryQueryDTO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "姓名/机构名称")
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "证件号/统一社会信用代码")
|
||||
@Schema(description = "证件号")
|
||||
private String certificateNo;
|
||||
|
||||
@Schema(description = "中介类型(1=个人, 2=实体)")
|
||||
private String intermediaryType;
|
||||
@Schema(description = "记录类型(INTERMEDIARY/RELATIVE/ENTERPRISE_RELATION)")
|
||||
private String recordType;
|
||||
|
||||
@Schema(description = "关联中介信息(姓名或证件号)")
|
||||
private String relatedIntermediaryKeyword;
|
||||
}
|
||||
|
||||
@@ -21,32 +21,25 @@ public class CcdiIntermediaryVO implements Serializable {
|
||||
@Serial
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
@Schema(description = "ID")
|
||||
private String id;
|
||||
@Schema(description = "记录类型")
|
||||
private String recordType;
|
||||
|
||||
@Schema(description = "姓名/机构名称")
|
||||
@Schema(description = "记录ID")
|
||||
private String recordId;
|
||||
|
||||
@Schema(description = "名称")
|
||||
private String name;
|
||||
|
||||
@Schema(description = "证件号/统一社会信用代码")
|
||||
@Schema(description = "证件号")
|
||||
private String certificateNo;
|
||||
|
||||
@Schema(description = "中介类型(1=个人, 2=实体)")
|
||||
private String intermediaryType;
|
||||
@Schema(description = "关联中介姓名")
|
||||
private String relatedIntermediaryName;
|
||||
|
||||
@Schema(description = "人员类型")
|
||||
private String personType;
|
||||
|
||||
@Schema(description = "公司")
|
||||
private String company;
|
||||
|
||||
@Schema(description = "数据来源")
|
||||
private String dataSource;
|
||||
@Schema(description = "关联关系")
|
||||
private String relationText;
|
||||
|
||||
@Schema(description = "创建时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date createTime;
|
||||
|
||||
@Schema(description = "修改时间")
|
||||
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss")
|
||||
private Date updateTime;
|
||||
}
|
||||
|
||||
@@ -4,8 +4,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.info.collection.domain.dto.*;
|
||||
import com.ruoyi.info.collection.domain.excel.CcdiIntermediaryEntityExcel;
|
||||
import com.ruoyi.info.collection.domain.excel.CcdiIntermediaryPersonExcel;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryEnterpriseRelationVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryEntityDetailVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryPersonDetailVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryRelativeVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryVO;
|
||||
|
||||
import java.util.List;
|
||||
@@ -35,6 +37,22 @@ public interface ICcdiIntermediaryService {
|
||||
*/
|
||||
CcdiIntermediaryPersonDetailVO selectIntermediaryPersonDetail(String bizId);
|
||||
|
||||
/**
|
||||
* 查询中介亲属列表
|
||||
*
|
||||
* @param bizId 中介本人ID
|
||||
* @return 亲属列表
|
||||
*/
|
||||
List<CcdiIntermediaryRelativeVO> selectIntermediaryRelativeList(String bizId);
|
||||
|
||||
/**
|
||||
* 查询中介亲属详情
|
||||
*
|
||||
* @param relativeBizId 亲属ID
|
||||
* @return 亲属详情
|
||||
*/
|
||||
CcdiIntermediaryRelativeVO selectIntermediaryRelativeDetail(String relativeBizId);
|
||||
|
||||
/**
|
||||
* 查询实体中介详情
|
||||
*
|
||||
@@ -59,6 +77,31 @@ public interface ICcdiIntermediaryService {
|
||||
*/
|
||||
int updateIntermediaryPerson(CcdiIntermediaryPersonEditDTO editDTO);
|
||||
|
||||
/**
|
||||
* 新增中介亲属
|
||||
*
|
||||
* @param bizId 中介本人ID
|
||||
* @param addDTO 新增DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int insertIntermediaryRelative(String bizId, CcdiIntermediaryRelativeAddDTO addDTO);
|
||||
|
||||
/**
|
||||
* 修改中介亲属
|
||||
*
|
||||
* @param editDTO 编辑DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int updateIntermediaryRelative(CcdiIntermediaryRelativeEditDTO editDTO);
|
||||
|
||||
/**
|
||||
* 删除中介亲属
|
||||
*
|
||||
* @param relativeBizId 亲属ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteIntermediaryRelative(String relativeBizId);
|
||||
|
||||
/**
|
||||
* 新增实体中介
|
||||
*
|
||||
@@ -75,6 +118,47 @@ public interface ICcdiIntermediaryService {
|
||||
*/
|
||||
int updateIntermediaryEntity(CcdiIntermediaryEntityEditDTO editDTO);
|
||||
|
||||
/**
|
||||
* 查询中介关联机构列表
|
||||
*
|
||||
* @param bizId 中介本人ID
|
||||
* @return 关联机构列表
|
||||
*/
|
||||
List<CcdiIntermediaryEnterpriseRelationVO> selectIntermediaryEnterpriseRelationList(String bizId);
|
||||
|
||||
/**
|
||||
* 查询中介关联机构详情
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 关联机构详情
|
||||
*/
|
||||
CcdiIntermediaryEnterpriseRelationVO selectIntermediaryEnterpriseRelationDetail(Long id);
|
||||
|
||||
/**
|
||||
* 新增中介关联机构
|
||||
*
|
||||
* @param bizId 中介本人ID
|
||||
* @param addDTO 新增DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int insertIntermediaryEnterpriseRelation(String bizId, CcdiIntermediaryEnterpriseRelationAddDTO addDTO);
|
||||
|
||||
/**
|
||||
* 修改中介关联机构
|
||||
*
|
||||
* @param editDTO 编辑DTO
|
||||
* @return 结果
|
||||
*/
|
||||
int updateIntermediaryEnterpriseRelation(CcdiIntermediaryEnterpriseRelationEditDTO editDTO);
|
||||
|
||||
/**
|
||||
* 删除中介关联机构
|
||||
*
|
||||
* @param id 主键ID
|
||||
* @return 结果
|
||||
*/
|
||||
int deleteIntermediaryEnterpriseRelation(Long id);
|
||||
|
||||
/**
|
||||
* 批量删除中介
|
||||
*
|
||||
|
||||
@@ -4,14 +4,18 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.ruoyi.info.collection.domain.CcdiBizIntermediary;
|
||||
import com.ruoyi.info.collection.domain.CcdiEnterpriseBaseInfo;
|
||||
import com.ruoyi.info.collection.domain.CcdiIntermediaryEnterpriseRelation;
|
||||
import com.ruoyi.info.collection.domain.dto.*;
|
||||
import com.ruoyi.info.collection.domain.excel.CcdiIntermediaryEntityExcel;
|
||||
import com.ruoyi.info.collection.domain.excel.CcdiIntermediaryPersonExcel;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryEnterpriseRelationVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryEntityDetailVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryPersonDetailVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryRelativeVO;
|
||||
import com.ruoyi.info.collection.domain.vo.CcdiIntermediaryVO;
|
||||
import com.ruoyi.info.collection.mapper.CcdiBizIntermediaryMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiEnterpriseBaseInfoMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiIntermediaryEnterpriseRelationMapper;
|
||||
import com.ruoyi.info.collection.mapper.CcdiIntermediaryMapper;
|
||||
import com.ruoyi.info.collection.service.ICcdiIntermediaryEntityImportService;
|
||||
import com.ruoyi.info.collection.service.ICcdiIntermediaryPersonImportService;
|
||||
@@ -48,6 +52,9 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
@Resource
|
||||
private CcdiIntermediaryMapper intermediaryMapper;
|
||||
|
||||
@Resource
|
||||
private CcdiIntermediaryEnterpriseRelationMapper enterpriseRelationMapper;
|
||||
|
||||
@Resource
|
||||
private ICcdiIntermediaryPersonImportService personImportService;
|
||||
|
||||
@@ -81,7 +88,7 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
@Override
|
||||
public CcdiIntermediaryPersonDetailVO selectIntermediaryPersonDetail(String bizId) {
|
||||
CcdiBizIntermediary person = bizIntermediaryMapper.selectById(bizId);
|
||||
if (person == null) {
|
||||
if (person == null || !isIntermediaryPerson(person)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@@ -92,6 +99,24 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
return vo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CcdiIntermediaryRelativeVO> selectIntermediaryRelativeList(String bizId) {
|
||||
LambdaQueryWrapper<CcdiBizIntermediary> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.eq(CcdiBizIntermediary::getRelatedNumId, bizId)
|
||||
.ne(CcdiBizIntermediary::getPersonSubType, "本人")
|
||||
.orderByDesc(CcdiBizIntermediary::getCreateTime);
|
||||
return bizIntermediaryMapper.selectList(wrapper).stream().map(this::buildRelativeVo).toList();
|
||||
}
|
||||
|
||||
@Override
|
||||
public CcdiIntermediaryRelativeVO selectIntermediaryRelativeDetail(String relativeBizId) {
|
||||
CcdiBizIntermediary relative = bizIntermediaryMapper.selectById(relativeBizId);
|
||||
if (relative == null || isIntermediaryPerson(relative)) {
|
||||
return null;
|
||||
}
|
||||
return buildRelativeVo(relative);
|
||||
}
|
||||
|
||||
/**
|
||||
* 查询实体中介详情
|
||||
*
|
||||
@@ -130,6 +155,8 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
|
||||
CcdiBizIntermediary person = new CcdiBizIntermediary();
|
||||
BeanUtils.copyProperties(addDTO, person);
|
||||
person.setPersonSubType("本人");
|
||||
person.setRelatedNumId(null);
|
||||
person.setDataSource("MANUAL");
|
||||
|
||||
return bizIntermediaryMapper.insert(person);
|
||||
@@ -151,12 +178,64 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
}
|
||||
}
|
||||
|
||||
CcdiBizIntermediary existing = bizIntermediaryMapper.selectById(editDTO.getBizId());
|
||||
if (existing == null || !isIntermediaryPerson(existing)) {
|
||||
throw new RuntimeException("中介本人不存在");
|
||||
}
|
||||
|
||||
CcdiBizIntermediary person = new CcdiBizIntermediary();
|
||||
BeanUtils.copyProperties(editDTO, person);
|
||||
person.setPersonSubType("本人");
|
||||
person.setRelatedNumId(null);
|
||||
|
||||
return bizIntermediaryMapper.updateById(person);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertIntermediaryRelative(String bizId, CcdiIntermediaryRelativeAddDTO addDTO) {
|
||||
CcdiBizIntermediary owner = requireIntermediaryPerson(bizId);
|
||||
validateRelativePersonSubType(addDTO.getPersonSubType());
|
||||
if (!checkPersonIdUnique(addDTO.getPersonId(), null)) {
|
||||
throw new RuntimeException("该证件号已存在");
|
||||
}
|
||||
|
||||
CcdiBizIntermediary relative = new CcdiBizIntermediary();
|
||||
BeanUtils.copyProperties(addDTO, relative);
|
||||
relative.setRelatedNumId(owner.getBizId());
|
||||
relative.setDataSource("MANUAL");
|
||||
return bizIntermediaryMapper.insert(relative);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateIntermediaryRelative(CcdiIntermediaryRelativeEditDTO editDTO) {
|
||||
CcdiBizIntermediary existing = bizIntermediaryMapper.selectById(editDTO.getBizId());
|
||||
if (existing == null || isIntermediaryPerson(existing)) {
|
||||
throw new RuntimeException("中介亲属不存在");
|
||||
}
|
||||
validateRelativePersonSubType(editDTO.getPersonSubType());
|
||||
if (StringUtils.isNotEmpty(editDTO.getPersonId())
|
||||
&& !checkPersonIdUnique(editDTO.getPersonId(), editDTO.getBizId())) {
|
||||
throw new RuntimeException("该证件号已存在");
|
||||
}
|
||||
|
||||
CcdiBizIntermediary relative = new CcdiBizIntermediary();
|
||||
BeanUtils.copyProperties(editDTO, relative);
|
||||
relative.setRelatedNumId(existing.getRelatedNumId());
|
||||
return bizIntermediaryMapper.updateById(relative);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteIntermediaryRelative(String relativeBizId) {
|
||||
CcdiBizIntermediary existing = bizIntermediaryMapper.selectById(relativeBizId);
|
||||
if (existing == null || isIntermediaryPerson(existing)) {
|
||||
throw new RuntimeException("中介亲属不存在");
|
||||
}
|
||||
return bizIntermediaryMapper.deleteById(relativeBizId);
|
||||
}
|
||||
|
||||
/**
|
||||
* 新增实体中介
|
||||
*
|
||||
@@ -197,6 +276,49 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
return enterpriseBaseInfoMapper.updateById(entity);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<CcdiIntermediaryEnterpriseRelationVO> selectIntermediaryEnterpriseRelationList(String bizId) {
|
||||
return enterpriseRelationMapper.selectByIntermediaryBizId(bizId);
|
||||
}
|
||||
|
||||
@Override
|
||||
public CcdiIntermediaryEnterpriseRelationVO selectIntermediaryEnterpriseRelationDetail(Long id) {
|
||||
return enterpriseRelationMapper.selectDetailById(id);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int insertIntermediaryEnterpriseRelation(String bizId, CcdiIntermediaryEnterpriseRelationAddDTO addDTO) {
|
||||
CcdiBizIntermediary owner = requireIntermediaryPerson(bizId);
|
||||
validateEnterpriseRelation(owner.getBizId(), addDTO.getSocialCreditCode(), null);
|
||||
|
||||
CcdiIntermediaryEnterpriseRelation relation = new CcdiIntermediaryEnterpriseRelation();
|
||||
BeanUtils.copyProperties(addDTO, relation);
|
||||
relation.setIntermediaryBizId(owner.getBizId());
|
||||
return enterpriseRelationMapper.insert(relation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int updateIntermediaryEnterpriseRelation(CcdiIntermediaryEnterpriseRelationEditDTO editDTO) {
|
||||
CcdiIntermediaryEnterpriseRelation existing = enterpriseRelationMapper.selectById(editDTO.getId());
|
||||
if (existing == null) {
|
||||
throw new RuntimeException("中介关联机构不存在");
|
||||
}
|
||||
validateEnterpriseRelation(existing.getIntermediaryBizId(), editDTO.getSocialCreditCode(), existing.getId());
|
||||
|
||||
CcdiIntermediaryEnterpriseRelation relation = new CcdiIntermediaryEnterpriseRelation();
|
||||
BeanUtils.copyProperties(editDTO, relation);
|
||||
relation.setIntermediaryBizId(existing.getIntermediaryBizId());
|
||||
return enterpriseRelationMapper.updateById(relation);
|
||||
}
|
||||
|
||||
@Override
|
||||
@Transactional
|
||||
public int deleteIntermediaryEnterpriseRelation(Long id) {
|
||||
return enterpriseRelationMapper.deleteById(id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 批量删除中介
|
||||
*
|
||||
@@ -208,12 +330,19 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
public int deleteIntermediaryByIds(String[] ids) {
|
||||
int count = 0;
|
||||
for (String id : ids) {
|
||||
// 判断是个人还是实体(个人ID长度较长,实体统一社会信用代码18位)
|
||||
if (id.length() > 18) {
|
||||
// 个人中介
|
||||
CcdiBizIntermediary intermediary = bizIntermediaryMapper.selectById(id);
|
||||
if (intermediary != null) {
|
||||
if (isIntermediaryPerson(intermediary)) {
|
||||
bizIntermediaryMapper.delete(new LambdaQueryWrapper<CcdiBizIntermediary>()
|
||||
.eq(CcdiBizIntermediary::getRelatedNumId, id));
|
||||
enterpriseRelationMapper.delete(new LambdaQueryWrapper<CcdiIntermediaryEnterpriseRelation>()
|
||||
.eq(CcdiIntermediaryEnterpriseRelation::getIntermediaryBizId, id));
|
||||
}
|
||||
count += bizIntermediaryMapper.deleteById(id);
|
||||
} else {
|
||||
// 实体中介
|
||||
continue;
|
||||
}
|
||||
|
||||
if (enterpriseBaseInfoMapper.selectById(id) != null) {
|
||||
count += enterpriseBaseInfoMapper.deleteById(id);
|
||||
}
|
||||
}
|
||||
@@ -325,4 +454,45 @@ public class CcdiIntermediaryServiceImpl implements ICcdiIntermediaryService {
|
||||
|
||||
return taskId;
|
||||
}
|
||||
|
||||
private boolean isIntermediaryPerson(CcdiBizIntermediary person) {
|
||||
return "本人".equals(person.getPersonSubType());
|
||||
}
|
||||
|
||||
private CcdiBizIntermediary requireIntermediaryPerson(String bizId) {
|
||||
CcdiBizIntermediary owner = bizIntermediaryMapper.selectById(bizId);
|
||||
if (owner == null || !isIntermediaryPerson(owner)) {
|
||||
throw new RuntimeException("中介本人不存在");
|
||||
}
|
||||
return owner;
|
||||
}
|
||||
|
||||
private void validateRelativePersonSubType(String personSubType) {
|
||||
if ("本人".equals(personSubType)) {
|
||||
throw new RuntimeException("亲属关系不能为本人");
|
||||
}
|
||||
}
|
||||
|
||||
private void validateEnterpriseRelation(String bizId, String socialCreditCode, Long excludeId) {
|
||||
requireIntermediaryPerson(bizId);
|
||||
if (enterpriseBaseInfoMapper.selectById(socialCreditCode) == null) {
|
||||
throw new RuntimeException("关联机构不存在");
|
||||
}
|
||||
boolean exists = enterpriseRelationMapper.existsByIntermediaryBizIdAndSocialCreditCode(bizId, socialCreditCode);
|
||||
if (exists) {
|
||||
if (excludeId == null) {
|
||||
throw new RuntimeException("该中介已关联此机构");
|
||||
}
|
||||
CcdiIntermediaryEnterpriseRelation existing = enterpriseRelationMapper.selectById(excludeId);
|
||||
if (existing == null || !socialCreditCode.equals(existing.getSocialCreditCode())) {
|
||||
throw new RuntimeException("该中介已关联此机构");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private CcdiIntermediaryRelativeVO buildRelativeVo(CcdiBizIntermediary relative) {
|
||||
CcdiIntermediaryRelativeVO vo = new CcdiIntermediaryRelativeVO();
|
||||
BeanUtils.copyProperties(relative, vo);
|
||||
return vo;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,57 +4,86 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
|
||||
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||
<mapper namespace="com.ruoyi.info.collection.mapper.CcdiIntermediaryMapper">
|
||||
|
||||
<!--
|
||||
中介黑名单联合查询
|
||||
支持按中介类型筛选: 1=个人中介, 2=实体中介, null=全部
|
||||
使用MyBatis Plus分页插件自动处理分页
|
||||
-->
|
||||
<!-- 中介综合库联合查询 -->
|
||||
<select id="selectIntermediaryList" resultType="com.ruoyi.info.collection.domain.vo.CcdiIntermediaryVO">
|
||||
SELECT * FROM (
|
||||
<!-- 查询个人中介 -->
|
||||
SELECT
|
||||
biz_id as id,
|
||||
name,
|
||||
person_id as certificate_no,
|
||||
'1' as intermediary_type,
|
||||
person_type,
|
||||
company,
|
||||
data_source,
|
||||
create_time,
|
||||
update_time
|
||||
CAST('INTERMEDIARY' AS CHAR CHARACTER SET utf8mb4) COLLATE utf8mb4_general_ci AS record_type,
|
||||
biz_id COLLATE utf8mb4_general_ci AS record_id,
|
||||
name COLLATE utf8mb4_general_ci AS name,
|
||||
person_id COLLATE utf8mb4_general_ci AS certificate_no,
|
||||
name COLLATE utf8mb4_general_ci AS related_intermediary_name,
|
||||
CAST('本人' AS CHAR CHARACTER SET utf8mb4) COLLATE utf8mb4_general_ci AS relation_text,
|
||||
person_id COLLATE utf8mb4_general_ci AS related_intermediary_certificate_no,
|
||||
create_time
|
||||
FROM ccdi_biz_intermediary
|
||||
WHERE person_sub_type COLLATE utf8mb4_general_ci = '本人' COLLATE utf8mb4_general_ci
|
||||
|
||||
UNION ALL
|
||||
|
||||
<!-- 查询实体中介 -->
|
||||
SELECT
|
||||
social_credit_code as id,
|
||||
enterprise_name as name,
|
||||
social_credit_code as certificate_no,
|
||||
'2' as intermediary_type,
|
||||
'实体' as person_type,
|
||||
enterprise_name as company,
|
||||
data_source,
|
||||
create_time,
|
||||
update_time
|
||||
FROM ccdi_enterprise_base_info
|
||||
WHERE risk_level = '1' AND ent_source = 'INTERMEDIARY'
|
||||
CAST('RELATIVE' AS CHAR CHARACTER SET utf8mb4) COLLATE utf8mb4_general_ci AS record_type,
|
||||
child.biz_id COLLATE utf8mb4_general_ci AS record_id,
|
||||
child.name COLLATE utf8mb4_general_ci AS name,
|
||||
child.person_id COLLATE utf8mb4_general_ci AS certificate_no,
|
||||
parent.name COLLATE utf8mb4_general_ci AS related_intermediary_name,
|
||||
child.person_sub_type COLLATE utf8mb4_general_ci AS relation_text,
|
||||
parent.person_id COLLATE utf8mb4_general_ci AS related_intermediary_certificate_no,
|
||||
child.create_time
|
||||
FROM ccdi_biz_intermediary child
|
||||
INNER JOIN ccdi_biz_intermediary parent
|
||||
ON child.related_num_id COLLATE utf8mb4_general_ci = parent.biz_id COLLATE utf8mb4_general_ci
|
||||
AND parent.person_sub_type COLLATE utf8mb4_general_ci = '本人' COLLATE utf8mb4_general_ci
|
||||
WHERE child.person_sub_type IS NOT NULL
|
||||
AND child.person_sub_type COLLATE utf8mb4_general_ci != '本人' COLLATE utf8mb4_general_ci
|
||||
|
||||
UNION ALL
|
||||
|
||||
SELECT
|
||||
CAST('ENTERPRISE_RELATION' AS CHAR CHARACTER SET utf8mb4) COLLATE utf8mb4_general_ci AS record_type,
|
||||
CAST(rel.id AS CHAR CHARACTER SET utf8mb4) COLLATE utf8mb4_general_ci AS record_id,
|
||||
COALESCE(
|
||||
ent.enterprise_name COLLATE utf8mb4_general_ci,
|
||||
rel.social_credit_code COLLATE utf8mb4_general_ci
|
||||
) COLLATE utf8mb4_general_ci AS name,
|
||||
rel.social_credit_code COLLATE utf8mb4_general_ci AS certificate_no,
|
||||
parent.name COLLATE utf8mb4_general_ci AS related_intermediary_name,
|
||||
COALESCE(
|
||||
NULLIF(rel.relation_person_post COLLATE utf8mb4_general_ci, ''),
|
||||
CAST('实体' AS CHAR CHARACTER SET utf8mb4) COLLATE utf8mb4_general_ci
|
||||
) COLLATE utf8mb4_general_ci AS relation_text,
|
||||
parent.person_id COLLATE utf8mb4_general_ci AS related_intermediary_certificate_no,
|
||||
rel.create_time
|
||||
FROM ccdi_intermediary_enterprise_relation rel
|
||||
INNER JOIN ccdi_biz_intermediary parent
|
||||
ON rel.intermediary_biz_id COLLATE utf8mb4_general_ci = parent.biz_id COLLATE utf8mb4_general_ci
|
||||
AND parent.person_sub_type COLLATE utf8mb4_general_ci = '本人' COLLATE utf8mb4_general_ci
|
||||
LEFT JOIN ccdi_enterprise_base_info ent
|
||||
ON rel.social_credit_code COLLATE utf8mb4_general_ci = ent.social_credit_code COLLATE utf8mb4_general_ci
|
||||
) AS combined_result
|
||||
<where>
|
||||
<!-- 按中介类型筛选 -->
|
||||
<if test="query.intermediaryType != null and query.intermediaryType != ''">
|
||||
AND intermediary_type = #{query.intermediaryType}
|
||||
<if test="query.recordType != null and query.recordType != ''">
|
||||
AND record_type COLLATE utf8mb4_general_ci =
|
||||
CONVERT(#{query.recordType} USING utf8mb4) COLLATE utf8mb4_general_ci
|
||||
</if>
|
||||
<!-- 按姓名/机构名称模糊查询 -->
|
||||
<if test="query.name != null and query.name != ''">
|
||||
AND name LIKE CONCAT('%', #{query.name}, '%')
|
||||
AND name COLLATE utf8mb4_general_ci LIKE
|
||||
CONCAT('%', CONVERT(#{query.name} USING utf8mb4), '%') COLLATE utf8mb4_general_ci
|
||||
</if>
|
||||
<!-- 按证件号/统一社会信用代码精确查询 -->
|
||||
<if test="query.certificateNo != null and query.certificateNo != ''">
|
||||
AND certificate_no = #{query.certificateNo}
|
||||
AND certificate_no COLLATE utf8mb4_general_ci =
|
||||
CONVERT(#{query.certificateNo} USING utf8mb4) COLLATE utf8mb4_general_ci
|
||||
</if>
|
||||
<if test="query.relatedIntermediaryKeyword != null and query.relatedIntermediaryKeyword != ''">
|
||||
AND (
|
||||
related_intermediary_name COLLATE utf8mb4_general_ci LIKE
|
||||
CONCAT('%', CONVERT(#{query.relatedIntermediaryKeyword} USING utf8mb4), '%') COLLATE utf8mb4_general_ci
|
||||
OR related_intermediary_certificate_no COLLATE utf8mb4_general_ci LIKE
|
||||
CONCAT('%', CONVERT(#{query.relatedIntermediaryKeyword} USING utf8mb4), '%') COLLATE utf8mb4_general_ci
|
||||
)
|
||||
</if>
|
||||
</where>
|
||||
ORDER BY update_time DESC
|
||||
ORDER BY create_time DESC
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
|
||||
Reference in New Issue
Block a user