Commit ef04a7c5 by zhouhaibao

Merge branch 'main' of http://192.168.3.233:8090/dj/rpc-dj-supervisor

# Conflicts:
#	rpc-dj-supervisor/src/main/resources/META-INF/orm/BusinessSceneMapper.xml
2 parents 91112621 1194611e
...@@ -68,7 +68,6 @@ public class SupervisorTaskDTO implements Serializable { ...@@ -68,7 +68,6 @@ public class SupervisorTaskDTO implements Serializable {
/** /**
* 督导记录(富文本内容) * 督导记录(富文本内容)
*/ */
@NotEmpty(message = "督导记录不能为空")
@ApiModelProperty(notes = "督导记录", required = true) @ApiModelProperty(notes = "督导记录", required = true)
private String taskContext; private String taskContext;
......
...@@ -48,5 +48,7 @@ public class SupervisorTaskQueryDTO implements Serializable { ...@@ -48,5 +48,7 @@ public class SupervisorTaskQueryDTO implements Serializable {
*/ */
private Integer receptionStatus; private Integer receptionStatus;
private Long audioId;
} }
...@@ -18,7 +18,7 @@ public class WarningBaselineConfigDTO implements Serializable { ...@@ -18,7 +18,7 @@ public class WarningBaselineConfigDTO implements Serializable {
@NotBlank(message = "指标编码不能为空") @NotBlank(message = "指标编码不能为空")
@ApiModelProperty(notes = "指标编码, 个人产值:A036", required = true) @ApiModelProperty(notes = "指标编码, 个人产值:A036", required = true)
private String indicatorCode; private String indicatorCode;
@NotBlank(message = "指标名称不能为空")
@ApiModelProperty(notes = "指标名称, 个人产值:个人产值", required = true) @ApiModelProperty(notes = "指标名称, 个人产值:个人产值", required = true)
private String indicatorName; private String indicatorName;
...@@ -26,7 +26,6 @@ public class WarningBaselineConfigDTO implements Serializable { ...@@ -26,7 +26,6 @@ public class WarningBaselineConfigDTO implements Serializable {
@ApiModelProperty(notes = "时间维度:(1.按天,2.按周,3.按月,5.按年)", required = true) @ApiModelProperty(notes = "时间维度:(1.按天,2.按周,3.按月,5.按年)", required = true)
private Integer timeDimension; private Integer timeDimension;
@NotEmpty(message = "预警基线配置列表不能为空")
@ApiModelProperty(notes = "预警基线配置列表", required = true) @ApiModelProperty(notes = "预警基线配置列表", required = true)
private List<SupervisorWarningBaselineConfig> configList; private List<SupervisorWarningBaselineConfig> configList;
@ApiModelProperty(notes = "更新标识:(0.新增,1.更新)", required = true) @ApiModelProperty(notes = "更新标识:(0.新增,1.更新)", required = true)
......
package cn.com.glsx.dj.supervisor.job;
import cn.com.glsx.dj.supervisor.enums.TimeDimensionEnum;
import cn.com.glsx.dj.supervisor.service.SupervisorAiAnalysisRecordService;
import cn.com.glsx.dj.supervisor.service.SupervisorTaskInfoService;
import cn.com.glsx.dj.supervisor.utils.DateUtils;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 督导团队培训数据 AI 分析定时任务 - 月维度
* 每月 1 号凌晨 1 点 20 分执行,查询上月(1 号至最后一天)数据,
* 对全部在职飞行督导下各团队的培训数据发起 AI 分析任务。
* 分析结果以"生成中"状态异步保存到 supervisor_ai_analysis_record 表,
* 由 SupervisorAiAnalysisQueryJob 轮询回写最终结果。
*/
@Slf4j
@Service
@ElasticJobConf(name = "SupervisorMonthlyTrainingAiAnalysisJob", cron = "0 20 1 1 * ?",
description = "督导团队培训数据月维度AI分析任务", overwrite = true)
public class SupervisorMonthlyTrainingAiAnalysisJob implements SimpleJob {
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private SupervisorAiAnalysisRecordService supervisorAiAnalysisRecordService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("督导团队培训数据 AI 分析任务(月)开始执行");
try {
// 计算上月的起始和结束日期
Date today = new Date();
String startDate = DateUtils.formatDate(DateUtils.getDateStartMonth(DateUtils.addDate(today, "month", -1)));
String endDate = DateUtils.formatDate(DateUtils.getDateEndMonth(DateUtils.addDate(today, "month", -1)));
log.info("本次分析周期:{} ~ {}", startDate, endDate);
List<MerchantStaffResponse> supervisorList = supervisorTaskInfoService.listAllEffectiveSupervisors();
if (CollectionUtils.isEmpty(supervisorList)) {
log.warn("未查询到在职飞行督导,任务结束");
return;
}
log.info("共查询到 {} 名在职飞行督导,开始逐一处理", supervisorList.size());
for (MerchantStaffResponse supervisor : supervisorList) {
try {
supervisorAiAnalysisRecordService.processSupervisorTrainingAiAnalysis(
supervisor, startDate, endDate, TimeDimensionEnum.MONTHLY.getCode());
} catch (Exception e) {
log.error("处理督导培训 AI 分析异常(月),supervisorPhone={},error={}",
supervisor.getStaffPhone(), e.getMessage(), e);
}
}
} catch (Exception e) {
log.error("督导团队培训数据 AI 分析任务(月)执行异常", e);
}
log.info("督导团队培训数据 AI 分析任务(月)执行结束");
}
}
package cn.com.glsx.dj.supervisor.job;
import cn.com.glsx.dj.supervisor.service.SupervisorAiAnalysisRecordService;
import cn.com.glsx.dj.supervisor.service.SupervisorTaskInfoService;
import cn.com.glsx.dj.supervisor.utils.DateUtils;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 督导下组员个人综合数据 AI 分析定时任务(日维度)
* 每日凌晨 1 点 30 分执行,查询昨天数据,遍历全部在职飞行督导,
* 再遍历每个督导的每名组员,将业绩、行为、培训数据聚合为纯文本,
* 发起 AI 大模型分析,结果以"生成中"状态异步保存到 supervisor_ai_analysis_record 表,
* 由 SupervisorAiAnalysisQueryJob 轮询回写最终结果。
*/
@Slf4j
@Service
@ElasticJobConf(name = "SupervisorPersonalAiAnalysisJob", cron = "0 30 1 * * ?",
description = "督导团队成员个人综合数据日维度AI分析任务", overwrite = true)
public class SupervisorPersonalAiAnalysisJob implements SimpleJob {
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private SupervisorAiAnalysisRecordService supervisorAiAnalysisRecordService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("督导团队成员个人综合 AI 分析任务(日)开始执行");
try {
// 昨天日期(yyyy-MM-dd)
String yesterday = DateUtils.getDayStartDate(1, false);
log.info("本次分析日期:{}", yesterday);
List<MerchantStaffResponse> supervisorList = supervisorTaskInfoService.listAllEffectiveSupervisors();
if (CollectionUtils.isEmpty(supervisorList)) {
log.warn("未查询到在职飞行督导,任务结束");
return;
}
log.info("共查询到 {} 名在职飞行督导,开始逐一处理", supervisorList.size());
for (MerchantStaffResponse supervisor : supervisorList) {
try {
supervisorAiAnalysisRecordService.processSupervisorPersonalAiAnalysis(supervisor, yesterday);
} catch (Exception e) {
log.error("处理督导个人综合 AI 分析异常(日),supervisorPhone={},error={}",
supervisor.getStaffPhone(), e.getMessage(), e);
}
}
} catch (Exception e) {
log.error("督导团队成员个人综合 AI 分析任务(日)执行异常", e);
}
log.info("督导团队成员个人综合 AI 分析任务(日)执行结束");
}
}
package cn.com.glsx.dj.supervisor.job;
import cn.com.glsx.dj.supervisor.enums.TimeDimensionEnum;
import cn.com.glsx.dj.supervisor.service.SupervisorAiAnalysisRecordService;
import cn.com.glsx.dj.supervisor.service.SupervisorTaskInfoService;
import cn.com.glsx.dj.supervisor.utils.DateUtils;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;
/**
* 督导团队培训数据 AI 分析定时任务 - 日维度
* 每日凌晨 1 点执行,查询前一天数据,对全部在职飞行督导下各团队的培训数据发起 AI 分析任务。
* 分析结果以"生成中"状态异步保存到 supervisor_ai_analysis_record 表,
* 由 SupervisorAiAnalysisQueryJob 轮询回写最终结果。
*/
@Slf4j
@Service
@ElasticJobConf(name = "SupervisorTrainingAiAnalysisJob", cron = "0 0 1 * * ?",
description = "督导团队培训数据日维度AI分析任务", overwrite = true)
public class SupervisorTrainingAiAnalysisJob implements SimpleJob {
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private SupervisorAiAnalysisRecordService supervisorAiAnalysisRecordService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("督导团队培训数据 AI 分析任务(日)开始执行");
try {
// 前一天日期(yyyy-MM-dd)
String yesterday = DateUtils.getDayStartDate(1, false);
log.info("本次分析日期:{}", yesterday);
List<MerchantStaffResponse> supervisorList = supervisorTaskInfoService.listAllEffectiveSupervisors();
if (CollectionUtils.isEmpty(supervisorList)) {
log.warn("未查询到在职飞行督导,任务结束");
return;
}
log.info("共查询到 {} 名在职飞行督导,开始逐一处理", supervisorList.size());
for (MerchantStaffResponse supervisor : supervisorList) {
try {
supervisorAiAnalysisRecordService.processSupervisorTrainingAiAnalysis(
supervisor, yesterday, yesterday, TimeDimensionEnum.DAILY.getCode());
} catch (Exception e) {
log.error("处理督导培训 AI 分析异常(日),supervisorPhone={},error={}",
supervisor.getStaffPhone(), e.getMessage(), e);
}
}
} catch (Exception e) {
log.error("督导团队培训数据 AI 分析任务(日)执行异常", e);
}
log.info("督导团队培训数据 AI 分析任务(日)执行结束");
}
}
package cn.com.glsx.dj.supervisor.job;
import cn.com.glsx.dj.supervisor.enums.TimeDimensionEnum;
import cn.com.glsx.dj.supervisor.service.SupervisorAiAnalysisRecordService;
import cn.com.glsx.dj.supervisor.service.SupervisorTaskInfoService;
import cn.com.glsx.dj.supervisor.utils.DateUtils;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Date;
import java.util.List;
/**
* 督导团队培训数据 AI 分析定时任务 - 周维度
* 每周一凌晨 1 点 15 分执行,查询上周(周一至周日)数据,
* 对全部在职飞行督导下各团队的培训数据发起 AI 分析任务。
* 分析结果以"生成中"状态异步保存到 supervisor_ai_analysis_record 表,
* 由 SupervisorAiAnalysisQueryJob 轮询回写最终结果。
*/
@Slf4j
@Service
@ElasticJobConf(name = "SupervisorWeeklyTrainingAiAnalysisJob", cron = "0 15 1 ? * 2",
description = "督导团队培训数据周维度AI分析任务", overwrite = true)
public class SupervisorWeeklyTrainingAiAnalysisJob implements SimpleJob {
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private SupervisorAiAnalysisRecordService supervisorAiAnalysisRecordService;
@Override
public void execute(ShardingContext shardingContext) {
log.info("督导团队培训数据 AI 分析任务(周)开始执行");
try {
// 计算上周的周一和周日
Date today = new Date();
String startDate = DateUtils.formatDate(DateUtils.getMondayOfWeek(DateUtils.addDate(today, "day", -7)));
String endDate = DateUtils.formatDate(DateUtils.getSundayOfWeek(DateUtils.addDate(today, "day", -7)));
log.info("本次分析周期:{} ~ {}", startDate, endDate);
List<MerchantStaffResponse> supervisorList = supervisorTaskInfoService.listAllEffectiveSupervisors();
if (CollectionUtils.isEmpty(supervisorList)) {
log.warn("未查询到在职飞行督导,任务结束");
return;
}
log.info("共查询到 {} 名在职飞行督导,开始逐一处理", supervisorList.size());
for (MerchantStaffResponse supervisor : supervisorList) {
try {
supervisorAiAnalysisRecordService.processSupervisorTrainingAiAnalysis(
supervisor, startDate, endDate, TimeDimensionEnum.WEEKLY.getCode());
} catch (Exception e) {
log.error("处理督导培训 AI 分析异常(周),supervisorPhone={},error={}",
supervisor.getStaffPhone(), e.getMessage(), e);
}
}
} catch (Exception e) {
log.error("督导团队培训数据 AI 分析任务(周)执行异常", e);
}
log.info("督导团队培训数据 AI 分析任务(周)执行结束");
}
}
package cn.com.glsx.dj.supervisor.service; package cn.com.glsx.dj.supervisor.service;
import cn.com.glsk.omni.ai.dto.LLMRequest;
import cn.com.glsk.omni.ai.dto.LLMResponse;
import cn.com.glsk.omni.ai.remote.AgiRemote;
import cn.com.glsx.dj.supervisor.dto.DashboardQueryReq;
import cn.com.glsx.dj.supervisor.dto.EmployeeRanking;
import cn.com.glsx.dj.supervisor.dto.EmployeeTrainingInfoDTO;
import cn.com.glsx.dj.supervisor.dto.EmployeeTrainingInfoRequestDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorDashboardVO;
import cn.com.glsx.dj.supervisor.enums.AiAnalysisTypeEnum;
import cn.com.glsx.dj.supervisor.mapper.SupervisorAiAnalysisRecordMapper; import cn.com.glsx.dj.supervisor.mapper.SupervisorAiAnalysisRecordMapper;
import cn.com.glsx.dj.supervisor.model.SupervisorAiAnalysisRecord; import cn.com.glsx.dj.supervisor.model.SupervisorAiAnalysisRecord;
import cn.com.glsx.dj.supervisor.utils.DateUtils;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.merchants.model.response.MerchantStaffResponse;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import java.math.BigDecimal;
import java.util.Collections; import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
/** /**
* 督导 AI 分析记录 Service 实现类 * 督导 AI 分析记录 Service
* *
* @author Alvin * @author Alvin
* @date 2026 年 3 月 11 日 * @date 2026 年 3 月 11 日
...@@ -20,14 +36,39 @@ import java.util.List; ...@@ -20,14 +36,39 @@ import java.util.List;
@Service @Service
public class SupervisorAiAnalysisRecordService { public class SupervisorAiAnalysisRecordService {
/** AI 任务状态:生成中 */
private static final int AI_TASK_STATUS_PENDING = 0;
/** 删除标记:正常 */
private static final String DELETED_FLAG_NORMAL = "N";
/** 创建人:系统 */
private static final String CREATED_BY_SYSTEM = "system";
/** Dashboard dateType:按指定时段 */
private static final int DATE_TYPE_RANGE = 0;
@Autowired @Autowired
private SupervisorAiAnalysisRecordMapper supervisorAiAnalysisRecordMapper; private SupervisorAiAnalysisRecordMapper supervisorAiAnalysisRecordMapper;
@Autowired
private SupervisorEmployeeTrainingInfoService supervisorEmployeeTrainingInfoService;
@Autowired
private SupervisorDashboardService supervisorDashboardService;
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private AgiRemote agiRemote;
// ============================= 查询 / 存储 =============================
public SupervisorAiAnalysisRecord getAiAnalysisRecord(SupervisorAiAnalysisRecord record) { public SupervisorAiAnalysisRecord getAiAnalysisRecord(SupervisorAiAnalysisRecord record) {
try { try {
log.info("查询 AI 分析记录,查询条件:{}", record); log.info("查询 AI 分析记录,查询条件:{}", record);
SupervisorAiAnalysisRecord result = supervisorAiAnalysisRecordMapper.selectByCondition(record); return supervisorAiAnalysisRecordMapper.selectByCondition(record);
return result;
} catch (Exception e) { } catch (Exception e) {
log.error("查询 AI 分析记录异常", e); log.error("查询 AI 分析记录异常", e);
throw new RuntimeException("查询失败:" + e.getMessage(), e); throw new RuntimeException("查询失败:" + e.getMessage(), e);
...@@ -36,8 +77,6 @@ public class SupervisorAiAnalysisRecordService { ...@@ -36,8 +77,6 @@ public class SupervisorAiAnalysisRecordService {
/** /**
* 查询所有生成中(ai_task_status=0)的 AI 分析记录列表 * 查询所有生成中(ai_task_status=0)的 AI 分析记录列表
*
* @return 生成中的记录列表
*/ */
public List<SupervisorAiAnalysisRecord> listPendingRecords() { public List<SupervisorAiAnalysisRecord> listPendingRecords() {
try { try {
...@@ -50,6 +89,19 @@ public class SupervisorAiAnalysisRecordService { ...@@ -50,6 +89,19 @@ public class SupervisorAiAnalysisRecordService {
} }
/** /**
* 保存 AI 分析记录
*/
public SupervisorAiAnalysisRecord saveRecord(SupervisorAiAnalysisRecord record) {
try {
supervisorAiAnalysisRecordMapper.insert(record);
return record;
} catch (Exception e) {
log.error("保存 AI 分析记录异常", e);
throw new RuntimeException("保存失败:" + e.getMessage(), e);
}
}
/**
* 更新 AI 任务状态和生成结果 * 更新 AI 任务状态和生成结果
* *
* @param id 记录 ID * @param id 记录 ID
...@@ -69,4 +121,352 @@ public class SupervisorAiAnalysisRecordService { ...@@ -69,4 +121,352 @@ public class SupervisorAiAnalysisRecordService {
log.error("更新 AI 任务状态异常,id={}", id, e); log.error("更新 AI 任务状态异常,id={}", id, e);
} }
} }
// ============================= 培训数据 AI 分析 =============================
/**
* 处理单个飞行督导的培训数据 AI 分析:查询培训数据 → 格式化内容 → 调用大模型 → 保存记录。
*
* @param supervisor 督导信息
* @param startDate 查询开始日期(yyyy-MM-dd)
* @param endDate 查询结束日期(yyyy-MM-dd)
* @param timeDimension 时间维度枚举值
*/
public void processSupervisorTrainingAiAnalysis(MerchantStaffResponse supervisor,
String startDate, String endDate, Integer timeDimension) {
String supervisorPhone = supervisor.getStaffPhone();
String supervisorName = supervisor.getStaffName();
log.info("开始处理督导培训 AI 分析,supervisorPhone={},startDate={},endDate={}",
supervisorPhone, startDate, endDate);
// 1. 查询督导下团队培训数据
EmployeeTrainingInfoRequestDTO request = new EmployeeTrainingInfoRequestDTO();
request.setSupervisorPhone(supervisorPhone);
request.setStartDate(startDate);
request.setEndDate(endDate);
List<EmployeeTrainingInfoDTO> trainingInfoList =
supervisorEmployeeTrainingInfoService.getAllEmployeeTrainingInfo(request);
if (CollectionUtils.isEmpty(trainingInfoList)) {
log.info("督导下暂无培训数据,跳过,supervisorPhone={}", supervisorPhone);
return;
}
// 2. 将培训数据格式化为纯文本
String requestContent = buildTrainingContent(trainingInfoList);
// 3. 调用大模型 → 保存记录
launchAiAndSaveRecord(supervisorPhone, supervisorName, startDate, endDate,
timeDimension, AiAnalysisTypeEnum.TRAINING.getCode(), requestContent);
}
// ============================= 个人数据 AI 分析 =============================
/**
* 处理单个飞行督导下各组员的个人综合 AI 分析:
* 查询业绩、行为、培训数据 → 按员工手机号聚合 → 逐人发起大模型分析 → 保存记录。
*
* @param supervisor 督导信息
* @param date 分析日期(yyyy-MM-dd,查昨天的数据)
*/
public void processSupervisorPersonalAiAnalysis(MerchantStaffResponse supervisor, String date) {
String supervisorPhone = supervisor.getStaffPhone();
String supervisorName = supervisor.getStaffName();
log.info("开始处理督导个人综合 AI 分析,supervisorPhone={},date={}", supervisorPhone, date);
// 1. 通过督导手机号查询督导 UUID
String supervisorId = supervisorTaskInfoService.getSupervisorUUIDByPhone(supervisorPhone);
if (supervisorId == null) {
log.warn("未找到督导 UUID,跳过,supervisorPhone={}", supervisorPhone);
return;
}
// 2. 构建通用查询条件(不限业务类型)
DashboardQueryReq dashboardReq = new DashboardQueryReq();
dashboardReq.setSupervisorId(supervisorId);
dashboardReq.setStartDate(date);
dashboardReq.setEndDate(date);
dashboardReq.setDateType(DATE_TYPE_RANGE);
dashboardReq.setNeedAiAnalysis(Boolean.FALSE);
// 3. 查询业绩数据
SupervisorDashboardVO performanceVO = supervisorDashboardService.getDashboardData(dashboardReq);
List<EmployeeRanking> performanceList =
(performanceVO != null && performanceVO.getEmployeeList() != null)
? performanceVO.getEmployeeList() : Collections.emptyList();
// 4. 查询行为数据
SupervisorDashboardVO behaviorVO = supervisorDashboardService.getDashboardBehaviorData(dashboardReq);
List<EmployeeRanking> behaviorList =
(behaviorVO != null && behaviorVO.getEmployeeList() != null)
? behaviorVO.getEmployeeList() : Collections.emptyList();
// 5. 查询培训数据
EmployeeTrainingInfoRequestDTO trainingReq = new EmployeeTrainingInfoRequestDTO();
trainingReq.setSupervisorPhone(supervisorPhone);
trainingReq.setStartDate(date);
trainingReq.setEndDate(date);
List<EmployeeTrainingInfoDTO> trainingList =
supervisorEmployeeTrainingInfoService.getAllEmployeeTrainingInfo(trainingReq);
if (CollectionUtils.isEmpty(performanceList) && CollectionUtils.isEmpty(behaviorList)
&& CollectionUtils.isEmpty(trainingList)) {
log.info("督导下暂无任何数据,跳过,supervisorPhone={}", supervisorPhone);
return;
}
// 6. 以手机号为 Key 聚合三类数据
Map<String, EmployeeRanking> performanceMap = buildPhoneMap(performanceList);
Map<String, EmployeeRanking> behaviorMap = buildPhoneMap(behaviorList);
Map<String, EmployeeTrainingInfoDTO> trainingMap = buildTrainingPhoneMap(trainingList);
// 7. 取所有出现过的员工手机号集合(三张表并集)
java.util.Set<String> allPhones = new java.util.HashSet<>();
allPhones.addAll(performanceMap.keySet());
allPhones.addAll(behaviorMap.keySet());
allPhones.addAll(trainingMap.keySet());
if (allPhones.isEmpty()) {
log.info("督导下员工手机号集合为空,跳过,supervisorPhone={}", supervisorPhone);
return;
}
log.info("督导 {} 下共 {} 名员工,开始逐一发起个人 AI 分析", supervisorPhone, allPhones.size());
// 8. 逐员工组装数据并发起 AI 分析
for (String employeePhone : allPhones) {
try {
EmployeeRanking perf = performanceMap.get(employeePhone);
EmployeeRanking behav = behaviorMap.get(employeePhone);
EmployeeTrainingInfoDTO train = trainingMap.get(employeePhone);
// 取员工名(优先业绩,其次行为,其次培训)
String employeeName = null;
if (perf != null && perf.getEmployeeName() != null) {
employeeName = perf.getEmployeeName();
} else if (behav != null && behav.getEmployeeName() != null) {
employeeName = behav.getEmployeeName();
} else if (train != null && train.getEmployeeName() != null) {
employeeName = train.getEmployeeName();
}
String content = buildPersonalContent(employeeName, employeePhone, perf, behav, train);
launchAiAndSaveRecord(supervisorPhone, supervisorName, date, date,
cn.com.glsx.dj.supervisor.enums.TimeDimensionEnum.DAILY.getCode(),
AiAnalysisTypeEnum.PERSONNEL.getCode(), content);
} catch (Exception e) {
log.error("处理员工个人 AI 分析异常,supervisorPhone={},employeePhone={},error={}",
supervisorPhone, employeePhone, e.getMessage(), e);
}
}
}
// ============================= 公共 AI 调用 =============================
/**
* 调用大模型发起异步 AI 分析任务,并以“生成中”状态保存记录。
* businessType 对应关系:7003-督导管理团队培训,7004-督导管理团队个人
*/
private void launchAiAndSaveRecord(String supervisorPhone, String supervisorName,
String startDate, String endDate,
Integer timeDimension, Integer analysisType,
String requestContent) {
// 根据分析类型确定大模型业务类型:培训(type=3) -> 7003,个人(type=4) -> 7004
int businessType = AiAnalysisTypeEnum.PERSONNEL.getCode().equals(analysisType) ? 7004 : 7003;
LLMRequest llmRequest = new LLMRequest();
llmRequest.setBusinessType(businessType);
llmRequest.setContent(requestContent);
llmRequest.setAsync(true);
RpcResponse<LLMResponse> rpcResponse = agiRemote.launchLLM(llmRequest);
if (rpcResponse == null || !rpcResponse.isSuccess()) {
String errorMsg = rpcResponse != null ? rpcResponse.getMessage() : "响应为空";
log.warn("调用大模型发起 AI 分析失败,supervisorPhone={},error={}", supervisorPhone, errorMsg);
return;
}
LLMResponse llmResponse = rpcResponse.getResult();
if (llmResponse == null || !llmResponse.isSuccess()) {
String errorMsg = llmResponse != null ? llmResponse.getError() : "响应结果为空";
log.warn("大模型返回失败,supervisorPhone={},error={}", supervisorPhone, errorMsg);
return;
}
String aiTaskId = llmResponse.getTaskId();
log.info("大模型 AI 分析任务创建成功,supervisorPhone={},aiTaskId={}", supervisorPhone, aiTaskId);
Date now = new Date();
SupervisorAiAnalysisRecord record = new SupervisorAiAnalysisRecord();
record.setType(analysisType);
record.setSupervisorPhone(supervisorPhone);
record.setSupervisorName(supervisorName);
record.setTimeDimension(timeDimension);
record.setStartDate(DateUtils.parseDate(startDate));
record.setEndDate(DateUtils.parseDate(endDate));
record.setAiRequestParams(requestContent);
record.setAiTaskId(aiTaskId);
record.setAiTaskStatus(AI_TASK_STATUS_PENDING);
record.setCreatedBy(CREATED_BY_SYSTEM);
record.setCreatedTime(now);
record.setDeletedFlag(DELETED_FLAG_NORMAL);
saveRecord(record);
log.info("AI 分析记录保存成功,supervisorPhone={},aiTaskId={}", supervisorPhone, aiTaskId);
}
// ============================= 内容格式化 =============================
/**
* 组装单个员工的个人综合数据为纯文本格式,所有字段直接取 EmployeeRanking 原始值:
* <pre>
* name:张三,
* 个人产值:2000,
* 个人客单价:600,
* 转化率:70%,
* 成交数:28,
* 战败数:22,
* 总录音数:46,
* 录音缺失率:8%,
* 学习时长:2h36,
* 完成课程数:9,
* 带教次数:8
* </pre>
*/
private String buildPersonalContent(String employeeName, String employeePhone,
EmployeeRanking perf, EmployeeRanking behav,
EmployeeTrainingInfoDTO train) {
StringBuilder sb = new StringBuilder();
// 姓名
sb.append("name:").append(employeeName != null ? employeeName : "").append(",\n");
// 业绩数据(直接取原始值)
BigDecimal personalOutput = perf != null && perf.getPersonalOutput() != null
? perf.getPersonalOutput() : BigDecimal.ZERO;
BigDecimal personalUnitPrice = perf != null && perf.getPersonalUnitPrice() != null
? perf.getPersonalUnitPrice() : BigDecimal.ZERO;
// personalConversion 为小数(如 0.70),格式化为百分比
BigDecimal personalConversion = perf != null && perf.getPersonalConversion() != null
? perf.getPersonalConversion() : BigDecimal.ZERO;
sb.append("个人产值:").append(personalOutput.toPlainString()).append(",\n");
sb.append("个人客单价:").append(personalUnitPrice.toPlainString()).append(",\n");
sb.append("转化率:").append(formatPercent(personalConversion)).append(",\n");
// 行为数据(直接取 EmployeeRanking 原始字段,不做任何计算)
int dealCount = behav != null && behav.getDealCount() != null ? behav.getDealCount() : 0;
int defeatCount = behav != null && behav.getDefeatCount() != null ? behav.getDefeatCount() : 0;
int recordingCount = behav != null && behav.getRecordingCount() != null ? behav.getRecordingCount() : 0;
// missingRate 已是百分比数值(如 8.00 表示 8%),直接拼 % 后缀
BigDecimal missingRate = behav != null && behav.getMissingRate() != null
? behav.getMissingRate() : BigDecimal.ZERO;
sb.append("成交数:").append(dealCount).append(",\n");
sb.append("战败数:").append(defeatCount).append(",\n");
sb.append("总录音数:").append(recordingCount).append(",\n");
sb.append("录音缺失率:").append(missingRate.setScale(0, BigDecimal.ROUND_HALF_UP).toPlainString()).append("%").append(",\n");
// 培训数据(直接取原始值)
BigDecimal studyHours = train != null ? train.getStudyHours() : null;
int completedCourses = train != null && train.getCompletedCourses() != null ? train.getCompletedCourses() : 0;
int coachingTimes = train != null && train.getCoachingTimes() != null ? train.getCoachingTimes() : 0;
sb.append("学习时长:").append(formatStudyHours(studyHours)).append(",\n");
sb.append("完成课程数:").append(completedCourses).append(",\n");
sb.append("带教次数:").append(coachingTimes);
return sb.toString();
}
/**
* 将员工培训数据列表拼装为纯文本格式,供大模型分析使用。
*/
private String buildTrainingContent(List<EmployeeTrainingInfoDTO> list) {
StringBuilder sb = new StringBuilder();
sb.append("员工:\n");
BigDecimal totalStudyHours = BigDecimal.ZERO;
int totalCompletedCourses = 0;
int totalCoachingTimes = 0;
for (EmployeeTrainingInfoDTO dto : list) {
sb.append("姓名:").append(dto.getEmployeeName() != null ? dto.getEmployeeName() : "").append(",\n");
sb.append("学习时长:").append(formatStudyHours(dto.getStudyHours())).append(",\n");
sb.append("完成课程数:").append(dto.getCompletedCourses() != null ? dto.getCompletedCourses() : 0).append(",\n");
sb.append("带教次数:").append(dto.getCoachingTimes() != null ? dto.getCoachingTimes() : 0).append("\n");
sb.append("\n");
if (dto.getStudyHours() != null) {
totalStudyHours = totalStudyHours.add(dto.getStudyHours());
}
totalCompletedCourses += dto.getCompletedCourses() != null ? dto.getCompletedCourses() : 0;
totalCoachingTimes += dto.getCoachingTimes() != null ? dto.getCoachingTimes() : 0;
}
sb.append("团队:\n");
sb.append("总学习时长:").append(formatStudyHours(totalStudyHours)).append(",\n");
sb.append("总完成课程数:").append(totalCompletedCourses).append(",\n");
sb.append("总带教次数:").append(totalCoachingTimes);
return sb.toString();
}
/**
* 将学习时长(小数小时)格式化为 Xh XX 形式,例如 2.6 -> 2h36
*/
private String formatStudyHours(BigDecimal hours) {
if (hours == null) {
return "0h0";
}
int h = hours.intValue();
int m = hours.subtract(BigDecimal.valueOf(h))
.multiply(BigDecimal.valueOf(60))
.setScale(0, BigDecimal.ROUND_HALF_UP)
.intValue();
return h + "h" + m;
}
/**
* 将小数比率格式化为百分比字符串,例如 0.7 -> "70%"
*/
private String formatPercent(BigDecimal rate) {
if (rate == null) {
return "0%";
}
return rate.multiply(new BigDecimal("100"))
.setScale(0, BigDecimal.ROUND_HALF_UP).toPlainString() + "%";
}
// ============================= 辅助方法 =============================
/**
* 将 EmployeeRanking 列表转为以手机号为 Key 的 Map(忽略手机号为空的项)
*/
private Map<String, EmployeeRanking> buildPhoneMap(List<EmployeeRanking> list) {
Map<String, EmployeeRanking> map = new HashMap<>();
if (CollectionUtils.isEmpty(list)) {
return map;
}
for (EmployeeRanking e : list) {
if (e.getEmployeePhone() != null && !e.getEmployeePhone().isEmpty()) {
map.put(e.getEmployeePhone(), e);
}
}
return map;
}
/**
* 将 EmployeeTrainingInfoDTO 列表转为以手机号为 Key 的 Map(忽略手机号为空的项)
*/
private Map<String, EmployeeTrainingInfoDTO> buildTrainingPhoneMap(List<EmployeeTrainingInfoDTO> list) {
Map<String, EmployeeTrainingInfoDTO> map = new HashMap<>();
if (CollectionUtils.isEmpty(list)) {
return map;
}
for (EmployeeTrainingInfoDTO dto : list) {
if (dto.getPhone() != null && !dto.getPhone().isEmpty()) {
map.put(dto.getPhone(), dto);
}
}
return map;
}
} }
...@@ -379,7 +379,7 @@ public class SupervisorDashboardService { ...@@ -379,7 +379,7 @@ public class SupervisorDashboardService {
* @param bizs 业务类型 * @param bizs 业务类型
* @return 门店及门店员工手机号列表 * @return 门店及门店员工手机号列表
*/ */
private Map<Integer, List<EmployeeRanking>> getSupervisorStoreAndEmployeePhoneList(String supervisorId, public Map<Integer, List<EmployeeRanking>> getSupervisorStoreAndEmployeePhoneList(String supervisorId,
Integer bizs) { Integer bizs) {
Map<Integer, List<EmployeeRanking>> result = new HashMap<>(); Map<Integer, List<EmployeeRanking>> result = new HashMap<>();
......
...@@ -31,6 +31,12 @@ public class SupervisorEmployeeTrainingInfoService { ...@@ -31,6 +31,12 @@ public class SupervisorEmployeeTrainingInfoService {
@Autowired @Autowired
private SupervisorTaskInfoMapper supervisorTaskInfoMapper; private SupervisorTaskInfoMapper supervisorTaskInfoMapper;
@Autowired
private SupervisorDashboardService supervisorDashboardService;
@Autowired
private SupervisorTaskInfoService supervisorTaskInfoService;
/** /**
* 根据条件查询全部员工培训信息列表 * 根据条件查询全部员工培训信息列表
* *
...@@ -38,11 +44,33 @@ public class SupervisorEmployeeTrainingInfoService { ...@@ -38,11 +44,33 @@ public class SupervisorEmployeeTrainingInfoService {
* @return 员工培训信息列表 * @return 员工培训信息列表
*/ */
public List<EmployeeTrainingInfoDTO> getAllEmployeeTrainingInfo(EmployeeTrainingInfoRequestDTO request) { public List<EmployeeTrainingInfoDTO> getAllEmployeeTrainingInfo(EmployeeTrainingInfoRequestDTO request) {
// TODO 1、根据督导手机号、业务类型 关联查询全部员工信息 // 1、根据督导手机号查询督导uuid
// 2、单个员工查询 String supervisorUUID = supervisorTaskInfoService.getSupervisorUUIDByPhone(request.getSupervisorPhone());
// 3、判空处理等 if (supervisorUUID == null) {
List<String> phoneList = new ArrayList<String>(); log.warn("未找到督导信息,supervisorPhone={}", request.getSupervisorPhone());
phoneList.add("13603070903"); return new ArrayList<>();
}
// 2、根据督导uuid和业务类型,获取督导下所有门店及员工信息
Map<Integer, List<EmployeeRanking>> storeEmployeeMap =
supervisorDashboardService.getSupervisorStoreAndEmployeePhoneList(supervisorUUID, request.getBusinessType());
if (CollectionUtils.isEmpty(storeEmployeeMap)) {
log.warn("督导下没有员工信息,supervisorPhone={}", request.getSupervisorPhone());
return new ArrayList<>();
}
// 3、提取全部员工手机号(去重)
List<String> phoneList = storeEmployeeMap.values().stream()
.flatMap(List::stream)
.map(EmployeeRanking::getEmployeePhone)
.filter(phone -> phone != null && !phone.isEmpty())
.distinct()
.collect(Collectors.toList());
if (CollectionUtils.isEmpty(phoneList)) {
log.warn("督导下员工手机号为空,supervisorPhone={}", request.getSupervisorPhone());
return new ArrayList<>();
}
List<BeiSenEmployeeListResonseDTO> beiSenEmployeeList = supervisorLearningCenterService.listEmployeeInfoByStaffPhone(phoneList); List<BeiSenEmployeeListResonseDTO> beiSenEmployeeList = supervisorLearningCenterService.listEmployeeInfoByStaffPhone(phoneList);
List<Integer> beiSenUserIdList = beiSenEmployeeList.stream().map(beiSenEmployeeListResonseDTO -> beiSenEmployeeListResonseDTO.getUserID()).collect(Collectors.toList()); List<Integer> beiSenUserIdList = beiSenEmployeeList.stream().map(beiSenEmployeeListResonseDTO -> beiSenEmployeeListResonseDTO.getUserID()).collect(Collectors.toList());
......
...@@ -639,12 +639,18 @@ public class SupervisorTaskInfoService { ...@@ -639,12 +639,18 @@ public class SupervisorTaskInfoService {
} else { } else {
List<StaffBaseInfoDTO> staffList = response.getResult(); List<StaffBaseInfoDTO> staffList = response.getResult();
if (CollectionUtils.isNotEmpty(staffList)) { if (CollectionUtils.isNotEmpty(staffList)) {
overviewDTO.setStaffCount(staffList.size()); //根据员工手机号去重计算员工个数
Set<String> phoneSet = staffList.stream().map(StaffBaseInfoDTO::getStaffPhone).collect(Collectors.toSet());
overviewDTO.setStaffCount(phoneSet.size());
//查询产值 //查询产值
SceneBaseReq req = new SceneBaseReq(); SceneBaseReq req = new SceneBaseReq();
req.setMerchantIds(merchantIdList); req.setMerchantIds(merchantIdList);
req.setCycleType(4); req.setCycleType(4);
req.setStaffUuids(staffList.stream().map(StaffBaseInfoDTO::getLoginUuid).collect(Collectors.toList())); req.setStaffUuids(staffList.stream().map(StaffBaseInfoDTO::getLoginUuid).collect(Collectors.toList()));
//设置指标开始时间,从配置文件中取值
req.setStartTime(env.getProperty("supervisor.output.startTime", String.class, "2021-01-01"));
//设置指标结束时间,固定当前日期
req.setEndTime(DateUtils.formatDate(new Date()));
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("查询督导团队产值失败,SceneBaseReq={}, error={}, message={}", JSON.toJSONString(req), outputResponse.getError(), outputResponse.getMessage());
...@@ -753,6 +759,7 @@ public class SupervisorTaskInfoService { ...@@ -753,6 +759,7 @@ public class SupervisorTaskInfoService {
req.setDateType(request.getDateType()); req.setDateType(request.getDateType());
req.setStartDate(request.getStartDate()); req.setStartDate(request.getStartDate());
req.setEndDate(request.getEndDate()); req.setEndDate(request.getEndDate());
req.setNeedAiAnalysis(false);
SupervisorDashboardVO dashboardData = supervisorDashboardService.getDashboardData(req); SupervisorDashboardVO dashboardData = supervisorDashboardService.getDashboardData(req);
DashboardMetrics metrics = dashboardData.getMetrics(); DashboardMetrics metrics = dashboardData.getMetrics();
...@@ -773,7 +780,7 @@ public class SupervisorTaskInfoService { ...@@ -773,7 +780,7 @@ public class SupervisorTaskInfoService {
* @param supervisorPhone * @param supervisorPhone
* @return * @return
*/ */
private String getSupervisorUUIDByPhone(String supervisorPhone) { public String getSupervisorUUIDByPhone(String supervisorPhone) {
List<MerchantStaffResponse> supervisorList = getMerchantStaffByPhone(supervisorPhone); List<MerchantStaffResponse> supervisorList = getMerchantStaffByPhone(supervisorPhone);
if (CollectionUtils.isEmpty(supervisorList)) { if (CollectionUtils.isEmpty(supervisorList)) {
return null; return null;
...@@ -808,6 +815,7 @@ public class SupervisorTaskInfoService { ...@@ -808,6 +815,7 @@ public class SupervisorTaskInfoService {
req.setDateType(request.getDateType()); req.setDateType(request.getDateType());
req.setStartDate(request.getStartDate()); req.setStartDate(request.getStartDate());
req.setEndDate(request.getEndDate()); req.setEndDate(request.getEndDate());
req.setNeedAiAnalysis(false);
SupervisorDashboardVO dashboardData = supervisorDashboardService.getDashboardData(req); SupervisorDashboardVO dashboardData = supervisorDashboardService.getDashboardData(req);
List<EmployeeRanking> employeeList = dashboardData.getEmployeeList(); List<EmployeeRanking> employeeList = dashboardData.getEmployeeList();
......
...@@ -6,25 +6,25 @@ ...@@ -6,25 +6,25 @@
<select id="getBusinessSceneByPhoneNumber" parameterType="java.lang.String" resultType="java.lang.String"> <select id="getBusinessSceneByPhoneNumber" parameterType="java.lang.String" resultType="java.lang.String">
SELECT COALESCE(GROUP_CONCAT(DISTINCT CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 THEN CASE WHEN go.business_type = 1 THEN '2' WHEN go.business_type = 2 THEN '3' END END ORDER BY CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 AND go.business_type = 1 THEN '2' WHEN go.scene_type = 0 AND go.business_type = 2 THEN '3' END SEPARATOR ', '), '') AS staff_scene_label SELECT COALESCE(GROUP_CONCAT(DISTINCT CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 THEN CASE WHEN go.business_type = 1 THEN '2' WHEN go.business_type = 2 THEN '3' END END ORDER BY CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 AND go.business_type = 1 THEN '2' WHEN go.scene_type = 0 AND go.business_type = 2 THEN '3' END SEPARATOR ', '), '') AS staff_scene_label
FROM dj_car_life_staff_info si FROM dj_car_life_staff_info si
LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY) LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
WHERE si.phone_number = #{phoneNumber} WHERE si.phone_number = #{phoneNumber}
GROUP BY si.phone_number GROUP BY si.phone_number
</select> </select>
<!-- 批次查询业务场景标签 --> <!-- 批次查询业务场景标签 -->
<select id="batchGetBusinessSceneByPhoneNumbers" parameterType="java.util.List" resultType="java.util.HashMap"> <select id="batchGetBusinessSceneByPhoneNumbers" parameterType="java.util.List" resultType="java.util.HashMap">
SELECT SELECT
si.phone_number as phoneNumber, si.phone_number as phoneNumber,
COALESCE(GROUP_CONCAT(DISTINCT CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 THEN CASE WHEN go.business_type = 1 THEN '2' WHEN go.business_type = 2 THEN '3' END END ORDER BY CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 AND go.business_type = 1 THEN '2' WHEN go.scene_type = 0 AND go.business_type = 2 THEN '3' END SEPARATOR ', '), '') AS businessScene COALESCE(GROUP_CONCAT(DISTINCT CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 THEN CASE WHEN go.business_type = 1 THEN '2' WHEN go.business_type = 2 THEN '3' END END ORDER BY CASE WHEN go.scene_type = 1 THEN '1' WHEN go.scene_type = 0 AND go.business_type = 1 THEN '2' WHEN go.scene_type = 0 AND go.business_type = 2 THEN '3' END SEPARATOR ', '), '') AS businessScene
FROM dj_car_life_staff_info si FROM dj_car_life_staff_info si
LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY) LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time &gt;= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
WHERE si.phone_number IN WHERE si.phone_number IN
<foreach collection="phoneNumbers" item="item" open="(" separator="," close=")"> <foreach collection="phoneNumbers" item="item" open="(" separator="," close=")">
#{item} #{item}
</foreach> </foreach>
GROUP BY si.phone_number GROUP BY si.phone_number
</select> </select>
<!-- 查询员工调店记录 --> <!-- 查询员工调店记录 -->
<select id="getEmployeeStoreTransferRecords" parameterType="map" resultType="cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO"> <select id="getEmployeeStoreTransferRecords" parameterType="map" resultType="cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO">
SELECT SELECT
......
...@@ -75,7 +75,7 @@ ...@@ -75,7 +75,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 stim.image_url,sti.store_manager_name,sti.store_manager_phone,sti.updated_by
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>
......
package cn.com.glsx.dj.supervisor.service; package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.smartcarlife.dto.ShopMerchantDirectorConfigDTO;
import cn.com.glsx.dj.smartcarlife.enums.DirectorTypeEnum;
import cn.com.glsx.dj.smartcarlife.remote.ShopMerchantDirectorConfigRemote;
import cn.com.glsx.dj.supervisor.dto.SupervisorManageSummaryDTO; import cn.com.glsx.dj.supervisor.dto.SupervisorManageSummaryDTO;
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;
...@@ -10,14 +13,17 @@ import cn.com.glsx.dj.supervisor.model.SupervisorTaskImage; ...@@ -10,14 +13,17 @@ import cn.com.glsx.dj.supervisor.model.SupervisorTaskImage;
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;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
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.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.ArrayList;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
/** /**
* @Title: * @Title:
...@@ -30,6 +36,9 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest { ...@@ -30,6 +36,9 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
@Autowired @Autowired
private SupervisorTaskInfoService supervisorTaskInfoService; private SupervisorTaskInfoService supervisorTaskInfoService;
@Autowired
private ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote;
@Test @Test
public void testGetTaskDetailById() { public void testGetTaskDetailById() {
SupervisorTaskDTO detail = supervisorTaskInfoService.getTaskDetailById(1L); SupervisorTaskDTO detail = supervisorTaskInfoService.getTaskDetailById(1L);
...@@ -219,4 +228,26 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest { ...@@ -219,4 +228,26 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
request.setTaskDesc("督导记录sdhnasuihfasifnasfnassjasidjkioasdasfn"); request.setTaskDesc("督导记录sdhnasuihfasifnasfnassjasidjkioasdasfn");
Long id = supervisorTaskInfoService.createSpecialTask(request); Long id = supervisorTaskInfoService.createSpecialTask(request);
} }
@Test
public void testGetTeamOverview() {
ShopMerchantDirectorConfigDTO dto = new ShopMerchantDirectorConfigDTO();
dto.setDirectorUserId("63c121922cba4956b2aac3f21dacd92f");
dto.setDirectorTypes(Arrays.asList(DirectorTypeEnum.FLIGHT_SUPERVISION.getValue()));
RpcResponse<List<ShopMerchantDirectorConfigDTO>> merchantResponse = shopMerchantDirectorConfigRemote.list(dto);
List<Integer> merchantIdList = new ArrayList<>();
if (merchantResponse.isSuccess() && merchantResponse.getResult() != null) {
List<ShopMerchantDirectorConfigDTO> merchantList = merchantResponse.getResult();
if (CollectionUtils.isNotEmpty(merchantList)) {
merchantIdList = merchantList.stream()
.map(ShopMerchantDirectorConfigDTO::getMerchantId)
.collect(Collectors.toList());
SupervisorTaskQueryDTO request = new SupervisorTaskQueryDTO();
request.setMerchantIdList(merchantIdList);
SupervisorTeamOverviewDTO overview = supervisorTaskInfoService.getTeamOverview(request);
System.out.println(JSON.toJSONString(overview));
}
}
}
} }
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!