|
|
|
@ -37,10 +37,16 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
|
|
|
|
import javax.imageio.ImageIO;
|
|
|
|
|
import javax.servlet.ServletOutputStream;
|
|
|
|
|
import javax.servlet.http.HttpServletResponse;
|
|
|
|
|
import java.awt.*;
|
|
|
|
|
import java.awt.image.BufferedImage;
|
|
|
|
|
import java.io.*;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.zip.ZipEntry;
|
|
|
|
|
import java.util.zip.ZipOutputStream;
|
|
|
|
|
|
|
|
|
|
import static com.kiisoo.ic.employee.constant.Constants.ADD_CP_CODE_BINDED;
|
|
|
|
@ -147,31 +153,77 @@ public class StoreEmployeeService {
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String fileUrl = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
file.mkdir();
|
|
|
|
|
|
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
// 生成的ZIP文件名为Demo.zip
|
|
|
|
|
String strZipName = "store_qrCode.zip";
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
|
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(strZipName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
|
continue;
|
|
|
|
|
}
|
|
|
|
|
String fileUrl = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
|
file.mkdir();
|
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
|
complayFile.mkdir();
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(privilageOrganizational.getId());
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)){
|
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
|
// poiStoreDOMapper.
|
|
|
|
|
String url = poiStoreDOMapper.selectStoreQrCode(poiStore.getId());
|
|
|
|
|
//下载图片
|
|
|
|
|
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(complayFile.getPath() +"/" +poiStore.getCode() + ".png"));
|
|
|
|
|
|
|
|
|
|
ImageIO.write(tag, "PNG", image);
|
|
|
|
|
|
|
|
|
|
in.close();
|
|
|
|
|
image.close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
if (files !=null && files.length>0){
|
|
|
|
|
for (int i =0;i<files.length;i++){
|
|
|
|
|
File companyFile = files[i];
|
|
|
|
|
out.putNextEntry(new ZipEntry(companyFile.getName()));
|
|
|
|
|
|
|
|
|
|
FileInputStream fileInputStream = new FileInputStream(companyFile);
|
|
|
|
|
|
|
|
|
|
int len;
|
|
|
|
|
// 读入需要下载的文件的内容,打包到zip文件
|
|
|
|
|
while ((len = fileInputStream.read(buffer)) > 0) {
|
|
|
|
|
out.write(buffer, 0, len);
|
|
|
|
|
}
|
|
|
|
|
fileInputStream.close();
|
|
|
|
|
out.closeEntry();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
out.flush();
|
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
|
byte[] bufferNew = new byte[1024];
|
|
|
|
|
File zipFile = new File(strZipName);
|
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
|
int lenNew;
|
|
|
|
|
while ((lenNew = inStream.read(bufferNew)) > 0) {
|
|
|
|
|
outputStream.write(bufferNew, 0, lenNew);
|
|
|
|
|
}
|
|
|
|
|
file.delete();
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|