Commit 54c2a26a by 邓实川

统计图优化,业务组员接口优化

parent ac08b9f3
......@@ -1004,6 +1004,24 @@ public class CrmController {
return ResultUtil.data(list, "获取成功");
}
@GetMapping("getBusinessManByGroupId")
@ApiOperation(value = "获取业务员ByGroupId", httpMethod = "GET", notes = "接口发布说明")
public Result<Object> getBusinessManByGroupId(@CurrentUser UserBean userBean, Integer gid) {
List<CrmBusinessGroupMember> list = CrmBusinessGroupMember.builder().build()
.selectList(new LambdaQueryWrapper<CrmBusinessGroupMember>().eq(CrmBusinessGroupMember::getGid, gid)
.select(CrmBusinessGroupMember::getEmpNum));
List<Integer> empNums = list.stream().map(CrmBusinessGroupMember::getEmpNum).collect(Collectors.toList());
List<Map<String, Object>> result = new ArrayList<Map<String, Object>>();
for (Integer empNum : empNums) {
String name = getEmpName(getOrgCode(userBean), empNum);
Map<String, Object> map = new HashMap<String, Object>();
map.put("name", name);
map.put("empNum", empNum);
result.add(map);
}
return ResultUtil.data(result, "获取成功");
}
// 获取公司全部业务员
private List<Integer> getAllBusinessGroupMember(Integer orgCode, Integer groupId) {
List<CrmBusinessGroupMember> list = CrmBusinessGroupMember.builder().build()
......@@ -1016,13 +1034,14 @@ public class CrmController {
}
// 封装条形图数据Map
private Map<String, Object> selectMap(Integer orgCode, Integer belonger, Integer status, String startCreateTime,
String endCreateTime) {
private Map<String, Object> selectMap(Integer orgCode, Integer groupId, 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(belonger != null, CrmClientData::getBelongUser, belonger)
.eq(groupId != null, CrmClientData::getBelongGroup, groupId)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
String name = "未知";
......@@ -1051,17 +1070,17 @@ public class CrmController {
if (belonger == null) {
List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
for (Integer memberId : members) {
Map<String, Object> map = selectMap(orgCode, memberId, status, startCreateTime, endCreateTime);
Map<String, Object> map = selectMap(orgCode, groupId, memberId, status, startCreateTime, endCreateTime);
if ((Integer) map.get("num") > 0) {
list.add(map);
}
}
Map<String, Object> map = selectMap(orgCode, 0, status, startCreateTime, endCreateTime);
Map<String, Object> map = selectMap(orgCode, groupId, 0, status, startCreateTime, endCreateTime);
if ((Integer) map.get("num") > 0)
list.add(map);
} else {
Map<String, Object> map = selectMap(orgCode, belonger, status, startCreateTime, endCreateTime);
Map<String, Object> map = selectMap(orgCode, groupId, belonger, status, startCreateTime, endCreateTime);
if ((Integer) map.get("num") > 0) {
list.add(map);
}
......@@ -1088,11 +1107,21 @@ public class CrmController {
num += CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getClientType, level).eq(CrmClientData::getBelongUser, memberId)
.eq(groupId != null, CrmClientData::getBelongGroup, groupId)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime,
startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime,
endCreateTime));
}
num += CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getClientType, level).eq(CrmClientData::getBelongUser, 0)
.eq(groupId != null, CrmClientData::getBelongGroup, groupId)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
map.put("level", level);
String name = ClientTypeClass.builder().id(level).build().selectById().getName();
map.put("name", name);
......
......@@ -29,6 +29,6 @@ import lombok.NoArgsConstructor;
public class CrmCartogramDto implements Serializable {
private static final long serialVersionUID = -4445892627839823485L;
private Integer provinceId;
private String province;
private Integer provinceNum;
private String provinceName;
private Integer num;
}
......@@ -6,7 +6,7 @@
<select id="crmCartogram"
resultType="cn.timer.api.dto.crm.CrmCartogramDto">
SELECT
province_id,province,count(province_id) provinceNum
province_id,province as provinceName,count(province_id) num
FROM
crm_client_data
WHERE
......
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