Commit 947ec9ae by 徐高华

企微托管

parent 715cfb2f
package com.gic.haoban.manage.web.controller.open;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.EntityUtil;
import com.gic.enterprise.api.service.EnterpriseService;
import com.gic.haoban.manage.api.dto.OpenStaffListDTO;
import com.gic.haoban.manage.api.qdto.OpenStaffPageQDTO;
import com.gic.haoban.manage.api.service.OpenStaffApiService;
import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.web.vo.open.OpenStaffExcelVO;
import com.gic.web.common.download.DownloadHandlerAbstract;
import com.gic.web.common.download.context.Context;
import org.apache.commons.collections.CollectionUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
@Service
public class OpenStaffExcelHandler extends DownloadHandlerAbstract<OpenStaffExcelVO> {
@Autowired
private OpenStaffApiService openStaffApiService ;
@Autowired
private StaffApiService staffApiService ;
@Autowired
private StaffClerkRelationApiService staffClerkRelationApiService ;
@Autowired
private EnterpriseService enterpriseService ;
@Override
public List<OpenStaffExcelVO> getData(Context context, String json, Integer currentPage) {
OpenStaffPageQDTO qdto = JSON.parseObject(json, OpenStaffPageQDTO.class);
BasePageInfo pageInfo = new BasePageInfo() ;
pageInfo.setPageSize(this.getPageSize());
pageInfo.setPageNum(currentPage);
ServiceResponse<Page<OpenStaffListDTO>> page = this.openStaffApiService.page(qdto, pageInfo);
List<OpenStaffExcelVO> voList = new ArrayList<>();
if (null != page && CollectionUtils.isNotEmpty(page.getResult().getResult())) {
for(OpenStaffListDTO item : page.getResult().getResult()) {
OpenStaffExcelVO vo = EntityUtil.changeEntityByJSON(OpenStaffExcelVO.class,item) ;
vo.setCreateTimeExcel(DateUtil.dateToStr(item.getCreateTime(),"yyyy-MM-dd HH:mm:ss"));
if(null != item.getAuthTime()) {
vo.setLastTimeExcel(DateUtil.dateToStr(item.getAuthTime(),"yyyy-MM-dd HH:mm:ss"));
}
if(CollectionUtils.isNotEmpty(item.getClerkList())) {
vo.setStoreCodes(item.getClerkList().stream().map(o->o.getStoreCode()).collect(Collectors.joining(",")));
vo.setStoreNames(item.getClerkList().stream().map(o->o.getStoreName()).collect(Collectors.joining(",")));
vo.setClerkCodes(item.getClerkList().stream().map(o->o.getClerkCode()).collect(Collectors.joining(",")));
vo.setClerkNames(item.getClerkList().stream().map(o->o.getClerkName()).collect(Collectors.joining(",")));
}
if(item.getStatusFlag()==1) {
vo.setStatusExcel("托管中");
}else {
if(item.getValidQrcodeFlag()==1) {
vo.setStatusExcel("待验证");
}else {
if (null == item.getFirstAuthTime()) {
vo.setStatusExcel("待授权");
}else{
vo.setStatusExcel("已过期");
}
}
}
voList.add(vo) ;
}
}
return voList;
}
@Override
public List<String> getColumnNames() {
return Arrays.asList("成员姓名", "成员code","托管状态","关联导购姓名","关联导购code","关联门店姓名","关联门店code","所属商户","最近托管授权时间","新增时间");
}
@Override
public LinkedHashMap<String, List<String>> doubleColumnNames() {
return null;
}
@Override
public List<String> getColumns() {
return Arrays.asList("staffName", "wxUserId", "statusExcel", "clerkNames","clerkCodes", "storeNames","storeCodes","brandName","lastTimeExcel","createTimeExcel");
}
@Override
public Integer getPageSize() {
return 1000 ;
}
}
package com.gic.haoban.manage.web.controller.open;
import cn.hutool.core.date.DatePattern;
import com.alibaba.fastjson.JSON;
import com.gic.api.base.commons.BasePageInfo;
import com.gic.api.base.commons.JSONResponse;
import com.gic.api.base.commons.Page;
import com.gic.api.base.commons.ServiceResponse;
import com.gic.commons.util.DateUtil;
import com.gic.commons.util.PageHelperUtils;
import com.gic.commons.webapi.reponse.RestResponse;
import com.gic.enterprise.api.dto.EnterpriseDTO;
......@@ -18,6 +22,10 @@ import com.gic.haoban.manage.api.service.StaffApiService;
import com.gic.haoban.manage.api.service.StaffClerkRelationApiService;
import com.gic.haoban.manage.web.qo.open.OpenStaffQO;
import com.gic.haoban.manage.web.vo.open.OpenStaffVO;
import com.gic.qcloud.BucketNameEnum;
import com.gic.web.common.download.DownloadTask;
import com.gic.web.common.download.DownloadTaskUtil;
import com.gic.web.common.download.constants.TaskTypeEnum;
import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
......@@ -26,6 +34,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;
......@@ -44,6 +53,8 @@ public class QywxOpenController {
private StaffClerkRelationApiService staffClerkRelationApiService ;
@Autowired
private EnterpriseService enterpriseService ;
@Autowired
private OpenStaffExcelHandler openStaffExcelHandler ;
/**
* 托管列表
......@@ -78,12 +89,40 @@ public class QywxOpenController {
* @return
*/
@RequestMapping("open-staff-excel")
public RestResponse<Page<OpenStaffVO>> excel(@RequestBody OpenStaffQO qo) {
public RestResponse<String> excel(@RequestBody OpenStaffQO qo) {
WebLoginDTO loginUser = AuthWebRequestUtil.getLoginUser();
OpenStaffPageQDTO qdto = EntityUtil.changeEntityByJSON(OpenStaffPageQDTO.class,qo) ;
qdto.setWxEnterpriseId(loginUser.getWxEnterpriseId());
qdto.setEnterpriseId(loginUser.getEnterpriseId());
return RestResponse.successResult(null);
BasePageInfo basePageInfo = new BasePageInfo() ;
basePageInfo.setPageNum(1);
basePageInfo.setPageSize(1);
ServiceResponse<Page<OpenStaffListDTO>> pageResp =this.openStaffApiService.page(qdto,basePageInfo) ;
final int totalCount = pageResp.getResult().getTotalCount() ;
if (totalCount == 0) {
return RestResponse.failure("9999", "导出数据条数为0");
}
Date startDate = new Date();
Date endDate = new Date() ;
String fileName = "好办托管企微号"+ "-" + DateUtil.formatString(startDate,"yyyy-MM-dd") + "到" + DateUtil.formatString(endDate,"yyyy-MM-dd");
// 1.组装数据查询条件
DownloadTask task = new DownloadTask();
task.setTaskTypeEnum(TaskTypeEnum.SMSREFUNDLOG);
task.setDataType(1);
task.setTotalCount(totalCount);
task.setFileName(fileName);
task.setChannelName(TaskTypeEnum.SMSREFUNDLOG.getName());
task.setBucketName(BucketNameEnum.REPORT_50000.getName());
task.setSearchDataParams(JSON.toJSONStringWithDateFormat(qdto, DatePattern.NORM_DATETIME_PATTERN));
task.setHandler(openStaffExcelHandler);
JSONResponse jsonResponse = DownloadTaskUtil.createDownloadTask(task);
final String reportId;
if (jsonResponse.isSuccess()) {
reportId = (String) jsonResponse.getResult();
} else {
return RestResponse.failure("9999",jsonResponse.getErrorMessage());
}
return RestResponse.successResult(reportId);
}
/**
......
package com.gic.haoban.manage.web.vo.open;
import java.io.Serializable;
import java.util.Date;
import java.util.List;
public class OpenStaffExcelVO implements Serializable {
/**
* 成员名称
*/
private String staffName;
/**
* 成员code
*/
private String wxUserId;
/**
* 品牌名称
*/
private String brandName;
private String clerkNames;
private String clerkCodes;
private String storeNames;
private String storeCodes;
/**
* 创建时间
*/
private String createTimeExcel;
/**
* 1授权中 2未登录(已过期)
*/
private String statusExcel;
private String lastTimeExcel;
public String getStaffName() {
return staffName;
}
public void setStaffName(String staffName) {
this.staffName = staffName;
}
public String getWxUserId() {
return wxUserId;
}
public void setWxUserId(String wxUserId) {
this.wxUserId = wxUserId;
}
public String getBrandName() {
return brandName;
}
public void setBrandName(String brandName) {
this.brandName = brandName;
}
public String getClerkNames() {
return clerkNames;
}
public void setClerkNames(String clerkNames) {
this.clerkNames = clerkNames;
}
public String getClerkCodes() {
return clerkCodes;
}
public void setClerkCodes(String clerkCodes) {
this.clerkCodes = clerkCodes;
}
public String getStoreNames() {
return storeNames;
}
public void setStoreNames(String storeNames) {
this.storeNames = storeNames;
}
public String getStoreCodes() {
return storeCodes;
}
public void setStoreCodes(String storeCodes) {
this.storeCodes = storeCodes;
}
public String getCreateTimeExcel() {
return createTimeExcel;
}
public void setCreateTimeExcel(String createTimeExcel) {
this.createTimeExcel = createTimeExcel;
}
public String getStatusExcel() {
return statusExcel;
}
public void setStatusExcel(String statusExcel) {
this.statusExcel = statusExcel;
}
public String getLastTimeExcel() {
return lastTimeExcel;
}
public void setLastTimeExcel(String lastTimeExcel) {
this.lastTimeExcel = lastTimeExcel;
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment