Browse Source

单位主体分页排序、示范项目分页排序

master
Jinyuanyuan 5 months ago
parent
commit
58d0d8e9e7
  1. 27
      huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java
  2. 6
      huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouProjectinfoMapper.java
  3. 100
      huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/mapping/HuzhouProjectinfoMapper.xml
  4. 90
      huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java

27
huzhou/src/main/java/com/easy/admin/modules/huzhou/controller/HuzhouProjectController.java

@ -25,6 +25,7 @@ import java.time.ZoneId;
import java.time.temporal.ChronoUnit; import java.time.temporal.ChronoUnit;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Objects;
@RestController @RestController
@ -199,8 +200,13 @@ public class HuzhouProjectController {
public Result<?> getDimensionPageSorted(HuzhouProjectinfo projectInfo, public Result<?> getDimensionPageSorted(HuzhouProjectinfo projectInfo,
@RequestParam(name="current", defaultValue="1") Integer pageNo, @RequestParam(name="current", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name="orderBy", defaultValue="duty_workplace") String orderBy, @RequestParam(name="sortField", defaultValue="duty_workplace") String orderBy,
@RequestParam(name="orderDir", defaultValue="desc") String orderDir){ @RequestParam(name="sortOrder", defaultValue="desc") String orderDir){
if(Objects.equals(orderDir, "descend")){
orderDir="desc";
} else if (Objects.equals(orderDir, "ascend")) {
orderDir="asc";
}
IPage<DimensionPageResponse> dimensionPage = projectinfoService.getDimensionPage(projectInfo, pageNo, pageSize, orderBy, orderDir); IPage<DimensionPageResponse> dimensionPage = projectinfoService.getDimensionPage(projectInfo, pageNo, pageSize, orderBy, orderDir);
return Result.OK(dimensionPage); return Result.OK(dimensionPage);
@ -214,8 +220,13 @@ public class HuzhouProjectController {
public Result<?> getPageSorted(HuzhouProjectinfo projectInfo, public Result<?> getPageSorted(HuzhouProjectinfo projectInfo,
@RequestParam(name="current", defaultValue="1") Integer pageNo, @RequestParam(name="current", defaultValue="1") Integer pageNo,
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize, @RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
@RequestParam(name="orderBy", defaultValue="duty_workplace") String orderBy, @RequestParam(name="sortField", defaultValue="duty_workplace") String orderBy,
@RequestParam(name="orderDir", defaultValue="desc") String orderDir){ @RequestParam(name="sortOrder", defaultValue="desc") String orderDir){
if(Objects.equals(orderDir, "descend")){
orderDir="desc";
} else if (Objects.equals(orderDir, "ascend")) {
orderDir="asc";
}
IPage<ProjectPageResponse> projectPage = projectinfoService.getProjectPage(projectInfo, pageNo, pageSize, orderBy, orderDir); IPage<ProjectPageResponse> projectPage = projectinfoService.getProjectPage(projectInfo, pageNo, pageSize, orderBy, orderDir);
return Result.OK(projectPage); return Result.OK(projectPage);
} }
@ -228,16 +239,16 @@ public class HuzhouProjectController {
} }
@GetMapping("/showCountBoardByReformName") @GetMapping("/showCountBoardByReformName")
public Result<?> showCountBoardByReformName(@RequestParam(name="orderBy",defaultValue="") String orderBy, public Result<?> showCountBoardByReformName(@RequestParam(name="sortField",defaultValue="") String orderBy,
@RequestParam(name="orderDir",defaultValue="") String orderDir){ @RequestParam(name="sortOrder",defaultValue="") String orderDir){
String condition="reformName"; String condition="reformName";
CountByConditionOV result = projectinfoService.countByCondition(condition,orderBy,orderDir); CountByConditionOV result = projectinfoService.countByCondition(condition,orderBy,orderDir);
return Result.ok(result); return Result.ok(result);
} }
@GetMapping("/showCountBoardByAdminDivision") @GetMapping("/showCountBoardByAdminDivision")
public Result<?> showCountBoardByAdminDivision(@RequestParam(name="orderBy",defaultValue="") String orderBy, public Result<?> showCountBoardByAdminDivision(@RequestParam(name="sortField",defaultValue="") String orderBy,
@RequestParam(name="orderDir",defaultValue="") String orderDir){ @RequestParam(name="sortOrder",defaultValue="") String orderDir){
String condition="adminDivision"; String condition="adminDivision";
CountByConditionOV result = projectinfoService.countByCondition(condition,orderBy,orderDir); CountByConditionOV result = projectinfoService.countByCondition(condition,orderBy,orderDir);
return Result.ok(result); return Result.ok(result);

6
huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/HuzhouProjectinfoMapper.java

@ -60,17 +60,21 @@ public interface HuzhouProjectinfoMapper extends BaseMapper<HuzhouProjectinfo> {
*/ */
IPage<DimensionPageOV> getDimensionPageSorted(Page page, @Param("info") HuzhouProjectinfo info, @Param("orderBy") String orderBy, @Param("orderDir") String orderDir); IPage<DimensionPageOV> getDimensionPageSorted(Page page, @Param("info") HuzhouProjectinfo info, @Param("orderBy") String orderBy, @Param("orderDir") String orderDir);
IPage<DimensionPageOV> getDimensionPageNoSorted(Page page, @Param("info") HuzhouProjectinfo info);
/** /**
* 获取项目信息列表(排序) * 获取项目信息列表(排序)
* @param info 查询条件 * @param info 查询条件
* @return List<HuzhouProjectinfoOV> * @return List<HuzhouProjectinfoOV>
*/ */
IPage<ProjectPageOV> getProjectPageSorted(Page page, @Param("info") HuzhouProjectinfo info, @Param("orderBy") String orderBy, @Param("orderDir") String orderDir); IPage<ProjectPageOV> getProjectPageSorted(Page page, @Param("info") HuzhouProjectinfo info, @Param("orderBy") String orderBy, @Param("orderDir") String orderDir);
IPage<ProjectPageOV> getProjectPageNoSorted(Page page, @Param("info") HuzhouProjectinfo info);
List<HuzhouProjectinfoOV> getListByCondition(@Param("info") HuzhouProjectinfo info,@Param("condition") String condition); List<HuzhouProjectinfoOV> getListByCondition(@Param("info") HuzhouProjectinfo info,@Param("condition") String condition);
List<NumByTypeOV> getNumByType(@Param("info") HuzhouProjectinfo info); List<NumByTypeOV> getNumByType(@Param("info") HuzhouProjectinfo info);
//根据一组项目id返回总金额、总中央资金、总省级资金 //根据一组项目id返回总金额、总中央资金、总省级资金
Map<String, BigDecimal> getTotalByProjectIds(@Param("projectIds") List<String> projectIds); Map<String, BigDecimal> getTotalByProjectIds(@Param("projectIds") List<String> projectIds);
List<HuzhouProjectinfoOV> getListByConditions(@Param("info") HuzhouProjectinfo info);
} }

100
huzhou/src/main/java/com/easy/admin/modules/huzhou/dao/mapping/HuzhouProjectinfoMapper.xml

@ -247,29 +247,47 @@ order by create_date desc
sum(provincial_money) as provincialMoney from huzhou_projectinfo sum(provincial_money) as provincialMoney from huzhou_projectinfo
<where> <where>
<include refid="selectAuthSql"/> <include refid="selectAuthSql"/>
<if test="info.projectName!=null and info.projectName!=''">
<bind name="tempStr" value="'%' + info.projectName + '%'" />
and project_name like #{tempStr}
</if>
<if test="info.adminDivision!=null and info.adminDivision!=''"> <if test="info.adminDivision!=null and info.adminDivision!=''">
<bind name="tempStr" value="'%' + info.adminDivision + '%'" /> <bind name="tempStr1" value="'%' + info.adminDivision + '%'" />
and admin_division like #{tempStr} and admin_division like #{tempStr1}
</if> </if>
<if test="info.dutyWorkplace!=null and info.dutyWorkplace!=''"> <if test="info.dutyWorkplace!=null and info.dutyWorkplace!=''">
<bind name="tempStr" value="'%' + info.dutyWorkplace + '%'" /> <bind name="tempStr2" value="'%' + info.dutyWorkplace + '%'" />
and duty_workplace like #{tempStr} and duty_workplace like #{tempStr2}
</if> </if>
<if test="info.workplaceProperties!=null and info.workplaceProperties!=''"> <if test="info.workplaceProperties!=null and info.workplaceProperties!=''">
<bind name="tempStr" value="'%' + info.workplaceProperties + '%'" /> <bind name="tempStr3" value="'%' + info.workplaceProperties + '%'" />
and workplace_properties like #{tempStr} and workplace_properties like #{tempStr3}
</if>
<if test="info.superLeader!=null and info.superLeader!=''">
and super_leader = #{info.superLeader}
</if>
<if test="info.type!=null and info.type!=''">
and type = #{info.type}
</if>
</where>
group by duty_workplace,admin_division,workplace_properties,super_leader
order by ${orderBy} ${orderDir}
</select>
<select id="getDimensionPageNoSorted" resultMap="dimensionPageMap" parameterType="com.easy.admin.modules.huzhou.entity.HuzhouProjectinfo">
SELECT duty_workplace as dutyWorkplace,admin_division as adminDivision,workplace_properties as workplaceProperties,super_leader as superLeader,
sum(total_money) as totalMoney,
sum(central_money) as centralMoney,
sum(provincial_money) as provincialMoney from huzhou_projectinfo
<where>
<include refid="selectAuthSql"/>
<if test="info.adminDivision!=null and info.adminDivision!=''">
<bind name="tempStr1" value="'%' + info.adminDivision + '%'" />
and admin_division like #{tempStr1}
</if> </if>
<if test="info.dutyWorkplace!=null and info.dutyWorkplace!=''"> <if test="info.dutyWorkplace!=null and info.dutyWorkplace!=''">
<bind name="tempStr" value="'%' + info.dutyWorkplace + '%'" /> <bind name="tempStr2" value="'%' + info.dutyWorkplace + '%'" />
and duty_workplace like #{tempStr} and duty_workplace like #{tempStr2}
</if> </if>
<if test="info.reformName!=null and info.reformName!=''"> <if test="info.workplaceProperties!=null and info.workplaceProperties!=''">
and reform_name = #{info.reformName} <bind name="tempStr3" value="'%' + info.workplaceProperties + '%'" />
and workplace_properties like #{tempStr3}
</if> </if>
<if test="info.superLeader!=null and info.superLeader!=''"> <if test="info.superLeader!=null and info.superLeader!=''">
and super_leader = #{info.superLeader} and super_leader = #{info.superLeader}
@ -279,7 +297,6 @@ order by create_date desc
</if> </if>
</where> </where>
group by duty_workplace,admin_division,workplace_properties,super_leader group by duty_workplace,admin_division,workplace_properties,super_leader
order by ${orderBy} ${orderDir}
</select> </select>
<select id="getProjectPageSorted" resultMap="projectPageMap" parameterType="com.easy.admin.modules.huzhou.entity.HuzhouProjectinfo"> <select id="getProjectPageSorted" resultMap="projectPageMap" parameterType="com.easy.admin.modules.huzhou.entity.HuzhouProjectinfo">
SELECT id as id,project_name as projectName,duty_workplace as dutyWorkplace,admin_division as adminDivision,workplace_properties as workplaceProperties,super_leader as superLeader, SELECT id as id,project_name as projectName,duty_workplace as dutyWorkplace,admin_division as adminDivision,workplace_properties as workplaceProperties,super_leader as superLeader,
@ -288,11 +305,6 @@ order by create_date desc
provincial_money as provincialMoney from huzhou_projectinfo provincial_money as provincialMoney from huzhou_projectinfo
<where> <where>
<include refid="selectAuthSql"/> <include refid="selectAuthSql"/>
<if test="info.projectName!=null and info.projectName!=''">
<bind name="tempStr" value="'%' + info.projectName + '%'" />
and project_name like #{tempStr}
</if>
<if test="info.adminDivision!=null and info.adminDivision!=''"> <if test="info.adminDivision!=null and info.adminDivision!=''">
<bind name="tempStr" value="'%' + info.adminDivision + '%'" /> <bind name="tempStr" value="'%' + info.adminDivision + '%'" />
and admin_division like #{tempStr} and admin_division like #{tempStr}
@ -305,12 +317,33 @@ order by create_date desc
<bind name="tempStr" value="'%' + info.workplaceProperties + '%'" /> <bind name="tempStr" value="'%' + info.workplaceProperties + '%'" />
and workplace_properties like #{tempStr} and workplace_properties like #{tempStr}
</if> </if>
<if test="info.superLeader!=null and info.superLeader!=''">
and super_leader = #{info.superLeader}
</if>
<if test="info.type!=null and info.type!=''">
and type = #{info.type}
</if>
</where>
order by ${orderBy} ${orderDir}
</select>
<select id="getProjectPageNoSorted" resultMap="projectPageMap" parameterType="com.easy.admin.modules.huzhou.entity.HuzhouProjectinfo">
SELECT id as id,project_name as projectName,duty_workplace as dutyWorkplace,admin_division as adminDivision,workplace_properties as workplaceProperties,super_leader as superLeader,
total_money as totalMoney,
central_money as centralMoney,
provincial_money as provincialMoney from huzhou_projectinfo
<where>
<include refid="selectAuthSql"/>
<if test="info.adminDivision!=null and info.adminDivision!=''">
<bind name="tempStr" value="'%' + info.adminDivision + '%'" />
and admin_division like #{tempStr}
</if>
<if test="info.dutyWorkplace!=null and info.dutyWorkplace!=''"> <if test="info.dutyWorkplace!=null and info.dutyWorkplace!=''">
<bind name="tempStr" value="'%' + info.dutyWorkplace + '%'" /> <bind name="tempStr" value="'%' + info.dutyWorkplace + '%'" />
and duty_workplace like #{tempStr} and duty_workplace like #{tempStr}
</if> </if>
<if test="info.reformName!=null and info.reformName!=''"> <if test="info.workplaceProperties!=null and info.workplaceProperties!=''">
and reform_name = #{info.reformName} <bind name="tempStr" value="'%' + info.workplaceProperties + '%'" />
and workplace_properties like #{tempStr}
</if> </if>
<if test="info.superLeader!=null and info.superLeader!=''"> <if test="info.superLeader!=null and info.superLeader!=''">
and super_leader = #{info.superLeader} and super_leader = #{info.superLeader}
@ -319,7 +352,6 @@ order by create_date desc
and type = #{info.type} and type = #{info.type}
</if> </if>
</where> </where>
order by ${orderBy} ${orderDir}
</select> </select>
<select id="getListByCondition" resultMap="HuzhouProjectinfoMap"> <select id="getListByCondition" resultMap="HuzhouProjectinfoMap">
SELECT * from huzhou_projectinfo u SELECT * from huzhou_projectinfo u
@ -335,6 +367,7 @@ order by create_date desc
</if> </if>
group by ${condition} group by ${condition}
</select> </select>
<select id="getNumByType" resultMap="NumByTypeMap"> <select id="getNumByType" resultMap="NumByTypeMap">
SELECT type,count(*) from huzhou_projectinfo u SELECT type,count(*) from huzhou_projectinfo u
<where> <where>
@ -358,4 +391,25 @@ order by create_date desc
#{projectId} #{projectId}
</foreach> </foreach>
</select> </select>
<select id="getListByConditions" resultMap="HuzhouProjectinfoMap" parameterType="com.easy.admin.modules.huzhou.entity.HuzhouProjectinfo">
SELECT * from huzhou_projectinfo u
<where>
<include refid="selectAuthSql"/>
<if test="info.adminDivision!=null and info.adminDivision!=''">
and u.admin_division = #{info.adminDivision}
</if>
<if test="info.dutyWorkplace!=null and info.dutyWorkplace!=''">
and u.duty_workplace = #{info.dutyWorkplace}
</if>
<if test="info.workplaceProperties!=null and info.workplaceProperties!=''">
and u.workplace_properties = #{info.workplaceProperties}
</if>
<if test="info.superLeader!=null and info.superLeader!=''">
and u.super_leader = #{info.superLeader}
</if>
<if test="info.type!=null and info.type!=''">
and type = #{info.type}
</if>
</where>
</select>
</mapper> </mapper>

90
huzhou/src/main/java/com/easy/admin/modules/huzhou/service/impl/HuzhouProjectinfoServiceImpl.java

@ -762,6 +762,16 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl<HuzhouProjectinfoM
int unfininshNum = 0; int unfininshNum = 0;
double progress = 0.00; double progress = 0.00;
String formatted = "0.00"; String formatted = "0.00";
//测试
// List<String> test=new ArrayList<>();
// test.add("1787757791784607745");
// List<HuzhouPlaninfo> t = planinfoService.listByProjectIds(test);
// fininshNum = (int) t.stream().filter(x -> (x.getIsfinish().equals("2"))).count();
// unfininshNum = t.size() - fininshNum;
// progress = (double) fininshNum / t.size();
// formatted = String.format("%.2f", progress);
if (Ids.size() != 0) { if (Ids.size() != 0) {
List<HuzhouPlaninfo> planInfoList = planinfoService.listByProjectIds(Ids); List<HuzhouPlaninfo> planInfoList = planinfoService.listByProjectIds(Ids);
fininshNum = (int) planInfoList.stream().filter(x -> (x.getIsfinish().equals("2"))).count(); fininshNum = (int) planInfoList.stream().filter(x -> (x.getIsfinish().equals("2"))).count();
@ -900,27 +910,37 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl<HuzhouProjectinfoM
@Override @Override
public IPage<DimensionPageResponse> getDimensionPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize, String orderBy, String orderDir) { public IPage<DimensionPageResponse> getDimensionPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize, String orderBy, String orderDir) {
Page page = new Page(pageNo, pageSize); // Page page1 = new Page(pageNo, pageSize);
//只要入库项目 //只要入库项目
projectInfo.setType("1"); projectInfo.setType("1");
ProjectInfoAuthSelect projectInfoAuthSelect = CommonUtils.setGetProjectInfoAuth(projectInfo); ProjectInfoAuthSelect projectInfoAuthSelect = CommonUtils.setGetProjectInfoAuth(projectInfo);
//获取全部 //获取全部
Page page = new Page(1, 1000);
IPage<DimensionPageOV> pageSorted = projectinfoMapper.getDimensionPageSorted(page, projectInfoAuthSelect, orderBy, orderDir); IPage<DimensionPageOV> pageSorted;
if((Objects.equals(orderBy, "paymentExecutionRate"))||(Objects.equals(orderBy, "superiorFundExecutionRate"))||Objects.equals(orderBy, "projectProgress")){
pageSorted = projectinfoMapper.getDimensionPageNoSorted(page,projectInfoAuthSelect);
}else {
pageSorted = projectinfoMapper.getDimensionPageSorted(page,projectInfoAuthSelect, orderBy, orderDir);
}
List<DimensionPageOV> records = pageSorted.getRecords(); List<DimensionPageOV> records = pageSorted.getRecords();
List<DimensionPageResponse> newRecords = new ArrayList<>(); List<DimensionPageResponse> newRecords = new ArrayList<>();
IPage<DimensionPageResponse> result = new Page<>(); IPage<DimensionPageResponse> result = new Page<>();
LambdaQueryWrapper<HuzhouProjectinfo> queryWrapper = new LambdaQueryWrapper<>(); HuzhouProjectinfo info =new HuzhouProjectinfo();
List<String> projectIds = new ArrayList<>();
for (DimensionPageOV r : records) { for (DimensionPageOV r : records) {
queryWrapper.eq(HuzhouProjectinfo::getDutyWorkplace, r.getDutyWorkplace()).eq(HuzhouProjectinfo::getAdminDivision, r.getAdminDivision()) info.setAdminDivision(r.getAdminDivision());
.eq(HuzhouProjectinfo::getWorkplaceProperties, r.getWorkplaceProperties()).eq(HuzhouProjectinfo::getSuperLeader, r.getSuperLeader()); info.setDutyWorkplace(r.getDutyWorkplace());
projectIds.addAll(projectinfoMapper.selectList(queryWrapper).stream().map(x -> x.getId()).collect(Collectors.toList())); info.setWorkplaceProperties(r.getWorkplaceProperties());
NewFundOV fund = this.getFund(projectIds); info.setSuperLeader(r.getSuperLeader());
info.setType("1");
ProjectInfoAuthSelect projectInfoAuthSelect1 = CommonUtils.setGetProjectInfoAuth(info);
List<HuzhouProjectinfoOV> listByConditions = projectinfoMapper.getListByConditions(projectInfoAuthSelect1);
List<String> projectIds = listByConditions.stream().map(x -> x.getId()).collect(Collectors.toList());
//进度
ProjectProgressOV progress = this.getProgress(projectIds); ProjectProgressOV progress = this.getProgress(projectIds);
//按单位划分的各类资金总额和执行率情况
NewFundOV fund = this.getFund(projectIds);
DimensionPageResponse build = new DimensionPageResponse(); DimensionPageResponse build = new DimensionPageResponse();
BeanUtils.copyProperties(r, build); BeanUtils.copyProperties(r, build);
BigDecimal totalDecimal = BigDecimal.valueOf(r.getTotalMoney()); BigDecimal totalDecimal = BigDecimal.valueOf(r.getTotalMoney());
@ -938,17 +958,41 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl<HuzhouProjectinfoM
.setProjectProgress(progress.getProjectProgress()); .setProjectProgress(progress.getProjectProgress());
newRecords.add(newRecord); newRecords.add(newRecord);
} }
result.setSize(pageSorted.getSize()).setCurrent(pageSorted.getCurrent()).setRecords(newRecords).setTotal(pageSorted.getTotal()); //资金执行率和上级资金执行率排序
List<DimensionPageResponse> sortedDimensionPageResponse = newRecords.stream().sorted(Comparator.comparing(DimensionPageResponse::getPaymentExecutionRate).reversed()).collect(Collectors.toList());;
if (Objects.equals(orderBy, "paymentExecutionRate")&& Objects.equals(orderDir, "desc")){
sortedDimensionPageResponse=newRecords.stream().sorted(Comparator.comparing(DimensionPageResponse::getPaymentExecutionRate).reversed()).collect(Collectors.toList());
} else if (Objects.equals(orderBy, "paymentExecutionRate") && Objects.equals(orderDir, "asc")) {
sortedDimensionPageResponse=newRecords.stream().sorted(Comparator.comparing(DimensionPageResponse::getPaymentExecutionRate)).collect(Collectors.toList());
}else if (Objects.equals(orderBy, "superiorFundExecutionRate")&& Objects.equals(orderDir, "desc")){
sortedDimensionPageResponse=newRecords.stream().sorted(Comparator.comparing(DimensionPageResponse::getSuperiorFundExecutionRate).reversed()).collect(Collectors.toList());
} else if (Objects.equals(orderBy, "superiorFundExecutionRate") && Objects.equals(orderDir, "asc")) {
sortedDimensionPageResponse=newRecords.stream().sorted(Comparator.comparing(DimensionPageResponse::getSuperiorFundExecutionRate)).collect(Collectors.toList());
}else if (Objects.equals(orderBy, "projectProgress")&& Objects.equals(orderDir, "desc")){
sortedDimensionPageResponse=newRecords.stream().sorted(Comparator.comparing(DimensionPageResponse::getProjectProgress).reversed()).collect(Collectors.toList());
} else if (Objects.equals(orderBy, "projectProgress") && Objects.equals(orderDir, "asc")) {
sortedDimensionPageResponse=newRecords.stream().sorted(Comparator.comparing(DimensionPageResponse::getProjectProgress)).collect(Collectors.toList());
}
//手动分页
int fromIndex = (pageNo - 1) * pageSize;
List<DimensionPageResponse> currentPageData = sortedDimensionPageResponse.subList(fromIndex, Math.min(fromIndex + pageSize, sortedDimensionPageResponse.size()));
result.setSize(pageSize).setCurrent(pageNo).setRecords(currentPageData).setTotal(pageSorted.getTotal());
return result; return result;
} }
@Override @Override
public IPage<ProjectPageResponse> getProjectPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize, String orderBy, String orderDir) { public IPage<ProjectPageResponse> getProjectPage(HuzhouProjectinfo projectInfo, Integer pageNo, Integer pageSize, String orderBy, String orderDir) {
Page page = new Page(pageNo, pageSize);
//只要入库项目 //只要入库项目
projectInfo.setType("1"); projectInfo.setType("1");
ProjectInfoAuthSelect projectInfoAuthSelect = CommonUtils.setGetProjectInfoAuth(projectInfo); ProjectInfoAuthSelect projectInfoAuthSelect = CommonUtils.setGetProjectInfoAuth(projectInfo);
IPage<ProjectPageOV> pageSorted = projectinfoMapper.getProjectPageSorted(page, projectInfoAuthSelect, orderBy, orderDir); Page page = new Page(1, 1000);
IPage<ProjectPageOV> pageSorted;
if((Objects.equals(orderBy, "paymentExecutionRate"))||(Objects.equals(orderBy, "superiorFundExecutionRate"))||Objects.equals(orderBy, "projectProgress")){
pageSorted = projectinfoMapper.getProjectPageNoSorted(page,projectInfoAuthSelect);
}else {
pageSorted = projectinfoMapper.getProjectPageSorted(page, projectInfoAuthSelect, orderBy, orderDir);
}
List<ProjectPageOV> records = pageSorted.getRecords(); List<ProjectPageOV> records = pageSorted.getRecords();
List<ProjectPageResponse> newRecords = new ArrayList<>(); List<ProjectPageResponse> newRecords = new ArrayList<>();
IPage<ProjectPageResponse> result = new Page<>(); IPage<ProjectPageResponse> result = new Page<>();
@ -974,7 +1018,25 @@ public class HuzhouProjectinfoServiceImpl extends ServiceImpl<HuzhouProjectinfoM
.setProjectProgress(progress.getProjectProgress()); .setProjectProgress(progress.getProjectProgress());
newRecords.add(newRecord); newRecords.add(newRecord);
} }
result.setSize(pageSorted.getSize()).setCurrent(pageSorted.getCurrent()).setRecords(newRecords).setTotal(pageSorted.getTotal()); //资金执行率和上级资金执行率排序
List<ProjectPageResponse> sortedProjectPageResponse = newRecords.stream().sorted(Comparator.comparing(ProjectPageResponse::getPaymentExecutionRate).reversed()).collect(Collectors.toList());;
if (Objects.equals(orderBy, "paymentExecutionRate")&& Objects.equals(orderDir, "desc")){
sortedProjectPageResponse=newRecords.stream().sorted(Comparator.comparing(ProjectPageResponse::getPaymentExecutionRate).reversed()).collect(Collectors.toList());
} else if (Objects.equals(orderBy, "paymentExecutionRate") && Objects.equals(orderDir, "asc")) {
sortedProjectPageResponse=newRecords.stream().sorted(Comparator.comparing(ProjectPageResponse::getPaymentExecutionRate)).collect(Collectors.toList());
}else if (Objects.equals(orderBy, "superiorFundExecutionRate")&& Objects.equals(orderDir, "desc")){
sortedProjectPageResponse=newRecords.stream().sorted(Comparator.comparing(ProjectPageResponse::getSuperiorFundExecutionRate).reversed()).collect(Collectors.toList());
} else if (Objects.equals(orderBy, "superiorFundExecutionRate") && Objects.equals(orderDir, "asc")) {
sortedProjectPageResponse=newRecords.stream().sorted(Comparator.comparing(ProjectPageResponse::getSuperiorFundExecutionRate)).collect(Collectors.toList());
}else if (Objects.equals(orderBy, "projectProgress")&& Objects.equals(orderDir, "desc")){
sortedProjectPageResponse=newRecords.stream().sorted(Comparator.comparing(ProjectPageResponse::getProjectProgress).reversed()).collect(Collectors.toList());
} else if (Objects.equals(orderBy, "projectProgress") && Objects.equals(orderDir, "asc")) {
sortedProjectPageResponse=newRecords.stream().sorted(Comparator.comparing(ProjectPageResponse::getProjectProgress)).collect(Collectors.toList());
}
//手动分页
int fromIndex = (pageNo - 1) * pageSize;
List<ProjectPageResponse> currentPageData = sortedProjectPageResponse.subList(fromIndex, Math.min(fromIndex + pageSize, sortedProjectPageResponse.size()));
result.setSize(pageSorted.getSize()).setCurrent(pageSorted.getCurrent()).setRecords(currentPageData).setTotal(pageSorted.getTotal());
return result; return result;
} }

Loading…
Cancel
Save