Commit 71ee657f by 庞善天

轻改短课程需求开发

1 parent 0ba32751
...@@ -12,7 +12,7 @@ ...@@ -12,7 +12,7 @@
<name>rpc-dj-smartcarlife-api</name> <name>rpc-dj-smartcarlife-api</name>
<properties> <properties>
<deploy.scanPackage>cn.com.glsx.dj.smartcarlife.remote</deploy.scanPackage> <deploy.scanPackage>cn.com.glsx.dj.smartcarlife.remote</deploy.scanPackage>
<smartcarlife.api.version>5.7.1-SNAPSHOT</smartcarlife.api.version> <smartcarlife.api.version>5.7.5-SNAPSHOT</smartcarlife.api.version>
<shopamll.api.version>5.6.4-SNAPSHOT</shopamll.api.version> <shopamll.api.version>5.6.4-SNAPSHOT</shopamll.api.version>
</properties> </properties>
<dependencies> <dependencies>
......
...@@ -170,4 +170,9 @@ public interface ContentManagerTaskRemote { ...@@ -170,4 +170,9 @@ public interface ContentManagerTaskRemote {
@ApiMethod("手动刷新长课程数据") @ApiMethod("手动刷新长课程数据")
RpcResponse<Boolean> syncStaffStudyCourse(); RpcResponse<Boolean> syncStaffStudyCourse();
@ApiMethod("学习中心-轻改短课程任务详情")
@ApiParam(name="request",notes="查询条件",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)
@ApiResponse("轻改任务详情")
RpcResponse<GetStaffStudyShortCourseDetailVO> getStaffLightShortCourseDetail(StaffStudyCourseDTO request);
} }
...@@ -173,5 +173,10 @@ public interface StaffBaseInfoRemote { ...@@ -173,5 +173,10 @@ public interface StaffBaseInfoRemote {
@ApiParams({@ApiParam(name = "staffPhone", notes = "手机号", dataType = ApiParam.DataTypeEnum.STRING, required = true)}) @ApiParams({@ApiParam(name = "staffPhone", notes = "手机号", dataType = ApiParam.DataTypeEnum.STRING, required = true)})
@ApiResponse("员工配置信息") @ApiResponse("员工配置信息")
RpcResponse<StaffConfig> getStaffConfig(String staffPhone); RpcResponse<StaffConfig> getStaffConfig(String staffPhone);
@ApiMethod("根据手机号集合获取员工列表")
@ApiParam(name="condition",notes="查询条件",dataType= ApiParam.DataTypeEnum.OBJECT,required=true)
@ApiResponse("员工列表")
RpcResponse<List<StaffBaseInfoDTO>> getStaffListByPhones(StaffBaseInfoDTO condition);
} }
...@@ -8,14 +8,14 @@ ...@@ -8,14 +8,14 @@
</parent> </parent>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-smartcarlife</artifactId> <artifactId>rpc-dj-smartcarlife</artifactId>
<version>5.6.4-SNAPSHOT</version> <version>5.7.5-SNAPSHOT</version>
<name>rpc-dj-smartcarlife</name> <name>rpc-dj-smartcarlife</name>
<packaging>war</packaging> <packaging>war</packaging>
<properties> <properties>
<skipTests>true</skipTests> <skipTests>true</skipTests>
<shopmall.api.version>5.6.4-SNAPSHOT</shopmall.api.version> <shopmall.api.version>5.6.4-SNAPSHOT</shopmall.api.version>
<stoassistant.api.version>5.6.4-SNAPSHOT</stoassistant.api.version> <stoassistant.api.version>5.6.4-SNAPSHOT</stoassistant.api.version>
<smartcarlife.api.version>5.7.1-SNAPSHOT</smartcarlife.api.version> <smartcarlife.api.version>5.7.5-SNAPSHOT</smartcarlife.api.version>
</properties> </properties>
<dependencies> <dependencies>
<dependency> <dependency>
......
...@@ -422,4 +422,15 @@ public class ContentManagerTaskRemoteImpl implements ContentManagerTaskRemote { ...@@ -422,4 +422,15 @@ public class ContentManagerTaskRemoteImpl implements ContentManagerTaskRemote {
} }
} }
@Override
public RpcResponse<GetStaffStudyShortCourseDetailVO> getStaffLightShortCourseDetail(StaffStudyCourseDTO request) {
RpcAssert.assertNotNull(request.getStaffPhone(), DefaultErrorEnum.PARAMETER_NULL, "param staffPhone must not be null");
try {
return RpcResponse.success(contentManagerTaskService.getStaffLightShortCourseDetail(request));
} catch (RpcServiceException e) {
log.error(e.getMessage(), e);
return RpcResponse.error(e);
}
}
} }
...@@ -349,4 +349,14 @@ public class StaffBaseInfoRemoteImpl implements StaffBaseInfoRemote { ...@@ -349,4 +349,14 @@ public class StaffBaseInfoRemoteImpl implements StaffBaseInfoRemote {
return RpcResponse.error(e); return RpcResponse.error(e);
} }
} }
@Override
public RpcResponse<List<StaffBaseInfoDTO>> getStaffListByPhones(StaffBaseInfoDTO condition) {
try{
return RpcResponse.success(staffBaseInfoService.getStaffListByPhones(condition));
}catch(RpcServiceException e){
log.error(e.getMessage(),e);
return RpcResponse.error(e);
}
}
} }
...@@ -3584,4 +3584,48 @@ public class ContentManagerTaskService { ...@@ -3584,4 +3584,48 @@ public class ContentManagerTaskService {
} }
return null; return null;
} }
public GetStaffStudyShortCourseDetailVO getStaffLightShortCourseDetail(StaffStudyCourseDTO condition) {
long l = System.currentTimeMillis();
GetStaffStudyShortCourseDetailVO detailVO = new GetStaffStudyShortCourseDetailVO();
try {
List<Integer> merchantIdList = this.getMerchantListByResidentStaff(detailVO.getStaffPhone(), false);
if (CollectionUtils.isNotEmpty(merchantIdList)) {
ShopMerchantDirectorConfigDTO configDTO = new ShopMerchantDirectorConfigDTO();
configDTO.setMerchantIdList(merchantIdList);
configDTO.setDirectorType(DirectorTypeEnum.AREA_SUPERVISION_2_1.getValue());
List<ShopMerchantDirectorConfigDTO> directorConfigDTOList = shopMerchantDirectorConfigService.list(configDTO);
if (CollectionUtils.isNotEmpty(directorConfigDTOList)) {
detailVO.setSuperior(directorConfigDTOList.stream()
.map(ShopMerchantDirectorConfigDTO::getDirectorName)
.filter(Objects::nonNull).collect(Collectors.joining(",")));
}
}
RpcPagination<MerchantStaffRequest> pagination = new RpcPagination<>();
pagination.setPageNum(1);
pagination.setPageSize(Integer.MAX_VALUE);
MerchantStaffRequest staffRequest = new MerchantStaffRequest();
staffRequest.setStaffBusinessType(0);
staffRequest.setStaffBusinessType(StaffBusinessTypeEnum.RESIDENT.getCode());
staffRequest.setStaffPhone(detailVO.getStaffPhone());
pagination.setCondition(staffRequest);
RpcResponse<RpcPagination<MerchantStaffResponse>> staffByPageRemote = merchantStaffRemote.findStaffByPageRemote(pagination);
if (staffByPageRemote != null && staffByPageRemote.isSuccess() && staffByPageRemote.getResult() != null) {
staffByPageRemote.getResult().getList().stream()
.map(MerchantStaffResponse::getCreatedTime)
.filter(Objects::nonNull)
.min(Comparator.comparing(Date::getTime))
.ifPresent(residentDate -> {
detailVO.setResidentTimeTag(classifyStayDuration(residentDate));
});
}
} catch (Exception e) {
log.error("构建轻改短课程员工信息数据失败 error:{}",e.getMessage(), e);
throw new RpcServiceException("短课程不存在");
} finally {
log.info("构建轻改短课程员工信息数据耗时:{}", System.currentTimeMillis() - l);
}
return detailVO;
}
} }
\ No newline at end of file \ No newline at end of file
...@@ -2308,4 +2308,14 @@ public class StaffBaseInfoService { ...@@ -2308,4 +2308,14 @@ public class StaffBaseInfoService {
throw new RpcServiceException(e.getMessage()); throw new RpcServiceException(e.getMessage());
} }
} }
public List<StaffBaseInfoDTO> getStaffListByPhones(StaffBaseInfoDTO condition) {
RpcAssert.assertNotNull(condition.getStaffPhoneList(), DefaultErrorEnum.DATA_NULL, "staffPhoneList not be null");
try {
return staffBaseInfoMapper.list(StaffBaseInfoDTO.builder().staffPhoneList(condition.getStaffPhoneList()).build());
} catch (Exception e) {
log.info(e.getMessage(), e);
throw new RpcServiceException(DefaultErrorEnum.DATABASE_ERROR, e.getMessage());
}
}
} }
...@@ -130,6 +130,12 @@ ...@@ -130,6 +130,12 @@
<if test="workingStatus != null"> <if test="workingStatus != null">
and working_status = #{workingStatus} and working_status = #{workingStatus}
</if> </if>
<if test="staffPhoneList != null and staffPhoneList.size() > 0">
and staff_phone in
<foreach collection="staffPhoneList" item="item" separator="," open="(" close=")">
#{item,jdbcType=VARCHAR}
</foreach>
</if>
</where> </where>
</select> </select>
......
  • @wangxw1
    commented
    Master

    一、关键问题与优化建议

    1. 逻辑错误:在业务逻辑中使用了未初始化的变量属性(重要)

    • 问题描述:在 ContentManagerTaskService.getStaffLightShortCourseDetail 方法中,代码首先创建了 detailVO 实例,随后在获取商户列表和设置查询条件时,多次调用了 detailVO.getStaffPhone()。由于 detailVO 是刚 new 出来的,其 staffPhone 属性为 null。
    • 影响分析:导致 getMerchantListByResidentStaff 无法查到数据,且远程调用 merchantStaffRemote.findStaffByPageRemote 时查询条件中的手机号为空,无法获取正确的员工入驻时间。该接口功能将完全失效。
    • 优化建议:应使用入参 condition.getStaffPhone() 获取手机号,并先将其赋值给 detailVO。 java public GetStaffStudyShortCourseDetailVO getStaffLightShortCourseDetail(StaffStudyCourseDTO condition) { GetStaffStudyShortCourseDetailVO detailVO = new GetStaffStudyShortCourseDetailVO(); detailVO.setStaffPhone(condition.getStaffPhone()); // 先赋值 // 后续逻辑改用 condition.getStaffPhone() 或已赋值的 detailVO.getStaffPhone() }

    2. 稳定性风险:远程分页调用设置 Integer.MAX_VALUE(中等)

    • 问题描述:在调用 merchantStaffRemote.findStaffByPageRemote 时,将 pageSize 设置为 Integer.MAX_VALUE。
    • 影响分析:若下游服务数据量异常或未做强制限额,可能导致下游 SQL 执行缓慢、内存溢出(OOM)或 Dubbo 响应超时,影响系统稳定性。
    • 优化建议:即使预期数据量不大,也应设置一个合理的上限(如 100 或 500),或者根据业务需求评估是否真的需要全量拉取。

    3. 异常处理不当:强行转换异常信息导致误导(低影响)

    • 问题描述:在 getStaffLightShortCourseDetail 方法中,catch (Exception e) 块统一抛出了 new RpcServiceException("短课程不存在")。
    • 影响分析:如果代码是因为空指针(NPE)或远程服务调用超时报错,前端却提示“短课程不存在”,会严重误导排查人员和用户,掩盖真实系统故障。
    • 优化建议:应区分业务逻辑异常和系统异常。对于未知异常,建议保留原始错误原因或返回更通用的“系统繁忙”信息,并确保日志完整记录。

    二、评分明细

    • 功能实现的正确性与健壮性(25/40):逻辑存在明显漏洞(使用 null 变量),导致核心功能不可用;存在冗余代码(setStaffBusinessType 被连续赋值两次)。
    • 安全性与潜在风险(28/30):未发现 SQL 注入或越权风险。MyBatis SQL 使用了 foreach 处理集合,符合非子查询要求。接口为新增,不涉及已有参数变更风险。
    • 最佳实践与可维护性(15/20):代码结构清晰,但异常处理过于武断;detailVO 的构建逻辑与方法名“获取详情”的契合度在当前代码片段中体现不足(仅见员工信息,未见课程详情)。
    • 性能与资源利用(4/5):Integer.MAX_VALUE 的分页设置存在潜在风险,虽然在特定手机号过滤下数据量可能受限,但属于工程坏习惯。
    • 提交信息质量(5/5):commit 信息简单明确,虽然可以更详细,但符合基本追溯要求。

    总分:77分

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