|
|
@ -20,11 +20,13 @@ import com.kiisoo.ic.generalize.entity.PrivilageOrganizationalMember;
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
import com.kiisoo.ic.store.bean.PoiStoreStaffDTO;
|
|
|
|
import com.kiisoo.ic.store.bean.PoiStoreStaffDTO;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStore;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.entity.PoiStoreStaff;
|
|
|
|
import com.kiisoo.ic.store.entity.PrivilageCpUserStoreDO;
|
|
|
|
import com.kiisoo.ic.store.entity.PrivilageCpUserStoreDO;
|
|
|
|
import com.kiisoo.ic.store.entity.StoreUserDTO;
|
|
|
|
import com.kiisoo.ic.store.entity.StoreUserDTO;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PoiStoreStaffDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.utils.ZipUtils;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
@ -86,6 +88,7 @@ public class StoreEmployeeService {
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private RetailCompanyMapper retailCompanyMapper;
|
|
|
|
private RetailCompanyMapper retailCompanyMapper;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 查询门店号
|
|
|
|
* 查询门店号
|
|
|
|
* @param storeId 门店id
|
|
|
|
* @param storeId 门店id
|
|
|
@ -147,32 +150,30 @@ public class StoreEmployeeService {
|
|
|
|
* @param response
|
|
|
|
* @param response
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public void downloadStoreUserCode(HttpServletResponse response) throws IOException {
|
|
|
|
public void downloadStoreUserCode(HttpServletResponse response) throws IOException {
|
|
|
|
Map<String,Object> result = new HashMap<>();
|
|
|
|
//查询所有公司
|
|
|
|
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(null);
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(null);
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)){
|
|
|
|
|
|
|
|
//根文件夹用于存放公司
|
|
|
|
|
|
|
|
String fileUrl = "门店码-"+UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
|
|
|
|
|
|
|
String fileUrl = UUID.randomUUID().toString().replace("-", "");
|
|
|
|
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
File file = new File(fileUrl);
|
|
|
|
file.mkdir();
|
|
|
|
file.mkdir();
|
|
|
|
|
|
|
|
// 生成的ZIP文件名
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
|
|
|
// 生成的ZIP文件名为Demo.zip
|
|
|
|
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
String strZipName = "store_qrCode_"+ fileUrl +".zip";
|
|
|
|
ZipOutputStream out = new ZipOutputStream(new FileOutputStream(strZipName));
|
|
|
|
FileOutputStream out = new FileOutputStream(new File(strZipName));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
for (PrivilageOrganizational privilageOrganizational:privilageOrganizationals) {
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null){
|
|
|
|
continue;
|
|
|
|
continue;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创建零售公司文件夹
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
File complayFile = new File(file.getPath()+"/"+privilageOrganizational.getName());
|
|
|
|
complayFile.mkdir();
|
|
|
|
complayFile.mkdir();
|
|
|
|
|
|
|
|
//查询店铺
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(privilageOrganizational.getId());
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCompany(privilageOrganizational.getId());
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)){
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)){
|
|
|
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
for (PoiStore poiStore:poiStores){
|
|
|
|
String url = poiStoreDOMapper.selectStoreQrCode(poiStore.getId());
|
|
|
|
String url = poiStoreDOMapper.selectStoreQrCode(poiStore.getId());
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
|
if (StringUtils.isBlank(url)){
|
|
|
@ -196,34 +197,102 @@ public class StoreEmployeeService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
File[] files = file.listFiles();
|
|
|
|
|
|
|
|
if (files !=null && files.length>0){
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
for (int i =0;i<files.length;i++){
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
File companyFile = files[i];
|
|
|
|
|
|
|
|
out.putNextEntry(new ZipEntry(companyFile.getName()));
|
|
|
|
//将文件输入到response
|
|
|
|
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
FileInputStream fileInputStream = new FileInputStream(companyFile);
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
|
|
|
|
File zipFile = new File(strZipName);
|
|
|
|
int len;
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
// 读入需要下载的文件的内容,打包到zip文件
|
|
|
|
int lenNew;
|
|
|
|
while ((len = fileInputStream.read(buffer)) > 0) {
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
out.write(buffer, 0, len);
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除文件,清理空间
|
|
|
|
|
|
|
|
file.delete();
|
|
|
|
|
|
|
|
zipFile.delete();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
|
|
|
|
* @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();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
fileInputStream.close();
|
|
|
|
|
|
|
|
out.closeEntry();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
out.flush();
|
|
|
|
|
|
|
|
out.close();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将根文件转换为zip文件
|
|
|
|
|
|
|
|
ZipUtils.toZip(file.getPath(),out,true);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//将文件输入到response
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
ServletOutputStream outputStream = response.getOutputStream();
|
|
|
|
byte[] bufferNew = new byte[1024];
|
|
|
|
byte[] buffer = new byte[1024];
|
|
|
|
File zipFile = new File(strZipName);
|
|
|
|
File zipFile = new File(strZipName);
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
FileInputStream inStream = new FileInputStream(zipFile);
|
|
|
|
int lenNew;
|
|
|
|
int lenNew;
|
|
|
|
while ((lenNew = inStream.read(bufferNew)) > 0) {
|
|
|
|
while ((lenNew = inStream.read(buffer)) > 0) {
|
|
|
|
outputStream.write(bufferNew, 0, lenNew);
|
|
|
|
outputStream.write(buffer, 0, lenNew);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//删除文件,清理空间
|
|
|
|
file.delete();
|
|
|
|
file.delete();
|
|
|
|
zipFile.delete();
|
|
|
|
zipFile.delete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|