Commit fae7712e by 谢海旭

v5.7.4版本 招聘管理

1 parent a36754ac
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
</parent> </parent>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId> <artifactId>rpc-dj-staff-api</artifactId>
<version>5.7.1-SNAPSHOT</version> <version>5.7.4-SNAPSHOT</version>
<name>rpc-dj-staff-api</name> <name>rpc-dj-staff-api</name>
<properties> <properties>
<deploy.scanPackage>cn.com.glsx.dj.staff.remote</deploy.scanPackage> <deploy.scanPackage>cn.com.glsx.dj.staff.remote</deploy.scanPackage>
...@@ -37,7 +37,7 @@ ...@@ -37,7 +37,7 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId> <artifactId>rpc-dj-staff-api</artifactId>
<version>5.7.1-SNAPSHOT</version> <version>5.7.4-SNAPSHOT</version>
</dependency> </dependency>
</dependencies> </dependencies>
</plugin> </plugin>
......
...@@ -37,6 +37,9 @@ public class RecruitmentDemandDTO extends RecruitmentDemand { ...@@ -37,6 +37,9 @@ public class RecruitmentDemandDTO extends RecruitmentDemand {
@ApiModelProperty(notes = "待确认试岗计划数量") @ApiModelProperty(notes = "待确认试岗计划数量")
private Integer trialWaitConfirmCount; private Integer trialWaitConfirmCount;
@ApiModelProperty(notes = "待处理试岗记录数(process_result IS NULL)")
private Integer waitProcessTrialCount;
@ApiModelProperty(notes = "是否只查待处理") @ApiModelProperty(notes = "是否只查待处理")
private Boolean onlyWaiting; private Boolean onlyWaiting;
......
...@@ -99,4 +99,9 @@ public interface RecruitmentDemandRemote { ...@@ -99,4 +99,9 @@ public interface RecruitmentDemandRemote {
@ApiParam(name = "dto", notes = "试岗人员信息,id/demandId/updatedBy必填", dataType = ApiParam.DataTypeEnum.OBJECT, required = true) @ApiParam(name = "dto", notes = "试岗人员信息,id/demandId/updatedBy必填", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("删除结果") @ApiResponse("删除结果")
RpcResponse<String> trialOnboardingDelete(@NotNull RecruitmentTrialOnboardingDTO dto); RpcResponse<String> trialOnboardingDelete(@NotNull RecruitmentTrialOnboardingDTO dto);
@ApiMethod("移动端-处理试岗人员")
@ApiParam(name = "dto", notes = "试岗人员信息,id/demandId/processResult/updatedBy必填", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)
@ApiResponse("处理结果")
RpcResponse<String> trialOnboardingProcess(@NotNull RecruitmentTrialOnboardingDTO dto);
} }
...@@ -7,14 +7,14 @@ ...@@ -7,14 +7,14 @@
</parent> </parent>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff</artifactId> <artifactId>rpc-dj-staff</artifactId>
<version>5.7.0-SNAPSHOT</version> <version>5.7.4-SNAPSHOT</version>
<name>rpc-dj-staff</name> <name>rpc-dj-staff</name>
<packaging>war</packaging> <packaging>war</packaging>
<dependencies> <dependencies>
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-staff-api</artifactId> <artifactId>rpc-dj-staff-api</artifactId>
<version>5.7.1-SNAPSHOT</version> <version>5.7.4-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.oreframework.boot</groupId> <groupId>org.oreframework.boot</groupId>
......
...@@ -322,4 +322,18 @@ public class RecruitmentDemandRemoteImpl implements RecruitmentDemandRemote{ ...@@ -322,4 +322,18 @@ public class RecruitmentDemandRemoteImpl implements RecruitmentDemandRemote{
return RpcResponse.error(e); return RpcResponse.error(e);
} }
} }
@Override
public RpcResponse<String> trialOnboardingProcess(RecruitmentTrialOnboardingDTO dto) {
try {
recruitmentDemandService.trialOnboardingProcess(dto);
return RpcResponse.success("success");
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
} catch (Exception e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
} }
...@@ -1881,6 +1881,11 @@ public class RecruitmentDemandService { ...@@ -1881,6 +1881,11 @@ public class RecruitmentDemandService {
if (!dto.getCreatedPhone().equals(existing.getCreatedPhone())) { if (!dto.getCreatedPhone().equals(existing.getCreatedPhone())) {
throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "仅支持对个人新增的试岗人员进行编辑"); throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "仅支持对个人新增的试岗人员进行编辑");
} }
if (Objects.nonNull(existing.getProcessResult())) {
throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "仅支持对待处理的试岗人员进行编辑");
}
RecruitmentTrialOnboarding update = new RecruitmentTrialOnboarding(); RecruitmentTrialOnboarding update = new RecruitmentTrialOnboarding();
update.setId(dto.getId()); update.setId(dto.getId());
update.setPersonName(dto.getPersonName()); update.setPersonName(dto.getPersonName());
...@@ -1930,6 +1935,10 @@ public class RecruitmentDemandService { ...@@ -1930,6 +1935,10 @@ public class RecruitmentDemandService {
if (!dto.getCreatedPhone().equals(existing.getCreatedPhone())) { if (!dto.getCreatedPhone().equals(existing.getCreatedPhone())) {
throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "仅支持对个人新增的试岗人员进行删除"); throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "仅支持对个人新增的试岗人员进行删除");
} }
if (Objects.nonNull(existing.getProcessResult())) {
throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "仅支持对待处理的试岗人员进行删除");
}
RecruitmentTrialOnboarding update = new RecruitmentTrialOnboarding(); RecruitmentTrialOnboarding update = new RecruitmentTrialOnboarding();
update.setId(dto.getId()); update.setId(dto.getId());
update.setDeletedFlag(BaseModel.DeletedFlagEnum.D.name()); update.setDeletedFlag(BaseModel.DeletedFlagEnum.D.name());
...@@ -1952,4 +1961,54 @@ public class RecruitmentDemandService { ...@@ -1952,4 +1961,54 @@ public class RecruitmentDemandService {
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR); throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
} }
} }
/**
* 移动端-处理试岗人员(单条)
* 与 dj.staff.api.recruitment.demand.process 使用同一把分布式锁(以 demandId 为 key)
* 仅允许对待处理(process_result IS NULL)的试岗记录执行处理
*
* @param dto 试岗记录信息,id / demandId / processResult / processorName / processTime / updatedBy 必填
*/
@GlsxDistributeLockable(name = "'RecruitmentDemandService_recruitmentDemandProcess_' + #dto.demandId", timeoutException = RpcServiceException.class)
@Transactional
public void trialOnboardingProcess(RecruitmentTrialOnboardingDTO dto) {
RpcAssert.assertNotNull(dto, DefaultErrorEnum.DATA_NULL, "dto not be null");
RpcAssert.assertNotNull(dto.getId(), DefaultErrorEnum.DATA_NULL, "id not be null");
RpcAssert.assertNotNull(dto.getDemandId(), DefaultErrorEnum.DATA_NULL, "demandId not be null");
RpcAssert.assertNotNull(dto.getProcessResult(), DefaultErrorEnum.DATA_NULL, "processResult not be null");
RpcAssert.assertNotEmpty(dto.getUpdatedBy(), DefaultErrorEnum.DATA_NULL, "updatedBy not be empty");
try {
RecruitmentTrialOnboarding existing = recruitmentTrialOnboardingMapper.selectByPrimaryKey(dto.getId());
if (existing == null || BaseModel.DeletedFlagEnum.D.name().equals(existing.getDeletedFlag())) {
throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "试岗记录不存在");
}
if (Objects.nonNull(existing.getProcessResult())) {
throw new RpcServiceException(RpcErrorEnum.BUSINESS_ERROR, "试岗记录已处理,不可重复处理");
}
RecruitmentTrialOnboarding update = new RecruitmentTrialOnboarding();
update.setId(dto.getId());
update.setProcessResult(dto.getProcessResult());
update.setProcessRemark(dto.getProcessRemark());
update.setProcessorName(dto.getProcessorName());
update.setProcessTime(dto.getProcessTime());
update.setUpdatedBy(dto.getUpdatedBy());
update.setUpdatedDate(new Date());
recruitmentTrialOnboardingMapper.updateByPrimaryKeySelective(update);
// 添加招聘需求操作记录(处理类型)
RecruitmentDemandOperationLog operationLog = new RecruitmentDemandOperationLog();
operationLog.setDemandId(dto.getDemandId());
operationLog.setOperationType(RecruitmentDemandLogOperationTypeEnum.PROCESS.getValue());
operationLog.setCreatedBy(dto.getUpdatedBy());
operationLog.setCreatedDate(new Date());
operationLog.setUpdatedBy(dto.getUpdatedBy());
operationLog.setUpdatedDate(new Date());
logMapper.insertSelective(operationLog);
} catch (RpcServiceException e) {
throw e;
} catch (Exception e) {
log.error("处理试岗人员异常,id:{}", dto.getId(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR);
}
}
} }
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
<result column="wait_process_resume_count" property="waitProcessResumeCount" jdbcType="INTEGER" /> <result column="wait_process_resume_count" property="waitProcessResumeCount" jdbcType="INTEGER" />
<result column="trial_wait_confirm_count" property="trialWaitConfirmCount" jdbcType="INTEGER" /> <result column="trial_wait_confirm_count" property="trialWaitConfirmCount" jdbcType="INTEGER" />
<result column="onboarding_wait_confirm_count" property="onboardingWaitConfirmCount" jdbcType="INTEGER" /> <result column="onboarding_wait_confirm_count" property="onboardingWaitConfirmCount" jdbcType="INTEGER" />
<result column="wait_process_trial_count" property="waitProcessTrialCount" jdbcType="INTEGER" />
</resultMap> </resultMap>
<resultMap id="webPageRecordDTOMap" type="cn.com.glsx.dj.staff.dto.recruitment.RecruitmentDemandPageRecordDTO" extends="BaseResultMap"> <resultMap id="webPageRecordDTOMap" type="cn.com.glsx.dj.staff.dto.recruitment.RecruitmentDemandPageRecordDTO" extends="BaseResultMap">
</resultMap> </resultMap>
...@@ -62,11 +63,11 @@ ...@@ -62,11 +63,11 @@
select select
count(if((a.status in (2, 3) and a.confirm_flag = 'N') count(if((a.status in (2, 3) and a.confirm_flag = 'N')
or (a.status = 1 and or (a.status = 1 and
(a.resume_wait_confirm_count > 0 or trial_wait_confirm_count > 0 or (a.resume_wait_confirm_count > 0 or wait_process_trial_count > 0 or
onboarding_wait_confirm_count > 0)), onboarding_wait_confirm_count > 0)),
a.id, a.id,
null)) as waitProcessCount, null)) as waitProcessCount,
count(if(a.status = 1 and a.resume_wait_confirm_count > 0, a.id, null)) as waitTSProcessCount, count(if(a.status = 1 and (a.resume_wait_confirm_count > 0 or a.wait_process_trial_count > 0), a.id, null)) as waitTSProcessCount,
count(if(a.status = 4, a.id, null)) as waitTSCheckCount, count(if(a.status = 4, a.id, null)) as waitTSCheckCount,
count(*) as totalCount count(*) as totalCount
from ( from (
...@@ -82,7 +83,7 @@ ...@@ -82,7 +83,7 @@
from dj_car_life_recruitment_trial_onboarding dclrt from dj_car_life_recruitment_trial_onboarding dclrt
where dclrt.demand_id = dclrd.id where dclrt.demand_id = dclrd.id
and dclrt.deleted_flag = 'N' and dclrt.deleted_flag = 'N'
and dclrt.confirm_flag = 'N') as trial_wait_confirm_count, and dclrt.process_result is null) as wait_process_trial_count,
(select count(*) (select count(*)
from dj_car_life_recruitment_onboarding_plan dclrop from dj_car_life_recruitment_onboarding_plan dclrop
where dclrop.demand_id = dclrd.id where dclrop.demand_id = dclrd.id
...@@ -115,10 +116,10 @@ ...@@ -115,10 +116,10 @@
and dclrr2.deleted_flag = 'N' and dclrr2.deleted_flag = 'N'
and (dclrr2.process_result is null or (dclrr2.process_result = 2 and dclrr2.interview_result is null))), 0) as wait_process_resume_count, and (dclrr2.process_result is null or (dclrr2.process_result = 2 and dclrr2.interview_result is null))), 0) as wait_process_resume_count,
if(dclrd.status = 1, (select count(*) if(dclrd.status = 1, (select count(*)
from dj_car_life_recruitment_trial_onboarding dclrt from dj_car_life_recruitment_trial_onboarding dclrt2
where dclrt.demand_id = dclrd.id and dclrt.deleted_flag = 'N' where dclrt2.demand_id = dclrd.id and dclrt2.deleted_flag = 'N'
and dclrt.confirm_flag = 'N' and dclrt2.process_result is null
), 0) as trial_wait_confirm_count, ), 0) as wait_process_trial_count,
if(dclrd.status = 1, (select count(*) if(dclrd.status = 1, (select count(*)
from dj_car_life_recruitment_onboarding_plan dclrop from dj_car_life_recruitment_onboarding_plan dclrop
where dclrop.demand_id = dclrd.id where dclrop.demand_id = dclrd.id
...@@ -151,32 +152,38 @@ ...@@ -151,32 +152,38 @@
and (dclrr.process_result is null or (dclrr.process_result = 2 and dclrr.interview_result is null))) and (dclrr.process_result is null or (dclrr.process_result = 2 and dclrr.interview_result is null)))
or exists( or exists(
select 1 select 1
from dj_car_life_recruitment_trial_onboarding t_pending
where t_pending.demand_id = dclrd.id
and t_pending.deleted_flag = 'N'
and t_pending.process_result is null)
or exists(
select 1
from dj_car_life_recruitment_onboarding_plan t1 from dj_car_life_recruitment_onboarding_plan t1
where t1.demand_id = dclrd.id where t1.demand_id = dclrd.id
and t1.deleted_flag = 'N' and t1.deleted_flag = 'N'
and t1.confirm_flag = 'N') and t1.confirm_flag = 'N')
or exists(
select 1
from dj_car_life_recruitment_trial_onboarding t2
where t2.demand_id = dclrd.id
and t2.deleted_flag = 'N'
and t2.confirm_flag = 'N')
))) )))
</if> </if>
<if test="onlyTSWaiting != null and onlyTSWaiting"> <if test="onlyTSWaiting != null and onlyTSWaiting">
and dclrd.status = 1 and dclrd.status = 1
and exists( and (exists(
select 1 select 1
from dj_car_life_recruitment_resume dclrr from dj_car_life_recruitment_resume dclrr
where dclrr.demand_id = dclrd.id where dclrr.demand_id = dclrd.id
and dclrr.deleted_flag = 'N' and dclrr.deleted_flag = 'N'
and (dclrr.process_result is null or (dclrr.process_result = 2 and dclrr.interview_result is null))) and (dclrr.process_result is null or (dclrr.process_result = 2 and dclrr.interview_result is null)))
or exists(
select 1
from dj_car_life_recruitment_trial_onboarding dclrto
where dclrto.demand_id = dclrd.id
and dclrto.deleted_flag = 'N'
and dclrto.process_result is null))
</if> </if>
</where> </where>
<if test="onlyWaiting != null and onlyWaiting"> <if test="onlyWaiting != null and onlyWaiting">
order by order by
case when dclrd.status = 1 and wait_process_resume_count > 0 then 5 case when dclrd.status = 1 and wait_process_resume_count > 0 then 5
when dclrd.status = 1 and trial_wait_confirm_count > 0 then 4 when dclrd.status = 1 and wait_process_trial_count > 0 then 4
when dclrd.status = 1 and onboarding_wait_confirm_count > 0 then 3 when dclrd.status = 1 and onboarding_wait_confirm_count > 0 then 3
when dclrd.status = 2 then 2 when dclrd.status = 2 then 2
when dclrd.status = 3 then 1 end desc, when dclrd.status = 3 then 1 end desc,
......
...@@ -86,7 +86,7 @@ ...@@ -86,7 +86,7 @@
select <include refid="Base_Column_List"></include> select <include refid="Base_Column_List"></include>
from dj_car_life_recruitment_trial_onboarding dclrto from dj_car_life_recruitment_trial_onboarding dclrto
<include refid="listCondition"></include> <include refid="listCondition"></include>
order by dclrto.trial_time, dclrto.id order by (dclrto.process_result is null) desc, dclrto.id asc
</select> </select>
<update id="updateConfirmFlagToConfirmed"> <update id="updateConfirmFlagToConfirmed">
......
  • @wangxw1
    commented
    Master

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

    1. 严重违反强制规则:MyBatis SQL 中大量使用了子查询

    • 问题描述:在 RecruitmentDemandMapper.xml 中,无论是 SELECT 字段列表里(如 (select count(*) from dj_car_life_recruitment_trial_onboarding...)),还是 WHERE 条件中(如 exists(select 1 ...)),都大量使用了嵌套子查询。
    • 影响分析:严重违反了“mybatis SQL中不允许使用子查询”的明确规定。在 SELECT 列表中对每一行执行多次子查询会导致典型的 N+1 性能问题,当主表数据量变大时,数据库性能将急剧下降,造成严重的慢 SQL 甚至拖垮数据库。
    • 优化建议:将子查询改写为 LEFT JOIN 配合 GROUP BY 进行聚合关联,或者将复杂的统计逻辑拆分到 Java 业务层组装。 示例(LEFT JOIN 改写): xml LEFT JOIN ( SELECT demand_id, COUNT(*) AS wait_process_trial_count FROM dj_car_life_recruitment_trial_onboarding WHERE deleted_flag = 'N' AND process_result IS NULL GROUP BY demand_id ) trial_stats ON trial_stats.demand_id = dclrd.id

    2. 数据库方言依赖:布尔表达式排序存在兼容性隐患

    • 问题描述:在 RecruitmentTrialOnboardingMapper.xml 中使用了 order by (dclrto.process_result is null) desc, dclrto.id asc。
    • 影响分析:直接在 ORDER BY 中使用布尔表达式是 MySQL 的特有语法,不符合标准 SQL 规范。若未来有数据库迁移需求(如迁移至 PostgreSQL 或 Oracle),该语句将会报错,降低了代码的可维护性与兼容性。
    • 优化建议:使用标准的 CASE WHEN 语句来实现相同的排序逻辑。 示例: xml order by (CASE WHEN dclrto.process_result IS NULL THEN 1 ELSE 0 END) desc, dclrto.id asc

    3. 冗余的异常捕获处理逻辑

    • 问题描述:在 RecruitmentDemandRemoteImpl.java 的 trialOnboardingProcess 方法中,分别捕获了 RpcServiceException 和 Exception,但处理逻辑完全一致。
    • 影响分析:虽然不影响功能,但违反了 DRY(Don't Repeat Yourself)原则,增加了无意义的代码行数,降低了代码的可读性。
    • 优化建议:由于处理动作相同,且 RpcServiceException 是 Exception 的子类,可直接合并捕获,或仅保留对 Exception 的捕获(如果无需对自定义异常做特殊处理)。 示例: java } catch (Exception e) { log.error(e.getMessage(), e); return RpcResponse.error(e); }

    二、评分明细

    • 功能实现的正确性与健壮性(25/40分):业务逻辑基本正确,且添加了合理的参数校验和状态控制。但严重违反了“MyBatis SQL 中不允许使用子查询”的硬性规定,因此大幅扣分。
    • 安全性与潜在风险(30/30分):使用了 MyBatis 的安全传参方式,未发现 SQL 注入、XSS 等明显安全漏洞。权限控制与分布式锁的使用合理。
    • 最佳实践与可维护性(15/20分):整体代码结构较清晰,注释完善。但存在非标准的 SQL 排序语法以及冗余的异常捕获代码,影响了可维护性。
    • 性能与资源利用(0/5分):SELECT 字段中嵌套子查询是典型的 SQL 性能反模式,会随数据量增长造成严重的性能瓶颈,完全未体现对数据库资源的合理利用。
    • 提交信息质量(2/5分):提交信息“v5.7.4版本 招聘管理 (by xiehx)”过于宽泛,未能准确体现本次新增“试岗人员处理接口”及相关状态变更的核心内容,缺乏可追溯性。

    总分:72分

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