Commit d22582e8 by zhouhaibao

[+]督导团队业绩和个人业绩查询

1 parent 222378e8
...@@ -74,4 +74,10 @@ public class DashboardQueryReq implements Serializable { ...@@ -74,4 +74,10 @@ public class DashboardQueryReq implements Serializable {
@ApiModelProperty(value = "排序方向", example = "1", notes = "排序方向:0.升序 1.降序") @ApiModelProperty(value = "排序方向", example = "1", notes = "排序方向:0.升序 1.降序")
private Integer sortDirection; private Integer sortDirection;
/**
* 是否需要触发AI分析:true-需要,false-不需要
*/
@ApiModelProperty(value = "是否需要触发AI分析", example = "true", notes = "是否需要触发AI分析:true-需要,false-不需要")
private Boolean needAiAnalysis = true;
} }
\ No newline at end of file \ No newline at end of file
...@@ -26,9 +26,9 @@ public class EmployeeBasicInfoReq implements Serializable { ...@@ -26,9 +26,9 @@ public class EmployeeBasicInfoReq implements Serializable {
private String employeeId; private String employeeId;
/** /**
* 督导ID * 手机号
*/ */
@ApiModelProperty(value = "督导ID", example = "123", required = true) @ApiModelProperty(value = "手机号", example = "18845678901", required = true)
private Long supervisorId; private String phone;
} }
\ No newline at end of file \ No newline at end of file
...@@ -163,6 +163,18 @@ public class EmployeeBehaviorDTO implements Serializable { ...@@ -163,6 +163,18 @@ public class EmployeeBehaviorDTO implements Serializable {
private Map<String, String> behaviorTags; private Map<String, String> behaviorTags;
/** /**
* 弱项
*/
@ApiModelProperty(value = "弱项", notes = "弱项")
private Map<String, String> badList;
/**
* 其他
*/
@ApiModelProperty(value = "其他", notes = "其他")
private Map<String, String> ohterList;
/**
* 量化指标 * 量化指标
*/ */
@ApiModelProperty(value = "量化指标") @ApiModelProperty(value = "量化指标")
......
...@@ -33,10 +33,10 @@ public class EmployeeBehaviorReq implements Serializable { ...@@ -33,10 +33,10 @@ public class EmployeeBehaviorReq implements Serializable {
private Long supervisorId; private Long supervisorId;
/** /**
* 场景 * 业务类型:1.延保 2.轻改 3.权益 4.二手车 必传
*/ */
@ApiModelProperty(value = "场景", example = "sales") @ApiModelProperty(value = "业务类型", example = "1", notes = "业务类型:1.延保 2.轻改 3.权益 4.二手车 必传")
private String scene; private Integer bizs;
/** /**
* 开始日期 * 开始日期
...@@ -56,4 +56,11 @@ public class EmployeeBehaviorReq implements Serializable { ...@@ -56,4 +56,11 @@ public class EmployeeBehaviorReq implements Serializable {
@ApiModelProperty(value = "门店ID", example = "1001") @ApiModelProperty(value = "门店ID", example = "1001")
private Integer merchantId; private Integer merchantId;
/**
* 员工手机号
*/
@ApiModelProperty(value = "员工手机号", example = "13800138000", required = true)
private String phone;
} }
...@@ -99,6 +99,109 @@ public class EmployeePerformanceDTO implements Serializable { ...@@ -99,6 +99,109 @@ public class EmployeePerformanceDTO implements Serializable {
*/ */
@ApiModelProperty(value = "总成交数环比", example = "12%") @ApiModelProperty(value = "总成交数环比", example = "12%")
private String totalDealsRate; private String totalDealsRate;
// 新增指标
/**
* 触客率(指标A064)
*/
@ApiModelProperty(value = "触客率(指标A064)", example = "85%")
private String customerContactRate;
/**
* 转化率(指标A085)
*/
@ApiModelProperty(value = "转化率(指标A085)", example = "75%")
private String conversionRate;
/**
* 渗透率(指标A077)
*/
@ApiModelProperty(value = "渗透率(指标A077)", example = "60%")
private String penetrationRate;
/**
* 平均客单价(指标A095)
*/
@ApiModelProperty(value = "平均客单价(指标A095)", example = "10000")
private Integer avgUnitPrice;
/**
* 新车交付数(指标A062)
*/
@ApiModelProperty(value = "新车交付数(指标A062)", example = "50")
private Integer newCarDeliveryCount;
/**
* 整车延保-渗透率(门店)(指标A067)
*/
@ApiModelProperty(value = "整车延保-渗透率(门店)(指标A067)", example = "45%")
private String vehicleWarrantyPenetrationStore;
/**
* 整车延保-成交数(指标A066)
*/
@ApiModelProperty(value = "整车延保-成交数(指标A066)", example = "20")
private Integer vehicleWarrantyDealCount;
/**
* 电池-渗透率(门店)(指标A094)
*/
@ApiModelProperty(value = "电池-渗透率(门店)(指标A094)", example = "30%")
private String batteryPenetrationStore;
/**
* 电池-成交数(指标A070)
*/
@ApiModelProperty(value = "电池-成交数(指标A070)", example = "15")
private Integer batteryDealCount;
/**
* 安心包-渗透率(门店)(指标A092)
*/
@ApiModelProperty(value = "安心包-渗透率(门店)(指标A092)", example = "25%")
private String safetyPackPenetrationStore;
/**
* 安心包-成交数(指标A086)
*/
@ApiModelProperty(value = "安心包-成交数(指标A086)", example = "10")
private Integer safetyPackDealCount;
/**
* 轮胎成交数(指标A087)
*/
@ApiModelProperty(value = "轮胎成交数(指标A087)", example = "8")
private Integer tireDealCount;
/**
* 轮胎渗透率(门店)(指标A093)
*/
@ApiModelProperty(value = "轮胎渗透率(门店)(指标A093)", example = "20%")
private String tirePenetrationStore;
/**
* 售前触客数(指标A063)
*/
@ApiModelProperty(value = "售前触客数(指标A063)", example = "80")
private Integer preSaleCustomerCount;
/**
* 售后触客数(指标A096)
*/
@ApiModelProperty(value = "售后触客数(指标A096)", example = "49")
private Integer postSaleCustomerCount;
/**
* 售前成交数(指标A097)
*/
@ApiModelProperty(value = "售前成交数(指标A097)", example = "60")
private Integer preSaleDealCount;
/**
* 售后成交数(指标A098)
*/
@ApiModelProperty(value = "售后成交数(指标A098)", example = "41")
private Integer postSaleDealCount;
} }
/** /**
...@@ -136,6 +239,91 @@ public class EmployeePerformanceDTO implements Serializable { ...@@ -136,6 +239,91 @@ public class EmployeePerformanceDTO implements Serializable {
*/ */
@ApiModelProperty(value = "日报完成率", example = "100%") @ApiModelProperty(value = "日报完成率", example = "100%")
private String dailyPerformanceRate; private String dailyPerformanceRate;
// 新增指标
/**
* 触客率(指标A064)
*/
@ApiModelProperty(value = "触客率(指标A064)", example = "85%")
private String customerContactRate;
/**
* 转化率(指标A085)
*/
@ApiModelProperty(value = "转化率(指标A085)", example = "75%")
private String conversionRate;
/**
* 渗透率(指标A077)
*/
@ApiModelProperty(value = "渗透率(指标A077)", example = "60%")
private String penetrationRate;
/**
* 平均客单价(指标A095)
*/
@ApiModelProperty(value = "平均客单价(指标A095)", example = "10000")
private Integer avgUnitPrice;
/**
* 整车延保-渗透率(员工)(指标A0100)
*/
@ApiModelProperty(value = "整车延保-渗透率(员工)(指标A0100)", example = "40%")
private String vehicleWarrantyPenetrationEmployee;
/**
* 整车延保-转化率(指标A099)
*/
@ApiModelProperty(value = "整车延保-转化率(指标A099)", example = "35%")
private String vehicleWarrantyConversionRate;
/**
* 电池-渗透率(员工)(指标A0103)
*/
@ApiModelProperty(value = "电池-渗透率(员工)(指标A0103)", example = "25%")
private String batteryPenetrationEmployee;
/**
* 电池-转化率(指标A091)
*/
@ApiModelProperty(value = "电池-转化率(指标A091)", example = "20%")
private String batteryConversionRate;
/**
* 安心包-渗透率(员工)(指标A0101)
*/
@ApiModelProperty(value = "安心包-渗透率(员工)(指标A0101)", example = "20%")
private String safetyPackPenetrationEmployee;
/**
* 安心包-转化率(指标A089)
*/
@ApiModelProperty(value = "安心包-转化率(指标A089)", example = "15%")
private String safetyPackConversionRate;
/**
* 轮胎渗透率(员工)(指标A0102)
*/
@ApiModelProperty(value = "轮胎渗透率(员工)(指标A0102)", example = "15%")
private String tirePenetrationEmployee;
/**
* 轮胎转化率(指标A090)
*/
@ApiModelProperty(value = "轮胎转化率(指标A090)", example = "10%")
private String tireConversionRate;
/**
* 售前转化率(指标A0104)
*/
@ApiModelProperty(value = "售前转化率(指标A0104)", example = "80%")
private String preSaleConversionRate;
/**
* 售后转化率(指标A0105)
*/
@ApiModelProperty(value = "售后转化率(指标A0105)", example = "65%")
private String postSaleConversionRate;
} }
/** /**
......
...@@ -26,6 +26,12 @@ public class EmployeeStoreTransferDTO implements Serializable { ...@@ -26,6 +26,12 @@ public class EmployeeStoreTransferDTO implements Serializable {
private Integer id; private Integer id;
/** /**
* 门店ID
*/
@ApiModelProperty(value = "门店ID", example = "44210895")
private Integer merchantId;
/**
* 门店名称 * 门店名称
*/ */
@ApiModelProperty(value = "门店名称", example = "深圳市南山界4S店") @ApiModelProperty(value = "门店名称", example = "深圳市南山界4S店")
......
...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty; ...@@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
import java.util.List;
/** /**
* 员工调店记录请求DTO * 员工调店记录请求DTO
...@@ -31,4 +32,21 @@ public class EmployeeStoreTransferReq implements Serializable { ...@@ -31,4 +32,21 @@ public class EmployeeStoreTransferReq implements Serializable {
@ApiModelProperty(value = "督导ID", example = "123", required = true) @ApiModelProperty(value = "督导ID", example = "123", required = true)
private Long supervisorId; private Long supervisorId;
/**
* 员工手机号
*/
@ApiModelProperty(value = "员工手机号", example = "19144475436", required = true)
private String phoneNumber;
/**
* 业务类型:1.延保 2.轻改 3.权益 4.二手车
*/
@ApiModelProperty(value = "业务类型", example = "1", notes = "业务类型:1.延保 2.轻改 3.权益 4.二手车")
private Integer bizs;
/**
* 督导的权限门店集合
*/
@ApiModelProperty(value = "督导的权限门店集合", example = "[44210895, 44210896]")
private List<Integer> merchantIds;
} }
...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.supervisor.dto; ...@@ -2,6 +2,7 @@ package cn.com.glsx.dj.supervisor.dto;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;
import java.util.Date;
import lombok.Data; import lombok.Data;
import java.io.Serializable; import java.io.Serializable;
...@@ -95,4 +96,124 @@ public class RecordingItemDTO implements Serializable { ...@@ -95,4 +96,124 @@ public class RecordingItemDTO implements Serializable {
@ApiModelProperty(value = "优秀案例提交按钮是否可点击", example = "true") @ApiModelProperty(value = "优秀案例提交按钮是否可点击", example = "true")
private Boolean caseSubmitButtonEnabled; private Boolean caseSubmitButtonEnabled;
/**
* 门店ID
*/
@ApiModelProperty(value = "门店ID", example = "44210895")
private Integer merchantId;
/**
* 销售UUID
*/
@ApiModelProperty(value = "销售UUID", example = "123_456")
private String salesUuid;
/**
* 销售姓名
*/
@ApiModelProperty(value = "销售姓名", example = "张三")
private String salesName;
/**
* 汽车品牌
*/
@ApiModelProperty(value = "汽车品牌", example = "别克")
private String carBrand;
/**
* 接待开始时间
*/
@ApiModelProperty(value = "接待开始时间", example = "2026-02-01 10:00:00")
private Date receptionStartTime;
/**
* 接待结束时间
*/
@ApiModelProperty(value = "接待结束时间", example = "2026-02-01 11:00:00")
private Date receptionEndTime;
/**
* 接待状态
*/
@ApiModelProperty(value = "接待状态", example = "1")
private Integer receptionStatus;
/**
* 员工UUID
*/
@ApiModelProperty(value = "员工UUID", example = "123_456")
private String staffUuid;
/**
* 录音URL
*/
@ApiModelProperty(value = "录音URL", example = "http://example.com/recording.mp3")
private String recordingUrl;
/**
* 购车方式
*/
@ApiModelProperty(value = "购车方式", example = "贷款")
private String carPurchaseMethod;
/**
* 检查历史标志
*/
@ApiModelProperty(value = "检查历史标志", example = "true")
private Boolean checkHistoryFlag;
/**
* 批次ID
*/
@ApiModelProperty(value = "批次ID", example = "123")
private Integer batchId;
/**
* 质检评分
*/
@ApiModelProperty(value = "质检评分", example = "63")
private Integer score;
/**
* 模型类型
*/
@ApiModelProperty(value = "模型类型", example = "1")
private Integer modelType;
/**
* 检查类型
*/
@ApiModelProperty(value = "检查类型", example = "1")
private Integer checkType;
/**
* 订单完成标志
*/
@ApiModelProperty(value = "订单完成标志", example = "true")
private Boolean orderFinishFlag;
/**
* 一车品牌
*/
@ApiModelProperty(value = "一车品牌", example = "别克")
private String oneCarBrand;
/**
* 攻防评分
*/
@ApiModelProperty(value = "攻防评分", example = "6.7")
private Double gfScroe;
/**
* 手机号
*/
@ApiModelProperty(value = "手机号", example = "13812345678")
private String phoneNumber;
/**
* 商户名称
*/
@ApiModelProperty(value = "商户名称", example = "深圳市南山界4S店")
private String merchantName;
} }
\ No newline at end of file \ No newline at end of file
...@@ -50,4 +50,10 @@ public class RecordingListDTO implements Serializable { ...@@ -50,4 +50,10 @@ public class RecordingListDTO implements Serializable {
@ApiModelProperty(value = "每页大小", example = "10") @ApiModelProperty(value = "每页大小", example = "10")
private Integer pageSize; private Integer pageSize;
/**
* 按日期分组的摘要信息列表
*/
@ApiModelProperty(value = "按日期分组的摘要信息列表")
private List<RecordingSummaryDTO> dateSummaryList;
} }
\ No newline at end of file \ No newline at end of file
...@@ -40,13 +40,13 @@ public class RecordingQueryReq implements Serializable { ...@@ -40,13 +40,13 @@ public class RecordingQueryReq implements Serializable {
/** /**
* 开始日期 * 开始日期
*/ */
@ApiModelProperty(value = "开始日期", example = "2026-02-01") @ApiModelProperty(value = "开始日期", example = "2026-02-01", required = true)
private String startDate; private String startDate;
/** /**
* 结束日期 * 结束日期
*/ */
@ApiModelProperty(value = "结束日期", example = "2026-02-29") @ApiModelProperty(value = "结束日期", example = "2026-02-29", required = true)
private String endDate; private String endDate;
/** /**
...@@ -67,4 +67,16 @@ public class RecordingQueryReq implements Serializable { ...@@ -67,4 +67,16 @@ public class RecordingQueryReq implements Serializable {
@ApiModelProperty(value = "接待结果(成交/战败)", example = "成交") @ApiModelProperty(value = "接待结果(成交/战败)", example = "成交")
private String receptionResult; private String receptionResult;
/**
* 门店ID
*/
@ApiModelProperty(value = "门店ID", example = "44210895", required = true)
private Integer merchantId;
/**
* 业务类型
*/
@ApiModelProperty(value = "业务类型", example = "1", required = true)
private Integer biz;
} }
\ No newline at end of file \ No newline at end of file
...@@ -75,6 +75,12 @@ ...@@ -75,6 +75,12 @@
<artifactId>rpc-dj-pe-analysis-api</artifactId> <artifactId>rpc-dj-pe-analysis-api</artifactId>
<version>5.7.0-SNAPSHOT</version> <version>5.7.0-SNAPSHOT</version>
</dependency> </dependency>
<dependency>
<groupId>org.junit.jupiter</groupId>
<artifactId>junit-jupiter</artifactId>
<version>RELEASE</version>
<scope>test</scope>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
...@@ -16,4 +16,8 @@ public class SmartcarlifeDubboConfig extends DubboConfig { ...@@ -16,4 +16,8 @@ public class SmartcarlifeDubboConfig extends DubboConfig {
public StaffBaseInfoRemote staffBaseInfoRemote() { public StaffBaseInfoRemote staffBaseInfoRemote() {
return factory.builder(StaffBaseInfoRemote.class).check(check).timeout(timeout).version("1.0.0").build(); return factory.builder(StaffBaseInfoRemote.class).check(check).timeout(timeout).version("1.0.0").build();
} }
@Bean
public ShopMerchantDirectorConfigRemote ShopMerchantDirectorConfigRemote() {
return factory.builder(ShopMerchantDirectorConfigRemote.class).check(check).timeout(timeout).version("1.0.0").build();
}
} }
package cn.com.glsx.dj.supervisor.mapper; package cn.com.glsx.dj.supervisor.mapper;
import cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO;
import cn.com.glsx.dj.supervisor.dto.RecordingItemDTO;
import java.util.Map;
import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param; import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import java.util.List;
/** /**
* 业务场景Mapper * 业务场景Mapper
* <p> * <p>
* 用于查询员工的业务场景标签 * 用于查询员工的业务场景标签、调店记录和录音列表
* </p> * </p>
* *
* @author fanfr * @author fanfr
...@@ -22,7 +26,140 @@ public interface BusinessSceneMapper { ...@@ -22,7 +26,140 @@ public interface BusinessSceneMapper {
* @param phoneNumber 手机号 * @param phoneNumber 手机号
* @return 业务场景标签,格式为逗号分隔的字符串 * @return 业务场景标签,格式为逗号分隔的字符串
*/ */
@Select("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 LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) WHERE si.phone_number = #{phoneNumber} GROUP BY si.phone_number")
String getBusinessSceneByPhoneNumber(@Param("phoneNumber") String phoneNumber); String getBusinessSceneByPhoneNumber(@Param("phoneNumber") String phoneNumber);
/**
* 查询员工调店记录
* <p>
* 根据业务类型和场景类型查询员工调店记录
* biz = 1, scene_type = 0, business_type = 2 (延保)
* biz = 2, scene_type = 1 (轻改)
* biz = 3, scene_type = 0, business_type = 1 (权益)
* </p>
*
* @param phoneNumber 员工手机号
* @param merchantIds 督导的权限门店集合
* @param bizs 业务类型
* @return 员工调店记录列表
*/
List<EmployeeStoreTransferDTO> getEmployeeStoreTransferRecords(
@Param("phoneNumber") String phoneNumber,
@Param("merchantIds") List<Integer> merchantIds,
@Param("bizs") Integer bizs
);
/**
* 查询录音列表
* <p>
* 根据员工UUID、门店ID、业务类型和日期范围查询录音列表
* </p>
*
* @param merchantId 门店ID
* @param uuid 员工UUID
* @param biz 业务类型
* @param startDate 开始日期
* @param endDate 结束日期
* @return 录音列表
*/
List<RecordingItemDTO> getRecordingList(
@Param("merchantId") Integer merchantId,
@Param("uuid") String uuid,
@Param("biz") Integer biz,
@Param("startDate") String startDate,
@Param("endDate") String endDate
);
/**
* 获取考勤统计和着装预警数据
* <p>
* 根据员工手机号和日期范围查询考勤统计和着装预警数据
* </p>
*
* @param staffPhone 员工手机号
* @param startDate 开始日期
* @param endDate 结束日期
* @return 考勤统计和着装预警数据
*/
Map<String, Object> getAttendanceAndDressCodeData(
@Param("staffPhone") String staffPhone,
@Param("startDate") String startDate,
@Param("endDate") String endDate
);
/**
* 获取日报统计数据
* <p>
* 根据员工UUID、门店ID、业务类型和日期范围查询日报统计数据
* </p>
*
* @param staffUuid 员工UUID
* @param merchantId 门店ID
* @param biz 业务类型
* @param startDate 开始日期
* @param endDate 结束日期
* @return 日报统计数据
*/
Map<String, Object> getDailyReportData(
@Param("staffUuid") String staffUuid,
@Param("merchantId") Integer merchantId,
@Param("biz") Integer biz,
@Param("startDate") String startDate,
@Param("endDate") String endDate
);
/**
* 获取客户接待数据
* <p>
* 根据门店ID、业务类型和日期范围查询客户接待数据
* </p>
*
* @param merchantId 门店ID
* @param biz 业务类型
* @param startDate 开始日期
* @param endDate 结束日期
* @return 客户接待数据
*/
Map<String, Object> getCustomerReceptionData(
@Param("merchantId") Integer merchantId,
@Param("biz") Integer biz,
@Param("startDate") String startDate,
@Param("endDate") String endDate
);
/**
* 获取录音分析数据
* <p>
* 根据员工UUID、门店ID、业务类型和日期范围查询录音分析数据
* </p>
*
* @param staffUuid 嘘工UUID
* @param merchantId 门店ID
* @param biz 业务类型
* @param startDate 开始日期
* @param endDate 结束日期
* @param receptionCount 接待数量
* @return 录音分析数据
*/
Map<String, Object> getRecordingAnalysisData(
@Param("staffUuid") String staffUuid,
@Param("merchantId") Integer merchantId,
@Param("biz") Integer biz,
@Param("startDate") String startDate,
@Param("endDate") String endDate,
@Param("receptionCount") Integer receptionCount
);
/**
* 获取行为标签数据
* <p>
* 根据员工手机号列表查询行为标签数据
* </p>
*
* @param phones 员工手机号列表
* @return 行为标签数据
*/
List<Map<String, Object>> getBehaviorTags(
@Param("phones") List<String> phones
);
} }
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.supervisor.remote; package cn.com.glsx.dj.supervisor.remote;
import cn.com.glsx.dj.supervisor.dto.*; import cn.com.glsx.dj.supervisor.dto.*;
import cn.com.glsx.dj.supervisor.mapper.BusinessSceneMapper;
import cn.com.glsx.dj.supervisor.model.DataBusinessDTO;
import cn.com.glsx.dj.supervisor.model.DataResp;
import cn.com.glsx.dj.supervisor.service.DataBizQueryParamsDTO;
import cn.com.glsx.dj.supervisor.service.GetDataStatsService;
import cn.com.glsx.dj.supervisor.service.SupervisorDashboardService; import cn.com.glsx.dj.supervisor.service.SupervisorDashboardService;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse; import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.framework.core.enums.DefaultErrorEnum; import cn.com.glsx.framework.core.enums.DefaultErrorEnum;
import cn.com.glsx.framework.core.exception.RpcServiceException; import cn.com.glsx.framework.core.exception.RpcServiceException;
import cn.com.glsx.framework.core.util.DateUtils; import java.util.List;
import cn.com.glsx.merchants.dto.beisen.BeisenEmployeeInfoDTO;
import cn.com.glsx.merchants.remote.MerchantUserRemote;
import cn.hutool.core.date.DateUtil;
import java.math.BigDecimal;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.dubbo.config.annotation.DubboReference;
import org.apache.dubbo.config.annotation.DubboService; import org.apache.dubbo.config.annotation.DubboService;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/** /**
* 督导看板远程服务实现类 * 督导看板远程服务实现类
* <p> * <p>
...@@ -41,18 +26,8 @@ import java.util.Map; ...@@ -41,18 +26,8 @@ import java.util.Map;
public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote { public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote {
@Autowired @Autowired
private GetDataStatsService getDataStatsService;
@Autowired
private SupervisorDashboardService supervisorDashboardService; private SupervisorDashboardService supervisorDashboardService;
@Autowired
private BusinessSceneMapper businessSceneMapper;
// 北森员工信息服务
@DubboReference(version = "2.0.0", check = false, timeout = 5000)
private MerchantUserRemote merchantUserRemote;
/** /**
* 获取督导首页数据 * 获取督导首页数据
* <p> * <p>
...@@ -117,73 +92,14 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote ...@@ -117,73 +92,14 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote
public RpcResponse<EmployeeBasicInfoDTO> getEmployeeDashboardData(EmployeeBasicInfoReq req) { public RpcResponse<EmployeeBasicInfoDTO> getEmployeeDashboardData(EmployeeBasicInfoReq req) {
try { try {
log.info("开始远程调用获取人员基础信息,请求参数:{}", req); log.info("开始远程调用获取人员基础信息,请求参数:{}", req);
EmployeeBasicInfoDTO result = supervisorDashboardService.getEmployeeDashboardData(req);
// 1. 从员工ID中提取手机号(假设员工ID格式为:id_phone) log.info("远程调用获取人员基础信息成功");
String employeeId = req.getEmployeeId(); return RpcResponse.success(result);
String phoneNumber = employeeId.split("_")[1]; } catch (RpcServiceException e) {
log.info("提取员工手机号:{}", phoneNumber);
// 2. 调用北森接口获取人员基本信息
log.info("调用北森接口获取人员基本信息,手机号:{}", phoneNumber);
List<String> phoneNumbers = new ArrayList<>();
phoneNumbers.add(phoneNumber);
RpcResponse<List<BeisenEmployeeInfoDTO>> beisenResponse = merchantUserRemote.selectByPhones(phoneNumbers);
// 3. 构建人员基础信息
EmployeeBasicInfoDTO basicInfo = new EmployeeBasicInfoDTO();
if (beisenResponse.isSuccess() && beisenResponse.getResult() != null && !beisenResponse.getResult().isEmpty()) {
BeisenEmployeeInfoDTO beisenInfo = beisenResponse.getResult().get(0);
// 从北森信息中获取数据
basicInfo.setName(beisenInfo.getName()); // 北森-人员-姓名
basicInfo.setPhone(beisenInfo.getMobilePhone()); // 北森-人员-手机号码
if (beisenInfo.getEntryDate() != null) {
basicInfo.setEntryDate(
DateUtils.formatDate(beisenInfo.getEntryDate())); // 北森-人员-入职日期
}
// 年龄:按照生日计算
if (beisenInfo.getBirthday() != null) {
basicInfo.setBirthday(DateUtils.formatDate(beisenInfo.getBirthday())); // 北森-人员-生日
basicInfo.setAge(calculateAge(beisenInfo.getBirthday())); // 计算年龄
}
basicInfo.setPosition(beisenInfo.getOIdJobPost()); // 北森-人员-职位
basicInfo.setManager(beisenInfo.getDirectLeaderName()); // 北森-人员-上级
basicInfo.setOrigin(beisenInfo.getBirthplace()); // 北森-人员-籍贯
// 性别:0男、1女
if (beisenInfo.getGender() != null) {
basicInfo.setGender(beisenInfo.getGender() == 0 ? "男" : "女");
}
// 政治面貌转化
if (beisenInfo.getPoliticalStatus() != null) {
basicInfo.setPoliticalStatus(convertPoliticalStatus(Integer.parseInt(beisenInfo.getPoliticalStatus())));
}
// 民族转换
if (beisenInfo.getNation() != null) {
basicInfo.setEthnicity(convertNation(Integer.parseInt(beisenInfo.getNation())));
}
log.info("成功获取北森员工信息:{}", beisenInfo.getName());
} else {
log.warn("未获取到北森员工信息,使用默认数据");
// 使用默认数据
}
// 4. 调用D+后台接口获取业务信息
log.info("调用D+后台接口获取业务信息,员工ID:{}", employeeId);
// 5. 获取业务场景标签
// 使用SQL查询:SELECT si.phone_number, 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 LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY si.phone_number
log.info("获取业务场景标签,手机号:{}", phoneNumber);
String businessScene = businessSceneMapper.getBusinessSceneByPhoneNumber(phoneNumber);
basicInfo.setBusiness(businessScene); // 业务场景标签
return RpcResponse.success(basicInfo);
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeDashboardData error {}", e); log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeDashboardData error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeDashboardData system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
} }
} }
...@@ -193,119 +109,15 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote ...@@ -193,119 +109,15 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote
EmployeePerformanceReq req) { EmployeePerformanceReq req) {
try { try {
log.info("开始远程调用获取个人业绩数据,请求参数:{}", req); log.info("开始远程调用获取个人业绩数据,请求参数:{}", req);
EmployeePerformanceDTO result = supervisorDashboardService.getEmployeePerformanceData(req);
// 构建个人业绩数据 log.info("远程调用获取个人业绩数据成功");
EmployeePerformanceDTO performanceData = new EmployeePerformanceDTO(); return RpcResponse.success(result);
} catch (RpcServiceException e) {
// 1. 获取门店数据(不传员工id)
// 分别获取各个指标的数据
Map<String, BigDecimal> storeMetrics = new java.util.HashMap<>();
Map<String, String> storeRates = new java.util.HashMap<>(); // 环比数据
String[] storeItemCodes = {"A036", "A076", "A084", "A075"}; // 指标编码:总产值、客单价、总触客数、总成交数
for (String itemCode : storeItemCodes) {
DataBizQueryParamsDTO storeQueryParams = new DataBizQueryParamsDTO();
storeQueryParams.setBizs(req.getBizs()); // 业务类型:1.延保
storeQueryParams.setMerchantIds(req.getMerchantId() != null ? req.getMerchantId().toString() : null); // 门店ID
storeQueryParams.setStartDate(req.getStartDate()); // 开始时间
storeQueryParams.setEndDate(req.getEndDate()); // 结束时间
storeQueryParams.setItemCodes(itemCode); // 单个指标编码
storeQueryParams.setDateType(req.getDateType());
String storeJsonBody = cn.hutool.json.JSONUtil.toJsonStr(storeQueryParams);
DataResp<List<DataBusinessDTO>> storeDataResp = getDataStatsService.getListDataResp(storeJsonBody);
if (storeDataResp != null && storeDataResp.getContent() != null && !storeDataResp.getContent().isEmpty()) {
DataBusinessDTO storeData = storeDataResp.getContent().get(0);
storeMetrics.put(itemCode, storeData.getItemValue());
storeRates.put(itemCode, storeData.getRate()); // 环比
}
}
// 处理门店数据
EmployeePerformanceDTO.StorePerformanceData storePerformanceData = new EmployeePerformanceDTO.StorePerformanceData();
// 总产值(指标A036)
storePerformanceData.setTotalValue(storeMetrics.get("A036") != null ? storeMetrics.get("A036").intValue() : 0);
storePerformanceData.setTotalValueRate(storeRates.get("A036")); // 总产值环比
// 客单价(指标A076)
storePerformanceData.setAveragePrice(storeMetrics.get("A076") != null ? storeMetrics.get("A076").intValue() : 0);
storePerformanceData.setAveragePriceRate(storeRates.get("A076")); // 客单价环比
// 总触客数(指标A084)
storePerformanceData.setTotalCustomers(storeMetrics.get("A084") != null ? storeMetrics.get("A084").intValue() : 0);
storePerformanceData.setTotalCustomersRate(storeRates.get("A084")); // 总触客数环比
// 总成交数(指标A075)
storePerformanceData.setTotalDeals(storeMetrics.get("A075") != null ? storeMetrics.get("A075").intValue() : 0);
storePerformanceData.setTotalDealsRate(storeRates.get("A075")); // 总成交数环比
performanceData.setStoreData(storePerformanceData);
// 2. 获取人员数据
// 分别获取各个指标的数据
Map<String, BigDecimal> employeeMetrics = new java.util.HashMap<>();
Map<String, String> employeeRates = new java.util.HashMap<>(); // 环比数据
String[] employeeItemCodes = {"A036", "A076"}; // 指标编码:总产值、客单价
for (String itemCode : employeeItemCodes) {
DataBizQueryParamsDTO employeeQueryParams = new DataBizQueryParamsDTO();
employeeQueryParams.setBizs(req.getBizs()); // 业务类型:1.延保
employeeQueryParams.setMerchantIds(req.getMerchantId() != null ? req.getMerchantId().toString() : null); // 门店ID
employeeQueryParams.setStaffIds(req.getEmployeeId()); // 员工ID
employeeQueryParams.setStartDate(req.getStartDate()); // 开始时间
employeeQueryParams.setEndDate(req.getEndDate()); // 结束时间
employeeQueryParams.setItemCodes(itemCode); // 单个指标编码
String employeeJsonBody = cn.hutool.json.JSONUtil.toJsonStr(employeeQueryParams);
DataResp<List<DataBusinessDTO>> employeeDataResp = getDataStatsService.getListDataResp(employeeJsonBody);
if (employeeDataResp != null && employeeDataResp.getContent() != null && !employeeDataResp.getContent().isEmpty()) {
DataBusinessDTO employeeData = employeeDataResp.getContent().get(0);
employeeMetrics.put(itemCode, employeeData.getItemValue());
employeeRates.put(itemCode, employeeData.getRate()); // 环比
}
}
// 处理人员数据
EmployeePerformanceDTO.EmployeeData employeePerformanceData = new EmployeePerformanceDTO.EmployeeData();
employeePerformanceData.setTotalValue(employeeMetrics.get("A036") != null ? employeeMetrics.get("A036").intValue() : 0);
employeePerformanceData.setTotalValueRate(employeeRates.get("A036")); // 总产值环比
employeePerformanceData.setAveragePrice(employeeMetrics.get("A076") != null ? employeeMetrics.get("A076").doubleValue() : 0.0);
employeePerformanceData.setAveragePriceRate(employeeRates.get("A076")); // 客单价环比
employeePerformanceData.setDailyPerformanceRate("100%"); // 暂时硬编码,后续从其他系统获取
performanceData.setEmployeeData(employeePerformanceData);
// 3. 获取产值趋势数据(返回聚合的时间数据)
DataBizQueryParamsDTO trendQueryParams = new DataBizQueryParamsDTO();
trendQueryParams.setBizs(req.getBizs());
trendQueryParams.setMerchantIds(req.getMerchantId() != null ? req.getMerchantId().toString() : null); // 门店ID
trendQueryParams.setStaffIds(req.getEmployeeId()); // 员工ID
trendQueryParams.setStartDate(req.getStartDate()); // 开始时间
trendQueryParams.setEndDate(req.getEndDate()); // 结束时间
trendQueryParams.setItemCodes("A036"); // 指标编码:总产值
trendQueryParams.setDateType(req.getDateType() != null ? req.getDateType() : 0); // 日期类型:0,按指定时段
String trendJsonBody = cn.hutool.json.JSONUtil.toJsonStr(trendQueryParams);
DataResp<List<DataBusinessDTO>> trendDataResp = getDataStatsService.getListDataResp(trendJsonBody);
// 处理产值趋势数据
List<EmployeePerformanceDTO.TrendData> trendData = new ArrayList<>();
if (trendDataResp != null && trendDataResp.getContent() != null && !trendDataResp.getContent().isEmpty()) {
for (DataBusinessDTO trendItem : trendDataResp.getContent()) {
EmployeePerformanceDTO.TrendData trend = new EmployeePerformanceDTO.TrendData();
trend.setDate(trendItem.getDate()); // 日期
trend.setValue(trendItem.getItemValue() != null ? trendItem.getItemValue().intValue() : 0); // 产值
trendData.add(trend);
}
}
performanceData.setTrendData(trendData);
return RpcResponse.success(performanceData);
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeePerformanceData error {}", e); log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeePerformanceData error {}", e);
// 处理报错信息,返回友好的错误提示 return RpcResponse.error(e.getError(), e.getMessage());
String errorMsg = "获取个人业绩数据失败,请稍后重试"; } catch (Exception e) {
if (e.getMessage() != null && !e.getMessage().isEmpty()) { log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeePerformanceData system error {}", e);
errorMsg = e.getMessage(); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
}
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, errorMsg);
} }
} }
...@@ -324,72 +136,14 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote ...@@ -324,72 +136,14 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote
public RpcResponse<EmployeeBehaviorDTO> getEmployeeBehaviorData(EmployeeBehaviorReq req) { public RpcResponse<EmployeeBehaviorDTO> getEmployeeBehaviorData(EmployeeBehaviorReq req) {
try { try {
log.info("开始远程调用获取个人行为分析数据,请求参数:{}", req); log.info("开始远程调用获取个人行为分析数据,请求参数:{}", req);
EmployeeBehaviorDTO result = supervisorDashboardService.getEmployeeBehaviorData(req);
// 构建个人行为分析数据
EmployeeBehaviorDTO behaviorData = new EmployeeBehaviorDTO();
// AI建议
behaviorData.setAiSuggestion("该员工学习时长领先但线索转化率低于平均水平,建议加强成交环节的实操带教");
// 考勤统计
EmployeeBehaviorDTO.AttendanceData attendance = new EmployeeBehaviorDTO.AttendanceData();
attendance.setCheckInDays(1); // 打卡天数
attendance.setLate(1); // 迟到
attendance.setEarlyLeave(1); // 早退
attendance.setAbsenteeism(1); // 旷工
behaviorData.setAttendance(attendance);
// 日报统计
EmployeeBehaviorDTO.DailyReportData dailyReport = new EmployeeBehaviorDTO.DailyReportData();
dailyReport.setSubmitted(0); // 已提交
dailyReport.setNotSubmitted(1); // 未提交
dailyReport.setOnDuty(0); // 在岗
dailyReport.setRest(0); // 调休
dailyReport.setCompletionRate("85%"); // 日报完成率
behaviorData.setDailyReport(dailyReport);
// 客户接待
EmployeeBehaviorDTO.CustomerReceptionData customerReception = new EmployeeBehaviorDTO.CustomerReceptionData();
customerReception.setActualDelivery(4); // 实际交车数(指标A062)
customerReception.setReceptionCount(2); // 接待数量(指标A084)
customerReception.setNotTouched(2); // 未触客数
behaviorData.setCustomerReception(customerReception);
// 录音分析
EmployeeBehaviorDTO.RecordingAnalysisData recordingAnalysis = new EmployeeBehaviorDTO.RecordingAnalysisData();
// 行为标签
Map<String, String> behaviorTags = new HashMap<>();
behaviorTags.put("salesAbility", "优秀");
behaviorTags.put("customerService", "一般");
behaviorTags.put("productKnowledge", "优秀");
behaviorTags.put("serviceAttitude", "一般");
behaviorTags.put("communicationSkills", "良好");
behaviorTags.put("persuasionAbility", "一般");
recordingAnalysis.setBehaviorTags(behaviorTags);
// 量化指标
EmployeeBehaviorDTO.QuantitativeIndicators quantitativeIndicators = new EmployeeBehaviorDTO.QuantitativeIndicators();
quantitativeIndicators.setRecordingCount(2); // 录音
quantitativeIndicators.setDealCount(1); // 成交数
quantitativeIndicators.setDefeatCount(1); // 战败数
quantitativeIndicators.setDealRate("50%"); // 成交率
quantitativeIndicators.setQualityScore(2); // 质检平均分
quantitativeIndicators.setAttackDefenseScore(1); // 攻防平均分
quantitativeIndicators.setRecordingMissingRate(1); // 录音缺失率
recordingAnalysis.setQuantitativeIndicators(quantitativeIndicators);
behaviorData.setRecordingAnalysis(recordingAnalysis);
// 着装预警
EmployeeBehaviorDTO.DressCodeWarningData dressCodeWarning = new EmployeeBehaviorDTO.DressCodeWarningData();
dressCodeWarning.setWarningCount(1); // 预警次数
behaviorData.setDressCodeWarning(dressCodeWarning);
log.info("远程调用获取个人行为分析数据成功"); log.info("远程调用获取个人行为分析数据成功");
return RpcResponse.success(behaviorData); return RpcResponse.success(result);
} catch (Exception e) { } catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeBehaviorData error {}", e); log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeBehaviorData error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeBehaviorData system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
} }
} }
...@@ -407,38 +161,14 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote ...@@ -407,38 +161,14 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote
public RpcResponse<List<EmployeeStoreTransferDTO>> getEmployeeStoreTransferRecords(EmployeeStoreTransferReq req) { public RpcResponse<List<EmployeeStoreTransferDTO>> getEmployeeStoreTransferRecords(EmployeeStoreTransferReq req) {
try { try {
log.info("开始远程调用获取员工调店记录,请求参数:{}", req); log.info("开始远程调用获取员工调店记录,请求参数:{}", req);
List<EmployeeStoreTransferDTO> result = supervisorDashboardService.getEmployeeStoreTransferRecords(req);
// 构建员工调店记录
List<EmployeeStoreTransferDTO> transferRecords = new ArrayList<>();
EmployeeStoreTransferDTO record1 = new EmployeeStoreTransferDTO();
record1.setId(1);
record1.setStoreName("深圳市南山界4S店");
record1.setStartDate("2025-12-12");
record1.setEndDate("2026-03-12");
record1.setStatus("current");
transferRecords.add(record1);
EmployeeStoreTransferDTO record2 = new EmployeeStoreTransferDTO();
record2.setId(2);
record2.setStoreName("深圳市福田区5S店");
record2.setStartDate("2025-06-01");
record2.setEndDate("2025-12-11");
record2.setStatus("history");
transferRecords.add(record2);
EmployeeStoreTransferDTO record3 = new EmployeeStoreTransferDTO();
record3.setId(3);
record3.setStoreName("深圳市宝安区6S店");
record3.setStartDate("2025-01-01");
record3.setEndDate("2025-05-31");
record3.setStatus("history");
transferRecords.add(record3);
log.info("远程调用获取员工调店记录成功"); log.info("远程调用获取员工调店记录成功");
return RpcResponse.success(transferRecords); return RpcResponse.success(result);
} catch (Exception e) { } catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeStoreTransferRecords error {}", e); log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeStoreTransferRecords error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getEmployeeStoreTransferRecords system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
} }
} }
...@@ -457,222 +187,16 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote ...@@ -457,222 +187,16 @@ public class SupervisorDashboardRemoteImpl implements SupervisorDashboardRemote
public RpcResponse<RecordingListDTO> getRecordingList(RecordingQueryReq req) { public RpcResponse<RecordingListDTO> getRecordingList(RecordingQueryReq req) {
try { try {
log.info("开始远程调用获取录音列表,请求参数:{}", req); log.info("开始远程调用获取录音列表,请求参数:{}", req);
RecordingListDTO result = supervisorDashboardService.getRecordingList(req);
// 构建录音摘要
RecordingSummaryDTO summary = new RecordingSummaryDTO();
summary.setDate("2月1日");
summary.setTotalRecordings(10);
summary.setDealCount(3);
summary.setDefeatCount(2);
// 构建录音列表
List<RecordingItemDTO> recordingList = new ArrayList<>();
// 成交录音
RecordingItemDTO recording1 = new RecordingItemDTO();
recording1.setRecordingId(1L);
recording1.setCustomerName("李四");
recording1.setCustomerPhone("13812345678");
recording1.setStoreStaff("张三");
recording1.setStoreName("深圳市南山界4S店");
recording1.setCustomerType("潜在客户");
recording1.setCarModel("GL8");
recording1.setReceptionTime("2026-02-01 10:00:00");
recording1.setReceptionResult("成交");
recording1.setCaseSubmitStatus(0);
recording1.setCaseSubmitStatusText("提交优秀案例");
recording1.setCaseSubmitButtonEnabled(true);
recordingList.add(recording1);
// 成交录音(已提交待审核)
RecordingItemDTO recording2 = new RecordingItemDTO();
recording2.setRecordingId(2L);
recording2.setCustomerName("王五");
recording2.setCustomerPhone("13987654321");
recording2.setStoreStaff("张三");
recording2.setStoreName("深圳市南山界4S店");
recording2.setCustomerType("老客户");
recording2.setCarModel("昂科威");
recording2.setReceptionTime("2026-02-01 14:30:00");
recording2.setReceptionResult("成交");
recording2.setCaseSubmitStatus(1);
recording2.setCaseSubmitStatusText("审核中");
recording2.setCaseSubmitButtonEnabled(false);
recordingList.add(recording2);
// 成交录音(已通过)
RecordingItemDTO recording3 = new RecordingItemDTO();
recording3.setRecordingId(3L);
recording3.setCustomerName("赵六");
recording3.setCustomerPhone("13765432198");
recording3.setStoreStaff("张三");
recording3.setStoreName("深圳市南山界4S店");
recording3.setCustomerType("潜在客户");
recording3.setCarModel("君越");
recording3.setReceptionTime("2026-02-01 16:00:00");
recording3.setReceptionResult("成交");
recording3.setCaseSubmitStatus(2);
recording3.setCaseSubmitStatusText("优秀案例提交通过");
recording3.setCaseSubmitButtonEnabled(false);
recordingList.add(recording3);
// 成交录音(已驳回)
RecordingItemDTO recording4 = new RecordingItemDTO();
recording4.setRecordingId(4L);
recording4.setCustomerName("孙七");
recording4.setCustomerPhone("13654321987");
recording4.setStoreStaff("张三");
recording4.setStoreName("深圳市南山界4S店");
recording4.setCustomerType("老客户");
recording4.setCarModel("英朗");
recording4.setReceptionTime("2026-02-01 11:00:00");
recording4.setReceptionResult("成交");
recording4.setCaseSubmitStatus(3);
recording4.setCaseSubmitStatusText("优秀案例提交已驳回,重新提交");
recording4.setCaseSubmitButtonEnabled(true);
recordingList.add(recording4);
// 战败录音
RecordingItemDTO recording5 = new RecordingItemDTO();
recording5.setRecordingId(5L);
recording5.setCustomerName("周八");
recording5.setCustomerPhone("13543219876");
recording5.setStoreStaff("张三");
recording5.setStoreName("深圳市南山界4S店");
recording5.setCustomerType("潜在客户");
recording5.setCarModel("威朗");
recording5.setReceptionTime("2026-02-01 09:00:00");
recording5.setReceptionResult("战败");
recording5.setCaseSubmitStatus(0);
recording5.setCaseSubmitStatusText("提交优秀案例");
recording5.setCaseSubmitButtonEnabled(false);
recordingList.add(recording5);
// 构建返回数据
RecordingListDTO result = new RecordingListDTO();
result.setSummary(summary);
result.setRecordingList(recordingList);
result.setTotalCount(10);
result.setPageNum(req.getPageNum() != null ? req.getPageNum() : 1);
result.setPageSize(req.getPageSize() != null ? req.getPageSize() : 10);
log.info("远程调用获取录音列表成功"); log.info("远程调用获取录音列表成功");
return RpcResponse.success(result); return RpcResponse.success(result);
} catch (Exception e) { } catch (RpcServiceException e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getRecordingList error {}", e); log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getRecordingList error {}", e);
return RpcResponse.error(e.getError(), e.getMessage());
} catch (Exception e) {
log.error("cn.com.glsx.dj.supervisor.remote.SupervisorDashboardRemoteImpl.getRecordingList system error {}", e);
return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage()); return RpcResponse.error(DefaultErrorEnum.SERVER_ERROR, e.getMessage());
} }
} }
/**
* 计算年龄
* @param birthday 生日日期
* @return 年龄
*/
private Integer calculateAge(java.util.Date birthday) {
if (birthday == null) {
return null;
}
java.util.Calendar cal = java.util.Calendar.getInstance();
int currentYear = cal.get(java.util.Calendar.YEAR);
int currentMonth = cal.get(java.util.Calendar.MONTH) + 1;
int currentDay = cal.get(java.util.Calendar.DAY_OF_MONTH);
cal.setTime(birthday);
int birthYear = cal.get(java.util.Calendar.YEAR);
int birthMonth = cal.get(java.util.Calendar.MONTH) + 1;
int birthDay = cal.get(java.util.Calendar.DAY_OF_MONTH);
int age = currentYear - birthYear;
if (currentMonth < birthMonth || (currentMonth == birthMonth && currentDay < birthDay)) {
age--;
}
return age;
}
/**
* 转化政治面貌
* @param politicalStatus 政治面貌代码
* @return 政治面貌名称
*/
private String convertPoliticalStatus(Integer politicalStatus) {
switch (politicalStatus) {
case 0:
return "群众";
case 1:
return "中共党员";
case 2:
return "共青团员";
case 3:
return "民主党派";
case 4:
return "群众";
case 6:
return "中共预备党员";
case 7:
return "民革党员";
case 8:
return "民盟盟员";
case 9:
return "民建会员";
case 10:
return "民进会员";
case 11:
return "农工党党员";
case 12:
return "致公党党员";
case 13:
return "九三学社社员";
case 14:
return "台盟盟员";
case 15:
return "无党派人士";
default:
return "群众";
}
}
/**
* 转化民族
* @param nation 民族代码
* @return 民族名称
*/
private String convertNation(Integer nation) {
switch (nation) {
case 1:
return "汉族";
case 2:
return "回族";
case 3:
return "畲族";
case 4:
return "塔塔尔族";
case 5:
return "阿昌族";
case 6:
return "哈萨克族";
case 7:
return "土家族";
case 8:
return "景颇族";
case 9:
return "哈尼族";
case 10:
return "土族";
case 11:
return "白族";
case 12:
return "维吾尔族";
case 13:
return "保安族";
case 14:
return "赫哲族";
case 15:
return "乌孜别克族";
// 其他民族编码可以根据需要添加
default:
return "汉族";
}
}
} }
...@@ -46,6 +46,12 @@ public class SupervisorDashboardService { ...@@ -46,6 +46,12 @@ public class SupervisorDashboardService {
@Autowired @Autowired
private ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote; private ShopMerchantDirectorConfigRemote shopMerchantDirectorConfigRemote;
@Autowired
private cn.com.glsx.dj.supervisor.mapper.BusinessSceneMapper businessSceneMapper;
@Autowired
private cn.com.glsx.merchants.remote.MerchantUserRemote merchantUserRemote;
/** /**
* 获取督导首页数据 * 获取督导首页数据
*/ */
...@@ -75,7 +81,7 @@ public class SupervisorDashboardService { ...@@ -75,7 +81,7 @@ public class SupervisorDashboardService {
vo.setEmployeeList(rawEmployeeData); // 前端可能需要做排序,或者这里排好序 vo.setEmployeeList(rawEmployeeData); // 前端可能需要做排序,或者这里排好序
// 4. 触发 AI 分析 // 4. 触发 AI 分析
if (!rawEmployeeData.isEmpty()) { if (!rawEmployeeData.isEmpty() && (req.getNeedAiAnalysis() == null || req.getNeedAiAnalysis())) {
// 此处为同步演示,使用开始时间-结束日期作为周期参数 // 此处为同步演示,使用开始时间-结束日期作为周期参数
String period = req.getStartDate() + "-" + req.getEndDate(); String period = req.getStartDate() + "-" + req.getEndDate();
String aiSuggestion = aiAnalysisService.generateSuggestion(req.getSupervisorId(), period, rawEmployeeData); String aiSuggestion = aiAnalysisService.generateSuggestion(req.getSupervisorId(), period, rawEmployeeData);
...@@ -105,11 +111,11 @@ public class SupervisorDashboardService { ...@@ -105,11 +111,11 @@ public class SupervisorDashboardService {
vo.setEmployeeList(dataList); vo.setEmployeeList(dataList);
// 4. 生成 AI 建议 (行为版) // 4. 生成 AI 建议 (行为版)
if (!dataList.isEmpty()) { if (!dataList.isEmpty() && (req.getNeedAiAnalysis() == null || req.getNeedAiAnalysis())) {
// 使用开始时间-结束日期作为周期参数 // 使用开始时间-结束日期作为周期参数
String period = req.getStartDate() + "-" + req.getEndDate(); String period = req.getStartDate() + "-" + req.getEndDate();
vo.setAiAnalysisSuggestion(aiAnalysisService.generateBehaviorSuggestion(req.getSupervisorId(), period, dataList)); vo.setAiAnalysisSuggestion(aiAnalysisService.generateBehaviorSuggestion(req.getSupervisorId(), period, dataList));
} else { } else if (!dataList.isEmpty()) {
vo.setAiAnalysisSuggestion("暂无行为数据生成建议。"); vo.setAiAnalysisSuggestion("暂无行为数据生成建议。");
} }
...@@ -548,4 +554,701 @@ public class SupervisorDashboardService { ...@@ -548,4 +554,701 @@ public class SupervisorDashboardService {
} }
} }
/**
* 获取员工行为数据
* <p>
* 根据员工ID、门店ID、业务类型和日期范围查询员工行为数据
* </p>
*
* @param req 查询参数
* @return 员工行为数据
*/
public cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO getEmployeeBehaviorData(cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorReq req) {
log.info("开始获取个人行为分析数据,请求参数:{}", req);
// 构建个人行为分析数据
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO behaviorData = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO();
// 获取考勤统计和着装预警数据
Map<String, Object> attendanceData = businessSceneMapper.getAttendanceAndDressCodeData(
req.getPhone(),
req.getStartDate(),
req.getEndDate()
);
// 考勤统计
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.AttendanceData attendance = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.AttendanceData();
attendance.setCheckInDays(getIntegerValue(attendanceData, "checkInDays")); // 打卡天数
attendance.setLate(getIntegerValue(attendanceData, "late")); // 迟到
attendance.setEarlyLeave(getIntegerValue(attendanceData, "earlyLeave")); // 早退
attendance.setAbsenteeism(getIntegerValue(attendanceData, "absenteeism")); // 旷工
behaviorData.setAttendance(attendance);
// 日报统计
Map<String, Object> dailyReportData = businessSceneMapper.getDailyReportData(
req.getEmployeeId(),
req.getMerchantId(),
req.getBizs(),
req.getStartDate(),
req.getEndDate()
);
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DailyReportData dailyReport = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DailyReportData();
int totalDays = getIntegerValue(dailyReportData, "totalDays");
int submitted = getIntegerValue(dailyReportData, "submitted");
int rest = getIntegerValue(dailyReportData, "rest");
int receptionCount = getIntegerValue(dailyReportData, "receptionCount");
// 未提交 = 自然日 - 已提交
int notSubmitted = totalDays - submitted;
// 在岗 = 已提交 - 调休
int onDuty = submitted - rest;
dailyReport.setSubmitted(submitted); // 已提交
dailyReport.setNotSubmitted(notSubmitted); // 未提交
dailyReport.setOnDuty(onDuty); // 在岗
dailyReport.setRest(rest); // 调休
// 计算日报完成率
String completionRate = totalDays > 0 ? String.format("%.0f%%", (double) submitted / totalDays * 100) : "0%";
dailyReport.setCompletionRate(completionRate); // 日报完成率
behaviorData.setDailyReport(dailyReport);
// 客户接待
Map<String, Object> customerReceptionData = businessSceneMapper.getCustomerReceptionData(
req.getMerchantId(),
req.getBizs(),
req.getStartDate(),
req.getEndDate()
);
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.CustomerReceptionData customerReception = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.CustomerReceptionData();
customerReception.setActualDelivery(getIntegerValue(customerReceptionData, "deliveryCount")); // 实际交车数
customerReception.setReceptionCount(receptionCount); // 接待数量(指标A084)
customerReception.setNotTouched(getIntegerValue(customerReceptionData, "notTouched")); // 未触客数
behaviorData.setCustomerReception(customerReception);
// 录音分析
Map<String, Object> recordingAnalysisData = businessSceneMapper.getRecordingAnalysisData(
req.getEmployeeId(),
req.getMerchantId(),
req.getBizs(),
req.getStartDate(),
req.getEndDate(),
receptionCount
);
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.RecordingAnalysisData recordingAnalysis = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.RecordingAnalysisData();
// 行为标签
List<String> phones = new ArrayList<>();
phones.add(req.getPhone());
List<Map<String, Object>> behaviorTagList = businessSceneMapper.getBehaviorTags(phones);
Map<String, String> behaviorTags = new HashMap<>();
Map<String, String> badList = new HashMap<>();
Map<String, String> ohterList = new HashMap<>();
for (Map<String, Object> tagData : behaviorTagList) {
String tagName = (String) tagData.get("tagName");
String groupName = (String) tagData.get("groupName");
behaviorTags.put(groupName, tagName);
if ("差".equals(tagName)) {
badList.put(groupName, tagName);
} else {
ohterList.put(groupName, tagName);
}
}
recordingAnalysis.setBehaviorTags(behaviorTags);
recordingAnalysis.setBadList(badList);
recordingAnalysis.setOhterList(ohterList);
// 量化指标
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.QuantitativeIndicators quantitativeIndicators = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.QuantitativeIndicators();
quantitativeIndicators.setRecordingCount(getIntegerValue(recordingAnalysisData, "recordingCount")); // 录音
quantitativeIndicators.setDealCount(getIntegerValue(recordingAnalysisData, "dealCount")); // 成交数
quantitativeIndicators.setDefeatCount(getIntegerValue(recordingAnalysisData, "defeatCount")); // 战败数
// 计算成交率
int recordingCount = getIntegerValue(recordingAnalysisData, "recordingCount");
int dealCount = getIntegerValue(recordingAnalysisData, "dealCount");
String dealRate = recordingCount > 0 ? String.format("%.0f%%", (double) dealCount / recordingCount * 100) : "0%";
quantitativeIndicators.setDealRate(dealRate); // 成交率
quantitativeIndicators.setQualityScore(getIntegerValue(recordingAnalysisData, "qualityScore")); // 质检平均分
quantitativeIndicators.setAttackDefenseScore(getIntegerValue(recordingAnalysisData, "attackDefenseScore")); // 攻防平均分
quantitativeIndicators.setRecordingMissingRate(getDoubleValue(recordingAnalysisData, "recordingMissingRate").intValue()); // 录音缺失率
recordingAnalysis.setQuantitativeIndicators(quantitativeIndicators);
behaviorData.setRecordingAnalysis(recordingAnalysis);
// 着装预警
cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DressCodeWarningData dressCodeWarning = new cn.com.glsx.dj.supervisor.dto.EmployeeBehaviorDTO.DressCodeWarningData();
dressCodeWarning.setWarningCount(getIntegerValue(attendanceData, "warningCount")); // 预警次数
behaviorData.setDressCodeWarning(dressCodeWarning);
log.info("获取个人行为分析数据成功");
return behaviorData;
}
/**
* 从Map中获取整数值,如果值为null则返回0
* @param map 数据Map
* @param key 键
* @return 整数值
*/
private Integer getIntegerValue(Map<String, Object> map, String key) {
if (map == null || !map.containsKey(key)) {
return 0;
}
Object value = map.get(key);
if (value == null) {
return 0;
}
if (value instanceof Integer) {
return (Integer) value;
}
if (value instanceof Long) {
return ((Long) value).intValue();
}
if (value instanceof Double) {
return ((Double) value).intValue();
}
return 0;
}
/**
* 从Map中获取浮点数值,如果值为null则返回0
* @param map 数据Map
* @param key 键
* @return 浮点数值
*/
private Double getDoubleValue(Map<String, Object> map, String key) {
if (map == null || !map.containsKey(key)) {
return 0.0;
}
Object value = map.get(key);
if (value == null) {
return 0.0;
}
if (value instanceof Double) {
return (Double) value;
}
if (value instanceof Integer) {
return ((Integer) value).doubleValue();
}
if (value instanceof Long) {
return ((Long) value).doubleValue();
}
return 0.0;
}
/**
* 获取人员基础信息
* <p>
* 根据员工ID和手机号获取人员基础信息
* 包含北森基本信息和业务场景标签
* </p>
*
* @param req 查询参数
* @return 人员基础信息
*/
public cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO getEmployeeDashboardData(cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoReq req) {
log.info("开始获取人员基础信息,请求参数:{}", req);
// 1. 使用请求中的手机号
String employeeId = req.getEmployeeId();
String phoneNumber = req.getPhone();
log.info("使用请求中的手机号:{}", phoneNumber);
// 2. 调用北森接口获取人员基本信息
log.info("调用北森接口获取人员基本信息,手机号:{}", phoneNumber);
java.util.List<String> phoneNumbers = new java.util.ArrayList<>();
phoneNumbers.add(phoneNumber);
cn.com.glsx.framework.core.beans.rpc.RpcResponse<java.util.List<cn.com.glsx.merchants.dto.beisen.BeisenEmployeeInfoDTO>> beisenResponse = merchantUserRemote.selectByPhones(phoneNumbers);
// 3. 构建人员基础信息
cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO basicInfo = new cn.com.glsx.dj.supervisor.dto.EmployeeBasicInfoDTO();
if (beisenResponse.isSuccess() && beisenResponse.getResult() != null && !beisenResponse.getResult().isEmpty()) {
cn.com.glsx.merchants.dto.beisen.BeisenEmployeeInfoDTO beisenInfo = beisenResponse.getResult().get(0);
// 从北森信息中获取数据
basicInfo.setName(beisenInfo.getName()); // 北森-人员-姓名
basicInfo.setPhone(beisenInfo.getMobilePhone()); // 北森-人员-手机号码
if (beisenInfo.getEntryDate() != null) {
basicInfo.setEntryDate(
cn.com.glsx.framework.core.util.DateUtils.formatDate(beisenInfo.getEntryDate())); // 北森-人员-入职日期
}
// 年龄:按照生日计算
if (beisenInfo.getBirthday() != null) {
basicInfo.setBirthday(cn.com.glsx.framework.core.util.DateUtils.formatDate(beisenInfo.getBirthday())); // 北森-人员-生日
basicInfo.setAge(calculateAge(beisenInfo.getBirthday())); // 计算年龄
}
basicInfo.setPosition(beisenInfo.getOIdJobPost()); // 北森-人员-职位
basicInfo.setManager(beisenInfo.getDirectLeaderName()); // 北森-人员-上级
basicInfo.setOrigin(beisenInfo.getBirthplace()); // 北森-人员-籍贯
// 性别:0男、1女
if (beisenInfo.getGender() != null) {
basicInfo.setGender(beisenInfo.getGender() == 0 ? "男" : "女");
}
// 政治面貌转化
if (beisenInfo.getPoliticalStatus() != null) {
basicInfo.setPoliticalStatus(convertPoliticalStatus(Integer.parseInt(beisenInfo.getPoliticalStatus())));
}
// 民族转换
if (beisenInfo.getNation() != null) {
basicInfo.setEthnicity(convertNation(Integer.parseInt(beisenInfo.getNation())));
}
log.info("成功获取北森员工信息:{}", beisenInfo.getName());
} else {
log.warn("未获取到北森员工信息,使用默认数据");
// 使用默认数据
}
// 4. 调用D+后台接口获取业务信息
log.info("调用D+后台接口获取业务信息,员工ID:{}", employeeId);
// 5. 获取业务场景标签
// 使用SQL查询:SELECT si.phone_number, 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 LEFT JOIN dj_car_life_goods_order go ON si.staff_uuid = go.seller_user_id AND go.install_upgrade_time >= DATE_SUB(CURDATE(), INTERVAL 30 DAY) GROUP BY si.phone_number
log.info("获取业务场景标签,手机号:{}", phoneNumber);
String businessScene = businessSceneMapper.getBusinessSceneByPhoneNumber(phoneNumber);
basicInfo.setBusiness(businessScene); // 业务场景标签
log.info("获取人员基础信息成功");
return basicInfo;
}
/**
* 计算年龄
* @param birthday 生日日期
* @return 年龄
*/
private Integer calculateAge(java.util.Date birthday) {
if (birthday == null) {
return null;
}
java.util.Calendar cal = java.util.Calendar.getInstance();
int currentYear = cal.get(java.util.Calendar.YEAR);
int currentMonth = cal.get(java.util.Calendar.MONTH) + 1;
int currentDay = cal.get(java.util.Calendar.DAY_OF_MONTH);
cal.setTime(birthday);
int birthYear = cal.get(java.util.Calendar.YEAR);
int birthMonth = cal.get(java.util.Calendar.MONTH) + 1;
int birthDay = cal.get(java.util.Calendar.DAY_OF_MONTH);
int age = currentYear - birthYear;
if (currentMonth < birthMonth || (currentMonth == birthMonth && currentDay < birthDay)) {
age--;
}
return age;
}
/**
* 转化政治面貌
* @param politicalStatus 政治面貌代码
* @return 政治面貌名称
*/
private String convertPoliticalStatus(Integer politicalStatus) {
switch (politicalStatus) {
case 0:
return "群众";
case 1:
return "中共党员";
case 2:
return "共青团员";
case 3:
return "民主党派";
case 4:
return "群众";
case 6:
return "中共预备党员";
case 7:
return "民革党员";
case 8:
return "民盟盟员";
case 9:
return "民建会员";
case 10:
return "民进会员";
case 11:
return "农工党党员";
case 12:
return "致公党党员";
case 13:
return "九三学社社员";
case 14:
return "台盟盟员";
case 15:
return "无党派人士";
default:
return "群众";
}
}
/**
* 转化民族
* @param nation 民族代码
* @return 民族名称
*/
private String convertNation(Integer nation) {
switch (nation) {
case 1:
return "汉族";
case 2:
return "回族";
case 3:
return "畲族";
case 4:
return "塔塔尔族";
case 5:
return "阿昌族";
case 6:
return "哈萨克族";
case 7:
return "土家族";
case 8:
return "景颇族";
case 9:
return "哈尼族";
case 10:
return "土族";
case 11:
return "白族";
case 12:
return "维吾尔族";
case 13:
return "保安族";
case 14:
return "赫哲族";
case 15:
return "乌孜别克族";
// 其他民族编码可以根据需要添加
default:
return "汉族";
}
}
/**
* 获取个人业绩数据
* <p>
* 根据员工ID、门店ID、业务类型和日期范围查询个人业绩数据
* 包含门店数据、人员数据和产值趋势数据
* </p>
*
* @param req 查询参数
* @return 个人业绩数据
*/
public cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO getEmployeePerformanceData(cn.com.glsx.dj.supervisor.dto.EmployeePerformanceReq req) {
log.info("开始获取个人业绩数据,请求参数:{}", req);
// 构建个人业绩数据
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO performanceData = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO();
// 1. 获取门店数据(不传员工id)
// 分别获取各个指标的数据
java.util.Map<String, java.math.BigDecimal> storeMetrics = new java.util.HashMap<>();
java.util.Map<String, String> storeRates = new java.util.HashMap<>(); // 环比数据
String[] storeItemCodes = {"A036", "A076", "A084", "A075", "A064", "A085", "A077", "A095", "A062", "A067", "A066", "A094", "A070", "A092", "A086", "A087", "A093", "A063", "A096", "A097", "A098"}; // 指标编码:总产值、客单价、总触客数、总成交数、触客率、转化率、渗透率、平均客单价、新车交付数、整车延保-渗透率(门店)、整车延保-成交数、电池-渗透率(门店)、电池-成交数、安心包-渗透率(门店)、安心包-成交数、轮胎成交数、轮胎渗透率(门店)、售前触客数、售后触客数、售前成交数、售后成交数
for (String itemCode : storeItemCodes) {
cn.com.glsx.dj.supervisor.service.DataBizQueryParamsDTO storeQueryParams = new cn.com.glsx.dj.supervisor.service.DataBizQueryParamsDTO();
storeQueryParams.setBizs(req.getBizs()); // 业务类型:1.延保
storeQueryParams.setMerchantIds(req.getMerchantId() != null ? req.getMerchantId().toString() : null); // 门店ID
storeQueryParams.setStartDate(req.getStartDate()); // 开始时间
storeQueryParams.setEndDate(req.getEndDate()); // 结束时间
storeQueryParams.setItemCodes(itemCode); // 单个指标编码
storeQueryParams.setDateType(req.getDateType());
String storeJsonBody = cn.hutool.json.JSONUtil.toJsonStr(storeQueryParams);
cn.com.glsx.dj.supervisor.model.DataResp<java.util.List<cn.com.glsx.dj.supervisor.model.DataBusinessDTO>> storeDataResp = getDataStatsService.getListDataResp(storeJsonBody);
if (storeDataResp != null && storeDataResp.getContent() != null && !storeDataResp.getContent().isEmpty()) {
cn.com.glsx.dj.supervisor.model.DataBusinessDTO storeData = storeDataResp.getContent().get(0);
storeMetrics.put(itemCode, storeData.getItemValue());
storeRates.put(itemCode, storeData.getRate()); // 环比
}
}
// 处理门店数据
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.StorePerformanceData storePerformanceData = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.StorePerformanceData();
// 总产值(指标A036)
storePerformanceData.setTotalValue(storeMetrics.get("A036") != null ? storeMetrics.get("A036").intValue() : 0);
storePerformanceData.setTotalValueRate(storeRates.get("A036")); // 总产值环比
// 客单价(指标A076)
storePerformanceData.setAveragePrice(storeMetrics.get("A076") != null ? storeMetrics.get("A076").intValue() : 0);
storePerformanceData.setAveragePriceRate(storeRates.get("A076")); // 客单价环比
// 总触客数(指标A084)
storePerformanceData.setTotalCustomers(storeMetrics.get("A084") != null ? storeMetrics.get("A084").intValue() : 0);
storePerformanceData.setTotalCustomersRate(storeRates.get("A084")); // 总触客数环比
// 总成交数(指标A075)
storePerformanceData.setTotalDeals(storeMetrics.get("A075") != null ? storeMetrics.get("A075").intValue() : 0);
storePerformanceData.setTotalDealsRate(storeRates.get("A075")); // 总成交数环比
// 触客率(指标A064)
storePerformanceData.setCustomerContactRate(storeRates.get("A064"));
// 转化率(指标A085)
storePerformanceData.setConversionRate(storeRates.get("A085"));
// 渗透率(指标A077)
storePerformanceData.setPenetrationRate(storeRates.get("A077"));
// 平均客单价(指标A095)
storePerformanceData.setAvgUnitPrice(storeMetrics.get("A095") != null ? storeMetrics.get("A095").intValue() : 0);
// 新车交付数(指标A062)
storePerformanceData.setNewCarDeliveryCount(storeMetrics.get("A062") != null ? storeMetrics.get("A062").intValue() : 0);
// 整车延保-渗透率(门店)(指标A067)
storePerformanceData.setVehicleWarrantyPenetrationStore(storeRates.get("A067"));
// 整车延保-成交数(指标A066)
storePerformanceData.setVehicleWarrantyDealCount(storeMetrics.get("A066") != null ? storeMetrics.get("A066").intValue() : 0);
// 电池-渗透率(门店)(指标A094)
storePerformanceData.setBatteryPenetrationStore(storeRates.get("A094"));
// 电池-成交数(指标A070)
storePerformanceData.setBatteryDealCount(storeMetrics.get("A070") != null ? storeMetrics.get("A070").intValue() : 0);
// 安心包-渗透率(门店)(指标A092)
storePerformanceData.setSafetyPackPenetrationStore(storeRates.get("A092"));
// 安心包-成交数(指标A086)
storePerformanceData.setSafetyPackDealCount(storeMetrics.get("A086") != null ? storeMetrics.get("A086").intValue() : 0);
// 轮胎成交数(指标A087)
storePerformanceData.setTireDealCount(storeMetrics.get("A087") != null ? storeMetrics.get("A087").intValue() : 0);
// 轮胎渗透率(门店)(指标A093)
storePerformanceData.setTirePenetrationStore(storeRates.get("A093"));
// 售前触客数(指标A063)
storePerformanceData.setPreSaleCustomerCount(storeMetrics.get("A063") != null ? storeMetrics.get("A063").intValue() : 0);
// 售后触客数(指标A096)
storePerformanceData.setPostSaleCustomerCount(storeMetrics.get("A096") != null ? storeMetrics.get("A096").intValue() : 0);
// 售前成交数(指标A097)
storePerformanceData.setPreSaleDealCount(storeMetrics.get("A097") != null ? storeMetrics.get("A097").intValue() : 0);
// 售后成交数(指标A098)
storePerformanceData.setPostSaleDealCount(storeMetrics.get("A098") != null ? storeMetrics.get("A098").intValue() : 0);
performanceData.setStoreData(storePerformanceData);
// 2. 获取人员数据
// 分别获取各个指标的数据
java.util.Map<String, java.math.BigDecimal> employeeMetrics = new java.util.HashMap<>();
java.util.Map<String, String> employeeRates = new java.util.HashMap<>(); // 环比数据
String[] employeeItemCodes = {"A036", "A076", "A064", "A085", "A077", "A095", "A0100", "A099", "A0103", "A091", "A0101", "A089", "A0102", "A090", "A0104", "A0105"}; // 指标编码:总产值、客单价、触客率、转化率、渗透率、平均客单价、整车延保-渗透率(员工)、整车延保-转化率、电池-渗透率(员工)、电池-转化率、安心包-渗透率(员工)、安心包-转化率、轮胎渗透率(员工)、轮胎转化率、售前转化率、售后转化率
for (String itemCode : employeeItemCodes) {
cn.com.glsx.dj.supervisor.service.DataBizQueryParamsDTO employeeQueryParams = new cn.com.glsx.dj.supervisor.service.DataBizQueryParamsDTO();
employeeQueryParams.setBizs(req.getBizs()); // 业务类型:1.延保
employeeQueryParams.setMerchantIds(req.getMerchantId() != null ? req.getMerchantId().toString() : null); // 门店ID
employeeQueryParams.setStaffIds(req.getEmployeeId()); // 员工ID
employeeQueryParams.setStartDate(req.getStartDate()); // 开始时间
employeeQueryParams.setEndDate(req.getEndDate()); // 结束时间
employeeQueryParams.setItemCodes(itemCode); // 单个指标编码
String employeeJsonBody = cn.hutool.json.JSONUtil.toJsonStr(employeeQueryParams);
cn.com.glsx.dj.supervisor.model.DataResp<java.util.List<cn.com.glsx.dj.supervisor.model.DataBusinessDTO>> employeeDataResp = getDataStatsService.getListDataResp(employeeJsonBody);
if (employeeDataResp != null && employeeDataResp.getContent() != null && !employeeDataResp.getContent().isEmpty()) {
cn.com.glsx.dj.supervisor.model.DataBusinessDTO employeeData = employeeDataResp.getContent().get(0);
employeeMetrics.put(itemCode, employeeData.getItemValue());
employeeRates.put(itemCode, employeeData.getRate()); // 环比
}
}
// 处理人员数据
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.EmployeeData employeePerformanceData = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.EmployeeData();
employeePerformanceData.setTotalValue(employeeMetrics.get("A036") != null ? employeeMetrics.get("A036").intValue() : 0);
employeePerformanceData.setTotalValueRate(employeeRates.get("A036")); // 总产值环比
employeePerformanceData.setAveragePrice(employeeMetrics.get("A076") != null ? employeeMetrics.get("A076").doubleValue() : 0.0);
employeePerformanceData.setAveragePriceRate(employeeRates.get("A076")); // 客单价环比
// 触客率(指标A064)
employeePerformanceData.setCustomerContactRate(employeeRates.get("A064"));
// 转化率(指标A085)
employeePerformanceData.setConversionRate(employeeRates.get("A085"));
// 渗透率(指标A077)
employeePerformanceData.setPenetrationRate(employeeRates.get("A077"));
// 平均客单价(指标A095)
employeePerformanceData.setAvgUnitPrice(employeeMetrics.get("A095") != null ? employeeMetrics.get("A095").intValue() : 0);
// 整车延保-渗透率(员工)(指标A0100)
employeePerformanceData.setVehicleWarrantyPenetrationEmployee(employeeRates.get("A0100"));
// 整车延保-转化率(指标A099)
employeePerformanceData.setVehicleWarrantyConversionRate(employeeRates.get("A099"));
// 电池-渗透率(员工)(指标A0103)
employeePerformanceData.setBatteryPenetrationEmployee(employeeRates.get("A0103"));
// 电池-转化率(指标A091)
employeePerformanceData.setBatteryConversionRate(employeeRates.get("A091"));
// 安心包-渗透率(员工)(指标A0101)
employeePerformanceData.setSafetyPackPenetrationEmployee(employeeRates.get("A0101"));
// 安心包-转化率(指标A089)
employeePerformanceData.setSafetyPackConversionRate(employeeRates.get("A089"));
// 轮胎渗透率(员工)(指标A0102)
employeePerformanceData.setTirePenetrationEmployee(employeeRates.get("A0102"));
// 轮胎转化率(指标A090)
employeePerformanceData.setTireConversionRate(employeeRates.get("A090"));
// 售前转化率(指标A0104)
employeePerformanceData.setPreSaleConversionRate(employeeRates.get("A0104"));
// 售后转化率(指标A0105)
employeePerformanceData.setPostSaleConversionRate(employeeRates.get("A0105"));
employeePerformanceData.setDailyPerformanceRate("100%"); // 暂时硬编码,后续从其他系统获取
performanceData.setEmployeeData(employeePerformanceData);
// 3. 获取产值趋势数据(返回聚合的时间数据)
cn.com.glsx.dj.supervisor.service.DataBizQueryParamsDTO trendQueryParams = new cn.com.glsx.dj.supervisor.service.DataBizQueryParamsDTO();
trendQueryParams.setBizs(req.getBizs());
trendQueryParams.setMerchantIds(req.getMerchantId() != null ? req.getMerchantId().toString() : null); // 门店ID
trendQueryParams.setStaffIds(req.getEmployeeId()); // 员工ID
trendQueryParams.setStartDate(req.getStartDate()); // 开始时间
trendQueryParams.setEndDate(req.getEndDate()); // 结束时间
trendQueryParams.setItemCodes("A036"); // 指标编码:总产值
trendQueryParams.setDateType(req.getDateType() != null ? req.getDateType() : 0); // 日期类型:0,按指定时段
String trendJsonBody = cn.hutool.json.JSONUtil.toJsonStr(trendQueryParams);
cn.com.glsx.dj.supervisor.model.DataResp<java.util.List<cn.com.glsx.dj.supervisor.model.DataBusinessDTO>> trendDataResp = getDataStatsService.getListDataResp(trendJsonBody);
// 处理产值趋势数据
java.util.List<cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.TrendData> trendData = new java.util.ArrayList<>();
if (trendDataResp != null && trendDataResp.getContent() != null && !trendDataResp.getContent().isEmpty()) {
for (cn.com.glsx.dj.supervisor.model.DataBusinessDTO trendItem : trendDataResp.getContent()) {
cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.TrendData trend = new cn.com.glsx.dj.supervisor.dto.EmployeePerformanceDTO.TrendData();
trend.setDate(trendItem.getDate()); // 日期
trend.setValue(trendItem.getItemValue() != null ? trendItem.getItemValue().intValue() : 0); // 产值
trendData.add(trend);
}
}
performanceData.setTrendData(trendData);
log.info("获取个人业绩数据成功");
return performanceData;
}
/**
* 获取员工调店记录
* <p>
* 根据员工手机号、门店ID列表和业务类型查询员工调店记录
* </p>
*
* @param req 查询参数
* @return 员工调店记录列表
*/
public java.util.List<cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO> getEmployeeStoreTransferRecords(cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferReq req) {
log.info("开始获取员工调店记录,请求参数:{}", req);
java.util.List<cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO> transferRecords = businessSceneMapper.getEmployeeStoreTransferRecords(
req.getPhoneNumber(),
req.getMerchantIds(),
req.getBizs()
);
log.info("获取员工调店记录成功,共 {} 条", transferRecords.size());
return transferRecords;
}
/**
* 获取录音列表
* <p>
* 根据门店ID、员工ID、业务类型和日期范围查询录音列表
* 包含录音摘要和录音列表数据
* </p>
*
* @param req 查询参数
* @return 录音列表数据
*/
public cn.com.glsx.dj.supervisor.dto.RecordingListDTO getRecordingList(cn.com.glsx.dj.supervisor.dto.RecordingQueryReq req) {
log.info("开始获取录音列表,请求参数:{}", req);
// 从数据库查询录音列表
java.util.List<cn.com.glsx.dj.supervisor.dto.RecordingItemDTO> recordingList = businessSceneMapper.getRecordingList(
req.getMerchantId(),
req.getEmployeeId(), // 员工UUID
req.getBiz(), // 业务类型
req.getStartDate(), // 开始日期
req.getEndDate() // 结束日期
);
// 计算总录音数、成交数和战败数
int totalRecordings = recordingList.size();
int dealCount = 0;
int defeatCount = 0;
// 按日期分组统计
java.util.Map<String, cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO> dateSummaryMap = new java.util.HashMap<>();
for (cn.com.glsx.dj.supervisor.dto.RecordingItemDTO item : recordingList) {
// 设置接待结果
if (item.getOrderFinishFlag() != null && item.getOrderFinishFlag()) {
item.setReceptionResult("成交");
dealCount++;
} else {
item.setReceptionResult("战败");
defeatCount++;
}
// 设置案例提交状态(默认未提交)
item.setCaseSubmitStatus(0);
item.setCaseSubmitStatusText("提交优秀案例");
item.setCaseSubmitButtonEnabled(true);
// 设置前端需要的字段
item.setStoreStaff(item.getSalesName()); // 驻店人员使用销售姓名
item.setStoreName(item.getMerchantName()); // 归属门店使用商户名称
item.setCustomerPhone(item.getPhoneNumber()); // 客户手机号
item.setReceptionTime(cn.com.glsx.framework.core.util.DateUtils.formatDate(item.getReceptionStartTime())); // 接待时间使用开始时间
// 按日期分组统计
if (item.getReceptionStartTime() != null) {
String dateStr = cn.com.glsx.framework.core.util.DateUtils.formatDate(item.getReceptionStartTime(), "yyyy-MM-dd");
cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO dateSummary = dateSummaryMap.get(dateStr);
if (dateSummary == null) {
dateSummary = new cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO();
dateSummary.setDate(dateStr);
dateSummary.setTotalRecordings(0);
dateSummary.setDealCount(0);
dateSummary.setDefeatCount(0);
dateSummaryMap.put(dateStr, dateSummary);
}
dateSummary.setTotalRecordings(dateSummary.getTotalRecordings() + 1);
if (item.getOrderFinishFlag() != null && item.getOrderFinishFlag()) {
dateSummary.setDealCount(dateSummary.getDealCount() + 1);
} else {
dateSummary.setDefeatCount(dateSummary.getDefeatCount() + 1);
}
}
}
// 构建录音摘要
cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO summary = new cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO();
summary.setDate(req.getDate() != null ? req.getDate() : req.getStartDate());
summary.setTotalRecordings(totalRecordings);
summary.setDealCount(dealCount);
summary.setDefeatCount(defeatCount);
// 构建按日期分组的摘要列表
java.util.List<cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO> dateSummaryList = new java.util.ArrayList<>(dateSummaryMap.values());
// 按日期排序
dateSummaryList.sort(java.util.Comparator.comparing(cn.com.glsx.dj.supervisor.dto.RecordingSummaryDTO::getDate));
// 分页处理
int pageNum = req.getPageNum() != null ? req.getPageNum() : 1;
int pageSize = req.getPageSize() != null ? req.getPageSize() : 10;
int startIndex = (pageNum - 1) * pageSize;
int endIndex = Math.min(startIndex + pageSize, recordingList.size());
java.util.List<cn.com.glsx.dj.supervisor.dto.RecordingItemDTO> pagedRecordingList = new java.util.ArrayList<>();
if (startIndex < recordingList.size()) {
pagedRecordingList = recordingList.subList(startIndex, endIndex);
}
// 构建返回数据
cn.com.glsx.dj.supervisor.dto.RecordingListDTO result = new cn.com.glsx.dj.supervisor.dto.RecordingListDTO();
result.setSummary(summary);
result.setRecordingList(pagedRecordingList);
result.setTotalCount(totalRecordings);
result.setPageNum(pageNum);
result.setPageSize(pageSize);
result.setDateSummaryList(dateSummaryList);
log.info("获取录音列表成功");
return result;
}
} }
\ No newline at end of file \ No newline at end of file
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="cn.com.glsx.dj.supervisor.mapper.BusinessSceneMapper">
<!-- 根据手机号查询业务场景标签 -->
<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
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 >= DATE_SUB(CURDATE(), INTERVAL 30 DAY)
WHERE si.phone_number = #{phoneNumber}
GROUP BY si.phone_number
</select>
<!-- 查询员工调店记录 -->
<select id="getEmployeeStoreTransferRecords" parameterType="map" resultType="cn.com.glsx.dj.supervisor.dto.EmployeeStoreTransferDTO">
SELECT
gi.merchant_id as merchantId,
MIN(gi.order_time) as startDate
FROM
dj_car_life_staff_info si
LEFT JOIN dj_car_life_goods_order gi ON si.staff_uuid = gi.seller_user_id
WHERE
si.phone_number = #{phoneNumber}
AND gi.merchant_id IN
<foreach collection="merchantIds" item="item" open="(" separator="," close=")">
#{item}
</foreach>
AND gi.deleted_flag = 'N'
<if test="bizs != null">
AND (
(#{bizs} = 1 AND gi.scene_type = 0 AND gi.business_type = 2)
OR (#{bizs} = 2 AND gi.scene_type = 1)
OR (#{bizs} = 3 AND gi.scene_type = 0 AND gi.business_type = 1)
)
</if>
GROUP BY
gi.merchant_id
ORDER BY
MIN(gi.order_time) DESC
</select>
<!-- 查询录音列表 -->
<select id="getRecordingList" parameterType="map" resultType="cn.com.glsx.dj.supervisor.dto.RecordingItemDTO">
SELECT
t1.merchant_id,
t6.merchant_name,
t1.customer_name,
t1.phone_number,
t1.sales_uuid,
t1.sales_name,
t1.car_brand,
t1.car_model,
t1.reception_start_time,
t1.reception_end_time,
t1.reception_status,
t1.staff_uuid,
t2.recording_url as recordingUrl,
t1.car_purchase_method,
t2.check_History_Flag as checkHistoryFlag,
t3.id as batchId,
t3.score as score,
t2.model_type as modelType,
t2.check_type as checkType,
CASE
WHEN EXISTS (
SELECT 1 FROM customer_order_temp t4
WHERE t4.phone = t1.phone_number
AND t4.scene_type = t1.bussiness_type - 1
AND t4.order_status IN (4,6)
) THEN true
ELSE false
END as orderFinishFlag,
t1.one_car_brand as oneCarBrand,
t5.avg_defence as gfScroe,
t5.customer_type as customerType
FROM reception_customer_info t1
LEFT JOIN inspection_badge_recordings t2 ON t1.id = t2.reception_id
LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id
LEFT JOIN inspection_defence t5 ON t3.id =t5.batch_id
LEFT JOIN dj_car_life_service_merchant t6 ON t1.merchant_id=t6.merchant_id
WHERE t1.merchant_id = #{merchantId}
AND t1.staff_uuid = #{uuid}
AND t1.bussiness_type = #{biz}
AND DATE(T1.reception_start_time)>=#{startDate}
AND DATE(T1.reception_start_time)<=#{endDate}
</select>
<!-- 获取考勤统计和着装预警数据 -->
<select id="getAttendanceAndDressCodeData" parameterType="map" resultType="java.util.HashMap">
SELECT
SUM(CASE WHEN clock_in_first_time IS NOT NULL OR clock_in_last_time IS NOT NULL THEN 1 ELSE 0 END) AS checkInDays,
SUM(CASE WHEN clock_in_first_time IS NOT NULL AND TIME(clock_in_first_time) > '09:30:00' THEN 1 ELSE 0 END) AS late,
SUM(CASE WHEN dclsqcii.clock_in_first_time IS NOT NULL AND dclsqcii.clock_in_last_time IS NULL THEN 1
WHEN TIMESTAMPDIFF(HOUR, dclsqcii.clock_in_first_time, dclsqcii.clock_in_last_time) < 8 THEN 1 ELSE 0 END) AS earlyLeave,
SUM(CASE WHEN clock_in_first_time IS NULL THEN 1 ELSE 0 END) AS absenteeism,
SUM(CASE WHEN dclsqcii.clock_in_abnormal_attire = 1 AND dclsqcii.clock_out_abnormal_attire = 1 THEN 2
WHEN dclsqcii.clock_in_abnormal_attire = 1 OR dclsqcii.clock_out_abnormal_attire = 1 THEN 1 ELSE 0 END) AS warningCount,
SUM(CASE WHEN TIME(clock_in_first_time) > '09:30:00'
THEN TIMESTAMPDIFF(MINUTE, DATE_FORMAT(dclsqcii.clock_in_date,'%Y-%m-%d 09:30:00'), clock_in_first_time) ELSE 0 END) AS lateTime,
SUM(CASE WHEN dclsqcii.clock_in_first_time IS NULL AND dclsqcii.clock_in_last_time IS NOT NULL THEN 1
WHEN dclsqcii.clock_in_first_time IS NOT NULL AND dclsqcii.clock_in_last_time IS NULL THEN 1 ELSE 0 END) AS missCount
FROM
dj_car_life_staff_qw_clock_in_info dclsqcii
WHERE
dclsqcii.staff_phone = #{staffPhone}
AND dclsqcii.clock_in_date >= #{startDate}
AND dclsqcii.clock_in_date <= #{endDate}
</select>
<!-- 获取日报统计数据 -->
<select id="getDailyReportData" parameterType="map" resultType="java.util.HashMap">
SELECT
-- 计算日期范围内的自然日数量
(DATEDIFF(#{endDate}, #{startDate}) + 1) AS totalDays,
-- 已提交的日报数量
SUM(CASE WHEN deleted_flag = 'N' THEN 1 ELSE 0 END) AS submitted,
-- 调休的日报数量
SUM(CASE WHEN on_break = 'Y' THEN 1 ELSE 0 END) AS rest,
-- 总接待数(售前+售后)
COALESCE(SUM(film_to_shop_count), 0) + COALESCE(SUM(after_sale_equity_to_shop_count), 0) AS receptionCount
FROM
dj_car_life_staff_daily_report
WHERE
staff_uuid = #{staffUuid}
AND merchant_id = #{merchantId}
AND report_date >= #{startDate}
AND report_date <= #{endDate}
<if test="biz != null">
AND (
(#{biz} = 1 AND scene_type = 0)
OR (#{biz} = 2 AND scene_type = 1)
OR (#{biz} = 3 AND scene_type = 0)
)
</if>
</select>
<!-- 获取客户接待数据 -->
<select id="getCustomerReceptionData" parameterType="map" resultType="java.util.HashMap">
SELECT
-- 店端实际交车数
COALESCE(SUM(huawei.delivery_count), 0) AS deliveryCount,
-- 店端总未触客数 = 店端实际交车数 - 实际交车数
COALESCE(SUM(huawei.not_delivery_count), 0) AS notTouched
FROM
dj_car_life_merchant_daily_report_huawei huawei
WHERE
huawei.merchant_id = #{merchantId}
AND huawei.report_date >= #{startDate}
AND huawei.report_date <= #{endDate}
<if test="biz != null">
AND (
(#{biz} = 1 AND huawei.scene_type = 0)
OR (#{biz} = 2 AND huawei.scene_type = 1)
OR (#{biz} = 3 AND huawei.scene_type = 0)
)
</if>
</select>
<!-- 获取录音分析数据 -->
<select id="getRecordingAnalysisData" parameterType="map" resultType="java.util.HashMap">
SELECT
-- 录音数
COUNT(*) AS recordingCount,
-- 成交数
SUM(CASE WHEN orderFinishFlag = true THEN 1 ELSE 0 END) AS dealCount,
-- 战败数 = 录音数 - 成交数
COUNT(*) - SUM(CASE WHEN orderFinishFlag = true THEN 1 ELSE 0 END) AS defeatCount,
-- 质检平均分
COALESCE(SUM(score) / COUNT(1), 0) AS qualityScore,
-- 平均攻防分
COALESCE(SUM(gfScroe) / COUNT(1), 0) AS attackDefenseScore,
-- 录音缺失率 = (接待数量 - 录音数量) / 接待数量
COALESCE((#{receptionCount} - COUNT(*)) / #{receptionCount} * 100, 0) AS recordingMissingRate
FROM (
SELECT
t1.merchant_id,
t6.merchant_name,
t1.customer_name,
t1.phone_number,
t1.sales_uuid,
t1.sales_name,
t1.car_brand,
t1.car_model,
t1.reception_start_time,
t1.reception_end_time,
t1.reception_status,
t1.staff_uuid,
t2.recording_url as recordingUrl,
t1.car_purchase_method,
t2.check_History_Flag as checkHistoryFlag,
t3.id as batchId,
t3.score as score,
t2.model_type as modelType,
t2.check_type as checkType,
CASE
WHEN EXISTS (
SELECT 1 FROM customer_order_temp t4
WHERE t4.phone = t1.phone_number
AND t4.scene_type = t1.bussiness_type - 1
AND t4.order_status IN (4,6)
) THEN true
ELSE false
END as orderFinishFlag,
t1.one_car_brand as oneCarBrand,
t5.avg_defence as gfScroe,
t5.customer_type as customerType
FROM reception_customer_info t1
LEFT JOIN inspection_badge_recordings t2 ON t1.id = t2.reception_id
LEFT JOIN inspection_conversation_batch t3 ON t3.record_id=t2.id
LEFT JOIN inspection_defence t5 ON t3.id =t5.batch_id and t5.deleted_flag='N'
LEFT JOIN dj_car_life_service_merchant t6 ON t1.merchant_id=t6.merchant_id
WHERE t1.merchant_id = #{merchantId}
AND t1.staff_uuid = #{staffUuid}
AND t1.bussiness_type = #{biz}
AND DATE(T1.reception_start_time)>=#{startDate}
AND DATE(T1.reception_start_time)<=#{endDate}
) AS recordingData
</select>
<!-- 获取行为标签数据 -->
<select id="getBehaviorTags" parameterType="map" resultType="java.util.HashMap">
SELECT
s.*,
t2.tag_name AS tagName,
t3.group_name as groupName
FROM staff_tag_relation s
LEFT JOIN staff_tag_definition t2 ON s.tag_id = t2.id
LEFT JOIN staff_tag_group t3 ON t2.group_id = t3.id
INNER JOIN (
SELECT tag_id, MAX(tag_cycle_starttime) AS max_time
FROM staff_tag_relation
WHERE staff_phone IN
<foreach item="item" collection="phones" separator="," open="(" close=")" index="">
#{item}
</foreach>
GROUP BY tag_id
) latest ON s.tag_id = latest.tag_id AND s.tag_cycle_starttime = latest.max_time
WHERE s.staff_phone IN
<foreach item="item" collection="phones" separator="," open="(" close=")" index="">
#{item}
</foreach>
</select>
</mapper>
\ No newline at end of file \ No newline at end of file
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!