Merge remote-tracking branch 'origin/master'

hehai
jiakun.lin 4 years ago
commit df19430f91
  1. 16
      src/main/java/com/msdw/tms/controller/AchievementManagementController.java
  2. 129
      src/main/java/com/msdw/tms/util/ListPageUtil.java
  3. 113
      src/main/java/com/msdw/tms/util/PageUtils.java
  4. 2
      src/main/resources/mapper/tms/AchievementManagementDao.xml

@ -7,6 +7,8 @@ import com.msdw.tms.entity.vo.AchievementManagementVO;
import com.msdw.tms.entity.vo.ResultsVo; import com.msdw.tms.entity.vo.ResultsVo;
import com.msdw.tms.service.AchievementManagementService; import com.msdw.tms.service.AchievementManagementService;
import com.msdw.tms.service.ProjectRecordService; import com.msdw.tms.service.ProjectRecordService;
import com.msdw.tms.util.ListPageUtil;
import com.msdw.tms.util.PageUtils;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional; import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.*; import org.springframework.web.bind.annotation.*;
@ -90,7 +92,11 @@ public class AchievementManagementController implements AchievementManagementApi
vo.setEndTime(endTime); vo.setEndTime(endTime);
} }
List<ResultsEntity> result = service.list(vo, page, size); List<ResultsEntity> result = service.list(vo, page, size);
return R.ok().put("data", result);
ListPageUtil<ResultsEntity> listPageUtil = new ListPageUtil<ResultsEntity>(result, page, size);
List<ResultsEntity> pagedList = listPageUtil.getPagedList();
PageUtils pageUtils = new PageUtils(pagedList, result.size(), page, size);
return R.ok().put("data", pageUtils);
} }
/** /**
@ -121,7 +127,11 @@ public class AchievementManagementController implements AchievementManagementApi
vo.setEndTime(endTime); vo.setEndTime(endTime);
} }
List<ResultsEntity> result = service.newList(vo, page, size); List<ResultsEntity> result = service.newList(vo, page, size);
return R.ok().put("data", result); /*return R.ok().put("data", result);*/
ListPageUtil<ResultsEntity> listPageUtil = new ListPageUtil<ResultsEntity>(result, page, size);
List<ResultsEntity> pagedList = listPageUtil.getPagedList();
PageUtils pageUtils = new PageUtils(pagedList, result.size(), page, size);
return R.ok().put("data", pageUtils);
} }
/** /**
@ -230,7 +240,7 @@ public class AchievementManagementController implements AchievementManagementApi
@Override @Override
@GetMapping("/exportAchievement") @GetMapping("/exportAchievement")
public void exportAchievement(HttpServletResponse response, @RequestParam String ids, @RequestParam Integer source) throws Exception { public void exportAchievement(HttpServletResponse response, @RequestParam String ids, @RequestParam Integer source) throws Exception {
service.exportAchievement(response, ids,source);//SearchAchievementVo vo service.exportAchievement(response, ids, source);//SearchAchievementVo vo
} }
//成绩管理列表 //成绩管理列表

@ -0,0 +1,129 @@
package com.msdw.tms.util;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
/**
* @ProjectName: gzedu
* @Package: com.huoran.edu.utils
* @ClassName: ListSub
* @Description: 集合分页
* @Author: Maureen.Rong
* @CreateDate: 2020/12/3 18:48
* @UpdateDate: 2020/12/3 18:48
* @Version: 1.0
*/
public class ListPageUtil<T> {
/**
* 原集合
*/
private List<T> data;
/**
* 上一页
*/
private int lastPage;
/**
* 当前页
*/
private int nowPage;
/**
* 下一页
*/
private int nextPage;
/**
* 每页条数
*/
private int pageSize;
/**
* 总页数
*/
private int totalPage;
/**
* 总数据条数
*/
private int totalCount;
public ListPageUtil(List<T> data, int nowPage, int pageSize) {
if (data == null || data.isEmpty()) {
//throw new IllegalArgumentException("暂无数据");
this.data = null;
// this.pageSize = pageSize;
// this.nowPage = nowPage;
// this.totalCount = data.size();
}
this.data = data;
this.pageSize = pageSize;
this.nowPage = nowPage;
this.totalCount = data.size();
this.totalPage = (totalCount + pageSize - 1) / pageSize;
this.lastPage = nowPage - 1 > 1 ? nowPage - 1 : 1;
this.nextPage = nowPage >= totalPage ? totalPage : nowPage + 1;
}
/**
* 得到分页后的数据
*
* @return 分页后结果
*/
public List<T> getPagedList() {
int fromIndex = (nowPage - 1) * pageSize;
if (fromIndex >= data.size()) {
return Collections.emptyList();//空数组
}
if (fromIndex < 0) {
return Collections.emptyList();//空数组
}
int toIndex = nowPage * pageSize;
if (toIndex >= data.size()) {
toIndex = data.size();
}
return data.subList(fromIndex, toIndex);
}
public int getPageSize() {
return pageSize;
}
public List<T> getData() {
return data;
}
public int getLastPage() {
return lastPage;
}
public int getNowPage() {
return nowPage;
}
public int getNextPage() {
return nextPage;
}
public int getTotalPage() {
return totalPage;
}
public int getTotalCount() {
return totalCount;
}
public static void main(String[] args) {
Integer[] array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12};
List<Integer> list = Arrays.asList(array);
ListPageUtil<Integer> listPageUtil = new ListPageUtil<Integer>(list, 1, 4);
List<Integer> pagedList = listPageUtil.getPagedList();
System.out.println(pagedList);
}
}

@ -0,0 +1,113 @@
/**
* Copyright (c) 2016-2019 人人开源 All rights reserved.
* <p>
* https://www.renren.io
* <p>
* 版权所有侵权必究
*/
package com.msdw.tms.util;
import com.baomidou.mybatisplus.core.metadata.IPage;
import lombok.Data;
import java.io.Serializable;
import java.util.List;
/**
* 分页工具类
*
* @author Mark sunlightcs@gmail.com
*/
@Data
public class PageUtils implements Serializable {
private static final long serialVersionUID = 1L;
/**
* 总记录数
*/
private int totalCount;
/**
* 每页记录数
*/
private int pageSize;
/**
* 总页数
*/
private int totalPage;
/**
* 当前页数
*/
private int currPage;
/**
* 列表数据
*/
private List<?> list;
/**
* 分页
*
* @param list 列表数据
* @param totalCount 总记录数
* @param pageSize 每页记录数
* @param currPage 当前页数
*/
public PageUtils(List<?> list, int totalCount, int pageSize, int currPage) {
this.list = list;
this.totalCount = totalCount;
this.pageSize = pageSize;
this.currPage = currPage;
this.totalPage = (int) Math.ceil((double) totalCount / pageSize);
}
/**
* 分页
*/
public PageUtils(IPage<?> page) {
this.list = page.getRecords();
this.totalCount = (int) page.getTotal();
this.pageSize = (int) page.getSize();
this.currPage = (int) page.getCurrent();
this.totalPage = (int) page.getPages();
}
public int getTotalCount() {
return totalCount;
}
public void setTotalCount(int totalCount) {
this.totalCount = totalCount;
}
public int getPageSize() {
return pageSize;
}
public void setPageSize(int pageSize) {
this.pageSize = pageSize;
}
public int getTotalPage() {
return totalPage;
}
public void setTotalPage(int totalPage) {
this.totalPage = totalPage;
}
public int getCurrPage() {
return currPage;
}
public void setCurrPage(int currPage) {
this.currPage = currPage;
}
public List<?> getList() {
return list;
}
public void setList(List<?> list) {
this.list = list;
}
}

@ -502,7 +502,7 @@
hr_project_management pm on et.project_id = pm.projectId hr_project_management pm on et.project_id = pm.projectId
WHERE WHERE
user_id = #{userId} user_id = #{userId}
AND pm.isdel = 0 /*AND pm.isdel = 0*/
<if test="searchContant!=null and searchContant!=''">and et.experimental_class_name like <if test="searchContant!=null and searchContant!=''">and et.experimental_class_name like
concat('%',#{searchContant},'%') or et.experimental_name like concat('%',#{searchContant},'%') or concat('%',#{searchContant},'%') or et.experimental_name like concat('%',#{searchContant},'%') or
pm.projectName like concat('%',#{searchContant},'%') pm.projectName like concat('%',#{searchContant},'%')

Loading…
Cancel
Save