|
|
|
@ -1,9 +1,11 @@
|
|
|
|
|
package com.kiisoo.ic.job.count;
|
|
|
|
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
|
|
import com.kiisoo.ic.common.utils.ExcelUtils;
|
|
|
|
|
import com.kiisoo.ic.config.WxCpConfiguration;
|
|
|
|
|
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
|
|
|
|
|
import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper;
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
|
import com.kiisoo.ic.store.entity.PrivilageCpUserStoreDO;
|
|
|
|
|
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
|
|
|
|
|
import com.kiisoo.ic.system.entity.SysTaskDO;
|
|
|
|
@ -16,9 +18,18 @@ import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
import me.chanjar.weixin.common.error.WxErrorException;
|
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
|
|
|
|
|
import me.chanjar.weixin.cp.api.WxCpService;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
import org.apache.poi.ss.usermodel.CellType;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
|
@ -26,6 +37,7 @@ import java.util.concurrent.Executors;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import static com.kiisoo.ic.config.WxCpConfiguration.APPLICATIONID;
|
|
|
|
|
import static com.kiisoo.ic.store.constant.Constants.DATABASE_CODE_KEY;
|
|
|
|
|
import static com.kiisoo.ic.system.constant.SysTaskConstant.TASK_STATUS_FINISHED;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
@ -50,7 +62,7 @@ public class CustomerCountJob {
|
|
|
|
|
private SysTaskDOMapper sysTaskDOMapper;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void handle(Boolean isAll,SysTaskDO sysTaskDO) throws WxErrorException {
|
|
|
|
|
public void handle(Boolean isAll,SysTaskDO sysTaskDO) throws WxErrorException, IOException {
|
|
|
|
|
|
|
|
|
|
//创建线程池
|
|
|
|
|
ExecutorService executors = Executors.newFixedThreadPool(THREAD_NUMBERS);
|
|
|
|
@ -71,12 +83,37 @@ public class CustomerCountJob {
|
|
|
|
|
|
|
|
|
|
CountDTOMessageEventProducer producer = new CountDTOMessageEventProducer(ringBuffer, privilageCpUserDOMapper);
|
|
|
|
|
|
|
|
|
|
List<String> cpUserIds;
|
|
|
|
|
List<String> cpUserIds = new ArrayList<>();
|
|
|
|
|
if (isAll){
|
|
|
|
|
WxCpService wxCpService = WxCpConfiguration.getCpService(APPLICATIONID);
|
|
|
|
|
WxCpExternalContactService externalContactService = wxCpService.getExternalContactService();
|
|
|
|
|
//查询企业微信已配置联系我的用户
|
|
|
|
|
cpUserIds = externalContactService.listFollowUser();
|
|
|
|
|
File file = new File("/Users/legna_yet/Desktop/账号.xls");
|
|
|
|
|
if (file != null) {
|
|
|
|
|
//获取文件名
|
|
|
|
|
String fileName = file.getAbsolutePath();
|
|
|
|
|
InputStream fileInput = new FileInputStream(file);
|
|
|
|
|
// 根据后缀创建EXCEL对象
|
|
|
|
|
Workbook book;
|
|
|
|
|
if (ExcelUtils.isExcel2007(fileName)) {
|
|
|
|
|
book = new XSSFWorkbook(fileInput);
|
|
|
|
|
} else {
|
|
|
|
|
book = new HSSFWorkbook(fileInput);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 得到第一个sheet
|
|
|
|
|
Sheet sheet = book.getSheetAt(0);
|
|
|
|
|
// 得到Excel的行数
|
|
|
|
|
int totalRows = sheet.getPhysicalNumberOfRows();
|
|
|
|
|
|
|
|
|
|
// 循环Excel行数,获取数据
|
|
|
|
|
for (int r = 1; r < totalRows; r++) {
|
|
|
|
|
Row dataRow = sheet.getRow(r);
|
|
|
|
|
if (dataRow == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
dataRow.getCell(0).setCellType(CellType.STRING);
|
|
|
|
|
String cpUserId = dataRow.getCell(0).getStringCellValue();
|
|
|
|
|
cpUserIds.add(cpUserId);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
List<PrivilageCpUserStoreDO> privilageCpUserStoreDOS = privilageCpUserStoreDOMapper.selectList(null);
|
|
|
|
|
List<Long> ids = privilageCpUserStoreDOS.stream().map(privilageCpUserStoreDO -> privilageCpUserStoreDO.getCpUserId()).collect(Collectors.toList());
|
|
|
|
|