Commit c16b1b64 by 邓实川 Committed by chenzg

客户列表分页 pageNumber,pageSize

parent 8a0d7cd3
......@@ -4,7 +4,6 @@ import java.io.IOException;
import java.io.InputStream;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.Date;
import java.util.HashMap;
......@@ -24,7 +23,9 @@ 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.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.StringUtils;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.date.DateUtil;
......@@ -532,12 +533,20 @@ public class CrmController {
.collect(Collectors.toList());
}
private <T> List<T> getPageList(List<T> list, int pageNumber, int pageSize, Comparator<T> comparator) {
return list.stream().sorted(comparator).skip((pageNumber - 1) * pageSize).limit(pageSize)
.collect(Collectors.toList());
}
@GetMapping("getMyCilentTotal")
@ApiOperation(value = "获取我的客户列表(全)", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CrmClientData>> getMyCilentTotal(@CurrentUser UserBean userBean,
@RequestParam(required = false, defaultValue = "0") Integer type,
@RequestParam(required = false) Integer groupId, @RequestParam(required = false) Integer status,
@RequestParam(required = false) String like) {
@RequestParam(required = false) String like,
@RequestParam(required = false, defaultValue = "1") int pageNumber,
@RequestParam(required = false, defaultValue = "10") int pageSize) {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
List<CrmClientData> crmClientDatas = null;
......@@ -556,8 +565,16 @@ public class CrmController {
crmClientDatas = getCilentFollowOvertime(empNum, orgCode, groupId, status);
else
return ResultUtil.error("查询失败");
Collections.sort(crmClientDatas, Comparator.comparing(CrmClientData::getCreateTime).reversed()); // 按时间降序排序
return ResultUtil.data(crmClientDatas, "查询成功");
// Collections.sort(crmClientDatas, Comparator.comparing(CrmClientData::getCreateTime).reversed()); // 按时间降序排序
// int pageNumber = 1;
// int pageSize = 10;
List<CrmClientData> result = getPageList(crmClientDatas, pageNumber, pageSize,
Comparator.comparing(CrmClientData::getCreateTime).reversed());
return ResultUtil.pageData(result, (long) result.size(), "查询成功");
// return ResultUtil.data(crmClientDatas, "查询成功");
}
private List<Integer> MyJoinGroup(Integer empNum, Integer orgCode) {
......@@ -579,7 +596,9 @@ public class CrmController {
@ApiOperation(value = "获取公海客户列表(全)", httpMethod = "GET", notes = "接口发布说明")
public Result<List<CrmClientData>> getSeaCilentTotal(@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) Integer status, @RequestParam(required = false) String like,
@RequestParam(required = false, defaultValue = "1") int pageNumber,
@RequestParam(required = false, defaultValue = "10") int pageSize) {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
......@@ -603,7 +622,14 @@ public class CrmController {
.like(!StrUtil.isBlank(like), CrmClientData::getClientName, like).or()
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like));
return ResultUtil.data(list, "查询成功");
// int pageNumber = 1;
// int pageSize = 5;
List<CrmClientData> result = getPageList(list, pageNumber, pageSize,
Comparator.comparing(CrmClientData::getCreateTime).reversed());
return ResultUtil.pageData(result, (long) list.size(), "查询成功");
// return ResultUtil.data(list, "查询成功");
} else {
......@@ -625,7 +651,11 @@ public class CrmController {
for (CrmClientData data : datas)
crmClientDatas.add(data);
}
return ResultUtil.data(crmClientDatas, "查询成功");
List<CrmClientData> result = getPageList(crmClientDatas, pageNumber, pageSize,
Comparator.comparing(CrmClientData::getCreateTime).reversed());
return ResultUtil.pageData(result, (long) crmClientDatas.size(), "查询成功");
// return ResultUtil.data(crmClientDatas, "查询成功");
}
}
......@@ -637,7 +667,9 @@ public class CrmController {
@RequestParam(required = false) String startCreateTime,
@RequestParam(required = false) String endCreateTime,
@RequestParam(required = false) String startFollowTime,
@RequestParam(required = false) String endFollowTime) {
@RequestParam(required = false) String endFollowTime,
@RequestParam(required = false, defaultValue = "1") int pageNumber,
@RequestParam(required = false, defaultValue = "10") int pageSize) {
Integer empNum = getEmpNum(userBean);
Integer orgCode = getOrgCode(userBean);
......@@ -653,8 +685,10 @@ public class CrmController {
&& (qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_ADMIN.getType()
|| qyzxEmpEntAsso.getUserType() == SysRoleType.U_TYPE_C_ADMIN.getType())) {
List<CrmClientData> datas = CrmClientData.builder().build()
.selectList(new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
IPage<CrmClientData> page = new Page<CrmClientData>(pageNumber, pageSize);
IPage<CrmClientData> datas = CrmClientData.builder().build().selectPage(page,
new QueryWrapper<CrmClientData>().lambda().eq(CrmClientData::getOrgCode, orgCode)
.eq(groupId != null && groupId >= 0, CrmClientData::getBelongGroup, groupId)
.eq(type != null && type >= 0, CrmClientData::getClientType, type)
.eq(status != null && status >= 0, CrmClientData::getClientStatus, status)
......@@ -664,12 +698,13 @@ public class CrmController {
.le(StringUtils.isNotBlank(endFollowTime), CrmClientData::getCreateTime, endFollowTime)
.like(!StrUtil.isBlank(like), CrmClientData::getClientName, like).or()
.like(!StrUtil.isBlank(like), CrmClientData::getClientCellphone, like));
return ResultUtil.data(datas, "查询成功");
return ResultUtil.pageData(datas.getRecords(), datas.getTotal(), "查询成功");
} else {
// 当前用户管理的组
List<Integer> gids = MyManageGroup(empNum, orgCode);
List<Object> crmClientDatas = new ArrayList<Object>();
List<CrmClientData> crmClientDatas = new ArrayList<CrmClientData>();
for (Integer gid : gids) {
List<CrmClientData> datas = CrmClientData.builder().build().selectList(new QueryWrapper<CrmClientData>()
.lambda().eq(CrmClientData::getBelongGroup, gid)
......@@ -685,7 +720,12 @@ public class CrmController {
for (CrmClientData data : datas)
crmClientDatas.add(data);
}
return ResultUtil.data(crmClientDatas, "查询成功");
List<CrmClientData> result = getPageList(crmClientDatas, pageNumber, pageSize,
Comparator.comparing(CrmClientData::getCreateTime).reversed());
return ResultUtil.pageData(result, (long) crmClientDatas.size(), "查询成功");
// return ResultUtil.data(crmClientDatas, "查询成功");
}
}
......
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