Commit 1def50d0 by 邓实川 Committed by chenzg

客户管理接口

parent 1de703b7
/**
* Title: CrmBusinessManager.java
* Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
package cn.timer.api.bean.crm;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;
/**
* Title: CrmBusinessGroupManager.java
*
* @Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
@Entity
@Data
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "crm_business_group_manager")
@ApiModel("业务组管理员表")
public class CrmBusinessGroupManager extends Model<CrmBusinessGroupManager> {
private static final long serialVersionUID = -957497237692110042L;
@Id
@GeneratedValue
@TableId(type = IdType.AUTO)
@ApiModelProperty(value = "编号")
private Integer id;
@ApiModelProperty(value = "组id")
private Integer gid;
@ApiModelProperty(value = "员工id")
private Integer empNum;
@ApiModelProperty(value = "企业id")
private Integer orgCode;
}
......@@ -54,6 +54,9 @@ public class CrmBusinessGroupMember extends Model<CrmBusinessGroupMember>{
@ApiModelProperty(value = "员工id")
private Integer empNum;
@ApiModelProperty(value = "0-普通成员 1-管理员")
private Integer type;
@ApiModelProperty(value = "企业id")
private Integer orgCode;
}
......@@ -37,7 +37,7 @@ import lombok.NoArgsConstructor;
@Builder
@NoArgsConstructor
@AllArgsConstructor
@Table(name = "crm_client_associates")
@Table(name = "crm_client_associate")
@ApiModel("客户协作人表")
public class CrmClientAssociate extends Model<CrmClientAssociate> {
......
......@@ -16,6 +16,7 @@ import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
......@@ -25,7 +26,9 @@ import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
......@@ -35,7 +38,6 @@ import cn.timer.api.bean.clazz.ClientTypeClass;
import cn.timer.api.bean.clazz.IndustryClass;
import cn.timer.api.bean.clazz.SysRegion;
import cn.timer.api.bean.crm.CrmBusinessGroup;
import cn.timer.api.bean.crm.CrmBusinessGroupManager;
import cn.timer.api.bean.crm.CrmBusinessGroupMember;
import cn.timer.api.bean.crm.CrmClientAssociate;
import cn.timer.api.bean.crm.CrmClientContacts;
......@@ -45,6 +47,7 @@ import cn.timer.api.bean.crm.CrmSeaRule;
import cn.timer.api.bean.yggl.YgglMainEmp;
import cn.timer.api.config.annotation.CurrentUser;
import cn.timer.api.config.annotation.UserBean;
import cn.timer.api.dao.crm.CrmClientDataMapper;
import cn.timer.api.utils.CheckUtil;
import cn.timer.api.utils.Result;
import cn.timer.api.utils.ResultUtil;
......@@ -66,6 +69,9 @@ import io.swagger.annotations.ApiOperation;
@RequestMapping(value = "/crm", produces = { "application/json" })
public class CrmController {
@Autowired
private CrmClientDataMapper crmClientDataMapper;
private Integer getEmpNum(UserBean userBean) {
return userBean.getEmpNum();
}
......@@ -129,11 +135,11 @@ public class CrmController {
Integer gid = crmBusinessGroup.getId();
Integer[] memberIds = crmBusinessGroup.getMemberIds();
for (Integer empId : memberIds) {
CrmBusinessGroupMember.builder().gid(gid).empNum(empId).orgCode(orgCode).build().insert();
CrmBusinessGroupMember.builder().gid(gid).empNum(empId).orgCode(orgCode).type(0).build().insert();
}
Integer[] managerIds = crmBusinessGroup.getManagerIds();
for (Integer empId : managerIds) {
CrmBusinessGroupManager.builder().gid(gid).empNum(empId).orgCode(orgCode).build().insert();
CrmBusinessGroupMember.builder().gid(gid).empNum(empId).orgCode(orgCode).type(1).build().insert();
}
CrmSeaRule crmSeaRule = crmBusinessGroup.getCrmSeaRules();
......@@ -151,11 +157,11 @@ public class CrmController {
CrmBusinessGroup::getSort, CrmBusinessGroup::getName, CrmBusinessGroup::getModifyTime));
for (CrmBusinessGroup crmBusinessGroup : list) {
Integer gid = crmBusinessGroup.getId();
List<CrmBusinessGroupManager> crmBusinessGroupManagers = CrmBusinessGroupManager.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupManager>().lambda()
.eq(CrmBusinessGroupManager::getGid, gid).select(CrmBusinessGroupManager::getEmpNum));
List<CrmBusinessGroupMember> crmBusinessGroupManagers = CrmBusinessGroupMember.builder().build().selectList(
new QueryWrapper<CrmBusinessGroupMember>().lambda().eq(CrmBusinessGroupMember::getGid, gid)
.eq(CrmBusinessGroupMember::getType, 1).select(CrmBusinessGroupMember::getEmpNum));
List<Map<String, Object>> managers = new ArrayList<Map<String, Object>>();
for (CrmBusinessGroupManager crmBusinessGroupManager : crmBusinessGroupManagers) {
for (CrmBusinessGroupMember crmBusinessGroupManager : crmBusinessGroupManagers) {
Integer empNum = crmBusinessGroupManager.getEmpNum();
String name = getEmpName(getOrgCode(userBean), empNum);
Map<String, Object> map = new HashMap<String, Object>();
......@@ -380,6 +386,21 @@ public class CrmController {
return ResultUtil.data(crmClientDatas, "查询成功");
}
private List<Integer> MyJoinGroup(Integer empNum, Integer orgCode) {
List<CrmBusinessGroupMember> members = CrmBusinessGroupMember.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupMember>().lambda()
.eq(CrmBusinessGroupMember::getEmpNum, empNum).eq(CrmBusinessGroupMember::getOrgCode, orgCode));
return members.stream().map(CrmBusinessGroupMember::getGid).collect(Collectors.toList());
}
private List<Integer> MyManageGroup(Integer empNum, Integer orgCode) {
List<CrmBusinessGroupMember> managers = CrmBusinessGroupMember.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupMember>().lambda()
.eq(CrmBusinessGroupMember::getEmpNum, empNum).eq(CrmBusinessGroupMember::getOrgCode, orgCode)
.eq(CrmBusinessGroupMember::getType, 1));
return managers.stream().map(CrmBusinessGroupMember::getGid).collect(Collectors.toList());
}
@GetMapping("getSeaCilentTotal")
@ApiOperation(value = "获取公海客户列表(全)", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CrmClientData>> getSeaCilentTotal(@CurrentUser UserBean userBean,
......@@ -388,29 +409,55 @@ public class CrmController {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
// 当前用户加入的组
List<CrmBusinessGroupMember> members = CrmBusinessGroupMember.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupMember>().lambda()
.eq(CrmBusinessGroupMember::getEmpNum, empNum).eq(CrmBusinessGroupMember::getOrgCode, orgCode));
List<Integer> gids1 = members.stream().map(CrmBusinessGroupMember::getGid).collect(Collectors.toList());
List<Integer> gids1 = MyJoinGroup(empNum, orgCode);
// 当前用户管理的组
List<CrmBusinessGroupManager> managers = CrmBusinessGroupManager.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupManager>().lambda()
.eq(CrmBusinessGroupManager::getEmpNum, empNum)
.eq(CrmBusinessGroupManager::getOrgCode, orgCode));
List<Integer> gids2 = managers.stream().map(CrmBusinessGroupManager::getGid).collect(Collectors.toList());
List<Integer> gids2 = MyManageGroup(empNum, orgCode);
List<Integer> myGids = CheckUtil.distinct(gids1, gids2, true); // 当前用户所有业务组id
List<CrmClientData> crmClientDatas = new ArrayList<CrmClientData>();
for (Integer gid : myGids) {
crmClientDatas.add(CrmClientData.builder().build()
.selectOne(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getBelongGroup, gid)
List<CrmClientData> datas = CrmClientData.builder().build()
.selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getBelongGroup, gid)
.eq(CrmClientData::getBelongUser, 0)
.eq(type != null && type >= 0, CrmClientData::getClientType, type)
.eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
.eq(status != null && status >= 0, CrmClientData::getClientStatus, status)
.like(!StrUtil.isBlank(like), CrmClientData::getClientName, like).or()
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like)));
} // TODO
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like));
for (CrmClientData data : datas)
crmClientDatas.add(data);
}
return ResultUtil.data(crmClientDatas, "查询成功");
}
@GetMapping("getAllCilentTotal")
@ApiOperation(value = "获取所有客户列表(全)", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getAllCilentTotal(@CurrentUser UserBean userBean,
@RequestParam(required = false) Integer type, @RequestParam(required = false) Integer groupId,
@RequestParam(required = false) Integer status, @RequestParam(required = false) String like,
@RequestParam(required = false) String startCreateTime,
@RequestParam(required = false) String endCreateTime,
@RequestParam(required = false) String startFollowTime,
@RequestParam(required = false) String endFollowTime) {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
// 当前用户管理的组
List<Integer> gids = MyManageGroup(empNum, orgCode);
List<Object> crmClientDatas = new ArrayList<Object>();
for (Integer gid : gids) {
List<CrmClientData> datas = CrmClientData.builder().build()
.selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getBelongGroup, gid)
.eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
.eq(type != null && type >= 0, CrmClientData::getClientType, type)
.eq(status != null && status >= 0, CrmClientData::getClientStatus, status)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime)
.ge(StringUtils.isNotBlank(startFollowTime), CrmClientData::getCreateTime, startFollowTime)
.le(StringUtils.isNotBlank(endFollowTime), CrmClientData::getCreateTime, endFollowTime)
.like(!StrUtil.isBlank(like), CrmClientData::getClientName, like).or()
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like));
for (CrmClientData data : datas)
crmClientDatas.add(data);
}
return ResultUtil.data(crmClientDatas, "查询成功");
}
......@@ -505,6 +552,13 @@ public class CrmController {
.eq(CrmClientFollow::getOrgCode, orgCode).eq(CrmClientFollow::getCid, cid)), "获取成功");
}
// 根据组id和员工号查询组管理员
private CrmBusinessGroupMember getGroupManager(Integer groupId, Integer empNum) {
return CrmBusinessGroupMember.builder().build().selectOne(
new QueryWrapper<CrmBusinessGroupMember>().lambda().eq(CrmBusinessGroupMember::getGid, groupId)
.eq(CrmBusinessGroupMember::getEmpNum, empNum).eq(CrmBusinessGroupMember::getType, 1));
}
@PostMapping("addClientArchive")
@ApiOperation(value = "客户封档/解封", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> addClientArchive(@CurrentUser UserBean userBean, @RequestParam Integer cid) {
......@@ -512,8 +566,9 @@ public class CrmController {
CrmClientData crmClientData = CrmClientData.builder().id(cid).build().selectById();
if (crmClientData == null)
return ResultUtil.error("请确认该客户是否存在");
if (!crmClientData.getBelongUser().equals(empNum))
return ResultUtil.error("不是当前客户归属人");
if (!crmClientData.getBelongUser().equals(empNum)
&& getGroupManager(crmClientData.getBelongGroup(), empNum) == null)
return ResultUtil.error("不是当前客户归属人或组管理员");
Integer status = crmClientData.getClientStatus();
if (status != null && status != 5) {
crmClientData.setClientStatus(5);
......@@ -531,13 +586,14 @@ public class CrmController {
@ApiOperation(value = "指派客户归属人", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> designateClientBelonger(@CurrentUser UserBean userBean, @RequestParam Integer cid,
@RequestParam Integer belongUser) {
Integer empNum = getEmpNum(userBean);
if (cid == null)
return ResultUtil.error("请传入id再试");
CrmClientData oldData = CrmClientData.builder().id(cid).build().selectById();
if (oldData == null)
return ResultUtil.error("请确认该客户数据是否存在");
if (!oldData.getBelongUser().equals(getEmpNum(userBean)))
return ResultUtil.error("不是当前客户归属人");
if (!oldData.getBelongUser().equals(empNum) && getGroupManager(oldData.getBelongGroup(), empNum) == null)
return ResultUtil.error("不是当前客户归属人或组管理员");
if (oldData.getClientStatus() == 5)
return ResultUtil.error("请解封后继续编辑操作");
......@@ -560,23 +616,253 @@ public class CrmController {
@Transactional
@ApiOperation(value = "释放客户到公海", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> freeClientToSea(@CurrentUser UserBean userBean, @RequestParam Integer cid) {
Integer empNum = getEmpNum(userBean);
if (cid == null)
return ResultUtil.error("请传入id再试");
CrmClientData oldData = CrmClientData.builder().id(cid).build().selectById();
if (oldData == null)
return ResultUtil.error("请确认该客户数据是否存在");
if (!oldData.getBelongUser().equals(getEmpNum(userBean)))
return ResultUtil.error("不是当前客户归属人");
if (oldData.getBelongUser() == 0)
return ResultUtil.error("该客户已在公海列表");
if ((!oldData.getOrgCode().equals(getOrgCode(userBean)) || !oldData.getBelongUser().equals(empNum))
&& getGroupManager(oldData.getBelongGroup(), empNum) == null)
return ResultUtil.error("不是当前客户归属人或组管理员");
if (oldData.getClientStatus() == 5)
return ResultUtil.error("请解封后继续编辑操作");
oldData.setBelongUser(0); // 0-进入客户公海
oldData.setBelongUserName(null);
if (oldData.updateById() && CrmClientAssociate.builder().build()
.delete(new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, cid)))
// 删除协作人列表
CrmClientAssociate.builder().build()
.delete(new QueryWrapper<CrmClientAssociate>().lambda().eq(CrmClientAssociate::getCid, cid));
if (oldData.updateById())
return ResultUtil.success("释放成功");
return ResultUtil.error("释放失败");
}
// TODO
@PostMapping("receiveSeaClient")
@ApiOperation(value = "接收公海客户", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> receiveSeaClient(@CurrentUser UserBean userBean, @RequestParam Integer cid) {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
if (cid == null)
return ResultUtil.error("请传入id再试");
CrmClientData oldData = CrmClientData.builder().id(cid).build().selectById();
if (oldData == null)
return ResultUtil.error("请确认该客户数据是否存在");
// 当前用户所有组id
List<Integer> myGids = CheckUtil.distinct(MyJoinGroup(empNum, orgCode), MyManageGroup(empNum, orgCode), true);
if (!myGids.contains(oldData.getBelongGroup()))
return ResultUtil.error("不是当前业务组成员");
oldData.setBelongUser(empNum);
oldData.setBelongUserName(getEmpName(orgCode, empNum));
if (oldData.updateById())
return ResultUtil.success("接收成功");
return ResultUtil.error("接收失败");
}
@Transactional
@PostMapping("designateClientBelongers")
@ApiOperation(value = "转移客户归属人(批量客户)", httpMethod = "POST", notes = "接口发布说明")
public Result<Void> designateClientBelongers(@CurrentUser UserBean userBean, @RequestParam List<Integer> cids,
@RequestParam Integer belonger) {
// 所选的客户列表
List<CrmClientData> crmClientDatas = crmClientDataMapper.selectBatchIds(cids);
// 业务组id列表
List<Integer> gids = crmClientDatas.stream().map(CrmClientData::getBelongGroup).collect(Collectors.toList());
Integer gid = gids.get(0);
// 当前操作人是否管理员
CrmBusinessGroupMember nowManager = CrmBusinessGroupMember.builder().build()
.selectOne(new QueryWrapper<CrmBusinessGroupMember>().lambda().eq(CrmBusinessGroupMember::getGid, gid)
.eq(CrmBusinessGroupMember::getEmpNum, getEmpNum(userBean))
.eq(CrmBusinessGroupMember::getType, 1));
if (nowManager == null)
return ResultUtil.error("没有操作权限,请联系组管理员进行操作");
// 是否有不同组的客户
if (gids.stream().distinct().count() > 1)
return ResultUtil.error("请确认是否同一业务组客户");
// 转移人业务组信息
CrmBusinessGroupMember crmBusinessGroupMember = CrmBusinessGroupMember.builder().build()
.selectOne(new QueryWrapper<CrmBusinessGroupMember>().lambda().eq(CrmBusinessGroupMember::getGid, gid)
.eq(CrmBusinessGroupMember::getEmpNum, belonger));
if (crmBusinessGroupMember == null)
return ResultUtil.error("请确认转移目标是当前业务组成员");
for (CrmClientData crmClientData : crmClientDatas) {
crmClientData.setBelongUser(belonger);
crmClientData.setBelongUserName(getEmpName(getOrgCode(userBean), belonger));
crmClientData.updateById();
}
return ResultUtil.success("转移成功");
}
/**
*
* @param userBean
* @param type 统计图类型(暂时不要)
* @param groupId 业务组id
* @param memberId 业务员id
* @param startCreateTime 创建时间-开始时间
* @param endCreateTime 创建时间-结束时间
* @return 对应客户数据count
*/
@GetMapping("getAllCartogram")
@ApiOperation(value = "获取统计图(全)", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getAllCartogram(@CurrentUser UserBean userBean,
@RequestParam(required = false) Integer groupId, @RequestParam(required = false) Integer belonger,
@RequestParam(required = false) String startCreateTime,
@RequestParam(required = false) String endCreateTime) {
Integer orgCode = getOrgCode(userBean);
List<Object> listAll = new ArrayList<Object>();
listAll.add(cartogram(orgCode, groupId, 1, belonger, startCreateTime, endCreateTime));// 图1
listAll.add(cartogram(orgCode, groupId, 2, belonger, startCreateTime, endCreateTime));// 图2
listAll.add(cartogram(orgCode, groupId, 3, belonger, startCreateTime, endCreateTime));// 图3
listAll.add(cartogram(orgCode, groupId, 4, belonger, startCreateTime, endCreateTime));// 图4
List<List<Map<String, Object>>> cartogram5 = new ArrayList<List<Map<String, Object>>>();// 图5
cartogram5.add(cartogram2(orgCode, groupId, 1, belonger, startCreateTime, endCreateTime));
cartogram5.add(cartogram2(orgCode, groupId, 2, belonger, startCreateTime, endCreateTime));
cartogram5.add(cartogram2(orgCode, groupId, 3, belonger, startCreateTime, endCreateTime));
listAll.add(cartogram5);
List<List<Map<String, Object>>> cartogram6 = new ArrayList<List<Map<String, Object>>>(); // 图6
for (String regionName : getRegionNameList()) {
cartogram6.add(cartogram3(orgCode, groupId, regionName, belonger, startCreateTime, endCreateTime));
}
listAll.add(cartogram6);
return ResultUtil.data(listAll, "获取成功");
}
// 获取省份名
private List<String> getRegionNameList() {
List<SysRegion> list = SysRegion.builder().build()
.selectList(new LambdaQueryWrapper<SysRegion>().eq(SysRegion::getLevel, 1));
return list.stream().map(SysRegion::getRegionName).collect(Collectors.toList());
}
// 获取公司全部业务员
private List<Integer> getAllBusinessGroupMember(Integer orgCode, Integer groupId) {
List<CrmBusinessGroupMember> list = CrmBusinessGroupMember.builder().build()
.selectList(new QueryWrapper<CrmBusinessGroupMember>().lambda()
.eq(CrmBusinessGroupMember::getOrgCode, orgCode)
.eq(groupId != null && groupId >= 0, CrmBusinessGroupMember::getGid, groupId));
return list.stream().map(CrmBusinessGroupMember::getEmpNum).collect(Collectors.toList()).stream().distinct()
.collect(Collectors.toList());
// list.stream().filter(CheckUtil.distinctByKey(CrmBusinessGroupMember::getEmpNum)).collect(Collectors.toList());
}
// 封装条形图数据Map
private Map<String, Object> selectMap(Integer orgCode, Integer belonger, Integer status, String startCreateTime,
String endCreateTime) {
Map<String, Object> map = new HashMap<String, Object>();
Integer num = CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getClientStatus, status).eq(CrmClientData::getBelongUser, belonger)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
String name = getEmpName(orgCode, belonger);
map.put("name", name);
map.put("num", num);
return map;
}
// 封装⚪形图数据Map1
private Map<String, Object> selectMap1(Integer orgCode, Integer belonger, Integer level, String startCreateTime,
String endCreateTime) {
Map<String, Object> map = new HashMap<String, Object>();
Integer num = CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getClientType, level).eq(CrmClientData::getBelongUser, belonger)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
map.put("level", level);
map.put("num", num);
return map;
}
// 封装⚪形图数据Map2
private Map<String, Object> selectMap2(Integer orgCode, Integer belonger, String province, String startCreateTime,
String endCreateTime) {
Map<String, Object> map = new HashMap<String, Object>();
Integer num = CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getProvince, province).eq(CrmClientData::getBelongUser, belonger)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
map.put("province", province);
map.put("num", num);
return map;
}
/**
* 统计图1,2,3,4
*
* @param orgCode 企业id(必填)
* @param groupId 组id (可不填)
* @param status 分类 1 2 3 4 (必填)
* @param belonger 业务员id (可不填)
* @return
*/
private List<Map<String, Object>> cartogram(Integer orgCode, Integer groupId, Integer status, Integer belonger,
String startCreateTime, String endCreateTime) {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (belonger == null) {
List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
for (Integer memberId : members) {
list.add(selectMap(orgCode, memberId, status, startCreateTime, endCreateTime));
}
} else {
list.add(selectMap(orgCode, belonger, status, startCreateTime, endCreateTime));
}
return list;
}
/**
* 统计图5
*
* @param orgCode 企业id(必填)
* @param groupId 组id (可不填)
* @param level 客户等级分类 (必填)
* @param belonger 业务员id (可不填)
* @return
*/
private List<Map<String, Object>> cartogram2(Integer orgCode, Integer groupId, Integer level, Integer belonger,
String startCreateTime, String endCreateTime) {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (belonger == null) {
List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
for (Integer memberId : members) {
Map<String, Object> map = selectMap1(orgCode, memberId, level, startCreateTime, endCreateTime);
list.add(map);
}
} else {
list.add(selectMap1(orgCode, belonger, level, startCreateTime, endCreateTime));
}
return list;
}
/**
* 统计图6
*
* @param orgCode 企业id(必填)
* @param groupId 组id (可不填)
* @param level 客户等级分类 (必填)
* @param belonger 业务员id (可不填)
* @return
*/
private List<Map<String, Object>> cartogram3(Integer orgCode, Integer groupId, String province, Integer belonger,
String startCreateTime, String endCreateTime) {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
if (belonger == null) {
List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
for (Integer memberId : members) {
list.add(selectMap2(orgCode, memberId, province, startCreateTime, endCreateTime));
}
} else {
list.add(selectMap2(orgCode, belonger, province, startCreateTime, endCreateTime));
}
return list;
}
// TODO 统计图
}
/**
* Title: CrmBusinessGroupManagerMapper.java
* Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
package cn.timer.api.dao.crm;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import cn.timer.api.bean.crm.CrmBusinessGroupManager;
/**
* Title: CrmBusinessGroupManagerMapper.java
*
* @Description:
* @author dsc
* @date 2020年6月9日
* @version 1.0
*/
public interface CrmBusinessGroupManagerMapper extends BaseMapper<CrmBusinessGroupManager> {
}
......@@ -9,6 +9,10 @@ package cn.timer.api.utils;
import java.lang.reflect.Field;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.function.Function;
import java.util.function.Predicate;
import java.util.stream.Collectors;
/**
......@@ -86,6 +90,17 @@ public class CheckUtil {
return list1;
return list1.stream().distinct().collect(Collectors.toList());
}
/**
* 字段条件去重
* @param <T>
* @param keyExtractor
* @return
*/
public static <T> Predicate<T> distinctByKey(Function<? super T, Object> keyExtractor) {
Map<Object, Boolean> seen = new ConcurrentHashMap<>();
return object -> seen.putIfAbsent(keyExtractor.apply(object), Boolean.TRUE) == null;
}
// public static void main(String[] args) {
// List<String> list1 = new ArrayList<String>();
......
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