Commit d93a0e9c by 王璐琦

feat(dailyreport): 新增日报数据上报功能及相关状态字段

- 新增接口pushDailyReportData,实现动态日报数据的推送上报
- 在DailyReportRecord等相关对象中增加submissionStatus和submissionDate字段
- 保存日报数据时,门店日报默认设置未上报状态
- 实现日报推送逻辑,防止重复上报并更新上报时间
- 调整相关DTO和请求参数,支持上报状态和上报时间传递
- 标记旧的日报草稿保存接口为Deprecated,准备替换使用新接口
1 parent b4f155d0
...@@ -77,6 +77,16 @@ public class DailyReportRecordController { ...@@ -77,6 +77,16 @@ public class DailyReportRecordController {
return CommonUtil.convertRopResponse(response); return CommonUtil.convertRopResponse(response);
} }
@ApiOperation("日报数据上报")
@ServiceMethod(method = "dj.api.smartcarlife.dailyReport.dynamic.data.push", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> pushDailyReportData(DynamicDailyReportPushRequest request) {
DailyReportRecordDTO dailyReportRecordDTO = CommonUtil.convertRequest(DailyReportRecordDTO.class);
dailyReportRecordDTO.setUpdatedBy(CommonUtil.getUserName());
RpcResponse<Boolean> response = dailyReportRecordRemote.pushDailyReportData(dailyReportRecordDTO);
return CommonUtil.convertRopResponse(response);
}
@Deprecated
@ApiOperation("日报草稿数据保存") @ApiOperation("日报草稿数据保存")
@ServiceMethod(method = "dj.api.smartcarlife.dailyReport.dynamic.draft.save", needInSession = NeedInSessionType.YES) @ServiceMethod(method = "dj.api.smartcarlife.dailyReport.dynamic.draft.save", needInSession = NeedInSessionType.YES)
public RopResponse<Boolean> saveDraftDailyReport(DynamicDailyReportSaveRequest request) { public RopResponse<Boolean> saveDraftDailyReport(DynamicDailyReportSaveRequest request) {
......
package cn.com.glsx.dj.carboutique.request.smartcarlife.dailyreport;
import com.rop.AbstractRopRequest;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
/**
* @ClassName DynamicDailyReportPushRequest
* @Description 动态日报推送请求参数
* @Author lqWang
* @Date 2026/7/22 17:18
*/
@Data
@ToString
public class DynamicDailyReportPushRequest extends AbstractRopRequest {
@ApiModelProperty(name = "dailyReportRecordId", notes = "填报记录id")
private Integer dailyReportRecordId;
}
...@@ -58,6 +58,12 @@ public class DynamicDailyReportSaveRequest extends AbstractRopRequest { ...@@ -58,6 +58,12 @@ public class DynamicDailyReportSaveRequest extends AbstractRopRequest {
@ApiModelProperty(name = "templateType", notes = "模板类型(1:驻店日报,2:门店日报,3:洽谈明细)",required=true) @ApiModelProperty(name = "templateType", notes = "模板类型(1:驻店日报,2:门店日报,3:洽谈明细)",required=true)
private Byte templateType; private Byte templateType;
@ApiModelProperty(name = "submissionStatus", notes = "上报状态(1:已上报,2:未上报)")
private Byte submissionStatus;
@ApiModelProperty(name = "submissionDate", notes = "上报时间")
private Byte submissionDate;
@ApiModelProperty(name = "reportTemplateId", notes = "报表模板id") @ApiModelProperty(name = "reportTemplateId", notes = "报表模板id")
private Integer reportTemplateId; private Integer reportTemplateId;
......
...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -4,6 +4,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.Date;
/** /**
* @ClassName DailyReportRecordDetailResponse * @ClassName DailyReportRecordDetailResponse
...@@ -51,6 +52,12 @@ public class DailyReportRecordDetailResponse implements Serializable { ...@@ -51,6 +52,12 @@ public class DailyReportRecordDetailResponse implements Serializable {
@ApiModelProperty(notes = "填报状态:0=草稿,1=已提交") @ApiModelProperty(notes = "填报状态:0=草稿,1=已提交")
private Byte reportStatus; private Byte reportStatus;
@ApiModelProperty(notes = "填报状态(1:已上报,2:未上报)")
private Byte submissionStatus;
@ApiModelProperty(notes = "上报时间")
private Date submissionDate;
@ApiModelProperty(notes = "提交内容") @ApiModelProperty(notes = "提交内容")
private String jsonContent; private String jsonContent;
} }
  • @wangxw1
    commented
    Master

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

    1. 数据类型定义严重错误(功能正确性 - 严重)

    • 位置:DynamicDailyReportSaveRequest.java 第 63 行
    • 问题描述:submissionDate(上报时间)字段的数据类型被错误地定义为了 Byte。
    • 潜在风险:时间数据无法用单个字节(Byte)表示。这会导致在反序列化时发生类型转换异常(TypeMismatchException),或者导致时间数据完全丢失,接口直接不可用。注意在 DailyReportRecordDetailResponse 中同名字段已被正确定义为 Date。
    • 优化建议:将 submissionDate 的类型修改为 java.util.Date、java.time.LocalDateTime 或 String(根据项目中统一的时间处理规范而定)。

    2. 接口入参未使用/对象转换逻辑异常(功能正确性 - 高)

    • 位置:DailyReportRecordController.java 第 83 行 (pushDailyReportData 方法)
    • 问题描述:方法接收了 request 参数,但在下一行的转换逻辑中完全没有使用:DailyReportRecordDTO dailyReportRecordDTO = CommonUtil.convertRequest(DailyReportRecordDTO.class);。
    • 潜在风险:如果 CommonUtil.convertRequest 期望传入源对象,这里属于漏传参数的 Bug(应为 convertRequest(request, xxx.class));如果该工具类是依靠 ThreadLocal 等上下文隐式获取请求参数,这种设计极度不透明,且容易在异步或多线程环境下引发数据错乱(数据串读)。
    • 优化建议:显式传递请求参数,修改为类似 CommonUtil.convertRequest(request, DailyReportRecordDTO.class); 的标准写法,确保数据来源清晰。

    3. 核心请求参数缺乏校验(安全性与健壮性 - 中)

    • 位置:DynamicDailyReportPushRequest.java 第 19 行
    • 问题描述:dailyReportRecordId 作为执行推送逻辑的核心 ID,缺少 JSR-303 参数校验注解(如 @NotNull)。
    • 潜在风险:如果前端漏传该参数,后端接收到的将是 null。该 null 值被传递到 RPC 层的 pushDailyReportData 方法时,极易引发 NullPointerException 或导致全表误更新等不可预期的 SQL 行为。
    • 优化建议:为必传字段添加校验注解,例如 @NotNull(message = "填报记录id不能为空"),并在 Controller 层对应方法参数前加上 @Valid 或 @Validated 注解。

    二、评分明细

    评审项 满分 得分 扣分说明
    1. 功能正确性与健壮性 40分 22分 扣18分。submissionDate 定义为 Byte 属于严重阻断性 Bug(-10分);Controller 中 request 参数未使用/隐式转换存在重大隐患(-8分)。
    2. 安全性与潜在风险 30分 25分 扣5分。核心请求 DTO 缺少 @NotNull 等基础防御性校验,存在空指针风险。
    3. 最佳实践与可维护性 20分 18分 扣2分。@Data 注解已包含 @ToString,DynamicDailyReportPushRequest 中同时使用属于冗余(-1分);类注释中的日期 2026/7/22 疑似笔误(-1分)。
    4. 性能与资源利用 5分 5分 满分。未见明显的性能瓶颈或资源滥用。
    5. 提交信息质量 5分 5分 满分。Commit message 格式规范(遵循 Angular 规范),清晰地描述了新增功能、字段变更以及废弃接口的原因。

    总分:75分

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