Commit 5819fdd1 by zhouhaibao
2 parents d22582e8 ea68655f
Showing 38 changed files with 1195 additions and 73 deletions
......@@ -73,7 +73,7 @@ public class AudioReceptionDTO implements Serializable {
* 录音复盘内容
*/
@ApiModelProperty(notes = "录音复盘内容")
private String reviewContent;
private String reviewContext;
@ApiModelProperty(notes = "录音批次id")
private Integer batchId;
......
......@@ -15,17 +15,26 @@ public class AudioSummaryDTO implements Serializable {
* 已复盘数量
*/
@ApiModelProperty(notes = "已复盘数量")
private Integer reviewedCount;
private Integer reviewedCount;
/**
* 未复盘数量
*/
@ApiModelProperty(notes = "未复盘数量")
private Integer unreviewedCount;
@ApiModelProperty(notes = "未复盘数量")
private Integer unreviewedCount;
/**
* 总数
*/
@ApiModelProperty(notes = "总数")
private Integer totalCount;
@ApiModelProperty(notes = "总数")
private Integer totalCount;
@ApiModelProperty(notes = "任务状态 0-待完成 1-进行中,2-已完成")
private Integer taskStatus;
/**
* 创建时间
*/
@ApiModelProperty(notes = "创建时间")
private Date createTime;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.ToString;
import javax.validation.constraints.NotEmpty;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 新增专项任务请求DTO
*/
@Data
@ToString
public class CreateSpecialTaskDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 门店ID
*/
@NotNull(message = "门店ID不能为空")
@ApiModelProperty(notes = "门店ID", required = true)
private Integer merchantId;
/**
* 门店名称(冗余字段)
*/
@NotEmpty(message = "门店名称不能为空")
@ApiModelProperty(notes = "门店名称", required = true)
private String merchantName;
/**
* 任务描述
*/
@ApiModelProperty(notes = "任务描述")
private String taskDesc;
/**
* 督导手机号
*/
@NotEmpty(message = "督导手机号不能为空")
@ApiModelProperty(notes = "督导手机号", required = true)
private String supervisorPhone;
/**
* 督导姓名
*/
@NotEmpty(message = "督导姓名不能为空")
@ApiModelProperty(notes = "督导姓名", required = true)
private String supervisorName;
/**
* 创建人姓名
*/
@NotEmpty(message = "创建人不能为空")
@ApiModelProperty(notes = "创建人姓名", required = true)
private String createdBy;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import javax.validation.constraints.NotNull;
import java.io.Serializable;
/**
* 督导管理详情页查询参数
*
* @author xiehx
* @date 2026-03-12
*/
@Data
public class SupervisorDetailQueryDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 督导手机号(必传,用于定位督导)
*/
@ApiModelProperty(notes = "督导手机号(必传)")
private String supervisorPhone;
/**
* 业务类型:1.延保 2.轻改 3.权益,不传或传null表示全场景
*/
@ApiModelProperty(notes = "业务类型:1.延保 2.轻改 3.权益,不传表示全场景")
private Integer bizType;
/**
* 日期类型:0,按指定时段;1,按周;2,按月;3,按年;4,全部
*/
@ApiModelProperty(value = "日期类型", example = "0", required = true, notes = "日期类型:0,按指定时段;1,按周;2,按月;3,按年;4,全部")
@NotNull
private Integer dateType;
/**
* 查询开始日期,格式 yyyy-MM-dd
*/
@ApiModelProperty(notes = "查询开始日期,格式 yyyy-MM-dd")
private String startDate;
/**
* 查询结束日期,格式 yyyy-MM-dd
*/
@ApiModelProperty(notes = "查询结束日期,格式 yyyy-MM-dd")
private String endDate;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 督导管理详情页 - 驻店销售明细行 DTO
* <p>
* 用于详情页驻店销售列表,包含:姓名、归属业务、产值、转化率、客单价
* </p>
*
* @author xiehx
* @date 2026-03-12
*/
@Data
public class SupervisorDetailStaffDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 驻店销售姓名
*/
@ApiModelProperty(notes = "驻店销售姓名")
private String staffName;
/**
* 驻店销售手机号
*/
@ApiModelProperty(notes = "驻店销售手机号")
private String staffPhone;
/**
* 归属业务(数据来源:D后台-人员管理-驻店管理-所属业务,多个业务用逗号拼接)
*/
@ApiModelProperty(notes = "归属业务,多个用逗号拼接,如:延保,轻改,权益")
private String bizNames;
/**
* 产值,单位元,保留2位小数
*/
@ApiModelProperty(notes = "产值,单位元,保留2位小数")
private BigDecimal outputValue;
/**
* 转化率,单位%,保留2位小数
*/
@ApiModelProperty(notes = "转化率,单位%,保留2位小数")
private BigDecimal conversionRate;
/**
* 客单价,单位元,保留2位小数
*/
@ApiModelProperty(notes = "客单价,单位元,保留2位小数")
private BigDecimal avgOrderValue;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.math.BigDecimal;
/**
* 督导管理详情页 - 汇总数据 DTO
* <p>
* 包含:团队人员数、产值、转化率、客单价
* </p>
*
* @author xiehx
* @date 2026-03-12
*/
@Data
public class SupervisorDetailSummaryDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 团队人员数(当前督导管理的驻店销售人员总数)
*/
@ApiModelProperty(notes = "团队人员数(当前督导管理的驻店销售人员总数)")
private Integer teamStaffCount;
/**
* 产值,单位元,保留2位小数
*/
@ApiModelProperty(notes = "产值,单位元,保留2位小数")
private BigDecimal outputValue;
/**
* 转化率,单位%,保留2位小数
*/
@ApiModelProperty(notes = "转化率,单位%,保留2位小数")
private BigDecimal conversionRate;
/**
* 客单价,单位元,保留2位小数
*/
@ApiModelProperty(notes = "客单价,单位元,保留2位小数")
private BigDecimal avgOrderValue;
}
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.math.BigDecimal;
import java.util.Date;
/**
* 督导管理分页列表-数据对象
*
* @author xiehx
* @date 2026-03-12
*/
@Data
public class SupervisorPageDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 督导姓名
*/
@ApiModelProperty(notes = "督导姓名")
private String name;
/**
* 督导手机号
*/
@ApiModelProperty(notes = "督导手机号")
private String phone;
/**
* 入职日期
*/
@ApiModelProperty(notes = "入职日期")
@JsonFormat(pattern = "yyyy-MM-dd", timezone = "GMT+8")
private Date entryDate;
/**
* 团队人员总数(督导负责门店下的员工总数)
*/
@ApiModelProperty(notes = "团队人员总数")
private Integer teamStaffCount;
/**
* 管理门店总数(该督导负责的门店去重后的数量)
*/
@ApiModelProperty(notes = "管理门店总数")
private Integer managedStoreCount;
/**
* 产值(单位:万,保留一位小数)
*/
@ApiModelProperty(notes = "产值(单位:万,保留一位小数)")
private BigDecimal outputValue;
}
package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
/**
* 督导管理分页查询-条件对象
*
* @author xiehx
* @date 2026-03-12
*/
@Data
public class SupervisorPageQueryDTO implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 督导姓名(模糊匹配)
*/
@ApiModelProperty(notes = "督导姓名(模糊匹配)")
private String name;
/**
* 督导手机号(精确匹配)
*/
@ApiModelProperty(notes = "督导手机号")
private String phone;
}
......@@ -102,6 +102,22 @@ public class SupervisorTaskDTO implements Serializable {
@ApiModelProperty(notes = "更新人手机号")
private String updatedPhone;
@ApiModelProperty(value = "入职时间", example = "2025-12-12")
private String entryDate;
/**
* 性别
*/
@ApiModelProperty(value = "性别", example = "女")
private String gender;
/**
* 归属业务
*/
@ApiModelProperty(value = "归属业务", example = "延保")
private String business;
/**
* 周任务人员列表
*/
......
......@@ -29,7 +29,8 @@ public class WarningBaselineConfigDTO implements Serializable {
@NotEmpty(message = "预警基线配置列表不能为空")
@ApiModelProperty(notes = "预警基线配置列表", required = true)
private List<SupervisorWarningBaselineConfig> configList;
@ApiModelProperty(notes = "更新标识:(0.新增,1.更新)", required = true)
private int updateFlag;
private String updatedBy;
......
......@@ -84,6 +84,17 @@ public interface SupervisorTaskInfoRemote {
@ApiResponse("提交结果")
RpcResponse<Boolean> submitAudioReview(SupervisorAudioReviewInfo request);
/**
* 查询录音详情信息
*/
@ApiMethod("查询录音详情信息")
@ApiParams({@ApiParam(name = "request", notes = "查询参数", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("录音详情信息")
RpcResponse<AudioReceptionDTO> getAudioReviewDetail(SupervisorTaskQueryDTO request);
/**
* 发起带教 - 提交
*/
......@@ -109,4 +120,38 @@ public interface SupervisorTaskInfoRemote {
@ApiParams({@ApiParam(name = "request", notes = "不需要参数,传null即可", dataType = ApiParam.DataTypeEnum.OBJECT, required = false)})
@ApiResponse("汇总数据")
RpcResponse<SupervisorManageSummaryDTO> getManageSummary();
/**
* 分页查询督导列表(含团队人数、管理门店、产值)
*/
@ApiMethod("分页查询督导列表")
@ApiParams({@ApiParam(name = "request", notes = "查询参数(督导姓名、手机号、分页)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("督导分页列表")
RpcResponse<RpcPagination<SupervisorPageDTO>> pageSupervisors(RpcPagination<SupervisorPageQueryDTO> request);
/**
* 督导管理详情页 - 核心指标汇总
* 返回:团队人员数、产值、转化率、客单价
*/
@ApiMethod("督导管理详情页汇总")
@ApiParams({@ApiParam(name = "request", notes = "查询参数(督导手机号、业务类型、起止日期)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("核心指标汇总")
RpcResponse<SupervisorDetailSummaryDTO> getDetailSummary(SupervisorDetailQueryDTO request);
/**
* 督导管理详情页 - 驻店销售明细分页列表
* 每行:驻店销售、归属业务、产值、转化率、客单价
*/
@ApiMethod("督导管理详情页驻店销售分页列表")
@ApiParams({@ApiParam(name = "request", notes = "查询参数(督导手机号、业务类型、起止日期、分页)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("驻店销售明细分页列表")
RpcResponse<RpcPagination<SupervisorDetailStaffDTO>> pageDetailStaff(RpcPagination<SupervisorDetailQueryDTO> request);
/**
* 新增专项任务
*/
@ApiMethod("新增专项任务")
@ApiParams({@ApiParam(name = "request", notes = "专项任务信息(门店ID、门店名称、任务描述、督导手机号、督导姓名、创建人)", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("新增结果(任务ID)")
RpcResponse<Long> createSpecialTask(CreateSpecialTaskDTO request);
}
\ No newline at end of file
......@@ -23,5 +23,13 @@ public interface SupervisorWarningBaselineConfigRemote {
@ApiResponse("预警基线配置列表")
RpcResponse<List<WarningBaselineConfigDTO>> listAllWarningBaselineConfigs();
/**
* 删除预警基线配置
*/
@ApiMethod("删除预警基线配置")
@ApiParams({@ApiParam(name = "request", notes = "预警基线配置信息", dataType = ApiParam.DataTypeEnum.OBJECT, required = true)})
@ApiResponse("删除结果")
RpcResponse<Boolean> deleteWarningBaselineConfig(WarningBaselineConfigDTO request);
}
......@@ -13,6 +13,11 @@
<dependencies>
<dependency>
<groupId>cn.com.glsx</groupId>
<artifactId>rpc-omni-ai-api</artifactId>
<version>1.0.0.1-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.8.38</version>
......@@ -20,7 +25,7 @@
<dependency>
<groupId>cn.com.glsx.merchants</groupId>
<artifactId>platform-merchants-api</artifactId>
<version>5.6.1-SNAPSHOT</version>
<version>5.7.0-SNAPSHOT</version>
</dependency>
<dependency>
......@@ -54,11 +59,6 @@
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-aop</artifactId>
</dependency>
<dependency>
<groupId>cn.com.glsx.merchants</groupId>
<artifactId>platform-merchants-api</artifactId>
<version>5.6.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
......
package cn.com.glsx.dj.supervisor.config;
import cn.com.glsk.omni.ai.remote.AgiRemote;
import cn.com.glsx.dj.peanalysis.remote.BusinessSceneAnalysisRemote;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
@Configuration
public class LLMDubboConfig extends DubboConfig {
@Bean
public AgiRemote agiRemote() {
return factory.builder(AgiRemote.class).check(false).timeout(120000).build();
}
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
/**
* Mapper 内部用 DTO - 飞行督导与门店关联关系
*
* @author system
* @date 2026-03-17
*/
@Data
public class SupervisorDirectorConfigDTO {
/**
* 门店商户号
*/
private Integer merchantId;
/**
* 负责人类型
*/
private Integer directorType;
/**
* 负责人(督导)ID
*/
private String directorUserId;
/**
* 负责人(督导)姓名
*/
private String directorName;
/**
* 负责人(督导)手机号
*/
private String directorPhone;
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
/**
* Mapper 内部用 DTO - 门店与驻店销售关联关系
*
* @author system
* @date 2026-03-17
*/
@Data
public class SupervisorStaffAccountDTO {
/**
* 员工 UUID
*/
private String staffUuid;
/**
* 驻店员工手机号
*/
private String staffPhone;
/**
* 归属门店商户号
*/
private Integer merchantId;
/**
* 归属门店商户名称
*/
private String merchantName;
/**
* 归属园区店商户号
*/
private Integer yqMerchantId;
/**
* 归属园区店商户名称
*/
private String yqMerchantName;
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
/**
* Mapper 内部用 DTO - 督导管理门店数量
*
* @author xiehx
* @date 2026-03-12
*/
@Data
public class SupervisorStoreCountDTO {
/**
* 督导手机号
*/
private String directorPhone;
/**
* 管理门店数
*/
private Integer storeCount;
}
package cn.com.glsx.dj.supervisor.dto;
import lombok.Data;
/**
* @Title:
* @Description:
* @Author xiehx
* @Date 2026/3/14
**/
@Data
public class SupervisorStoreManagerDTO {
/**
* 督导手机号
*/
private String supervisorPhone;
/**
* 驻店销售UUID列表
*/
private String storeManagerUuid;
}
package cn.com.glsx.dj.supervisor.job;
import cn.com.glsk.omni.ai.dto.LLMResponse;
import cn.com.glsk.omni.ai.remote.AgiRemote;
import cn.com.glsx.dj.supervisor.model.SupervisorAiAnalysisRecord;
import cn.com.glsx.dj.supervisor.service.SupervisorAiAnalysisRecordService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
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 分析结果轮询定时任务
* 每 10 秒执行一次,查询状态为"生成中"的 AI 分析记录,
* 调用 AgiRemote.queryLLMResult() 获取大模型结果并更新记录状态。
*/
@Slf4j
@Service
@ElasticJobConf(name = "SupervisorAiAnalysisQueryJob", cron = "*/10 * * * * ?", description = "督导AI分析结果轮询任务", overwrite = false)
public class SupervisorAiAnalysisQueryJob implements SimpleJob {
/** AI 任务状态:生成中 */
private static final int AI_TASK_STATUS_PENDING = 0;
/** AI 任务状态:成功 */
private static final int AI_TASK_STATUS_SUCCESS = 1;
/** AI 任务状态:失败 */
private static final int AI_TASK_STATUS_FAIL = 2;
@Autowired
private SupervisorAiAnalysisRecordService supervisorAiAnalysisRecordService;
@Autowired
private AgiRemote agiRemote;
@Override
public void execute(ShardingContext shardingContext) {
log.info("督导 AI 分析结果轮询任务开始执行");
try {
// 查询所有生成中的 AI 分析记录
List<SupervisorAiAnalysisRecord> pendingList = supervisorAiAnalysisRecordService.listPendingRecords();
if (CollectionUtils.isEmpty(pendingList)) {
log.info("暂无生成中的 AI 分析记录,本次轮询结束");
return;
}
log.info("查询到 {} 条生成中的 AI 分析记录,开始轮询结果", pendingList.size());
for (SupervisorAiAnalysisRecord record : pendingList) {
queryAndUpdateRecord(record);
}
} catch (Exception e) {
log.error("督导 AI 分析结果轮询任务执行异常", e);
}
log.info("督导 AI 分析结果轮询任务执行结束");
}
/**
* 查询单条记录的 AI 生成结果并更新数据库
*
* @param record 待查询的 AI 分析记录
*/
private void queryAndUpdateRecord(SupervisorAiAnalysisRecord record) {
Long recordId = record.getId();
String aiTaskId = record.getAiTaskId();
try {
log.info("开始查询 AI 分析结果,recordId={},aiTaskId={}", recordId, aiTaskId);
RpcResponse<LLMResponse> rpcResponse = agiRemote.queryLLMResult(aiTaskId);
if (rpcResponse == null || !rpcResponse.isSuccess()) {
String errorMsg = rpcResponse != null ? rpcResponse.getMessage() : "响应为空";
log.warn("查询 AI 分析结果失败,recordId={},aiTaskId={},error={}", recordId, aiTaskId, errorMsg);
return;
}
LLMResponse llmResponse = rpcResponse.getResult();
if (llmResponse == null) {
log.warn("AI 分析结果为空,recordId={},aiTaskId={}", recordId, aiTaskId);
return;
}
if (!llmResponse.isTaskFinished()) {
// 任务尚未完成,等待下次轮询
log.info("AI 分析任务尚未完成,继续等待,recordId={},aiTaskId={}", recordId, aiTaskId);
return;
}
if (!llmResponse.isSuccess()) {
// 任务完成但失败
log.warn("AI 分析任务执行失败,recordId={},aiTaskId={},error={}", recordId, aiTaskId, llmResponse.getError());
supervisorAiAnalysisRecordService.updateAiTaskResult(recordId, AI_TASK_STATUS_FAIL, llmResponse.getError());
return;
}
// 任务成功,更新结果
String result = llmResponse.getMessage();
log.info("AI 分析任务成功,recordId={},aiTaskId={},resultLength={}", recordId, aiTaskId, result != null ? result.length() : 0);
supervisorAiAnalysisRecordService.updateAiTaskResult(recordId, AI_TASK_STATUS_SUCCESS, result);
} catch (Exception e) {
log.error("查询并更新 AI 分析结果异常,recordId={},aiTaskId={}", recordId, aiTaskId, e);
}
}
}
......@@ -20,6 +20,7 @@ import cn.com.glsx.dj.supervisor.service.SupervisorTaskInfoService;
import cn.com.glsx.dj.supervisor.utils.DateUtils;
import cn.com.glsx.framework.core.beans.BaseModel;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
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;
......@@ -27,6 +28,7 @@ import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import java.math.BigDecimal;
......@@ -58,6 +60,9 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
@Autowired
private BusinessSceneAnalysisRemote businessSceneAnalysisRemote;
@Autowired
private Environment environment;
@Override
public void execute(ShardingContext shardingContext) {
......@@ -65,14 +70,17 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
log.info("督导录音复盘任务生成开始执行");
// 1. 查询系统中所有督导员工列表
List<cn.com.glsx.merchants.model.response.MerchantStaffResponse> supervisorList = supervisorTaskInfoService.listAllSupervisors();
List<MerchantStaffResponse> supervisorList = supervisorTaskInfoService.listAllEffectiveSupervisors();
if (supervisorList == null || supervisorList.isEmpty()) {
log.error("查询督导员工列表为空");
return;
}
String yesterday = DateUtils.getYesterdayDate();
//String yesterday = "2024-05-10";
//计算员工排名阈值
double rankThreshold = environment.getProperty("dj.supervisor.audio.review.task.rank.threshold", Double.class, 0.3);
// 2. 遍历督导员工列表
for (cn.com.glsx.merchants.model.response.MerchantStaffResponse supervisor : supervisorList) {
for (MerchantStaffResponse supervisor : supervisorList) {
try {
// 2.1 查询督导管理的门店列表,参考CommonUtil.getFlightSupervisionMerchantList方法
ShopMerchantDirectorConfigDTO dto = new ShopMerchantDirectorConfigDTO();
......@@ -95,7 +103,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
// 2.2 查询督导下面的员工列表
StaffBaseInfoDTO staffParam = new StaffBaseInfoDTO();
staffParam.setMerchantIdList(merchantIdList);
RpcResponse<List<StaffBaseInfoDTO>> staffResponse = staffBaseInfoRemote.listShopStaffBaseInfo(staffParam);
RpcResponse<List<StaffBaseInfoDTO>> staffResponse = staffBaseInfoRemote.listShopStaffInfoGroupByUUid(staffParam);
if (!staffResponse.isSuccess() || staffResponse.getResult() == null || staffResponse.getResult().isEmpty()) {
log.info("督导 {} 无管理员工", supervisor.getStaffName());
continue;
......@@ -103,9 +111,12 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
List<StaffBaseInfoDTO> staffList = staffResponse.getResult();
// 2.3 查询督导员工产值列表,根据手机号匹配员工产值
Map<String, BigDecimal> staffValueMap = getStaffValueMap(staffList, merchantIdList, yesterday);
//将staffList 用手机号分组, 并转为list
Map<String, StaffBaseInfoDTO> staffMap = staffList.stream().collect(Collectors.toMap(StaffBaseInfoDTO::getStaffPhone, v -> v, (v1, v2) -> v1));
//将staffMap 转为list
List<StaffBaseInfoDTO> staffPhoneList = staffMap.values().stream().collect(Collectors.toList());
// 3. 根据员工的产值,对员工进行排序(按产值降序排序,如果为空,排最后)
List<StaffBaseInfoDTO> sortedStaffList = staffList.stream()
List<StaffBaseInfoDTO> sortedStaffList = staffPhoneList.stream()
.sorted((s1, s2) -> {
BigDecimal v1 = staffValueMap.getOrDefault(s1.getStaffPhone(), BigDecimal.ZERO);
BigDecimal v2 = staffValueMap.getOrDefault(s2.getStaffPhone(), BigDecimal.ZERO);
......@@ -114,7 +125,7 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
.collect(Collectors.toList());
// 3.1 计算排名倒数30%的人员数量,向上取值
int totalStaff = sortedStaffList.size();
int poorPerfCount = (int) Math.ceil(totalStaff * 0.3);
int poorPerfCount = (int) Math.ceil(totalStaff * rankThreshold);
if (poorPerfCount <= 0) {
log.info("督导 {} 管理员工数量不足,无需生成录音复盘任务", supervisor.getStaffName());
continue;
......@@ -122,7 +133,6 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
// 3.2 获取绩差员工列表
List<StaffBaseInfoDTO> poorPerfStaffList = sortedStaffList.subList(
Math.max(0, totalStaff - poorPerfCount), totalStaff);
poorPerfStaffList.stream().map(StaffBaseInfoDTO::getStaffPhone).collect(Collectors.toList());
// 4. 根据绩差员工列表,查询员工昨日接待录音列表(接待状态为战败)
List<AudioReceptionDTO> audioList = getStaffAudioList(merchantIdList, poorPerfStaffList.stream().map(StaffBaseInfoDTO::getStaffPhone).collect(Collectors.toList()), yesterday);
if (CollectionUtils.isEmpty(audioList)) {
......@@ -161,10 +171,11 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
req.setCycleType(1); // 3.按日
// 设置时间范围,查询昨日数据
req.setStartTime(date);
req.setEndTime(date);
// 设置门店列表
req.setMerchantIds(merchantIdList);
//设置员工信息
req.setStaffPhones(staffList.stream().map(StaffBaseInfoDTO::getStaffPhone).collect(Collectors.toList()));
req.setStaffUuids(staffList.stream().map(StaffBaseInfoDTO::getLoginUuid).collect(Collectors.toList()));
// 调用远程接口查询督导员工产值列表
RpcResponse<List<StoreEmployeeRankResponse.EmployeeAnalysisItem>> response =
......@@ -206,8 +217,8 @@ public class SupervisorAudioReviewTaskJob implements SimpleJob {
/**
* 生成录音复盘任务记录
*/
private void generateAudioReviewTask(cn.com.glsx.merchants.model.response.MerchantStaffResponse supervisor,
List<AudioReceptionDTO> audioList) {
private void generateAudioReviewTask(MerchantStaffResponse supervisor,
List<AudioReceptionDTO> audioList) {
Date date = new Date();
// 1. 生成supervisor_task_info记录
SupervisorTaskInfo taskInfo = new SupervisorTaskInfo();
......
......@@ -4,6 +4,8 @@ import cn.com.glsx.dj.supervisor.model.SupervisorAiAnalysisRecord;
import org.apache.ibatis.annotations.Mapper;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
import java.util.List;
@Mapper
public interface SupervisorAiAnalysisRecordMapper extends OreMapper<SupervisorAiAnalysisRecord> {
......@@ -14,4 +16,11 @@ public interface SupervisorAiAnalysisRecordMapper extends OreMapper<SupervisorAi
* @return AI 分析记录
*/
SupervisorAiAnalysisRecord selectByCondition(SupervisorAiAnalysisRecord record);
/**
* 查询所有生成中(ai_task_status=0)的 AI 分析记录列表
*
* @return 生成中的记录列表
*/
List<SupervisorAiAnalysisRecord> selectPendingRecords();
}
......@@ -12,7 +12,7 @@ import java.util.List;
@Mapper
public interface SupervisorAudioReviewInfoMapper extends OreMapper<SupervisorAudioReviewInfo> {
List<AudioReceptionDTO> listAudionByReceptionId(@Param("relationId") Long receptionId);
List<AudioReceptionDTO> listAudionByReceptionId(SupervisorTaskQueryDTO query);
List<AudioReceptionDTO> listAudionByEmployeeInfo(SupervisorTaskQueryDTO query);
......
package cn.com.glsx.dj.supervisor.mapper;
import cn.com.glsx.dj.supervisor.dto.MapperQueryEmployeeTrainingInfoDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.dto.TrainingListDTO;
import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskInfo;
import org.apache.ibatis.annotations.MapKey;
import org.apache.ibatis.annotations.Mapper;
......@@ -54,10 +51,44 @@ public interface SupervisorTaskInfoMapper extends OreMapper<SupervisorTaskInfo>
List<Integer> queryMerchantBySupervisorPhone(@Param("phoneList") List<String> phoneList);
/**
* 按督导手机号分组,统计各督导管理的门店数量
* key=director_phone, value=COUNT(DISTINCT merchant_id)
*
* @param phoneList 督导手机号列表
* @return key为手机号,value为门店数
*/
@MapKey("directorPhone")
Map<String, SupervisorStoreCountDTO> queryStoreCountGroupByPhone(@Param("phoneList") List<String> phoneList);
/**
* 查询给定门店列表下的全部驻店人员uuid列表
*
* @param merchantIdList
* @return
*/
List<String> queryStoreManagerUuidByMerchantId(@Param("merchantIdList") List<Integer> merchantIdList);
/**
* 通过督导手机号查询驻店人员uuid列表
*
* @param phoneList
* @return
*/
List<SupervisorStoreManagerDTO> queryStoreMangerUuidListBySupervisorPhone(@Param("phoneList") List<String> phoneList);
/**
* 通过飞行督导手机号查询与门店的关联关系列表
*
* @param supervisorPhoneList 飞行督导手机号
* @return 门店关联关系列表
*/
List<SupervisorDirectorConfigDTO> queryDirectorConfigBySupervisorPhone(@Param("supervisorPhoneList") List<String> supervisorPhoneList);
/**
* 通过门店商户号列表查询门店与驻店销售的关联关系列表
*
* @param merchantIdList 门店商户号列表
* @return 驻店销售关联关系列表
*/
List<SupervisorStaffAccountDTO> queryStaffAccountByMerchantIdList(@Param("merchantIdList") List<Integer> merchantIdList);
}
\ No newline at end of file
......@@ -3,7 +3,12 @@ package cn.com.glsx.dj.supervisor.remote;
import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.dto.AudioReceptionDTO;
import cn.com.glsx.dj.supervisor.dto.AudioSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorDetailQueryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorDetailStaffDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorDetailSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorManageSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorPageDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorPageQueryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.model.SupervisorAudioReviewInfo;
......@@ -153,6 +158,22 @@ public class SupervisorTaskInfoRemoteImpl implements SupervisorTaskInfoRemote {
}
}
@Override
public RpcResponse<AudioReceptionDTO> getAudioReviewDetail(SupervisorTaskQueryDTO request) {
try {
AudioReceptionDTO result = supervisorAudioReviewInfoService.getAudioReviewDetail(request);
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getAudioReviewDetail error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getAudioReviewDetail system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<Long> submitCoaching(SupervisorTaskDTO request) {
try {
......@@ -198,4 +219,68 @@ public class SupervisorTaskInfoRemoteImpl implements SupervisorTaskInfoRemote {
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<RpcPagination<SupervisorPageDTO>> pageSupervisors(RpcPagination<SupervisorPageQueryDTO> request) {
try {
log.info("分页查询督导列表 - 开始查询");
RpcPagination<SupervisorPageDTO> result = supervisorTaskInfoService.pageSupervisors(request);
log.info("分页查询督导列表 - 查询成功,total={}", result.getTotal());
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageSupervisors error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageSupervisors system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<SupervisorDetailSummaryDTO> getDetailSummary(SupervisorDetailQueryDTO request) {
try {
log.info("督导管理详情页汇总 - 开始查询,request={}", request);
SupervisorDetailSummaryDTO result = supervisorTaskInfoService.getDetailSummary(request);
log.info("督导管理详情页汇总 - 查询成功");
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getDetailSummary error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.getDetailSummary system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<RpcPagination<SupervisorDetailStaffDTO>> pageDetailStaff(RpcPagination<SupervisorDetailQueryDTO> request) {
try {
log.info("督导管理详情页驻店销售分页 - 开始查询");
RpcPagination<SupervisorDetailStaffDTO> result = supervisorTaskInfoService.pageDetailStaff(request);
log.info("督导管理详情页驻店销售分页 - 查询成功,total={}", result.getTotal());
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageDetailStaff error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.pageDetailStaff system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<Long> createSpecialTask(CreateSpecialTaskDTO request) {
try {
log.info("新增专项任务 - 开始,request={}", request);
Long taskId = supervisorTaskInfoService.createSpecialTask(request);
log.info("新增专项任务 - 成功,taskId={}", taskId);
return RpcResponse.success(taskId);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.createSpecialTask error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorTaskInfoRemoteImpl.createSpecialTask system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
}
}
......@@ -45,4 +45,18 @@ public class SupervisorWarningBaselineConfigRemoteImpl implements SupervisorWarn
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
@Override
public RpcResponse<Boolean> deleteWarningBaselineConfig(WarningBaselineConfigDTO request) {
try {
Boolean result = supervisorWarningBaselineConfigService.deleteWarningBaselineConfig(request);
return RpcResponse.success(result);
} catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorWarningBaselineConfigRemoteImpl.deleteWarningBaselineConfig error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorWarningBaselineConfigRemoteImpl.deleteWarningBaselineConfig system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVICE_ERROR, e.getMessage());
}
}
}
......@@ -2,12 +2,14 @@ package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.mapper.SupervisorAiAnalysisRecordMapper;
import cn.com.glsx.dj.supervisor.model.SupervisorAiAnalysisRecord;
import cn.com.glsx.framework.core.beans.BaseModel;
import cn.hutool.core.date.DateUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Collections;
import java.util.Date;
import java.util.List;
/**
* 督导 AI 分析记录 Service 实现类
*
......@@ -31,4 +33,40 @@ public class SupervisorAiAnalysisRecordService {
throw new RuntimeException("查询失败:" + e.getMessage(), e);
}
}
/**
* 查询所有生成中(ai_task_status=0)的 AI 分析记录列表
*
* @return 生成中的记录列表
*/
public List<SupervisorAiAnalysisRecord> listPendingRecords() {
try {
List<SupervisorAiAnalysisRecord> list = supervisorAiAnalysisRecordMapper.selectPendingRecords();
return list != null ? list : Collections.emptyList();
} catch (Exception e) {
log.error("查询生成中的 AI 分析记录列表异常", e);
return Collections.emptyList();
}
}
/**
* 更新 AI 任务状态和生成结果
*
* @param id 记录 ID
* @param aiTaskStatus AI 任务状态(1-成功、2-失败)
* @param aiGenerateResult AI 生成结果(失败时可为 null)
*/
public void updateAiTaskResult(Long id, Integer aiTaskStatus, String aiGenerateResult) {
try {
SupervisorAiAnalysisRecord update = new SupervisorAiAnalysisRecord();
update.setId(id);
update.setAiTaskStatus(aiTaskStatus);
update.setAiGenerateResult(aiGenerateResult);
update.setUpdatedBy("system");
update.setUpdatedTime(new Date());
supervisorAiAnalysisRecordMapper.updateByPrimaryKeySelective(update);
} catch (Exception e) {
log.error("更新 AI 任务状态异常,id={}", id, e);
}
}
}
......@@ -2,6 +2,7 @@ package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.dto.AudioReceptionDTO;
import cn.com.glsx.dj.supervisor.dto.AudioSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.enums.ReviewStatusEnum;
import cn.com.glsx.dj.supervisor.enums.TaskStatusEnum;
......@@ -15,6 +16,7 @@ import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.oreframework.distribute.lock.annotation.GlsxDistributeLockable;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
......@@ -57,7 +59,7 @@ public class SupervisorAudioReviewInfoService {
public Page<AudioReceptionDTO> pageAudioReception(RpcPagination<SupervisorTaskQueryDTO> request) {
//分页查询
Page<AudioReceptionDTO> page = PageHelper.startPage(request.getPageNum(), request.getPageSize());
List<AudioReceptionDTO> list = supervisorAudioReviewInfoMapper.listAudionByReceptionId(request.getCondition().getId());
List<AudioReceptionDTO> list = supervisorAudioReviewInfoMapper.listAudionByReceptionId(request.getCondition());
if(CollectionUtils.isNotEmpty(list)) {
list.forEach(item -> {
//处理录音时长
......@@ -69,6 +71,20 @@ public class SupervisorAudioReviewInfoService {
return page;
}
/**
* 查询录音复盘记录详情
* @param query
* @return
*/
public AudioReceptionDTO getAudioReviewDetail(SupervisorTaskQueryDTO query) {
List<AudioReceptionDTO> audioReceptionDTOS = supervisorAudioReviewInfoMapper.listAudionByReceptionId(query);
if (CollectionUtils.isNotEmpty(audioReceptionDTOS)) {
return audioReceptionDTOS.get(0);
}
return null;
}
public List<AudioReceptionDTO> listAudionByEmployeeInfo(SupervisorTaskQueryDTO query) {
return supervisorAudioReviewInfoMapper.listAudionByEmployeeInfo(query);
}
......@@ -89,6 +105,12 @@ public class SupervisorAudioReviewInfoService {
dto.setUnreviewedCount((int) unreviewedCount);
dto.setTotalCount(list.size());
}
//查询 录音任务详情
SupervisorTaskDTO task = supervisorTaskInfoService.getTaskDetailById(request.getId());
if (task != null) {
dto.setTaskStatus(task.getTaskStatus());
dto.setCreateTime(task.getCreateTime());
}
return dto;
}
......@@ -107,7 +129,7 @@ public class SupervisorAudioReviewInfoService {
throw new RpcServiceException(DefaultErrorEnum.DATA_NOT_EXIST, "录音复盘记录不存在");
}
//判断是否已复盘
if (ReviewStatusEnum.COMPLETED.getCode().equals(info.getReviewStatus())) {
if (ReviewStatusEnum.COMPLETED.getCode().equals(info.getReviewStatus()) && StringUtils.isBlank(request.getReviewTarget())) {
log.error("提交录音复盘记录,录音复盘记录已复盘,id={}", request.getId());
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "录音复盘记录已复盘,不能重复提交");
}
......
......@@ -130,7 +130,7 @@ public class SupervisorDashboardService {
* @param dashboardQueryReq 请求参数
* @return 指标数据
*/
private List<EmployeeRanking> getDashboardMetrics(DashboardQueryReq dashboardQueryReq) {
public List<EmployeeRanking> getDashboardMetrics(DashboardQueryReq dashboardQueryReq) {
// 1.获取 BI 指标数据
DataBizQueryParamsDTO params = new DataBizQueryParamsDTO();
......
......@@ -4,6 +4,8 @@ import cn.com.glsx.dj.supervisor.dto.WarningBaselineConfigDTO;
import cn.com.glsx.dj.supervisor.mapper.SupervisorWarningBaselineConfigMapper;
import cn.com.glsx.dj.supervisor.model.SupervisorWarningBaselineConfig;
import cn.com.glsx.framework.core.beans.BaseModel;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
......@@ -32,34 +34,58 @@ public class SupervisorWarningBaselineConfigService {
* @return 是否成功
*/
@GlsxDistributeLockable(name = "warningBaselineConfig_createOrUpdateWarningBaselineConfig", timeoutException = Exception.class)
public Boolean createOrUpdateWarningBaselineConfig(WarningBaselineConfigDTO config) {
//根据 指标+ 时间维度查询数据库是否已经配置过相同记录
List<SupervisorWarningBaselineConfig> configList = queryWarningBaselineConfig(config.getIndicatorCode(), config.getTimeDimension());
Date now = new Date();
if (CollectionUtils.isEmpty(configList)) {
// 新增
config.getConfigList().stream().forEach(item -> {
item.setIndicatorCode(config.getIndicatorCode());
item.setIndicatorName(config.getIndicatorName());
item.setTimeDimension(config.getTimeDimension());
item.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
item.setCreatedBy(config.getUpdatedBy());
item.setCreateTime(now);
item.setUpdatedBy(config.getUpdatedBy());
item.setUpdatedDate(now);
});
supervisorWarningBaselineConfigMapper.insertList(config.getConfigList());
} else {
// 更新
config.getConfigList().stream().forEach(item -> {
item.setUpdatedBy(config.getUpdatedBy());
item.setUpdatedDate(now);
});
//批量更新
supervisorWarningBaselineConfigMapper.batchUpdate(config.getConfigList());
}
return true;
}
public Boolean createOrUpdateWarningBaselineConfig(WarningBaselineConfigDTO config) {
//根据 指标+ 时间维度查询数据库是否已经配置过相同记录
List<SupervisorWarningBaselineConfig> configList = queryWarningBaselineConfig(config.getIndicatorCode(), config.getTimeDimension());
Date now = new Date();
//判断是否为新增操作
if (config.getUpdateFlag() == 0) {
if (CollectionUtils.isNotEmpty(configList)) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "已存在相同预警基线设置!");
}
// 新增
config.getConfigList().stream().forEach(item -> {
item.setIndicatorCode(config.getIndicatorCode());
item.setIndicatorName(config.getIndicatorName());
item.setTimeDimension(config.getTimeDimension());
item.setDeletedFlag(BaseModel.DeletedFlagEnum.N.name());
item.setCreatedBy(config.getUpdatedBy());
item.setCreateTime(now);
item.setUpdatedBy(config.getUpdatedBy());
item.setUpdatedDate(now);
});
supervisorWarningBaselineConfigMapper.insertList(config.getConfigList());
} else {
// 过滤出需要更新的记录
List<Long> updateList = config.getConfigList().stream()
.filter(item -> item.getId() != null).
map(SupervisorWarningBaselineConfig::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(updateList)) {
//没传id, 抛异常
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "更新预警基线配置时,必须传递id!");
}
if (CollectionUtils.isNotEmpty(configList)) {
//检查 更新的id是否存在,如果不存在,说明已经存在其他指标配置,不能更新
List<Long> existList = configList.stream()
.filter(item -> updateList.contains(item.getId()))
.map(SupervisorWarningBaselineConfig::getId).collect(Collectors.toList());
if (CollectionUtils.isEmpty(existList)) {
throw new RpcServiceException(DefaultErrorEnum.SERVER_ERROR, "已存在相同预警基线设置!");
}
}
// 更新
config.getConfigList().stream().forEach(item -> {
item.setIndicatorCode(config.getIndicatorCode());
item.setIndicatorName(config.getIndicatorName());
item.setTimeDimension(config.getTimeDimension());
item.setUpdatedBy(config.getUpdatedBy());
item.setUpdatedDate(now);
});
//批量更新
supervisorWarningBaselineConfigMapper.batchUpdate(config.getConfigList());
}
return true;
}
/**
* 指标+ 时间维度查询数据库记录
......@@ -111,6 +137,34 @@ public class SupervisorWarningBaselineConfigService {
}).collect(Collectors.toList());
}
/**
* 删除预警基线配置
* @param config 预警基线配置DTO
* @return 是否成功
*/
@GlsxDistributeLockable(name = "warningBaselineConfig_deleteWarningBaselineConfig", timeoutException = Exception.class)
public Boolean deleteWarningBaselineConfig(WarningBaselineConfigDTO config) {
//根据 指标+ 时间维度查询数据库是否已经配置过相同记录
List<SupervisorWarningBaselineConfig> configList = queryWarningBaselineConfig(config.getIndicatorCode(), config.getTimeDimension());
if (CollectionUtils.isEmpty(configList)) {
return false;
}
// 逻辑删除
SupervisorWarningBaselineConfig update = new SupervisorWarningBaselineConfig();
update.setDeletedFlag(BaseModel.DeletedFlagEnum.D.name());
update.setUpdatedBy(config.getUpdatedBy());
update.setUpdatedDate(new Date());
//批量更新
Example example = new Example(SupervisorWarningBaselineConfig.class);
Example.Criteria criteria = example.createCriteria();
//根据 指标编码+时间维度更新
criteria.andEqualTo("indicatorCode", config.getIndicatorCode());
criteria.andEqualTo("timeDimension", config.getTimeDimension());
criteria.andEqualTo("deletedFlag", BaseModel.DeletedFlagEnum.N.name());
supervisorWarningBaselineConfigMapper.updateByExampleSelective(update, example);
return true;
}
......
......@@ -67,4 +67,15 @@
</if>
</where>
</select>
<select id="selectPendingRecords" resultMap="ResultMapWithBLOBs">
SELECT
<include refid="Base_Column_List"/>,
<include refid="Blob_Column_List"/>
FROM supervisor_ai_analysis_record
WHERE deleted_flag = 'N'
AND ai_task_status = 0
AND ai_task_id IS NOT NULL
ORDER BY created_time ASC
</select>
</mapper>
......@@ -25,8 +25,8 @@
create_time, updated_by, updated_date, deleted_flag
</sql>
<select id="listAudionByReceptionId" resultType="cn.com.glsx.dj.supervisor.dto.AudioReceptionDTO">
select sari.id, sari.receptionId as batchId, sari.reviewStatus, sari.review_target reviewTarget, sari.review_context reviewContext,
<select id="listAudionByReceptionId" parameterType="cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO" resultType="cn.com.glsx.dj.supervisor.dto.AudioReceptionDTO">
select sari.id, sari.reception_id as batchId, sari.review_status reviewStatus, sari.review_target reviewTarget, sari.review_context reviewContext,
t2.audio_time as staticDate,t1.employee_name employeeName,re.customer_name customerName,re.phone_number as phoneNumber,
re.merchant_id merchantNo,re.car_model carModel, re.car_brand as carBrand,
ind.customer_type as customerType,ind.avg_defence as avgDefence,
......@@ -41,14 +41,19 @@
left join dj_car_life_service_merchant sm on re.merchant_id = sm.merchant_id and sm.deleted_flag= 'N'
<where>
sari.deleted_flag = 'N' and cb.deleted_flag = 'N'
and sari.relation_id = #{relationId}
<if test="id != null">
and sari.relation_id = #{id}
</if>
<if test="audioId != null">
and sari.id = #{audioId}
</if>
</where>
order by cb.start_time desc
</select>
<select id="listAudionByEmployeeInfo" parameterType="cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO" resultType="cn.com.glsx.dj.supervisor.dto.AudioReceptionDTO">
select cb.id as batchId , t1.phone_number as staffPhone
from join inspection_conversation_batch cb
from inspection_conversation_batch cb
left join reception_customer_info re on cb.task_id = re.id
left join inspection_conversation_date t2 on cb.conversation_id = t2.id
left join inspection_employee_badge t1 on t1.badge_id = t2.badge_id
......
......@@ -46,11 +46,18 @@
<result column="updated_date" property="updatedDate" jdbcType="TIMESTAMP" />
<result column="updated_by" property="updatedBy" />
<result column="updated_phone" property="updatedPhone" />
<result column="store_manager_phone" property="storeManagerPhone" jdbcType="VARCHAR" />
<result column="store_manager_name" property="storeManagerName" jdbcType="VARCHAR" />
<collection property="taskImageList" ofType="cn.com.glsx.dj.supervisor.model.SupervisorTaskImage">
<result column="image_url" property="imageUrl" />
</collection>
</resultMap>
<resultMap id="supervisorStoreManagerDTOMap" type="cn.com.glsx.dj.supervisor.dto.SupervisorStoreManagerDTO">
<result column="supervisorPhone" property="supervisorPhone"/>
<result column="storeManagerUuid" property="storeManagerUuid"/>
</resultMap>
<sql id="Base_Column_List" >
<!--
WARNING - @mbg.generated
......@@ -68,7 +75,7 @@
<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,
stim.image_url
stim.image_url,sti.store_manager_name,sti.store_manager_phone
from supervisor_task_info sti
left join supervisor_task_image stim on stim.relation_id = sti.id and stim.deleted_flag = 'N'
<where>
......@@ -92,10 +99,10 @@
</foreach>
</if>
<if test="startDate != null and startDate != ''">
and sti.start_date &gt;= #{startDate}
and CAST(sti.create_time AS DATE) &gt;= #{startDate, jdbcType=DATE}
</if>
<if test="endDate != null and endDate != ''">
and sti.end_date &lt;= #{endDate}
and CAST(sti.create_time AS DATE) &lt;= #{endDate, jdbcType=DATE}
</if>
<if test="taskStatus != null">
and sti.task_status = #{taskStatus}
......@@ -199,6 +206,19 @@
#{i}
</foreach>
</select>
<select id="queryStoreCountGroupByPhone" resultType="cn.com.glsx.dj.supervisor.dto.SupervisorStoreCountDTO">
SELECT director_phone AS directorPhone,
COUNT(DISTINCT merchant_id) AS storeCount
FROM dj_car_life_shop_merchant_director_config
WHERE deleted_flag = 'N'
AND director_type = 6
AND director_phone IN
<foreach collection="phoneList" open="(" item="i" close=")" separator=",">
#{i}
</foreach>
GROUP BY director_phone
</select>
<select id="queryStoreManagerUuidByMerchantId" resultType="java.lang.String">
SELECT DISTINCT staff_uuid
FROM dj_car_life_staff_account_record
......@@ -210,5 +230,60 @@
#{i}
</foreach>
</select>
<select id="queryStoreMangerUuidListBySupervisorPhone" resultMap="supervisorStoreManagerDTOMap">
SELECT distinct
d.director_phone AS supervisorPhone,
s.staff_uuid AS storeManagerUuid
FROM dj_car_life_shop_merchant_director_config d
INNER JOIN dj_car_life_staff_account_record s ON d.merchant_id = s.merchant_id AND s.deleted_flag = 'N'
WHERE d.director_type = 6
AND d.deleted_flag = 'N'
AND s.job_type = 11
AND s.created_source = 6
AND d.director_phone in
<foreach collection="phoneList" open="(" item="i" close=")" separator=",">
#{i}
</foreach>
</select>
<resultMap id="supervisorDirectorConfigDTOMap" type="cn.com.glsx.dj.supervisor.dto.SupervisorDirectorConfigDTO">
<result column="merchant_id" property="merchantId"/>
<result column="director_type" property="directorType"/>
<result column="director_user_id" property="directorUserId"/>
<result column="director_name" property="directorName"/>
<result column="director_phone" property="directorPhone"/>
</resultMap>
<resultMap id="supervisorStaffAccountDTOMap" type="cn.com.glsx.dj.supervisor.dto.SupervisorStaffAccountDTO">
<result column="staff_uuid" property="staffUuid"/>
<result column="staff_phone" property="staffPhone"/>
<result column="merchant_id" property="merchantId"/>
<result column="merchant_name" property="merchantName"/>
<result column="yq_merchant_id" property="yqMerchantId"/>
<result column="yq_merchant_name" property="yqMerchantName"/>
</resultMap>
<select id="queryDirectorConfigBySupervisorPhone" resultMap="supervisorDirectorConfigDTOMap">
SELECT merchant_id, director_type, director_user_id, director_name, director_phone
FROM dj_car_life_shop_merchant_director_config
WHERE deleted_flag = 'N'
AND director_type = 6
AND director_phone in
<foreach collection="supervisorPhoneList" open="(" item="i" close=")" separator=",">
#{i}
</foreach>
</select>
<select id="queryStaffAccountByMerchantIdList" resultMap="supervisorStaffAccountDTOMap">
SELECT staff_uuid, staff_phone, merchant_id, merchant_name, yq_merchant_id, yq_merchant_name
FROM dj_car_life_staff_account_record
WHERE deleted_flag = 'N'
AND job_type = 11
AND created_source = 6
AND merchant_id IN
<foreach collection="merchantIdList" open="(" item="i" close=")" separator=",">
#{i}
</foreach>
</select>
</mapper>
\ No newline at end of file
......@@ -29,6 +29,21 @@
<update id="batchUpdate">
UPDATE supervisor_warning_baseline_config
SET
indicator_code = CASE
<foreach collection="list" item="item" separator="">
WHEN id = #{item.id} THEN #{item.indicatorCode}
</foreach>
END,
indicator_name = CASE
<foreach collection="list" item="item" separator="">
WHEN id = #{item.id} THEN #{item.indicatorName}
</foreach>
END,
time_dimension = CASE
<foreach collection="list" item="item" separator="">
WHEN id = #{item.id} THEN #{item.timeDimension}
</foreach>
END,
min_value = CASE
<foreach collection="list" item="item" separator="">
WHEN id = #{item.id} THEN #{item.minValue}
......
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.dto.AudioReceptionDTO;
import cn.com.glsx.dj.supervisor.dto.AudioSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.model.SupervisorAudioReviewInfo;
import cn.com.glsx.framework.core.beans.rpc.RpcPagination;
import com.github.pagehelper.Page;
import org.apache.commons.collections4.CollectionUtils;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import static org.junit.Assert.assertTrue;
public class SupervisorAudioReviewInfoServiceTest extends BaseServiceTest {
@Autowired
private SupervisorAudioReviewInfoService supervisorAudioReviewInfoService;
/**
* 测试提交录音复盘记录
*/
@Test
public void testSubmitAudioReview() {
SupervisorAudioReviewInfo request = new SupervisorAudioReviewInfo();
request.setId(1L);
request.setReviewContext("测试录音");
request.setReviewTarget("标签仔");
request.setUpdatedBy("fanfr");
Boolean result = supervisorAudioReviewInfoService.submitAudioReview(request);
assertTrue(result);
}
/**
* 测试 分页查询录音复盘记录
*/
@Test
public void testQueryAudioReviewInfoPage() {
RpcPagination<SupervisorTaskQueryDTO> request = new RpcPagination<>();
request.setPageNum(1);
request.setPageSize(10);
SupervisorTaskQueryDTO condition = new SupervisorTaskQueryDTO();
request.setCondition(condition);
condition.setId(16L);
Page<AudioReceptionDTO> result = supervisorAudioReviewInfoService.pageAudioReception(request);
assertTrue(CollectionUtils.isNotEmpty(result));
}
/**
* 测试 查询录音复盘汇总信息(getAudioSummary)
*/
@Test
public void testQueryAudioReviewSummary() {
Long id = 16L;
SupervisorTaskQueryDTO request = new SupervisorTaskQueryDTO();
request.setId(id);
AudioSummaryDTO result = supervisorAudioReviewInfoService.getAudioSummary(request);
assertTrue(result != null);
}
}
package cn.com.glsx.dj.supervisor.service;
import cn.com.glsx.dj.supervisor.job.SupervisorAudioReviewTaskJob;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
public class SupervisorAudioReviewTaskJobTest extends BaseServiceTest {
@Autowired
private SupervisorAudioReviewTaskJob supervisorAudioReviewTaskJob;
@Test
public void testExecute() {
supervisorAudioReviewTaskJob.execute(null);
}
}
......@@ -4,10 +4,12 @@ import cn.com.glsx.dj.supervisor.dto.SupervisorManageSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskQueryDTO;
import cn.com.glsx.dj.supervisor.dto.SupervisorTaskSummaryDTO;
import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskCourse;
import cn.com.glsx.dj.supervisor.model.SupervisorTaskImage;
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 com.alibaba.fastjson.JSON;
import com.github.pagehelper.Page;
import org.junit.Test;
......@@ -166,6 +168,8 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
request.setCondition(queryDTO);
List<Integer> typeList = Arrays.asList(0, 3, 5);
queryDTO.setTaskTypeList(typeList);
queryDTO.setStartDate("2026-01-01");
queryDTO.setEndDate("2026-01-31");
request.setPageSize(10);
request.setPageNum(1);
Page<SupervisorTaskDTO> supervisorTaskDTOS = supervisorTaskInfoService.pageTask(request);
......@@ -194,4 +198,25 @@ public class SupervisorTaskInfoServiceTest extends BaseServiceTest {
SupervisorTaskSummaryDTO summary = supervisorTaskInfoService.getTaskSummary(queryDTO);
System.out.println(JSON.toJSONString(summary));
}
@Test
public void testPageSupervisors() {
RpcPagination<SupervisorPageQueryDTO> pagination = new RpcPagination<>();
pagination.setPageNum(1);
pagination.setPageSize(10);
RpcPagination<SupervisorPageDTO> paged = supervisorTaskInfoService.pageSupervisors(pagination);
System.out.println(JSON.toJSONString(paged));
}
@Test
public void testCreateSpecialTask() {
CreateSpecialTaskDTO request = new CreateSpecialTaskDTO();
request.setMerchantId(43423334);
request.setMerchantName("萨达梵蒂冈");
request.setSupervisorPhone("13603070903");
request.setSupervisorName("谢海旭");
request.setCreatedBy("admin");
request.setTaskDesc("督导记录sdhnasuihfasifnasfnassjasidjkioasdasfn");
Long id = supervisorTaskInfoService.createSpecialTask(request);
}
}
\ No newline at end of file
......@@ -22,30 +22,31 @@ public class SupervisorWarningBaselineConfigServiceTest extends BaseServiceTest
@Test
public void testCreateOrUpdateWarningBaselineConfig() {
WarningBaselineConfigDTO config = new WarningBaselineConfigDTO();
config.setIndicatorCode("A036");
config.setIndicatorName("个人产值");
config.setIndicatorCode("A076");
config.setIndicatorName("个人客单价");
config.setTimeDimension(2);
config.setUpdateFlag(1);
List<SupervisorWarningBaselineConfig> configList = new java.util.ArrayList<>();
SupervisorWarningBaselineConfig redItem = new SupervisorWarningBaselineConfig();
redItem.setMinValue(new BigDecimal(0));
redItem.setMaxValue(new BigDecimal(1200));
redItem.setMaxValueInf(0);
redItem.setWarningLevel(0);
redItem.setId(4L);
redItem.setId(10L);
configList.add(redItem);
SupervisorWarningBaselineConfig yellowItem = new SupervisorWarningBaselineConfig();
yellowItem.setMinValue(new BigDecimal(1200));
yellowItem.setMaxValue(new BigDecimal(4000));
yellowItem.setMaxValueInf(0);
yellowItem.setWarningLevel(1);
yellowItem.setId(5L);
yellowItem.setId(11L);
configList.add(yellowItem);
SupervisorWarningBaselineConfig greenItem = new SupervisorWarningBaselineConfig();
greenItem.setMinValue(new BigDecimal(4000));
greenItem.setMaxValue(new BigDecimal(6000));
greenItem.setMaxValueInf(0);
greenItem.setWarningLevel(2);
greenItem.setId(6L);
greenItem.setId(12L);
configList.add(greenItem);
config.setConfigList(configList);
config.setUpdatedBy("system");
......@@ -61,4 +62,19 @@ public class SupervisorWarningBaselineConfigServiceTest extends BaseServiceTest
List<WarningBaselineConfigDTO> configList = supervisorWarningBaselineConfigService.listAllWarningBaselineConfig();
assertTrue(configList.size() > 0);
}
/**
* 测试删除
*/
@Test
public void testDeleteWarningBaselineConfig() {
WarningBaselineConfigDTO config = new WarningBaselineConfigDTO();
config.setIndicatorCode("A036");
config.setTimeDimension(2);
config.setUpdatedBy("system");
Boolean result = supervisorWarningBaselineConfigService.deleteWarningBaselineConfig(config);
assertTrue(result);
List<WarningBaselineConfigDTO> configList = supervisorWarningBaselineConfigService.listAllWarningBaselineConfig();
assertTrue(configList.size() > 0);
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!