Commit f1621551 by 范富荣

督导-周报:新增提报优秀案例,带教要求任务类型生成逻辑

1 parent 5a74bbc4
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 周任务状态变更请求DTO
* 用于优秀案例录音、带教要求两类周任务的完成状态判定
*/
@Data
@ToString
public class WeeklyTaskStatusReqDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 任务类型(6-优秀案例录音,7-带教要求)
*/
@NotNull(message = "任务类型不能为空")
@ApiModelProperty(notes = "任务类型(6-优秀案例录音,7-带教要求)", required = true)
private Integer taskType;
/**
* 创建日期,用于推算所属周的起止日期(格式:yyyy-MM-dd)
*/
@NotBlank(message = "创建日期不能为空")
@ApiModelProperty(notes = "创建日期,格式yyyy-MM-dd", required = true)
private String createDate;
/**
* 督导UUID
*/
@NotBlank(message = "督导UUID不能为空")
@ApiModelProperty(notes = "督导UUID", required = true)
private String supervisorUuid;
}
...@@ -4,7 +4,7 @@ import lombok.AllArgsConstructor; ...@@ -4,7 +4,7 @@ import lombok.AllArgsConstructor;
import lombok.Getter; import lombok.Getter;
/** /**
* 日报类型 0-日报 1-周报,2-月报, 3-录音, 4-专项 * 日报类型 0-日报 1-周报,2-月报, 3-录音, 4-专项, 5-带教, 6-优秀案例录音, 7-带教要求
*/ */
@Getter @Getter
@AllArgsConstructor @AllArgsConstructor
...@@ -26,7 +26,13 @@ public enum TaskTypeEnum { ...@@ -26,7 +26,13 @@ public enum TaskTypeEnum {
SPECIAL_RECORDING(4, "专项"), SPECIAL_RECORDING(4, "专项"),
/** 带教 */ /** 带教 */
TRAINING(5, "带教"); TRAINING(5, "带教"),
/** 优秀案例录音 */
EXCELLENT_CASE_AUDIO(6, "优秀案例录音"),
/** 带教要求 */
COACHING_REQUIREMENT(7, "带教要求");
private Integer code; private Integer code;
......
...@@ -154,4 +154,16 @@ public interface SupervisorTaskInfoRemote { ...@@ -154,4 +154,16 @@ public interface SupervisorTaskInfoRemote {
@ApiParams({@ApiParam(name = "request", notes = "专项任务信息(门店ID、门店名称、任务描述、督导手机号、督导姓名、创建人)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)}) @ApiParams({@ApiParam(name = "request", notes = "专项任务信息(门店ID、门店名称、任务描述、督导手机号、督导姓名、创建人)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("新增结果(任务ID)") @ApiResponse("新增结果(任务ID)")
RpcResponse<Long> createSpecialTask(CreateSpecialTaskDTO request); RpcResponse<Long> createSpecialTask(CreateSpecialTaskDTO request);
/**
* 更新周任务状态(优秀案例录音/带教要求)
* <p>
* 根据任务类型、创建日期(推算所属周)和督导UUID查询任务,
* 判断该任务对应的完成指标是否达标,并更新任务状态。
* </p>
*/
@ApiMethod("更新周任务状态")
@ApiParams({@ApiParam(name = "request", notes = "请求参数(任务类型、创建日期、督导UUID)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("任务ID")
RpcResponse<Long> updateWeeklyTaskStatus(WeeklyTaskStatusReqDTO request);
} }
\ No newline at end of file \ No newline at end of file
...@@ -14,12 +14,12 @@ import org.springframework.stereotype.Service; ...@@ -14,12 +14,12 @@ import org.springframework.stereotype.Service;
import java.util.Date; import java.util.Date;
/** /**
* 督导周报任务定时生成任务 * 督导周任务定时生成任务(优秀案例录音 + 带教要求)
* 每周一凌晨1点5分0秒开始执行 * 每周一凌晨1点5分0秒开始执行
* *
*/ */
@Service @Service
@ElasticJobConf(name = "SupervisorWeekTaskJob", cron = "0 5 1 ? * 1", description = "督导周报任务定时生成任务", overwrite = true) @ElasticJobConf(name = "SupervisorWeekTaskJob", cron = "0 5 1 ? * 1", description = "督导周任务定时生成任务(优秀案例录音+带教要求)", overwrite = true)
@Slf4j @Slf4j
public class SupervisorWeekTaskJob implements SimpleJob { public class SupervisorWeekTaskJob implements SimpleJob {
...@@ -29,7 +29,7 @@ public class SupervisorWeekTaskJob implements SimpleJob { ...@@ -29,7 +29,7 @@ public class SupervisorWeekTaskJob implements SimpleJob {
public void execute(ShardingContext shardingContext) { public void execute(ShardingContext shardingContext) {
try { try {
String dates = shardingContext.getJobParameter(); String dates = shardingContext.getJobParameter();
log.info("督导周报生成任务开始执行,入参: {}", dates); log.info("督导周任务生成任务开始执行,入参: {}", dates);
String startTimeStr = null; String startTimeStr = null;
String endTimeStr = null; String endTimeStr = null;
if (StringUtils.isBlank(dates)) { if (StringUtils.isBlank(dates)) {
...@@ -42,10 +42,17 @@ public class SupervisorWeekTaskJob implements SimpleJob { ...@@ -42,10 +42,17 @@ public class SupervisorWeekTaskJob implements SimpleJob {
startTimeStr = dateArray[0]; startTimeStr = dateArray[0];
endTimeStr = dateArray[1]; endTimeStr = dateArray[1];
} }
supervisorTaskInfoService.generateWeekTask(startTimeStr, endTimeStr); // 原周报生成逻辑,已注释保留
log.info("督导周报生成任务结束"); // supervisorTaskInfoService.generateWeekTask(startTimeStr, endTimeStr);
// 生成优秀案例录音任务
supervisorTaskInfoService.generateExcellentCaseAudioTask(startTimeStr, endTimeStr);
// 生成带教要求任务
supervisorTaskInfoService.generateCoachingRequirementTask(startTimeStr, endTimeStr);
log.info("督导周任务生成任务结束");
} catch (Exception e) { } catch (Exception e) {
log.error("督导周报生成定时任务执行异常 {}", e); log.error("督导周任务生成定时任务执行异常 {}", e);
} }
} }
} }
...@@ -81,4 +81,16 @@ public interface ExcellentCaseReviewMapper extends OreMapper<ExcellentCaseReview ...@@ -81,4 +81,16 @@ public interface ExcellentCaseReviewMapper extends OreMapper<ExcellentCaseReview
* @return 客户类型列表 * @return 客户类型列表
*/ */
List<String> queryAllCustomerTypes(); List<String> queryAllCustomerTypes();
/**
* 统计指定提交人在指定日期范围内提交的优秀案例数量
*
* @param submitterId 提交人ID(督导UUID)
* @param startDate 开始日期(yyyy-MM-dd)
* @param endDate 结束日期(yyyy-MM-dd)
* @return 提交数量
*/
int countBySubmitterAndDateRange(@Param("submitterId") String submitterId,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
} }
...@@ -68,4 +68,16 @@ public interface SupervisorTaskInfoMapper extends OreMapper<SupervisorTaskInfo> ...@@ -68,4 +68,16 @@ public interface SupervisorTaskInfoMapper extends OreMapper<SupervisorTaskInfo>
*/ */
List<SupervisorDirectorConfigDTO> queryDirectorConfigBySupervisorPhone(@Param("supervisorPhoneList") List<String> supervisorPhoneList); List<SupervisorDirectorConfigDTO> queryDirectorConfigBySupervisorPhone(@Param("supervisorPhoneList") List<String> supervisorPhoneList);
/**
* 统计指定督导在指定日期范围内完成的带教次数(task_type=5, task_status=2)
*
* @param supervisorUuid 督导UUID
* @param startDate 开始日期(yyyy-MM-dd)
* @param endDate 结束日期(yyyy-MM-dd)
* @return 带教完成次数
*/
int countCoachingBySupervisorAndDateRange(@Param("supervisorUuid") String supervisorUuid,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
} }
\ No newline at end of file \ No newline at end of file
...@@ -283,4 +283,20 @@ public class SupervisorTaskInfoRemoteImpl implements SupervisorTaskInfoRemote { ...@@ -283,4 +283,20 @@ public class SupervisorTaskInfoRemoteImpl implements SupervisorTaskInfoRemote {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
} }
} }
@Override
public RpcResponse<Long> updateWeeklyTaskStatus(WeeklyTaskStatusReqDTO request) {
try {
log.info("更新周任务状态 - 开始,request={}", request);
Long taskId = supervisorTaskInfoService.updateWeeklyTaskStatus(request);
log.info("更新周任务状态 - 完成,taskId={}", taskId);
return RpcResponse.success(taskId);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.updateWeeklyTaskStatus error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.updateWeeklyTaskStatus system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
} }
...@@ -10,6 +10,7 @@ import cn.com.glsx.dj.supervisor.enums.ReviewStatusEnum; ...@@ -10,6 +10,7 @@ import cn.com.glsx.dj.supervisor.enums.ReviewStatusEnum;
import cn.com.glsx.dj.supervisor.enums.TaskStatusEnum; import cn.com.glsx.dj.supervisor.enums.TaskStatusEnum;
import cn.com.glsx.dj.supervisor.enums.TaskTypeEnum; import cn.com.glsx.dj.supervisor.enums.TaskTypeEnum;
import cn.com.glsx.dj.supervisor.mapper.BusinessSceneMapper; import cn.com.glsx.dj.supervisor.mapper.BusinessSceneMapper;
import cn.com.glsx.dj.supervisor.mapper.ExcellentCaseReviewMapper;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskCourseMapper; import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskCourseMapper;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskImageMapper; import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskImageMapper;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskInfoMapper; import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskInfoMapper;
...@@ -100,6 +101,9 @@ public class SupervisorTaskInfoService { ...@@ -100,6 +101,9 @@ public class SupervisorTaskInfoService {
@Autowired @Autowired
private BusinessSceneMapper businessSceneMapper; private BusinessSceneMapper businessSceneMapper;
@Autowired
private ExcellentCaseReviewMapper excellentCaseReviewMapper;
/** /**
* 生成日报信息 * 生成日报信息
* @param startTimeStr 日报的开始时间,yyyy-MM-dd * @param startTimeStr 日报的开始时间,yyyy-MM-dd
...@@ -149,6 +153,24 @@ public class SupervisorTaskInfoService { ...@@ -149,6 +153,24 @@ public class SupervisorTaskInfoService {
generateTask(TaskTypeEnum.WEEKLY_REPORT.getCode(), startTimeStr, endTimeStr); generateTask(TaskTypeEnum.WEEKLY_REPORT.getCode(), startTimeStr, endTimeStr);
} }
/**
* 生成优秀案例录音任务
* @param startTimeStr 开始时间,yyyy-MM-dd
* @param endTimeStr 结束时间,yyyy-MM-dd
*/
public void generateExcellentCaseAudioTask(String startTimeStr, String endTimeStr) {
generateTask(TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode(), startTimeStr, endTimeStr);
}
/**
* 生成带教要求任务
* @param startTimeStr 开始时间,yyyy-MM-dd
* @param endTimeStr 结束时间,yyyy-MM-dd
*/
public void generateCoachingRequirementTask(String startTimeStr, String endTimeStr) {
generateTask(TaskTypeEnum.COACHING_REQUIREMENT.getCode(), startTimeStr, endTimeStr);
}
public void generateMonthTask(String startTimeStr, String endTimeStr) { public void generateMonthTask(String startTimeStr, String endTimeStr) {
generateTask(TaskTypeEnum.MONTHLY_REPORT.getCode(), startTimeStr, endTimeStr); generateTask(TaskTypeEnum.MONTHLY_REPORT.getCode(), startTimeStr, endTimeStr);
} }
...@@ -925,4 +947,83 @@ public class SupervisorTaskInfoService { ...@@ -925,4 +947,83 @@ public class SupervisorTaskInfoService {
return taskInfo.getId(); return taskInfo.getId();
} }
/**
* 更新周任务状态(优秀案例录音 / 带教要求)
* <p>
* 根据任务类型、创建日期推算所属周起止日期,查询对应的周任务记录,
* 再统计该周内相关记录条数,达到配置阈值即标记为已完成,否则标记为进行中。
* </p>
*
* @param request 请求参数(任务类型、创建日期、督导UUID)
* @return 任务ID,未找到任务时返回null
*/
public Long updateWeeklyTaskStatus(WeeklyTaskStatusReqDTO request) {
Integer taskType = request.getTaskType();
String createDate = request.getCreateDate();
String supervisorUuid = request.getSupervisorUuid();
// 根据创建日期推算所属周的起止日期
Date date = cn.com.glsx.framework.core.util.DateUtils.parseDate(createDate);
String weekStart = cn.com.glsx.framework.core.util.DateUtils.formatDate(
cn.com.glsx.dj.supervisor.utils.DateUtils.getMondayOfWeek(date));
String weekEnd = cn.com.glsx.framework.core.util.DateUtils.formatDate(
cn.com.glsx.dj.supervisor.utils.DateUtils.getSundayOfWeek(date));
// 查询该督导本周对应的周任务
SupervisorTaskInfo condition = new SupervisorTaskInfo();
condition.setTaskType(taskType);
condition.setStartDate(weekStart);
condition.setEndDate(weekEnd);
condition.setSupervisorUuid(supervisorUuid);
condition.setDeletedFlag("N");
SupervisorTaskInfo taskInfo = supervisorTaskInfoMapper.selectOne(condition);
if (taskInfo == null) {
log.warn("未找到对应周任务,taskType={}, weekStart={}, weekEnd={}, supervisorUuid={}",
taskType, weekStart, weekEnd, supervisorUuid);
return null;
}
log.info("查询到周任务,taskId={}, taskType={}, weekStart={}, weekEnd={}",
taskInfo.getId(), taskType, weekStart, weekEnd);
// 根据任务类型统计完成数量,并与阈值比较
int count = 0;
int limit = 0;
if (TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode().equals(taskType)) {
// 优秀案例录音:统计该督导本周提交的案例数量
count = excellentCaseReviewMapper.countBySubmitterAndDateRange(supervisorUuid, weekStart, weekEnd);
limit = env.getProperty("supervisor.weektask.excellentCaseLimit", Integer.class, 2);
log.info("优秀案例录音统计,count={}, limit={}", count, limit);
} else if (TaskTypeEnum.COACHING_REQUIREMENT.getCode().equals(taskType)) {
// 带教要求:统计该督导本周完成的带教次数(task_type=5 已完成)
count = supervisorTaskInfoMapper.countCoachingBySupervisorAndDateRange(supervisorUuid, weekStart, weekEnd);
limit = env.getProperty("supervisor.weektask.coachingRequirementLimit", Integer.class, 6);
log.info("带教要求统计,count={}, limit={}", count, limit);
} else {
log.warn("不支持的任务类型,taskType={}", taskType);
return taskInfo.getId();
}
// 判定并更新任务状态
Integer newStatus = count >= limit
? TaskStatusEnum.COMPLETED.getCode()
: TaskStatusEnum.IN_PROGRESS.getCode();
if (!newStatus.equals(taskInfo.getTaskStatus())) {
SupervisorTaskInfo update = new SupervisorTaskInfo();
update.setId(taskInfo.getId());
update.setTaskStatus(newStatus);
update.setUpdatedDate(new Date());
update.setUpdatedBy("system");
supervisorTaskInfoMapper.updateByPrimaryKeySelective(update);
log.info("周任务状态已更新,taskId={}, newStatus={}", taskInfo.getId(), newStatus);
} else {
log.info("周任务状态未变化,taskId={}, status={}", taskInfo.getId(), newStatus);
}
return taskInfo.getId();
}
} }
...@@ -218,4 +218,13 @@ ...@@ -218,4 +218,13 @@
order by customer_type order by customer_type
</select> </select>
<select id="countBySubmitterAndDateRange" resultType="int">
SELECT COUNT(*)
FROM excellent_case_review
WHERE deleted_flag = 'N'
AND submitter_id = #{submitterId}
AND CAST(create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
AND CAST(create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
...@@ -260,5 +260,15 @@ ...@@ -260,5 +260,15 @@
</foreach> </foreach>
</select> </select>
<select id="countCoachingBySupervisorAndDateRange" resultType="int">
SELECT COUNT(*)
FROM supervisor_task_info
WHERE deleted_flag = 'N'
AND task_type = 5
AND task_status = 2
AND supervisor_uuid = #{supervisorUuid}
AND CAST(create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
AND CAST(create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!