|
|
@ -23,6 +23,7 @@ import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
import com.kiisoo.ic.generalize.service.RetailCompanyService;
|
|
|
|
import com.kiisoo.ic.store.bean.BsdShareCodeResponse;
|
|
|
|
import com.kiisoo.ic.store.bean.BsdShareCodeResponse;
|
|
|
|
|
|
|
|
import com.kiisoo.ic.store.bean.CpUserExcelDTO;
|
|
|
|
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.PoiStoreStaff;
|
|
|
@ -33,10 +34,13 @@ import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
|
|
|
|
import com.kiisoo.ic.utils.ZipUtils;
|
|
|
|
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.HSSFCellStyle;
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
import org.apache.poi.ss.usermodel.Row;
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
import org.apache.poi.ss.usermodel.Sheet;
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
import org.apache.poi.ss.usermodel.Workbook;
|
|
|
|
|
|
|
|
import org.apache.poi.ss.util.CellRangeAddress;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
@ -368,6 +372,130 @@ public class StoreEmployeeService {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 批量下载店铺二维码
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param response
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void exportStoreExcel(HttpServletResponse response) throws Exception {
|
|
|
|
|
|
|
|
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
List<CpUserExcelDTO> results = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//查询大区
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> regionWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
regionWrapper.eq("status", 1).eq("type", 2).eq("level", 1);
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> regions = retailCompanyMapper.selectList(regionWrapper);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(regions)){
|
|
|
|
|
|
|
|
for (PrivilageOrganizational region:regions){
|
|
|
|
|
|
|
|
if (region == null || region.getId() == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询所有公司
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> queryWrapper = new QueryWrapper<>();
|
|
|
|
|
|
|
|
queryWrapper.eq("status", 1).eq("type", 2).eq("level", 2).eq("parent_id",region.getId());
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> privilageOrganizationals = retailCompanyMapper.selectList(queryWrapper);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(privilageOrganizationals)) {
|
|
|
|
|
|
|
|
//遍历零售公司
|
|
|
|
|
|
|
|
for (PrivilageOrganizational privilageOrganizational : privilageOrganizationals) {
|
|
|
|
|
|
|
|
if (privilageOrganizational == null || privilageOrganizational.getId() == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
//查询客户
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageOrganizational> customerWrap = new QueryWrapper<>();
|
|
|
|
|
|
|
|
customerWrap.eq("status", 1).eq("type", 2).eq("level", 3).eq("parent_id", privilageOrganizational.getId());
|
|
|
|
|
|
|
|
List<PrivilageOrganizational> customerList = retailCompanyMapper.selectList(customerWrap);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(customerList)) {
|
|
|
|
|
|
|
|
List<Long> customerIds = customerList.stream().map(i -> i.getId()).collect(Collectors.toList());
|
|
|
|
|
|
|
|
//查询店铺
|
|
|
|
|
|
|
|
List<PoiStore> poiStores = poiStoreDOMapper.selectShopByCustomerIds(customerIds);
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(poiStores)) {
|
|
|
|
|
|
|
|
//遍历店铺查询门店码url
|
|
|
|
|
|
|
|
for (PoiStore poiStore : poiStores) {
|
|
|
|
|
|
|
|
String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(poiStore.getId());
|
|
|
|
|
|
|
|
if (StringUtils.isBlank(cpUserId)) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
QueryWrapper<PrivilageCpUserDO> userQw = new QueryWrapper<>();
|
|
|
|
|
|
|
|
userQw.eq("cp_user_id",cpUserId).last("limit 1");
|
|
|
|
|
|
|
|
PrivilageCpUserDO privilageCpUserDO = privilageCpUserDOMapper.selectOne(userQw);
|
|
|
|
|
|
|
|
if (privilageCpUserDO == null) {
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
CpUserExcelDTO excelDTO = new CpUserExcelDTO(region.getName(),privilageOrganizational.getName(),
|
|
|
|
|
|
|
|
privilageOrganizational.getCode(),poiStore.getName(),poiStore.getCode(),
|
|
|
|
|
|
|
|
privilageCpUserDO.getCpUserId(),privilageCpUserDO.getName(),privilageCpUserDO.getAlias());
|
|
|
|
|
|
|
|
results.add(excelDTO);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (CollectionUtils.isNotEmpty(results)){
|
|
|
|
|
|
|
|
createStoreUserExcel(results,response);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void createStoreUserExcel(List<CpUserExcelDTO> results,HttpServletResponse response) throws IOException {
|
|
|
|
|
|
|
|
String[] headNames = new String[]{"序号","大区名","零售公司","零售公司编号","店铺名","店铺编号"," 企业微信号","企业微信号名称","企业微信号别名"};
|
|
|
|
|
|
|
|
HSSFWorkbook ws = new HSSFWorkbook();
|
|
|
|
|
|
|
|
Sheet hssfSheet = ws.createSheet("门店号信息");
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
HSSFCellStyle cellStyle = ws.createCellStyle();
|
|
|
|
|
|
|
|
cellStyle.setWrapText(true);//设置自动换行
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int isAdd = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//设置列名
|
|
|
|
|
|
|
|
if (null != headNames && headNames.length > 0) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Row row = hssfSheet.createRow(isAdd++);
|
|
|
|
|
|
|
|
for (int i = 0; i < headNames.length; i++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String name = headNames[i];
|
|
|
|
|
|
|
|
Cell cell = row.createCell(i);
|
|
|
|
|
|
|
|
cell.setCellValue(name);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
isAdd++;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < results.size(); i++) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//创造行
|
|
|
|
|
|
|
|
Row row = hssfSheet.createRow(isAdd++);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
CpUserExcelDTO cpUserExcelDTO = results.get(i);
|
|
|
|
|
|
|
|
Cell orderCell = row.createCell(0);
|
|
|
|
|
|
|
|
orderCell.setCellValue(i + 1 +"");
|
|
|
|
|
|
|
|
Cell reginCell = row.createCell(1);
|
|
|
|
|
|
|
|
reginCell.setCellValue(cpUserExcelDTO.getRegionName());
|
|
|
|
|
|
|
|
Cell companyNameCell = row.createCell(2);
|
|
|
|
|
|
|
|
companyNameCell.setCellValue(cpUserExcelDTO.getCompanyName());
|
|
|
|
|
|
|
|
Cell companyCodeCell = row.createCell(3);
|
|
|
|
|
|
|
|
companyCodeCell.setCellValue(cpUserExcelDTO.getCompanyCode());
|
|
|
|
|
|
|
|
Cell storeNameCell = row.createCell(4);
|
|
|
|
|
|
|
|
storeNameCell.setCellValue(cpUserExcelDTO.getStoreName());
|
|
|
|
|
|
|
|
Cell storeCodeCell = row.createCell(5);
|
|
|
|
|
|
|
|
storeCodeCell.setCellValue(cpUserExcelDTO.getStoreCode());
|
|
|
|
|
|
|
|
Cell cpUserIdCell = row.createCell(6);
|
|
|
|
|
|
|
|
cpUserIdCell.setCellValue(cpUserExcelDTO.getCpUserId());
|
|
|
|
|
|
|
|
Cell nameCell = row.createCell(7);
|
|
|
|
|
|
|
|
nameCell.setCellValue(cpUserExcelDTO.getName());
|
|
|
|
|
|
|
|
Cell aliasCell = row.createCell(8);
|
|
|
|
|
|
|
|
aliasCell.setCellValue(cpUserExcelDTO.getAlias());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
OutputStream output = response.getOutputStream();
|
|
|
|
|
|
|
|
response.reset();
|
|
|
|
|
|
|
|
response.setHeader("Content-disposition", "attachment; filename=store.xls");
|
|
|
|
|
|
|
|
response.setContentType("application/msexcel");
|
|
|
|
|
|
|
|
ws.write(output);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
* 批量下载店铺导购吗
|
|
|
|
*
|
|
|
|
*
|
|
|
|