Commit 6c1ca739 by 黄炜

feat: 招聘需求字段调整

1 parent 28d1d7dd
......@@ -10,6 +10,12 @@
<version>5.8.3-SNAPSHOT</version>
<name>rop-dj-staff-miniprogram</name>
<packaging>war</packaging>
<properties>
<sale.api.version>5.8.2-SNAPSHOT</sale.api.version>
</properties>
<dependencies>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
......@@ -26,6 +32,18 @@
<artifactId>rpc-dj-smartcarlife-api</artifactId>
<version>5.6.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-sale-api</artifactId>
<version>${sale.api.version}</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj.peanalysis</groupId>
<artifactId>rpc-dj-pe-analysis-api</artifactId>
<version>5.8.2-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId>
......
package cn.com.glsx.dj.staff.miniprogram.config.dubbo;
import cn.com.glsx.dj.peanalysis.remote.BusinessAnalysisRemote;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class PeAnalysisDubboConfig extends DubboConfig {
@Bean
public BusinessAnalysisRemote businessAnalysisRemote() {
return factory.builder(BusinessAnalysisRemote.class)
.check(check)
.timeout(timeout)
.version("1.0.0").build();
}
}
package cn.com.glsx.dj.staff.miniprogram.config.dubbo;
import cn.com.glsx.dj.sale.remote.SalePotentialCustomersRemote;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class SaleDubboConfig extends DubboConfig {
@Bean
public SalePotentialCustomersRemote salePotentialCustomersRemote() {
return factory.builder(SalePotentialCustomersRemote.class)
.version("1.0.0")
.protocol("dubbo")
.check(check)
.timeout(timeout).build();
}
}
package cn.com.glsx.dj.staff.miniprogram.controller.recruitment;
import cn.com.glsx.dj.sale.dto.SalePotentialCustomersDTO;
import cn.com.glsx.dj.sale.dto.SalePotentialCustomersFilterDTO;
import cn.com.glsx.dj.sale.remote.SalePotentialCustomersRemote;
import cn.com.glsx.dj.staff.dto.recruitment.RecruitmentDemandDTO;
import cn.com.glsx.dj.staff.miniprogram.convert.RecruitmentDemandDTOConvert;
import cn.com.glsx.dj.staff.miniprogram.request.common.CommonIdRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandAddRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandPageRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.RecruitmentDemandStoreListRequest;
import cn.com.glsx.dj.staff.miniprogram.request.recruitment.SalePotentialCustomersPageRequest;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandDetailResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandPageResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStatResponse;
import cn.com.glsx.dj.staff.miniprogram.response.recruitment.RecruitmentDemandStoreListResponse;
import cn.com.glsx.dj.staff.miniprogram.service.recruitment.RecruitmentDemandService;
import cn.com.glsx.dj.staff.miniprogram.util.CommonUtil;
import cn.com.glsx.dj.staff.remote.RecruitmentDemandRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.rop.response.RopResponse;
import com.rop.AbstractRopRequest;
......@@ -38,6 +43,9 @@ public class RecruitmentDemandController {
private final RecruitmentDemandService recruitmentDemandService;
private final SalePotentialCustomersRemote salePotentialCustomersRemote;
@ApiOperation("招聘需求统计")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.demand.stat", needInSession = NeedInSessionType.YES)
public RopResponse<RecruitmentDemandStatResponse> statRecruitmentDemand(AbstractRopRequest request){
......@@ -80,4 +88,23 @@ public class RecruitmentDemandController {
RecruitmentDemandDTO dto = CommonUtil.convertRequest(RecruitmentDemandDTO.class);
return recruitmentDemandService.addRecruitmentDemand(dto);
}
/**
* 分页查询潜客数据
*/
@ApiOperation("分页查询潜客数据")
@ServiceMethod(method = "dj.api.staff.miniprogram.recruitment.demand.potentialCustomers.page", needInSession = NeedInSessionType.YES)
@PostMapping("/dj.api.staff.miniprogram.recruitment.demand.potentialCustomers.page/1.0.0")
public RopResponse<RpcPagination<SalePotentialCustomersDTO>> page(SalePotentialCustomersPageRequest request) {
RpcPagination<SalePotentialCustomersDTO> rpcPagination = new RpcPagination<>();
rpcPagination.setPageNum(request.getCurrentPage());
rpcPagination.setPageSize(request.getPageSize());
SalePotentialCustomersFilterDTO customersFilterDTO = CommonUtil.convertRequest(SalePotentialCustomersFilterDTO.class);
customersFilterDTO.setQuerySource(1);
if (!recruitmentDemandService.fillAreaOperationPotentialCustomerScope(customersFilterDTO)) {
return RopResponse.error("获取区域运营潜客门店范围失败");
}
return CommonUtil.convertRopResponse(salePotentialCustomersRemote.getPotentialCustomerListPage(customersFilterDTO, rpcPagination));
}
}
......@@ -49,24 +49,7 @@ public class RecruitmentDemandAddRequest extends AbstractRopRequest {
@ApiModelProperty(notes = "是否通过系统门店创建,true-是 false-否,勾选未创建系统门店时传 false")
private Boolean bySystemMerchant;
@ApiModelProperty(notes = "近一月新车销量(未创建系统门店时必填,仅支持大于0的整数,最大不超过9999)")
private Integer salesVolume;
@ApiModelProperty(notes = "潜客门店id,通过潜客门店创建时必传")
private Integer potentialCustomerId;
@ApiModelProperty(notes = "主营品牌,多个以/分隔(未创建系统门店时必填)")
private String brand;
@ApiModelProperty(notes = "门店地址,省市联动(未创建系统门店时必填)")
private String merchantAddress;
/**
* 门店地址详情,最大不超过60个字符
*/
@Size(max = 60, message = "门店地址详情最大不超过60个字符")
private String merchantAddressDetail;
@ApiModelProperty(notes = "省市区编码,格式:省编码/市编码(未创建系统门店时必填)")
private String provinceCityCode;
@ApiModelProperty(notes = "省份名称(未创建系统门店时必填,用于查询技术督导)")
private String province;
}
package cn.com.glsx.dj.staff.miniprogram.request.recruitment;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.util.List;
@Data
@ToString
public class SalePotentialCustomersPageRequest extends AbstractRopRequest {
@ApiModelProperty(notes = "当前页码")
private Integer currentPage;
@ApiModelProperty(notes = "每页条数")
private Integer pageSize;
@ApiModelProperty(notes = "创建开始时间(yyyy-MM-dd HH:mm:ss)")
private String createdStartTime;
@ApiModelProperty(notes = "创建结束时间(yyyy-MM-dd HH:mm:ss)")
private String createdEndTime;
@ApiModelProperty(notes = "省份ID")
private Integer provinceId;
@ApiModelProperty(notes = "城市ID")
private Integer cityId;
@ApiModelProperty(notes = "业务类型 多选 使用逗号分隔 1-【1.1 精品升级】、2-【2.1权益升级】、3-【2.2续保积分】、4-【2.3延保升级】、5-【6.1二手车】")
private List<Integer> businessTypeList;
@ApiModelProperty(notes = "合作模式:1-直营 2-服务商")
private Integer cooperationMode;
@ApiModelProperty(notes = "主营品牌id")
private Integer mainBrandId;
@ApiModelProperty(notes = "子品牌id")
private Integer subBrandId;
@ApiModelProperty(notes = "流量情况 1-[30以下]、2-[30-50]、3-[50-80]、4-[80-120]、5-[120 以上]")
private Integer flowSituation;
@ApiModelProperty(notes = "归属人")
private String salesPersonId;
@ApiModelProperty(notes = "签约开始时间")
private String signedStartTime;
@ApiModelProperty(notes = "签约结束时间")
private String signedEndTime;
@ApiModelProperty(notes = "预计展示开始时间")
private String expectedOperationStartDate;
@ApiModelProperty(notes = "预计展示结束时间")
private String expectedOperationEndDate;
@ApiModelProperty(notes = "状态: 1-跟进中 2-未签约 3-已签约")
private Integer potentialCustomersStatus;
@ApiModelProperty(notes = "信息核验状态 0-否 1-是,复用 isBind 字段")
private Integer isBind;
@ApiModelProperty(notes = "绑定商户名称")
private String merchantName;
@ApiModelProperty(notes = "潜客门店名称")
private String storeName;
}
package cn.com.glsx.dj.staff.miniprogram.service.recruitment;
import cn.com.glsx.dj.peanalysis.dto.analysis.ProvinceOrganizationScopeDTO;
import cn.com.glsx.dj.peanalysis.remote.BusinessAnalysisRemote;
import cn.com.glsx.dj.sale.dto.SalePotentialCustomersFilterDTO;
import cn.com.glsx.dj.carboutique.response.LoginUserInfoResponse;
import cn.com.glsx.dj.smartcarlife.dto.MerchantListDTO;
import cn.com.glsx.dj.smartcarlife.dto.SceneMerchantRefDTO;
......@@ -37,6 +40,7 @@ import org.springframework.transaction.annotation.Transactional;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.stream.Collectors;
......@@ -50,6 +54,10 @@ public class RecruitmentDemandService {
private SceneMerchantRefRemote sceneMerchantRefRemote;
@Autowired
private RecruitmentDemandRemote recruitmentDemandRemote;
@Autowired
private BusinessAnalysisRemote businessAnalysisRemote;
private static final Integer NO_PERMISSION_MERCHANT_ID = -1;
/**
* 门店列表
......@@ -114,6 +122,68 @@ public class RecruitmentDemandService {
}
/**
* 将当前登录区域运营可选范围追加到潜客分页过滤条件。
* 权限来源:dj_car_life_province_organization 按当前登录人 uuid 匹配省份组织关系。
* 表里的 1.1区域运营、2.1区域运营、2.3区域运营分别映射潜客业务场景 1-精品升级、2-权益升级、4-延保升级。
*
* @param customersFilterDTO 潜客分页过滤条件
* @return true-追加成功;false-查询区域运营范围失败
*/
public boolean fillAreaOperationPotentialCustomerScope(SalePotentialCustomersFilterDTO customersFilterDTO) {
RpcResponse<List<ProvinceOrganizationScopeDTO>> provinceResp = businessAnalysisRemote.getPotentialCustomerScopeByUuid(CommonUtil.getLoginUserInfo().getUuid());
if (!provinceResp.hasResult()) {
log.error("fill potential customer scope, 查询当前登录人省份组织关系失败, msg:{}", provinceResp.getMessage());
return false;
}
List<ProvinceOrganizationScopeDTO> provinceOrganizationList = provinceResp.getResult();
if (CollectionUtils.isEmpty(provinceOrganizationList)) {
// 当前登录人没有省份或业务场景权限时,塞一个不存在的范围,避免空条件查出全量潜客。
customersFilterDTO.setProvinceIdList(Collections.singletonList(NO_PERMISSION_MERCHANT_ID));
customersFilterDTO.setBusinessTypeList(Collections.singletonList(NO_PERMISSION_MERCHANT_ID));
return true;
}
List<Integer> provinceIdList = provinceOrganizationList.stream()
.filter(o -> o != null && o.getProvinceId() != null)
.map(ProvinceOrganizationScopeDTO::getProvinceId)
.distinct()
.collect(Collectors.toList());
customersFilterDTO.setProvinceIdList(CollectionUtils.isEmpty(provinceIdList)
? Collections.singletonList(NO_PERMISSION_MERCHANT_ID) : provinceIdList);
// 业务场景要限制在当前区域运营负责的范围内;如果前端已传业务场景,则只保留双方交集。
List<Integer> businessTypeList = provinceOrganizationList.stream()
.filter(o -> o != null && o.getBusinessType() != null)
.map(ProvinceOrganizationScopeDTO::getBusinessType)
.distinct()
.collect(Collectors.toList());
customersFilterDTO.setBusinessTypeList(retainScope(customersFilterDTO.getBusinessTypeList(), businessTypeList));
return true;
}
/**
* 取请求范围与区域运营权限范围的交集。
* 请求未指定时使用全部权限范围;交集为空时返回 -1,避免后续潜客分页按空条件查出全量数据。
*
* @param requestScope 请求中指定的筛选范围,可为空
* @param areaScope 当前登录区域运营可访问的权限范围
* @return 实际传给潜客分页接口的筛选范围
*/
private List<Integer> retainScope(List<Integer> requestScope, List<Integer> areaScope) {
if (CollectionUtils.isEmpty(areaScope)) {
return Collections.singletonList(NO_PERMISSION_MERCHANT_ID);
}
if (CollectionUtils.isEmpty(requestScope)) {
return areaScope;
}
List<Integer> retainList = requestScope.stream()
.filter(areaScope::contains)
.distinct()
.collect(Collectors.toList());
return CollectionUtils.isEmpty(retainList) ? Collections.singletonList(NO_PERMISSION_MERCHANT_ID) : retainList;
}
/**
* 试岗门店(4S店)下拉列表:区域运营名下关联的全部4S店,转换为试岗门店storeNo/storeName。
* 用于新增/编辑试岗人员时选择试岗门店。
*
......@@ -224,17 +294,6 @@ public class RecruitmentDemandService {
if (org.apache.commons.lang3.StringUtils.isBlank(dto.getMerchantId())) {
return RopResponse.error(RopErrorEnum.RECRUITMENT_DEMAND_MERCHANT_REQUIRED);
}
} else {
// 未创建系统门店:销量、品牌、门店地址必填
if (dto.getSalesVolume() == null || dto.getSalesVolume() <= 0) {
return RopResponse.error(RopErrorEnum.RECRUITMENT_DEMAND_SALES_VOLUME_REQUIRED);
}
if (org.apache.commons.lang3.StringUtils.isBlank(dto.getBrand())) {
return RopResponse.error(RopErrorEnum.RECRUITMENT_DEMAND_BRAND_REQUIRED);
}
if (org.apache.commons.lang3.StringUtils.isBlank(dto.getMerchantAddress())) {
return RopResponse.error(RopErrorEnum.RECRUITMENT_DEMAND_ADDRESS_REQUIRED);
}
}
RpcResponse<RecruitmentDemandDTO> response = recruitmentDemandRemote.recruitmentDemandAdd(dto);
if (!response.isSuccess()) {
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议(仅限 Top 3)

    1. [架构规范与可维护性] Controller 层直接调用 RPC 远程接口(严重)

    • 位置:src/main/java/cn/com/glsx/dj/staff/miniprogram/controller/recruitment/RecruitmentDemandController.java
    • 问题描述:在 page 方法中,Controller 直接注入并调用了 salePotentialCustomersRemote(Dubbo RPC 接口)。根据阿里巴巴 Java 开发手册的分层架构规范,Web 层(Controller)应该向下调用 Service 层,由 Service 层负责组合、编排本地逻辑与 RPC 远程调用。Controller 直接调用 RPC 会导致业务逻辑外泄,增加模块间的耦合度,且不利于后续的单元测试和事务/异常统一处理。
    • 优化建议:将 salePotentialCustomersRemote.getPotentialCustomerListPage(...) 的调用逻辑下沉到 RecruitmentDemandService 中,Controller 只负责接收请求、参数校验和调用本地 Service。

    2. [功能健壮性/NPE风险] 链式调用缺乏空指针保护(高)

    • 位置:src/main/java/cn/com/glsx/dj/staff/miniprogram/service/recruitment/RecruitmentDemandService.java (第 133 行)
    • 问题描述:在 fillAreaOperationPotentialCustomerScope 方法中,存在链式调用 CommonUtil.getLoginUserInfo().getUuid()。虽然 Controller 层配置了 needInSession = NeedInSessionType.YES,但在 Service 层直接信任上下文并进行链式调用是极度危险的。一旦获取不到登录态(例如本地测试、拦截器失效或内部调用),将直接抛出 NullPointerException,导致整个接口崩溃。
    • 优化建议:提取变量并进行判空保护: java LoginUserInfoResponse userInfo = CommonUtil.getLoginUserInfo(); if (userInfo == null || userInfo.getUuid() == null) { log.error("获取当前登录用户信息失败"); return false; } RpcResponse<List<ProvinceOrganizationScopeDTO>> provinceResp = businessAnalysisRemote.getPotentialCustomerScopeByUuid(userInfo.getUuid());

    3. [规范与可维护性] Maven 依赖版本未统一管理(中)

    • 位置:pom.xml
    • 问题描述:新增的依赖中,rpc-dj-sale-api 使用了 <properties> 中定义的 ${sale.api.version} 进行版本管理,但紧跟其后的 rpc-dj-pe-analysis-api 却直接硬编码了版本号 5.8.2-SNAPSHOT。这违反了阿里巴巴 Java 开发手册中关于“二方库版本号在 pom.xml 中必须统一定义”的规范,会导致后续升级版本时容易遗漏,增加维护成本。
    • 优化建议:在 <properties> 标签内新增 <peanalysis.api.version>5.8.2-SNAPSHOT</peanalysis.api.version>,并在 <dependency> 中通过 ${peanalysis.api.version} 进行引用。

    二、评分明细

    • 功能实现的正确性与健壮性 (32/40分):业务逻辑实现基本正确,集合交集处理(retainScope)考虑了边界情况,防御性编程较好。但 Service 层存在明显的链式调用 NPE 隐患,扣除 8 分。
    • 安全性与潜在风险 (28/30分):未发现明显的 SQL 注入或越权风险。但新增的 SalePotentialCustomersPageRequest 分页请求类缺少 @Min、@Max 等基础的参数校验注解,可能会导致大批量查询拖垮下游服务,扣除 2 分。
    • 最佳实践与可维护性 (13/20分):Controller 层直接调用 RPC 接口破坏了标准的分层架构,POM 依赖版本管理不一致。扣除 7 分。
    • 性能与资源利用 (5/5分):集合过滤使用了 Java 8 Stream API,且针对省份 ID 等小数据量集合使用 contains 进行交集过滤,性能处于合理范围内。
    • 提交信息质量 (5/5分):提交信息简明扼要,能反映代码变更的目的。

    总分:83分

Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!