请求波司登获取数据·

master
yechenhao 6 years ago
parent 4b18fc60c9
commit 83877d095c

@ -44,12 +44,12 @@ public class WxCpConfiguration {
@PostConstruct @PostConstruct
public void initServices() { public void initServices() {
QueryWrapper<BasicConfigDO> baseParams = new QueryWrapper<>(); QueryWrapper<BasicConfigDO> baseParams = new QueryWrapper<>();
baseParams.eq("code","HT_CP_CORPID"); baseParams.eq("code","CP_CORPID");
BasicConfigDO basicConfigDO = basicConfigDOMapper.selectOne(baseParams); BasicConfigDO basicConfigDO = basicConfigDOMapper.selectOne(baseParams);
QueryWrapper<BasicConfigDO> confParams = new QueryWrapper<>(); QueryWrapper<BasicConfigDO> confParams = new QueryWrapper<>();
confParams.likeRight("code","HT_CP_"); confParams.likeRight("code","CP_");
confParams.ne("code","HT_CP_CORPID"); confParams.ne("code","CP_CORPID");
List<BasicConfigDO> confConfigDO = basicConfigDOMapper.selectList(confParams); List<BasicConfigDO> confConfigDO = basicConfigDOMapper.selectList(confParams);
Map<String,Map<String,String>> confMap = new HashMap<>(); Map<String,Map<String,String>> confMap = new HashMap<>();
if (CollectionUtils.isNotEmpty(confConfigDO)){ if (CollectionUtils.isNotEmpty(confConfigDO)){

@ -0,0 +1,51 @@
package com.kiisoo.ic.store.bean;
import lombok.Data;
@Data
public class CpUserExcelDTO {
/**
*
*/
private String regionName;
/**
*
*/
private String companyName;
/**
*
*/
private String companyCode;
/**
*
*/
private String storeName;
/**
*
*/
private String storeCode;
/**
*
*/
private String cpUserId;
/**
*
*/
private String name;
/**
*
*/
private String alias;
public CpUserExcelDTO(){}
public CpUserExcelDTO(String regionName, String companyName, String companyCode, String storeName, String storeCode, String cpUserId, String name, String alias) {
this.regionName = regionName;
this.companyName = companyName;
this.companyCode = companyCode;
this.storeName = storeName;
this.storeCode = storeCode;
this.cpUserId = cpUserId;
this.name = name;
this.alias = alias;
}
}

@ -93,6 +93,20 @@ public class StoreEmployeeController extends BaseController {
} }
} }
/**
* excel
* @param response
*/
@RequestMapping(value = "download/store/excel/bsd",method = RequestMethod.GET)
@ResponseBody
public void downloadStoreCpUserExcelForBSD(HttpServletResponse response) {
try {
storeEmployeeService.exportStoreExcel(response);
} catch (Exception e) {
log.error("批量下载店铺excel", e);
}
}
/** /**
* *
* @param response * @param response

@ -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);
}
/** /**
* *
* *

@ -25,6 +25,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import static com.kiisoo.ic.store.constant.Constants.BSD_REQ_QRCODE_TYPE_SELLER;
import static com.kiisoo.ic.store.constant.Constants.BSD_REQ_QRCODE_TYPE_STORE; import static com.kiisoo.ic.store.constant.Constants.BSD_REQ_QRCODE_TYPE_STORE;
/** /**
@ -114,7 +115,7 @@ public class WebAppMyController extends BaseController {
if (StringUtils.isBlank(img)){ if (StringUtils.isBlank(img)){
Long storeId = poiStoreStaffs.get(0).getStoreId(); Long storeId = poiStoreStaffs.get(0).getStoreId();
String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(storeId); String cpUserId = privilageCpUserStoreDOMapper.selectCpUserIdByStoreId(storeId);
img = storeEmployeeService.getQrCodeFromBSD(cpUserId,BSD_REQ_QRCODE_TYPE_STORE,"0",poiStoreStaffs.get(0).getStoreCode()); img = storeEmployeeService.getQrCodeFromBSD(cpUserId,BSD_REQ_QRCODE_TYPE_SELLER,poiStoreStaffs.get(0).getStaffCode(),poiStoreStaffs.get(0).getStoreCode());
PoiStoreStaff update = new PoiStoreStaff(); PoiStoreStaff update = new PoiStoreStaff();
update.setId(poiStoreStaffs.get(0).getId()); update.setId(poiStoreStaffs.get(0).getId());
update.setEpWechatQrCode(img); update.setEpWechatQrCode(img);

Loading…
Cancel
Save