门店号管理

dev_0531
LegnaYet 6 years ago
parent dc46aee7fb
commit ddece597d1

@ -88,7 +88,9 @@ public class CustomerBehaviorJob {
disruptor.shutdown(); disruptor.shutdown();
sysTaskDO.setStatus(TASK_STATUS_FINISHED); if (sysTaskDO !=null){
sysTaskDOMapper.updateById(sysTaskDO); sysTaskDO.setStatus(TASK_STATUS_FINISHED);
sysTaskDOMapper.updateById(sysTaskDO);
}
} }
} }

@ -19,7 +19,7 @@ public class SyncBehaviorJobController {
public void getCustomerInfo(@RequestParam("startDate") String startDate, @RequestParam("endDate")String endDate){ public void getCustomerInfo(@RequestParam("startDate") String startDate, @RequestParam("endDate")String endDate){
try { try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
customerBehaviorJob.handle(sdf.parse(startDate),sdf.parse(endDate)); customerBehaviorJob.handle(sdf.parse(startDate),sdf.parse(endDate),null);
}catch (Exception e){ }catch (Exception e){
log.error("",e); log.error("",e);
} }

@ -94,8 +94,9 @@ public class CustomerCountJob {
disruptor.shutdown(); disruptor.shutdown();
sysTaskDO.setStatus(TASK_STATUS_FINISHED); if (sysTaskDO!=null){
sysTaskDOMapper.updateById(sysTaskDO); sysTaskDO.setStatus(TASK_STATUS_FINISHED);
sysTaskDOMapper.updateById(sysTaskDO);
}
} }
} }

@ -17,7 +17,7 @@ public class SyncCountJobController {
@GetMapping("/sync/count") @GetMapping("/sync/count")
public void getCustomerInfo(@RequestParam("isAll")Boolean isAll){ public void getCustomerInfo(@RequestParam("isAll")Boolean isAll){
try { try {
customerDataJob.handle(isAll); customerDataJob.handle(isAll,null);
}catch (Exception e){ }catch (Exception e){
log.error("",e); log.error("",e);
} }

@ -15,6 +15,7 @@ import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseBody;
import javax.servlet.http.HttpServletResponse;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -127,4 +128,30 @@ public class StorePromotionDataController extends BaseController {
} }
} }
/**
* 广
* @param userId
* @param roleCode
* @param startDate
* @param endDate
* @return
*/
@RequestMapping(value = "/behavior/excel",method = RequestMethod.POST)
@ResponseBody
public void listUserBehaviorData(@RequestParam("userId") Long userId,
@RequestParam(value = "startDate",required = false) String startDate,
@RequestParam(value = "endDate",required = false) String endDate,
@RequestParam(value = "companyId",required = false) Long companyId,
@RequestParam(value = "shopId",required = false) Long shopId,
HttpServletResponse response){
try {
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
storePromotionDataService.downloadUserBehaviorDataExcel(userId,companyId, shopId,
StringUtils.isBlank(startDate) ? null : sdf.parse(startDate),
StringUtils.isBlank(endDate) ? null : sdf.parse(endDate),response);
}catch (Exception e){
log.error("查询门店推广数据列表",e);
}
}
} }

@ -1,20 +1,15 @@
package com.kiisoo.ic.store.service; package com.kiisoo.ic.store.service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import com.kiisoo.aegis.common.faces.util.HttpUtil;
import com.kiisoo.ic.common.utils.MD5FileUtil; import com.kiisoo.ic.common.utils.MD5FileUtil;
import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil; import com.kiisoo.ic.common.utils.httpClientUtil.HttpClientUtil;
import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult; import com.kiisoo.ic.common.utils.httpClientUtil.HttpResult;
import com.kiisoo.ic.config.WxCpConfiguration; import com.kiisoo.ic.config.WxCpConfiguration;
import com.kiisoo.ic.customer.bean.OpCustomerDTO;
import com.kiisoo.ic.customer.service.CustomerViewService; import com.kiisoo.ic.customer.service.CustomerViewService;
import com.kiisoo.ic.domain.mapper.PrivilageDomainEntityDOMapper; import com.kiisoo.ic.domain.mapper.PrivilageDomainEntityDOMapper;
import com.kiisoo.ic.domain.service.PrivilageDomainService; import com.kiisoo.ic.domain.service.PrivilageDomainService;
import com.kiisoo.ic.employee.entity.PrivilageCpUserDO;
import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper; import com.kiisoo.ic.employee.mapper.PrivilageCpUserDOMapper;
import com.kiisoo.ic.generalize.entity.PoiCustomerContactDataStat; import com.kiisoo.ic.generalize.entity.PoiCustomerContactDataStat;
import com.kiisoo.ic.generalize.entity.PrivilageOrganizational; import com.kiisoo.ic.generalize.entity.PrivilageOrganizational;
@ -26,18 +21,23 @@ import com.kiisoo.ic.store.entity.*;
import com.kiisoo.ic.store.mapper.PoiStoreDOMapper; import com.kiisoo.ic.store.mapper.PoiStoreDOMapper;
import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper; import com.kiisoo.ic.store.mapper.PrivilageCpUserStoreDOMapper;
import com.kiisoo.ic.store.mapper.StorePromotionDataDOMapper; import com.kiisoo.ic.store.mapper.StorePromotionDataDOMapper;
import com.kiisoo.ic.utils.DateUtils;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import me.chanjar.weixin.common.error.WxErrorException; import me.chanjar.weixin.common.error.WxErrorException;
import me.chanjar.weixin.cp.api.WxCpExternalContactService;
import me.chanjar.weixin.cp.api.WxCpService; import me.chanjar.weixin.cp.api.WxCpService;
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.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.text.ParseException; import java.text.ParseException;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.*; import java.util.*;
@ -333,6 +333,96 @@ public class StorePromotionDataService {
return new PageInfo<>(results); return new PageInfo<>(results);
} }
public void downloadUserBehaviorDataExcel(Long userId, Long companyId, Long shopId, Date startDate, Date endDate, HttpServletResponse response) throws IOException {
Set<Long> shopIds = new HashSet<>();
if (shopId != null) {
//如果有店铺则查店铺
shopIds.add(shopId);
} else if (companyId != null) {
//如果有公司则查公司店铺
Set<Long> sp = customerViewService.getCompanyShop(companyId, userId);
shopIds.addAll(sp);
} else {
//查询用户权限店铺
shopIds = new HashSet<>(privilageDomainService.listUserDatePermission(userId));
}
List<PoiCustomerContactDataStat> results = poiCustomerContactDataStatMapper.selectSumDataByShopIds(shopIds,startDate,endDate);
if (CollectionUtils.isNotEmpty(results)){
results.forEach(result -> {
Long storeId = result.getStoreId();
PoiStore poiStore = poiStoreDOMapper.selectById(storeId);
if (poiStore == null){
return;
}
result.setStoreName(poiStore.getName());
result.setStoreCode(poiStore.getCode());
result.setAddress(poiStore.getAddress());
//客户orgId
Long customerId = privilageDomainEntityDOMapper.selectDomainIdByShopEntity(storeId);
if (customerId != null){
PrivilageOrganizational customer = retailCompanyMapper.selectById(customerId);
PrivilageOrganizational company = retailCompanyMapper.selectById(customer.getParentId());
result.setCompanyName(company.getName());
}
});
}
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++);
PoiCustomerContactDataStat poiCustomerContactDataStat = results.get(i);
Cell orderCell = row.createCell(0);
orderCell.setCellValue(i + 1 +"");
Cell storeCell = row.createCell(1);
storeCell.setCellValue(poiCustomerContactDataStat.getStoreName());
Cell storeCodeCell = row.createCell(2);
storeCodeCell.setCellValue(poiCustomerContactDataStat.getStoreCode());
Cell companyNameCell = row.createCell(3);
companyNameCell.setCellValue(poiCustomerContactDataStat.getCompanyName());
Cell newContactCntCell = row.createCell(4);
newContactCntCell.setCellValue(poiCustomerContactDataStat.getNewContactCnt());
Cell chatCntCell = row.createCell(5);
chatCntCell.setCellValue(poiCustomerContactDataStat.getChatCnt());
Cell messageCntCell = row.createCell(6);
messageCntCell.setCellValue(poiCustomerContactDataStat.getMessageCnt());
Cell replyPercentage = row.createCell(7);
replyPercentage.setCellValue(poiCustomerContactDataStat.getReplyPercentage());
Cell avgReplyTime = row.createCell(8);
avgReplyTime.setCellValue(poiCustomerContactDataStat.getAvgReplyTime());
Cell negativeFeedbackCnt = row.createCell(9);
negativeFeedbackCnt.setCellValue(poiCustomerContactDataStat.getNegativeFeedbackCnt());
}
OutputStream output = response.getOutputStream();
response.setHeader("Content-disposition", "attachment; filename=store.xls");
response.setContentType("application/vnd.ms-excel");
ws.write(output);
ws.close();
}
/** /**
* *

Loading…
Cancel
Save