feat(mapper): 添加公司关联查询和关键词搜索功能

- 在多个Mapper XML文件中添加LEFT JOIN credit_company表关联
- 扩展关键词搜索范围,支持通过公司名称进行搜索匹配
- 更新CreditNearbyCompany相关功能,支持按公司ID筛选和导入
- 修改CreditNearbyCompanyParam中companyId字段类型为String
- 暂时注释掉纳税人识别号相关的搜索条件
- 统一各信用数据映射文件中的关键词搜索逻辑
This commit is contained in:
2026-01-15 23:33:42 +08:00
parent e810136fbb
commit 2116856167
26 changed files with 42 additions and 5 deletions

View File

@@ -137,6 +137,7 @@ public class CreditNearbyCompanyController extends BaseController {
@Operation(summary = "批量导入附近企业") @Operation(summary = "批量导入附近企业")
@PostMapping("/import") @PostMapping("/import")
public ApiResult<List<String>> importBatch(@RequestParam("file") MultipartFile file, public ApiResult<List<String>> importBatch(@RequestParam("file") MultipartFile file,
@RequestParam(value = "companyId", required = false) Integer companyId,
@RequestParam(value = "parentId", required = false) Integer parentId, @RequestParam(value = "parentId", required = false) Integer parentId,
@RequestParam(value = "type", required = false) Integer type) { @RequestParam(value = "type", required = false) Integer type) {
List<String> errorMessages = new ArrayList<>(); List<String> errorMessages = new ArrayList<>();
@@ -181,6 +182,9 @@ public class CreditNearbyCompanyController extends BaseController {
if (item.getType() == null && type != null) { if (item.getType() == null && type != null) {
item.setType(type); item.setType(type);
} }
if (item.getCompanyId() == null && companyId != null) {
item.setCompanyId(companyId);
}
if (item.getUserId() == null && currentUserId != null) { if (item.getUserId() == null && currentUserId != null) {
item.setUserId(currentUserId); item.setUserId(currentUserId);
} }
@@ -208,6 +212,7 @@ public class CreditNearbyCompanyController extends BaseController {
CreditNearbyCompany existing = creditNearbyCompanyService.lambdaQuery() CreditNearbyCompany existing = creditNearbyCompanyService.lambdaQuery()
.eq(!ImportHelper.isBlank(item.getCode()), CreditNearbyCompany::getCode, item.getCode()) .eq(!ImportHelper.isBlank(item.getCode()), CreditNearbyCompany::getCode, item.getCode())
.eq(ImportHelper.isBlank(item.getCode()), CreditNearbyCompany::getName, item.getName()) .eq(ImportHelper.isBlank(item.getCode()), CreditNearbyCompany::getName, item.getName())
.eq(companyId != null, CreditNearbyCompany::getCompanyId, companyId)
.eq(parentId != null, CreditNearbyCompany::getParentId, parentId) .eq(parentId != null, CreditNearbyCompany::getParentId, parentId)
.eq(type != null, CreditNearbyCompany::getType, type) .eq(type != null, CreditNearbyCompany::getType, type)
.one(); .one();

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_administrative_license a FROM credit_administrative_license a
LEFT JOIN credit_company b ON a.company_id = b.id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -72,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_bankruptcy a FROM credit_bankruptcy a
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -60,6 +61,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_branch a FROM credit_branch a
LEFT JOIN credit_company b ON a.company_id = b.id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -60,6 +61,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -64,6 +64,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -58,6 +58,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -85,6 +85,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_historical_legal_person a FROM credit_historical_legal_person a
LEFT JOIN credit_company b ON a.company_id = b.id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -54,6 +55,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_judgment_debtor_history a FROM credit_judgment_debtor_history a
LEFT JOIN credit_company b ON a.company_id = b.id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -72,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -94,6 +94,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.name LIKE CONCAT('%', #{param.keywords}, '%') AND (a.name LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_nearby_company a FROM credit_nearby_company a
LEFT JOIN credit_company b ON a.company_id = b.id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -13,7 +14,7 @@
<if test="param.name != null"> <if test="param.name != null">
AND a.name LIKE CONCAT('%', #{param.name}, '%') AND a.name LIKE CONCAT('%', #{param.name}, '%')
</if> </if>
<if test="param.name != null"> <if test="param.companyId != null">
AND a.company_id = #{param.companyId} AND a.company_id = #{param.companyId}
</if> </if>
<if test="param.registrationStatus != null"> <if test="param.registrationStatus != null">
@@ -61,9 +62,9 @@
<if test="param.region != null"> <if test="param.region != null">
AND a.region LIKE CONCAT('%', #{param.region}, '%') AND a.region LIKE CONCAT('%', #{param.region}, '%')
</if> </if>
<if test="param.taxpayerCode != null"> <!-- <if test="param.taxpayerCode != null">-->
AND a.taxpayer_code LIKE CONCAT('%', #{param.taxpayerCode}, '%') <!-- AND a.taxpayer_code LIKE CONCAT('%', #{param.taxpayerCode}, '%')-->
</if> <!-- </if>-->
<if test="param.registrationNumber != null"> <if test="param.registrationNumber != null">
AND a.registration_number LIKE CONCAT('%', #{param.registrationNumber}, '%') AND a.registration_number LIKE CONCAT('%', #{param.registrationNumber}, '%')
</if> </if>
@@ -201,6 +202,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_patent a FROM credit_patent a
LEFT JOIN credit_company b ON a.company_id = b.id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -72,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -61,6 +61,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -58,6 +58,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -6,6 +6,7 @@
<sql id="selectSql"> <sql id="selectSql">
SELECT a.* SELECT a.*
FROM credit_suspected_relationship a FROM credit_suspected_relationship a
LEFT JOIN credit_company b ON a.company_id = b.id
<where> <where>
<if test="param.id != null"> <if test="param.id != null">
AND a.id = #{param.id} AND a.id = #{param.id}
@@ -69,6 +70,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -73,6 +73,7 @@
</if> </if>
<if test="param.keywords != null"> <if test="param.keywords != null">
AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%') AND (a.comments LIKE CONCAT('%', #{param.keywords}, '%')
OR b.name = #{param.keywords}
) )
</if> </if>
</where> </where>

View File

@@ -75,7 +75,7 @@ public class CreditNearbyCompanyParam extends BaseParam {
@Schema(description = "企业ID") @Schema(description = "企业ID")
@QueryField(type = QueryType.EQ) @QueryField(type = QueryType.EQ)
private Integer companyId; private String companyId;
@Schema(description = "纳税人识别号") @Schema(description = "纳税人识别号")
private String taxpayerCode; private String taxpayerCode;