月报标题模板
This commit is contained in:
+16
-2
@@ -53,8 +53,9 @@ public class LawsMonthlyReportTitleTemplateEOController extends JeroController<L
|
||||
@RequestParam(name="pageSize", defaultValue="10") Integer pageSize,
|
||||
HttpServletRequest req) {
|
||||
QueryWrapper<LawsMonthlyReportTitleTemplateEO> queryWrapper = QueryGenerator.initQueryWrapper(lawsMonthlyReportTitleTemplateEO, req.getParameterMap());
|
||||
Page<LawsMonthlyReportTitleTemplateEO> page = new Page<LawsMonthlyReportTitleTemplateEO>(pageNo, pageSize);
|
||||
IPage<LawsMonthlyReportTitleTemplateEO> pageList = lawsMonthlyReportTitleTemplateEOService.page(page, queryWrapper);
|
||||
// Page<LawsMonthlyReportTitleTemplateEO> page = new Page<LawsMonthlyReportTitleTemplateEO>(pageNo, pageSize);
|
||||
// IPage<LawsMonthlyReportTitleTemplateEO> pageList = lawsMonthlyReportTitleTemplateEOService.page(page, queryWrapper);
|
||||
IPage<LawsMonthlyReportTitleTemplateEO> pageList = lawsMonthlyReportTitleTemplateEOService.getPageInfo(pageNo,pageSize, queryWrapper);
|
||||
return Result.OK(pageList);
|
||||
}
|
||||
|
||||
@@ -167,4 +168,17 @@ public class LawsMonthlyReportTitleTemplateEOController extends JeroController<L
|
||||
return super.importExcel(request, response, LawsMonthlyReportTitleTemplateEO.class);
|
||||
}
|
||||
|
||||
/**
|
||||
* 列表查询
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
@AutoLog(value = "月报标题模板-列表查询")
|
||||
@ApiOperation(value="月报标题模板-列表查询", notes="月报标题模板-列表查询")
|
||||
@GetMapping(value = "/oneMenu")
|
||||
public Result<List<LawsMonthlyReportTitleTemplateEO>> OneMenuList() {
|
||||
List<LawsMonthlyReportTitleTemplateEO> list = lawsMonthlyReportTitleTemplateEOService.OneMenuList();
|
||||
return Result.OK(list);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
+18
-8
@@ -1,21 +1,21 @@
|
||||
package com.jero.modules.report.entity;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.math.BigDecimal;
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableField;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import lombok.Data;
|
||||
import com.fasterxml.jackson.annotation.JsonFormat;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import com.jero.common.aspect.annotation.Dict;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
import lombok.EqualsAndHashCode;
|
||||
import lombok.experimental.Accessors;
|
||||
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
|
||||
import org.jeecgframework.poi.excel.annotation.Excel;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
/**
|
||||
@@ -76,4 +76,14 @@ public class LawsMonthlyReportTitleTemplateEO implements Serializable {
|
||||
@ApiModelProperty(value = "英文标题")
|
||||
private java.lang.String titleEn;
|
||||
|
||||
@TableField(exist = false)
|
||||
private List<LawsMonthlyReportTitleTemplateEO> children = new ArrayList<>();
|
||||
|
||||
//标识(上移-->0,下移-->1)
|
||||
@TableField(exist = false)
|
||||
private String flag;
|
||||
|
||||
//排序
|
||||
private int sort;
|
||||
|
||||
}
|
||||
|
||||
+1
@@ -11,5 +11,6 @@
|
||||
<result column="parent_id" property="parentId" />
|
||||
<result column="title_cn" property="titleCn" />
|
||||
<result column="title_en" property="titleEn" />
|
||||
<result column="sort" property="sort" />
|
||||
</resultMap>
|
||||
</mapper>
|
||||
|
||||
+18
-1
@@ -1,7 +1,10 @@
|
||||
package com.jero.modules.report.service;
|
||||
|
||||
import com.jero.modules.report.entity.LawsMonthlyReportTitleTemplateEO;
|
||||
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.jero.modules.report.entity.LawsMonthlyReportTitleTemplateEO;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -58,4 +61,18 @@ public interface ILawsMonthlyReportTitleTemplateEOService extends IService<LawsM
|
||||
* @return
|
||||
*/
|
||||
List<LawsMonthlyReportTitleTemplateEO> queryList();
|
||||
|
||||
/**
|
||||
* 分页
|
||||
* @param pageNo
|
||||
* @param pageSize
|
||||
* @param queryWrapper
|
||||
* @return
|
||||
*/
|
||||
IPage<LawsMonthlyReportTitleTemplateEO> getPageInfo(Integer pageNo,Integer pageSize, QueryWrapper<LawsMonthlyReportTitleTemplateEO> queryWrapper);
|
||||
|
||||
/**
|
||||
* 以及菜单
|
||||
*/
|
||||
List<LawsMonthlyReportTitleTemplateEO> OneMenuList();
|
||||
}
|
||||
|
||||
+102
-3
@@ -1,12 +1,22 @@
|
||||
package com.jero.modules.report.service.impl;
|
||||
|
||||
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.extension.plugins.pagination.Page;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.jero.modules.report.entity.LawsMonthlyReportTitleTemplateEO;
|
||||
import com.jero.modules.report.mapper.LawsMonthlyReportTitleTemplateEOMapper;
|
||||
import com.jero.modules.report.service.ILawsMonthlyReportTitleTemplateEOService;
|
||||
import com.jero.modules.system.util.StringUtils;
|
||||
import org.springframework.stereotype.Service;
|
||||
import java.util.List;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Comparator;
|
||||
import java.util.Date;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import java.util.List;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
* @Description: 月报标题模板
|
||||
@@ -25,7 +35,29 @@ public class LawsMonthlyReportTitleTemplateEOServiceImpl extends ServiceImpl<Law
|
||||
*/
|
||||
@Override
|
||||
public void add(LawsMonthlyReportTitleTemplateEO lawsMonthlyReportTitleTemplateEO) {
|
||||
Date now = new Date();
|
||||
List<LawsMonthlyReportTitleTemplateEO> lawsMonthlyReportTitleTemplateEOS = this.list();
|
||||
List<LawsMonthlyReportTitleTemplateEO> parent = lawsMonthlyReportTitleTemplateEOS.stream().filter(e -> StringUtils.isBlank(e.getParentId())).collect(Collectors.toList());
|
||||
List<LawsMonthlyReportTitleTemplateEO> children = lawsMonthlyReportTitleTemplateEOS.stream().filter(e -> StringUtils.isNotBlank(e.getParentId())).collect(Collectors.toList());
|
||||
int sort = 0;
|
||||
if(StringUtils.isBlank(lawsMonthlyReportTitleTemplateEO.getParentId())){
|
||||
if(parent.size() == 0){
|
||||
lawsMonthlyReportTitleTemplateEO.setSort(0);
|
||||
}else{
|
||||
List<Integer> sortList = parent.stream().map(LawsMonthlyReportTitleTemplateEO::getSort).collect(Collectors.toList());
|
||||
Collections.sort(sortList);
|
||||
sort = sortList.get(sortList.size()-1) + 1;
|
||||
}
|
||||
}else{
|
||||
if(children.size() == 0){
|
||||
lawsMonthlyReportTitleTemplateEO.setSort(0);
|
||||
}else{
|
||||
List<Integer> sortList = parent.stream().map(LawsMonthlyReportTitleTemplateEO::getSort).collect(Collectors.toList());
|
||||
Collections.sort(sortList);
|
||||
sort = sortList.get(sortList.size()-1) + 1;
|
||||
}
|
||||
}
|
||||
lawsMonthlyReportTitleTemplateEO.setSort(sort);
|
||||
Date now = new Date();
|
||||
lawsMonthlyReportTitleTemplateEO.setCreateTime(now);
|
||||
lawsMonthlyReportTitleTemplateEO.setUpdateTime(now);
|
||||
save(lawsMonthlyReportTitleTemplateEO);
|
||||
@@ -86,4 +118,71 @@ public class LawsMonthlyReportTitleTemplateEOServiceImpl extends ServiceImpl<Law
|
||||
public List<LawsMonthlyReportTitleTemplateEO> queryList() {
|
||||
return list();
|
||||
}
|
||||
|
||||
@Override
|
||||
public IPage<LawsMonthlyReportTitleTemplateEO> getPageInfo( Integer pageNo,Integer pageSize,QueryWrapper<LawsMonthlyReportTitleTemplateEO> queryWrapper) {
|
||||
List<LawsMonthlyReportTitleTemplateEO> lawsMonthlyReportTitleTemplateEOS = this.list();
|
||||
List<LawsMonthlyReportTitleTemplateEO> parentList = lawsMonthlyReportTitleTemplateEOS.stream()
|
||||
.filter(e -> StringUtils.isBlank(e.getParentId())).collect(Collectors.toList());
|
||||
Collections.sort(parentList, new Comparator<LawsMonthlyReportTitleTemplateEO>() {
|
||||
@Override
|
||||
public int compare(LawsMonthlyReportTitleTemplateEO p1, LawsMonthlyReportTitleTemplateEO p2) {
|
||||
return String.valueOf(p1.getSort()).compareTo(String.valueOf(p2.getSort()));
|
||||
}
|
||||
});
|
||||
|
||||
for (LawsMonthlyReportTitleTemplateEO lawsMonthlyReportTitleTemplateEO : parentList) {
|
||||
List<LawsMonthlyReportTitleTemplateEO> children = lawsMonthlyReportTitleTemplateEOS.stream()
|
||||
.filter(e -> lawsMonthlyReportTitleTemplateEO.getId().equals(e.getParentId())).collect(Collectors.toList());
|
||||
if(children.size() != 0){
|
||||
Collections.sort(children, new Comparator<LawsMonthlyReportTitleTemplateEO>() {
|
||||
@Override
|
||||
public int compare(LawsMonthlyReportTitleTemplateEO p1, LawsMonthlyReportTitleTemplateEO p2) {
|
||||
return String.valueOf(p1.getSort()).compareTo(String.valueOf(p2.getSort()));
|
||||
}
|
||||
});
|
||||
lawsMonthlyReportTitleTemplateEO.setChildren(children);
|
||||
}
|
||||
}
|
||||
Page pages = getPages(pageNo, pageSize, parentList);
|
||||
return pages;
|
||||
}
|
||||
|
||||
/**
|
||||
* 以及菜单
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public List<LawsMonthlyReportTitleTemplateEO> OneMenuList() {
|
||||
LambdaQueryWrapper<LawsMonthlyReportTitleTemplateEO> wrapper = new LambdaQueryWrapper<>();
|
||||
wrapper.isNull(LawsMonthlyReportTitleTemplateEO::getParentId);
|
||||
return this.list(wrapper);
|
||||
}
|
||||
|
||||
public Page getPages(Integer currentPage, Integer pageSize, List<LawsMonthlyReportTitleTemplateEO> list){
|
||||
Page page =new Page();
|
||||
if(list==null){
|
||||
return null;
|
||||
}
|
||||
int size = list.size();
|
||||
if(pageSize > size){
|
||||
pageSize = size;
|
||||
}
|
||||
if(pageSize!=0){
|
||||
//求出最⼤页数,防⽌currentPage越界
|
||||
int maxPage = size % pageSize ==0? size / pageSize : size / pageSize +1;
|
||||
if(currentPage > maxPage){
|
||||
currentPage = maxPage;
|
||||
}
|
||||
}
|
||||
//当前页第⼀条数据的下标
|
||||
int curIdx = currentPage >1?(currentPage -1)* pageSize :0;
|
||||
List pageList =new ArrayList();
|
||||
//将当前页的数据放进pageList
|
||||
for(int i =0; i < pageSize && curIdx + i < size; i++){
|
||||
pageList.add(list.get(curIdx + i));
|
||||
}
|
||||
page.setCurrent(currentPage).setSize(pageSize).setTotal(list.size()).setRecords(pageList);
|
||||
return page;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user