Skip to content

Commit

Permalink
Merge pull request #44 from lianluoyi/dev
Browse files Browse the repository at this point in the history
V1.33.0版本更新
  • Loading branch information
broccoli77 committed Oct 23, 2023
2 parents 9244476 + b8db7a2 commit e4afe2a
Show file tree
Hide file tree
Showing 83 changed files with 2,252 additions and 335 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
import com.easyink.common.constant.Constants;
import com.easyink.common.core.domain.AjaxResult;
import com.easyink.common.core.domain.FileVo;
import com.easyink.common.enums.ResultTip;
import com.easyink.common.exception.CustomException;
import com.easyink.common.exception.file.FileException;
import com.easyink.common.exception.file.NoFileException;
import com.easyink.common.utils.StringUtils;
import com.easyink.common.utils.file.FileUploadUtils;
import com.easyink.common.utils.file.FileUtils;
Expand All @@ -24,6 +28,8 @@

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.IOException;

/**
Expand Down Expand Up @@ -77,13 +83,21 @@ public void fileDownload(@ApiParam("文件名") String fileName, @ApiParam("是
response.setContentType("multipart/form-data");
response.setHeader("Content-Disposition",
"attachment;fileName=" + FileUtils.setFileDownloadHeader(request, realFileName));
// 检查文件是否存在
File file = new File(filePath);
if (!file.exists()) {
log.error("要下载的文件不存在: {}", filePath);
throw new NoFileException("no file");
}
FileUtils.writeBytes(filePath, response.getOutputStream());
if (Boolean.TRUE.equals(delete)) {
FileUtils.deleteFile(filePath);
}
} catch (Exception e) {
log.error("下载文件失败 e:{}", ExceptionUtils.getStackTrace(e));
} catch (IOException e) {
log.error("下载文件失败, e:{}", ExceptionUtils.getStackTrace(e));
throw new NoFileException("error");
}

}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.easyink.common.core.controller.BaseController;
import com.easyink.common.core.domain.AjaxResult;
import com.easyink.common.core.domain.ConversationArchiveQuery;
import com.easyink.common.core.domain.ConversationArchiveViewContextDTO;
import com.easyink.common.core.page.TableDataInfo;
import com.easyink.common.token.TokenService;
import com.easyink.common.utils.ServletUtils;
import com.easyink.common.utils.StringUtils;
Expand Down Expand Up @@ -86,4 +88,10 @@ public AjaxResult<PageInfo<ConversationArchiveVO>> getChatAllList(ConversationAr
return AjaxResult.success(weConversationArchiveService.getChatAllList(query, tokenService.getLoginUser(ServletUtils.getRequest())));
}

@ApiOperation(value = "查看消息上下文接口", httpMethod = "GET")
@GetMapping("/view/context")
public TableDataInfo<ConversationArchiveVO> viewContext(ConversationArchiveViewContextDTO dto) {
dto.setCorpId(LoginTokenService.getLoginUser().getCorpId());
return weConversationArchiveService.viewContext(dto);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package com.easyink.web.controller.wecom;

import com.easyink.common.annotation.DataScope;
import com.easyink.common.annotation.Log;
import com.easyink.common.constant.WeConstans;
import com.easyink.common.core.controller.BaseController;
Expand All @@ -15,22 +16,31 @@
import com.easyink.wecom.domain.dto.tag.RemoveWeCustomerTagDTO;
import com.easyink.wecom.domain.entity.WeCustomerExportDTO;
import com.easyink.wecom.domain.vo.WeMakeCustomerTagVO;
import com.easyink.wecom.domain.vo.customer.WeCustomerSumVO;
import com.easyink.wecom.domain.vo.customer.WeCustomerUserListVO;
import com.easyink.wecom.domain.vo.customer.WeCustomerVO;
import com.easyink.wecom.domain.vo.customer.*;
import com.easyink.wecom.login.util.LoginTokenService;
import com.easyink.wecom.service.WeCustomerService;
import com.easyink.wecom.utils.OprIdGenerator;
import com.google.common.collect.Lists;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;

import static com.easyink.common.constant.Constants.EXPORT_MAX_WAIT_TIME;

/**
* 企业微信客户Controller
Expand All @@ -48,6 +58,9 @@ public class WeCustomerController extends BaseController {
@Lazy
private WeCustomerService weCustomerService;

@Resource(name = "threadPoolTaskExecutor")
private ThreadPoolTaskExecutor threadPoolTaskExecutor;

/**
* 查询企业微信客户列表
*/
Expand All @@ -70,6 +83,7 @@ public TableDataInfo<WeCustomerVO> listV2(@RequestBody WeCustomerSearchDTO weCus
//预设分页参数
PageInfoUtil.setPage(pageNum, pageSize);
}
weCustomerSearchDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId());
WeCustomer weCustomer=weCustomerService.changeWecustomer(weCustomerSearchDTO);
List<WeCustomerVO> list = weCustomerService.selectWeCustomerListV3(weCustomer);
return getDataTable(list);
Expand All @@ -93,6 +107,7 @@ public TableDataInfo<WeCustomerVO> listDistinct(WeCustomer weCustomer) {
@PostMapping("/sum")
@ApiOperation("查询企业客户统计数据")
public AjaxResult<WeCustomerSumVO> sum(@RequestBody WeCustomerSearchDTO weCustomerSearchDTO) {
weCustomerSearchDTO.setCorpId(LoginTokenService.getLoginUser().getCorpId());
WeCustomer weCustomer=weCustomerService.changeWecustomer(weCustomerSearchDTO);
weCustomer.setCorpId(LoginTokenService.getLoginUser().getCorpId());
return AjaxResult.success(weCustomerService.weCustomerCount(weCustomer));
Expand All @@ -110,18 +125,65 @@ public AjaxResult<List<WeCustomerVO>> getCustomersByUserIdV2(@PathVariable Strin
*/
@PreAuthorize("@ss.hasPermi('customerManage:customer:export') || @ss.hasPermi('customerManage:lossRemind:export')")
@Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
@PostMapping("/export")
// @PostMapping("/export")
@ApiOperation("导出企业微信客户列表")
@Deprecated
public <T> AjaxResult<T> export(@RequestBody WeCustomerExportDTO dto) {
dto.setCorpId(LoginTokenService.getLoginUser().getCorpId());
log.info("[导出客户]开始导出,corpId:{}", dto.getCorpId());
long startTime = System.currentTimeMillis();
AjaxResult<T> export = weCustomerService.export(dto);
long endTime = System.currentTimeMillis();
log.info("[导出客户]导出完成,corpId:{} , time:{} ", dto.getCorpId(), ( endTime - startTime) / 1000.00D);
log.info("[导出客户]导出完成,corpId:{} , time:{} ", dto.getCorpId(), (endTime - startTime) / 1000.00D);
return export;
}

/**
* 导出企业微信客户列表V2
*/
@PreAuthorize("@ss.hasPermi('customerManage:customer:export') || @ss.hasPermi('customerManage:lossRemind:export')")
@Log(title = "企业微信客户", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ApiOperation("导出企业微信客户列表")
public AjaxResult<ExportOprVO> exportV2(@RequestBody WeCustomerExportDTO dto) {
LoginUser loginUser = LoginTokenService.getLoginUser();
dto.setCorpId(loginUser.getCorpId());
dto.setAdmin(loginUser.isSuperAdmin());
String oprId = OprIdGenerator.EXPORT.get();
String fileName = UUID.randomUUID() + "_" + "customer" + ".xlsx";
ExportOprVO result = ExportOprVO.builder().oprId(oprId).fileName(fileName).hasFinished(false).build();
if(dto.getSelectedProperties() == null || dto.getSelectedProperties().size() == 0) {
dto.setSelectedProperties( Lists.newArrayList("客户","添加时间","所属员工","标签"));
}
WeCustomerExportDTO customer = weCustomerService.transferData(dto);
CompletableFuture future = CompletableFuture.runAsync(() -> {
// 执行异步处理任务
weCustomerService.genExportData(customer, oprId, fileName);
}, threadPoolTaskExecutor);
try {
// 在3秒内等待异步处理任务完成
future.get(EXPORT_MAX_WAIT_TIME, TimeUnit.SECONDS);
result.setHasFinished(true);
return AjaxResult.success(result);
} catch (TimeoutException e) {
// 处理未完成,只返回OprId
return AjaxResult.success(result);
} catch (InterruptedException | ExecutionException e) {
// 处理出现异常
return AjaxResult.error();
}
}


@GetMapping("/export/result")
@ApiOperation("获取导出客户的结果")
public AjaxResult getExportResult(String oprId) {
return AjaxResult.success(new CustomerExportResultVO(
weCustomerService.getExportResult(oprId)
)
);
}

/**
* 获取企业微信客户详细信息-> 未被使用
*/
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package com.easyink.web.controller.wecom.transfer;

import com.easyink.common.core.domain.AjaxResult;
import com.easyink.wecom.service.WeFlowerCustomerRelService;
import com.easyink.wecom.service.WeSensitiveActHitService;
import com.easyink.wecom.service.WeUserCustomerMessageStatisticsService;
import io.swagger.annotations.Api;
Expand All @@ -24,6 +25,7 @@ public class WeComTransferController {

private final WeUserCustomerMessageStatisticsService weUserCustomerMessageStatisticsService;
private final WeSensitiveActHitService weSensitiveActHitService;
private final WeFlowerCustomerRelService weFlowerCustomerRelService;

@PostMapping("/updateUserActiveChatCnt")
@ApiOperation("更新历史数据中员工主动发起的会话数")
Expand All @@ -38,4 +40,11 @@ public AjaxResult updateSensitive() {
weSensitiveActHitService.updateHistorySensitive();
return AjaxResult.success();
}

@PostMapping("/update/totalAllCustomerCnt")
@ApiOperation("数据统计-联系客户-客户总数,旧数据统计")
public AjaxResult updateTotalAllCustomerCnt() {
weFlowerCustomerRelService.updateTotalAllCustomerCnt();
return AjaxResult.success();
}
}
7 changes: 7 additions & 0 deletions easyink-admin/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -491,6 +491,9 @@ wecome:
needErrcodeUrl: # 如果有错误码需要单独业务处理,不抛出异常的接口
- /externalcontact/get_group_msg_result
- /externalcontact/del_corp_tag
# 需要重试判断的code
needRetryCode:
- 45033

# JS SDK 身份校验url
authorizeUrl: ${WE_COM_AUTHORIZE_URL:https://open.weixin.qq.com/connect/oauth2/authorize}
Expand Down Expand Up @@ -558,4 +561,8 @@ thread-pool-prop:
corePoolSize: ${THREAD_POOL_SEND_CALLBACK_CORE_SIZE:50}
maxPoolSize: ${THREAD_POOL_SEND_CALLBACK_MAX_SIZE:200}
queueCapacity: ${THREAD_POOL_SEND_CALLBACK_QUEUE_SIZE:100}
# 获取员工执行群发结果线程池参数(因为企微官方接口频率限制,所以这个线程池的最大线程数限制为5)
messageResultTask:
corePoolSize: ${THREAD_POOL_SEND_CALLBACK_CORE_SIZE:5}
maxPoolSize: ${THREAD_POOL_SEND_CALLBACK_MAX_SIZE:5}

Original file line number Diff line number Diff line change
Expand Up @@ -58,4 +58,9 @@ public class WeComeConfig {
*/
private String[] needErrcodeUrl;

/**
* 需要重试判断的Code
*/
private Integer[] needRetryCode;

}
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,12 @@ public static Long[] getInitMenuList(){
*/
protected static final String[] CSV_INJECT_CHAR_LIST = {"+", "-", "@", "="};

/**
* 导出最大等待时间
*/
public final static int EXPORT_MAX_WAIT_TIME = 3 ;


/**
* 获得可能会引起CSV注入 的特殊字符序列
*
Expand All @@ -295,4 +301,14 @@ public static Long[] getInitMenuList(){
* 默认的新客留存率值
*/
public static final String EMPTY_RETAIN_RATE_VALUE = "-";

/**
* 数据统计-联系客户最大查询时间范围
*/
public static final Integer STATISTIC_MAX_COUNT_DATES = 180;

/**
* 群发发送人/群名称的分隔符
*/
public static final String CUSTOMER_PUSH_MESSAGE_SEPARATOR = "、";
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
package com.easyink.common.constant.conversation;

/**
* 会话存档常量类
*
* @author lichaoyu
* @date 2023/9/18 10:11
*/
public class ConversationArchiveConstants {

/**
* 发送状态为已发送
*/
public static final String ACTION_SEND = "send";

/**
* 发送状态为已撤回
*/
public static final String ACTION_RECALL = "recall";

/**
* 查询的结果数量开始位置
*/
public static final int SEARCH_FROM = 0;

/**
* 查询的结果数量最大值(pageSize设置为10000表示全部查询)
*/
public static final int SEARCH_SIZE = 10000;

/**
* 返回的msgId标识符
*/
public static final String MSG_ID = "msgId";

/**
* 查询下文信息标识
*/
public static final String PRIOR_CONTEXT = "after";

/**
* 查询上文信息标识
*/
public static final String NEXT_CONTEXT = "before";

/**
* 默认的查询上下文信息的聊天条数
*/
public static final int DEFAULT_CONTEXT_NUM = 10;

/**
* 分页查询上下文信息的聊天条数
*/
public static final int PAGE_CONTEXT_NUM = 20;
}
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,14 @@ public class BaseEntity extends RootEntity implements Serializable {
@ApiModelProperty(value = "做游标分页时使用,查找userId > lastId的数据")
private String lastId;

/**
* 是否是管理员 ,如果是管理员则部分查询可以简化
*/
@JsonIgnore
@TableField(exist = false)
private Boolean isAdmin;


public String getLastId() {
return lastId;
}
Expand Down Expand Up @@ -205,5 +213,11 @@ public void setEndTime(String endTime) {
this.endTime = DateUtils.parseEndDay(endTime);
}

public Boolean getAdmin() {
return isAdmin;
}

public void setAdmin(Boolean admin) {
isAdmin = admin;
}
}
Loading

0 comments on commit e4afe2a

Please sign in to comment.