Commit bb67c29e by 范富荣

添加推送轻改客户录音到群聊功能

1 parent 9e3d4f8a
Showing 17 changed files with 962 additions and 6 deletions
...@@ -24,4 +24,9 @@ public interface ConfigCenterConstants { ...@@ -24,4 +24,9 @@ public interface ConfigCenterConstants {
*/ */
String CURRENT_SYSTEM_TIME_FOR_TEST = "current.system.time.for.test"; String CURRENT_SYSTEM_TIME_FOR_TEST = "current.system.time.for.test";
/**
* 客户档案录音对应的URL
*/
String RECEPTION_CUSTOMER_FILE_URL = "reception.customer.file.url";
} }
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ReceptionCustomerFileDetailDTO implements Serializable {
private static final long serialVersionUID = 1L;
// --- Recording Info (Top Module) ---
@ApiModelProperty(notes = "车主姓名")
private String customerName;
@ApiModelProperty(notes = "电话")
private String phoneNumber;
@ApiModelProperty(notes = "接待开始时间")
private Date receptionStartTime;
@ApiModelProperty(notes = "车品牌")
private String carBrand;
// --- Customer File Info (Bottom Module) ---
@ApiModelProperty(notes = "主键ID")
private Long id;
@ApiModelProperty(notes = "提交状态, 0-未提交, 1-已提交")
private Integer submitStatus;
@ApiModelProperty(notes = "录音接待id")
private Integer receptionId;
@ApiModelProperty(notes = "接待结果, 0-成交, 1-战败")
private Integer receptionResult;
@ApiModelProperty(notes = "成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交")
private Integer dealAttribution;
@ApiModelProperty(notes = "战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败")
private Integer loseReason;
@ApiModelProperty(notes = "用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者")
private Integer carUserType;
@ApiModelProperty(notes = "客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他")
private Integer customerBackground;
@ApiModelProperty(notes = "是否好沟通, 0-是, 1-否")
private Integer easyCommunication;
@ApiModelProperty(notes = "是否按揭, 0-是, 1-否")
private Integer isMortgage;
@ApiModelProperty(notes = "首付比例, 0-全款, 1-50%, 2-零首付")
private Integer downPaymentRatio;
@ApiModelProperty(notes = "购车背景, 0-首购, 1-增购")
private Integer purchaseBackground;
@ApiModelProperty(notes = "是否本地用车, 0-本地, 1-外地")
private Integer isLocalUse;
@ApiModelProperty(notes = "购车用途, 0-公司车, 1-家庭用车")
private Integer purchasePurpose;
@ApiModelProperty(notes = "购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃")
private String installItems;
@ApiModelProperty(notes = "赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板")
private String giftItems;
@ApiModelProperty(notes = "贴膜品牌(手填文本)")
private String filmBrand;
@ApiModelProperty(notes = "是否了解其它品牌精品, 0-是, 1-否")
private Integer knowOtherBrandGoods;
}
package cn.com.glsx.dj.mindworkplate.dto;
import com.alibaba.excel.annotation.ExcelProperty;
import com.alibaba.excel.annotation.write.style.ColumnWidth;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceptionCustomerFileExportDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ExcelProperty(value = "驻店人员")
private String salesName;
@ExcelProperty(value = "门店名称")
private String merchantName;
@ExcelProperty(value = "接待日期")
@ColumnWidth(20)
private String receptionStartTimeStr;
@ExcelProperty(value = "客户姓名")
@ColumnWidth(15)
private String customerName;
@ExcelProperty(value = "接待录音链接")
@ColumnWidth(40)
private String fileUrl;
@ExcelProperty(value = "客户手机号")
@ColumnWidth(15)
private String phoneNumber;
@ExcelProperty(value = "车型")
@ColumnWidth(20)
private String carModel;
@ExcelProperty(value = "接待结果")
@ColumnWidth(12)
private String receptionResultStr;
@ExcelProperty(value = "结果归因(新增)")
@ColumnWidth(20)
private String resultAttributionStr;
@ExcelProperty(value = "用车人")
@ColumnWidth(12)
private String carUserTypeStr;
@ExcelProperty(value = "客户背景")
@ColumnWidth(15)
private String customerBackgroundStr;
@ExcelProperty(value = "是否好沟通")
@ColumnWidth(12)
private String easyCommunicationStr;
@ExcelProperty(value = "是否按揭")
@ColumnWidth(12)
private String isMortgageStr;
@ExcelProperty(value = "首付比例")
@ColumnWidth(12)
private String downPaymentRatioStr;
@ExcelProperty(value = "购车背景")
@ColumnWidth(12)
private String purchaseBackgroundStr;
@ExcelProperty(value = "是否本地用车")
@ColumnWidth(15)
private String isLocalUseStr;
@ExcelProperty(value = "购车用途")
@ColumnWidth(15)
private String purchasePurposeStr;
@ExcelProperty(value = "加装项目(多选)")
@ColumnWidth(30)
private String installItemsStr;
@ExcelProperty(value = "赠送精品项目(多选)")
@ColumnWidth(30)
private String giftItemsStr;
@ExcelProperty(value = "窗膜品牌")
@ColumnWidth(15)
private String filmBrand;
@ExcelProperty(value = "是否了解其它品牌精品")
@ColumnWidth(20)
private String knowOtherBrandGoodsStr;
}
package cn.com.glsx.dj.mindworkplate.dto;
import lombok.Data;
import java.io.Serializable;
import java.util.Date;
@Data
public class ReceptionCustomerFileSummaryDTO implements Serializable {
private static final long serialVersionUID = 1L;
// From reception_customer_info
private String salesName;
private String merchantName;
private Date receptionStartTime;
private String customerName;
private String phoneNumber;
private String carModel;
// From inspection_conversation_batch
private String fileUrl;
// From reception_customer_file
private Integer receptionResult;
private Integer dealAttribution;
private Integer loseReason;
private Integer carUserType;
private Integer customerBackground;
private Integer easyCommunication;
private Integer isMortgage;
private Integer downPaymentRatio;
private Integer purchaseBackground;
private Integer isLocalUse;
private Integer purchasePurpose;
private String installItems;
private String giftItems;
private String filmBrand;
private Integer knowOtherBrandGoods;
}
package cn.com.glsx.dj.mindworkplate.dto;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.io.Serializable;
@Data
public class ReceptionCustomerFileUpdateRequestDTO implements Serializable {
private static final long serialVersionUID = 1L;
@ApiModelProperty(notes = "录音接待id", required = true)
private Integer receptionId;
@ApiModelProperty(notes = "接待结果, 0-成交, 1-战败")
private Integer receptionResult;
@ApiModelProperty(notes = "成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交")
private Integer dealAttribution;
@ApiModelProperty(notes = "战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败")
private Integer loseReason;
@ApiModelProperty(notes = "用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者")
private Integer carUserType;
@ApiModelProperty(notes = "客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他")
private Integer customerBackground;
@ApiModelProperty(notes = "是否好沟通, 0-是, 1-否")
private Integer easyCommunication;
@ApiModelProperty(notes = "是否按揭, 0-是, 1-否")
private Integer isMortgage;
@ApiModelProperty(notes = "首付比例, 0-全款, 1-50%, 2-零首付")
private Integer downPaymentRatio;
@ApiModelProperty(notes = "购车背景, 0-首购, 1-增购")
private Integer purchaseBackground;
@ApiModelProperty(notes = "是否本地用车, 0-本地, 1-外地")
private Integer isLocalUse;
@ApiModelProperty(notes = "购车用途, 0-公司车, 1-家庭用车")
private Integer purchasePurpose;
@ApiModelProperty(notes = "购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃")
private String installItems;
@ApiModelProperty(notes = "赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板")
private String giftItems;
@ApiModelProperty(notes = "贴膜品牌(手填文本)")
private String filmBrand;
@ApiModelProperty(notes = "是否了解其它品牌精品, 0-是, 1-否")
private Integer knowOtherBrandGoods;
@ApiModelProperty(notes = "修改人")
private String updatedBy;
}
package cn.com.glsx.dj.mindworkplate.model;
import java.io.Serializable;
import java.util.Date;
import javax.persistence.Column;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.Table;
import lombok.Data;
@Data
@Table(name = "reception_customer_file")
public class ReceptionCustomerFile implements Serializable {
private static final long serialVersionUID = -1L;
/**
* 主键ID
*/
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long id;
/**
* 提交状态, 0-未提交, 1-已提交
*/
@Column(name = "submit_status")
private Integer submitStatus;
/**
* 录音接待id
*/
@Column(name = "reception_id")
private Integer receptionId;
/**
* 接待结果, 0-成交, 1-战败
*/
@Column(name = "reception_result")
private Integer receptionResult;
/**
* 成交归因(接待结果=0时填写), 0-自然成交, 1-活动成交, 2-对比成交, 3-引导成交, 4-口碑成交, 5-培育成交
*/
@Column(name = "deal_attribution")
private Integer dealAttribution;
/**
* 战败归因(接待结果=1时填写), 0-价格战败, 1-竞品战败, 2-产品战败, 3-需求战败, 4-决策战败, 5-服务战败, 6-其他战败
*/
@Column(name = "lose_reason")
private Integer loseReason;
/**
* 用车人, 0-主人本人, 1-公司户, 2-代办, 3-决策者
*/
@Column(name = "car_user_type")
private Integer carUserType;
/**
* 客户背景, 0-企业老板, 1-老师, 2-医生, 3-建筑, 4-个体, 5-自由职业, 6-其他
*/
@Column(name = "customer_background")
private Integer customerBackground;
/**
* 是否好沟通, 0-是, 1-否
*/
@Column(name = "easy_communication")
private Integer easyCommunication;
/**
* 是否按揭, 0-是, 1-否
*/
@Column(name = "is_mortgage")
private Integer isMortgage;
/**
* 首付比例, 0-全款, 1-50%, 2-零首付
*/
@Column(name = "down_payment_ratio")
private Integer downPaymentRatio;
/**
* 购车背景, 0-首购, 1-增购
*/
@Column(name = "purchase_background")
private Integer purchaseBackground;
/**
* 是否本地用车, 0-本地, 1-外地
*/
@Column(name = "is_local_use")
private Integer isLocalUse;
/**
* 购车用途, 0-公司车, 1-家庭用车
*/
@Column(name = "purchase_purpose")
private Integer purchasePurpose;
/**
* 购车时加装项目(多选,英文逗号分隔保存int编码), 0-零重力座椅, 1-轮毂, 2-内饰, 3-玻璃
*/
@Column(name = "install_items")
private String installItems;
/**
* 赠送精品项目(多选,英文逗号分隔保存int编码), 0-脚垫, 1-车衣, 2-底盘护板, 3-电动踏板, 4-小桌板
*/
@Column(name = "gift_items")
private String giftItems;
/**
* 贴膜品牌(手填文本)
*/
@Column(name = "film_brand")
private String filmBrand;
/**
* 是否了解其它品牌精品, 0-是, 1-否
*/
@Column(name = "know_other_brand_goods")
private Integer knowOtherBrandGoods;
/**
* 创建人
*/
@Column(name = "created_by")
private String createdBy;
/**
* 创建时间
*/
@Column(name = "created_date")
private Date createdDate;
/**
* 修改人
*/
@Column(name = "updated_by")
private String updatedBy;
/**
* 修改时间
*/
@Column(name = "updated_date")
private Date updatedDate;
/**
* 删除标识(D:已删除;N:未删除)
*/
@Column(name = "deleted_flag")
private String deletedFlag;
}
...@@ -165,5 +165,10 @@ public class ReceptionCustomerInfo implements Serializable { ...@@ -165,5 +165,10 @@ public class ReceptionCustomerInfo implements Serializable {
@Column(name = "car_purchase_method") @Column(name = "car_purchase_method")
private Integer carPurchaseMethod; private Integer carPurchaseMethod;
@Transient
private String staffName;
@Transient
private String staffPhone;
} }
\ No newline at end of file \ No newline at end of file
...@@ -165,11 +165,16 @@ ...@@ -165,11 +165,16 @@
<artifactId>spring-boot-starter-test</artifactId> <artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope> <scope>test</scope>
</dependency> </dependency>
<dependency> <dependency>
<groupId>cn.com.glsx.merchants</groupId> <groupId>cn.com.glsx.merchants</groupId>
<artifactId>platform-merchants-api</artifactId> <artifactId>platform-merchants-api</artifactId>
<version>5.6.1-SNAPSHOT</version> <version>5.6.1-SNAPSHOT</version>
<scope>compile</scope> <scope>compile</scope>
</dependency> </dependency>
<dependency>
<groupId>org.oreframework.boot</groupId>
<artifactId>ore-boot-starter-alioss</artifactId>
<version>2.2.0-SNAPSHOT</version>
</dependency>
</dependencies> </dependencies>
</project> </project>
\ No newline at end of file \ No newline at end of file
package cn.com.glsx.dj.mindworkplate.job.customer;
import cn.com.glsx.dj.mindworkplate.service.customer.ReceptionCustomerFileGenerateService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import java.time.LocalDate;
import java.time.ZoneId;
import java.time.format.DateTimeFormatter;
import java.time.format.DateTimeParseException;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
//@ElasticJobConf(name = "ReceptionCustomerFileGenerateJob", cron = "0 0/5 * * * ?", description = "生成接待录音对应的客户档案", overwrite = true)
public class ReceptionCustomerFileGenerateJob implements SimpleJob {
//@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Override
public void execute(ShardingContext shardingContext) {
try {
log.info("生成接待录音对应的客户档案任务开始执行");
LocalDate date = getJobDate(shardingContext);
receptionCustomerFileGenerateService.generateLightModCustomerFilesByDate(date);
log.info("生成接待录音对应的客户档案任务结束执行, 日期:{}", date);
} catch (Exception e) {
log.error("生成接待录音对应的客户档案任务执行异常", e);
}
}
private LocalDate getJobDate(ShardingContext shardingContext) {
String param = shardingContext.getJobParameter();
if (StringUtils.isBlank(param)) {
return LocalDate.now(ZoneId.systemDefault());
}
try {
return LocalDate.parse(param.trim(), DateTimeFormatter.ISO_LOCAL_DATE);
} catch (DateTimeParseException e) {
log.warn("生成接待录音对应的客户档案任务日期参数解析失败, param:{}", param);
return LocalDate.now(ZoneId.systemDefault());
}
}
}
package cn.com.glsx.dj.mindworkplate.job.customer;
import cn.com.glsx.dj.mindworkplate.service.customer.ReceptionCustomerFileGenerateService;
import com.dangdang.ddframe.job.api.ShardingContext;
import com.dangdang.ddframe.job.api.simple.SimpleJob;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.oreframework.boot.autoconfigure.elasticjob.annotation.ElasticJobConf;
import org.springframework.beans.factory.annotation.Autowired;
@Slf4j
@ElasticJobConf(name = "ReceptionCustomerFileSummaryJob", cron = "0 0 8 ? * MON", description = "每周一汇总轻改业务客户档案信息并推送到埋点群", overwrite = true)
public class ReceptionCustomerFileSummaryJob implements SimpleJob {
@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Override
public void execute(ShardingContext shardingContext) {
try {
log.info("每周汇总轻改业务客户档案信息任务开始执行");
String jobParam = shardingContext.getJobParameter();
if (StringUtils.isNotBlank(jobParam)) {
String[] dates = jobParam.split(",");
if (dates.length == 2) {
receptionCustomerFileGenerateService.exportAndPushSummary(dates[0], dates[1]);
} else {
log.warn("定时任务参数格式不正确,期望格式:'yyyy-MM-dd,yyyy-MM-dd',实际:{}", jobParam);
receptionCustomerFileGenerateService.exportAndPushSummary(null, null); // 使用默认日期范围
}
} else {
receptionCustomerFileGenerateService.exportAndPushSummary(null, null); // 使用默认日期范围
}
log.info("每周汇总轻改业务客户档案信息任务结束执行");
} catch (Exception e) {
log.error("每周汇总轻改业务客户档案信息任务执行异常", e);
}
}
}
package cn.com.glsx.dj.mindworkplate.mapper;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile;
import cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo;
import java.util.Date;
import java.util.List;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.oreframework.datasource.mybatis.mapper.OreMapper;
@Mapper
public interface ReceptionCustomerFileMapper extends OreMapper<ReceptionCustomerFile> {
List<ReceptionCustomerInfo> listNeedGenerateTodayLightModReception(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
Integer batchInsertInit(@Param("list") List<ReceptionCustomerFile> list);
Integer updateCustomerFileFlag(@Param("ids") List<Integer> ids);
Integer updatePushStatusByReceptionIds(@Param("receptionIds") List<Integer> receptionIds);
ReceptionCustomerFileDetailDTO findDetailByReceptionId(@Param("receptionId") Integer receptionId);
Integer updateByReceptionId(ReceptionCustomerFileUpdateRequestDTO request);
ReceptionCustomerFile selectByReceptionId(@Param("receptionId") Integer receptionId);
List<ReceptionCustomerFileSummaryDTO> listSummaryBetweenDates(
@Param("startTime") Date startTime,
@Param("endTime") Date endTime);
}
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.util.HttpUtil;
import cn.com.glsx.entmicro.model.request.EntmicroStaffRequest;
import cn.com.glsx.entmicro.model.response.EntmicroStaffResponse;
import cn.com.glsx.entmicro.remote.EntmicroStaffRemote;
import cn.com.glsx.framework.core.beans.rpc.RpcResponse;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.request.SendWorkWechatMessageRequestDTO;
import cn.com.glsx.scrm.wechat.dto.workwechat.message.response.SendWorkWechatMessageResponseDTO;
import cn.com.glsx.scrm.wechat.remote.WorkWechatMessageRemote;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang.StringUtils;
import org.oreframework.boot.env.OrePropertyConfigurer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.env.Environment;
import org.springframework.stereotype.Service;
import javax.annotation.Resource;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
@Service
@Slf4j
public class QWManager {
@Autowired
private Environment environment;
@Resource
private EntmicroStaffRemote entmicroStaffRemote;
@Autowired
private WorkWechatMessageRemote workWechatMessageRemote;
/**
* 通过http请求发送企微应用消息
*
* @param sendWorkWechatMessageRequestDTO
* @return
*/
public SendWorkWechatMessageResponseDTO sendMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("发送企微应用消息:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
SendWorkWechatMessageResponseDTO responseDTO=null;
try {
String baseurl = environment.getProperty("wechat.base.path")+"/wechat/message/sendMessage";
responseDTO = HttpUtil.post(baseurl,JSONObject.parseObject(JSONObject.toJSONString(sendWorkWechatMessageRequestDTO)), SendWorkWechatMessageResponseDTO.class);
log.info("发送企微应用消息 ropResponse:{}", JSON.toJSONString(responseDTO));
} catch (Exception e) {
e.printStackTrace();
log.info("发送企微应用消息异常:", e);
}
return responseDTO;
}
public boolean sendSingleWechatMessage(SendWorkWechatMessageRequestDTO sendWorkWechatMessageRequestDTO) {
log.info("sendMessage request:{}", JSON.toJSONString(sendWorkWechatMessageRequestDTO));
RpcResponse<SendWorkWechatMessageResponseDTO> sendWorkWechatMessageResponseDTORpcResponse = workWechatMessageRemote
.sendMessage(sendWorkWechatMessageRequestDTO);
log.info("sendMessage resp:{}", JSON.toJSONString(sendWorkWechatMessageResponseDTORpcResponse));
if (!sendWorkWechatMessageResponseDTORpcResponse.isSuccess()) {
log.info("发送企微消息,参数为:{},异常:{}", sendWorkWechatMessageRequestDTO,
sendWorkWechatMessageResponseDTORpcResponse.getException());
return false;
}
return true;
}
/**
* 通过商户号+手机号查询企微员工标识
*
* @param merchantId 商户号
* @param mobile 手机号
* @return 企微userId
*/
public String getUserId(Integer merchantId, String mobile) {
log.info("查询企微员工标识, 商户号:{}, 手机号:{}", merchantId, mobile);
String userId = null;
try {
String baseurl = environment.getProperty("wechat.base.path") + "/wechat/oa/getuserid";
JSONObject requestBody = new JSONObject();
requestBody.put("merchantId", merchantId);
requestBody.put("mobile", mobile);
JSONObject responseDTO = HttpUtil.post(baseurl, requestBody, JSONObject.class);
log.info("查询企微员工标识 response:{}", JSON.toJSONString(responseDTO));
if (responseDTO != null && responseDTO.getBoolean("success")) {
userId = responseDTO.getString("userid");
}
} catch (Exception e) {
e.printStackTrace();
log.error("查询企微员工标识异常:", e);
}
return userId;
}
/**
* 获取全量广联数科员工企微
*/
public Map<String, String> getSendUserIds() {
EntmicroStaffRequest entmicroStaffRequest = new EntmicroStaffRequest();
// dev = 44211227 test = 44209813 线上 = 44202977
Integer merchantId = OrePropertyConfigurer.getProperty("dj.send.work.wechat.merchant.id",Integer.class,44202977);
entmicroStaffRequest.setMerchantId(merchantId);
RpcResponse<List<EntmicroStaffResponse>> staffResponse = entmicroStaffRemote.findStaffByMerchantId(entmicroStaffRequest);
if (staffResponse.hasResult()) {
List<EntmicroStaffResponse> result = staffResponse.getResult();
return result.stream().filter(item ->
StringUtils.isNotBlank(item.getStaffPhone()) && StringUtils.isNotBlank(item.getUserId()))
.collect(Collectors.toMap(EntmicroStaffResponse::getStaffPhone, EntmicroStaffResponse::getUserId, (a, b) -> a));
}
if (staffResponse.isFailed()) {
log.warn("获取发送员工失败,失败原因:{}", staffResponse.getException().getMessage());
}
return null;
}
public String getJoinedUserIds(Map<String, String> phoneToUserIdMap, List<String> phoneNumbers) {
StringBuilder userIds = new StringBuilder();
for (String phoneNumber : phoneNumbers) {
String userId = phoneToUserIdMap.get(phoneNumber);
if (userId != null) {
if (userIds.length() > 0) {
userIds.append("|");
}
userIds.append(userId);
}
}
return userIds.toString();
}
}
...@@ -78,6 +78,34 @@ public class EasyExcelUtils { ...@@ -78,6 +78,34 @@ public class EasyExcelUtils {
head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data); head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
} }
/**
* 导出
*
* @param os
* @param data
* @param sheetName
* @param clazz
*/
public static void writeExcelWithOutWraypped(OutputStream os, List<? extends Object> data, String sheetName, Class clazz, String serviceProviderType) {
//表头样式
WriteCellStyle headWriteCellStyle = new WriteCellStyle();
// 允许自动换行
headWriteCellStyle.setWrapped(true);
//设置表头居中对齐
headWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.CENTER);
WriteFont writeFont = new WriteFont();
writeFont.setFontHeightInPoints((short) 12);
headWriteCellStyle.setWriteFont(writeFont);
//内容样式
WriteCellStyle contentWriteCellStyle = new WriteCellStyle();
//设置内容靠左对齐
contentWriteCellStyle.setHorizontalAlignment(HorizontalAlignment.LEFT);
contentWriteCellStyle.setWrapped(false);
HorizontalCellStyleStrategy horizontalCellStyleStrategy = new HorizontalCellStyleStrategy(headWriteCellStyle, contentWriteCellStyle);
ExcelWriterBuilder head = EasyExcel.write(os).head(clazz);
head.excelType(ExcelTypeEnum.XLSX).sheet(sheetName).registerWriteHandler(horizontalCellStyleStrategy).doWrite(data);
}
/** /**
* 导出 * 导出
* *
......
...@@ -50,4 +50,11 @@ public class ExcelExportUtils { ...@@ -50,4 +50,11 @@ public class ExcelExportUtils {
} }
} }
} }
public static byte[] excelExportWithoutUpload(String filename, List<? extends Object> list, Class clazz, String serviceProviderType) {
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
EasyExcelUtils.writeExcelWithOutWraypped(outputStream, list, filename, clazz, serviceProviderType);
byte[] bytes = outputStream.toByteArray();
return bytes;
}
} }
<?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.mindworkplate.mapper.ReceptionCustomerFileMapper">
<select id="listNeedGenerateTodayLightModReception" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerInfo">
select distinct
rci.id as id,
rci.reception_status as receptionStatus,
ieb.employee_name as staffName,
ieb.phone_number as staffPhone,
rci.customer_name as customerName,
rci.phone_number as phoneNumber
from reception_customer_info rci
inner join inspection_badge_recordings ibr on ibr.reception_id = rci.id and ibr.deleted_flag = 'N'
inner join inspection_conversation_batch cb on cb.task_id = rci.id and cb.deleted_flag = 'N'
inner join inspection_conversation_date t2 on cb.conversation_id = t2.id and t2.deleted_flag = 'N'
inner join inspection_employee_badge ieb on ieb.badge_id = t2.badge_id and ieb.deleted_flag = 'N'
where rci.deleted_flag = 'N'
and rci.bussiness_type = 2
and rci.reception_start_time &gt;= #{startTime}
and rci.reception_start_time &lt; #{endTime}
and ibr.recording_id is not null and ibr.recording_id != ''
and not exists (
select 1 from reception_customer_file rcf
where rcf.reception_id = rci.id and rcf.deleted_flag = 'N'
)
order by rci.id asc
</select>
<insert id="batchInsertInit">
insert into reception_customer_file
(submit_status, push_status, reception_id, reception_result, created_by, created_date, deleted_flag)
values
<foreach collection="list" item="item" separator=",">
(#{item.submitStatus}, #{item.pushStatus}, #{item.receptionId}, #{item.receptionResult}, #{item.createdBy}, #{item.createdDate}, #{item.deletedFlag})
</foreach>
</insert>
<update id="updateCustomerFileFlag">
update reception_customer_info
set customer_file_flag = 1, updated_by = 'system', updated_date = now()
where id in
<foreach collection="ids" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<update id="updatePushStatusByReceptionIds">
update reception_customer_file
set push_status = 1, updated_by = 'system', updated_date = now()
where reception_id in
<foreach collection="receptionIds" item="item" separator="," open="(" close=")">
#{item}
</foreach>
</update>
<select id="findDetailByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO">
select
rci.customer_name as customerName,
rci.phone_number as phoneNumber,
rci.reception_start_time as receptionStartTime,
rci.car_brand as carBrand,
rcf.id as id,
rcf.submit_status as submitStatus,
rcf.reception_id as receptionId,
rcf.reception_result as receptionResult,
rcf.deal_attribution as dealAttribution,
rcf.lose_reason as loseReason,
rcf.car_user_type as carUserType,
rcf.customer_background as customerBackground,
rcf.easy_communication as easyCommunication,
rcf.is_mortgage as isMortgage,
rcf.down_payment_ratio as downPaymentRatio,
rcf.purchase_background as purchaseBackground,
rcf.is_local_use as isLocalUse,
rcf.purchase_purpose as purchasePurpose,
rcf.install_items as installItems,
rcf.gift_items as giftItems,
rcf.film_brand as filmBrand,
rcf.know_other_brand_goods as knowOtherBrandGoods
from inspection_conversation_batch t2
LEFT JOIN reception_customer_file rcf on rcf.reception_id = t2.record_id and rcf.deleted_flag = 'N'
left join reception_customer_info rci on t2.task_id = rci.id and rci.deleted_flag = 'N'
where t2.record_id = #{receptionId}
limit 1
</select>
<update id="updateByReceptionId">
update reception_customer_file
<set>
<if test="receptionResult != null">reception_result = #{receptionResult},</if>
<if test="dealAttribution != null">deal_attribution = #{dealAttribution},</if>
<if test="loseReason != null">lose_reason = #{loseReason},</if>
<if test="carUserType != null">car_user_type = #{carUserType},</if>
<if test="customerBackground != null">customer_background = #{customerBackground},</if>
<if test="easyCommunication != null">easy_communication = #{easyCommunication},</if>
<if test="isMortgage != null">is_mortgage = #{isMortgage},</if>
<if test="downPaymentRatio != null">down_payment_ratio = #{downPaymentRatio},</if>
<if test="purchaseBackground != null">purchase_background = #{purchaseBackground},</if>
<if test="isLocalUse != null">is_local_use = #{isLocalUse},</if>
<if test="purchasePurpose != null">purchase_purpose = #{purchasePurpose},</if>
<if test="installItems != null">install_items = #{installItems},</if>
<if test="giftItems != null">gift_items = #{giftItems},</if>
<if test="filmBrand != null">film_brand = #{filmBrand},</if>
<if test="knowOtherBrandGoods != null">know_other_brand_goods = #{knowOtherBrandGoods},</if>
<if test="updatedBy != null">updated_by = #{updatedBy},</if>
submit_status = 1,
updated_date = now()
</set>
where reception_id = #{receptionId}
and deleted_flag = 'N'
</update>
<select id="listSummaryBetweenDates" resultType="cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileSummaryDTO">
select
ieb.employee_name as salesName,
rci.merchant_id as merchantName,
rci.reception_start_time as receptionStartTime,
rci.customer_name as customerName,
rci.phone_number as phoneNumber,
rci.car_model as carModel,
icb.file_url as fileUrl,
rcf.reception_result as receptionResult,
rcf.deal_attribution as dealAttribution,
rcf.lose_reason as loseReason,
rcf.car_user_type as carUserType,
rcf.customer_background as customerBackground,
rcf.easy_communication as easyCommunication,
rcf.is_mortgage as isMortgage,
rcf.down_payment_ratio as downPaymentRatio,
rcf.purchase_background as purchaseBackground,
rcf.is_local_use as isLocalUse,
rcf.purchase_purpose as purchasePurpose,
rcf.install_items as installItems,
rcf.gift_items as giftItems,
rcf.film_brand as filmBrand,
rcf.know_other_brand_goods as knowOtherBrandGoods
from reception_customer_file rcf
left join inspection_conversation_batch icb on rcf.reception_id = icb.record_id and icb.deleted_flag = 'N'
left join reception_customer_info rci on icb.task_id = rci.id and rci.deleted_flag = 'N'
LEFT JOIN inspection_badge_recordings t3 ON icb.record_id = t3.id and t3.deleted_flag = 'N'
LEFT JOIN inspection_employee_badge ieb ON t3.badge_id = ieb.badge_id and ieb.deleted_flag = 'N'
where rcf.submit_status = 1
and rcf.created_date &gt;= #{startTime}
and rcf.created_date &lt; #{endTime}
and rcf.deleted_flag = 'N'
order by rcf.created_date desc
</select>
<select id="selectByReceptionId" resultType="cn.com.glsx.dj.mindworkplate.model.ReceptionCustomerFile">
select
id, submit_status, reception_id, reception_result, deal_attribution,
lose_reason, car_user_type, customer_background, easy_communication, is_mortgage,
down_payment_ratio, purchase_background, is_local_use, purchase_purpose,
install_items, gift_items, film_brand, know_other_brand_goods,
created_by, created_date, updated_by, updated_date, deleted_flag
from reception_customer_file
where reception_id = #{receptionId}
and deleted_flag = 'N'
limit 1
</select>
</mapper>
package cn.com.glsx.dj.mindworkplate.service.customer;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileDetailDTO;
import cn.com.glsx.dj.mindworkplate.dto.ReceptionCustomerFileUpdateRequestDTO;
import cn.com.glsx.dj.mindworkplate.service.BaseServiceTest;
import org.junit.Test;
import org.springframework.beans.factory.annotation.Autowired;
import java.time.LocalDate;
public class ReceptionCustomerFileGenerateServiceTest extends BaseServiceTest {
@Autowired
private ReceptionCustomerFileGenerateService receptionCustomerFileGenerateService;
@Test
public void testGenerateLightModCustomerFilesByDate() {
//指定日期:2024-05-10
LocalDate date = LocalDate.of(2024, 5, 10);
receptionCustomerFileGenerateService.generateLightModCustomerFilesByDate(date);
}
@Test
public void testUpdateCustomerFile() {
ReceptionCustomerFileUpdateRequestDTO request = new ReceptionCustomerFileUpdateRequestDTO();
request.setReceptionId(823);
request.setReceptionResult(0);
request.setDealAttribution(0);
//request.setLoseReason(0);
request.setCarUserType(0);
request.setCustomerBackground(0);
request.setEasyCommunication(0);
request.setIsMortgage(0);
request.setDownPaymentRatio(0);
request.setPurchaseBackground(0);
request.setIsLocalUse(0);
request.setPurchasePurpose(0);
request.setInstallItems("0");
request.setGiftItems("0");
request.setFilmBrand("");
request.setKnowOtherBrandGoods(0);
request.setUpdatedBy("ffr");
receptionCustomerFileGenerateService.updateCustomerFile(request);
ReceptionCustomerFileDetailDTO detailByReceptionId = receptionCustomerFileGenerateService.findDetailByReceptionId(823);
System.out.println(detailByReceptionId);
}
@Test
public void testExportAndPushSummary() {
receptionCustomerFileGenerateService.exportAndPushSummary("2026-04-06", "2026-04-12");
}
}
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!