|
|
|
@ -359,8 +359,7 @@ public class StoreEmployeeService {
|
|
|
|
|
/**
|
|
|
|
|
* 批量下载店铺二维码
|
|
|
|
|
*/
|
|
|
|
|
@Scheduled(cron = "0 0 0 * * ?")
|
|
|
|
|
public void downloadStoreUserCodeFromBSD() throws Exception {
|
|
|
|
|
public void downloadStoreUserCodeFromBSD(HttpServletResponse response) throws Exception {
|
|
|
|
|
File zipFile = new File("store_qrCode.zip");
|
|
|
|
|
if (zipFile.exists()) {
|
|
|
|
|
zipFile.delete();
|
|
|
|
@ -449,8 +448,20 @@ public class StoreEmployeeService {
|
|
|
|
|
ZipUtils.toZip(file.getPath(), out, true);
|
|
|
|
|
|
|
|
|
|
//删除文件,清理空间
|
|
|
|
|
file.delete();
|
|
|
|
|
deleteDir(file.getAbsolutePath());
|
|
|
|
|
System.out.println("门店码生成成功");
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
int lenNew;
|
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
}
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
outputStream.close();
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -587,95 +598,11 @@ public class StoreEmployeeService {
|
|
|
|
|
ws.close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
|
*
|
|
|
|
|
* @param response
|
|
|
|
|
*/
|
|
|
|
|
public void downloadStoreStaffCode(HttpServletResponse response) throws IOException {
|
|
|
|
|
//查询所有公司
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(null);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)) {
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
String fileUrl = "导购码-" + UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
file.mkdir();
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
|
String strZipName = "store_qrCode_" + fileUrl + ".zip";
|
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational : privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File complayFile = new File(file.getPath() + "/" + privilageOrganizational.getName());
|
|
|
|
|
complayFile.mkdir();
|
|
|
|
|
//查询店铺
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(privilageOrganizational.getId());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)) {
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
for (PoiStore poiStore : poiStores) {
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
|
File storeFile = new File(complayFile.getPath() + "/" + poiStore.getName());
|
|
|
|
|
storeFile.mkdir();
|
|
|
|
|
|
|
|
|
|
QueryWrapper<PoiStoreStaff> staffQr = new QueryWrapper();
|
|
|
|
|
staffQr.eq(DATABASE_STORE_ID_KEY, poiStore.getId());
|
|
|
|
|
staffQr.eq(DATABASE_TYPE_KEY, TYPE_STAFF_SELLER);
|
|
|
|
|
List<PoiStoreStaff> poiStoreStaffs = poiStoreStaffDOMapper.selectList(staffQr);
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStoreStaffs)) {
|
|
|
|
|
for (PoiStoreStaff poiStoreStaff : poiStoreStaffs) {
|
|
|
|
|
String url = poiStoreStaff.getEpWechatQrCode();
|
|
|
|
|
if (StringUtils.isBlank(url)) {
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
//下载图片
|
|
|
|
|
BufferedInputStream in = new BufferedInputStream(employeeService.getInputStream(url));
|
|
|
|
|
//字节流转图片对象
|
|
|
|
|
Image bi = ImageIO.read(in);
|
|
|
|
|
//构建图片流
|
|
|
|
|
BufferedImage tag = new BufferedImage(300, 300, BufferedImage.TYPE_INT_RGB);
|
|
|
|
|
//绘制改变尺寸后的图
|
|
|
|
|
tag.getGraphics().drawImage(bi, 0, 0, 300, 300, null);
|
|
|
|
|
//输出流
|
|
|
|
|
BufferedOutputStream image = new BufferedOutputStream(new FileOutputStream(storeFile.getPath() + "/" + poiStoreStaff.getStaffCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
image.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
ZipUtils.toZip(file.getPath(), out, true);
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
File zipFile = new File(strZipName);
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
int lenNew;
|
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
}
|
|
|
|
|
//删除文件,清理空间
|
|
|
|
|
file.delete();
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
|
*/
|
|
|
|
|
@Scheduled(cron = "0 0 1 * * ?")
|
|
|
|
|
public void downloadStoreStaffCodeFromBSD() throws Exception {
|
|
|
|
|
public void downloadStoreStaffCodeFromBSD(HttpServletResponse response) throws Exception {
|
|
|
|
|
File zipFile = new File("seller_qrCode.zip");
|
|
|
|
|
if (zipFile.exists()) {
|
|
|
|
|
zipFile.delete();
|
|
|
|
@ -774,8 +701,47 @@ public class StoreEmployeeService {
|
|
|
|
|
ZipUtils.toZip(file.getPath(), out, true);
|
|
|
|
|
|
|
|
|
|
//删除文件,清理空间
|
|
|
|
|
file.delete();
|
|
|
|
|
deleteDir(file.getAbsolutePath());
|
|
|
|
|
System.out.println("导购码生成成功");
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
int lenNew;
|
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
}
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
outputStream.close();
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 迭代删除文件夹
|
|
|
|
|
* @param dirPath 文件夹路径
|
|
|
|
|
*/
|
|
|
|
|
public static void deleteDir(String dirPath)
|
|
|
|
|
{
|
|
|
|
|
File file = new File(dirPath);
|
|
|
|
|
if(file.isFile())
|
|
|
|
|
{
|
|
|
|
|
file.delete();
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
if(files == null)
|
|
|
|
|
{
|
|
|
|
|
file.delete();
|
|
|
|
|
}else
|
|
|
|
|
{
|
|
|
|
|
for (int i = 0; i < files.length; i++)
|
|
|
|
|
{
|
|
|
|
|
deleteDir(files[i].getAbsolutePath());
|
|
|
|
|
}
|
|
|
|
|
file.delete();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -909,31 +875,6 @@ public class StoreEmployeeService {
|
|
|
|
|
results.add(importErrorDTO);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void downloadStoreStaffCodeFile(HttpServletResponse response) throws IOException {
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
File zipFile = new File("seller_qrCode.zip");
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
int lenNew;
|
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
}
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void downloadStoreUserCodeFile(HttpServletResponse response) throws IOException {
|
|
|
|
|
//将文件输入到response
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
File zipFile = new File("store_qrCode.zip");
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
int lenNew;
|
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
}
|
|
|
|
|
outputStream.flush();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 作废波司登分享二维码
|
|
|
|
|