From 1b2c4dda74f5c5ac47dcf05618252ac8e0e327b8 Mon Sep 17 00:00:00 2001 From: kevin jiang Date: Sat, 30 May 2020 14:28:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E9=A6=96=E9=A1=B5=E6=80=BB?= =?UTF-8?q?=E6=95=B0=EF=BC=8C=E8=AF=BB=E5=8F=96=E9=80=9A=E8=AE=AF=E5=BD=95?= =?UTF-8?q?=E8=B4=A6=E5=8F=B7=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../kiisoo/ic/job/count/CustomerCountJob.java | 70 +++++++++++-------- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/src/main/java/com/kiisoo/ic/job/count/CustomerCountJob.java b/src/main/java/com/kiisoo/ic/job/count/CustomerCountJob.java index 00d20a6..ab64003 100644 --- a/src/main/java/com/kiisoo/ic/job/count/CustomerCountJob.java +++ b/src/main/java/com/kiisoo/ic/job/count/CustomerCountJob.java @@ -10,6 +10,7 @@ import com.kiisoo.ic.store.entity.PrivilageCpUserStoreDO; import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper; import com.kiisoo.ic.system.entity.SysTaskDO; import com.kiisoo.ic.system.mapper.SysTaskDOMapper; +import com.kiisoo.ic.wx.service.QWMailListManageService; import com.lmax.disruptor.BlockingWaitStrategy; import com.lmax.disruptor.RingBuffer; import com.lmax.disruptor.dsl.Disruptor; @@ -18,6 +19,7 @@ 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 me.chanjar.weixin.cp.bean.WxCpUser; import org.apache.commons.lang3.StringUtils; import org.apache.poi.hssf.usermodel.HSSFWorkbook; import org.apache.poi.ss.usermodel.CellType; @@ -62,6 +64,10 @@ public class CustomerCountJob { private SysTaskDOMapper sysTaskDOMapper; + @Autowired + private QWMailListManageService qwMailListManageService; + + public void handle(Boolean isAll,SysTaskDO sysTaskDO) throws WxErrorException, IOException { //创建线程池 @@ -85,34 +91,42 @@ public class CustomerCountJob { List cpUserIds = new ArrayList<>(); if (isAll){ - File file = new File("/root/account.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); - } +// File file = new File("/root/account.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); +// } +// } + + List wxCpUsers = qwMailListManageService.syncUser(); + System.out.println(wxCpUsers.size()); + for (int i = 0; i < wxCpUsers.size(); i++) { + WxCpUser item = wxCpUsers.get(i); + String userId = item.getUserId(); + cpUserIds.add(userId); } }else { List privilageCpUserStoreDOS = privilageCpUserStoreDOMapper.selectList(null);