Commit 0d209d22 by 林冲

Merge remote-tracking branch 'origin/main' into v5.8.2

# Conflicts:
#	rpc-dj-supervisor-api/pom.xml
#	rpc-dj-supervisor-api/src/main/java/cn/com/glsx/dj/supervisor/remote/SupervisorTaskInfoRemote.java
#	rpc-dj-supervisor/pom.xml
#	rpc-dj-supervisor/src/main/java/cn/com/glsx/dj/supervisor/remote/SupervisorTaskInfoRemoteImpl.java
2 parents f6c859de c26767fa
Showing 60 changed files with 3230 additions and 160 deletions
...@@ -50,7 +50,7 @@ public class ExcellentCaseDetailDTO implements Serializable { ...@@ -50,7 +50,7 @@ public class ExcellentCaseDetailDTO implements Serializable {
@ApiModelProperty(notes = "接待时间") @ApiModelProperty(notes = "接待时间")
private String receptionTime; private String receptionTime;
@ApiModelProperty(notes = "接待状态") @ApiModelProperty(notes = "接待状态, 1.成交 0.战败")
private Integer receptionStatus; private Integer receptionStatus;
@ApiModelProperty(notes = "员工UUID") @ApiModelProperty(notes = "员工UUID")
......
...@@ -28,6 +28,18 @@ public class ExcellentCaseReviewQueryDTO implements Serializable { ...@@ -28,6 +28,18 @@ public class ExcellentCaseReviewQueryDTO implements Serializable {
@ApiModelProperty(notes = "审核状态:0-待审核,1-通过,2-驳回") @ApiModelProperty(notes = "审核状态:0-待审核,1-通过,2-驳回")
private Integer reviewStatus; private Integer reviewStatus;
@ApiModelProperty(notes = "任务ID(根据任务ID查询优秀案例时使用)")
private Long taskId;
@ApiModelProperty(notes = "提交人ID(督导UUID)")
private String submitterId;
@ApiModelProperty(notes = "开始日期,格式yyyy-MM-dd")
private String startDate;
@ApiModelProperty(notes = "结束日期,格式yyyy-MM-dd")
private String endDate;
@ApiModelProperty(notes = "页码") @ApiModelProperty(notes = "页码")
private Integer pageNum; private Integer pageNum;
......
...@@ -2,6 +2,9 @@ package cn.com.glsx.dj.supervisor.dto; ...@@ -2,6 +2,9 @@ package cn.com.glsx.dj.supervisor.dto;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskCourse; import cn.com.glsx.dj.supervisor.model.SupervisorTaskCourse;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskImage; import cn.com.glsx.dj.supervisor.model.SupervisorTaskImage;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskMerchant;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskParticipant;
import cn.com.glsx.dj.supervisor.model.SupervisorTeachingDetail;
import cn.com.glsx.dj.supervisor.model.SupervisorWeekTaskStaff; import cn.com.glsx.dj.supervisor.model.SupervisorWeekTaskStaff;
import cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemote; import cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemote;
import com.fasterxml.jackson.annotation.JsonFormat; import com.fasterxml.jackson.annotation.JsonFormat;
...@@ -85,6 +88,18 @@ public class SupervisorTaskDTO implements Serializable { ...@@ -85,6 +88,18 @@ public class SupervisorTaskDTO implements Serializable {
private Integer audioReviewCompletedCount; private Integer audioReviewCompletedCount;
/** /**
* 周任务完成标准(分母)
*/
@ApiModelProperty(notes = "周任务完成标准(分母)")
private Integer weeklyTaskTotalCount;
/**
* 周任务已完成数量(分子)
*/
@ApiModelProperty(notes = "周任务已完成数量(分子)")
private Integer weeklyTaskCompletedCount;
/**
* 创建时间 * 创建时间
*/ */
@ApiModelProperty(notes = "创建时间") @ApiModelProperty(notes = "创建时间")
...@@ -108,6 +123,11 @@ public class SupervisorTaskDTO implements Serializable { ...@@ -108,6 +123,11 @@ public class SupervisorTaskDTO implements Serializable {
private String startDate; private String startDate;
private String endDate;
@ApiModelProperty(notes = "督导UUID")
private String supervisorUuid;
/** /**
* 性别 * 性别
...@@ -135,4 +155,46 @@ public class SupervisorTaskDTO implements Serializable { ...@@ -135,4 +155,46 @@ public class SupervisorTaskDTO implements Serializable {
@ApiModelProperty(notes = "课程列表") @ApiModelProperty(notes = "课程列表")
private List<SupervisorTaskCourse> taskCourseList; private List<SupervisorTaskCourse> taskCourseList;
/**
* 后续工作事项
*/
@ApiModelProperty(notes = "后续工作事项")
private String nextWorkItems;
/**
* 需协助事项
*/
@ApiModelProperty(notes = "需协助事项")
private String needAssistItems;
/**
* 门店关联列表
*/
@ApiModelProperty(notes = "门店关联列表")
private List<SupervisorTaskMerchant> taskMerchantList;
/**
* 带教进度/结果
*/
@ApiModelProperty(notes = "带教进度/结果(1000字以内)")
private String teachingProgress;
/**
* 下月计划
*/
@ApiModelProperty(notes = "下月计划(1000字以内)")
private String nextMonthPlan;
/**
* 带教详情
*/
@ApiModelProperty(notes = "带教详情")
private SupervisorTeachingDetail teachingDetail;
/**
* 参与人员列表
*/
@ApiModelProperty(notes = "参与人员列表")
private List<SupervisorTaskParticipant> participantList;
} }
...@@ -6,6 +6,7 @@ import lombok.ToString; ...@@ -6,6 +6,7 @@ import lombok.ToString;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import java.util.Map;
@Data @Data
@ToString @ToString
...@@ -39,6 +40,9 @@ public class SupervisorTaskQueryDTO implements Serializable { ...@@ -39,6 +40,9 @@ public class SupervisorTaskQueryDTO implements Serializable {
@ApiModelProperty(notes = "督导管理的门店id列表") @ApiModelProperty(notes = "督导管理的门店id列表")
private List<Integer> merchantIdList; private List<Integer> merchantIdList;
@ApiModelProperty(notes = "按督导类型分组的门店id列表,key=督导类型(directorType), value=门店id列表")
private Map<Integer, List<Integer>> directorTypeMerchantMap;
@ApiModelProperty(notes = "督导管理的员工手机号列表") @ApiModelProperty(notes = "督导管理的员工手机号列表")
private List<String> staffPhoneList; private List<String> staffPhoneList;
......
package cn.com.glsx.dj.supervisor.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class SupervisorTeachingListDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "任务ID")
private Long id;
@ApiModelProperty(notes = "带教场景名称")
private String teachingSceneName;
@ApiModelProperty(notes = "带教时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
private Date teachingTime;
@ApiModelProperty(notes = "带教方式名称")
private String teachingMethodName;
@ApiModelProperty(notes = "带教主题名称")
private String teachingTopicName;
@ApiModelProperty(notes = "带教门店(多个以逗号分隔)")
private String merchantNames;
@ApiModelProperty(notes = "参与人员(多个以逗号分隔)")
private String participantNames;
}
package cn.com.glsx.dj.supervisor.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
@Data
@ToString
public class SupervisorTeamStaffDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "主键ID")
private Integer id;
@ApiModelProperty(notes = "驻店员工姓名")
private String staffName;
@ApiModelProperty(notes = "驻店员工手机号")
private String staffPhone;
@ApiModelProperty(notes = "招聘通道(1.校招,2.社招)")
private Integer hireType;
@ApiModelProperty(notes = "入职时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date entryTime;
@ApiModelProperty(notes = "职级类型(0:实习生(理论),1:实习生(实践),2:初级驻店,3:中级驻店,4:高级驻店,5:小店长,6:大店长,7:初级区域督导,8:中级区域督导,9:高级区域督导)")
private Integer jobType;
@ApiModelProperty(notes = "职称类型(1:导师)")
private Integer titleType;
@ApiModelProperty(notes = "员工业务标签(多个用逗号分隔,0:权益+延保,1:轻改)")
private String staffSceneLabel;
@ApiModelProperty(notes = "当前归属门店商户号")
private Integer merchantId;
@ApiModelProperty(notes = "当前归属门店商户名称")
private String merchantName;
@ApiModelProperty(notes = "服务门店商户号")
private Integer serviceMerchantId;
@ApiModelProperty(notes = "服务门店商户名称")
private String serviceMerchantName;
@ApiModelProperty(notes = "当前归属园区店商户号")
private Integer yqMerchantId;
@ApiModelProperty(notes = "当前归属园区店商户名称")
private String yqMerchantName;
@ApiModelProperty(notes = "在职状态(0:在职,1:离职,2:待激活 3:已分配门店)")
private Integer workingStatus;
@ApiModelProperty(notes = "导师姓名")
private String mentorName;
@ApiModelProperty(notes = "导师手机号")
private String mentorPhone;
@ApiModelProperty(notes = "创建来源")
private Integer createdSource;
@ApiModelProperty(notes = "备注")
private String remark;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.List;
@Data
@ToString
public class SupervisorTeamStaffQueryDTO implements Serializable {
@ApiModelProperty(notes = "督导手机号")
private String supervisorPhone;
@ApiModelProperty(notes = "门店商户号列表")
private List<Integer> merchantIdList;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class UnfinishedTaskCountDTO implements Serializable {
@ApiModelProperty(notes = "每日任务未完成数量(日报、录音、带教)")
private Integer dailyCount;
@ApiModelProperty(notes = "每周任务未完成数量(优秀案例录音、带教要求)")
private Integer weeklyCount;
@ApiModelProperty(notes = "每月任务未完成数量(月报)")
private Integer monthlyCount;
@ApiModelProperty(notes = "专项任务未完成数量")
private Integer specialCount;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class UnfinishedTaskCountReqDTO implements Serializable {
@ApiModelProperty(notes = "督导手机号", required = true)
private String supervisorPhone;
@ApiModelProperty(notes = "开始日期(yyyy-MM-dd,可为空)")
private String startDate;
@ApiModelProperty(notes = "结束日期(yyyy-MM-dd,可为空)")
private String endDate;
}
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;
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 录音复盘统计(Mapper 查询用)
*/
@Data
public class WorkbenchAudioReviewStatDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long relationId;
private String supervisorName;
private String taskDate;
private Integer totalCount;
private Integer reviewedCount;
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 优秀案例提报统计
*/
@Data
public class WorkbenchExcellentCaseCountDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String submitterName;
/** 提交日期 yyyy-MM-dd */
private String submitDate;
private Integer count;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 工作台报表响应
*/
@Data
public class WorkbenchReportDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "报表类型:1-今日动态 2-本周概览 3-月度总览 4-专项督办")
private Integer reportType;
@ApiModelProperty(notes = "查询开始日期")
private String startDate;
@ApiModelProperty(notes = "查询结束日期")
private String endDate;
@ApiModelProperty(notes = "顶部统计数据")
private WorkbenchReportStatisticsDTO statistics;
@ApiModelProperty(notes = "督导任务数据列表")
private List<WorkbenchReportSupervisorItemDTO> supervisorList;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 工作台报表查询参数
*/
@Data
public class WorkbenchReportQueryDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "报表类型:1-今日动态 2-本周概览 3-月度总览 4-专项督办", required = true)
private Integer reportType;
@ApiModelProperty(notes = "开始日期 yyyy-MM-dd", required = true)
private String startDate;
@ApiModelProperty(notes = "结束日期 yyyy-MM-dd", required = true)
private String endDate;
@ApiModelProperty(notes = "督导姓名(模糊搜索,仅过滤列表,不影响顶部统计)")
private String supervisorName;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 工作台报表顶部统计
*/
@Data
public class WorkbenchReportStatisticsDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "完成人数")
private Integer completedCount;
@ApiModelProperty(notes = "部分完成人数(专项督办无此项)")
private Integer partialCompletedCount;
@ApiModelProperty(notes = "未完成人数")
private Integer unfinishedCount;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 工作台报表-督导任务数据卡片
*/
@Data
public class WorkbenchReportSupervisorItemDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "督导姓名")
private String supervisorName;
@ApiModelProperty(notes = "督导手机号")
private String supervisorPhone;
@ApiModelProperty(notes = "督导UUID")
private String supervisorUuid;
@ApiModelProperty(notes = "完成状态:0-未完成 1-部分完成 2-已完成")
private Integer completionStatus;
@ApiModelProperty(notes = "完成状态名称")
private String completionStatusName;
// ---------- 今日动态 ----------
@ApiModelProperty(notes = "战败复盘率(百分比,0-100)")
private Integer defeatReviewRate;
@ApiModelProperty(notes = "战败复盘是否完成(复盘率>50%)")
private Boolean defeatReviewCompleted;
@ApiModelProperty(notes = "线上带教次数")
private Integer onlineTeachingCount;
@ApiModelProperty(notes = "线下带教次数")
private Integer offlineTeachingCount;
@ApiModelProperty(notes = "日报状态:0-未提交 1-在岗 2-调休")
private Integer dailyReportStatus;
@ApiModelProperty(notes = "日报状态名称")
private String dailyReportStatusName;
@ApiModelProperty(notes = "日报任务ID(可跳转详情)")
private Long dailyReportTaskId;
@ApiModelProperty(notes = "日报是否可进入详情")
private Boolean dailyReportDetailEnabled;
// ---------- 周/月概览 ----------
@ApiModelProperty(notes = "日报提交进度,如 3/4")
private String dailyReportProgress;
@ApiModelProperty(notes = "日报任务是否完成")
private Boolean dailyReportTaskCompleted;
@ApiModelProperty(notes = "复盘任务进度,如 2/4")
private String reviewTaskProgress;
@ApiModelProperty(notes = "复盘任务是否完成")
private Boolean reviewTaskCompleted;
@ApiModelProperty(notes = "带教任务进度,如 4/6 或 2/3(月)")
private String teachingTaskProgress;
@ApiModelProperty(notes = "带教任务是否完成")
private Boolean teachingTaskCompleted;
@ApiModelProperty(notes = "优秀录音提报进度,如 0/2 或 1/3(月)")
private String excellentCaseProgress;
@ApiModelProperty(notes = "优秀录音提报是否完成")
private Boolean excellentCaseTaskCompleted;
// ---------- 月度总览 ----------
@ApiModelProperty(notes = "月报状态:0-未提交 1-已提交")
private Integer monthReportStatus;
@ApiModelProperty(notes = "月报状态名称")
private String monthReportStatusName;
@ApiModelProperty(notes = "月报任务ID(可跳转详情)")
private Long monthReportTaskId;
@ApiModelProperty(notes = "月报是否可进入详情")
private Boolean monthReportDetailEnabled;
// ---------- 专项督办 ----------
@ApiModelProperty(notes = "专项任务完成情况,如 0/2")
private String specialTaskProgress;
@ApiModelProperty(notes = "专项任务是否全部完成")
private Boolean specialTaskCompleted;
@ApiModelProperty(notes = "专项任务列表")
private List<WorkbenchSpecialTaskItemDTO> specialTaskList;
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 工作台报表任务行(Mapper 查询用)
*/
@Data
public class WorkbenchReportTaskRowDTO implements Serializable {
private static final long serialVersionUID = 1L;
private Long id;
private Integer taskType;
private Integer taskStatus;
private Integer onDutyFlag;
private String supervisorName;
private String supervisorPhone;
private String supervisorUuid;
private String merchantName;
private String taskDesc;
private String taskContext;
private Date createTime;
private Date updatedDate;
/** yyyy-MM-dd */
private String taskDate;
}
package cn.com.glsx.dj.supervisor.dto;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
/**
* 专项任务明细
*/
@Data
public class WorkbenchSpecialTaskItemDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "任务ID")
private Long taskId;
@ApiModelProperty(notes = "门店名称")
private String merchantName;
@ApiModelProperty(notes = "任务描述")
private String taskDesc;
@ApiModelProperty(notes = "督导记录")
private String taskContext;
@ApiModelProperty(notes = "任务状态 0-待完成 1-进行中 2-已完成")
private Integer taskStatus;
@ApiModelProperty(notes = "创建时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date createTime;
@ApiModelProperty(notes = "更新时间")
@JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
private Date updatedDate;
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
import java.io.Serializable;
/**
* 带教场景统计(Mapper 查询用)
*/
@Data
public class WorkbenchTeachingCountDTO implements Serializable {
private static final long serialVersionUID = 1L;
private String supervisorName;
/** 1-线上 2-线下 */
private String teachingSceneCode;
private Integer count;
}
...@@ -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;
......
package cn.com.glsx.dj.supervisor.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 工作台任务完成状态
*/
@Getter
@AllArgsConstructor
public enum WorkbenchCompletionStatusEnum {
/** 未完成 */
UNFINISHED(0, "未完成"),
/** 部分完成 */
PARTIAL(1, "部分完成"),
/** 已完成 */
COMPLETED(2, "已完成");
private final Integer code;
private final String name;
}
package cn.com.glsx.dj.supervisor.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 日报提交状态(今日动态展示)
*/
@Getter
@AllArgsConstructor
public enum WorkbenchDailyReportStatusEnum {
/** 未提交 */
NOT_SUBMITTED(0, "未提交"),
/** 在岗 */
ON_DUTY(1, "在岗"),
/** 调休 */
REST(2, "调休");
private final Integer code;
private final String name;
}
package cn.com.glsx.dj.supervisor.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 工作台报表类型
*/
@Getter
@AllArgsConstructor
public enum WorkbenchReportTypeEnum {
/** 今日动态 */
TODAY(1, "今日动态"),
/** 本周概览 */
WEEK(2, "本周概览"),
/** 月度总览 */
MONTH(3, "月度总览"),
/** 专项督办 */
SPECIAL(4, "专项督办");
private final Integer code;
private final String name;
public static WorkbenchReportTypeEnum of(Integer code) {
if (code == null) {
return null;
}
for (WorkbenchReportTypeEnum e : values()) {
if (e.code.equals(code)) {
return e;
}
}
return null;
}
}
package cn.com.glsx.dj.supervisor.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 带教场景枚举
*/
@Getter
@AllArgsConstructor
public enum WorkbenchSceneCodeEnum {
/** 线上 */
ONLINE("1", "线上"),
/** 线下 */
OFFLINE("2", "线下");
private final String code;
private final String name;
}
package cn.com.glsx.dj.supervisor.enums;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 提交状态
*/
@Getter
@AllArgsConstructor
public enum WorkbenchSubmitStatusEnum {
/** 未提交 */
NOT_SUBMITTED(0, "未提交"),
/** 已提交 */
SUBMITTED(1, "已提交");
private final Integer code;
private final String name;
}
...@@ -141,4 +141,28 @@ public class SupervisorTaskInfo implements Serializable { ...@@ -141,4 +141,28 @@ public class SupervisorTaskInfo implements Serializable {
*/ */
@Column(name = "task_context") @Column(name = "task_context")
private String taskContext; private String taskContext;
/**
* 后续工作事项
*/
@Column(name = "next_work_items")
private String nextWorkItems;
/**
* 需协助事项
*/
@Column(name = "need_assist_items")
private String needAssistItems;
/**
* 带教进度/结果
*/
@Column(name = "teaching_progress")
private String teachingProgress;
/**
* 下月计划
*/
@Column(name = "next_month_plan")
private String nextMonthPlan;
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.model;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Data
@ToString
@Table(name = "supervisor_task_merchant")
public class SupervisorTaskMerchant implements Serializable {
/**
* 主键ID(自增)
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 关联任务ID(supervisor_task_info.id)
*/
@Column(name = "relation_id")
private Long relationId;
/**
* 门店ID
*/
@ApiModelProperty(notes = "门店ID")
@Column(name = "merchant_id")
private Integer merchantId;
/**
* 门店名称
*/
@ApiModelProperty(notes = "门店名称")
@Column(name = "merchant_name")
private String merchantName;
/**
* 创建人姓名
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "create_time")
private Date createTime;
/**
* 更新人账户名称
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 更新时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@Column(name = "deleted_flag")
private String deletedFlag;
}
package cn.com.glsx.dj.supervisor.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
@ToString
@Data
@Table(name = "supervisor_task_participant")
public class SupervisorTaskParticipant implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@ApiModelProperty(notes = "关联任务ID(supervisor_task_info.id)")
@Column(name = "task_id")
private Long taskId;
@ApiModelProperty(notes = "参与人员手机号")
@Column(name = "participant_phone")
private String participantPhone;
@ApiModelProperty(notes = "参与人员姓名")
@Column(name = "participant_name")
private String participantName;
@Column(name = "created_by")
private String createdBy;
@Column(name = "create_time")
private Date createTime;
@Column(name = "updated_by")
private String updatedBy;
@Column(name = "updated_date")
private Date updatedDate;
@Column(name = "deleted_flag")
private String deletedFlag;
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.model;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import org.springframework.format.annotation.DateTimeFormat;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.*;
@Data
@ToString
@Table(name = "supervisor_teaching_detail")
public class SupervisorTeachingDetail implements Serializable {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
@Column(name = "task_id")
private Long taskId;
@ApiModelProperty(notes = "带教场景编码(字典:teaching_scene)")
@Column(name = "teaching_scene_code")
private String teachingSceneCode;
@ApiModelProperty(notes = "带教场景名称(线上/线下)")
@Column(name = "teaching_scene_name")
private String teachingSceneName;
@ApiModelProperty(notes = "带教方式编码(字典:teaching_method)")
@Column(name = "teaching_method_code")
private String teachingMethodCode;
@ApiModelProperty(notes = "带教方式名称")
@Column(name = "teaching_method_name")
private String teachingMethodName;
@ApiModelProperty(notes = "带教主题编码(字典:teaching_topic)")
@Column(name = "teaching_topic_code")
private String teachingTopicCode;
@ApiModelProperty(notes = "带教主题名称")
@Column(name = "teaching_topic_name")
private String teachingTopicName;
@ApiModelProperty(notes = "带教时间,yyyy-MM-dd HH:mm", required = true)
@JsonFormat(pattern = "yyyy-MM-dd HH:mm", timezone = "GMT+8")
@DateTimeFormat(pattern = "yyyy-MM-dd HH:mm")
@Column(name = "teaching_time")
private Date teachingTime;
}
...@@ -128,4 +128,17 @@ public interface ExcellentCaseReviewRemote { ...@@ -128,4 +128,17 @@ public interface ExcellentCaseReviewRemote {
@ApiMethod("查询所有客户类型") @ApiMethod("查询所有客户类型")
@ApiResponse("客户类型列表") @ApiResponse("客户类型列表")
RpcResponse<List<String>> queryAllCustomerTypes(); RpcResponse<List<String>> queryAllCustomerTypes();
/**
* 根据任务ID查询优秀案例列表(分页)
* <p>
* 根据任务ID查询任务详情,获取督导UUID和所属周起止日期,
* 再查询该督导在该周内提交的优秀案例列表
* </p>
*/
@interface QueryExcellentCaseListByTaskId {}
@ApiMethod("根据任务ID查询优秀案例列表")
@ApiParams({@ApiParam(name = "request", notes = "分页查询参数(需在condition中传入taskId)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("优秀案例分页列表")
RpcResponse<RpcPagination<ExcellentCaseDetailDTO>> queryExcellentCaseListByTaskId(RpcPagination<ExcellentCaseReviewQueryDTO> request);
} }
...@@ -158,6 +158,50 @@ public interface SupervisorTaskInfoRemote { ...@@ -158,6 +158,50 @@ public interface SupervisorTaskInfoRemote {
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);
/**
* 统计各任务类型未完成任务数量
*/
@ApiMethod("统计各任务类型未完成任务数量")
@ApiParams({@ApiParam(name = "request", notes = "查询参数(督导手机号、起止日期)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("各类型未完成任务数量")
RpcResponse<UnfinishedTaskCountDTO> getUnfinishedTaskCount(UnfinishedTaskCountReqDTO request);
/**
* 分页查询带教列表
*/
@ApiMethod("分页查询带教列表")
@ApiParams({@ApiParam(name = "request", notes = "查询参数", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("带教列表分页结果")
RpcResponse<RpcPagination<SupervisorTeachingListDTO>> pageTeachingRecords(RpcPagination<SupervisorTaskQueryDTO> request);
/**
* 工作台报表(今日动态/本周概览/月度总览/专项督办)
*/
@ApiMethod("工作台报表")
@ApiParams({@ApiParam(name = "request", notes = "查询参数(报表类型、起止日期、督导姓名)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("工作台报表数据")
RpcResponse<WorkbenchReportDTO> getWorkbenchReport(WorkbenchReportQueryDTO request);
/**
* 分页查询驻店基础信息
*/
@ApiMethod("分页查询驻店基础信息")
@ApiParams({@ApiParam(name = "request", notes = "查询参数(督导手机号、门店商户号列表)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("驻店基础信息分页列表")
RpcResponse<RpcPagination<SupervisorTeamStaffDTO>> pageStaffBaseInfo(RpcPagination<SupervisorTeamStaffQueryDTO> request);
/**
* 查询所有区域运营 * 查询所有区域运营
*/ */
@ApiMethod("查询所有区域运营") @ApiMethod("查询所有区域运营")
......
...@@ -68,12 +68,12 @@ ...@@ -68,12 +68,12 @@
<dependency> <dependency>
<groupId>cn.com.glsx.dj</groupId> <groupId>cn.com.glsx.dj</groupId>
<artifactId>rpc-dj-smartcarlife-api</artifactId> <artifactId>rpc-dj-smartcarlife-api</artifactId>
<version>5.7.0-SNAPSHOT</version> <version>5.8.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.dj.peanalysis</groupId> <groupId>cn.com.glsx.dj.peanalysis</groupId>
<artifactId>rpc-dj-pe-analysis-api</artifactId> <artifactId>rpc-dj-pe-analysis-api</artifactId>
<version>5.7.0-SNAPSHOT</version> <version>5.8.1-SNAPSHOT</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>org.junit.jupiter</groupId> <groupId>org.junit.jupiter</groupId>
......
...@@ -91,7 +91,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob { ...@@ -91,7 +91,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
// 2.1 查询督导管理的门店列表,参考CommonUtil.getFlightSupervisionMerchantList方法 // 2.1 查询督导管理的门店列表,参考CommonUtil.getFlightSupervisionMerchantList方法
ShopMerchantDirectorConfigDTO dto = new ShopMerchantDirectorConfigDTO(); ShopMerchantDirectorConfigDTO dto = new ShopMerchantDirectorConfigDTO();
dto.setDirectorUserId(supervisor.getUuid()); dto.setDirectorUserId(supervisor.getUuid());
dto.setDirectorTypes(Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())); dto.setDirectorTypes(Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue(), DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue()));
RpcResponse<List<ShopMerchantDirectorConfigDTO>> merchantResponse = shopMerchantDirectorConfigRemote.list(dto); RpcResponse<List<ShopMerchantDirectorConfigDTO>> merchantResponse = shopMerchantDirectorConfigRemote.list(dto);
log.info("请求参数:directorUserId:{},directorTypes:{}", dto.getDirectorUserId(), dto.getDirectorTypes()); log.info("请求参数:directorUserId:{},directorTypes:{}", dto.getDirectorUserId(), dto.getDirectorTypes());
List<Integer> merchantIdList = new ArrayList<>(); List<Integer> merchantIdList = new ArrayList<>();
...@@ -100,6 +100,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob { ...@@ -100,6 +100,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
if (CollectionUtils.isNotEmpty(merchantList)) { if (CollectionUtils.isNotEmpty(merchantList)) {
merchantIdList = merchantList.stream() merchantIdList = merchantList.stream()
.map(ShopMerchantDirectorConfigDTO::getMerchantId) .map(ShopMerchantDirectorConfigDTO::getMerchantId)
.distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
} }
...@@ -111,7 +112,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob { ...@@ -111,7 +112,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
StaffBaseInfoDTO staffParam = new StaffBaseInfoDTO(); StaffBaseInfoDTO staffParam = new StaffBaseInfoDTO();
staffParam.setMerchantIdList(merchantIdList); staffParam.setMerchantIdList(merchantIdList);
RpcResponse<List<StaffBaseInfoDTO>> staffResponse = staffBaseInfoRemote.listShopStaffInfoGroupByUUid(staffParam); RpcResponse<List<StaffBaseInfoDTO>> staffResponse = staffBaseInfoRemote.listShopStaffInfoGroupByUUid(staffParam);
log.info("请求参数:merchantIdList:{},返回参数:{}", merchantIdList, staffResponse); log.info("请求参数:merchantIdList:{},返回参数:{}", JSON.toJSONString(merchantIdList), JSON.toJSONString(staffResponse));
if (!staffResponse.isSuccess() || staffResponse.getResult() == null || staffResponse.getResult().isEmpty()) { if (!staffResponse.isSuccess() || staffResponse.getResult() == null || staffResponse.getResult().isEmpty()) {
log.info("督导{},手机号{} 无管理员工", supervisor.getStaffName(), supervisor.getStaffPhone()); log.info("督导{},手机号{} 无管理员工", supervisor.getStaffName(), supervisor.getStaffPhone());
continue; continue;
......
...@@ -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 0 ? * 2", 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,46 @@ public interface SupervisorTaskInfoMapper extends OreMapper<SupervisorTaskInfo> ...@@ -68,4 +68,46 @@ 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);
/**
* 按任务类型分组,统计未完成任务数量
*
* @param supervisorPhone 督导手机号
* @param taskTypes 任务类型列表
* @param startDate 开始日期(yyyy-MM-dd)
* @param endDate 结束日期(yyyy-MM-dd)
* @return 每条记录包含 taskType 和 count
*/
List<Map<String, Object>> countUnfinishedByTaskTypes(@Param("supervisorPhone") String supervisorPhone,
@Param("taskTypes") List<Integer> taskTypes,
@Param("startDate") String startDate,
@Param("endDate") String endDate);
/**
* 查询带教记录列表
*
* @param request 查询条件
* @return 带教记录列表
*/
List<SupervisorTeachingListDTO> listTeachingRecords(SupervisorTaskQueryDTO request);
/**
* 分页查询驻店基础信息
*
* @param request 查询条件(督导手机号、门店商户号列表)
* @return 驻店基础信息列表
*/
List<SupervisorTeamStaffDTO> listStaffBaseInfo(SupervisorTeamStaffQueryDTO request);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.mapper;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskMerchant;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface SupervisorTaskMerchantMapper extends OreMapper<SupervisorTaskMerchant> {
}
package cn.com.glsx.dj.supervisor.mapper;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskParticipant;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface SupervisorTaskParticipantMapper extends OreMapper<SupervisorTaskParticipant> {
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.mapper;
import cn.com.glsx.dj.supervisor.model.SupervisorTeachingDetail;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface SupervisorTeachingDetailMapper extends OreMapper<SupervisorTeachingDetail> {
}
package cn.com.glsx.dj.supervisor.mapper;
import cn.com.glsx.dj.supervisor.dto.WorkbenchAudioReviewStatDTO;
import cn.com.glsx.dj.supervisor.dto.WorkbenchExcellentCaseCountDTO;
import cn.com.glsx.dj.supervisor.dto.WorkbenchReportTaskRowDTO;
import cn.com.glsx.dj.supervisor.dto.WorkbenchTeachingCountDTO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import java.util.List;
@Mapper
public interface SupervisorWorkbenchReportMapper {
/**
* 按日期范围与任务类型查询任务
*/
List<WorkbenchReportTaskRowDTO> listTasksByDateRangeAndTypes(@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("taskTypes") List<Integer> taskTypes);
/**
* 统计带教场景(线上/线下)
*/
List<WorkbenchTeachingCountDTO> countTeachingByScene(@Param("startDate") String startDate,
@Param("endDate") String endDate);
/**
* 统计录音复盘(按任务维度)
*/
List<WorkbenchAudioReviewStatDTO> listAudioReviewStats(@Param("startDate") String startDate,
@Param("endDate") String endDate);
/**
* 统计优秀案例提报数量
*/
List<WorkbenchExcellentCaseCountDTO> countExcellentCaseGroupBySubmitterName(@Param("startDate") String startDate,
@Param("endDate") String endDate);
}
...@@ -221,4 +221,18 @@ public class ExcellentCaseReviewRemoteImpl implements ExcellentCaseReviewRemote ...@@ -221,4 +221,18 @@ public class ExcellentCaseReviewRemoteImpl implements ExcellentCaseReviewRemote
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
} }
} }
@Override
public RpcResponse<RpcPagination<ExcellentCaseDetailDTO>> queryExcellentCaseListByTaskId(RpcPagination<ExcellentCaseReviewQueryDTO> request) {
try {
Page<ExcellentCaseDetailDTO> result = excellentCaseReviewService.queryExcellentCaseListByTaskId(request);
return RpcResponse.success(RpcPagination.copyPage(result));
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.ExcellentCaseReviewRemoteImpl.queryExcellentCaseListByTaskId error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.ExcellentCaseReviewRemoteImpl.queryExcellentCaseListByTaskId system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
} }
...@@ -11,9 +11,12 @@ import cn.com.glsx.dj.supervisor.dto.SupervisorPageDTO; ...@@ -11,9 +11,12 @@ import cn.com.glsx.dj.supervisor.dto.SupervisorPageDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorPageQueryDTO; import cn.com.glsx.dj.supervisor.dto.SupervisorPageQueryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO; import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO; import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTeamStaffDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTeamStaffQueryDTO;
import cn.com.glsx.dj.supervisor.model.SupervisorAudioReviewInfo; import cn.com.glsx.dj.supervisor.model.SupervisorAudioReviewInfo;
import cn.com.glsx.dj.supervisor.service.SupervisorAudioReviewInfoService; import cn.com.glsx.dj.supervisor.service.SupervisorAudioReviewInfoService;
import cn.com.glsx.dj.supervisor.service.SupervisorTaskInfoService; import cn.com.glsx.dj.supervisor.service.SupervisorTaskInfoService;
import cn.com.glsx.dj.supervisor.service.SupervisorWorkbenchReportService;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
...@@ -35,6 +38,8 @@ public class SupervisorTaskInfoRemoteImpl implements SupervisorTaskInfoRemote { ...@@ -35,6 +38,8 @@ public class SupervisorTaskInfoRemoteImpl implements SupervisorTaskInfoRemote {
private SupervisorTaskInfoService supervisorTaskInfoService; private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired @Autowired
private SupervisorAudioReviewInfoService supervisorAudioReviewInfoService; private SupervisorAudioReviewInfoService supervisorAudioReviewInfoService;
@Autowired
private SupervisorWorkbenchReportService supervisorWorkbenchReportService;
@Override @Override
public RpcResponse<Boolean> submitDayTask(SupervisorTaskDTO request) { public RpcResponse<Boolean> submitDayTask(SupervisorTaskDTO request) {
...@@ -313,4 +318,83 @@ public class SupervisorTaskInfoRemoteImpl implements SupervisorTaskInfoRemote { ...@@ -313,4 +318,83 @@ 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());
}
}
@Override
public RpcResponse<UnfinishedTaskCountDTO> getUnfinishedTaskCount(UnfinishedTaskCountReqDTO request) {
try {
log.info("统计未完成任务数量 - 开始,request={}", request);
UnfinishedTaskCountDTO result = supervisorTaskInfoService.getUnfinishedTaskCount(request);
log.info("统计未完成任务数量 - 完成,result={}", result);
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getUnfinishedTaskCount error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getUnfinishedTaskCount system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<RpcPagination<SupervisorTeachingListDTO>> pageTeachingRecords(RpcPagination<SupervisorTaskQueryDTO> request) {
try {
log.info("分页查询带教列表 - 开始,request={}", request);
Page<SupervisorTeachingListDTO> result = supervisorTaskInfoService.pageTeachingRecords(request);
log.info("分页查询带教列表 - 完成,total={}", result.getTotal());
return RpcResponse.success(RpcPagination.copyPage(result));
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageTeachingRecords error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageTeachingRecords system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<WorkbenchReportDTO> getWorkbenchReport(WorkbenchReportQueryDTO request) {
try {
log.info("工作台报表 - 开始,request={}", request);
WorkbenchReportDTO result = supervisorWorkbenchReportService.getWorkbenchReport(request);
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getWorkbenchReport error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getWorkbenchReport system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<RpcPagination<SupervisorTeamStaffDTO>> pageStaffBaseInfo(RpcPagination<SupervisorTeamStaffQueryDTO> request) {
try {
log.info("分页查询驻店基础信息 - 开始,request={}", request);
Page<SupervisorTeamStaffDTO> result = supervisorTaskInfoService.pageStaffBaseInfo(request);
log.info("分页查询驻店基础信息 - 完成,total={}", result.getTotal());
return RpcResponse.success(RpcPagination.copyPage(result));
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageStaffBaseInfo error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageStaffBaseInfo system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
} }
package cn.com.glsx.dj.supervisor.service; package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.dto.ExcellentCaseDetailDTO; import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.dto.ExcellentCaseReviewQueryDTO;
import cn.com.glsx.dj.supervisor.dto.ExcellentCaseReviewReqDTO;
import cn.com.glsx.dj.supervisor.dto.ExcellentCaseSubmitDTO;
import cn.com.glsx.dj.supervisor.enums.ExcellentCaseReviewStatusEnum; import cn.com.glsx.dj.supervisor.enums.ExcellentCaseReviewStatusEnum;
import cn.com.glsx.dj.supervisor.enums.TaskTypeEnum;
import cn.com.glsx.dj.supervisor.mapper.ExcellentCaseReviewMapper; import cn.com.glsx.dj.supervisor.mapper.ExcellentCaseReviewMapper;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskInfoMapper;
import cn.com.glsx.dj.supervisor.model.ExcellentCaseReview; import cn.com.glsx.dj.supervisor.model.ExcellentCaseReview;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskInfo;
import cn.com.glsx.dj.supervisor.util.DateUtil;
import cn.com.glsx.framework.core.beans.BaseModel; import cn.com.glsx.framework.core.beans.BaseModel;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
...@@ -16,6 +17,7 @@ import com.github.pagehelper.Page; ...@@ -16,6 +17,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.http.client.utils.DateUtils;
import org.springframework.beans.BeanUtils; import org.springframework.beans.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
...@@ -41,6 +43,12 @@ public class ExcellentCaseReviewService { ...@@ -41,6 +43,12 @@ public class ExcellentCaseReviewService {
@Autowired @Autowired
private ExcellentCaseReviewMapper excellentCaseReviewMapper; private ExcellentCaseReviewMapper excellentCaseReviewMapper;
@Autowired
private SupervisorTaskInfoMapper supervisorTaskInfoMapper;
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
/** /**
* 提交优秀案例 * 提交优秀案例
* <p> * <p>
...@@ -106,6 +114,12 @@ public class ExcellentCaseReviewService { ...@@ -106,6 +114,12 @@ public class ExcellentCaseReviewService {
} }
log.info("提交优秀案例成功,案例ID:{}", existingCount.getId()); log.info("提交优秀案例成功,案例ID:{}", existingCount.getId());
} }
//更新周报:优秀案例状态:
WeeklyTaskStatusReqDTO param = new WeeklyTaskStatusReqDTO();
param.setTaskType(TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode());
param.setCreateDate(DateUtils.formatDate(new Date(), "yyyy-MM-dd"));
param.setSupervisorUuid(currentUserId);
supervisorTaskInfoService.updateWeeklyTaskStatus(param);
return true; return true;
} }
...@@ -323,4 +337,39 @@ public class ExcellentCaseReviewService { ...@@ -323,4 +337,39 @@ public class ExcellentCaseReviewService {
log.info("查询所有客户类型成功,数据条数:{}", types != null ? types.size() : 0); log.info("查询所有客户类型成功,数据条数:{}", types != null ? types.size() : 0);
return types; return types;
} }
/**
* 根据任务ID查询优秀案例列表(分页)
* <p>
* 根据任务ID查询 supervisor_task_info 获取督导UUID和所属周起止日期,
* 再调用 queryExcellentCaseList 查询该督导在该周内提交的优秀案例
* </p>
*
* @param request 分页查询参数(condition中需传入taskId)
* @return 分页的案例列表
*/
public Page<ExcellentCaseDetailDTO> queryExcellentCaseListByTaskId(RpcPagination<ExcellentCaseReviewQueryDTO> request) {
ExcellentCaseReviewQueryDTO condition = request.getCondition();
Long taskId = condition.getTaskId();
log.info("根据任务ID查询优秀案例列表,taskId={}, pageNum={}, pageSize={}", taskId, request.getPageNum(), request.getPageSize());
RpcAssert.assertNotNull(taskId, DefaultErrorEnum.PARAMETER_NULL, "任务ID不能为空");
// 查询任务详情,获取督导UUID和起止日期
SupervisorTaskInfo taskInfo = supervisorTaskInfoMapper.selectByPrimaryKey(taskId);
if (taskInfo == null) {
log.error("根据ID查询任务信息不存在,taskId={}", taskId);
throw new RpcServiceException(DefaultErrorEnum.DATA_NOT_EXIST, "根据ID查询任务信息不存在");
}
// 填充查询条件
condition.setSubmitterId(taskInfo.getSupervisorUuid());
condition.setStartDate(taskInfo.getStartDate());
condition.setEndDate(taskInfo.getEndDate());
Page<ExcellentCaseDetailDTO> page = PageHelper.startPage(request.getPageNum(), request.getPageSize());
excellentCaseReviewMapper.queryExcellentCaseList(condition);
log.info("根据任务ID查询优秀案例列表完成,taskId={}", taskId);
return page;
}
} }
...@@ -7,6 +7,7 @@ import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO; ...@@ -7,6 +7,7 @@ import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO; import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.enums.ReviewStatusEnum; 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.model.SupervisorTaskInfo;
import cn.com.glsx.dj.supervisor.mapper.SupervisorAudioReviewInfoMapper; import cn.com.glsx.dj.supervisor.mapper.SupervisorAudioReviewInfoMapper;
import cn.com.glsx.dj.supervisor.model.SupervisorAudioReviewInfo; import cn.com.glsx.dj.supervisor.model.SupervisorAudioReviewInfo;
import cn.com.glsx.framework.core.beans.BaseModel; import cn.com.glsx.framework.core.beans.BaseModel;
...@@ -20,6 +21,7 @@ import org.apache.commons.collections.CollectionUtils; ...@@ -20,6 +21,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils; import org.apache.commons.lang.StringUtils;
import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable; import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation; import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
...@@ -39,6 +41,9 @@ public class SupervisorAudioReviewInfoService { ...@@ -39,6 +41,9 @@ public class SupervisorAudioReviewInfoService {
@Autowired @Autowired
private SupervisorTaskInfoService supervisorTaskInfoService; private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private Environment env;
/** /**
...@@ -142,20 +147,28 @@ public class SupervisorAudioReviewInfoService { ...@@ -142,20 +147,28 @@ public class SupervisorAudioReviewInfoService {
} }
request.setUpdatedDate(new Date()); request.setUpdatedDate(new Date());
supervisorAudioReviewInfoMapper.updateByPrimaryKeySelective(request); supervisorAudioReviewInfoMapper.updateByPrimaryKeySelective(request);
//查询关联任务,如果任务已完成则无需重复更新任务状态
SupervisorTaskInfo taskInfo = supervisorTaskInfoService.selectByPrimaryKey(info.getRelationId());
if (taskInfo != null && TaskStatusEnum.COMPLETED.getCode().equals(taskInfo.getTaskStatus())) {
return true;
}
//查询关联任务中其他录音是否全部复盘,若全部复盘,则更新任务状态为已完成 //查询关联任务中其他录音是否全部复盘,若全部复盘,则更新任务状态为已完成
List<SupervisorAudioReviewInfo> list = listByTaskIds(Arrays.asList(info.getRelationId())); List<SupervisorAudioReviewInfo> list = listByTaskIds(Arrays.asList(info.getRelationId()));
if (CollectionUtils.isNotEmpty(list)) { if (CollectionUtils.isNotEmpty(list)) {
//判断是否全部复盘 //从配置读取复盘完成比例阈值(百分比),默认50
boolean allReviewed = list.stream().allMatch(item -> ReviewStatusEnum.COMPLETED.getCode().equals(item.getReviewStatus())); int completeRatio = env.getProperty("supervisor_audio_review_complete_ratio", Integer.class, 50);
boolean anyReviewed = list.stream().anyMatch(item -> ReviewStatusEnum.COMPLETED.getCode().equals(item.getReviewStatus())); long reviewedCount = list.stream().filter(item -> ReviewStatusEnum.COMPLETED.getCode().equals(item.getReviewStatus())).count();
if (allReviewed) { boolean anyReviewed = reviewedCount > 0;
//更新任务状态为已完成 if (anyReviewed) {
if (reviewedCount * 100 >= (long) list.size() * completeRatio) {
//复盘比例>=阈值,更新任务状态为已完成
supervisorTaskInfoService.updateTaskStatus(info.getRelationId(), TaskStatusEnum.COMPLETED.getCode(), request.getUpdatedBy()); supervisorTaskInfoService.updateTaskStatus(info.getRelationId(), TaskStatusEnum.COMPLETED.getCode(), request.getUpdatedBy());
} else if (anyReviewed) { } else {
//更新任务状态为进行中 //复盘比例<阈值,更新任务状态为进行中
supervisorTaskInfoService.updateTaskStatus(info.getRelationId(), TaskStatusEnum.IN_PROGRESS.getCode(), request.getUpdatedBy()); supervisorTaskInfoService.updateTaskStatus(info.getRelationId(), TaskStatusEnum.IN_PROGRESS.getCode(), request.getUpdatedBy());
} }
} }
}
return true; return true;
} }
......
...@@ -187,25 +187,78 @@ public class SupervisorDashboardService { ...@@ -187,25 +187,78 @@ public class SupervisorDashboardService {
public SupervisorDashboardVO getDashboardData(DashboardQueryReq req) { public SupervisorDashboardVO getDashboardData(DashboardQueryReq req) {
SupervisorDashboardVO vo = new SupervisorDashboardVO(); SupervisorDashboardVO vo = new SupervisorDashboardVO();
Integer bizs = req.getBizs();
// 1. 获取督导管理的门店列表
List<Integer> merchantIds = getSupervisorMerchants(req.getSupervisorId());
log.info("开始远程调用获取督导首页数据,请求参数:{}", req); log.info("开始远程调用获取督导首页数据,请求参数:{}", req);
// 1.获取督导的管理门店以及门店的员工的手机号列表
List<EmployeeRanking> storeAndEmployeePhoneList = getSupervisorStoreAndEmployeePhoneList( List<EmployeeRanking> storeAndEmployeePhoneList;
req.getSupervisorId(), merchantIds); List<EmployeeRanking> rawEmployeeData;
if (bizs == null) {
// biz为空时,需要分开查询不同业务类型的门店和指标数据
// 1.1飞行督导(type=6)对应轻改(biz=2),2.1飞行督导(type=13)对应延保+权益(biz=1,3)
List<List<EmployeeRanking>> dataLists = new ArrayList<>();
List<Integer> allMerchantIds = new ArrayList<>();
// 查询1.1飞行督导的门店和轻改业务数据
List<Integer> flightSupervisionMerchants = getMerchantsByDirectorType(req.getSupervisorId(),
DirectorTypeEnum.FLIGHT_SUPERVISION.getValue());
if (!flightSupervisionMerchants.isEmpty()) {
// 有权限才查询指标数据
dataLists.add(queryMetricsByBiz(req, flightSupervisionMerchants, 2));
allMerchantIds.addAll(flightSupervisionMerchants);
}
// 查询2.1飞行督导的门店和延保/权益业务数据
List<Integer> flightSupervision21Merchants = getMerchantsByDirectorType(req.getSupervisorId(),
DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue()); // FLIGHT_SUPERVISION_2_1
if (!flightSupervision21Merchants.isEmpty()) {
// 有权限才查询指标数据
dataLists.add(queryMetricsByBiz(req, flightSupervision21Merchants, 1)); // 延保
dataLists.add(queryMetricsByBiz(req, flightSupervision21Merchants, 3)); // 权益
allMerchantIds.addAll(flightSupervision21Merchants);
}
if (CollectionUtils.isEmpty(allMerchantIds)){
return vo;
}
// allMerchantIds 去重
allMerchantIds = allMerchantIds.stream().distinct().collect(Collectors.toList());
// 获取所有门店的员工列表
storeAndEmployeePhoneList = getSupervisorStoreAndEmployeePhoneList(req.getSupervisorId(), allMerchantIds);
if (storeAndEmployeePhoneList.isEmpty()) {
return vo;
}
// 处理员工业务场景标签
processEmployeeBusinessScene(storeAndEmployeePhoneList);
// 聚合有权限的业务场景的指标数据
rawEmployeeData = aggregateMetricsData(dataLists);
req.setMerchantIds(allMerchantIds);
} else {
// biz不为空时,使用原有逻辑
List<Integer> merchantIds = getSupervisorMerchants(req.getSupervisorId(), bizs);
if(CollectionUtils.isEmpty(merchantIds)){
return vo;
}
// 获取督导的管理门店以及门店的员工的手机号列表
storeAndEmployeePhoneList = getSupervisorStoreAndEmployeePhoneList(req.getSupervisorId(), merchantIds);
if (storeAndEmployeePhoneList.isEmpty()) { if (storeAndEmployeePhoneList.isEmpty()) {
return vo; return vo;
} }
// 2. 处理员工业务场景标签 // 处理员工业务场景标签
processEmployeeBusinessScene(storeAndEmployeePhoneList); processEmployeeBusinessScene(storeAndEmployeePhoneList);
req.setMerchantIds(merchantIds); req.setMerchantIds(merchantIds);
// 4. 获取 BI 数据 // 获取 BI 数据
// 根据维度调用不同的 BI 指标 ID (A036, A076, A085 等) rawEmployeeData = getDashboardMetrics(req);
List<EmployeeRanking> rawEmployeeData = getDashboardMetrics(req); }
// 5. 以 storeAndEmployeePhoneList 为基准,通过手机号关联设置员工的指标数据 // 5. 以 storeAndEmployeePhoneList 为基准,通过手机号关联设置员工的指标数据
Map<String, EmployeeRanking> metricMap = new HashMap<>(); Map<String, EmployeeRanking> metricMap = new HashMap<>();
...@@ -262,7 +315,7 @@ public class SupervisorDashboardService { ...@@ -262,7 +315,7 @@ public class SupervisorDashboardService {
// 3. 组装基础指标 // 3. 组装基础指标
DashboardMetrics metrics = aggregateMetrics(storeAndEmployeePhoneList); DashboardMetrics metrics = aggregateMetrics(storeAndEmployeePhoneList);
metrics.setStoreCount(merchantIds.size()); metrics.setStoreCount(req.getMerchantIds().size());
vo.setMetrics(metrics); vo.setMetrics(metrics);
// 4. 触发 AI 分析 // 4. 触发 AI 分析
...@@ -336,20 +389,70 @@ public class SupervisorDashboardService { ...@@ -336,20 +389,70 @@ public class SupervisorDashboardService {
public SupervisorDashboardVO getDashboardBehaviorData(DashboardQueryReq req) { public SupervisorDashboardVO getDashboardBehaviorData(DashboardQueryReq req) {
SupervisorDashboardVO vo = new SupervisorDashboardVO(); SupervisorDashboardVO vo = new SupervisorDashboardVO();
Integer bizs = req.getBizs();
List<EmployeeRanking> storePhoneMap;
List<EmployeeRanking> dataList;
if (bizs == null) {
// biz为空时,需要分开查询不同业务类型的门店和行为数据
// 1.1飞行督导(type=6)对应轻改(biz=2),2.1飞行督导(type=13)对应延保+权益(biz=1,3)
List<List<EmployeeRanking>> dataLists = new ArrayList<>();
List<Integer> allMerchantIds = new ArrayList<>();
// 查询1.1飞行督导的门店和轻改业务数据
List<Integer> flightSupervisionMerchants = getMerchantsByDirectorType(req.getSupervisorId(),
DirectorTypeEnum.FLIGHT_SUPERVISION.getValue());
if (!flightSupervisionMerchants.isEmpty()) {
// 有权限才查询行为数据
dataLists.add(fetchBehaviorDataByBiz(req, flightSupervisionMerchants, 2));
allMerchantIds.addAll(flightSupervisionMerchants);
}
// 查询2.1飞行督导的门店和延保/权益业务数据
List<Integer> flightSupervision21Merchants = getMerchantsByDirectorType(req.getSupervisorId(),
Byte.valueOf("13")); // FLIGHT_SUPERVISION_2_1
if (!flightSupervision21Merchants.isEmpty()) {
// 有权限才查询行为数据
dataLists.add(fetchBehaviorDataByBiz(req, flightSupervision21Merchants, 1)); // 延保
dataLists.add(fetchBehaviorDataByBiz(req, flightSupervision21Merchants, 3)); // 权益
allMerchantIds.addAll(flightSupervision21Merchants);
}
if (CollectionUtils.isEmpty(allMerchantIds)){
return vo;
}
allMerchantIds = allMerchantIds.stream().distinct().collect(Collectors.toList());
// 获取所有门店的员工列表
storePhoneMap = getSupervisorStoreAndEmployeePhoneList(req.getSupervisorId(), allMerchantIds);
if (storePhoneMap.isEmpty()) return vo;
// 处理员工业务场景标签
processEmployeeBusinessScene(storePhoneMap);
// 聚合有权限的业务场景的行为数据
dataList = aggregateBehaviorData(dataLists);
req.setMerchantIds(allMerchantIds);
} else {
// biz不为空时,使用原有逻辑
List<Integer> merchantIds = getSupervisorMerchants(req.getSupervisorId(), bizs);
if (CollectionUtils.isEmpty(merchantIds)){
return vo;
}
// 1. 获取督导管理的门店列表
List<Integer> merchantIds = getSupervisorMerchants(req.getSupervisorId());
req.setMerchantIds(merchantIds); req.setMerchantIds(merchantIds);
// 1. 获取管辖员工
List<EmployeeRanking> storePhoneMap = getSupervisorStoreAndEmployeePhoneList( // 获取管辖员工
req.getSupervisorId(), merchantIds); storePhoneMap = getSupervisorStoreAndEmployeePhoneList(req.getSupervisorId(), merchantIds);
if (storePhoneMap.isEmpty()) return vo; if (storePhoneMap.isEmpty()) return vo;
// 2. 处理员工业务场景标签 // 处理员工业务场景标签
processEmployeeBusinessScene(storePhoneMap); processEmployeeBusinessScene(storePhoneMap);
// 4. 获取行为数据 (多源合并) // 获取行为数据 (多源合并)
List<EmployeeRanking> dataList = fetchBehaviorData(req); dataList = fetchBehaviorData(req);
}
Map<String, EmployeeRanking> metricMap = new HashMap<>(); Map<String, EmployeeRanking> metricMap = new HashMap<>();
for (EmployeeRanking metric : dataList) { for (EmployeeRanking metric : dataList) {
if (metric.getEmployeePhone() != null) { if (metric.getEmployeePhone() != null) {
...@@ -375,7 +478,7 @@ public class SupervisorDashboardService { ...@@ -375,7 +478,7 @@ public class SupervisorDashboardService {
// 3. 聚合卡片数据 // 3. 聚合卡片数据
DashboardMetrics metrics = aggregateMetrics(storePhoneMap); DashboardMetrics metrics = aggregateMetrics(storePhoneMap);
metrics.setStoreCount(merchantIds.size()); metrics.setStoreCount(req.getMerchantIds().size());
vo.setMetrics(metrics); vo.setMetrics(metrics);
// 4. 生成 AI 建议 (行为版) // 4. 生成 AI 建议 (行为版)
...@@ -431,33 +534,55 @@ public class SupervisorDashboardService { ...@@ -431,33 +534,55 @@ public class SupervisorDashboardService {
* @return 指标数据 * @return 指标数据
*/ */
public List<EmployeeRanking> getDashboardMetrics(DashboardQueryReq dashboardQueryReq) { public List<EmployeeRanking> getDashboardMetrics(DashboardQueryReq dashboardQueryReq) {
Integer bizs = dashboardQueryReq.getBizs();
// 1.获取 BI 指标数据 // 用于聚合多个业务场景的数据
DataBizQueryParamsDTO params = new DataBizQueryParamsDTO(); Map<String, EmployeeMetricTemp> aggregatedPhoneMetricMap = new HashMap<>();
params.setBizs(dashboardQueryReq.getBizs());
params.setDateType(dashboardQueryReq.getDateType()); // 如果biz为空,需要分开查询三个业务场景(延保=1、轻改=2、权益=3)的数据,然后合并
params.setStartDate(dashboardQueryReq.getStartDate()); if (bizs == null) {
params.setBrandIds(environment.getProperty("bi.default.brandIds")==null?"-1,-2,-4,3454":environment.getProperty("bi.default.brandIds")); // 分别查询三个业务场景的数据
params.setEndDate(dashboardQueryReq.getEndDate()); List<Integer> bizList = Arrays.asList(1, 2, 3); // 延保、轻改、权益
if (CollectionUtils.isNotEmpty(dashboardQueryReq.getMerchantIds())) {
params.setMerchantIds( for (Integer biz : bizList) {
dashboardQueryReq.getMerchantIds().stream().map(String::valueOf).collect(Collectors.joining(","))); DataResp<List<DataBusinessDTO>> bizDataResp = queryBiData(dashboardQueryReq, biz);
} Map<String, EmployeeMetricTemp> bizMetricMap = getStringEmployeeMetricTempMap(bizDataResp);
params.setItemCodes("A036,A075,A084");
params.setExts("merchantId,staffId"); // 将当前业务场景的数据聚合到总Map中
DataResp<List<DataBusinessDTO>> listDataResp = getDataStatsService.getMultiItemCodeData( for (Map.Entry<String, EmployeeMetricTemp> entry : bizMetricMap.entrySet()) {
params); String phone = entry.getKey();
EmployeeMetricTemp bizTemp = entry.getValue();
// 获取或创建聚合对象
EmployeeMetricTemp aggregatedTemp = aggregatedPhoneMetricMap.computeIfAbsent(phone,
k -> new EmployeeMetricTemp());
Map<String, EmployeeMetricTemp> phoneMetricMap = getStringEmployeeMetricTempMap( // 累加指标值
listDataResp); aggregatedTemp.setOutputValue(aggregatedTemp.getOutputValue().add(bizTemp.getOutputValue()));
aggregatedTemp.setNumeratorValue(aggregatedTemp.getNumeratorValue().add(bizTemp.getNumeratorValue()));
aggregatedTemp.setDenominatorValue(aggregatedTemp.getDenominatorValue().add(bizTemp.getDenominatorValue()));
// 5. 转换为目标对象并计算最终指标 // 保留第一条非空的基础信息
if (aggregatedTemp.getStaffName() == null && bizTemp.getStaffName() != null) {
aggregatedTemp.setStaffName(bizTemp.getStaffName());
}
if (aggregatedTemp.getMerchantId() == null && bizTemp.getMerchantId() != null) {
aggregatedTemp.setMerchantId(bizTemp.getMerchantId());
}
}
}
} else {
// biz不为空,直接查询对应业务的数据
DataResp<List<DataBusinessDTO>> listDataResp = queryBiData(dashboardQueryReq, bizs);
aggregatedPhoneMetricMap = getStringEmployeeMetricTempMap(listDataResp);
}
// 转换为目标对象并计算最终指标
List<EmployeeRanking> result = new ArrayList<>(); List<EmployeeRanking> result = new ArrayList<>();
BigDecimal zero = BigDecimal.ZERO; BigDecimal zero = BigDecimal.ZERO;
for (Map.Entry<String, EmployeeMetricTemp> entry : phoneMetricMap.entrySet()) { for (Map.Entry<String, EmployeeMetricTemp> entry : aggregatedPhoneMetricMap.entrySet()) {
EmployeeRanking ranking = getEmployeeRanking(entry, zero); EmployeeRanking ranking = getEmployeeRanking(entry, zero);
result.add(ranking); result.add(ranking);
} }
...@@ -490,7 +615,181 @@ public class SupervisorDashboardService { ...@@ -490,7 +615,181 @@ public class SupervisorDashboardService {
} }
return result; return result;
}
/**
* 查询BI指标数据的辅助方法
*/
private DataResp<List<DataBusinessDTO>> queryBiData(DashboardQueryReq dashboardQueryReq, Integer bizs) {
DataBizQueryParamsDTO params = new DataBizQueryParamsDTO();
params.setBizs(bizs);
params.setDateType(dashboardQueryReq.getDateType());
params.setStartDate(dashboardQueryReq.getStartDate());
params.setBrandIds(environment.getProperty("bi.default.brandIds")==null?"-1,-2,-4,3454":environment.getProperty("bi.default.brandIds"));
params.setEndDate(dashboardQueryReq.getEndDate());
if (CollectionUtils.isNotEmpty(dashboardQueryReq.getMerchantIds())) {
params.setMerchantIds(
dashboardQueryReq.getMerchantIds().stream().map(String::valueOf).collect(Collectors.joining(",")));
}
params.setItemCodes("A036,A075,A084");
params.setExts("merchantId,staffId");
return getDataStatsService.getMultiItemCodeData(params);
}
/**
* 根据督导类型获取门店列表
*/
private List<Integer> getMerchantsByDirectorType(String supervisorId, Byte directorType) {
List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(ShopMerchantDirectorConfigDTO.builder()
.directorTypes(Arrays.asList(directorType))
.directorUserId(supervisorId)
.build()).getResult();
if (list == null || list.isEmpty()) {
return new ArrayList<>();
}
return list.stream()
.map(ShopMerchantDirectorConfigDTO::getMerchantId)
.distinct()
.collect(Collectors.toList());
}
/**
* 根据业务类型查询指标数据
*/
private List<EmployeeRanking> queryMetricsByBiz(DashboardQueryReq req, List<Integer> merchantIds, Integer bizs) {
if (merchantIds == null || merchantIds.isEmpty()) {
return new ArrayList<>();
}
// 创建临时请求对象,避免修改原始请求
DashboardQueryReq tempReq = new DashboardQueryReq();
tempReq.setDateType(req.getDateType());
tempReq.setStartDate(req.getStartDate());
tempReq.setEndDate(req.getEndDate());
tempReq.setMerchantIds(merchantIds);
tempReq.setBizs(bizs);
return getDashboardMetrics(tempReq);
}
/**
* 聚合多个业务场景的指标数据
*/
private List<EmployeeRanking> aggregateMetricsData(List<List<EmployeeRanking>> dataLists) {
Map<String, EmployeeRanking> aggregatedMap = new HashMap<>();
BigDecimal zero = BigDecimal.ZERO;
for (List<EmployeeRanking> dataList : dataLists) {
if (dataList == null || dataList.isEmpty()) {
continue;
}
for (EmployeeRanking ranking : dataList) {
String phone = ranking.getEmployeePhone();
if (phone == null) {
continue;
}
EmployeeRanking aggregated = aggregatedMap.computeIfAbsent(phone, k -> new EmployeeRanking());
// 累加指标值
BigDecimal output = ranking.getPersonalOutput() != null ? ranking.getPersonalOutput() : zero;
BigDecimal unitPrice = ranking.getPersonalUnitPrice() != null ? ranking.getPersonalUnitPrice() : zero;
BigDecimal conversion = ranking.getPersonalConversion() != null ? ranking.getPersonalConversion() : zero;
aggregated.setPersonalOutput(aggregated.getPersonalOutput() != null ?
aggregated.getPersonalOutput().add(output) : output);
aggregated.setPersonalUnitPrice(aggregated.getPersonalUnitPrice() != null ?
aggregated.getPersonalUnitPrice().add(unitPrice) : unitPrice);
aggregated.setPersonalConversion(aggregated.getPersonalConversion() != null ?
aggregated.getPersonalConversion().add(conversion) : conversion);
// 保留员工姓名
if (aggregated.getEmployeeName() == null && ranking.getEmployeeName() != null) {
aggregated.setEmployeeName(ranking.getEmployeeName());
}
aggregated.setEmployeePhone(phone);
}
}
return new ArrayList<>(aggregatedMap.values());
}
/**
* 根据业务类型查询行为数据
*/
private List<EmployeeRanking> fetchBehaviorDataByBiz(DashboardQueryReq req, List<Integer> merchantIds, Integer bizs) {
if (merchantIds == null || merchantIds.isEmpty()) {
return new ArrayList<>();
}
// 创建临时请求对象,避免修改原始请求
DashboardQueryReq tempReq = new DashboardQueryReq();
tempReq.setDateType(req.getDateType());
tempReq.setStartDate(req.getStartDate());
tempReq.setEndDate(req.getEndDate());
tempReq.setMerchantIds(merchantIds);
tempReq.setBizs(bizs);
tempReq.setSortField(req.getSortField());
tempReq.setSortDirection(req.getSortDirection());
return fetchBehaviorData(tempReq);
}
/**
* 聚合多个业务场景的行为数据
*/
private List<EmployeeRanking> aggregateBehaviorData(List<List<EmployeeRanking>> dataLists) {
Map<String, EmployeeRanking> aggregatedMap = new HashMap<>();
BigDecimal zero = BigDecimal.ZERO;
for (List<EmployeeRanking> dataList : dataLists) {
if (dataList == null || dataList.isEmpty()) {
continue;
}
for (EmployeeRanking ranking : dataList) {
String phone = ranking.getEmployeePhone();
if (phone == null) {
continue;
}
EmployeeRanking aggregated = aggregatedMap.computeIfAbsent(phone, k -> new EmployeeRanking());
// 累加行为指标值
BigDecimal output = ranking.getPersonalOutput() != null ? ranking.getPersonalOutput() : zero;
BigDecimal missingRate = ranking.getMissingRate() != null ? ranking.getMissingRate() : zero;
aggregated.setPersonalOutput(aggregated.getPersonalOutput() != null ?
aggregated.getPersonalOutput().add(output) : output);
aggregated.setMissingRate(aggregated.getMissingRate() != null ?
aggregated.getMissingRate().add(missingRate) : missingRate);
// 累加成整数类型指标
aggregated.setDealCount(aggregated.getDealCount() != null ?
aggregated.getDealCount() + (ranking.getDealCount() != null ? ranking.getDealCount() : 0)
: (ranking.getDealCount() != null ? ranking.getDealCount() : 0));
aggregated.setDefeatCount(aggregated.getDefeatCount() != null ?
aggregated.getDefeatCount() + (ranking.getDefeatCount() != null ? ranking.getDefeatCount() : 0)
: (ranking.getDefeatCount() != null ? ranking.getDefeatCount() : 0));
aggregated.setRecordingCount(aggregated.getRecordingCount() != null ?
aggregated.getRecordingCount() + (ranking.getRecordingCount() != null ? ranking.getRecordingCount() : 0)
: (ranking.getRecordingCount() != null ? ranking.getRecordingCount() : 0));
aggregated.setLeadCount(aggregated.getLeadCount() != null ?
aggregated.getLeadCount() + (ranking.getLeadCount() != null ? ranking.getLeadCount() : 0)
: (ranking.getLeadCount() != null ? ranking.getLeadCount() : 0));
// 保留员工姓名
if (aggregated.getEmployeeName() == null && ranking.getEmployeeName() != null) {
aggregated.setEmployeeName(ranking.getEmployeeName());
}
aggregated.setEmployeePhone(phone);
}
}
return new ArrayList<>(aggregatedMap.values());
} }
/** /**
...@@ -629,15 +928,36 @@ public class SupervisorDashboardService { ...@@ -629,15 +928,36 @@ public class SupervisorDashboardService {
return new ArrayList<>(); return new ArrayList<>();
} }
public List<Integer> getSupervisorMerchants(String supervisorId) { public List<Integer> getSupervisorMerchants(String supervisorId, Integer bizs) {
// 根据业务类型确定需要查询的督导类型
List<Byte> directorTypes = new ArrayList<>();
// 1.1飞行督导(type=6)对应轻改(biz=2),2.1飞行督导(type=13)对应延保+权益(biz=1,3)
if (bizs == null) {
// biz为空时,查询两种类型的门店
directorTypes.add(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue());
directorTypes.add(DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue()); // FLIGHT_SUPERVISION_2_1
} else if (bizs == 2) {
// 轻改业务,只查询1.1飞行督导
directorTypes.add(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue());
} else if (bizs == 1 || bizs == 3) {
// 延保或权益业务,只查询2.1飞行督导
directorTypes.add(DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue()); // FLIGHT_SUPERVISION_2_1
}
if (directorTypes.isEmpty()) {
log.warn("getSupervisorMerchants: 未匹配到有效的业务类型,bizs={}", bizs);
return new ArrayList<>();
}
List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(ShopMerchantDirectorConfigDTO.builder() List<ShopMerchantDirectorConfigDTO> list = shopMerchantDirectorConfigRemote.list(ShopMerchantDirectorConfigDTO.builder()
.directorTypes( .directorTypes(directorTypes)
Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue()))
.directorUserId(supervisorId) .directorUserId(supervisorId)
.build()).getResult(); .build()).getResult();
return list.stream() return list.stream()
.map(ShopMerchantDirectorConfigDTO::getMerchantId) .map(ShopMerchantDirectorConfigDTO::getMerchantId)
.distinct()
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
......
...@@ -55,7 +55,7 @@ public class SupervisorEmployeeTrainingInfoService { ...@@ -55,7 +55,7 @@ public class SupervisorEmployeeTrainingInfoService {
} }
// 2、根据督导uuid,获取督导下所有门店及员工信息(已按手机号去重) // 2、根据督导uuid,获取督导下所有门店及员工信息(已按手机号去重)
List<Integer> merchantIds = supervisorDashboardService.getSupervisorMerchants(supervisorUUID); List<Integer> merchantIds = supervisorDashboardService.getSupervisorMerchants(supervisorUUID,request.getBusinessType());
List<EmployeeRanking> supervisorStoreAndEmployeePhoneList = supervisorDashboardService.getSupervisorStoreAndEmployeePhoneList( List<EmployeeRanking> supervisorStoreAndEmployeePhoneList = supervisorDashboardService.getSupervisorStoreAndEmployeePhoneList(
supervisorUUID, merchantIds); supervisorUUID, merchantIds);
......
...@@ -4,15 +4,13 @@ import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq; ...@@ -4,15 +4,13 @@ import cn.com.glsx.dj.peanalysis.dto.req.output.SceneBaseReq;
import cn.com.glsx.dj.peanalysis.dto.res.output.SceneOutputResponse; import cn.com.glsx.dj.peanalysis.dto.res.output.SceneOutputResponse;
import cn.com.glsx.dj.peanalysis.remote.BusinessSceneAnalysisRemote; import cn.com.glsx.dj.peanalysis.remote.BusinessSceneAnalysisRemote;
import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffBaseInfoDTO; import cn.com.glsx.dj.smartcarlife.dto.merchantPerformanceConfig.StaffBaseInfoDTO;
import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum;
import cn.com.glsx.dj.smartcarlife.remote.StaffBaseInfoRemote; import cn.com.glsx.dj.smartcarlife.remote.StaffBaseInfoRemote;
import cn.com.glsx.dj.supervisor.dto.*; import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.enums.ReviewStatusEnum; 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.*;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskCourseMapper;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskImageMapper;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskInfoMapper;
import cn.com.glsx.dj.supervisor.model.*; import cn.com.glsx.dj.supervisor.model.*;
import cn.com.glsx.framework.core.beans.BaseModel; import cn.com.glsx.framework.core.beans.BaseModel;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
...@@ -66,12 +64,21 @@ public class SupervisorTaskInfoService { ...@@ -66,12 +64,21 @@ public class SupervisorTaskInfoService {
private SupervisorWeekTaskStaffService supervisorWeekTaskStaffService; private SupervisorWeekTaskStaffService supervisorWeekTaskStaffService;
@Autowired @Autowired
private SupervisorTaskMerchantService supervisorTaskMerchantService;
@Autowired
private SupervisorAudioReviewInfoService supervisorAudioReviewInfoService; private SupervisorAudioReviewInfoService supervisorAudioReviewInfoService;
@Autowired @Autowired
private SupervisorTaskCourseService supervisorTaskCourseService; private SupervisorTaskCourseService supervisorTaskCourseService;
@Autowired @Autowired
private SupervisorTeachingDetailService supervisorTeachingDetailService;
@Autowired
private SupervisorTaskParticipantService supervisorTaskParticipantService;
@Autowired
private StaffBaseInfoRemote staffBaseInfoRemote; private StaffBaseInfoRemote staffBaseInfoRemote;
@Autowired @Autowired
...@@ -84,6 +91,15 @@ public class SupervisorTaskInfoService { ...@@ -84,6 +91,15 @@ public class SupervisorTaskInfoService {
private SupervisorTaskCourseMapper supervisorTaskCourseMapper; private SupervisorTaskCourseMapper supervisorTaskCourseMapper;
@Autowired @Autowired
private SupervisorTaskMerchantMapper supervisorTaskMerchantMapper;
@Autowired
private SupervisorTeachingDetailMapper supervisorTeachingDetailMapper;
@Autowired
private SupervisorTaskParticipantMapper supervisorTaskParticipantMapper;
@Autowired
private SupervisorLearningCenterService supervisorLearningCenterService; private SupervisorLearningCenterService supervisorLearningCenterService;
@Autowired @Autowired
...@@ -95,6 +111,9 @@ public class SupervisorTaskInfoService { ...@@ -95,6 +111,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
...@@ -144,6 +163,24 @@ public class SupervisorTaskInfoService { ...@@ -144,6 +163,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);
} }
...@@ -182,7 +219,7 @@ public class SupervisorTaskInfoService { ...@@ -182,7 +219,7 @@ public class SupervisorTaskInfoService {
return summary; return summary;
} }
// 3. 查询 director_config 表,统计所有督导负责的门店(director_type=6,平台中飞行督导) // 3. 查询 director_config 表,统计所有督导负责的门店(director_type=6、13,平台中飞行督导)
List<SupervisorDirectorConfigDTO> supervisorDirectorConfigDTOS = supervisorTaskInfoMapper.queryDirectorConfigBySupervisorPhone(phoneList); List<SupervisorDirectorConfigDTO> supervisorDirectorConfigDTOS = supervisorTaskInfoMapper.queryDirectorConfigBySupervisorPhone(phoneList);
List<Integer> merchantIdList = supervisorDirectorConfigDTOS.stream() List<Integer> merchantIdList = supervisorDirectorConfigDTOS.stream()
.map(SupervisorDirectorConfigDTO::getMerchantId) .map(SupervisorDirectorConfigDTO::getMerchantId)
...@@ -190,9 +227,26 @@ public class SupervisorTaskInfoService { ...@@ -190,9 +227,26 @@ public class SupervisorTaskInfoService {
.collect(Collectors.toList()); .collect(Collectors.toList());
summary.setManagedStoreCount(merchantIdList.size()); summary.setManagedStoreCount(merchantIdList.size());
// supervisorDirectorConfigDTOS按director_type分组、1.1类型一组、2.1一组
Map<Integer, List<SupervisorDirectorConfigDTO>> configByType = supervisorDirectorConfigDTOS.stream()
.collect(Collectors.groupingBy(SupervisorDirectorConfigDTO::getDirectorType));
List<Integer> type6MerchantIds = configByType.getOrDefault(6, Collections.emptyList()).stream()
.map(SupervisorDirectorConfigDTO::getMerchantId).distinct().collect(Collectors.toList());
List<Integer> type13MerchantIds = configByType.getOrDefault(13, Collections.emptyList()).stream()
.map(SupervisorDirectorConfigDTO::getMerchantId).distinct().collect(Collectors.toList());
// 查询统计本月内总产值,保留2位小数 // 查询统计本月内总产值,保留2位小数
BigDecimal monthlyOutput = getMerchantListMonthlyOutput(merchantIdList); // 1.1:轻改(bizs=2) 2.1:延保(bizs=1) + 权益(bizs=3) 分三次查询产值,最后汇总为一个值作为总产值
summary.setMonthlyOutput(monthlyOutput != null ? monthlyOutput.setScale(2, java.math.RoundingMode.HALF_UP) : BigDecimal.ZERO); BigDecimal totalOutput = BigDecimal.ZERO;
if (!type6MerchantIds.isEmpty()) {
totalOutput = totalOutput.add(getMerchantListMonthlyOutput(type6MerchantIds, 2));
}
if (!type13MerchantIds.isEmpty()) {
totalOutput = totalOutput.add(getMerchantListMonthlyOutput(type13MerchantIds, 1));
totalOutput = totalOutput.add(getMerchantListMonthlyOutput(type13MerchantIds, 3));
}
summary.setMonthlyOutput(totalOutput.setScale(2, java.math.RoundingMode.HALF_UP));
return summary; return summary;
} }
...@@ -200,10 +254,12 @@ public class SupervisorTaskInfoService { ...@@ -200,10 +254,12 @@ public class SupervisorTaskInfoService {
* 查询门店列表本月内总产值 * 查询门店列表本月内总产值
* *
* @param merchantIdList 门店ID列表 * @param merchantIdList 门店ID列表
* @param bizs 业务类型,延保=1、轻改=2、权益=3
* @return 本月内总产值 * @return 本月内总产值
*/ */
private BigDecimal getMerchantListMonthlyOutput(List<Integer> merchantIdList) { private BigDecimal getMerchantListMonthlyOutput(List<Integer> merchantIdList, Integer bizs) {
DashboardQueryReq req = new DashboardQueryReq(); DashboardQueryReq req = new DashboardQueryReq();
req.setBizs(bizs);
req.setDateType(4); req.setDateType(4);
req.setStartDate(DateUtil.beginOfMonth(new Date()).toDateStr()); req.setStartDate(DateUtil.beginOfMonth(new Date()).toDateStr());
req.setEndDate(DateUtil.endOfMonth(new Date()).toDateStr()); req.setEndDate(DateUtil.endOfMonth(new Date()).toDateStr());
...@@ -489,6 +545,8 @@ public class SupervisorTaskInfoService { ...@@ -489,6 +545,8 @@ public class SupervisorTaskInfoService {
} }
//插入图片列表 //插入图片列表
supervisorTaskImageService.batchInsertImage(request, date); supervisorTaskImageService.batchInsertImage(request, date);
//插入门店关联列表
supervisorTaskMerchantService.batchInsert(request, date);
//判断是否是周报 //判断是否是周报
if (TaskTypeEnum.WEEKLY_REPORT.getCode().equals(taskInfo.getTaskType())) { if (TaskTypeEnum.WEEKLY_REPORT.getCode().equals(taskInfo.getTaskType())) {
//插入周任务员工列表 //插入周任务员工列表
...@@ -516,6 +574,13 @@ public class SupervisorTaskInfoService { ...@@ -516,6 +574,13 @@ public class SupervisorTaskInfoService {
} }
/** /**
* 根据ID查询任务基本信息(不含关联数据)
*/
public SupervisorTaskInfo selectByPrimaryKey(Long id) {
return supervisorTaskInfoMapper.selectByPrimaryKey(id);
}
/**
* 根据ID查询督导任务详情 * 根据ID查询督导任务详情
* @param id * @param id
* @return * @return
...@@ -528,12 +593,22 @@ public class SupervisorTaskInfoService { ...@@ -528,12 +593,22 @@ public class SupervisorTaskInfoService {
log.error("根据id查询任务信息不存在,id={}", id); log.error("根据id查询任务信息不存在,id={}", id);
throw new RpcServiceException(DefaultErrorEnum.DATA_NOT_EXIST, "根据id查询任务信息不存在"); throw new RpcServiceException(DefaultErrorEnum.DATA_NOT_EXIST, "根据id查询任务信息不存在");
} }
//查询门店关联列表
List<SupervisorTaskMerchant> taskMerchantList = supervisorTaskMerchantService.selectByRelationId(id);
taskInfo.setTaskMerchantList(taskMerchantList);
if (TaskTypeEnum.WEEKLY_REPORT.getCode().equals(taskInfo.getTaskType())) { if (TaskTypeEnum.WEEKLY_REPORT.getCode().equals(taskInfo.getTaskType())) {
//查询周任务员工列表 //查询周任务员工列表
List<SupervisorWeekTaskStaff> weekTaskStaffList = supervisorWeekTaskStaffService.selectByRelationId(id); List<SupervisorWeekTaskStaff> weekTaskStaffList = supervisorWeekTaskStaffService.selectByRelationId(id);
taskInfo.setWeekTaskStaffList(weekTaskStaffList); taskInfo.setWeekTaskStaffList(weekTaskStaffList);
} }
if (TaskTypeEnum.TRAINING.getCode().equals(taskInfo.getTaskType())) { if (TaskTypeEnum.TRAINING.getCode().equals(taskInfo.getTaskType())) {
// 查询带教详情
SupervisorTeachingDetail teachingDetail = supervisorTeachingDetailService.selectByTaskId(id);
taskInfo.setTeachingDetail(teachingDetail);
// 查询参与人员列表
List<SupervisorTaskParticipant> participantList = supervisorTaskParticipantService.selectByTaskId(id);
taskInfo.setParticipantList(participantList);
// 查询课程列表
List<SupervisorTaskCourse> taskCourseList = supervisorTaskCourseService.selectByTaskId(id); List<SupervisorTaskCourse> taskCourseList = supervisorTaskCourseService.selectByTaskId(id);
taskInfo.setTaskCourseList(taskCourseList); taskInfo.setTaskCourseList(taskCourseList);
//根据员工手机号,查询北森员工信息 //根据员工手机号,查询北森员工信息
...@@ -617,6 +692,22 @@ public class SupervisorTaskInfoService { ...@@ -617,6 +692,22 @@ public class SupervisorTaskInfoService {
} }
} }
} }
// 周任务进度计算:优秀案例录音、带教要求
for (SupervisorTaskDTO task : taskList) {
if (task.getTaskType() == null) continue;
if (StringUtils.isBlank(task.getSupervisorUuid()) || StringUtils.isBlank(task.getStartDate()) || StringUtils.isBlank(task.getEndDate())) continue;
if (TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode().equals(task.getTaskType())) {
task.setWeeklyTaskTotalCount(env.getProperty("supervisor.weektask.excellentCaseLimit", Integer.class, 2));
int caseCount = excellentCaseReviewMapper.countBySubmitterAndDateRange(
task.getSupervisorUuid(), task.getStartDate(), task.getEndDate());
task.setWeeklyTaskCompletedCount(caseCount);
} else if (TaskTypeEnum.COACHING_REQUIREMENT.getCode().equals(task.getTaskType())) {
task.setWeeklyTaskTotalCount(env.getProperty("supervisor.weektask.coachingRequirementLimit", Integer.class, 6));
int coachingCount = supervisorTaskInfoMapper.countCoachingBySupervisorAndDateRange(
task.getSupervisorUuid(), task.getStartDate(), task.getEndDate());
task.setWeeklyTaskCompletedCount(coachingCount);
}
}
} }
return page; return page;
} }
...@@ -650,48 +741,71 @@ public class SupervisorTaskInfoService { ...@@ -650,48 +741,71 @@ public class SupervisorTaskInfoService {
/** /**
* 查询督导团队概况信息 * 查询督导团队概况信息
* @param request 督导管理的门店id列表 * @param request 督导管理的门店id列表(含按督导类型分组的门店数据)
* @return 督导团队概况信息 * @return 督导团队概况信息
*/ */
public SupervisorTeamOverviewDTO getTeamOverview(SupervisorTaskQueryDTO request) { public SupervisorTeamOverviewDTO getTeamOverview(SupervisorTaskQueryDTO request) {
log.info("查询督导团队概况信息,查询条件: {}", request); log.info("查询督导团队概况信息,查询条件: {}", JSON.toJSONString(request));
SupervisorTeamOverviewDTO overviewDTO = new SupervisorTeamOverviewDTO(); SupervisorTeamOverviewDTO overviewDTO = new SupervisorTeamOverviewDTO();
List<Integer> merchantIdList = request.getMerchantIdList(); List<Integer> merchantIdList = request.getMerchantIdList();
// 计算团队员工个数 // 计算团队员工个数(使用所有门店去重)
StaffBaseInfoDTO param = new StaffBaseInfoDTO(); StaffBaseInfoDTO param = new StaffBaseInfoDTO();
param.setMerchantIdList(merchantIdList); param.setMerchantIdList(merchantIdList);
RpcResponse<List<StaffBaseInfoDTO>> response = staffBaseInfoRemote.listShopStaffInfoGroupByUUid(param); RpcResponse<List<StaffBaseInfoDTO>> response = staffBaseInfoRemote.listShopStaffInfoGroupByUUid(param);
if (response.hasError()) { if (response.hasError()) {
log.error("查询团队员工个数失败,merchantIdList={}, error={}, message={}", merchantIdList, response.getError(), response.getMessage()); log.error("查询团队员工个数失败,merchantIdList={}, error={}, message={}", merchantIdList, response.getError(), response.getMessage());
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, response.getMessage()); throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, response.getMessage());
} else { }
List<StaffBaseInfoDTO> staffList = response.getResult(); List<StaffBaseInfoDTO> staffList = response.getResult();
if (CollectionUtils.isNotEmpty(staffList)) { if (CollectionUtils.isNotEmpty(staffList)) {
//根据员工手机号去重计算员工个数 Set<String> phoneSet = staffList.stream()
Set<String> phoneSet = staffList.stream().filter(x -> StringUtils.isNotBlank(x.getStaffPhone())).map(StaffBaseInfoDTO::getStaffPhone).collect(Collectors.toSet()); .filter(x -> StringUtils.isNotBlank(x.getStaffPhone()))
.map(StaffBaseInfoDTO::getStaffPhone)
.collect(Collectors.toSet());
overviewDTO.setStaffCount(phoneSet.size()); overviewDTO.setStaffCount(phoneSet.size());
//查询产值 }
// 按督导类型分别查询产值并求和
Map<Integer, List<Integer>> directorTypeMerchantMap = request.getDirectorTypeMerchantMap();
BigDecimal totalOutput = BigDecimal.ZERO;
String startTime = env.getProperty("supervisor.output.startTime", String.class, "2021-01-01");
String endTime = DateUtils.formatDate(new Date());
if (directorTypeMerchantMap != null && !directorTypeMerchantMap.isEmpty()) {
for (Map.Entry<Integer, List<Integer>> entry : directorTypeMerchantMap.entrySet()) {
Integer directorType = entry.getKey();
List<Integer> merchantIds = entry.getValue();
if (CollectionUtils.isEmpty(merchantIds)) {
continue;
}
SceneBaseReq req = new SceneBaseReq(); SceneBaseReq req = new SceneBaseReq();
req.setMerchantIds(merchantIdList); req.setMerchantIds(merchantIds);
req.setCycleType(4); req.setCycleType(4);
//req.setStaffUuids(staffList.stream().map(StaffBaseInfoDTO::getLoginUuid).collect(Collectors.toList())); req.setStartTime(startTime);
//设置指标开始时间,从配置文件中取值 req.setEndTime(endTime);
req.setStartTime(env.getProperty("supervisor.output.startTime", String.class, "2021-01-01"));
//设置指标结束时间,固定当前日期 // 1.1飞行督导(type=6)对应轻改,2.1飞行督导(type=13)对应延保+权益
req.setEndTime(DateUtils.formatDate(new Date())); if (Integer.valueOf(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue()).equals(directorType)) {
req.setBizs(2);
} else if (Integer.valueOf(DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue()).equals(directorType)) {
req.setBizsMulti("1,3");
}
RpcResponse<SceneOutputResponse> outputResponse = businessSceneAnalysisRemote.querySupervisorOutput(req); RpcResponse<SceneOutputResponse> outputResponse = businessSceneAnalysisRemote.querySupervisorOutput(req);
if (outputResponse.hasError()) { if (outputResponse.hasError()) {
log.error("查询督导团队产值失败,SceneBaseReq={}, error={}, message={}", JSON.toJSONString(req), outputResponse.getError(), outputResponse.getMessage()); log.error("查询督导团队产值失败,directorType={}, merchantIds={}, error={}, message={}",
directorType, merchantIds, outputResponse.getError(), outputResponse.getMessage());
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, outputResponse.getMessage()); throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, outputResponse.getMessage());
} else {
SceneOutputResponse outputResp = outputResponse.getResult();
if (outputResp != null) {
overviewDTO.setTotalValue(outputResp.getOutputValue());
} }
SceneOutputResponse outputResp = outputResponse.getResult();
if (outputResp != null && outputResp.getOutputValue() != null) {
totalOutput = totalOutput.add(outputResp.getOutputValue());
} }
} }
} }
overviewDTO.setTotalValue(totalOutput);
return overviewDTO; return overviewDTO;
} }
/** /**
...@@ -724,6 +838,38 @@ public class SupervisorTaskInfoService { ...@@ -724,6 +838,38 @@ public class SupervisorTaskInfoService {
Long taskId = taskInfo.getId(); Long taskId = taskInfo.getId();
log.info("插入带教任务成功,taskId={}", taskId); log.info("插入带教任务成功,taskId={}", taskId);
// 插入带教详情
if (request.getTeachingDetail() != null) {
SupervisorTeachingDetail teachingDetail = request.getTeachingDetail();
teachingDetail.setTaskId(taskId);
supervisorTeachingDetailMapper.insertSelective(teachingDetail);
log.info("插入带教详情成功");
}
// 插入门店关联列表
if (CollectionUtils.isNotEmpty(request.getTaskMerchantList())) {
for (SupervisorTaskMerchant merchant : request.getTaskMerchantList()) {
merchant.setRelationId(taskId);
merchant.setCreatedBy(request.getSupervisorPhone());
merchant.setCreateTime(date);
merchant.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
}
supervisorTaskMerchantMapper.insertList(request.getTaskMerchantList());
log.info("插入带教门店成功,merchantCount={}", request.getTaskMerchantList().size());
}
// 插入参与人员列表
if (CollectionUtils.isNotEmpty(request.getParticipantList())) {
for (SupervisorTaskParticipant participant : request.getParticipantList()) {
participant.setTaskId(taskId);
participant.setCreatedBy(request.getSupervisorName());
participant.setCreateTime(date);
participant.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
}
supervisorTaskParticipantMapper.insertList(request.getParticipantList());
log.info("插入参与人员成功,participantCount={}", request.getParticipantList().size());
}
// 插入图片列表 // 插入图片列表
if (CollectionUtils.isNotEmpty(request.getTaskImageList())) { if (CollectionUtils.isNotEmpty(request.getTaskImageList())) {
for (SupervisorTaskImage image : request.getTaskImageList()) { for (SupervisorTaskImage image : request.getTaskImageList()) {
...@@ -758,7 +904,12 @@ public class SupervisorTaskInfoService { ...@@ -758,7 +904,12 @@ public class SupervisorTaskInfoService {
log.info("插入带教课程成功,courseCount={}", courseCount); log.info("插入带教课程成功,courseCount={}", courseCount);
} }
//更新周任务:带教要求状态
WeeklyTaskStatusReqDTO param = new WeeklyTaskStatusReqDTO();
param.setTaskType(TaskTypeEnum.COACHING_REQUIREMENT.getCode());
param.setCreateDate(org.apache.http.client.utils.DateUtils.formatDate(new Date(), "yyyy-MM-dd"));
param.setSupervisorUuid(request.getSupervisorUuid());
updateWeeklyTaskStatus(param);
log.info("发起带教 - 提交成功,taskId={}", taskId); log.info("发起带教 - 提交成功,taskId={}", taskId);
return taskId; return taskId;
...@@ -934,4 +1085,227 @@ public class SupervisorTaskInfoService { ...@@ -934,4 +1085,227 @@ 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();
}
/**
* 统计各任务类型未完成任务数量
*
* @param request 查询参数(督导手机号、起止日期)
* @return 各类型未完成任务数量
*/
public UnfinishedTaskCountDTO getUnfinishedTaskCount(UnfinishedTaskCountReqDTO request) {
String supervisorPhone = request.getSupervisorPhone();
String startDate = request.getStartDate();
String endDate = request.getEndDate();
UnfinishedTaskCountDTO result = new UnfinishedTaskCountDTO();
result.setDailyCount(0);
result.setWeeklyCount(0);
result.setMonthlyCount(0);
result.setSpecialCount(0);
boolean useCustomDate = StringUtils.isNotBlank(startDate) && StringUtils.isNotBlank(endDate);
if (useCustomDate) {
// 使用自定义时间范围,一次查询所有类型
List<Integer> allTypes = Arrays.asList(
TaskTypeEnum.DAILY_REPORT.getCode(),
TaskTypeEnum.AUDIO_RECORDING.getCode(),
TaskTypeEnum.TRAINING.getCode(),
TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode(),
TaskTypeEnum.COACHING_REQUIREMENT.getCode(),
TaskTypeEnum.MONTHLY_REPORT.getCode(),
TaskTypeEnum.SPECIAL_RECORDING.getCode()
);
Map<Integer, Integer> countMap = toCountMap(
supervisorTaskInfoMapper.countUnfinishedByTaskTypes(supervisorPhone, allTypes, startDate, endDate));
result.setDailyCount(sumCounts(countMap,
TaskTypeEnum.DAILY_REPORT.getCode(),
TaskTypeEnum.AUDIO_RECORDING.getCode(),
TaskTypeEnum.TRAINING.getCode()));
result.setWeeklyCount(sumCounts(countMap,
TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode(),
TaskTypeEnum.COACHING_REQUIREMENT.getCode()));
result.setMonthlyCount(sumCounts(countMap, TaskTypeEnum.MONTHLY_REPORT.getCode()));
result.setSpecialCount(sumCounts(countMap, TaskTypeEnum.SPECIAL_RECORDING.getCode()));
} else {
// 默认时间范围:每日=今天,每周=本周,每月=本月,专项=今天
String today = cn.com.glsx.framework.core.util.DateUtils.formatDate(new Date());
String weekStart = cn.com.glsx.framework.core.util.DateUtils.formatDate(
cn.com.glsx.dj.supervisor.utils.DateUtils.getMondayOfWeek(new Date()));
String weekEnd = cn.com.glsx.framework.core.util.DateUtils.formatDate(
cn.com.glsx.dj.supervisor.utils.DateUtils.getSundayOfWeek(new Date()));
String monthStart = DateUtil.beginOfMonth(new Date()).toDateStr();
String monthEnd = DateUtil.endOfMonth(new Date()).toDateStr();
// 每日任务(日报、录音、带教)
List<Integer> dailyTypes = Arrays.asList(
TaskTypeEnum.DAILY_REPORT.getCode(),
TaskTypeEnum.AUDIO_RECORDING.getCode(),
TaskTypeEnum.TRAINING.getCode());
Map<Integer, Integer> dailyMap = toCountMap(
supervisorTaskInfoMapper.countUnfinishedByTaskTypes(supervisorPhone, dailyTypes, today, today));
result.setDailyCount(sumAllValues(dailyMap));
// 每周任务(优秀案例录音、带教要求)
List<Integer> weeklyTypes = Arrays.asList(
TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode(),
TaskTypeEnum.COACHING_REQUIREMENT.getCode());
Map<Integer, Integer> weeklyMap = toCountMap(
supervisorTaskInfoMapper.countUnfinishedByTaskTypes(supervisorPhone, weeklyTypes, weekStart, weekEnd));
result.setWeeklyCount(sumAllValues(weeklyMap));
// 每月任务(月报)
List<Integer> monthlyTypes = Collections.singletonList(TaskTypeEnum.MONTHLY_REPORT.getCode());
Map<Integer, Integer> monthlyMap = toCountMap(
supervisorTaskInfoMapper.countUnfinishedByTaskTypes(supervisorPhone, monthlyTypes, monthStart, monthEnd));
result.setMonthlyCount(sumAllValues(monthlyMap));
// 专项任务(专项,按每日统计)
List<Integer> specialTypes = Collections.singletonList(TaskTypeEnum.SPECIAL_RECORDING.getCode());
Map<Integer, Integer> specialMap = toCountMap(
supervisorTaskInfoMapper.countUnfinishedByTaskTypes(supervisorPhone, specialTypes, today, today));
result.setSpecialCount(sumAllValues(specialMap));
}
return result;
}
private Map<Integer, Integer> toCountMap(List<Map<String, Object>> list) {
if (CollectionUtils.isEmpty(list)) {
return Collections.emptyMap();
}
Map<Integer, Integer> map = new HashMap<>();
for (Map<String, Object> row : list) {
Number taskTypeNum = (Number) row.get("taskType");
Number countNum = (Number) row.get("count");
Integer taskType = taskTypeNum != null ? taskTypeNum.intValue() : null;
Long count = countNum != null ? countNum.longValue() : null;
if (taskType != null) {
map.put(taskType, count != null ? count.intValue() : 0);
}
}
return map;
}
private int sumCounts(Map<Integer, Integer> countMap, Integer... types) {
int sum = 0;
for (Integer type : types) {
sum += countMap.getOrDefault(type, 0);
}
return sum;
}
private int sumAllValues(Map<Integer, Integer> countMap) {
int sum = 0;
for (Integer val : countMap.values()) {
sum += val;
}
return sum;
}
public Page<SupervisorTeachingListDTO> pageTeachingRecords(RpcPagination<SupervisorTaskQueryDTO> request) {
SupervisorTaskQueryDTO condition = request.getCondition();
SupervisorTaskInfo taskInfo = supervisorTaskInfoMapper.selectByPrimaryKey(condition.getId());
if (taskInfo == null) {
throw new RpcServiceException(DefaultErrorEnum.DATA_NOT_EXIST, "任务不存在");
}
if (!TaskTypeEnum.COACHING_REQUIREMENT.getCode().equals(taskInfo.getTaskType())) {
throw new RpcServiceException(DefaultErrorEnum.SERVICE_ERROR, "非带教要求任务");
}
condition.setSupervisorPhone(taskInfo.getSupervisorPhone());
condition.setStartDate(taskInfo.getStartDate());
condition.setEndDate(taskInfo.getEndDate());
Page<SupervisorTeachingListDTO> page = PageHelper.startPage(request.getPageNum(), request.getPageSize());
List<SupervisorTeachingListDTO> list = supervisorTaskInfoMapper.listTeachingRecords(condition);
return page;
}
/**
* 分页查询驻店基础信息
*/
public Page<SupervisorTeamStaffDTO> pageStaffBaseInfo(RpcPagination<SupervisorTeamStaffQueryDTO> request) {
Page<SupervisorTeamStaffDTO> page = PageHelper.startPage(request.getPageNum(), request.getPageSize());
supervisorTaskInfoMapper.listStaffBaseInfo(request.getCondition());
return page;
}
} }
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskMerchantMapper;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskMerchant;
import cn.com.glsx.framework.core.beans.BaseModel;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.Date;
import java.util.List;
@Service
@Slf4j
public class SupervisorTaskMerchantService {
@Autowired
private SupervisorTaskMerchantMapper supervisorTaskMerchantMapper;
/**
* 批量插入任务门店关联列表
* @param request
* @param date
* @return
*/
public int batchInsert(SupervisorTaskDTO request, Date date) {
List<SupervisorTaskMerchant> taskMerchantList = request.getTaskMerchantList();
if (CollectionUtils.isNotEmpty(taskMerchantList)) {
taskMerchantList.forEach(taskMerchant -> {
taskMerchant.setRelationId(request.getId());
taskMerchant.setCreatedBy(request.getUpdatedBy());
taskMerchant.setCreateTime(date);
taskMerchant.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
});
return supervisorTaskMerchantMapper.insertList(taskMerchantList);
}
return 0;
}
/**
* 根据任务ID查询门店关联列表
* @param relationId
* @return
*/
public List<SupervisorTaskMerchant> selectByRelationId(Long relationId) {
Example example = new Example(SupervisorTaskMerchant.class);
example.createCriteria().andEqualTo("relationId", relationId).andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
return supervisorTaskMerchantMapper.selectByExample(example);
}
}
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTaskParticipantMapper;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskParticipant;
import cn.com.glsx.framework.core.beans.BaseModel;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@Service
@Slf4j
public class SupervisorTaskParticipantService {
@Autowired
private SupervisorTaskParticipantMapper supervisorTaskParticipantMapper;
/**
* 根据任务ID查询参与人员列表
*
* @param taskId
* @return
*/
public List<SupervisorTaskParticipant> selectByTaskId(Long taskId) {
Example example = new Example(SupervisorTaskParticipant.class);
example.createCriteria().andEqualTo("taskId", taskId).andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
return supervisorTaskParticipantMapper.selectByExample(example);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.mapper.SupervisorTeachingDetailMapper;
import cn.com.glsx.dj.supervisor.model.SupervisorTeachingDetail;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import tk.mybatis.mapper.entity.Example;
import java.util.List;
@Service
@Slf4j
public class SupervisorTeachingDetailService {
@Autowired
private SupervisorTeachingDetailMapper supervisorTeachingDetailMapper;
/**
* 根据任务ID查询带教详情
*
* @param taskId
* @return
*/
public SupervisorTeachingDetail selectByTaskId(Long taskId) {
Example example = new Example(SupervisorTeachingDetail.class);
example.createCriteria().andEqualTo("taskId", taskId);
return supervisorTeachingDetailMapper.selectOneByExample(example);
}
}
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.enums.*;
import cn.com.glsx.dj.supervisor.mapper.SupervisorWorkbenchReportMapper;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.RpcAssert;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.time.DayOfWeek;
import java.time.LocalDate;
import java.time.YearMonth;
import java.time.format.DateTimeFormatter;
import java.time.temporal.ChronoUnit;
import java.time.temporal.TemporalAdjusters;
import java.util.*;
import java.util.stream.Collectors;
/**
* 工作台报表服务
*/
@Service
@Slf4j
public class SupervisorWorkbenchReportService {
private static final DateTimeFormatter DATE_FMT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
@Autowired
private SupervisorWorkbenchReportMapper workbenchReportMapper;
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private Environment env;
public WorkbenchReportDTO getWorkbenchReport(WorkbenchReportQueryDTO query) {
RpcAssert.assertNotNull(query, DefaultErrorEnum.PARAMETER_NULL, "查询参数不能为空");
RpcAssert.assertNotNull(query.getReportType(), DefaultErrorEnum.PARAMETER_NULL, "报表类型不能为空");
RpcAssert.assertNotNull(query.getStartDate(), DefaultErrorEnum.PARAMETER_NULL, "开始日期不能为空");
RpcAssert.assertNotNull(query.getEndDate(), DefaultErrorEnum.PARAMETER_NULL, "结束日期不能为空");
WorkbenchReportTypeEnum reportType = WorkbenchReportTypeEnum.of(query.getReportType());
if (reportType == null) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, "报表类型不合法");
}
LocalDate start = LocalDate.parse(query.getStartDate(), DATE_FMT);
LocalDate end = LocalDate.parse(query.getEndDate(), DATE_FMT);
if (start.isAfter(end)) {
throw new RpcServiceException(DefaultErrorEnum.PARAMETER_NULL, "开始日期不能晚于结束日期");
}
int reviewRatioThreshold = env.getProperty("supervisor_audio_review_complete_ratio", Integer.class, 50);
int coachingLimit = env.getProperty("supervisor.weektask.coachingRequirementLimit", Integer.class, 6);
int excellentLimit = env.getProperty("supervisor.weektask.excellentCaseLimit", Integer.class, 2);
// 获取所有督导人员列表
List<MerchantStaffResponse> allSupervisors = supervisorTaskInfoService.listAllEffectiveSupervisors();
if (CollectionUtils.isEmpty(allSupervisors)) {
return emptyReport(query, reportType);
}
// 根据报表类型获取所有需要查询的类型
List<Integer> taskTypes = resolveTaskTypes(reportType);
// 查询督导任务数据
List<WorkbenchReportTaskRowDTO> taskRows = workbenchReportMapper.listTasksByDateRangeAndTypes(
query.getStartDate(), query.getEndDate(), taskTypes);
// 统计带教场景(线上/线下)数量
List<WorkbenchTeachingCountDTO> teachingCounts = workbenchReportMapper.countTeachingByScene(
query.getStartDate(), query.getEndDate());
// 统计录音复盘数量
List<WorkbenchAudioReviewStatDTO> audioStats = workbenchReportMapper.listAudioReviewStats(
query.getStartDate(), query.getEndDate());
// 优秀案例录音提报
List<WorkbenchExcellentCaseCountDTO> excellentCaseCounts = null;
if (reportType == WorkbenchReportTypeEnum.WEEK || reportType == WorkbenchReportTypeEnum.MONTH) {
excellentCaseCounts = workbenchReportMapper.countExcellentCaseGroupBySubmitterName(
query.getStartDate(), query.getEndDate());
}
TaskDataIndex dataIndex = new TaskDataIndex(taskRows, teachingCounts, audioStats,
excellentCaseCounts, reviewRatioThreshold);
List<WorkbenchReportSupervisorItemDTO> allItems = new ArrayList<>();
for (MerchantStaffResponse staff : allSupervisors) {
String name = staff.getStaffName();
// 专项任务此人没有数据不显示
if (reportType == WorkbenchReportTypeEnum.SPECIAL) {
if (!dataIndex.hasSpecialTask(name)) {
continue;
}
}
// 构建人员数据
WorkbenchReportSupervisorItemDTO item = buildItem(
staff, reportType, start, end, dataIndex, coachingLimit, excellentLimit);
allItems.add(item);
}
// 统计各个任务人数
WorkbenchReportStatisticsDTO statistics = buildStatistics(allItems, reportType);
// 按督导姓名进行过滤并排序
String nameFilter = query.getSupervisorName();
List<WorkbenchReportSupervisorItemDTO> filteredList = allItems;
if (StringUtils.isNotBlank(nameFilter)) {
filteredList = allItems.stream()
.filter(i -> i.getSupervisorName() != null && i.getSupervisorName().contains(nameFilter.trim()))
.collect(Collectors.toList());
}
sortSupervisorList(filteredList);
WorkbenchReportDTO result = new WorkbenchReportDTO();
result.setReportType(query.getReportType());
result.setStartDate(query.getStartDate());
result.setEndDate(query.getEndDate());
result.setStatistics(statistics);
result.setSupervisorList(filteredList);
return result;
}
private WorkbenchReportDTO emptyReport(WorkbenchReportQueryDTO query, WorkbenchReportTypeEnum reportType) {
WorkbenchReportStatisticsDTO statistics = new WorkbenchReportStatisticsDTO();
statistics.setCompletedCount(0);
statistics.setPartialCompletedCount(0);
statistics.setUnfinishedCount(0);
WorkbenchReportDTO dto = new WorkbenchReportDTO();
dto.setReportType(query.getReportType());
dto.setStartDate(query.getStartDate());
dto.setEndDate(query.getEndDate());
dto.setStatistics(statistics);
dto.setSupervisorList(Collections.emptyList());
return dto;
}
private List<Integer> resolveTaskTypes(WorkbenchReportTypeEnum reportType) {
switch (reportType) {
case TODAY:
return Arrays.asList(
TaskTypeEnum.DAILY_REPORT.getCode(),
TaskTypeEnum.AUDIO_RECORDING.getCode(),
TaskTypeEnum.TRAINING.getCode());
case WEEK:
return Arrays.asList(
TaskTypeEnum.DAILY_REPORT.getCode(),
TaskTypeEnum.AUDIO_RECORDING.getCode(),
TaskTypeEnum.TRAINING.getCode());
case MONTH:
return Arrays.asList(
TaskTypeEnum.DAILY_REPORT.getCode(),
TaskTypeEnum.AUDIO_RECORDING.getCode(),
TaskTypeEnum.TRAINING.getCode(),
TaskTypeEnum.MONTHLY_REPORT.getCode());
case SPECIAL:
return Collections.singletonList(TaskTypeEnum.SPECIAL_RECORDING.getCode());
default:
return Collections.emptyList();
}
}
private WorkbenchReportSupervisorItemDTO buildItem(MerchantStaffResponse staff,
WorkbenchReportTypeEnum reportType,
LocalDate start, LocalDate end,
TaskDataIndex dataIndex,
int coachingLimit, int excellentLimit) {
String name = staff.getStaffName();
WorkbenchReportSupervisorItemDTO item = new WorkbenchReportSupervisorItemDTO();
item.setSupervisorName(name);
item.setSupervisorPhone(staff.getStaffPhone());
item.setSupervisorUuid(staff.getUuid());
int completedSubTasks;
int totalSubTasks;
switch (reportType) {
case TODAY:
fillTodayFields(item, name, start, end, dataIndex);
completedSubTasks = countCompletedSubTasks(
item.getDailyReportStatus() != null && item.getDailyReportStatus() > 0,
Boolean.TRUE.equals(item.getDefeatReviewCompleted()));
totalSubTasks = 2;
break;
case WEEK:
int weekElapsedDays = calcElapsedDays(start, end);
fillWeekFields(item, name, start, end, weekElapsedDays, dataIndex, coachingLimit, excellentLimit);
completedSubTasks = countCompletedSubTasks(
Boolean.TRUE.equals(item.getDailyReportTaskCompleted()),
Boolean.TRUE.equals(item.getReviewTaskCompleted()),
Boolean.TRUE.equals(item.getTeachingTaskCompleted()),
Boolean.TRUE.equals(item.getExcellentCaseTaskCompleted()));
totalSubTasks = 4;
break;
case MONTH:
int monthElapsedDays = calcElapsedDays(start, end);
List<LocalDate[]> weeksInMonth = getWeeksWithSundayInMonth(YearMonth.from(start));
int elapsedWeeks = calcElapsedWeeks(weeksInMonth, end);
fillMonthFields(item, name, start, end, monthElapsedDays, weeksInMonth, elapsedWeeks,
dataIndex, coachingLimit, excellentLimit);
completedSubTasks = countCompletedSubTasks(
Boolean.TRUE.equals(item.getDailyReportTaskCompleted()),
Boolean.TRUE.equals(item.getReviewTaskCompleted()),
Boolean.TRUE.equals(item.getTeachingTaskCompleted()),
Boolean.TRUE.equals(item.getExcellentCaseTaskCompleted()),
item.getMonthReportStatus() != null && item.getMonthReportStatus() == 1);
totalSubTasks = 5;
break;
case SPECIAL:
fillSpecialFields(item, name, dataIndex);
List<WorkbenchReportTaskRowDTO> specialTasks = dataIndex.getSpecialTasks(name);
long specialCompleted = specialTasks.stream()
.filter(t -> TaskStatusEnum.COMPLETED.getCode().equals(t.getTaskStatus()))
.count();
completedSubTasks = (int) specialCompleted;
totalSubTasks = specialTasks.size();
break;
default:
completedSubTasks = 0;
totalSubTasks = 0;
}
WorkbenchCompletionStatusEnum status = resolveCompletionStatus(
reportType, completedSubTasks, totalSubTasks);
item.setCompletionStatus(status.getCode());
item.setCompletionStatusName(status.getName());
return item;
}
private void fillTodayFields(WorkbenchReportSupervisorItemDTO item, String name,
LocalDate start, LocalDate end, TaskDataIndex dataIndex) {
WorkbenchReportTaskRowDTO daily = dataIndex.getSubmittedDailyReport(name, start, end);
if (daily == null) {
item.setDailyReportStatus(WorkbenchDailyReportStatusEnum.NOT_SUBMITTED.getCode());
item.setDailyReportStatusName(WorkbenchDailyReportStatusEnum.NOT_SUBMITTED.getName());
item.setDailyReportDetailEnabled(false);
} else {
item.setDailyReportTaskId(daily.getId());
item.setDailyReportDetailEnabled(true);
if (Integer.valueOf(1).equals(daily.getOnDutyFlag())) {
item.setDailyReportStatus(WorkbenchDailyReportStatusEnum.REST.getCode());
item.setDailyReportStatusName(WorkbenchDailyReportStatusEnum.REST.getName());
} else {
item.setDailyReportStatus(WorkbenchDailyReportStatusEnum.ON_DUTY.getCode());
item.setDailyReportStatusName(WorkbenchDailyReportStatusEnum.ON_DUTY.getName());
}
}
int reviewRate = dataIndex.getDefeatReviewRate(name, start, end);
item.setDefeatReviewRate(reviewRate);
item.setDefeatReviewCompleted(reviewRate >= dataIndex.reviewRatioThreshold);
item.setOnlineTeachingCount(dataIndex.getTeachingCount(name, WorkbenchSceneCodeEnum.ONLINE.getCode()));
item.setOfflineTeachingCount(dataIndex.getTeachingCount(name, WorkbenchSceneCodeEnum.OFFLINE.getCode()));
}
private void fillWeekFields(WorkbenchReportSupervisorItemDTO item, String name,
LocalDate start, LocalDate end, int elapsedDays,
TaskDataIndex dataIndex, int coachingLimit, int excellentLimit) {
int dailySubmitted = dataIndex.countSubmittedDailyReportDays(name, start, end);
item.setDailyReportProgress(dailySubmitted + "/" + elapsedDays);
item.setDailyReportTaskCompleted(elapsedDays > 0 && dailySubmitted >= elapsedDays);
int reviewCompletedDays = dataIndex.countReviewCompletedDays(name, start, end);
item.setReviewTaskProgress(reviewCompletedDays + "/" + elapsedDays);
item.setReviewTaskCompleted(elapsedDays > 0 && reviewCompletedDays >= elapsedDays);
int coachingCount = dataIndex.countTrainingRecords(name, start, end);
item.setTeachingTaskProgress(coachingCount + "/" + coachingLimit);
item.setTeachingTaskCompleted(coachingCount >= coachingLimit);
int excellentCount = dataIndex.countExcellentCaseRecords(name, start, end);
item.setExcellentCaseProgress(excellentCount + "/" + excellentLimit);
item.setExcellentCaseTaskCompleted(excellentCount >= excellentLimit);
}
private void fillMonthFields(WorkbenchReportSupervisorItemDTO item, String name,
LocalDate start, LocalDate end, int elapsedDays,
List<LocalDate[]> weeksInMonth, int elapsedWeeks,
TaskDataIndex dataIndex, int coachingLimit, int excellentLimit) {
fillWeekFields(item, name, start, end, elapsedDays, dataIndex, coachingLimit, excellentLimit);
int coachingCompletedWeeks = 0;
int excellentCompletedWeeks = 0;
LocalDate today = LocalDate.now();
for (LocalDate[] week : weeksInMonth) {
LocalDate weekStart = week[0];
LocalDate weekEnd = week[1];
if (weekStart.isAfter(today)) {
continue;
}
LocalDate effectiveEnd = weekEnd.isAfter(today) ? today : weekEnd;
int weekCoaching = dataIndex.countTrainingRecords(name, weekStart, effectiveEnd);
if (weekCoaching >= coachingLimit) {
coachingCompletedWeeks++;
}
int weekExcellent = dataIndex.countExcellentCaseRecords(name, weekStart, effectiveEnd);
if (weekExcellent >= excellentLimit) {
excellentCompletedWeeks++;
}
}
item.setTeachingTaskProgress(coachingCompletedWeeks + "/" + elapsedWeeks);
item.setTeachingTaskCompleted(elapsedWeeks > 0 && coachingCompletedWeeks >= elapsedWeeks);
item.setExcellentCaseProgress(excellentCompletedWeeks + "/" + elapsedWeeks);
item.setExcellentCaseTaskCompleted(elapsedWeeks > 0 && excellentCompletedWeeks >= elapsedWeeks);
WorkbenchReportTaskRowDTO monthReport = dataIndex.getSubmittedMonthReport(name, start, end);
if (monthReport == null) {
item.setMonthReportStatus(WorkbenchSubmitStatusEnum.NOT_SUBMITTED.getCode());
item.setMonthReportStatusName(WorkbenchSubmitStatusEnum.NOT_SUBMITTED.getName());
item.setMonthReportDetailEnabled(false);
} else {
item.setMonthReportStatus(WorkbenchSubmitStatusEnum.SUBMITTED.getCode());
item.setMonthReportStatusName(WorkbenchSubmitStatusEnum.SUBMITTED.getName());
item.setMonthReportTaskId(monthReport.getId());
item.setMonthReportDetailEnabled(true);
}
}
private void fillSpecialFields(WorkbenchReportSupervisorItemDTO item, String name, TaskDataIndex dataIndex) {
List<WorkbenchReportTaskRowDTO> specialTasks = dataIndex.getSpecialTasks(name);
long completed = specialTasks.stream()
.filter(t -> TaskStatusEnum.COMPLETED.getCode().equals(t.getTaskStatus()))
.count();
item.setSpecialTaskProgress(completed + "/" + specialTasks.size());
item.setSpecialTaskCompleted(!specialTasks.isEmpty() && completed == specialTasks.size());
List<WorkbenchSpecialTaskItemDTO> taskList = specialTasks.stream().map(t -> {
WorkbenchSpecialTaskItemDTO dto = new WorkbenchSpecialTaskItemDTO();
dto.setTaskId(t.getId());
dto.setMerchantName(t.getMerchantName());
dto.setTaskDesc(t.getTaskDesc());
dto.setTaskContext(t.getTaskContext());
dto.setTaskStatus(t.getTaskStatus());
dto.setCreateTime(t.getCreateTime());
dto.setUpdatedDate(t.getUpdatedDate());
return dto;
}).collect(Collectors.toList());
item.setSpecialTaskList(taskList);
}
private WorkbenchCompletionStatusEnum resolveCompletionStatus(WorkbenchReportTypeEnum reportType,
int completedSubTasks, int totalSubTasks) {
if (totalSubTasks == 0) {
return WorkbenchCompletionStatusEnum.UNFINISHED;
}
if (reportType == WorkbenchReportTypeEnum.SPECIAL) {
return completedSubTasks >= totalSubTasks
? WorkbenchCompletionStatusEnum.COMPLETED
: WorkbenchCompletionStatusEnum.UNFINISHED;
}
if (completedSubTasks >= totalSubTasks) {
return WorkbenchCompletionStatusEnum.COMPLETED;
}
if (completedSubTasks > 0) {
return WorkbenchCompletionStatusEnum.PARTIAL;
}
return WorkbenchCompletionStatusEnum.UNFINISHED;
}
private int countCompletedSubTasks(boolean... flags) {
int count = 0;
for (boolean flag : flags) {
if (flag) {
count++;
}
}
return count;
}
private WorkbenchReportStatisticsDTO buildStatistics(List<WorkbenchReportSupervisorItemDTO> allItems,
WorkbenchReportTypeEnum reportType) {
WorkbenchReportStatisticsDTO statistics = new WorkbenchReportStatisticsDTO();
int completed = 0;
int partial = 0;
int unfinished = 0;
for (WorkbenchReportSupervisorItemDTO item : allItems) {
if (WorkbenchCompletionStatusEnum.COMPLETED.getCode().equals(item.getCompletionStatus())) {
completed++;
} else if (WorkbenchCompletionStatusEnum.PARTIAL.getCode().equals(item.getCompletionStatus())) {
partial++;
} else {
unfinished++;
}
}
statistics.setCompletedCount(completed);
statistics.setPartialCompletedCount(reportType == WorkbenchReportTypeEnum.SPECIAL ? null : partial);
statistics.setUnfinishedCount(unfinished);
return statistics;
}
private void sortSupervisorList(List<WorkbenchReportSupervisorItemDTO> list) {
list.sort(Comparator
.comparing(WorkbenchReportSupervisorItemDTO::getCompletionStatus,
Comparator.nullsLast(Comparator.naturalOrder()))
.thenComparing(WorkbenchReportSupervisorItemDTO::getSupervisorName,
Comparator.nullsLast(String::compareTo)));
}
private int calcElapsedDays(LocalDate start, LocalDate end) {
LocalDate today = LocalDate.now();
LocalDate effectiveEnd = end.isAfter(today) ? today : end;
if (effectiveEnd.isBefore(start)) {
return 0;
}
return (int) ChronoUnit.DAYS.between(start, effectiveEnd) + 1;
}
/**
* 获取月份内「周日落在该月」的自然周(周一-周日)
*/
private List<LocalDate[]> getWeeksWithSundayInMonth(YearMonth yearMonth) {
LocalDate first = yearMonth.atDay(1);
LocalDate last = yearMonth.atEndOfMonth();
List<LocalDate[]> weeks = new ArrayList<>();
LocalDate monday = first.with(TemporalAdjusters.previousOrSame(DayOfWeek.MONDAY));
while (!monday.isAfter(last)) {
LocalDate sunday = monday.plusDays(6);
if (YearMonth.from(sunday).equals(yearMonth)) {
weeks.add(new LocalDate[]{monday, sunday});
}
monday = monday.plusWeeks(1);
}
return weeks;
}
private int calcElapsedWeeks(List<LocalDate[]> weeksInMonth, LocalDate rangeEnd) {
LocalDate today = LocalDate.now();
LocalDate effectiveEnd = rangeEnd.isAfter(today) ? today : rangeEnd;
int count = 0;
for (LocalDate[] week : weeksInMonth) {
if (!week[0].isAfter(effectiveEnd)) {
count++;
}
}
return count;
}
/**
* 任务数据索引,加速按督导聚合
*/
private static class TaskDataIndex {
private final int reviewRatioThreshold;
private final Map<String, List<WorkbenchReportTaskRowDTO>> tasksByName;
private final Map<String, Map<String, Integer>> teachingByNameAndScene;
private final Map<String, List<WorkbenchAudioReviewStatDTO>> audioByName;
private final Map<String, Map<String, Integer>> excellentCaseCountByNameAndDate;
TaskDataIndex(List<WorkbenchReportTaskRowDTO> tasks,
List<WorkbenchTeachingCountDTO> teachingCounts,
List<WorkbenchAudioReviewStatDTO> audioStats,
List<WorkbenchExcellentCaseCountDTO> excellentCaseCounts,
int reviewRatioThreshold) {
this.reviewRatioThreshold = reviewRatioThreshold;
this.tasksByName = tasks.stream()
.filter(t -> StringUtils.isNotBlank(t.getSupervisorName()))
.collect(Collectors.groupingBy(WorkbenchReportTaskRowDTO::getSupervisorName));
this.teachingByNameAndScene = new HashMap<>();
if (teachingCounts != null) {
for (WorkbenchTeachingCountDTO tc : teachingCounts) {
teachingByNameAndScene
.computeIfAbsent(tc.getSupervisorName(), k -> new HashMap<>())
.put(tc.getTeachingSceneCode(), tc.getCount() == null ? 0 : tc.getCount());
}
}
this.audioByName = audioStats == null ? Collections.emptyMap() :
audioStats.stream()
.filter(a -> StringUtils.isNotBlank(a.getSupervisorName()))
.collect(Collectors.groupingBy(WorkbenchAudioReviewStatDTO::getSupervisorName));
this.excellentCaseCountByNameAndDate = new HashMap<>();
if (excellentCaseCounts != null) {
for (WorkbenchExcellentCaseCountDTO ec : excellentCaseCounts) {
if (StringUtils.isNotBlank(ec.getSubmitterName()) && StringUtils.isNotBlank(ec.getSubmitDate())) {
excellentCaseCountByNameAndDate
.computeIfAbsent(ec.getSubmitterName(), k -> new HashMap<>())
.put(ec.getSubmitDate(), ec.getCount() == null ? 0 : ec.getCount());
}
}
}
}
boolean hasSpecialTask(String name) {
return getSpecialTasks(name).size() > 0;
}
List<WorkbenchReportTaskRowDTO> getSpecialTasks(String name) {
return tasksByName.getOrDefault(name, Collections.emptyList()).stream()
.filter(t -> TaskTypeEnum.SPECIAL_RECORDING.getCode().equals(t.getTaskType()))
.collect(Collectors.toList());
}
WorkbenchReportTaskRowDTO getSubmittedDailyReport(String name, LocalDate start, LocalDate end) {
return tasksByName.getOrDefault(name, Collections.emptyList()).stream()
.filter(t -> TaskTypeEnum.DAILY_REPORT.getCode().equals(t.getTaskType()))
.filter(t -> TaskStatusEnum.COMPLETED.getCode().equals(t.getTaskStatus()))
.filter(t -> isDateInRange(t.getTaskDate(), start, end))
.max(Comparator.comparing(WorkbenchReportTaskRowDTO::getCreateTime,
Comparator.nullsFirst(Comparator.naturalOrder())))
.orElse(null);
}
WorkbenchReportTaskRowDTO getSubmittedMonthReport(String name, LocalDate start, LocalDate end) {
return tasksByName.getOrDefault(name, Collections.emptyList()).stream()
.filter(t -> TaskTypeEnum.MONTHLY_REPORT.getCode().equals(t.getTaskType()))
.filter(t -> TaskStatusEnum.COMPLETED.getCode().equals(t.getTaskStatus()))
.filter(t -> isDateInRange(t.getTaskDate(), start, end))
.findFirst()
.orElse(null);
}
int countSubmittedDailyReportDays(String name, LocalDate start, LocalDate end) {
Set<String> days = tasksByName.getOrDefault(name, Collections.emptyList()).stream()
.filter(t -> TaskTypeEnum.DAILY_REPORT.getCode().equals(t.getTaskType()))
.filter(t -> TaskStatusEnum.COMPLETED.getCode().equals(t.getTaskStatus()))
.map(WorkbenchReportTaskRowDTO::getTaskDate)
.filter(d -> isDateInRange(d, start, end))
.collect(Collectors.toSet());
return days.size();
}
int countReviewCompletedDays(String name, LocalDate start, LocalDate end) {
LocalDate today = LocalDate.now();
LocalDate effectiveEnd = end.isAfter(today) ? today : end;
int count = 0;
for (LocalDate day = start; !day.isAfter(effectiveEnd); day = day.plusDays(1)) {
if (getDefeatReviewRate(name, day, day) >= reviewRatioThreshold) {
count++;
}
}
return count;
}
int getDefeatReviewRate(String name, LocalDate start, LocalDate end) {
List<WorkbenchAudioReviewStatDTO> stats = audioByName.getOrDefault(name, Collections.emptyList()).stream()
.filter(s -> isDateInRange(s.getTaskDate(), start, end))
.collect(Collectors.toList());
if (stats.isEmpty()) {
return 100;
}
int total = stats.stream().mapToInt(s -> s.getTotalCount() == null ? 0 : s.getTotalCount()).sum();
int reviewed = stats.stream().mapToInt(s -> s.getReviewedCount() == null ? 0 : s.getReviewedCount()).sum();
if (total == 0) {
return 100;
}
return reviewed * 100 / total;
}
int getTeachingCount(String name, String sceneCode) {
Map<String, Integer> sceneMap = teachingByNameAndScene.get(name);
if (sceneMap == null) {
return 0;
}
return sceneMap.getOrDefault(sceneCode, 0);
}
int countTrainingRecords(String name, LocalDate start, LocalDate end) {
return (int) tasksByName.getOrDefault(name, Collections.emptyList()).stream()
.filter(t -> TaskTypeEnum.TRAINING.getCode().equals(t.getTaskType()))
.filter(t -> isDateInRange(t.getTaskDate(), start, end))
.count();
}
/**
* 优秀案例录音提报数
*/
int countExcellentCaseRecords(String name, LocalDate start, LocalDate end) {
Map<String, Integer> dateCountMap = excellentCaseCountByNameAndDate.get(name);
if (dateCountMap == null || dateCountMap.isEmpty()) {
return 0;
}
int total = 0;
for (Map.Entry<String, Integer> entry : dateCountMap.entrySet()) {
if (isDateInRange(entry.getKey(), start, end)) {
total += entry.getValue();
}
}
return total;
}
private static boolean isDateInRange(String dateStr, LocalDate start, LocalDate end) {
if (StringUtils.isBlank(dateStr)) {
return false;
}
LocalDate d = LocalDate.parse(dateStr, DATE_FMT);
return !d.isBefore(start) && !d.isAfter(end);
}
}
}
...@@ -108,7 +108,8 @@ ...@@ -108,7 +108,8 @@
t7.review_time, t7.review_time,
t7.review_comment, t7.review_comment,
t7.create_time, t7.create_time,
t7.updated_date t7.updated_date,
t2.id as recording_id
FROM reception_customer_info t1 FROM reception_customer_info t1
LEFT JOIN inspection_badge_recordings t2 ON t1.id = t2.reception_id LEFT JOIN inspection_badge_recordings t2 ON t1.id = t2.reception_id
LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id
...@@ -135,6 +136,15 @@ ...@@ -135,6 +136,15 @@
<if test="query.reviewStatus != null"> <if test="query.reviewStatus != null">
and t7.review_status = #{query.reviewStatus} and t7.review_status = #{query.reviewStatus}
</if> </if>
<if test="query.submitterId != null and query.submitterId != ''">
and t7.submitter_id = #{query.submitterId}
</if>
<if test="query.startDate != null and query.startDate != ''">
and CAST(t7.create_time AS DATE) &gt;= #{query.startDate, jdbcType=DATE}
</if>
<if test="query.endDate != null and query.endDate != ''">
and CAST(t7.create_time AS DATE) &lt;= #{query.endDate, jdbcType=DATE}
</if>
order by t7.create_time desc order by t7.create_time desc
</select> </select>
...@@ -218,4 +228,13 @@ ...@@ -218,4 +228,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
...@@ -24,6 +24,10 @@ ...@@ -24,6 +24,10 @@
<result column="task_desc" property="taskDesc" jdbcType="VARCHAR" /> <result column="task_desc" property="taskDesc" jdbcType="VARCHAR" />
<result column="store_manager_phone" property="storeManagerPhone" jdbcType="VARCHAR" /> <result column="store_manager_phone" property="storeManagerPhone" jdbcType="VARCHAR" />
<result column="store_manager_name" property="storeManagerName" jdbcType="VARCHAR" /> <result column="store_manager_name" property="storeManagerName" jdbcType="VARCHAR" />
<result column="next_work_items" property="nextWorkItems"/>
<result column="need_assist_items" property="needAssistItems"/>
<result column="teaching_progress" property="teachingProgress"/>
<result column="next_month_plan" property="nextMonthPlan"/>
</resultMap> </resultMap>
<resultMap id="ResultMapWithBLOBs" type="cn.com.glsx.dj.supervisor.model.SupervisorTaskInfo" extends="BaseResultMap" > <resultMap id="ResultMapWithBLOBs" type="cn.com.glsx.dj.supervisor.model.SupervisorTaskInfo" extends="BaseResultMap" >
<!-- <!--
...@@ -49,6 +53,12 @@ ...@@ -49,6 +53,12 @@
<result column="store_manager_phone" property="storeManagerPhone" jdbcType="VARCHAR" /> <result column="store_manager_phone" property="storeManagerPhone" jdbcType="VARCHAR" />
<result column="store_manager_name" property="storeManagerName" jdbcType="VARCHAR" /> <result column="store_manager_name" property="storeManagerName" jdbcType="VARCHAR" />
<result column="start_date" property="startDate"/> <result column="start_date" property="startDate"/>
<result column="end_date" property="endDate"/>
<result column="supervisor_uuid" property="supervisorUuid"/>
<result column="next_work_items" property="nextWorkItems"/>
<result column="need_assist_items" property="needAssistItems"/>
<result column="teaching_progress" property="teachingProgress"/>
<result column="next_month_plan" property="nextMonthPlan"/>
<collection property="taskImageList" ofType="cn.com.glsx.dj.supervisor.model.SupervisorTaskImage"> <collection property="taskImageList" ofType="cn.com.glsx.dj.supervisor.model.SupervisorTaskImage">
<result column="image_url" property="imageUrl" /> <result column="image_url" property="imageUrl" />
</collection> </collection>
...@@ -65,7 +75,8 @@ ...@@ -65,7 +75,8 @@
--> -->
id, task_type, task_status, on_duty_flag, merchant_id, merchant_name, start_date, end_date, id, task_type, task_status, on_duty_flag, merchant_id, merchant_name, start_date, end_date,
supervisor_phone, supervisor_name, created_by, create_time, updated_by, updated_phone, supervisor_phone, supervisor_name, created_by, create_time, updated_by, updated_phone,
updated_date, deleted_flag, task_desc, store_manager_phone, store_manager_name updated_date, deleted_flag, task_desc, store_manager_phone, store_manager_name,
teaching_progress, next_month_plan
</sql> </sql>
<sql id="Blob_Column_List" > <sql id="Blob_Column_List" >
<!-- <!--
...@@ -76,7 +87,7 @@ ...@@ -76,7 +87,7 @@
<select id="getTaskDetailById" resultMap="TaskDetailMap"> <select id="getTaskDetailById" resultMap="TaskDetailMap">
select sti.id, sti.task_type, sti.task_status, sti.on_duty_flag, sti.merchant_id, sti.merchant_name, sti.task_desc,sti.task_context,sti.create_time,sti.updated_date, select sti.id, sti.task_type, sti.task_status, sti.on_duty_flag, sti.merchant_id, sti.merchant_name, sti.task_desc,sti.task_context,sti.create_time,sti.updated_date,
stim.image_url,sti.store_manager_name,sti.store_manager_phone,sti.updated_by,sti.start_date stim.image_url,sti.store_manager_name,sti.store_manager_phone,sti.updated_by,sti.start_date,sti.next_work_items,sti.need_assist_items,sti.teaching_progress,sti.next_month_plan
from supervisor_task_info sti from supervisor_task_info sti
left join supervisor_task_image stim on stim.relation_id = sti.id and stim.deleted_flag = 'N' left join supervisor_task_image stim on stim.relation_id = sti.id and stim.deleted_flag = 'N'
<where> <where>
...@@ -86,7 +97,8 @@ ...@@ -86,7 +97,8 @@
<select id="listTask" parameterType="cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO" resultMap="TaskDetailMap"> <select id="listTask" parameterType="cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO" resultMap="TaskDetailMap">
select sti.id, sti.task_type, sti.task_status,sti.updated_date,sti.updated_phone, sti.updated_by, sti.store_manager_name, select sti.id, sti.task_type, sti.task_status,sti.updated_date,sti.updated_phone, sti.updated_by, sti.store_manager_name,
sti.task_desc,sti.task_context, sti.merchant_name, sti.create_time sti.task_desc,sti.task_context, sti.merchant_name, sti.create_time, sti.start_date, sti.end_date, sti.supervisor_uuid,
sti.teaching_progress,sti.next_month_plan
from supervisor_task_info sti from supervisor_task_info sti
<where> <where>
sti.deleted_flag = 'N' sti.deleted_flag = 'N'
...@@ -154,20 +166,20 @@ ...@@ -154,20 +166,20 @@
</select> </select>
<select id="queryCoachingTimes" resultType="cn.com.glsx.dj.supervisor.dto.MapperQueryEmployeeTrainingInfoDTO"> <select id="queryCoachingTimes" resultType="cn.com.glsx.dj.supervisor.dto.MapperQueryEmployeeTrainingInfoDTO">
SELECT SELECT
store_manager_phone AS phone, tp.participant_phone AS phone,
COUNT(*) AS coachingTimes COUNT(DISTINCT ti.id) AS coachingTimes
FROM supervisor_task_info FROM supervisor_task_participant tp
WHERE INNER JOIN supervisor_task_info ti ON ti.id = tp.task_id AND ti.deleted_flag = 'N'
store_manager_phone IN WHERE tp.deleted_flag = 'N'
AND tp.participant_phone IN
<foreach collection="phoneList" open="(" item="i" close=")" separator=","> <foreach collection="phoneList" open="(" item="i" close=")" separator=",">
#{i} #{i}
</foreach> </foreach>
AND task_type = 5 AND ti.task_type = 5
AND task_status = 2 AND ti.task_status = 2
AND cast(create_time as date) &gt;= #{startDate, jdbcType=DATE} AND cast(ti.create_time as date) &gt;= #{startDate, jdbcType=DATE}
AND cast(create_time as date) &lt;= #{endDate, jdbcType=DATE} AND cast(ti.create_time as date) &lt;= #{endDate, jdbcType=DATE}
AND deleted_flag = 'N' GROUP BY tp.participant_phone
GROUP BY store_manager_phone
</select> </select>
<select id="queryCourseTrainingList" resultType="cn.com.glsx.dj.supervisor.dto.TrainingListDTO"> <select id="queryCourseTrainingList" resultType="cn.com.glsx.dj.supervisor.dto.TrainingListDTO">
...@@ -190,19 +202,25 @@ ...@@ -190,19 +202,25 @@
<select id="queryCoachingTrainingList" resultType="cn.com.glsx.dj.supervisor.dto.TrainingListDTO"> <select id="queryCoachingTrainingList" resultType="cn.com.glsx.dj.supervisor.dto.TrainingListDTO">
SELECT SELECT
id AS taskId, ti.id AS taskId,
DATE_FORMAT(create_time, '%Y-%m-%d %H:%i:%s') AS completedTime DATE_FORMAT(ti.create_time, '%Y-%m-%d %H:%i:%s') AS completedTime
FROM supervisor_task_info FROM supervisor_task_info ti
WHERE deleted_flag = 'N' WHERE ti.deleted_flag = 'N'
AND task_type = 5 AND ti.task_type = 5
AND store_manager_phone = #{storeManagerPhone} AND EXISTS (
SELECT 1
FROM supervisor_task_participant tp
WHERE tp.task_id = ti.id
AND tp.participant_phone = #{storeManagerPhone}
AND tp.deleted_flag = 'N'
)
<if test="startDate != null and startDate != ''"> <if test="startDate != null and startDate != ''">
AND CAST(create_time AS DATE) &gt;= #{startDate, jdbcType=DATE} AND CAST(ti.create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
</if> </if>
<if test="endDate != null and endDate != ''"> <if test="endDate != null and endDate != ''">
AND CAST(create_time AS DATE) &lt;= #{endDate, jdbcType=DATE} AND CAST(ti.create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
</if> </if>
ORDER BY create_time DESC ORDER BY ti.create_time DESC
</select> </select>
<select id="queryMerchantBySupervisorPhone" resultType="java.lang.Integer"> <select id="queryMerchantBySupervisorPhone" resultType="java.lang.Integer">
SELECT DISTINCT merchant_id SELECT DISTINCT merchant_id
...@@ -249,12 +267,137 @@ ...@@ -249,12 +267,137 @@
SELECT merchant_id, director_type, director_user_id, director_name, director_phone SELECT merchant_id, director_type, director_user_id, director_name, director_phone
FROM dj_car_life_shop_merchant_director_config FROM dj_car_life_shop_merchant_director_config
WHERE deleted_flag = 'N' WHERE deleted_flag = 'N'
AND director_type = 6 AND director_type in (6, 13)
AND director_phone in AND director_phone in
<foreach collection="supervisorPhoneList" open="(" item="i" close=")" separator=","> <foreach collection="supervisorPhoneList" open="(" item="i" close=")" separator=",">
#{i} #{i}
</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>
<select id="countUnfinishedByTaskTypes" resultType="java.util.HashMap">
SELECT CAST(task_type AS SIGNED) AS taskType, COUNT(*) AS count
FROM supervisor_task_info
WHERE deleted_flag = 'N'
AND supervisor_phone = #{supervisorPhone}
AND task_status != 2
AND task_type IN
<foreach collection="taskTypes" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
<if test="startDate != null and startDate != ''">
AND CAST(create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
</if>
<if test="endDate != null and endDate != ''">
AND CAST(create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
</if>
GROUP BY task_type
</select>
<resultMap id="teachingListMap" type="cn.com.glsx.dj.supervisor.dto.SupervisorTeachingListDTO">
<result column="id" property="id"/>
<result column="teaching_scene_name" property="teachingSceneName"/>
<result column="teaching_time" property="teachingTime" jdbcType="TIMESTAMP"/>
<result column="teaching_method_name" property="teachingMethodName"/>
<result column="teaching_topic_name" property="teachingTopicName"/>
<result column="merchant_names" property="merchantNames"/>
<result column="participant_names" property="participantNames"/>
</resultMap>
<select id="listTeachingRecords" parameterType="cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO" resultMap="teachingListMap">
SELECT
sti.id,
std.teaching_scene_name,
std.teaching_time,
std.teaching_method_name,
std.teaching_topic_name,
GROUP_CONCAT(DISTINCT stm.merchant_name ORDER BY stm.id SEPARATOR '、') AS merchant_names,
GROUP_CONCAT(DISTINCT stp.participant_name ORDER BY stp.id SEPARATOR '、') AS participant_names
FROM supervisor_task_info sti
INNER JOIN supervisor_teaching_detail std ON std.task_id = sti.id
LEFT JOIN supervisor_task_merchant stm ON stm.relation_id = sti.id AND stm.deleted_flag = 'N'
LEFT JOIN supervisor_task_participant stp ON stp.task_id = sti.id AND stp.deleted_flag = 'N'
<where>
sti.deleted_flag = 'N'
AND sti.task_type = 5
<if test="supervisorPhone != null and supervisorPhone != ''">
AND sti.supervisor_phone = #{supervisorPhone}
</if>
<if test="startDate != null and startDate != ''">
AND CAST(sti.create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
</if>
<if test="endDate != null and endDate != ''">
AND CAST(sti.create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
</if>
</where>
GROUP BY sti.id, std.teaching_scene_name, std.teaching_time, std.teaching_method_name, std.teaching_topic_name
ORDER BY sti.create_time DESC
</select>
<resultMap id="teamStaffResultMap" type="cn.com.glsx.dj.supervisor.dto.SupervisorTeamStaffDTO">
<result column="id" property="id"/>
<result column="staff_name" property="staffName"/>
<result column="staff_phone" property="staffPhone"/>
<result column="hire_type" property="hireType"/>
<result column="entry_time" property="entryTime" jdbcType="TIMESTAMP"/>
<result column="job_type" property="jobType"/>
<result column="title_type" property="titleType"/>
<result column="staff_scene_label" property="staffSceneLabel"/>
<result column="merchant_id" property="merchantId"/>
<result column="merchant_name" property="merchantName"/>
<result column="service_merchant_id" property="serviceMerchantId"/>
<result column="service_merchant_name" property="serviceMerchantName"/>
<result column="yq_merchant_id" property="yqMerchantId"/>
<result column="yq_merchant_name" property="yqMerchantName"/>
<result column="working_status" property="workingStatus"/>
<result column="mentor_name" property="mentorName"/>
<result column="mentor_phone" property="mentorPhone"/>
<result column="created_source" property="createdSource"/>
<result column="remark" property="remark"/>
</resultMap>
<select id="listStaffBaseInfo" parameterType="cn.com.glsx.dj.supervisor.dto.SupervisorTeamStaffQueryDTO" resultMap="teamStaffResultMap">
SELECT
bs.*
FROM
dj_car_life_staff_base_info bs
WHERE
bs.deleted_flag = 'N'
AND bs.working_status = 0
AND EXISTS (
SELECT 1
FROM dj_car_life_shop_merchant_director_config dc
INNER JOIN dj_car_life_staff_account_assign_record ar ON dc.merchant_id = ar.merchant_id
INNER JOIN dj_car_life_staff_account_assign_scene sc ON ar.id = sc.account_record_id
WHERE dc.director_type IN (6, 13)
AND dc.director_phone = #{supervisorPhone}
AND dc.deleted_flag = 'N'
AND ar.deleted_flag = 'N'
AND sc.deleted_flag = 'N'
AND ar.staff_phone = bs.staff_phone
<if test="merchantIdList != null and merchantIdList.size() > 0">
AND dc.merchant_id IN
<foreach collection="merchantIdList" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
AND (
(dc.director_type = 6 AND sc.scene_type = 1)
OR
(dc.director_type = 13 AND sc.scene_type = 0)
)
)
ORDER BY bs.id
</select>
</mapper> </mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.glsx.dj.supervisor.mapper.SupervisorTaskParticipantMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.supervisor.model.SupervisorTaskParticipant" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="task_id" property="taskId" jdbcType="BIGINT" />
<result column="participant_phone" property="participantPhone" jdbcType="VARCHAR" />
<result column="participant_name" property="participantName" jdbcType="VARCHAR" />
<result column="created_by" property="createdBy" jdbcType="VARCHAR" />
<result column="create_time" property="createTime" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" jdbcType="VARCHAR" />
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="deleted_flag" property="deletedFlag" jdbcType="CHAR" />
</resultMap>
<sql id="Base_Column_List" >
id, task_id, participant_phone, participant_name, created_by, create_time, updated_by, updated_date, deleted_flag
</sql>
</mapper>
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.glsx.dj.supervisor.mapper.SupervisorTeachingDetailMapper" >
<resultMap id="BaseResultMap" type="cn.com.glsx.dj.supervisor.model.SupervisorTeachingDetail" >
<id column="id" property="id" jdbcType="BIGINT" />
<result column="task_id" property="taskId" jdbcType="BIGINT" />
<result column="teaching_scene_code" property="teachingSceneCode" jdbcType="VARCHAR" />
<result column="teaching_scene_name" property="teachingSceneName" jdbcType="VARCHAR" />
<result column="teaching_method_code" property="teachingMethodCode" jdbcType="VARCHAR" />
<result column="teaching_method_name" property="teachingMethodName" jdbcType="VARCHAR" />
<result column="teaching_topic_code" property="teachingTopicCode" jdbcType="VARCHAR" />
<result column="teaching_topic_name" property="teachingTopicName" jdbcType="VARCHAR" />
<result column="teaching_time" property="teachingTime" jdbcType="TIMESTAMP" />
</resultMap>
<sql id="Base_Column_List" >
id, task_id, teaching_scene_code, teaching_scene_name, teaching_method_code, teaching_method_name, teaching_topic_code,
teaching_topic_name, teaching_time
</sql>
</mapper>
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" >
<mapper namespace="cn.com.glsx.dj.supervisor.mapper.SupervisorWorkbenchReportMapper">
<select id="listTasksByDateRangeAndTypes" resultType="cn.com.glsx.dj.supervisor.dto.WorkbenchReportTaskRowDTO">
SELECT
sti.id,
sti.task_type AS taskType,
sti.task_status AS taskStatus,
sti.on_duty_flag AS onDutyFlag,
sti.supervisor_name AS supervisorName,
sti.supervisor_phone AS supervisorPhone,
sti.supervisor_uuid AS supervisorUuid,
sti.merchant_name AS merchantName,
sti.task_desc AS taskDesc,
sti.task_context AS taskContext,
sti.create_time AS createTime,
sti.updated_date AS updatedDate,
DATE_FORMAT(sti.create_time, '%Y-%m-%d') AS taskDate
FROM supervisor_task_info sti
WHERE sti.deleted_flag = 'N'
AND CAST(sti.create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
AND CAST(sti.create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
<if test="taskTypes != null and taskTypes.size() > 0">
AND sti.task_type IN
<foreach collection="taskTypes" item="item" open="(" close=")" separator=",">
#{item}
</foreach>
</if>
</select>
<select id="countTeachingByScene" resultType="cn.com.glsx.dj.supervisor.dto.WorkbenchTeachingCountDTO">
SELECT
sti.supervisor_name AS supervisorName,
std.teaching_scene_code AS teachingSceneCode,
COUNT(*) AS count
FROM supervisor_task_info sti
INNER JOIN supervisor_teaching_detail std ON std.task_id = sti.id
WHERE sti.deleted_flag = 'N'
AND sti.task_type = 5
AND CAST(sti.create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
AND CAST(sti.create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
GROUP BY sti.supervisor_name, std.teaching_scene_code
</select>
<select id="listAudioReviewStats" resultType="cn.com.glsx.dj.supervisor.dto.WorkbenchAudioReviewStatDTO">
SELECT
sti.id AS relationId,
sti.supervisor_name AS supervisorName,
DATE_FORMAT(sti.create_time, '%Y-%m-%d') AS taskDate,
COUNT(sari.id) AS totalCount,
SUM(CASE WHEN sari.review_status = 1 THEN 1 ELSE 0 END) AS reviewedCount
FROM supervisor_task_info sti
LEFT JOIN supervisor_audio_review_info sari
ON sari.relation_id = sti.id AND sari.deleted_flag = 'N'
WHERE sti.deleted_flag = 'N'
AND sti.task_type = 3
AND CAST(sti.create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
AND CAST(sti.create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
GROUP BY sti.id, sti.supervisor_name, DATE_FORMAT(sti.create_time, '%Y-%m-%d')
</select>
<select id="countExcellentCaseGroupBySubmitterName" resultType="cn.com.glsx.dj.supervisor.dto.WorkbenchExcellentCaseCountDTO">
SELECT
submitter_name AS submitterName,
DATE_FORMAT(create_time, '%Y-%m-%d') AS submitDate,
COUNT(*) AS count
FROM excellent_case_review
WHERE deleted_flag = 'N'
AND submitter_name IS NOT NULL
AND submitter_name != ''
AND CAST(create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
AND CAST(create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
GROUP BY submitter_name, DATE_FORMAT(create_time, '%Y-%m-%d')
</select>
</mapper>
...@@ -57,7 +57,6 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest { ...@@ -57,7 +57,6 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
req.setSupervisorId("63c121922cba4956b2aac3f21dacd92f"); req.setSupervisorId("63c121922cba4956b2aac3f21dacd92f");
req.setStartDate("2026-03-01"); req.setStartDate("2026-03-01");
req.setEndDate("2026-03-29"); req.setEndDate("2026-03-29");
req.setBizs(2);
req.setDateType(2); req.setDateType(2);
req.setNeedAiAnalysis(true); req.setNeedAiAnalysis(true);
req.setSortField(4); req.setSortField(4);
...@@ -81,7 +80,6 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest { ...@@ -81,7 +80,6 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
req.setStartDate("2026-03-01"); req.setStartDate("2026-03-01");
req.setEndDate("2026-03-31"); req.setEndDate("2026-03-31");
req.setMerchantId(44211227); req.setMerchantId(44211227);
req.setBizs(2);
req.setDateType(2); req.setDateType(2);
RpcResponse<EmployeePerformanceDTO> response = supervisorDashboardRemote.getEmployeePerformanceData(req); RpcResponse<EmployeePerformanceDTO> response = supervisorDashboardRemote.getEmployeePerformanceData(req);
System.out.println(JSON.toJSONString(response)); System.out.println(JSON.toJSONString(response));
...@@ -93,7 +91,6 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest { ...@@ -93,7 +91,6 @@ public class SupervisorDashboardRemoteImplTest extends BaseServiceTest {
req.setEmployeeId("584fdb460afa4dad835cbe8d73cfa923"); req.setEmployeeId("584fdb460afa4dad835cbe8d73cfa923");
req.setPhone("13132112126"); req.setPhone("13132112126");
req.setMerchantId(44211227); req.setMerchantId(44211227);
req.setBizs(2);
req.setStartDate("2026-03-01"); req.setStartDate("2026-03-01");
req.setEndDate("2026-03-30"); req.setEndDate("2026-03-30");
RpcResponse<EmployeeBehaviorDTO> response = supervisorDashboardRemote.getEmployeeBehaviorData(req); RpcResponse<EmployeeBehaviorDTO> response = supervisorDashboardRemote.getEmployeeBehaviorData(req);
......
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.dto.ExcellentCaseDetailDTO;
import cn.com.glsx.dj.supervisor.dto.ExcellentCaseReviewQueryDTO;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import com.github.pagehelper.Page;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class ExcellentCaseReviewServiceTest extends BaseServiceTest {
@Autowired
private ExcellentCaseReviewService excellentCaseReviewService;
@Test
public void testQueryExcellentCaseListByTaskId() {
RpcPagination<ExcellentCaseReviewQueryDTO> request = new RpcPagination<>();
request.setPageNum(1);
request.setPageSize(10);
ExcellentCaseReviewQueryDTO condition = new ExcellentCaseReviewQueryDTO();
condition.setTaskId(214L);
request.setCondition(condition);
Page<ExcellentCaseDetailDTO> page = excellentCaseReviewService.queryExcellentCaseListByTaskId(request);
System.out.println(page);
}
}
...@@ -23,9 +23,9 @@ public class SupervisorAudioReviewInfoServiceTest extends BaseServiceTest { ...@@ -23,9 +23,9 @@ public class SupervisorAudioReviewInfoServiceTest extends BaseServiceTest {
@Test @Test
public void testSubmitAudioReview() { public void testSubmitAudioReview() {
SupervisorAudioReviewInfo request = new SupervisorAudioReviewInfo(); SupervisorAudioReviewInfo request = new SupervisorAudioReviewInfo();
request.setId(1L); request.setId(4L);
request.setReviewContext("测试录音"); request.setReviewContext("测试录音完成率");
request.setReviewTarget("标签仔"); //request.setReviewTarget("标签仔1");
request.setUpdatedBy("fanfr"); request.setUpdatedBy("fanfr");
Boolean result = supervisorAudioReviewInfoService.submitAudioReview(request); Boolean result = supervisorAudioReviewInfoService.submitAudioReview(request);
assertTrue(result); assertTrue(result);
......
package cn.com.glsx.dj.supervisor.service; package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.mindworkplate.dto.residentpoint.StaffBaseInfoDTO;
import cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO; import cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO;
import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum; import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum;
import cn.com.glsx.dj.smartcarlife.remote.ShopMerchantDirectorConfigRemote; import cn.com.glsx.dj.smartcarlife.remote.ShopMerchantDirectorConfigRemote;
...@@ -8,8 +9,10 @@ import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO; ...@@ -8,8 +9,10 @@ import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO; import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskSummaryDTO; import cn.com.glsx.dj.supervisor.dto.SupervisorTaskSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.*; import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.enums.TaskTypeEnum;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskCourse; import cn.com.glsx.dj.supervisor.model.SupervisorTaskCourse;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskImage; import cn.com.glsx.dj.supervisor.model.SupervisorTaskImage;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskMerchant;
import cn.com.glsx.dj.supervisor.model.SupervisorWeekTaskStaff; import cn.com.glsx.dj.supervisor.model.SupervisorWeekTaskStaff;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination; import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
...@@ -18,13 +21,11 @@ import cn.com.glsx.merchants.model.response.MerchantStaffResponse; ...@@ -18,13 +21,11 @@ import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page; import com.github.pagehelper.Page;
import org.apache.commons.collections.CollectionUtils; import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.httpclient.util.DateUtil;
import org.junit.Test; import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList; import java.util.*;
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -115,6 +116,22 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest { ...@@ -115,6 +116,22 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
supervisorTaskInfoService.generateWeekTask(startTimeStr, endTimeStr); supervisorTaskInfoService.generateWeekTask(startTimeStr, endTimeStr);
} }
@Test
public void testGenerateCoachingRequirementTask() {
String startTimeStr = "2026-05-11";
String endTimeStr = "2026-05-17";
supervisorTaskInfoService.generateCoachingRequirementTask(startTimeStr, endTimeStr);
}
@Test
public void testGenerateExcellentCaseAudioTask() {
String startTimeStr = "2026-05-11";
String endTimeStr = "2026-05-17";
supervisorTaskInfoService.generateExcellentCaseAudioTask(startTimeStr, endTimeStr);
supervisorTaskInfoService.generateCoachingRequirementTask(startTimeStr, endTimeStr);
}
/** /**
* 测试生成月报任务 * 测试生成月报任务
*/ */
...@@ -158,19 +175,27 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest { ...@@ -158,19 +175,27 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
@Test @Test
public void testSubmitDayTask() { public void testSubmitDayTask() {
SupervisorTaskDTO request = new SupervisorTaskDTO(); SupervisorTaskDTO request = new SupervisorTaskDTO();
request.setId(3L); request.setId(234L);
// 设置其他全部参数 // 设置其他全部参数
request.setMerchantId(43423334); // request.setMerchantId(43423334);
request.setMerchantName("萨达梵蒂冈"); // request.setMerchantName("萨达梵蒂冈");
List<SupervisorTaskMerchant> taskMerchantList = new ArrayList<>();
SupervisorTaskMerchant merchant = new SupervisorTaskMerchant();
merchant.setMerchantId(43423334);
merchant.setMerchantName("萨达梵蒂冈");
taskMerchantList.add(merchant);
request.setTaskMerchantList(taskMerchantList);
request.setOnDutyFlag(0); request.setOnDutyFlag(0);
request.setTaskContext("督导日报记录"); request.setTaskContext("督导日报记录");
List<SupervisorTaskImage> taskImageList = new ArrayList<>(); request.setNextWorkItems("日报-明日继续");
SupervisorTaskImage image = new SupervisorTaskImage(); request.setNeedAssistItems("帮我copy数据");
image.setImageUrl("http://oss.glsx.com/123456.jpg"); // List<SupervisorTaskImage> taskImageList = new ArrayList<>();
taskImageList.add(image); // SupervisorTaskImage image = new SupervisorTaskImage();
request.setTaskImageList(taskImageList); // image.setImageUrl("http://oss.glsx.com/123456.jpg");
request.setUpdatedBy("周敏"); // taskImageList.add(image);
request.setUpdatedPhone("18682474862"); // request.setTaskImageList(taskImageList);
request.setUpdatedBy("陈希");
request.setUpdatedPhone("13132112126");
supervisorTaskInfoService.submitDayTask(request); supervisorTaskInfoService.submitDayTask(request);
} }
...@@ -192,12 +217,12 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest { ...@@ -192,12 +217,12 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
public void testPageTask() { public void testPageTask() {
RpcPagination<SupervisorTaskQueryDTO> request = new RpcPagination<>(); RpcPagination<SupervisorTaskQueryDTO> request = new RpcPagination<>();
SupervisorTaskQueryDTO queryDTO = new SupervisorTaskQueryDTO(); SupervisorTaskQueryDTO queryDTO = new SupervisorTaskQueryDTO();
// queryDTO.setSupervisorPhone("18682474862"); queryDTO.setSupervisorPhone("18682474862");
request.setCondition(queryDTO); request.setCondition(queryDTO);
List<Integer> typeList = Arrays.asList(4); List<Integer> typeList = Arrays.asList(6, 7);
queryDTO.setTaskTypeList(typeList); queryDTO.setTaskTypeList(typeList);
// queryDTO.setStartDate("2026-01-01"); queryDTO.setStartDate("2026-05-11");
// queryDTO.setEndDate("2026-01-31"); queryDTO.setEndDate("2026-05-17");
request.setPageSize(10); request.setPageSize(10);
request.setPageNum(1); request.setPageNum(1);
Page<SupervisorTaskDTO> supervisorTaskDTOS = supervisorTaskInfoService.pageTask(request); Page<SupervisorTaskDTO> supervisorTaskDTOS = supervisorTaskInfoService.pageTask(request);
...@@ -250,25 +275,29 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest { ...@@ -250,25 +275,29 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
@Test @Test
public void testGetTeamOverview() { public void testGetTeamOverview() {
ShopMerchantDirectorConfigDTO dto = new ShopMerchantDirectorConfigDTO(); ShopMerchantDirectorConfigDTO dto = ShopMerchantDirectorConfigDTO.builder()
dto.setDirectorUserId("63c121922cba4956b2aac3f21dacd92f"); .directorUserId("63c121922cba4956b2aac3f21dacd92f")
dto.setDirectorTypes(Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue())); .directorTypes(Arrays.asList(
RpcResponse<List<ShopMerchantDirectorConfigDTO>> merchantResponse = shopMerchantDirectorConfigRemote.list(dto); DirectorTypeEnum.FLIGHT_SUPERVISION.getValue(),
List<Integer> merchantIdList = new ArrayList<>(); DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue()))
if (merchantResponse.isSuccess() && merchantResponse.getResult() != null) { .build();
List<ShopMerchantDirectorConfigDTO> merchantList = merchantResponse.getResult(); RpcResponse<List<ShopMerchantDirectorConfigDTO>> response = shopMerchantDirectorConfigRemote.list(dto);
if (CollectionUtils.isNotEmpty(merchantList)) { List<ShopMerchantDirectorConfigDTO> list = response.getResult();
merchantIdList = merchantList.stream() Map<Integer, List<Integer>> map = new HashMap<>();
.map(ShopMerchantDirectorConfigDTO::getMerchantId) if (CollectionUtils.isNotEmpty(list)) {
.collect(Collectors.toList()); for (ShopMerchantDirectorConfigDTO item : list) {
map.computeIfAbsent(Integer.valueOf(item.getDirectorType()), k -> new ArrayList<>())
.add(item.getMerchantId());
}
}
SupervisorTaskQueryDTO request = new SupervisorTaskQueryDTO(); SupervisorTaskQueryDTO request = new SupervisorTaskQueryDTO();
request.setMerchantIdList(merchantIdList); request.setDirectorTypeMerchantMap(map);
List<Integer> allMerchantIds = map.values().stream()
.flatMap(List::stream).distinct().collect(Collectors.toList());
request.setMerchantIdList(allMerchantIds);
SupervisorTeamOverviewDTO overview = supervisorTaskInfoService.getTeamOverview(request); SupervisorTeamOverviewDTO overview = supervisorTaskInfoService.getTeamOverview(request);
System.out.println(JSON.toJSONString(overview)); System.out.println(JSON.toJSONString(overview));
} }
}
}
/** /**
* 测试分页查询督导列表(不带筛选条件,查询第1页) * 测试分页查询督导列表(不带筛选条件,查询第1页)
...@@ -331,4 +360,54 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest { ...@@ -331,4 +360,54 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
RpcPagination<SupervisorDetailStaffDTO> result = supervisorTaskInfoService.pageDetailStaff(pagination); RpcPagination<SupervisorDetailStaffDTO> result = supervisorTaskInfoService.pageDetailStaff(pagination);
System.out.println(JSON.toJSONString(result)); System.out.println(JSON.toJSONString(result));
} }
@Test
public void testGetUnfinishedTaskCount() {
UnfinishedTaskCountReqDTO request = new UnfinishedTaskCountReqDTO();
request.setSupervisorPhone("13603070903");
UnfinishedTaskCountDTO count = supervisorTaskInfoService.getUnfinishedTaskCount(request);
System.out.println(JSON.toJSONString(count));
request.setStartDate("2026-03-01");
request.setEndDate("2026-03-31");
count = supervisorTaskInfoService.getUnfinishedTaskCount(request);
System.out.println(JSON.toJSONString(count));
}
@Test
public void testUpdateWeeklyTaskStatus() {
WeeklyTaskStatusReqDTO request = new WeeklyTaskStatusReqDTO();
request.setTaskType(TaskTypeEnum.EXCELLENT_CASE_AUDIO.getCode());
request.setCreateDate("2026-03-20");
request.setSupervisorUuid("c4c9d90316e04ea6961c1dda22cdab00");
supervisorTaskInfoService.updateWeeklyTaskStatus(request);
System.out.println(JSON.toJSONString(request));
request.setTaskType(TaskTypeEnum.COACHING_REQUIREMENT.getCode());
request.setCreateDate("2026-03-20");
supervisorTaskInfoService.updateWeeklyTaskStatus(request);
System.out.println(JSON.toJSONString(request));
}
@Test
public void testPageStaffBaseInfo() {
RpcPagination<SupervisorTeamStaffQueryDTO> pagination = new RpcPagination<>();
pagination.setPageNum(1);
pagination.setPageSize(10);
SupervisorTeamStaffQueryDTO condition = new SupervisorTeamStaffQueryDTO();
condition.setSupervisorPhone("17680252939");
pagination.setCondition(condition);
Page<SupervisorTeamStaffDTO> result = supervisorTaskInfoService.pageStaffBaseInfo(pagination);
System.out.println(JSON.toJSONString(result));
}
@Test
public void testPageTeachingRecords() {
RpcPagination<SupervisorTaskQueryDTO> pagination = new RpcPagination<>();
pagination.setPageNum(1);
pagination.setPageSize(10);
SupervisorTaskQueryDTO condition = new SupervisorTaskQueryDTO();
condition.setId(217L);
pagination.setCondition(condition);
Page<SupervisorTeachingListDTO> result = supervisorTaskInfoService.pageTeachingRecords(pagination);
System.out.println(JSON.toJSONString(result));
}
} }
\ No newline at end of file \ No newline at end of file
  • @wangxw1
    commented
    Master

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

    1. 性能瓶颈:循环内进行同步 RPC 远程调用

    • 问题描述:在 SupervisorDashboardService.getDashboardData 方法(遍历 bizList 调用 queryBiData)以及 SupervisorTaskInfoService.getTeamOverview 方法(遍历 directorTypeMerchantMap 调用 businessSceneAnalysisRemote.querySupervisorOutput)中,存在于 for 循环内部发起同步 RPC 调用的情况。
    • 影响分析:这是经典的性能反模式(N+1 调用问题)。虽然当前循环次数较少(如 2-3 次),但网络 I/O 延迟会被线性放大。一旦下游服务响应变慢或出现网络抖动,将直接导致当前接口响应超时,严重影响系统的吞吐量和稳定性。
    • 优化建议:
      • 方案A(推荐):推动下游提供方(如 businessSceneAnalysisRemote)提供批量查询接口(Batch API),通过一次 RPC 调用传入所有参数,在服务端完成聚合后返回。
      • 方案B:如果下游接口暂无法改造,建议在当前服务中使用 CompletableFuture 配合自定义线程池,将循环内的串行 RPC 调用改为并行调用,最后再进行结果合并(allOf().join())。

    2. 健壮性隐患:selectOne 存在抛出异常的风险

    • 问题描述:在 SupervisorTaskInfoService.updateWeeklyTaskStatus 方法中,使用了 supervisorTaskInfoMapper.selectOne(condition) 来获取周任务记录。
    • 影响分析:MyBatis / TkMyBatis 的 selectOne 方法在查询结果大于 1 条时,会直接抛出 TooManyResultsException 异常。如果在极端并发情况下,或者由于历史脏数据导致同一个督导在同一周内生成了多条相同 taskType 的记录,该核心状态更新逻辑将直接崩溃,导致任务状态无法正常流转。
    • 优化建议:采用防御性编程。建议改用 select(condition) 获取列表后取第一条记录,或者在底层 SQL 层面强制加上 LIMIT 1。同时,建议在数据库层面为 (supervisor_uuid, task_type, start_date, end_date) 增加唯一联合索引,从根源上杜绝脏数据。 java // 优化建议代码示例 List<SupervisorTaskInfo> taskList = supervisorTaskInfoMapper.select(condition); if (CollectionUtils.isEmpty(taskList)) { log.warn("未找到对应周任务..."); return null; } SupervisorTaskInfo taskInfo = taskList.get(0); // 防御性取第一条

    3. 可维护性缺陷:魔法值硬编码与枚举使用不一致

    • 问题描述:在 SupervisorDashboardService.getDashboardBehaviorData 方法中,获取门店列表时硬编码了魔法值 "13":Byte.valueOf("13")。而在同一个类的 getDashboardData 方法中,正确的做法是使用了枚举 DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue()。
    • 影响分析:硬编码魔法值极大地降低了代码的可读性和可维护性。如果未来该业务类型的枚举值发生变更,硬编码的地方将无法在编译期被发现,会引发隐蔽的线上 Bug。
    • 优化建议:统一使用系统已定义的枚举类,消除魔法值。 ```java // 修改前 List flightSupervision21Merchants = getMerchantsByDirectorType(req.getSupervisorId(), Byte.valueOf("13"));

    // 修改后 List flightSupervision21Merchants = getMerchantsByDirectorType(req.getSupervisorId(), DirectorTypeEnum.FLIGHT_SUPERVISION_2_1.getValue());

    
    ---
    
    #### 二、评分明细
    
    * **功能实现的正确性与健壮性(34 / 40分)**
      * **理由**:业务逻辑整体实现完整,Dubbo `Remote` 接口的变更均属于新增方法,未破坏“已有请求参数变更视为危险实现”的规则。但在防御性编程上存在欠缺(如 `selectOne` 潜在的异常风险),可能在边界场景下引发故障。
    
    * **安全性与潜在风险(30 / 30分)**
      * **理由**:未发现明显的 SQL 注入、越权或敏感信息泄露风险。入参校验(如 `@NotNull`, `@NotBlank`)使用规范,UUID 传递与权限隔离逻辑基本合理。
    
    * **最佳实践与可维护性(16 / 20分)**
      * **理由**:代码结构清晰,DTO、Enum 和 Model 的划分符合工程规范。扣分项在于代码中出现了硬编码魔法值(如 `"13"`),以及部分代码冗余(`getDashboardData` 和 `getDashboardBehaviorData` 的结构高度重复,建议进一步抽取公共模板方法)。
    
    * **性能与资源利用(2 / 5分)**
      * **理由**:存在明显的性能反模式。在 `for` 循环中嵌套发起同步 RPC 调用,是对线程资源和网络 I/O 的极大浪费,在流量高峰期容易成为系统瓶颈。
    
    * **提交信息质量(5 / 5分)**
      * **理由**:Commit 信息(如 `fix(supervisor): 解决商户ID重复导致的数据处理问题`、`refactor(dashboard): 优化督导数据查询逻辑支持多业务类型`)格式规范,清晰地描述了变更原因、具体动作和影响范围,可追溯性强。
    
    总分:87分
    
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!