Commit 09762ee2 by 邓实川 Committed by chenzg

客户管理-统计图优化

parent 1def50d0
......@@ -80,14 +80,18 @@ public class CrmClientData extends Model<CrmClientData> {
@ApiModelProperty(value = "客户邮箱")
private String clientEmail;
@ApiModelProperty(value = "区编号")
private Integer keyId;
@ApiModelProperty(value = "省")
private String province;
@ApiModelProperty(value = "省id")
private Integer provinceId;
@ApiModelProperty(value = "市")
private String city;
@ApiModelProperty(value = "市")
private Integer cityId;
@ApiModelProperty(value = "区")
private String district;
@ApiModelProperty(value = "区编号")
private Integer districtId;
@ApiModelProperty(value = "邮编")
private String zipCode;
@ApiModelProperty(value = "详细地址")
......@@ -125,7 +129,7 @@ public class CrmClientData extends Model<CrmClientData> {
@ApiModelProperty(value = "附件地址")
private String fileUrl;
@ApiModelProperty(value = "客户联系人数量")
private Integer contactsNum;
......
......@@ -207,13 +207,16 @@ public class CrmController {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
crmClientData.setCreateUser(empNum);
SysRegion district = getSysRegion(crmClientData.getKeyId());
SysRegion district = getSysRegion(crmClientData.getDistrictId());
// crmClientData.setZipCode(district.getZipCode());
crmClientData.setDistrict(district.getRegionName());
SysRegion city = getSysRegion(district.getRegionCode());
crmClientData.setCity(city.getRegionName());
crmClientData.setCityId(city.getKeyId());
SysRegion province = getSysRegion(city.getRegionCode());
crmClientData.setProvinceId(province.getKeyId());
crmClientData.setProvince(province.getRegionName());
crmClientData.setBelongUserName(getEmpName(orgCode, crmClientData.getBelongUser()));
crmClientData.setOrgCode(getOrgCode(userBean));
Integer belongGroup = crmClientData.getBelongGroup();
......@@ -718,26 +721,33 @@ public class CrmController {
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));
List<Map<String, Object>> cartogram5 = new ArrayList<Map<String, Object>>();// 图5
List<ClientTypeClass> typeClasses = ClientTypeClass.builder().build().selectAll();
for (ClientTypeClass clientTypeClass : typeClasses) {
Integer type = clientTypeClass.getId();
Map<String, Object> map = cartogram2(orgCode, groupId, type, belonger, startCreateTime, endCreateTime);
if ((Integer) map.get("num") > 0) {
cartogram5.add(map);
}
}
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));
List<Map<String, Object>> cartogram6 = new ArrayList<Map<String, Object>>(); // 图6
for (Integer keyId : getKeyIdList()) {
Map<String, Object> map = cartogram3(orgCode, groupId, keyId, belonger, startCreateTime, endCreateTime);
if ((Integer) map.get("num") > 0) {
cartogram6.add(map);
}
}
listAll.add(cartogram6);
return ResultUtil.data(listAll, "获取成功");
}
// 获取省份
private List<String> getRegionNameList() {
// 获取省份id
private List<Integer> getKeyIdList() {
List<SysRegion> list = SysRegion.builder().build()
.selectList(new LambdaQueryWrapper<SysRegion>().eq(SysRegion::getLevel, 1));
return list.stream().map(SysRegion::getRegionName).collect(Collectors.toList());
.selectList(new LambdaQueryWrapper<SysRegion>().eq(SysRegion::getLevel, 1).select(SysRegion::getKeyId));
return list.stream().map(SysRegion::getKeyId).collect(Collectors.toList());
}
// 获取公司全部业务员
......@@ -766,34 +776,6 @@ public class CrmController {
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
*
......@@ -809,10 +791,16 @@ public class CrmController {
if (belonger == null) {
List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
for (Integer memberId : members) {
list.add(selectMap(orgCode, memberId, status, startCreateTime, endCreateTime));
Map<String, Object> map = selectMap(orgCode, memberId, status, startCreateTime, endCreateTime);
if ((Integer) map.get("num") > 0) {
list.add(map);
}
}
} else {
list.add(selectMap(orgCode, belonger, status, startCreateTime, endCreateTime));
Map<String, Object> map = selectMap(orgCode, belonger, status, startCreateTime, endCreateTime);
if ((Integer) map.get("num") > 0) {
list.add(map);
}
}
return list;
}
......@@ -826,19 +814,38 @@ public class CrmController {
* @param belonger 业务员id (可不填)
* @return
*/
private List<Map<String, Object>> cartogram2(Integer orgCode, Integer groupId, Integer level, Integer belonger,
private 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>>();
Map<String, Object> map = new HashMap<String, Object>();
Integer num = 0;
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);
num += CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getClientType, level).eq(CrmClientData::getBelongUser, memberId)
.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);
map.put("num", num);
} else {
list.add(selectMap1(orgCode, belonger, level, startCreateTime, endCreateTime));
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);
String name = ClientTypeClass.builder().id(level).build().selectById().getName();
map.put("name", name);
map.put("num", num);
}
return list;
return map;
}
/**
......@@ -850,19 +857,42 @@ public class CrmController {
* @param belonger 业务员id (可不填)
* @return
*/
private List<Map<String, Object>> cartogram3(Integer orgCode, Integer groupId, String province, Integer belonger,
private Map<String, Object> cartogram3(Integer orgCode, Integer groupId, Integer provinceId, Integer belonger,
String startCreateTime, String endCreateTime) {
List<Map<String, Object>> list = new ArrayList<Map<String, Object>>();
Map<String, Object> map = new HashMap<String, Object>();
Integer num = 0;
if (belonger == null) {
List<Integer> members = getAllBusinessGroupMember(orgCode, groupId);
for (Integer memberId : members) {
list.add(selectMap2(orgCode, memberId, province, startCreateTime, endCreateTime));
num += CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getProvinceId, provinceId).eq(CrmClientData::getBelongUser, memberId)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime,
startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime,
endCreateTime));
}
map.put("provinceId", provinceId);
String name = SysRegion.builder().build().selectOne(new QueryWrapper<SysRegion>().lambda()
.eq(SysRegion::getLevel, 1).eq(SysRegion::getKeyId, provinceId).select(SysRegion::getRegionName))
.getRegionName();
map.put("provinceName", name);
map.put("num", num);
} else {
list.add(selectMap2(orgCode, belonger, province, startCreateTime, endCreateTime));
num = CrmClientData.builder().build()
.selectCount(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(CrmClientData::getProvinceId, provinceId).eq(CrmClientData::getBelongUser, belonger)
.ge(StringUtils.isNotBlank(startCreateTime), CrmClientData::getCreateTime, startCreateTime)
.le(StringUtils.isNotBlank(endCreateTime), CrmClientData::getCreateTime, endCreateTime));
map.put("provinceId", provinceId);
String name = SysRegion.builder().build().selectOne(new QueryWrapper<SysRegion>().lambda()
.eq(SysRegion::getLevel, 1).eq(SysRegion::getKeyId, provinceId).select(SysRegion::getRegionName))
.getRegionName();
map.put("provinceName", name);
map.put("num", num);
}
return list;
return map;
}
// TODO 统计图
}
......@@ -19,6 +19,6 @@ import cn.timer.api.bean.clazz.ClientSourceClass;
* @date 2020年6月8日
* @version 1.0
*/
public interface CilentSourceClassMapper extends BaseMapper<ClientSourceClass> {
public interface ClientSourceClassMapper extends BaseMapper<ClientSourceClass> {
}
......@@ -19,6 +19,6 @@ import cn.timer.api.bean.clazz.ClientTypeClass;
* @date 2020年6月8日
* @version 1.0
*/
public interface CilentTypeClassMapper extends BaseMapper<ClientTypeClass> {
public interface ClientTypeClassMapper extends BaseMapper<ClientTypeClass> {
}
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