|
|
|
@@ -28,8 +28,11 @@ import javax.servlet.http.HttpServletResponse; |
|
|
|
import java.io.*; |
|
|
|
import java.util.List; |
|
|
|
import java.util.Map; |
|
|
|
import java.util.Optional; |
|
|
|
import java.util.UUID; |
|
|
|
|
|
|
|
import static java.util.stream.Collectors.toList; |
|
|
|
|
|
|
|
@Service |
|
|
|
public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { |
|
|
|
|
|
|
|
@@ -101,7 +104,7 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { |
|
|
|
return PageHelper.startPage(pageNum, pageSize).doSelectPageInfo(() -> wxCUserBasicInfoMapper.findListMap(record)); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
/*@Override |
|
|
|
public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { |
|
|
|
|
|
|
|
|
|
|
|
@@ -221,8 +224,110 @@ public class WxCUserBasicInfoServiceImpl implements WxCUserBasicInfoService { |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
}*/ |
|
|
|
|
|
|
|
public void exportData(HttpServletRequest request, HttpServletResponse response, String tenantId) { |
|
|
|
|
|
|
|
|
|
|
|
WxCUser wxCUser = new WxCUser(); |
|
|
|
wxCUser.setTenantId(tenantId); |
|
|
|
List<WxCUser> userlist = wxCUserMapper.findList(wxCUser); |
|
|
|
|
|
|
|
WxCUserBasicInfo basicInfo = new WxCUserBasicInfo(); |
|
|
|
basicInfo.setTenantId(tenantId); |
|
|
|
List<WxCUserBasicInfo> memberlist = wxCUserBasicInfoMapper.findList(basicInfo); |
|
|
|
|
|
|
|
XSSFWorkbook workbook; |
|
|
|
String filepath = "./uploads/"; |
|
|
|
File savefile = new File(filepath); |
|
|
|
if (!savefile.exists()) { |
|
|
|
savefile.mkdirs(); |
|
|
|
} |
|
|
|
String filename = UUID.randomUUID() + ".xlsx"; |
|
|
|
filepath = filepath + filename; |
|
|
|
try { |
|
|
|
File file = new File(filepath); |
|
|
|
workbook = new XSSFWorkbook(); |
|
|
|
|
|
|
|
XSSFSheet sheetOne = workbook.createSheet("会员"); |
|
|
|
Row row = sheetOne.createRow(0); |
|
|
|
Cell nameCell = row.createCell(0); |
|
|
|
Cell phoneCell = row.createCell(1); |
|
|
|
Cell nickNameCell = row.createCell(2); |
|
|
|
Cell cityCell = row.createCell(3); |
|
|
|
Cell provinceCell = row.createCell(4); |
|
|
|
Cell countryCodeCell = row.createCell(5); |
|
|
|
Cell registerIpCell = row.createCell(6); |
|
|
|
Cell emailCell = row.createCell(7); |
|
|
|
Cell educationCell = row.createCell(8); |
|
|
|
Cell addressCell = row.createCell(9); |
|
|
|
Cell activeTimeCell = row.createCell(10); |
|
|
|
Cell registerTimeCell = row.createCell(11); |
|
|
|
|
|
|
|
nameCell.setCellValue("姓名"); |
|
|
|
phoneCell.setCellValue("手机号"); |
|
|
|
nickNameCell.setCellValue("微信名称"); |
|
|
|
cityCell.setCellValue("城市"); |
|
|
|
provinceCell.setCellValue("省份"); |
|
|
|
countryCodeCell.setCellValue("国家代码"); |
|
|
|
registerIpCell.setCellValue("注册IP"); |
|
|
|
emailCell.setCellValue("邮箱"); |
|
|
|
educationCell.setCellValue("学历"); |
|
|
|
addressCell.setCellValue("地址"); |
|
|
|
activeTimeCell.setCellValue("上次活跃时间"); |
|
|
|
registerTimeCell.setCellValue("注册时间"); |
|
|
|
|
|
|
|
for (int i = 0; i < memberlist.size(); i++) { |
|
|
|
row = sheetOne.createRow(i + 1); |
|
|
|
nameCell = row.createCell(0); |
|
|
|
phoneCell = row.createCell(1); |
|
|
|
nickNameCell = row.createCell(2); |
|
|
|
cityCell = row.createCell(3); |
|
|
|
provinceCell = row.createCell(4); |
|
|
|
countryCodeCell = row.createCell(5); |
|
|
|
registerIpCell = row.createCell(6); |
|
|
|
emailCell = row.createCell(7); |
|
|
|
educationCell = row.createCell(8); |
|
|
|
addressCell = row.createCell(9); |
|
|
|
activeTimeCell = row.createCell(10); |
|
|
|
registerTimeCell = row.createCell(11); |
|
|
|
|
|
|
|
WxCUserBasicInfo wxCUserBasicInfo = memberlist.get(0); |
|
|
|
nameCell.setCellValue(wxCUserBasicInfo.getName()); |
|
|
|
String phone = wxCUserBasicInfo.getPhone(); |
|
|
|
phoneCell.setCellValue(phone); |
|
|
|
emailCell.setCellValue(wxCUserBasicInfo.getEmail()); |
|
|
|
educationCell.setCellValue(wxCUserBasicInfo.getEducation()); |
|
|
|
addressCell.setCellValue(wxCUserBasicInfo.getAddress()); |
|
|
|
Optional<WxCUser> first = userlist.stream().filter(m -> { |
|
|
|
if(m.getPhone() != null){ |
|
|
|
return m.getPhone().equals(phone); |
|
|
|
} |
|
|
|
return false; |
|
|
|
}).findFirst(); |
|
|
|
if(first.isPresent()){ |
|
|
|
WxCUser cUser = first.get(); |
|
|
|
nickNameCell.setCellValue(cUser.getNickName()); |
|
|
|
countryCodeCell.setCellValue(cUser.getCountryCode()); |
|
|
|
cityCell.setCellValue(cUser.getCity()); |
|
|
|
provinceCell.setCellValue(cUser.getProvince()); |
|
|
|
registerIpCell.setCellValue(cUser.getRegisterIp()); |
|
|
|
activeTimeCell.setCellValue(cUser.getUpdateDate()); |
|
|
|
registerTimeCell.setCellValue(cUser.getCreateDate()); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
FileOutputStream fileOut = new FileOutputStream(file); |
|
|
|
workbook.write(fileOut); |
|
|
|
fileOut.close(); |
|
|
|
workbook.close(); |
|
|
|
downFile(filepath, filename, response, request); |
|
|
|
FileUtils.forceDelete(file); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
public void downFile(String filePath,String filename, HttpServletResponse response, |
|
|
|
HttpServletRequest req) throws IOException { |
|
|
|
|