大屏接口

dev_0531
yechenhao 5 years ago
parent e82f942335
commit 8479db0cb6

@ -0,0 +1,16 @@
package com.kiisoo.ic.store.bean;
import lombok.Data;
@Data
public class CustomerDistinctDTO {
private String companyCode;
private String companyName;
private Long storeId;
private Long customerId;
private String storeName;
private String storeCode;
private String customerName;
private String customerUserId;
private Integer count;
}

@ -98,6 +98,20 @@ public class StorePromotionDataController extends BaseController {
}
}
/**
* 广
* @param response
* @return
*/
@RequestMapping(value = "distinct/customer/excel",method = RequestMethod.POST)
public void distinctCustomer(HttpServletResponse response){
try {
storePromotionDataService.distinctCustomer(response);
}catch (Exception e){
log.error("查询门店推广数据列表",e);
}
}
/**
* 广
* @param userId

@ -8,6 +8,7 @@ import org.springframework.stereotype.Repository;
import java.util.Date;
import java.util.List;
import java.util.Map;
/**
@ -206,4 +207,6 @@ public interface StorePromotionDataDOMapper {
* @return
*/
Date selectLatestUpdateTime(@Param("storeId") Long storeId);
List<Map<String, Object>> selectDistinctCustomer();
}

@ -8,7 +8,10 @@ import com.kiisoo.ic.common.utils.MD5FileUtil;
import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult;
import com.kiisoo.ic.config.WxCpConfiguration;
import com.kiisoo.ic.customer.entity.OpCustomer;
import com.kiisoo.ic.customer.entity.OpSellerCustomerRelation;
import com.kiisoo.ic.customer.mapper.OpCustomerDOMapper;
import com.kiisoo.ic.customer.mapper.OpSellerCustomerRelationDOMapper;
import com.kiisoo.ic.customer.service.CustomerViewService;
import com.kiisoo.ic.domain.mapper.PrivilageDomainEntityDOMapper;
import com.kiisoo.ic.domain.service.PrivilageDomainService;
@ -19,6 +22,7 @@ import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
import com.kiisoo.ic.generalize.mapper.PoiCustomerContactDataStatMapper;
import com.kiisoo.ic.generalize.mapper.RetailCompanyMapper;
import com.kiisoo.ic.store.bean.BsdShareCodeResponse;
import com.kiisoo.ic.store.bean.CustomerDistinctDTO;
import com.kiisoo.ic.store.constant.Constants;
import com.kiisoo.ic.store.entity.*;
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
@ -41,6 +45,7 @@ import org.springframework.stereotype.Service;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.io.Serializable;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.*;
@ -67,6 +72,18 @@ public class StorePromotionDataService {
@Autowired
private StorePromotionDataDOMapper storePromotionDataDOMapper;
/**
* mapper
*/
@Autowired
private OpSellerCustomerRelationDOMapper opSellerCustomerRelationDOMapper;
/**
* mapper
*/
@Autowired
private OpCustomerDOMapper opCustomerDOMapper;
/**
* mapper
*/
@ -591,4 +608,89 @@ public class StorePromotionDataService {
}
return storePromotionDataDO;
}
public void distinctCustomer(HttpServletResponse response) throws IOException {
List<Map<String,Object>> customerIds = storePromotionDataDOMapper.selectDistinctCustomer();
List<CustomerDistinctDTO> customerDistinctDTOS = new ArrayList<>();
customerIds.forEach(customerId ->{
QueryWrapper<OpSellerCustomerRelation> relationQw = new QueryWrapper<>();
relationQw.eq("customer_id",customerId.get("customerId")).ne("type",3);
List<OpSellerCustomerRelation> opSellerCustomerRelations = opSellerCustomerRelationDOMapper.selectList(relationQw);
OpCustomer customer = opCustomerDOMapper.selectById((Serializable) customerId.get("customerId"));
opSellerCustomerRelations.forEach(opSellerCustomerRelation -> {
CustomerDistinctDTO customerDistinctDTO = new CustomerDistinctDTO();
customerDistinctDTO.setCount((Integer) customerId.get("count"));
PoiStore poiStore = poiStoreDOMapper.selectById(opSellerCustomerRelation.getStoreId());
customerDistinctDTO.setStoreName(poiStore.getName());
customerDistinctDTO.setStoreCode(poiStore.getCode());
Long orgCustomerId = privilageDomainEntityDOMapper.selectDomainIdByShopEntity(poiStore.getId());
if (orgCustomerId != null) {
PrivilageOrganizational orgCustomer = retailCompanyMapper.selectById(orgCustomerId);
PrivilageOrganizational company = retailCompanyMapper.selectById(orgCustomer.getParentId());
customerDistinctDTO.setCompanyName(company.getName());
customerDistinctDTO.setCompanyCode(company.getCode());
}
customerDistinctDTO.setStoreId(opSellerCustomerRelation.getStoreId());
customerDistinctDTO.setCustomerId(opSellerCustomerRelation.getCustomerId());
customerDistinctDTO.setCustomerName(customer.getName());
customerDistinctDTO.setCustomerUserId(customer.getExternalUserid());
customerDistinctDTOS.add(customerDistinctDTO);
});
});
customerDistinctDTOS.sort(new Comparator<CustomerDistinctDTO>() {
@Override
public int compare(CustomerDistinctDTO o1, CustomerDistinctDTO o2) {
return o1.getStoreId().compareTo(o2.getStoreId());
}
});
String[] headNames = new String[]{"零售公司编号", "零售公司","店铺名", "店铺编号", "客户名称", "客户id", "添加店铺总数"};
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 < customerDistinctDTOS.size(); i++) {
//创造行
Row row = hssfSheet.createRow(isAdd++);
CustomerDistinctDTO customerDistinctDTO = customerDistinctDTOS.get(i);
Cell cpUserIdCell = row.createCell(0);
cpUserIdCell.setCellValue(customerDistinctDTO.getCompanyCode());
Cell storeCodeCell = row.createCell(1);
storeCodeCell.setCellValue(customerDistinctDTO.getCompanyName());
Cell reginCell = row.createCell(2);
reginCell.setCellValue(customerDistinctDTO.getStoreName());
Cell companyNameCell = row.createCell(3);
companyNameCell.setCellValue(customerDistinctDTO.getStoreCode());
Cell companyCodeCell = row.createCell(4);
companyCodeCell.setCellValue(customerDistinctDTO.getCustomerName());
Cell storeNameCell = row.createCell(5);
storeNameCell.setCellValue(customerDistinctDTO.getCustomerUserId());;
Cell nameCell = row.createCell(6);
nameCell.setCellValue(customerDistinctDTO.getCount());
}
OutputStream output = response.getOutputStream();
response.setHeader("Content-disposition", "attachment; filename=store.xls");
response.setContentType("application/vnd.ms-excel");
ws.write(output);
ws.close();
}
}

@ -409,6 +409,16 @@
<select id="selectLatestUpdateTime" resultType="java.util.Date">
select max(update_time) from op_seller_customer_relation where store_id = #{storeId}
</select>
<select id="selectDistinctCustomer" resultType="Map">
SELECT
customer_id as customerId,count( store_id ) as count
FROM
op_seller_customer_relation
GROUP BY
customer_id
HAVING
count( store_id ) > 1;
</select>
</mapper>

Loading…
Cancel
Save