Commit 226604c9 authored by mlchun's avatar mlchun

1.部分接口分页处理

parent f589bb98
package io.hmit.modules.serviceOrder.controller; package io.hmit.modules.serviceOrder.controller;
import com.sun.xml.internal.bind.v2.TODO;
import io.hmit.annotation.Login; import io.hmit.annotation.Login;
import io.hmit.annotation.LoginUser; import io.hmit.annotation.LoginUser;
import io.hmit.common.constant.Constant; import io.hmit.common.constant.Constant;
......
...@@ -6,12 +6,10 @@ import io.hmit.common.constant.Constant; ...@@ -6,12 +6,10 @@ import io.hmit.common.constant.Constant;
import io.hmit.common.page.PageData; import io.hmit.common.page.PageData;
import io.hmit.common.service.impl.CrudServiceImpl; import io.hmit.common.service.impl.CrudServiceImpl;
import io.hmit.common.utils.ConvertUtils; import io.hmit.common.utils.ConvertUtils;
import io.hmit.dao.UserDao;
import io.hmit.entity.UserEntity; import io.hmit.entity.UserEntity;
import io.hmit.modules.serviceOrder.dao.PensionOrderDao; import io.hmit.modules.serviceOrder.dao.PensionOrderDao;
import io.hmit.modules.serviceOrder.dto.PensionOrderDTO; import io.hmit.modules.serviceOrder.dto.PensionOrderDTO;
import io.hmit.modules.serviceOrder.dto.PensionOrderServiceDTO; import io.hmit.modules.serviceOrder.dto.PensionOrderServiceDTO;
import io.hmit.modules.serviceOrder.dto.ReservationDTO;
import io.hmit.modules.serviceOrder.entity.PensionOrderEntity; import io.hmit.modules.serviceOrder.entity.PensionOrderEntity;
import io.hmit.modules.serviceOrder.service.PensionOrderService; import io.hmit.modules.serviceOrder.service.PensionOrderService;
import io.hmit.modules.serviceOrder.service.PensionOrderServiceService; import io.hmit.modules.serviceOrder.service.PensionOrderServiceService;
...@@ -113,7 +111,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe ...@@ -113,7 +111,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
@Override @Override
public PageData<PensionOrderDTO> getElderAllOrderOrByStatusPage(Map<String, Object> params, Long creator, Integer status) { public PageData<PensionOrderDTO> getElderAllOrderOrByStatusPage(Map<String, Object> params, Long creator, Integer status) {
IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false); // IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false);
List<PensionOrderDTO> list = new ArrayList<>(); List<PensionOrderDTO> list = new ArrayList<>();
if (null == status) { if (null == status) {
list = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, status); list = pensionOrderDao.getElderAllOrderOrByStatusList(params, creator, status);
...@@ -125,8 +123,8 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe ...@@ -125,8 +123,8 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
list.addAll(list1); list.addAll(list1);
list.addAll(list2); list.addAll(list2);
} }
page.setTotal(list.size()); // page.setTotal(list.size());
return getPageData(list, page.getTotal(), PensionOrderDTO.class); return getPageData(getSubList(params, list), list.size(), PensionOrderDTO.class);
} }
@Override @Override
...@@ -146,7 +144,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe ...@@ -146,7 +144,7 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
@Override @Override
public PageData<PensionOrderDTO> getOrganizationOrder(Map<String, Object> params, Long userId) { public PageData<PensionOrderDTO> getOrganizationOrder(Map<String, Object> params, Long userId) {
//登录->查询登录人员所属机构ID->机构ID查询服务ID(List)->服务ID + 状态查询订单(List) //登录->查询登录人员所属机构ID->机构ID查询服务ID(List)->服务ID + 状态查询订单(List)
IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false); // IPage<PensionOrderEntity> page = getPage(params, Constant.CREATE_DATE, false);
List<Long> serviceIds = pensionOrganizationService.findServiceIdListByServiceUserId(userId); List<Long> serviceIds = pensionOrganizationService.findServiceIdListByServiceUserId(userId);
Integer status = null; Integer status = null;
if (null != params.get("status")) { if (null != params.get("status")) {
...@@ -157,8 +155,9 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe ...@@ -157,8 +155,9 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
List<PensionOrderDTO> list = pensionOrderDao.getAllOrderByServiceId(id, status); List<PensionOrderDTO> list = pensionOrderDao.getAllOrderByServiceId(id, status);
result.addAll(list); result.addAll(list);
} }
page.setTotal(result.size()); // page.setTotal(result.size());
return getPageData(result, page.getTotal(), PensionOrderDTO.class);
return getPageData(getSubList(params, result), result.size(), PensionOrderDTO.class);
} }
@Override @Override
...@@ -201,4 +200,23 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe ...@@ -201,4 +200,23 @@ public class PensionOrderServiceImpl extends CrudServiceImpl<PensionOrderDao, Pe
return true; return true;
} }
//对List进行手动分页
private List<PensionOrderDTO> getSubList(Map<String, Object> params, List<PensionOrderDTO> list){
Integer pageNum = Integer.parseInt(params.get("page").toString());
Integer pageSize = Integer.parseInt(params.get("limit").toString());
Integer count = list.size();
Integer pageNo = (pageNum - 1) * pageSize;
List<PensionOrderDTO> list2 ;
if (pageNo+pageSize > count) {
if (pageNo > count){
list2 = null;
}else {
list2 = list.subList(pageNo, count);
}
}else {
list2 = list.subList(pageNo, pageNo+pageSize);
}
return list2;
}
} }
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