Commit bf951a25 by 黄炜

feat: 事项-督导带教提交逻辑

1 parent 0ae5ae3e
...@@ -123,4 +123,16 @@ public class TaskInfoDTO implements Serializable { ...@@ -123,4 +123,16 @@ public class TaskInfoDTO implements Serializable {
@ApiModelProperty(notes = "参与人员名称列表,仅专项带教任务返回") @ApiModelProperty(notes = "参与人员名称列表,仅专项带教任务返回")
private List<String> taskStaffList; private List<String> taskStaffList;
@ApiModelProperty(notes = "带教内容摘要,仅专项带教任务返回")
private String assigneeDetail;
@ApiModelProperty(notes = "带教照片佐证URL列表,仅专项带教任务返回")
private List<String> assigneeImages;
@ApiModelProperty(notes = "推送课程ID,仅专项带教任务返回")
private String pushCoursesId;
@ApiModelProperty(notes = "推送课程名称,仅专项带教任务返回")
private String pushCoursesName;
} }
...@@ -3,12 +3,8 @@ package cn.com.glsx.dj.staff.dto.taskcenter; ...@@ -3,12 +3,8 @@ package cn.com.glsx.dj.staff.dto.taskcenter;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import javax.validation.constraints.Max;
import javax.validation.constraints.Min;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 专项任务回复提交 DTO * 专项任务回复提交 DTO
...@@ -19,33 +15,56 @@ public class TaskInfoSubmitDTO implements Serializable { ...@@ -19,33 +15,56 @@ public class TaskInfoSubmitDTO implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "任务主键id", required = true) @ApiModelProperty(notes = "任务主键id", required = true)
@NotNull(message = "任务id不能为空")
private Long id; private Long id;
@ApiModelProperty(notes = "专项任务回复内容,1-800字符", required = true) @ApiModelProperty(notes = "专项任务回复内容,1-800字符", required = true)
@NotBlank(message = "专项任务回复不能为空")
@Size(max = 800, message = "专项任务回复不能超过800字符")
private String replyContent; private String replyContent;
@ApiModelProperty(notes = "修改人") @ApiModelProperty(notes = "修改人")
@Size(max = 64, message = "修改人不能超过64字符")
private String updatedBy; private String updatedBy;
@ApiModelProperty(notes = "是否更换:0-不更换,1-更换;人员更换评估任务必填") @ApiModelProperty(notes = "是否更换:0-不更换,1-更换;人员更换评估任务必填")
@Min(value = 0, message = "是否更换参数不正确")
@Max(value = 1, message = "是否更换参数不正确")
private Integer replaceFlag; private Integer replaceFlag;
@ApiModelProperty(notes = "更换方式:1-发起招聘需求,2-关联已有招聘需求,3-关联另一个驻店人员完成调换") @ApiModelProperty(notes = "更换方式:1-发起招聘需求,2-关联已有招聘需求,3-关联另一个驻店人员完成调换")
@Min(value = 1, message = "更换方式参数不正确")
@Max(value = 3, message = "更换方式参数不正确")
private Integer replaceMethod; private Integer replaceMethod;
@ApiModelProperty(notes = "招聘需求id") @ApiModelProperty(notes = "招聘需求id")
@Size(max = 64, message = "招聘需求id不能超过64字符")
private String recruitmentDemandId; private String recruitmentDemandId;
@ApiModelProperty(notes = "完成调换的驻店人员uuid") @ApiModelProperty(notes = "完成调换的驻店人员uuid")
@Size(max = 64, message = "调换驻店人员uuid不能超过64字符")
private String replacementStaffUuid; private String replacementStaffUuid;
@ApiModelProperty(notes = "带教场景编码,督导带教任务必填")
private String teachingSceneCode;
@ApiModelProperty(notes = "带教场景名称,督导带教任务必填")
private String teachingSceneName;
@ApiModelProperty(notes = "带教时间,格式:yyyy-MM-dd HH:mm:ss,督导带教任务必填")
private String teachingTime;
@ApiModelProperty(notes = "带教方式编码,督导带教任务必填")
private String teachingMethodCode;
@ApiModelProperty(notes = "带教方式名称,督导带教任务必填")
private String teachingMethodName;
@ApiModelProperty(notes = "带教主题编码,督导带教任务必填")
private String teachingTopicCode;
@ApiModelProperty(notes = "带教主题名称,督导带教任务必填")
private String teachingTopicName;
@ApiModelProperty(notes = "带教内容摘要,督导带教任务必填")
private String assigneeDetail;
@ApiModelProperty(notes = "带教照片佐证URL列表,督导带教任务必填")
private List<String> assigneeImages;
@ApiModelProperty(notes = "推送课程ID,督导带教任务选填")
private String pushCoursesId;
@ApiModelProperty(notes = "推送课程名称,督导带教任务选填")
private String pushCoursesName;
} }
...@@ -19,61 +19,96 @@ public class TaskSupervisorCoach implements Serializable { ...@@ -19,61 +19,96 @@ public class TaskSupervisorCoach implements Serializable {
private static final long serialVersionUID = 1L; private static final long serialVersionUID = 1L;
/** 扩展表主键。 */
@Id @Id
@GeneratedValue(strategy = GenerationType.IDENTITY) @GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id; private Long id;
/** 本地事项ID,关联dj_car_life_task_info.id。 */
@Column(name = "task_id") @Column(name = "task_id")
private Long taskId; private Long taskId;
/** 任务中心任务ID。 */
@Column(name = "task_center_id") @Column(name = "task_center_id")
private Long taskCenterId; private Long taskCenterId;
/** 带教场景编码。 */
@Column(name = "teaching_scene_code") @Column(name = "teaching_scene_code")
private String teachingSceneCode; private String teachingSceneCode;
/** 带教场景名称,例如线上、线下。 */
@Column(name = "teaching_scene_name") @Column(name = "teaching_scene_name")
private String teachingSceneName; private String teachingSceneName;
/** 实际带教时间。 */
@Column(name = "teaching_time") @Column(name = "teaching_time")
private Date teachingTime; private Date teachingTime;
/** 带教方式编码。 */
@Column(name = "teaching_method_code") @Column(name = "teaching_method_code")
private String teachingMethodCode; private String teachingMethodCode;
/** 带教方式名称,例如视频培训、现场培训。 */
@Column(name = "teaching_method_name") @Column(name = "teaching_method_name")
private String teachingMethodName; private String teachingMethodName;
/** 带教主题编码。 */
@Column(name = "teaching_topic_code") @Column(name = "teaching_topic_code")
private String teachingTopicCode; private String teachingTopicCode;
/** 带教主题名称。 */
@Column(name = "teaching_topic_name") @Column(name = "teaching_topic_name")
private String teachingTopicName; private String teachingTopicName;
/** 带教目标原始值,例如转化率目标60。 */
@Column(name = "teaching_target") @Column(name = "teaching_target")
private String teachingTarget; private String teachingTarget;
/** 带教门店ID。 */
@Column(name = "task_merchant_id") @Column(name = "task_merchant_id")
private String taskMerchantId; private String taskMerchantId;
/** 带教门店名称。 */
@Column(name = "task_merchant_name") @Column(name = "task_merchant_name")
private String taskMerchantName; private String taskMerchantName;
/** 需带教人员姓名列表,使用JSON数组字符串保存。 */
@Column(name = "task_staff_list") @Column(name = "task_staff_list")
private String taskStaffList; private String taskStaffList;
/** 推送课程ID。 */
@Column(name = "push_courses_id")
private String pushCoursesId;
/** 推送课程名称。 */
@Column(name = "push_courses_name")
private String pushCoursesName;
/** 带教内容摘要。 */
@Column(name = "assignee_detail")
private String assigneeDetail;
/** 带教照片佐证URL列表,使用JSON数组字符串保存。 */
@Column(name = "assignee_images")
private String assigneeImages;
/** 创建人。 */
@Column(name = "created_by") @Column(name = "created_by")
private String createdBy; private String createdBy;
/** 创建时间。 */
@Column(name = "created_date") @Column(name = "created_date")
private Date createdDate; private Date createdDate;
/** 最后修改人。 */
@Column(name = "updated_by") @Column(name = "updated_by")
private String updatedBy; private String updatedBy;
/** 最后修改时间。 */
@Column(name = "updated_date") @Column(name = "updated_date")
private Date updatedDate; private Date updatedDate;
/** 删除标识:N-未删除,D-已删除。 */
@Column(name = "deleted_flag") @Column(name = "deleted_flag")
private String deletedFlag; private String deletedFlag;
} }
package cn.com.glsx.dj.staff.converter; package cn.com.glsx.dj.staff.converter;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoDTO; import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoDTO;
import cn.com.glsx.dj.staff.dto.taskcenter.TaskInfoSubmitDTO;
import cn.com.glsx.dj.staff.model.TaskInfo; import cn.com.glsx.dj.staff.model.TaskInfo;
import cn.com.glsx.dj.staff.model.TaskStaffRel; import cn.com.glsx.dj.staff.model.TaskStaffRel;
import cn.com.glsx.dj.staff.model.TaskSupervisorCoach; import cn.com.glsx.dj.staff.model.TaskSupervisorCoach;
...@@ -47,6 +48,10 @@ public interface TaskSupervisorCoachConvert { ...@@ -47,6 +48,10 @@ public interface TaskSupervisorCoachConvert {
@Mapping(target = "taskMerchantId", expression = "java(contextValueOrDefault(context, taskInfo.getStoreId(), \"taskMerchantId\", \"task_merchant_id\", \"merchantId\", \"merchant_id\"))"), @Mapping(target = "taskMerchantId", expression = "java(contextValueOrDefault(context, taskInfo.getStoreId(), \"taskMerchantId\", \"task_merchant_id\", \"merchantId\", \"merchant_id\"))"),
@Mapping(target = "taskMerchantName", expression = "java(contextValueOrDefault(context, taskInfo.getStoreName(), \"taskMerchantName\", \"task_merchant_name\", \"merchantName\", \"merchant_name\"))"), @Mapping(target = "taskMerchantName", expression = "java(contextValueOrDefault(context, taskInfo.getStoreName(), \"taskMerchantName\", \"task_merchant_name\", \"merchantName\", \"merchant_name\"))"),
@Mapping(target = "taskStaffList", expression = "java(staffNameJson(staffList))"), @Mapping(target = "taskStaffList", expression = "java(staffNameJson(staffList))"),
@Mapping(target = "pushCoursesId", ignore = true),
@Mapping(target = "pushCoursesName", ignore = true),
@Mapping(target = "assigneeDetail", ignore = true),
@Mapping(target = "assigneeImages", ignore = true),
@Mapping(target = "createdBy", constant = "system"), @Mapping(target = "createdBy", constant = "system"),
@Mapping(source = "taskInfo.createdDate", target = "createdDate"), @Mapping(source = "taskInfo.createdDate", target = "createdDate"),
@Mapping(target = "updatedBy", constant = "system"), @Mapping(target = "updatedBy", constant = "system"),
...@@ -58,6 +63,7 @@ public interface TaskSupervisorCoachConvert { ...@@ -58,6 +63,7 @@ public interface TaskSupervisorCoachConvert {
@Mappings({ @Mappings({
@Mapping(source = "taskStaffList", target = "taskStaffList", qualifiedByName = "jsonToStringList"), @Mapping(source = "taskStaffList", target = "taskStaffList", qualifiedByName = "jsonToStringList"),
@Mapping(source = "assigneeImages", target = "assigneeImages", qualifiedByName = "jsonToStringList"),
@Mapping(target = "id", ignore = true), @Mapping(target = "id", ignore = true),
@Mapping(target = "taskCenterId", ignore = true), @Mapping(target = "taskCenterId", ignore = true),
@Mapping(target = "createdDate", ignore = true) @Mapping(target = "createdDate", ignore = true)
...@@ -65,6 +71,37 @@ public interface TaskSupervisorCoachConvert { ...@@ -65,6 +71,37 @@ public interface TaskSupervisorCoachConvert {
void updateTaskInfo(TaskSupervisorCoach source, @MappingTarget TaskInfoDTO target); void updateTaskInfo(TaskSupervisorCoach source, @MappingTarget TaskInfoDTO target);
/** /**
* 将督导带教提交参数更新到扩展记录。
*/
@Mappings({
@Mapping(source = "assigneeDetail", target = "assigneeDetail"),
@Mapping(source = "assigneeImages", target = "assigneeImages", qualifiedByName = "stringListToJson"),
@Mapping(source = "pushCoursesId", target = "pushCoursesId"),
@Mapping(source = "pushCoursesName", target = "pushCoursesName"),
@Mapping(source = "teachingTime", target = "teachingTime", qualifiedByName = "stringToDate"),
@Mapping(target = "id", ignore = true),
@Mapping(target = "taskId", ignore = true),
@Mapping(target = "taskCenterId", ignore = true),
@Mapping(target = "teachingTarget", ignore = true),
@Mapping(target = "taskMerchantId", ignore = true),
@Mapping(target = "taskMerchantName", ignore = true),
@Mapping(target = "taskStaffList", ignore = true),
@Mapping(target = "createdBy", ignore = true),
@Mapping(target = "createdDate", ignore = true),
@Mapping(target = "updatedDate", ignore = true),
@Mapping(target = "deletedFlag", ignore = true)
})
void updateSupervisorCoachResult(TaskInfoSubmitDTO source, @MappingTarget TaskSupervisorCoach target);
/**
* 将提交的照片URL列表转换为扩展表保存的JSON数组字符串。
*/
@Named("stringListToJson")
default String stringListToJson(List<String> list) {
return list == null ? null : JSONUtil.toJsonStr(list);
}
/**
* 将扩展表保存的人员姓名JSON数组转换为详情接口的字符串列表。 * 将扩展表保存的人员姓名JSON数组转换为详情接口的字符串列表。
*/ */
@Named("jsonToStringList") @Named("jsonToStringList")
...@@ -80,6 +117,21 @@ public interface TaskSupervisorCoachConvert { ...@@ -80,6 +117,21 @@ public interface TaskSupervisorCoachConvert {
} }
/** /**
* 将提交的带教时间转换为Date,未传或格式错误时不更新原带教时间。
*/
@Named("stringToDate")
default Date stringToDate(String value) {
if (StringUtils.isBlank(value)) {
return null;
}
try {
return DateUtil.parse(value);
} catch (Exception ignored) {
return null;
}
}
/**
* 按给定fieldId顺序读取第一个非空的bizContext字段值。 * 按给定fieldId顺序读取第一个非空的bizContext字段值。
*/ */
default String contextValue(Map<String, String> context, String... keys) { default String contextValue(Map<String, String> context, String... keys) {
......
...@@ -44,6 +44,12 @@ public interface TaskInfoMapper { ...@@ -44,6 +44,12 @@ public interface TaskInfoMapper {
@Param("updatedBy") String updatedBy); @Param("updatedBy") String updatedBy);
/** /**
* 完成不使用reply_content的事项(更新reply_time、status)。
*/
int completeTask(@Param("id") Long id,
@Param("updatedBy") String updatedBy);
/**
* 查询本地任务表最大创建时间 * 查询本地任务表最大创建时间
*/ */
Date getMaxCreatedDate(); Date getMaxCreatedDate();
...@@ -78,6 +84,11 @@ public interface TaskInfoMapper { ...@@ -78,6 +84,11 @@ public interface TaskInfoMapper {
int insertSupervisorCoach(TaskSupervisorCoach supervisorCoach); int insertSupervisorCoach(TaskSupervisorCoach supervisorCoach);
/** /**
* 更新督导专项带教执行结果。
*/
int updateSupervisorCoachResult(TaskSupervisorCoach supervisorCoach);
/**
* 根据task_center_id查询本地任务主键id * 根据task_center_id查询本地任务主键id
*/ */
Long getIdByTaskCenterId(@Param("taskCenterId") Long taskCenterId); Long getIdByTaskCenterId(@Param("taskCenterId") Long taskCenterId);
......
...@@ -165,6 +165,8 @@ public class TaskInfoService { ...@@ -165,6 +165,8 @@ public class TaskInfoService {
if (Integer.valueOf(2).equals(taskInfo.getStatus())) { if (Integer.valueOf(2).equals(taskInfo.getStatus())) {
throw new RpcServiceException("任务已逾期,无法提交"); throw new RpcServiceException("任务已逾期,无法提交");
} }
boolean supervisorCoachTask = SUPERVISOR_COACH_TASK_TYPE.equals(taskInfo.getTaskType());
String replyContent = supervisorCoachTask ? null : dto.getReplyContent();
// 2. 人员更换评估任务保存执行结果 // 2. 人员更换评估任务保存执行结果
TaskStaffReplaceResult replaceResult = null; TaskStaffReplaceResult replaceResult = null;
...@@ -176,8 +178,24 @@ public class TaskInfoService { ...@@ -176,8 +178,24 @@ public class TaskInfoService {
} }
} }
// 2.1 督导带教任务保存带教执行结果
TaskSupervisorCoach supervisorCoach = null;
if (supervisorCoachTask) {
supervisorCoach = taskInfoMapper.getSupervisorCoachByTaskId(taskInfo.getId());
if (supervisorCoach == null) {
throw new RpcServiceException("督导带教扩展信息不存在");
}
taskSupervisorCoachConvert.updateSupervisorCoachResult(dto, supervisorCoach);
int resultRows = taskInfoMapper.updateSupervisorCoachResult(supervisorCoach);
if (resultRows == 0) {
throw new RpcServiceException("督导带教执行结果保存失败");
}
}
// 3. 更新本地任务状态 // 3. 更新本地任务状态
int rows = taskInfoMapper.updateTaskReply(dto.getId(), dto.getReplyContent(), dto.getUpdatedBy()); int rows = supervisorCoachTask
? taskInfoMapper.completeTask(dto.getId(), dto.getUpdatedBy())
: taskInfoMapper.updateTaskReply(dto.getId(), replyContent, dto.getUpdatedBy());
if (rows == 0) { if (rows == 0) {
throw new RpcServiceException("任务已完成或任务更新失败"); throw new RpcServiceException("任务已完成或任务更新失败");
} }
...@@ -194,7 +212,8 @@ public class TaskInfoService { ...@@ -194,7 +212,8 @@ public class TaskInfoService {
} }
// 4.2 在现有业务上下文中覆盖本次执行结果字段 // 4.2 在现有业务上下文中覆盖本次执行结果字段
String updatedBizContext = buildUpdatedBizContext(existingBizContext, dto.getReplyContent(), replaceResult); String updatedBizContext = buildUpdatedBizContext(
existingBizContext, replyContent, replaceResult, supervisorCoach);
// 4.3 调用finishTaskAssignee接口,标记任务完成 // 4.3 调用finishTaskAssignee接口,标记任务完成
FinishTaskAssigneeRequest finishRequest = new FinishTaskAssigneeRequest(); FinishTaskAssigneeRequest finishRequest = new FinishTaskAssigneeRequest();
...@@ -202,6 +221,9 @@ public class TaskInfoService { ...@@ -202,6 +221,9 @@ public class TaskInfoService {
finishRequest.setAssigneeId(taskInfo.getAssignedToId()); finishRequest.setAssigneeId(taskInfo.getAssignedToId());
finishRequest.setUpdatedBy(dto.getUpdatedBy()); finishRequest.setUpdatedBy(dto.getUpdatedBy());
finishRequest.setBizContext(updatedBizContext); finishRequest.setBizContext(updatedBizContext);
if (supervisorCoach != null) {
finishRequest.setAssigneeDetail(buildSupervisorCoachAssigneeDetail(supervisorCoach));
}
RpcResponse<Boolean> finishResp = taskCenterRemote.finishTaskAssignee(finishRequest); RpcResponse<Boolean> finishResp = taskCenterRemote.finishTaskAssignee(finishRequest);
if (finishResp == null || !finishResp.isSuccess()) { if (finishResp == null || !finishResp.isSuccess()) {
...@@ -340,7 +362,8 @@ public class TaskInfoService { ...@@ -340,7 +362,8 @@ public class TaskInfoService {
* 格式:[{"fieldId":"xxx","fieldName":"xxx","fieldType":"text","fieldValue":"xxx","linkAlias":null}] * 格式:[{"fieldId":"xxx","fieldName":"xxx","fieldType":"text","fieldValue":"xxx","linkAlias":null}]
*/ */
private String buildUpdatedBizContext(String existingBizContext, String replyContent, private String buildUpdatedBizContext(String existingBizContext, String replyContent,
TaskStaffReplaceResult replaceResult) { TaskStaffReplaceResult replaceResult,
TaskSupervisorCoach supervisorCoach) {
JSONArray contextArray; JSONArray contextArray;
// 解析已有上下文,解析失败则新建 // 解析已有上下文,解析失败则新建
if (StringUtils.isNotBlank(existingBizContext)) { if (StringUtils.isNotBlank(existingBizContext)) {
...@@ -353,7 +376,12 @@ public class TaskInfoService { ...@@ -353,7 +376,12 @@ public class TaskInfoService {
} else { } else {
contextArray = new JSONArray(); contextArray = new JSONArray();
} }
upsertField(contextArray, buildField("reply_content", "专项任务回复", "textarea", replyContent, null)); if (supervisorCoach == null) {
upsertField(contextArray, buildField("reply_content", "专项任务回复", "textarea",
replyContent, null));
} else {
removeField(contextArray, "reply_content");
}
if (replaceResult != null) { if (replaceResult != null) {
upsertField(contextArray, buildField("replace_flag", "任务执行结果", "radio", upsertField(contextArray, buildField("replace_flag", "任务执行结果", "radio",
String.valueOf(replaceResult.getReplaceFlag()), null)); String.valueOf(replaceResult.getReplaceFlag()), null));
...@@ -382,9 +410,74 @@ public class TaskInfoService { ...@@ -382,9 +410,74 @@ public class TaskInfoService {
} }
} }
} }
if (supervisorCoach != null) {
appendSupervisorCoachContext(contextArray, supervisorCoach);
}
return contextArray.toString(); return contextArray.toString();
} }
/**
* 将督导带教执行结果写入任务中心bizContext,供任务详情回显。
*/
private void appendSupervisorCoachContext(JSONArray contextArray,
TaskSupervisorCoach supervisorCoach) {
// 执行摘要与照片佐证只写扩展表和task_assignee.assignee_detail,不写biz_context。
removeField(contextArray, "assigneeDetail");
removeField(contextArray, "assigneeImages");
upsertField(contextArray, buildField("teachingSceneCode", "带教场景编码", "text",
supervisorCoach.getTeachingSceneCode(), null));
upsertField(contextArray, buildField("teachingSceneName", "带教场景", "text",
supervisorCoach.getTeachingSceneName(), null));
upsertField(contextArray, buildField("teachingTime", "带教时间", "datetime",
supervisorCoach.getTeachingTime() == null ? null
: DateUtil.formatDateTime(supervisorCoach.getTeachingTime()), null));
upsertField(contextArray, buildField("teachingMethodCode", "带教方式编码", "text",
supervisorCoach.getTeachingMethodCode(), null));
upsertField(contextArray, buildField("teachingMethodName", "带教方式", "text",
supervisorCoach.getTeachingMethodName(), null));
upsertField(contextArray, buildField("teachingTopicCode", "带教主题编码", "text",
supervisorCoach.getTeachingTopicCode(), null));
upsertField(contextArray, buildField("teachingTopicName", "带教主题", "text",
supervisorCoach.getTeachingTopicName(), null));
upsertField(contextArray, buildField("teachingTarget", "带教目标", "text",
supervisorCoach.getTeachingTarget(), null));
upsertField(contextArray, buildField("taskMerchantId", "带教门店ID", "text",
supervisorCoach.getTaskMerchantId(), null));
upsertField(contextArray, buildField("taskMerchantName", "带教门店", "text",
supervisorCoach.getTaskMerchantName(), null));
upsertField(contextArray, buildField("taskStaffList", "需带教人员", "json",
supervisorCoach.getTaskStaffList(), null));
upsertField(contextArray, buildField("pushCoursesId", "推送课程ID", "text",
supervisorCoach.getPushCoursesId(), null));
upsertField(contextArray, buildField("pushCoursesName", "推送课程", "text",
supervisorCoach.getPushCoursesName(), null));
}
/**
* 构建任务中心task_assignee.assignee_detail保存的督导带教执行详情JSON。
*/
private String buildSupervisorCoachAssigneeDetail(TaskSupervisorCoach supervisorCoach) {
JSONObject detail = new JSONObject();
detail.set("teachingSceneCode", supervisorCoach.getTeachingSceneCode());
detail.set("teachingSceneName", supervisorCoach.getTeachingSceneName());
detail.set("teachingTime", supervisorCoach.getTeachingTime() == null ? null
: DateUtil.formatDateTime(supervisorCoach.getTeachingTime()));
detail.set("teachingMethodCode", supervisorCoach.getTeachingMethodCode());
detail.set("teachingMethodName", supervisorCoach.getTeachingMethodName());
detail.set("teachingTopicCode", supervisorCoach.getTeachingTopicCode());
detail.set("teachingTopicName", supervisorCoach.getTeachingTopicName());
detail.set("assigneeDetail", supervisorCoach.getAssigneeDetail());
detail.set("taskMerchantId", supervisorCoach.getTaskMerchantId());
detail.set("taskMerchantName", supervisorCoach.getTaskMerchantName());
detail.set("taskStaffList", taskSupervisorCoachConvert.jsonToStringList(
supervisorCoach.getTaskStaffList()));
detail.set("assigneeImages", taskSupervisorCoachConvert.jsonToStringList(
supervisorCoach.getAssigneeImages()));
detail.set("pushCoursesId", supervisorCoach.getPushCoursesId());
detail.set("pushCoursesName", supervisorCoach.getPushCoursesName());
return detail.toString();
}
private void upsertField(JSONArray contextArray, JSONObject newField) { private void upsertField(JSONArray contextArray, JSONObject newField) {
String fieldId = newField.getStr("fieldId"); String fieldId = newField.getStr("fieldId");
for (int i = 0; i < contextArray.size(); i++) { for (int i = 0; i < contextArray.size(); i++) {
...@@ -397,4 +490,14 @@ public class TaskInfoService { ...@@ -397,4 +490,14 @@ public class TaskInfoService {
} }
contextArray.add(newField); contextArray.add(newField);
} }
private void removeField(JSONArray contextArray, String fieldId) {
for (int i = contextArray.size() - 1; i >= 0; i--) {
Object item = contextArray.get(i);
if (item instanceof JSONObject
&& fieldId.equals(((JSONObject) item).getStr("fieldId"))) {
contextArray.remove(i);
}
}
}
} }
...@@ -45,6 +45,10 @@ ...@@ -45,6 +45,10 @@
<result column="task_merchant_id" property="taskMerchantId" jdbcType="VARCHAR"/> <result column="task_merchant_id" property="taskMerchantId" jdbcType="VARCHAR"/>
<result column="task_merchant_name" property="taskMerchantName" jdbcType="VARCHAR"/> <result column="task_merchant_name" property="taskMerchantName" jdbcType="VARCHAR"/>
<result column="task_staff_list" property="taskStaffList" jdbcType="LONGVARCHAR"/> <result column="task_staff_list" property="taskStaffList" jdbcType="LONGVARCHAR"/>
<result column="push_courses_id" property="pushCoursesId" jdbcType="VARCHAR"/>
<result column="push_courses_name" property="pushCoursesName" jdbcType="VARCHAR"/>
<result column="assignee_detail" property="assigneeDetail" jdbcType="LONGVARCHAR"/>
<result column="assignee_images" property="assigneeImages" jdbcType="LONGVARCHAR"/>
<result column="created_by" property="createdBy" jdbcType="VARCHAR"/> <result column="created_by" property="createdBy" jdbcType="VARCHAR"/>
<result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/> <result column="created_date" property="createdDate" jdbcType="TIMESTAMP"/>
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/> <result column="updated_by" property="updatedBy" jdbcType="VARCHAR"/>
...@@ -150,6 +154,17 @@ ...@@ -150,6 +154,17 @@
WHERE id = #{id} AND status = 0 AND deleted_flag = 'N' WHERE id = #{id} AND status = 0 AND deleted_flag = 'N'
</update> </update>
<!-- 完成不使用reply_content的事项 -->
<update id="completeTask">
UPDATE dj_car_life_task_info
SET reply_content = NULL,
reply_time = NOW(),
status = 1,
updated_by = #{updatedBy},
updated_date = NOW()
WHERE id = #{id} AND status = 0 AND deleted_flag = 'N'
</update>
<!-- 查询本地任务表最大创建时间 --> <!-- 查询本地任务表最大创建时间 -->
<select id="getMaxCreatedDate" resultType="java.util.Date"> <select id="getMaxCreatedDate" resultType="java.util.Date">
SELECT MAX(created_date) FROM dj_car_life_task_info WHERE deleted_flag = 'N' SELECT MAX(created_date) FROM dj_car_life_task_info WHERE deleted_flag = 'N'
...@@ -214,6 +229,8 @@ ...@@ -214,6 +229,8 @@
teaching_method_code, teaching_method_name, teaching_method_code, teaching_method_name,
teaching_topic_code, teaching_topic_name, teaching_target, teaching_topic_code, teaching_topic_name, teaching_target,
task_merchant_id, task_merchant_name, task_staff_list, task_merchant_id, task_merchant_name, task_staff_list,
push_courses_id, push_courses_name,
assignee_detail, assignee_images,
created_by, created_date, updated_by, updated_date, deleted_flag) created_by, created_date, updated_by, updated_date, deleted_flag)
VALUES VALUES
(#{taskId}, #{taskCenterId}, (#{taskId}, #{taskCenterId},
...@@ -221,9 +238,33 @@ ...@@ -221,9 +238,33 @@
#{teachingMethodCode}, #{teachingMethodName}, #{teachingMethodCode}, #{teachingMethodName},
#{teachingTopicCode}, #{teachingTopicName}, #{teachingTarget}, #{teachingTopicCode}, #{teachingTopicName}, #{teachingTarget},
#{taskMerchantId}, #{taskMerchantName}, #{taskStaffList}, #{taskMerchantId}, #{taskMerchantName}, #{taskStaffList},
#{pushCoursesId}, #{pushCoursesName},
#{assigneeDetail}, #{assigneeImages},
#{createdBy}, #{createdDate}, #{updatedBy}, NOW(), #{deletedFlag}) #{createdBy}, #{createdDate}, #{updatedBy}, NOW(), #{deletedFlag})
</insert> </insert>
<!-- 更新督导专项带教执行结果 -->
<update id="updateSupervisorCoachResult"
parameterType="cn.com.glsx.dj.staff.model.TaskSupervisorCoach">
UPDATE dj_car_life_task_supervisor_coach
<set>
<if test="teachingSceneCode != null">teaching_scene_code = #{teachingSceneCode},</if>
<if test="teachingSceneName != null">teaching_scene_name = #{teachingSceneName},</if>
<if test="teachingTime != null">teaching_time = #{teachingTime},</if>
<if test="teachingMethodCode != null">teaching_method_code = #{teachingMethodCode},</if>
<if test="teachingMethodName != null">teaching_method_name = #{teachingMethodName},</if>
<if test="teachingTopicCode != null">teaching_topic_code = #{teachingTopicCode},</if>
<if test="teachingTopicName != null">teaching_topic_name = #{teachingTopicName},</if>
push_courses_id = #{pushCoursesId},
push_courses_name = #{pushCoursesName},
assignee_detail = #{assigneeDetail},
assignee_images = #{assigneeImages},
updated_by = #{updatedBy},
updated_date = NOW()
</set>
WHERE task_id = #{taskId} AND deleted_flag = 'N'
</update>
<!-- 根据task_center_id查询本地任务主键id --> <!-- 根据task_center_id查询本地任务主键id -->
<select id="getIdByTaskCenterId" resultType="java.lang.Long"> <select id="getIdByTaskCenterId" resultType="java.lang.Long">
SELECT id FROM dj_car_life_task_info SELECT id FROM dj_car_life_task_info
...@@ -237,7 +278,8 @@ ...@@ -237,7 +278,8 @@
teaching_method_code, teaching_method_name, teaching_method_code, teaching_method_name,
teaching_topic_code, teaching_topic_name, teaching_target, teaching_topic_code, teaching_topic_name, teaching_target,
task_merchant_id, task_merchant_name, task_merchant_id, task_merchant_name,
task_staff_list, task_staff_list, push_courses_id, push_courses_name,
assignee_detail, assignee_images,
created_by, created_date, updated_by, updated_date, deleted_flag created_by, created_date, updated_by, updated_date, deleted_flag
FROM dj_car_life_task_supervisor_coach FROM dj_car_life_task_supervisor_coach
WHERE task_id = #{taskId} AND deleted_flag = 'N' WHERE task_id = #{taskId} AND deleted_flag = 'N'
......
  • @wangxw1
    commented
    Master

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

    1. 危险的 RPC 接口参数变更(严重风险)

    • 问题描述:在 TaskInfoSubmitDTO.java 中,移除了原有字段(如 id, replyContent, replaceFlag 等)的 JSR-303 校验注解(@NotNull, @NotBlank, @Min 等)。
    • 影响分析:触发了“dubbo服务提供者Remote接口中的已有请求参数变更视为危险实现”的规则。直接移除原有参数的校验注解会导致上游调用方传入非法数据(如 id 为空)时,直接穿透到服务层,极易引发 NullPointerException 或导致脏数据入库。即便业务上某些字段(如 replyContent)在特定任务类型下不再必填,也不应采取一刀切删除注解的方式。
    • 优化建议: 恢复全局必填字段(如 id)的 @NotNull 注解。对于根据任务类型动态必填的字段,建议在 TaskInfoService 的业务逻辑中进行编程式校验,或者使用 JSR-303 的 @Validated(Group.class) 分组校验。

    2. 核心业务逻辑缺失对非督导带教任务的空值校验(逻辑漏洞)

    • 问题描述:在 TaskInfoService.java 的 submitTask 方法中,由于 DTO 移除了 replyContent 的 @NotBlank 校验,当处理非督导带教任务(supervisorCoachTask == false)时,未对 dto.getReplyContent() 进行判空。
    • 影响分析:如果前端/调用方对普通任务传入了空的 replyContent,代码会将其直接传给 taskInfoMapper.updateTaskReply。这不仅破坏了原有“专项任务回复不能为空”的业务规则,还可能因数据库字段约束(若为 NOT NULL)导致 SQL 异常。
    • 优化建议: 在 TaskInfoService.java 第 168 行后增加显式的逻辑校验: java if (!supervisorCoachTask && StringUtils.isBlank(dto.getReplyContent())) { throw new RpcServiceException("专项任务回复不能为空"); }

    3. MyBatis 更新语句存在可选字段全量覆盖风险(数据丢失隐患)

    • 问题描述:在 TaskInfoMapper.xml 的 updateSupervisorCoachResult 方法中,push_courses_id、assignee_detail 等字段未被 <if test="... != null"> 标签包裹。
    • 影响分析:根据 TaskInfoSubmitDTO 的注释,pushCoursesId 等字段为“选填”。如果在某次更新操作中,前端未传递这些选填参数(值为 null),该 SQL 会将数据库中原有的值直接更新为 NULL,导致历史数据被意外清空。
    • 优化建议: 在 XML 中为这些选填字段添加 <if> 判断,确保仅在非空时更新(除非业务明确要求支持置空操作): xml <if test="pushCoursesId != null">push_courses_id = #{pushCoursesId},</if> <if test="pushCoursesName != null">push_courses_name = #{pushCoursesName},</if> <if test="assigneeDetail != null">assignee_detail = #{assigneeDetail},</if> <if test="assigneeImages != null">assignee_images = #{assigneeImages},</if>

    二、评分明细

    • 功能实现的正确性与健壮性(30/40分):督导带教的核心流转逻辑和上下文 JSON 组装逻辑基本正确,removeField 采用倒序遍历避免了并发修改异常,值得肯定。但因为移除了基础的参数校验,且未在 Service 层补齐,导致系统面对异常入参时健壮性大幅下降。
    • 安全性与潜在风险(20/30分):未发现 SQL 注入或越权风险(MyBatis 均合规使用 #{},且无子查询)。但 RPC 暴露的 DTO 移除了基础校验,属于危险变更,增加了系统被脏数据攻击或引发内部异常的风险。
    • 最佳实践与可维护性(16/20分):MapStruct 的使用较为规范,代码结构清晰。扣分点在于 TaskSupervisorCoachConvert.java 中的 stringToDate 方法直接捕获了顶层的 Exception,建议捕获具体的解析异常;且 DTO 校验规则的破坏不利于后续维护。
    • 性能与资源利用(5/5分):JSON 转换与解析均使用了常规工具类,无明显性能瓶颈,数据库更新与插入操作索引命中预期良好。
    • 提交信息质量(4/5分):Commit 信息 feat: 事项-督导带教提交逻辑 能够概括本次核心功能,但未能体现出对已有 DTO 校验规则的破坏性修改,缺乏警示作用。

    总分:75分

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