Commit 2e7f020d by dengshichuan

Merge branch 'dsc' into 'develop'

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

See merge request 8timerv2/8timerapiv200!259
parents 96868f08 54c2a26a
...@@ -1004,6 +1004,24 @@ public class CrmController { ...@@ -1004,6 +1004,24 @@ public class CrmController {
return ResultUtil.data(list, "获取成功"); 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) { private List<Integer> getAllBusinessGroupMember(Integer orgCode, Integer groupId) {
List<CrmBusinessGroupMember> list = CrmBusinessGroupMember.builder().build() List<CrmBusinessGroupMember> list = CrmBusinessGroupMember.builder().build()
...@@ -1016,13 +1034,14 @@ public class CrmController { ...@@ -1016,13 +1034,14 @@ public class CrmController {
} }
// 封装条形图数据Map // 封装条形图数据Map
private Map<String, Object> selectMap(Integer orgCode, Integer belonger, Integer status, String startCreateTime, private Map<String, Object> selectMap(Integer orgCode, Integer groupId, Integer belonger, Integer status,
String endCreateTime) { String startCreateTime, String endCreateTime) {
Map<String, Object> map = new HashMap<String, Object>(); Map<String, Object> map = new HashMap<String, Object>();
Integer num = CrmClientData.builder().build() Integer num = CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode) .selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getClientStatus, status) .eq(CrmClientData::getClientStatus, status)
.eq(belonger != null, CrmClientData::getBelongUser, belonger) .eq(belonger != null, CrmClientData::getBelongUser, belonger)
.eq(groupId != null, CrmClientData::getBelongGroup, groupId)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime) .ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime)); .le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
String name = "未知"; String name = "未知";
...@@ -1051,17 +1070,17 @@ public class CrmController { ...@@ -1051,17 +1070,17 @@ public class CrmController {
if (belonger == null) { if (belonger == null) {
List<Integer> members = getAllBusinessGroupMember(orgCode, groupId); List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
for (Integer memberId : members) { 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) { if ((Integer) map.get("num") > 0) {
list.add(map); 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) if ((Integer) map.get("num") > 0)
list.add(map); list.add(map);
} else { } 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) { if ((Integer) map.get("num") > 0) {
list.add(map); list.add(map);
} }
...@@ -1088,11 +1107,21 @@ public class CrmController { ...@@ -1088,11 +1107,21 @@ public class CrmController {
num += CrmClientData.builder().build() num += CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode) .selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getClientType, level).eq(CrmClientData::getBelongUser, memberId) .eq(CrmClientData::getClientType, level).eq(CrmClientData::getBelongUser, memberId)
.eq(groupId != null, CrmClientData::getBelongGroup, groupId)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, .ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime,
startCreateTime) startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, .le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime,
endCreateTime)); 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); map.put("level", level);
String name = ClientTypeClass.builder().id(level).build().selectById().getName(); String name = ClientTypeClass.builder().id(level).build().selectById().getName();
map.put("name", name); map.put("name", name);
......
...@@ -29,6 +29,6 @@ import lombok.NoArgsConstructor; ...@@ -29,6 +29,6 @@ import lombok.NoArgsConstructor;
public class CrmCartogramDto implements Serializable { public class CrmCartogramDto implements Serializable {
private static final long serialVersionUID = -4445892627839823485L; private static final long serialVersionUID = -4445892627839823485L;
private Integer provinceId; private Integer provinceId;
private String province; private String provinceName;
private Integer provinceNum; private Integer num;
} }
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
<select id="crmCartogram" <select id="crmCartogram"
resultType="cn.timer.api.dto.crm.CrmCartogramDto"> resultType="cn.timer.api.dto.crm.CrmCartogramDto">
SELECT SELECT
province_id,province,count(province_id) provinceNum province_id,province as provinceName,count(province_id) num
FROM FROM
crm_client_data crm_client_data
WHERE 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