Commit 76b342de by 284718418@qq.com

CRM 统计数据导出

parent 6014962b
package cn.timer.api.controller.crm;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.net.URLEncoder;
import java.time.LocalDate;
import java.util.*;
import java.util.stream.Collectors;
import cn.timer.api.controller.zpgl.sevice.ZpglService;
import cn.timer.api.dto.crm.CrmCartogramCountExportDto;
import cn.timer.api.dto.insure.PolicyDto;
import cn.timer.api.utils.ExcelUtils;
import org.apache.poi.xssf.usermodel.XSSFWorkbook;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
......@@ -67,6 +70,9 @@ import cn.timer.api.utils.ResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
/**
* Title: CrmController.java
*
......@@ -1503,15 +1509,13 @@ public class CrmController {
reader.addHeaderAlias("个人地址", "linkAddress");
reader.addHeaderAlias("跟进记录", "followuprecord");
List<CrmClientDataImportVo> list = reader.read(0, 1, CrmClientDataImportVo.class);
Map<String, String> map = Maps.newHashMap();
for (CrmClientDataImportVo crmClientDataImportVo : list) {
String name = crmClientDataImportVo.getClientName();
Map<String, String> map = Maps.newHashMap();
try {
CrmClientData crmd = CrmClientData.builder().build().selectOne(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getBelongUser, empNum).eq(CrmClientData::getClientName, crmClientDataImportVo.getClientName())
.eq(CrmClientData::getClientCellphone, crmClientDataImportVo.getClientCellphone()));
CrmClientData crmd = CrmClientData.builder().build().selectOne(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode,orgCode).eq(CrmClientData::getBelongUser, empNum).eq(CrmClientData::getClientName, crmClientDataImportVo.getClientName())
);
if(crmd == null) {
String clientName = crmClientDataImportVo.getClientName(); // 客户名称(必填)
String belongGroupName = crmClientDataImportVo.getBelongGroupName(); // 分组名(必填)
......@@ -1661,6 +1665,20 @@ public class CrmController {
// return ResultUtil.success("导入成功");
}
@GetMapping(value = "/exportCartogram")
@ApiOperation(value = "导出统计", httpMethod = "GET", notes = "导出统计")
public Result<Object> exportCartogram(@CurrentUser UserBean userBean,
@RequestParam(required = false) Integer groupId, @RequestParam(required = false) Integer belonger,
@RequestParam(required = false) String startCreateTime,
@RequestParam(required = false) String endCreateTime, HttpServletRequest request, HttpServletResponse resp) {
if(endCreateTime != null && !("").equals(endCreateTime)) {
endCreateTime = endCreateTime.substring(0, 10)+" 23:59:59";
}
List<CrmCartogramCountExportDto> userList = crmClientDataMapper.selectCrmCartogramCount(userBean.getOrgCode(), belonger, groupId, startCreateTime, endCreateTime);
return ResultUtil.data(userList,"成功");
}
private ExcelReader getReaderByUrl(String url) {
InputStream is = null;
try {
......
......@@ -9,6 +9,7 @@ package cn.timer.api.dao.crm;
import java.util.List;
import cn.timer.api.dto.crm.CrmCartogramCountExportDto;
import org.springframework.web.bind.annotation.RequestParam;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
......@@ -30,4 +31,11 @@ public interface CrmClientDataMapper extends BaseMapper<CrmClientData> {
@RequestParam(name = "belongGroup", required = false) Integer belongGroup,
@RequestParam(name = "startCreateTime", required = false) String startCreateTime,
@RequestParam(name = "endCreateTime", required = false) String endCreateTime);
List<CrmCartogramCountExportDto> selectCrmCartogramCount(@RequestParam("orgCode") Integer orgCode,
@RequestParam(name = "belongUser", required = false) Integer belongUser,
@RequestParam(name = "belongGroup", required = false) Integer belongGroup,
@RequestParam(name = "startCreateTime", required = false) String startCreateTime,
@RequestParam(name = "endCreateTime", required = false) String endCreateTime);
}
/**
* Title: CrmCartogramDto.java
* Description:
* @author dsc
* @date 2020年6月22日
* @version 1.0
*/
package cn.timer.api.dto.crm;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.io.Serializable;
/**
*
* @author wuqingjun
* @date 2023年4月12日
* @version 1.0
*/
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
public class CrmCartogramCountExportDto implements Serializable {
private static final long serialVersionUID = -4445892627839823485L;
private Integer provinceId;
/**
* 归属人姓名
*/
private String belongUserName;
/**
* 潜在
*/
private Integer potential;
/**
* 意向
*/
private Integer intention;
/**
* 签约
*/
private Integer signing;
/**
* 合作中
*/
private Integer cooperation;
/**
* 已封档
*/
private Integer file;
}
......@@ -26,5 +26,29 @@
GROUP BY
province_id
</select>
<select id="selectCrmCartogramCount" resultType="cn.timer.api.dto.crm.CrmCartogramCountExportDto">
SELECT belong_user_name,
COUNT(IF(ccd.client_status=1,ccd.id,NULL))potential,
COUNT(IF(ccd.client_status=2,ccd.id,NULL))intention,
COUNT(IF(ccd.client_status=3,ccd.id,NULL))signing,
COUNT(IF(ccd.client_status=4,ccd.id,NULL))cooperation,
COUNT(IF(ccd.client_status=5,ccd.id,NULL))file FROM `crm_client_data` ccd
LEFT JOIN crm_business_group_member cbgm ON cbgm.emp_num = ccd.belong_user
<where>
ccd.org_code = #{orgCode} and cbgm.org_code = #{orgCode}
<if test='null != belongUser and belongUser !=""'>
AND ccd.belong_user = #{belongUser}
</if>
<if test='null != belongGroup and belongGroup !=""'>
AND ccd.belong_group = #{belongGroup}
</if>
<if test='null != startCreateTime and startCreateTime !=""'>
AND ccd.create_time <![CDATA[>=]]> #{startCreateTime}
</if>
<if test='null != endCreateTime and endCreateTime !=""'>
AND ccd.create_time <![CDATA[<=]]> #{endCreateTime}
</if>
</where>
GROUP BY ccd.belong_user
</select>
</mapper>
\ 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