初始代码
This commit is contained in:
36
yunzhupaas-datareport-univer-model/pom.xml
Normal file
36
yunzhupaas-datareport-univer-model/pom.xml
Normal file
@@ -0,0 +1,36 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<parent>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-datareport-univer-core</artifactId>
|
||||
<version>5.2.0-RELEASE</version>
|
||||
</parent>
|
||||
|
||||
<artifactId>yunzhupaas-datareport-univer-model</artifactId>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>com.yunzhupaas</groupId>
|
||||
<artifactId>yunzhupaas-common-core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.antlr</groupId>
|
||||
<artifactId>antlr4-runtime</artifactId>
|
||||
<version>4.5.3</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
<version>${zxing.version}</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
||||
<profiles>
|
||||
</profiles>
|
||||
|
||||
</project>
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/9/10 下午4:28
|
||||
*/
|
||||
public enum CellDataEnum {
|
||||
text, chart, dataSource, parameter, expression
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/26 下午12:06
|
||||
*/
|
||||
public enum FormatTypeEnum {
|
||||
highlightCell, colorScale, iconSet, dataBar;
|
||||
|
||||
public static FormatTypeEnum getFormat(String name) {
|
||||
for (FormatTypeEnum status : FormatTypeEnum.values()) {
|
||||
if (Objects.equals(status.name(), name)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return FormatTypeEnum.highlightCell;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.poi.ss.usermodel.HorizontalAlignment;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2025/1/6 下午6:00
|
||||
*/
|
||||
@Getter
|
||||
public enum HorizontalEnum {
|
||||
GENERAL(0, HorizontalAlignment.GENERAL),
|
||||
LEFT(1, HorizontalAlignment.LEFT),
|
||||
CENTER(2, HorizontalAlignment.CENTER),
|
||||
RIGHT(3, HorizontalAlignment.RIGHT);
|
||||
|
||||
private Integer code;
|
||||
private HorizontalAlignment horizontal;
|
||||
|
||||
HorizontalEnum(Integer code, HorizontalAlignment horizontal) {
|
||||
this.code = code;
|
||||
this.horizontal = horizontal;
|
||||
}
|
||||
|
||||
public static HorizontalAlignment getHorizontalValue(Integer code) {
|
||||
for (HorizontalEnum status : HorizontalEnum.values()) {
|
||||
if (Objects.equals(status.getCode(), code)) {
|
||||
return status.getHorizontal();
|
||||
}
|
||||
}
|
||||
return HorizontalAlignment.GENERAL;
|
||||
}
|
||||
|
||||
public static Integer getHorizontalCode(HorizontalAlignment horizontal) {
|
||||
for (HorizontalEnum status : HorizontalEnum.values()) {
|
||||
if (Objects.equals(status.getHorizontal(), horizontal)) {
|
||||
return status.getCode();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/25 下午3:29
|
||||
*/
|
||||
public enum ImageEnum {
|
||||
BASE64, URL
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/12/4 下午4:40
|
||||
*/
|
||||
public enum OperatorEnum {
|
||||
lessThan, greaterThan, greaterThanOrEqual, min, max, middle
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/6/20 下午5:12
|
||||
*/
|
||||
public enum ResourceEnum {
|
||||
|
||||
/**
|
||||
* 注释
|
||||
*/
|
||||
SHEET_THREAD_COMMENT_PLUGIN,
|
||||
/**
|
||||
* 工作表权限
|
||||
*/
|
||||
SHEET_WORKSHEET_PROTECTION_PLUGIN,
|
||||
/**
|
||||
* 工作表单元权限
|
||||
*/
|
||||
SHEET_WORKSHEET_PROTECTION_POINT_PLUGIN,
|
||||
/**
|
||||
* 区域保护
|
||||
*/
|
||||
SHEET_RANGE_PROTECTION_PLUGIN,
|
||||
/**
|
||||
* 图片
|
||||
*/
|
||||
SHEET_DRAWING_PLUGIN,
|
||||
/**
|
||||
* 条件格式
|
||||
*/
|
||||
SHEET_CONDITIONAL_FORMATTING_PLUGIN,
|
||||
/**
|
||||
* 超链接
|
||||
*/
|
||||
SHEET_HYPER_LINK_PLUGIN,
|
||||
/**
|
||||
* 名称定义
|
||||
*/
|
||||
SHEET_DEFINED_NAME_PLUGIN,
|
||||
/**
|
||||
* 数据验证
|
||||
*/
|
||||
SHEET_DATA_VALIDATION_PLUGIN,
|
||||
/**
|
||||
* 过滤器
|
||||
*/
|
||||
SHEET_FILTER_PLUGIN,
|
||||
/**
|
||||
* 授权服务
|
||||
*/
|
||||
SHEET_AuthzIoMockService_PLUGIN
|
||||
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.poi.ss.usermodel.BorderStyle;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
public enum StyleTypeEnum {
|
||||
|
||||
NONE(0, BorderStyle.NONE),
|
||||
THIN(1, BorderStyle.THIN),
|
||||
HAIR(2, BorderStyle.HAIR),
|
||||
DOTTED(3, BorderStyle.DOTTED),
|
||||
DASHED(4, BorderStyle.DASHED),
|
||||
DASH_DOT(5, BorderStyle.DASH_DOT),
|
||||
DASH_DOT_DOT(6, BorderStyle.DASH_DOT_DOT),
|
||||
DOUBLE(7, BorderStyle.DOUBLE),
|
||||
MEDIUM(8, BorderStyle.MEDIUM),
|
||||
MEDIUM_DASHED(9, BorderStyle.MEDIUM_DASHED),
|
||||
MEDIUM_DASH_DOT(10, BorderStyle.MEDIUM_DASH_DOT),
|
||||
MEDIUM_DASH_DOT_DOT(11, BorderStyle.MEDIUM_DASH_DOT_DOT),
|
||||
SLANT_DASH_DOT(12, BorderStyle.SLANTED_DASH_DOT),
|
||||
THICK(13, BorderStyle.THICK);
|
||||
|
||||
private Integer code;
|
||||
private BorderStyle borderStyle;
|
||||
|
||||
StyleTypeEnum(Integer code, BorderStyle borderStyle) {
|
||||
this.code = code;
|
||||
this.borderStyle = borderStyle;
|
||||
}
|
||||
|
||||
public static StyleTypeEnum getStyle(Integer code) {
|
||||
for (StyleTypeEnum status : StyleTypeEnum.values()) {
|
||||
if (Objects.equals(status.getCode(), code)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/27 上午11:46
|
||||
*/
|
||||
@Getter
|
||||
public enum SubTypeEnum {
|
||||
|
||||
cellIs("number", "cellIs"),
|
||||
equal("equal", "equal"),
|
||||
notEqual("notEqual", "notEqual"),
|
||||
top10("rank", "top10"),
|
||||
uniqueValues("uniqueValues", "uniqueValues"),
|
||||
duplicateValues("duplicateValues", "duplicateValues"),
|
||||
containsText("containsText", "containsText"),
|
||||
notContainsText("notContainsText", "notContainsText"),
|
||||
beginsWith("beginsWith", "beginsWith"),
|
||||
endsWith("endsWith", "endsWith"),
|
||||
containsBlanks("containsBlanks", "containsBlanks"),
|
||||
notContainsBlanks("notContainsBlanks", "notContainsBlanks"),
|
||||
containsErrors("containsErrors", "containsErrors"),
|
||||
notContainsErrors("notContainsErrors", "notContainsErrors"),
|
||||
expression("formula", "expression"),
|
||||
aboveAverage("average", "aboveAverage"),
|
||||
timePeriod("timePeriod", "timePeriod"),
|
||||
text("text", "text");
|
||||
|
||||
private String code;
|
||||
private String type;
|
||||
|
||||
SubTypeEnum(String code, String type) {
|
||||
this.code = code;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public static SubTypeEnum getType(String type) {
|
||||
for (SubTypeEnum status : SubTypeEnum.values()) {
|
||||
if (Objects.equals(status.getType(), type)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/21 下午3:15
|
||||
*/
|
||||
@Getter
|
||||
public enum UniverDataEnum {
|
||||
|
||||
// 汇总方式
|
||||
none(0, "无"),
|
||||
select(1, "列表"),
|
||||
group(2, "分组"),
|
||||
summary(3, "汇总"),
|
||||
|
||||
// 填充方向
|
||||
cellDirection(4, "portrait"),
|
||||
cellDefault(5, "default"),
|
||||
cellNone(6, "none"),
|
||||
cellCustom(7, "custom"),
|
||||
cellRoot(8, "root");
|
||||
|
||||
private Integer code;
|
||||
private String name;
|
||||
|
||||
UniverDataEnum(Integer code, String name) {
|
||||
this.code = code;
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public static UniverDataEnum getData(String name) {
|
||||
for (UniverDataEnum status : UniverDataEnum.values()) {
|
||||
if (Objects.equals(status.getName(), name)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/12/11 上午9:41
|
||||
*/
|
||||
@Getter
|
||||
public enum ValidationType {
|
||||
|
||||
none("any", 0),
|
||||
whole("whole", 1),
|
||||
decimal("decimal", 2),
|
||||
list("list", 3),
|
||||
checkbox("checkbox", 3),
|
||||
listMultiple("listMultiple", 3),
|
||||
date("date", 4),
|
||||
textLength("textLength", 6),
|
||||
custom("custom", 7);
|
||||
|
||||
private String type;
|
||||
private Integer validationType;
|
||||
|
||||
ValidationType(String type, Integer validationType) {
|
||||
this.type = type;
|
||||
this.validationType = validationType;
|
||||
}
|
||||
|
||||
public static ValidationType getValidationType(String type) {
|
||||
for (ValidationType status : ValidationType.values()) {
|
||||
if (Objects.equals(status.getType(), type)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return ValidationType.none;
|
||||
}
|
||||
|
||||
public static ValidationType getType(Integer validationType) {
|
||||
for (ValidationType status : ValidationType.values()) {
|
||||
if (Objects.equals(status.getValidationType(), validationType)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return ValidationType.none;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
import org.apache.poi.ss.usermodel.VerticalAlignment;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2025/1/6 下午5:54
|
||||
*/
|
||||
@Getter
|
||||
public enum VerticalEnum {
|
||||
TOP(1, VerticalAlignment.TOP),
|
||||
CENTER(2, VerticalAlignment.CENTER),
|
||||
BOTTOM(3, VerticalAlignment.BOTTOM);
|
||||
|
||||
private Integer code;
|
||||
private VerticalAlignment vertical;
|
||||
|
||||
VerticalEnum(Integer code, VerticalAlignment vertical) {
|
||||
this.code = code;
|
||||
this.vertical = vertical;
|
||||
}
|
||||
|
||||
public static VerticalAlignment getVerticalValue(Integer code) {
|
||||
for (VerticalEnum status : VerticalEnum.values()) {
|
||||
if (Objects.equals(status.getCode(), code)) {
|
||||
return status.getVertical();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static Integer getVerticalCode(VerticalAlignment vertical) {
|
||||
for (VerticalEnum status : VerticalEnum.values()) {
|
||||
if (Objects.equals(status.getVertical(), vertical)) {
|
||||
return status.getCode();
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,51 @@
|
||||
package com.yunzhupaas.enums;
|
||||
|
||||
import lombok.Getter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/12/11 下午3:15
|
||||
*/
|
||||
@Getter
|
||||
public enum operatorTypeEnum {
|
||||
|
||||
none("none", -1),
|
||||
between("between", 0),
|
||||
notBetween("notBetween", 1),
|
||||
equal("equal", 2),
|
||||
NOT_EQUAL("notEqual", 3),
|
||||
greaterThan("greaterThan", 4),
|
||||
lessThan("lessThan", 5),
|
||||
greaterThanOrEqual("greaterThanOrEqual", 6),
|
||||
lessThanOrEqual("lessThanOrEqual", 7);
|
||||
|
||||
private String operatorType;
|
||||
private Integer operator;
|
||||
|
||||
operatorTypeEnum(String operatorType, Integer operator) {
|
||||
this.operatorType = operatorType;
|
||||
this.operator = operator;
|
||||
}
|
||||
|
||||
public static operatorTypeEnum getOperator(String operatorType) {
|
||||
for (operatorTypeEnum status : operatorTypeEnum.values()) {
|
||||
if (Objects.equals(status.getOperatorType(), operatorType)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return operatorTypeEnum.none;
|
||||
}
|
||||
|
||||
public static operatorTypeEnum getOperator(Integer operator) {
|
||||
for (operatorTypeEnum status : operatorTypeEnum.values()) {
|
||||
if (Objects.equals(status.getOperator(), operator)) {
|
||||
return status;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/26 上午11:31
|
||||
*/
|
||||
@Data
|
||||
public class DataQuery {
|
||||
private String sheet;
|
||||
private String sheetName;
|
||||
private List<Object> queryList = new ArrayList<>();
|
||||
private List<DataSortModel> sortList = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yunzhupaas.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/12/6 下午2:12
|
||||
*/
|
||||
@Data
|
||||
public class DataSortModel {
|
||||
private String id;
|
||||
private String vModel;
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yunzhupaas.univer.chart;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/9/10 下午1:29
|
||||
*/
|
||||
@Data
|
||||
public class UniverChartField {
|
||||
// 维度
|
||||
private List<String> seriesNameField = new ArrayList<>();
|
||||
// 系列
|
||||
private List<String> classifyNameField = new ArrayList<>();
|
||||
// 值
|
||||
private List<List<String>> seriesDataField = new ArrayList<>();
|
||||
// 最大值
|
||||
private List<String> maxField = new ArrayList<>();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.univer.chart;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/9/10 下午1:26
|
||||
*/
|
||||
@Data
|
||||
public class UniverChartModel {
|
||||
private String unitId;
|
||||
private String subUnitId;
|
||||
private String drawingId;
|
||||
private UniverChartField field = new UniverChartField();
|
||||
private String source;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.univer.data.cell;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/8/1 下午8:54
|
||||
*/
|
||||
@Data
|
||||
public class UniverCell implements Serializable {
|
||||
private String sheet;
|
||||
private Integer row;
|
||||
private Integer col;
|
||||
private String drawingId;
|
||||
private String domId;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yunzhupaas.univer.data.cell;
|
||||
|
||||
import com.yunzhupaas.enums.CellDataEnum;
|
||||
import com.yunzhupaas.enums.UniverDataEnum;
|
||||
import com.yunzhupaas.ureport.definition.value.AggregateType;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverDataConfig {
|
||||
// dataSource
|
||||
private Integer col;
|
||||
private Integer row;
|
||||
private String sheet;
|
||||
private String type = CellDataEnum.text.name();
|
||||
private UniverDataConfig custom;
|
||||
private String field;
|
||||
// 0.无 1.列表 2. 分组 3.汇总
|
||||
private Integer polymerizationType = 1;
|
||||
// 汇总方式
|
||||
private String summaryType = AggregateType.sum.name();
|
||||
private String fillDirection = UniverDataEnum.cellDirection.getName();
|
||||
private String leftParentCellType = UniverDataEnum.cellNone.getName();
|
||||
private String leftParentCellCustomRowName;
|
||||
private String leftParentCellCustomColName;
|
||||
private String topParentCellType = UniverDataEnum.cellNone.getName();
|
||||
private String topParentCellCustomRowName;
|
||||
private String topParentCellCustomColName;
|
||||
|
||||
// echarts
|
||||
private String drawingId;
|
||||
private String unitId;
|
||||
private String subUnitId;
|
||||
private UniverDataConfig option;
|
||||
private String classifyNameField;
|
||||
private String seriesNameField;
|
||||
private String seriesDataField;
|
||||
private String maxField;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.univer.data.custom;
|
||||
|
||||
import com.yunzhupaas.univer.data.cell.UniverDataConfig;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/25 下午2:49
|
||||
*/
|
||||
@Data
|
||||
public class UniverCustom {
|
||||
private List<UniverDataConfig> cells = new ArrayList<>();
|
||||
private Map<String, UniverDataConfig> floatEcharts = new HashMap<>();
|
||||
private Map<String, UniverDataConfig> floatImages = new HashMap<>();
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/21 上午11:06
|
||||
*/
|
||||
@Data
|
||||
public class UniverConfig {
|
||||
private String operator;
|
||||
private UniverValue value;
|
||||
private String iconType;
|
||||
private String iconId;
|
||||
private Integer index;
|
||||
private String color;
|
||||
|
||||
private UniverValue min;
|
||||
private UniverValue max;
|
||||
private Boolean isGradient;
|
||||
private String positiveColor;
|
||||
private String nativeColor;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/10/18 下午1:58
|
||||
*/
|
||||
@Data
|
||||
public class UniverCustomFilters {
|
||||
private List<UniverCustomFilters> customFilters;
|
||||
private String val;
|
||||
private String operator;
|
||||
private Integer and;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverDrawing implements Serializable {
|
||||
private String unitId;
|
||||
private String subUnitId;
|
||||
private String drawingId;
|
||||
private Integer drawingType;
|
||||
private String imageSourceType;
|
||||
private String source;
|
||||
// 悬浮图片
|
||||
private UniverTransform sheetTransform;
|
||||
// 单元格图片
|
||||
private UniverTransform docTransform;
|
||||
private Integer behindDoc;
|
||||
private Integer layoutType;
|
||||
private Integer wrapText;
|
||||
private Integer distB;
|
||||
private Integer distL;
|
||||
private Integer distR;
|
||||
private Integer distT;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/10/18 下午1:58
|
||||
*/
|
||||
@Data
|
||||
public class UniverFilters {
|
||||
private UniverCustomFilters customFilters;
|
||||
private Long colId;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/24 下午1:31
|
||||
*/
|
||||
@Data
|
||||
public class UniverNum {
|
||||
private String i;
|
||||
private Integer row;
|
||||
private Integer col;
|
||||
private String sheet;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/9/10 下午6:12
|
||||
*/
|
||||
@Data
|
||||
public class UniverOffset {
|
||||
private Integer column;
|
||||
private Integer columnOffset;
|
||||
private Integer row;
|
||||
private Integer rowOffset;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/22 上午11:41
|
||||
*/
|
||||
@Data
|
||||
public class UniverRef implements Serializable {
|
||||
private Integer count;
|
||||
private String i;
|
||||
private String pattern;
|
||||
private String type;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import com.yunzhupaas.univer.style.UniverStyle;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/22 上午11:33
|
||||
*/
|
||||
@Data
|
||||
public class UniverRule {
|
||||
private String type;
|
||||
private String subType;
|
||||
private String operator;
|
||||
private UniverStyle style;
|
||||
private Object value;
|
||||
private Boolean isShowValue;
|
||||
private Object config;
|
||||
private Boolean isPercent;
|
||||
private Boolean isBottom;
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/9/10 下午6:09
|
||||
*/
|
||||
@Data
|
||||
public class UniverTransform {
|
||||
// 悬浮图片
|
||||
private Boolean flipY;
|
||||
private Boolean flipX;
|
||||
private Integer skewX;
|
||||
private Integer skewY;
|
||||
private UniverOffset from;
|
||||
private UniverOffset to;
|
||||
|
||||
// 单元格图片
|
||||
private Integer relativeFrom;
|
||||
private Integer posOffset;
|
||||
private UniverTransform size;
|
||||
private UniverTransform positionH;
|
||||
private UniverTransform positionV;
|
||||
|
||||
// 图片公共
|
||||
private Integer angle;
|
||||
private Integer left;
|
||||
private Integer top;
|
||||
private Integer width;
|
||||
private Integer height;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yunzhupaas.univer.data.resource;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/21 上午11:09
|
||||
*/
|
||||
@Data
|
||||
public class UniverValue {
|
||||
private Object value;
|
||||
private String type;
|
||||
}
|
||||
@@ -0,0 +1,30 @@
|
||||
package com.yunzhupaas.univer.model;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/7/4 下午4:12
|
||||
*/
|
||||
@Data
|
||||
public class UniverPreview {
|
||||
|
||||
private String cells;
|
||||
|
||||
private String snapshot;
|
||||
|
||||
private String queryList;
|
||||
|
||||
private String chartData;
|
||||
|
||||
private String fullName;
|
||||
|
||||
private String versionId;
|
||||
|
||||
private Integer allowExport;
|
||||
|
||||
private Integer allowPrint;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.univer.model;
|
||||
|
||||
import com.yunzhupaas.univer.resources.UniverResource;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheet;
|
||||
import com.yunzhupaas.univer.style.UniverStyle;
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverWorkBook implements Serializable {
|
||||
private String id;
|
||||
private Integer rev;
|
||||
private String name;
|
||||
/**
|
||||
* Univer版本
|
||||
*/
|
||||
private String appVersion = "0.4.1";
|
||||
/**
|
||||
* Univer语言
|
||||
*/
|
||||
private String locale = "zhCN";
|
||||
/**
|
||||
* 样式列表
|
||||
*/
|
||||
private Map<String, UniverStyle> styles = new HashMap<>();
|
||||
private List<String> sheetOrder = new ArrayList<>();
|
||||
private Map<String, UniverSheet> sheets = new HashMap<>();
|
||||
private List<UniverResource> resources = new ArrayList<>();
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yunzhupaas.univer.properties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/5 下午3:58
|
||||
*/
|
||||
@Data
|
||||
public class UniverBody {
|
||||
private String dataStream;
|
||||
private List<UniverBodyConfig> textRuns;
|
||||
private List<UniverBodyConfig> tables;
|
||||
private List<UniverBodyConfig> sectionBreaks;
|
||||
private List<UniverBodyConfig> paragraphs;
|
||||
private List<UniverBodyConfig> customDecorations;
|
||||
private List<UniverBodyConfig> customBlocks;
|
||||
private List<UniverBodyConfig> customRanges;
|
||||
private UniverBodyConfig settings;
|
||||
}
|
||||
@@ -0,0 +1,58 @@
|
||||
package com.yunzhupaas.univer.properties;
|
||||
|
||||
import com.yunzhupaas.univer.style.UniverStyle;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/5 下午4:08
|
||||
*/
|
||||
@Data
|
||||
public class UniverBodyConfig {
|
||||
private Integer startIndex;
|
||||
private UniverBodyConfig paragraphStyle;
|
||||
private Integer horizontalAlign;
|
||||
private Integer rangeType;
|
||||
private String rangeId;
|
||||
private String url;
|
||||
private UniverBodyConfig properties;
|
||||
|
||||
private Integer ed;
|
||||
private String sId;
|
||||
private String id;
|
||||
private Integer st;
|
||||
private UniverStyle ts;
|
||||
|
||||
private Integer endIndex;
|
||||
private String tableId;
|
||||
|
||||
private Integer charSpace;
|
||||
private Integer paddingEnd;
|
||||
private Integer width;
|
||||
|
||||
private String defaultFooterId;
|
||||
private String defaultHeaderId;
|
||||
private String evenPageFooterId;
|
||||
private String evenPageHeaderId;
|
||||
private String firstPageFooterId;
|
||||
private String firstPageHeaderId;
|
||||
|
||||
private Integer linePitch;
|
||||
private Integer marginBottom;
|
||||
private Integer marginFooter;
|
||||
private Integer marginHeader;
|
||||
private Integer marginLeft;
|
||||
private Integer marginRight;
|
||||
private Integer marginTop;
|
||||
private Integer pageNumberStart;
|
||||
private Integer useFirstPageHeaderFooter;
|
||||
|
||||
private Integer zoomRatio;
|
||||
|
||||
private String blockId;
|
||||
private Integer blockType;
|
||||
private Integer type;
|
||||
private Boolean wholeEntity;
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.yunzhupaas.univer.properties;
|
||||
|
||||
import com.yunzhupaas.univer.style.UniverStyle;
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/5 下午3:55
|
||||
*/
|
||||
@Data
|
||||
public class UniverDocumentStyle {
|
||||
|
||||
private Integer autoHyphenation;
|
||||
private Integer characterSpacingControl;
|
||||
private Integer consecutiveHyphenLimit;
|
||||
private String defaultFooterId;
|
||||
private String defaultHeaderId;
|
||||
private Integer defaultTabStop;
|
||||
private Integer doNotHyphenateCaps;
|
||||
private Integer documentFlavor;
|
||||
private Integer evenAndOddHeaders;
|
||||
private String evenPageFooterId;
|
||||
private String evenPageHeaderId;
|
||||
private String firstPageFooterId;
|
||||
private String firstPageHeaderId;
|
||||
private Integer hyphenationZone;
|
||||
private Integer marginBottom;
|
||||
private Integer marginFooter;
|
||||
private Integer marginHeader;
|
||||
private Integer marginLeft;
|
||||
private Integer marginRight;
|
||||
private Integer marginTop;
|
||||
private Integer pageNumberStart;
|
||||
private Integer pageOrient;
|
||||
private UniverDocumentStyleConfig pageSize;
|
||||
private Integer paragraphLineGapDefault;
|
||||
private UniverDocumentStyleConfig renderConfig;
|
||||
private Boolean spaceWidthEastAsian;
|
||||
private UniverStyle textStyle;
|
||||
private Boolean useFirstPageHeaderFooter;
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yunzhupaas.univer.properties;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/5 下午3:55
|
||||
*/
|
||||
@Data
|
||||
public class UniverDocumentStyleConfig {
|
||||
private Integer width;
|
||||
private Integer height;
|
||||
private Integer background;
|
||||
private Integer horizontalAlign;
|
||||
private Integer verticalAlign;
|
||||
private Integer centerAngle;
|
||||
private Integer vertexAngle;
|
||||
private Integer wrapStrategy;
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package com.yunzhupaas.univer.properties;
|
||||
|
||||
import com.yunzhupaas.univer.data.resource.UniverDrawing;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/11/5 下午5:54
|
||||
*/
|
||||
@Data
|
||||
public class UniverProperties {
|
||||
private UniverBody body;
|
||||
private Boolean disabled;
|
||||
private UniverDocumentStyle documentStyle;
|
||||
private Map<String, UniverDrawing> drawings;
|
||||
private List<String> drawingsOrder;
|
||||
private Map<String, Object> footers;
|
||||
private List<String> headerFooterDrawingsOrder;
|
||||
private Map<String, Object> headers;
|
||||
private String id;
|
||||
private Map<String, Object> lists;
|
||||
private String locale;
|
||||
private Map<String, Object> resources;
|
||||
private Integer rev;
|
||||
private UniverBodyConfig settings;
|
||||
private Map<String, Object> tableSource;
|
||||
private String title;
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
package com.yunzhupaas.univer.resources;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverResource {
|
||||
private String id;
|
||||
private String name;
|
||||
private String data;
|
||||
}
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.yunzhupaas.univer.resources;
|
||||
|
||||
import com.yunzhupaas.univer.data.resource.*;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetRange;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/22 下午2:10
|
||||
*/
|
||||
@Data
|
||||
public class UniverResourceData {
|
||||
// SHEET_DATA_VALIDATION
|
||||
private String uid;
|
||||
private String operator;
|
||||
private String formula1;
|
||||
private String formula2;
|
||||
private String error;
|
||||
private Integer renderMode;
|
||||
private Boolean allowBlank;
|
||||
private Integer errorStyle;
|
||||
private Boolean showErrorMessage;
|
||||
|
||||
// SHEET_NUMFMT_PLUGIN
|
||||
private Map<String, Map<Integer, Map<Integer, UniverNum>>> model;
|
||||
private List<UniverRef> refModel;
|
||||
private List<UniverNum> numModel;
|
||||
|
||||
// SHEET_CONDITIONAL_FORMATTING_PLUGIN
|
||||
private String cfId;
|
||||
private UniverRule rule;
|
||||
private Boolean stopIfTrue;
|
||||
|
||||
// SHEET_CONDITIONAL_FORMATTING_PLUGIN、SHEET_DATA_VALIDATION、SHEET_RANGE_PROTECTION
|
||||
private List<UniverSheetRange> ranges;
|
||||
|
||||
// SHEET_NUMFMT_PLUGIN、SHEET_DATA_VALIDATION
|
||||
private String type;
|
||||
|
||||
// SHEET_DEFINED_NAME_PLUGIN
|
||||
private String id;
|
||||
private String name;
|
||||
private String formulaOrRefString;
|
||||
private String comment;
|
||||
private String localSheetId;
|
||||
|
||||
// SHEET_RANGE_PROTECTION
|
||||
private String permissionId;
|
||||
private String unitType;
|
||||
private String unitId;
|
||||
private String subUnitId;
|
||||
|
||||
// SHEET_DRAWING_PLUGIN
|
||||
private List<String> order;
|
||||
private Map<String, UniverDrawing> data;
|
||||
|
||||
// SHEET_FILTER_PLUGIN
|
||||
private UniverSheetRange ref;
|
||||
private List<UniverFilters> filterColumns;
|
||||
private List<Integer> cachedFilteredOut;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheet implements Serializable {
|
||||
private String id;
|
||||
private String name;
|
||||
private String tabColor;
|
||||
private Integer hidden;
|
||||
private UniverSheetFreeze freeze;
|
||||
private Integer rowCount;
|
||||
private Integer columnCount;
|
||||
private Integer zoomRatio;
|
||||
private Integer scrollTop;
|
||||
private Integer scrollLeft;
|
||||
private Integer defaultColumnWidth;
|
||||
private Integer defaultRowHeight;
|
||||
private List<UniverSheetRange> mergeData;
|
||||
private Map<Integer, Map<Integer, UniverSheetCellData>> cellData;
|
||||
private Map<Integer, UniverSheetRowData> rowData;
|
||||
private Map<Integer, UniverSheetColumnData> columnData;
|
||||
private UniverSheetRowHeader rowHeader;
|
||||
private UniverSheetColumnHeader columnHeader;
|
||||
private Integer showGridlines;
|
||||
private List<String> selections;
|
||||
private Integer rightToLeft;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetCell implements Serializable {
|
||||
private Integer row;
|
||||
private Integer column;
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetCellData implements Serializable {
|
||||
/**
|
||||
* The unique key, a random string, is used for the plug-in to associate the
|
||||
* cell. When the cell information changes,
|
||||
* the plug-in does not need to change the data, reducing the pressure on the
|
||||
* back-end interface id?: string.
|
||||
*/
|
||||
private Object p;
|
||||
|
||||
/**
|
||||
* style id
|
||||
* UniverStyle | String
|
||||
*/
|
||||
private Object s;
|
||||
|
||||
/**
|
||||
* Origin value
|
||||
* String | Integer | Boolean
|
||||
*/
|
||||
private Object v;
|
||||
|
||||
// Usually the type is automatically determined based on the data, or the user
|
||||
// directly specifies
|
||||
// 1 string, 2 number, 3 boolean, 4 force string, green icon, set null for cell
|
||||
// clear all
|
||||
private Integer t;
|
||||
|
||||
/**
|
||||
* Raw formula string. For example `=SUM(A1:B4)`.
|
||||
*/
|
||||
private String f;
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetColumnData implements Serializable {
|
||||
/**
|
||||
* width
|
||||
*/
|
||||
private Integer w;
|
||||
/**
|
||||
* hidden
|
||||
*/
|
||||
private Integer hd;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetColumnHeader implements Serializable {
|
||||
private Integer height;
|
||||
private Integer hidden;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetFreeze implements Serializable {
|
||||
private Integer xSplit = 0;
|
||||
private Integer ySplit = 0;
|
||||
private Integer startRow = -1;
|
||||
private Integer startColumn = -1;
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetRange implements Serializable {
|
||||
/**
|
||||
* The start row (inclusive) of the range
|
||||
* startRow
|
||||
*/
|
||||
private Integer startRow;
|
||||
|
||||
/**
|
||||
* The end row (exclusive) of the range
|
||||
* endRow
|
||||
*/
|
||||
private Integer endRow;
|
||||
/**
|
||||
* The start column (inclusive) of the range
|
||||
* startColumn
|
||||
*/
|
||||
private Integer startColumn;
|
||||
|
||||
/**
|
||||
* The end column (exclusive) of the range
|
||||
* endColumn
|
||||
*/
|
||||
private Integer endColumn;
|
||||
|
||||
private Integer rangeType;
|
||||
|
||||
private Integer startAbsoluteRefType;
|
||||
|
||||
private Integer endAbsoluteRefType;
|
||||
|
||||
private String unitId;
|
||||
|
||||
private String sheetId;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetRowData implements Serializable {
|
||||
/**
|
||||
* height in pixel
|
||||
*/
|
||||
private Integer h;
|
||||
/**
|
||||
* is current row self-adaptive to its content, use `ah` to set row height when
|
||||
* true, else use `h`.
|
||||
*/
|
||||
private Integer ia; // pre name `isAutoHeight`
|
||||
/**
|
||||
* auto height
|
||||
*/
|
||||
private Integer ah;
|
||||
/**
|
||||
* hidden
|
||||
*/
|
||||
private Integer hd;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.univer.sheet;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverSheetRowHeader implements Serializable {
|
||||
private Integer width;
|
||||
private Integer hidden;
|
||||
}
|
||||
@@ -0,0 +1,98 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverStyle implements Serializable {
|
||||
/**
|
||||
* fontFamily
|
||||
*/
|
||||
private String ff;
|
||||
/**
|
||||
* fontSize
|
||||
* <p>
|
||||
* pt
|
||||
*/
|
||||
private Integer fs;
|
||||
/**
|
||||
* italic
|
||||
* 0: false
|
||||
* 1: true
|
||||
*/
|
||||
private Integer it;
|
||||
/**
|
||||
* bold
|
||||
* 0: false
|
||||
* 1: true
|
||||
*/
|
||||
private Integer bl;
|
||||
|
||||
/**
|
||||
* underline
|
||||
*/
|
||||
private UniverStyleTextDecoration ul;
|
||||
/**
|
||||
* strikethrough
|
||||
*/
|
||||
private UniverStyleTextDecoration st;
|
||||
/**
|
||||
* overline
|
||||
*/
|
||||
private UniverStyleTextDecoration ol;
|
||||
|
||||
/**
|
||||
* background
|
||||
*/
|
||||
private UniverStyleColor bg;
|
||||
|
||||
/**
|
||||
* border
|
||||
*/
|
||||
private UniverStyleBorder bd;
|
||||
|
||||
/**
|
||||
* foreground
|
||||
*/
|
||||
private UniverStyleColor cl;
|
||||
|
||||
/**
|
||||
* (1.正常 2.Subscript 下标 3.Superscript上标 )
|
||||
*/
|
||||
private Integer va;
|
||||
/**
|
||||
* textRotation
|
||||
*/
|
||||
private UniverStyleTextRotation tr;
|
||||
/**
|
||||
* textDirection
|
||||
*/
|
||||
private Integer td;
|
||||
/**
|
||||
* horizontalAlignment
|
||||
*/
|
||||
private Integer ht;
|
||||
/**
|
||||
* verticalAlignment
|
||||
*/
|
||||
private Integer vt;
|
||||
/**
|
||||
* wrapStrategy
|
||||
*/
|
||||
private Integer tb;
|
||||
/**
|
||||
* padding
|
||||
*/
|
||||
private UniverStylePadding pd;
|
||||
/**
|
||||
* dataFormat
|
||||
*/
|
||||
private UniverStylePattern n;
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* Style properties of top, bottom, left and right border
|
||||
* TLBR = 'tlbr', //START_TOP_LEFT_END_BOTTOM_RIGHT
|
||||
* TLBC = 'tlbc', // START_TOP_LEFT_END_BOTTOM_CENTER
|
||||
* TLMR = 'tlmr', // START_TOP_LEFT_END_MIDDLE_RIGHT
|
||||
* BLTR = 'bltr', // START_BOTTOM_LEFT_END_TOP_RIGHT
|
||||
* MLTR = 'mltr', // START_MIDDLE_LEFT_END_TOP_RIGHT
|
||||
* BCTR = 'bctr', // START_BOTTOM_CENTER_END_TOP_RIGHT
|
||||
*
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverStyleBorder implements Serializable {
|
||||
private UniverStyleBorderStyle t;
|
||||
private UniverStyleBorderStyle r;
|
||||
private UniverStyleBorderStyle b;
|
||||
private UniverStyleBorderStyle l;
|
||||
|
||||
private UniverStyleBorderStyle tl_br;
|
||||
private UniverStyleBorderStyle tl_bc;
|
||||
private UniverStyleBorderStyle tl_mr;
|
||||
|
||||
private UniverStyleBorderStyle bl_tr;
|
||||
private UniverStyleBorderStyle ml_tr;
|
||||
private UniverStyleBorderStyle bc_tr;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverStyleBorderStyle implements Serializable {
|
||||
private Integer s;
|
||||
private UniverStyleColor cl;
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverStyleColor implements Serializable {
|
||||
private String rgb;
|
||||
private Object th;
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverStylePadding implements Serializable {
|
||||
private Integer t;
|
||||
private Integer r;
|
||||
private Integer b;
|
||||
private Integer l;
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/9/6 上午9:00
|
||||
*/
|
||||
@Data
|
||||
public class UniverStylePattern {
|
||||
private String pattern;
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverStyleTextDecoration implements Serializable {
|
||||
// show
|
||||
private Integer s;
|
||||
// color is follow the font color. the default value is TRUE, it's also TRUE if
|
||||
// it is undefined. the cl has no effect when `c` is TRUE.
|
||||
private Integer c;
|
||||
// color
|
||||
private UniverStyleColor cl;
|
||||
// lineType
|
||||
private Object t;
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yunzhupaas.univer.style;
|
||||
|
||||
import lombok.Data;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/5/11 下午4:35
|
||||
*/
|
||||
@Data
|
||||
public class UniverStyleTextRotation implements Serializable {
|
||||
/**
|
||||
* angle
|
||||
*/
|
||||
private int a;
|
||||
/**
|
||||
* vertical
|
||||
* true : 1
|
||||
* false : 0
|
||||
*/
|
||||
private int v;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yunzhupaas.ureport;
|
||||
|
||||
import lombok.AllArgsConstructor;
|
||||
import lombok.Getter;
|
||||
import lombok.NoArgsConstructor;
|
||||
import lombok.Setter;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
@NoArgsConstructor
|
||||
@AllArgsConstructor
|
||||
public class Range {
|
||||
private int start = -1;
|
||||
private int end;
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package com.yunzhupaas.ureport.build;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class BindData {
|
||||
private Object value;
|
||||
private List<Map<String, Object>> dataList;
|
||||
|
||||
}
|
||||
@@ -0,0 +1,169 @@
|
||||
package com.yunzhupaas.ureport.build;
|
||||
|
||||
import com.yunzhupaas.ureport.definition.value.SimpleValue;
|
||||
import com.yunzhupaas.ureport.definition.value.Value;
|
||||
import com.yunzhupaas.ureport.expression.util.ElCompute;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.ureport.model.Report;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class Context {
|
||||
private Report report;
|
||||
private Cell rootCell;
|
||||
private ReportBuilder reportBuilder;
|
||||
private Map<String, Dataset> datasetMap;
|
||||
private Map<String, Object> variableMap = new HashMap<>();
|
||||
private Map<Integer, List<Row>> currentPageRowsMap = new HashMap<>();
|
||||
private Map<Row, Map<Column, Cell>> blankCellsMap = new HashMap<>();
|
||||
private Map<String, List<Cell>> unprocessedCellsMap = new HashMap<>();
|
||||
|
||||
public Context(ReportBuilder reportBuilder, Report report, Map<String, Dataset> datasetMap) {
|
||||
this.reportBuilder = reportBuilder;
|
||||
this.report = report;
|
||||
report.setContext(this);
|
||||
this.datasetMap = datasetMap;
|
||||
Map<String, List<Cell>> cellsMap = report.getCellsMap();
|
||||
for (String key : cellsMap.keySet()) {
|
||||
if (key.equals(report.getRootCell().getName())) {
|
||||
continue;
|
||||
}
|
||||
List<Cell> list = new ArrayList<>();
|
||||
list.addAll(cellsMap.get(key));
|
||||
unprocessedCellsMap.put(key, list);
|
||||
}
|
||||
this.rootCell = new Cell();
|
||||
this.rootCell.setName("ROOT");
|
||||
}
|
||||
|
||||
public List<Cell> nextUnprocessedCells() {
|
||||
if (unprocessedCellsMap.size() == 0) {
|
||||
return null;
|
||||
}
|
||||
List<Cell> targetCellsList = null;
|
||||
String targetCellName = null;
|
||||
Set<String> keySet = unprocessedCellsMap.keySet();
|
||||
for (String cellName : keySet) {
|
||||
List<Cell> cells = unprocessedCellsMap.get(cellName);
|
||||
Cell cell = cells.get(0);
|
||||
Value value = cell.getValue();
|
||||
Cell leftParent = cell.getLeftParentCell();
|
||||
Cell topParent = cell.getTopParentCell();
|
||||
if ((leftParent == null || leftParent.isProcessed()) && (topParent == null || topParent.isProcessed())) {
|
||||
targetCellsList = cells;
|
||||
targetCellName = cellName;
|
||||
break;
|
||||
}
|
||||
if (value instanceof SimpleValue) {
|
||||
targetCellsList = cells;
|
||||
targetCellName = cellName;
|
||||
break;
|
||||
}
|
||||
}
|
||||
unprocessedCellsMap.remove(targetCellName);
|
||||
return targetCellsList;
|
||||
}
|
||||
|
||||
public List<BindData> buildCellData(Cell cell) {
|
||||
return DataCompute.buildCellData(cell, this);
|
||||
}
|
||||
|
||||
public void addReportCell(Cell newCell) {
|
||||
report.addCell(newCell);
|
||||
}
|
||||
|
||||
public void addCell(Cell newCell) {
|
||||
addReportCell(newCell);
|
||||
addUnprocessedCell(newCell);
|
||||
}
|
||||
|
||||
public void addUnprocessedCell(Cell cell) {
|
||||
String cellName = cell.getName();
|
||||
List<Cell> cells = null;
|
||||
if (unprocessedCellsMap.containsKey(cellName)) {
|
||||
cells = unprocessedCellsMap.get(cellName);
|
||||
} else {
|
||||
cells = new ArrayList<>();
|
||||
unprocessedCellsMap.put(cellName, cells);
|
||||
}
|
||||
|
||||
int lastIdx = report.findSameLeftCell(cells, cell, 0);
|
||||
if (lastIdx > -1 && lastIdx < cells.size() - 1) {
|
||||
cells.add(lastIdx + 1, cell);
|
||||
} else {
|
||||
cells.add(cell);
|
||||
}
|
||||
}
|
||||
|
||||
public List<Map<String, Object>> getDatasetData(String name) {
|
||||
List<Map<String, Object>> list = new ArrayList<>();
|
||||
if (datasetMap.containsKey(name)) {
|
||||
list.addAll(datasetMap.get(name).getData());
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
public Row getRow(int rowNumber) {
|
||||
return report.getRow(rowNumber);
|
||||
}
|
||||
|
||||
public Column getColumn(int columnNumber) {
|
||||
return report.getColumn(columnNumber);
|
||||
}
|
||||
|
||||
public void addBlankCell(Cell cell) {
|
||||
cell.setBlankCell(true);
|
||||
Row row = cell.getRow();
|
||||
Column column = cell.getColumn();
|
||||
Map<Column, Cell> cellMap = blankCellsMap.get(row);
|
||||
if (cellMap == null) {
|
||||
cellMap = new HashMap<>();
|
||||
blankCellsMap.put(row, cellMap);
|
||||
}
|
||||
cellMap.put(column, cell);
|
||||
addReportCell(cell);
|
||||
}
|
||||
|
||||
public Cell getBlankCell(Row row, Column column) {
|
||||
Map<Column, Cell> colCellMap = blankCellsMap.get(row);
|
||||
if (colCellMap == null) {
|
||||
return null;
|
||||
}
|
||||
Cell targetCell = colCellMap.get(column);
|
||||
return targetCell;
|
||||
}
|
||||
|
||||
public void removeBlankCell(Cell blankCell) {
|
||||
Row row = blankCell.getRow();
|
||||
Column col = blankCell.getColumn();
|
||||
Map<Column, Cell> colCellMap = blankCellsMap.get(row);
|
||||
colCellMap.remove(col);
|
||||
}
|
||||
|
||||
public void putVariable(String key, Object value) {
|
||||
variableMap.put(key, value);
|
||||
}
|
||||
|
||||
public Object evalExpr(String expression) {
|
||||
return new ElCompute().doCompute(expression);
|
||||
}
|
||||
|
||||
public boolean isCellPocessed(String cellName) {
|
||||
return !unprocessedCellsMap.containsKey(cellName);
|
||||
}
|
||||
|
||||
public List<Row> getCurrentPageRows(int index) {
|
||||
return currentPageRowsMap.get(index);
|
||||
}
|
||||
|
||||
public Object getVariable(String key) {
|
||||
return variableMap.get(key);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yunzhupaas.ureport.build;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.yunzhupaas.ureport.compute.DatasetValueCompute;
|
||||
import com.yunzhupaas.ureport.compute.SimpleValueCompute;
|
||||
import com.yunzhupaas.ureport.compute.ValueCompute;
|
||||
import com.yunzhupaas.ureport.definition.value.Value;
|
||||
import com.yunzhupaas.ureport.definition.value.ValueType;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Data
|
||||
public class DataCompute {
|
||||
|
||||
@SuppressWarnings("null")
|
||||
private static Map<String, ValueCompute> valueComputesMap = ImmutableMap.of(
|
||||
ValueType.simple.name(), new SimpleValueCompute(),
|
||||
ValueType.dataset.name(), new DatasetValueCompute());
|
||||
|
||||
public static List<BindData> buildCellData(Cell cell, Context context) {
|
||||
Value value = cell.getValue();
|
||||
ValueCompute valueCompute = valueComputesMap.get(value.getType());
|
||||
if (valueCompute == null) {
|
||||
valueCompute = valueComputesMap.get(ValueType.simple.name());
|
||||
}
|
||||
List<BindData> list = valueCompute.compute(cell, context);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,14 @@
|
||||
package com.yunzhupaas.ureport.build;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class Dataset {
|
||||
private String name;
|
||||
private List<Map<String, Object>> data;
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yunzhupaas.ureport.build;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
import com.yunzhupaas.ureport.build.aggregate.*;
|
||||
import com.yunzhupaas.ureport.definition.value.AggregateType;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DatasetUtils {
|
||||
|
||||
private static Map<AggregateType, Aggregate> aggregates = ImmutableMap.of(
|
||||
AggregateType.group, new GroupAggregate(),
|
||||
AggregateType.select, new SelectAggregate(),
|
||||
AggregateType.avg, new AvgAggregate(),
|
||||
AggregateType.count, new CountAggregate(),
|
||||
AggregateType.sum, new SumAggregate(),
|
||||
AggregateType.min, new MinAggregate(),
|
||||
AggregateType.max, new MaxAggregate(),
|
||||
AggregateType.none, new NoneAggregate());
|
||||
|
||||
public static List<BindData> computeDatasetExpression(DatasetValue datasetValue, Cell cell, Context context) {
|
||||
AggregateType type = datasetValue.getAggregate();
|
||||
Aggregate aggregate = aggregates.get(type);
|
||||
if (aggregate == null) {
|
||||
aggregate = aggregates.get(AggregateType.select);
|
||||
}
|
||||
return aggregate.aggregate(datasetValue, cell, context);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.yunzhupaas.ureport.build;
|
||||
|
||||
import com.yunzhupaas.ureport.cell.CellBuilder;
|
||||
import com.yunzhupaas.ureport.cell.down.DownExpandBuilder;
|
||||
import com.yunzhupaas.ureport.cell.none.NoneExpandBuilder;
|
||||
import com.yunzhupaas.ureport.cell.right.RightExpandBuilder;
|
||||
import com.yunzhupaas.ureport.definition.Expand;
|
||||
import com.yunzhupaas.ureport.definition.ReportDefinition;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Report;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ReportBuilder {
|
||||
private Map<Expand, CellBuilder> cellBuildersMap = new HashMap<>();
|
||||
|
||||
public ReportBuilder() {
|
||||
cellBuildersMap.put(Expand.Down, new DownExpandBuilder());
|
||||
cellBuildersMap.put(Expand.None, new NoneExpandBuilder());
|
||||
cellBuildersMap.put(Expand.Right, new RightExpandBuilder());
|
||||
}
|
||||
|
||||
public Report buildReport(ReportDefinition reportDefinition) {
|
||||
Report report = reportDefinition.newReport();
|
||||
Map<String, Dataset> datasetMap = reportDefinition.getDatasetMap();
|
||||
Context context = new Context(this, report, datasetMap);
|
||||
List<Cell> cells = new ArrayList<>();
|
||||
cells.add(report.getRootCell());
|
||||
do {
|
||||
buildCell(context, cells);
|
||||
cells = context.nextUnprocessedCells();
|
||||
} while (cells != null);
|
||||
return report;
|
||||
}
|
||||
|
||||
public void buildCell(Context context, List<Cell> cells) {
|
||||
if (cells == null) {
|
||||
cells = context.nextUnprocessedCells();
|
||||
}
|
||||
if (cells == null) {
|
||||
return;
|
||||
}
|
||||
CellBuilder noneExpandBuilder = new NoneExpandBuilder();
|
||||
for (Cell cell : cells) {
|
||||
List<BindData> dataList = context.buildCellData(cell);
|
||||
cell.setProcessed(true);
|
||||
int size = dataList.size();
|
||||
if (size == 1) {
|
||||
noneExpandBuilder.buildCell(dataList, cell, context);
|
||||
} else if (size > 1) {
|
||||
CellBuilder cellBuilder = cellBuildersMap.get(cell.getExpand());
|
||||
cellBuilder.buildCell(dataList, cell, context);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2016年12月21日
|
||||
*/
|
||||
public abstract class Aggregate {
|
||||
|
||||
public abstract List<BindData> aggregate(DatasetValue expr, Cell cell, Context context);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.math.RoundingMode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 1月20日
|
||||
*/
|
||||
public class AvgAggregate extends Aggregate {
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
List<BindData> list = doAggregate(expr, cell, context, objList);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
List<BigDecimal> bindDataList = DataUtils.dataList(expr, objList);
|
||||
BigDecimal result = bindDataList.stream().reduce(BigDecimal.ZERO, BigDecimal::add);
|
||||
if (!objList.isEmpty()) {
|
||||
result = result.divide(new BigDecimal(objList.size()), RoundingMode.HALF_UP);
|
||||
}
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(result.doubleValue());
|
||||
List<BindData> list = new ArrayList<>();
|
||||
list.add(bindData);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class CountAggregate extends Aggregate {
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
List<BindData> list = doAggregate(expr, cell, context, objList);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(objList.size());
|
||||
List<BindData> list = new ArrayList<>();
|
||||
list.add(bindData);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,52 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.text.Collator;
|
||||
import java.util.*;
|
||||
|
||||
public class GroupAggregate extends Aggregate {
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
List<BindData> list = doAggregate(expr, cell, context, objList);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
List<BindData> list = new ArrayList<>();
|
||||
String property = expr.getProperty();
|
||||
Map<Object, List<Map<String, Object>>> map = new LinkedHashMap<>();
|
||||
for (Map<String, Object> obj : objList) {
|
||||
List<Map<String, Object>> rowList = new ArrayList<>();
|
||||
Object value = obj.get(property) != null ? obj.get(property) : "";
|
||||
if (map.containsKey(value)) {
|
||||
rowList = map.get(value);
|
||||
}
|
||||
rowList.add(obj);
|
||||
map.put(value, rowList);
|
||||
}
|
||||
for (Object key : map.keySet()) {
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(key);
|
||||
bindData.setDataList(map.get(key));
|
||||
list.add(bindData);
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
List<Map<String, Object>> rowList = new ArrayList<>();
|
||||
rowList.add(new HashMap<>());
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue("");
|
||||
bindData.setDataList(rowList);
|
||||
list.add(bindData);
|
||||
}
|
||||
Collator collator = Collator.getInstance(Locale.CHINA);
|
||||
list.sort(Comparator.comparing(BindData::getValue, collator));
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MaxAggregate extends Aggregate {
|
||||
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
List<BindData> list = doAggregate(expr, cell, context, objList);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
List<BigDecimal> bindDataList = DataUtils.dataList(expr, objList);
|
||||
if (bindDataList.isEmpty()) {
|
||||
bindDataList.add(new BigDecimal(0));
|
||||
}
|
||||
BigDecimal result = bindDataList.stream().reduce(bindDataList.get(0), BigDecimal::max);
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(result.doubleValue());
|
||||
List<BindData> list = new ArrayList<>();
|
||||
list.add(bindData);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,37 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class MinAggregate extends Aggregate {
|
||||
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
List<BindData> list = doAggregate(expr, cell, context, objList);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
List<BigDecimal> bindDataList = DataUtils.dataList(expr, objList);
|
||||
if (bindDataList.isEmpty()) {
|
||||
bindDataList.add(new BigDecimal(0));
|
||||
}
|
||||
BigDecimal result = bindDataList.stream().reduce(bindDataList.get(0), BigDecimal::min);
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(result.doubleValue());
|
||||
List<BindData> list = new ArrayList<>();
|
||||
list.add(bindData);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author :云筑产品开发平台组
|
||||
* @version: V3.1.0
|
||||
* @copyright 深圳市乐程软件有限公司
|
||||
* @date :2024/9/13 下午5:17
|
||||
*/
|
||||
public class NoneAggregate extends Aggregate {
|
||||
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
List<BindData> list = doAggregate(expr, cell, context, objList);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
List<String> dataList = new ArrayList<>();
|
||||
String property = expr.getProperty();
|
||||
for (Map<String, Object> o : objList) {
|
||||
Object data = o.get(property);
|
||||
dataList.add(data != null ? data.toString() : "");
|
||||
}
|
||||
BindData bindData = new BindData();
|
||||
bindData.setDataList(objList);
|
||||
bindData.setValue(String.join(",", dataList));
|
||||
List<BindData> list = new ArrayList<>();
|
||||
list.add(bindData);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class SelectAggregate extends Aggregate {
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
return doAggregate(expr, cell, context, objList);
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
List<BindData> list = new ArrayList<>();
|
||||
String property = expr.getProperty();
|
||||
for (Map<String, Object> o : objList) {
|
||||
List<Map<String, Object>> bindList = new ArrayList<>();
|
||||
bindList.add(o);
|
||||
Object data = o.get(property);
|
||||
BindData bindData = new BindData();
|
||||
bindData.setDataList(bindList);
|
||||
bindData.setValue(data);
|
||||
list.add(bindData);
|
||||
}
|
||||
if (list.size() == 0) {
|
||||
List<Map<String, Object>> rowList = new ArrayList<>();
|
||||
rowList.add(new HashMap<>());
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue("");
|
||||
bindData.setDataList(rowList);
|
||||
list.add(bindData);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,32 @@
|
||||
package com.yunzhupaas.ureport.build.aggregate;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
|
||||
import java.math.BigDecimal;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class SumAggregate extends Aggregate {
|
||||
@Override
|
||||
public List<BindData> aggregate(DatasetValue expr, Cell cell, Context context) {
|
||||
List<Map<String, Object>> objList = DataUtils.fetchData(cell, context, expr.getDatasetName());
|
||||
List<BindData> list = doAggregate(expr, cell, context, objList);
|
||||
return list;
|
||||
}
|
||||
|
||||
protected List<BindData> doAggregate(DatasetValue expr, Cell cell, Context context,
|
||||
List<Map<String, Object>> objList) {
|
||||
List<BigDecimal> bindDataList = DataUtils.dataList(expr, objList);
|
||||
BigDecimal result = bindDataList.stream().reduce(BigDecimal.YUNZHUPAAS, BigDecimal::add);
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(result.doubleValue());
|
||||
List<BindData> list = new ArrayList<>();
|
||||
list.add(bindData);
|
||||
return list;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yunzhupaas.ureport.cell;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface CellBuilder {
|
||||
Cell buildCell(List<BindData> dataList, Cell cell, Context context);
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.yunzhupaas.ureport.cell;
|
||||
|
||||
public enum DuplicateType {
|
||||
Duplicate, IncreaseSpan, Blank, Self;
|
||||
}
|
||||
@@ -0,0 +1,80 @@
|
||||
package com.yunzhupaas.ureport.cell.down;
|
||||
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class CellDownDuplicateUnit {
|
||||
private Cell mainCell;
|
||||
private int mainCellRowNumber;
|
||||
private Context context;
|
||||
private String groupId;
|
||||
private DownDuplicate downDuplicate;
|
||||
private DownDuplocatorWrapper downDuplocatorWrapper;
|
||||
|
||||
public CellDownDuplicateUnit(Context context, DownDuplocatorWrapper downDuplocatorWrapper, Cell mainCell,
|
||||
int mainCellRowNumber, int rowSize) {
|
||||
this.context = context;
|
||||
this.downDuplocatorWrapper = downDuplocatorWrapper;
|
||||
this.mainCell = mainCell;
|
||||
this.mainCellRowNumber = mainCellRowNumber;
|
||||
this.downDuplicate = new DownDuplicate(mainCell, rowSize, context);
|
||||
}
|
||||
|
||||
public void duplicate(Cell cell, int index) {
|
||||
Map<Cell, Cell> newCellMap = new HashMap<>();
|
||||
newCellMap.put(mainCell, cell);
|
||||
downDuplicate.setIndex(index);
|
||||
for (CellDownDuplicator childDuplicator : downDuplocatorWrapper.getMainCellChildren()) {
|
||||
Cell newCell = childDuplicator.duplicateChildrenCell(downDuplicate, cell, mainCell, false);
|
||||
newCell.setDataList(cell.getDataList());
|
||||
newCell.setLeftGroupId(groupId);
|
||||
newCellMap.put(childDuplicator.getCell(), newCell);
|
||||
processChildrenCells(newCell, childDuplicator.getCell(), newCellMap, downDuplicate,
|
||||
childDuplicator.isNonChild());
|
||||
childDuplicator.setNonChild(false);
|
||||
}
|
||||
for (CellDownDuplicator cellDownDuplicator : downDuplocatorWrapper.getCellDuplicators()) {
|
||||
cellDownDuplicator.duplicate(downDuplicate, cell);
|
||||
}
|
||||
Row newRow = downDuplicate.newRow(cell.getRow(), mainCellRowNumber);
|
||||
cell.setRow(newRow);
|
||||
newRow.getCells().add(cell);
|
||||
cell.getColumn().getCells().add(cell);
|
||||
context.addReportCell(cell);
|
||||
downDuplicate.reset();
|
||||
for (Cell newCell : newCellMap.values()) {
|
||||
Cell originTopCell = newCell.getTopParentCell();
|
||||
if (originTopCell != null && newCellMap.containsKey(originTopCell)) {
|
||||
newCell.setTopParentCell(newCellMap.get(originTopCell));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
downDuplicate.complete();
|
||||
}
|
||||
|
||||
private void processChildrenCells(Cell cell, Cell originalCell, Map<Cell, Cell> newCellMap,
|
||||
DownDuplicate downDuplicate, boolean parentNonChild) {
|
||||
List<CellDownDuplicator> childCellDownDuplicators = downDuplocatorWrapper.fetchChildrenDuplicator(originalCell);
|
||||
if (childCellDownDuplicators == null) {
|
||||
return;
|
||||
}
|
||||
for (CellDownDuplicator duplicator : childCellDownDuplicators) {
|
||||
Cell newCell = duplicator.duplicateChildrenCell(downDuplicate, cell, originalCell, parentNonChild);
|
||||
newCell.setLeftGroupId(groupId);
|
||||
newCellMap.put(duplicator.getCell(), newCell);
|
||||
processChildrenCells(newCell, duplicator.getCell(), newCellMap, downDuplicate, duplicator.isNonChild());
|
||||
duplicator.setNonChild(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,160 @@
|
||||
package com.yunzhupaas.ureport.cell.down;
|
||||
|
||||
import com.yunzhupaas.enums.UniverDataEnum;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetCellData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.cell.DuplicateType;
|
||||
import com.yunzhupaas.ureport.definition.BlankCellInfo;
|
||||
import com.yunzhupaas.ureport.definition.value.SimpleValue;
|
||||
import com.yunzhupaas.ureport.definition.value.Value;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CellDownDuplicator {
|
||||
private Cell cell;
|
||||
private int cellRowNumber;
|
||||
private DuplicateType duplicateType;
|
||||
private BlankCellInfo blankCellInfo;
|
||||
private boolean nonChild = false;
|
||||
|
||||
public CellDownDuplicator(Cell cell, DuplicateType duplicateType, int cellRowNumber) {
|
||||
this.cell = cell;
|
||||
this.cellRowNumber = cellRowNumber;
|
||||
this.duplicateType = duplicateType;
|
||||
}
|
||||
|
||||
public CellDownDuplicator(Cell cell, DuplicateType duplicateType, BlankCellInfo blankCellInfo, int cellRowNumber) {
|
||||
this.cell = cell;
|
||||
if (cellRowNumber == 0) {
|
||||
this.cellRowNumber = cell.getRow().getRowNumber();
|
||||
} else {
|
||||
this.cellRowNumber = cellRowNumber;
|
||||
}
|
||||
this.duplicateType = duplicateType;
|
||||
this.blankCellInfo = blankCellInfo;
|
||||
}
|
||||
|
||||
public Cell duplicateChildrenCell(DownDuplicate downDuplicate, Cell leftParent, Cell originalCell,
|
||||
boolean parentNonChild) {
|
||||
Cell newCell = cell.newCell();
|
||||
Row newRow = downDuplicate.newRow(newCell.getRow(), cellRowNumber);
|
||||
newRow.getCells().add(newCell);
|
||||
newCell.getColumn().getCells().add(newCell);
|
||||
newCell.setRow(newRow);
|
||||
if (newCell.getLeftParentCell() == originalCell) {
|
||||
newCell.setLeftParentCell(leftParent);
|
||||
if (parentNonChild) {
|
||||
nonChild = true;
|
||||
}
|
||||
} else {
|
||||
nonChild = true;
|
||||
}
|
||||
Cell leftParentCell = newCell.getLeftParentCell();
|
||||
if (leftParentCell != null) {
|
||||
leftParentCell.addRowChild(newCell);
|
||||
}
|
||||
Cell topParentCell = newCell.getTopParentCell();
|
||||
if (topParentCell != null) {
|
||||
topParentCell.addColumnChild(newCell);
|
||||
}
|
||||
Value value = newCell.getValue();
|
||||
Context context = downDuplicate.getContext();
|
||||
String leftType = newCell.getLeftType();
|
||||
String topType = newCell.getTopType();
|
||||
DataUtils.cellList(newCell, true, true);
|
||||
if (value instanceof SimpleValue) {
|
||||
newCell.setData(value.getValue());
|
||||
newCell.setProcessed(true);
|
||||
context.addReportCell(newCell);
|
||||
if (isSimpleValue(value, leftType, topType)) {
|
||||
newCell.setData("");
|
||||
// newCell.setCellData(new UniverSheetCellData());
|
||||
}
|
||||
} else {
|
||||
if (nonChild) {
|
||||
newCell.setValue(new SimpleValue(""));
|
||||
} else {
|
||||
context.addCell(newCell);
|
||||
}
|
||||
}
|
||||
return newCell;
|
||||
}
|
||||
|
||||
public Cell duplicate(DownDuplicate downDuplicate, Cell newMainCell) {
|
||||
switch (duplicateType) {
|
||||
case Blank:
|
||||
processBlankCell(downDuplicate, newMainCell);
|
||||
break;
|
||||
case Self:
|
||||
processSelfBlankCell(downDuplicate);
|
||||
break;
|
||||
case IncreaseSpan:
|
||||
processIncreaseSpanCell(downDuplicate);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void processBlankCell(DownDuplicate downDuplicate, Cell newMainCell) {
|
||||
Context context = downDuplicate.getContext();
|
||||
Cell newBlankCell = cell.newRowBlankCell(context, blankCellInfo, downDuplicate.getMainCell());
|
||||
if (blankCellInfo.isParent() && newMainCell.getLeftParentCell() == cell) {
|
||||
newMainCell.setLeftParentCell(newBlankCell);
|
||||
}
|
||||
Row newRow = downDuplicate.newRow(newBlankCell.getRow(), cellRowNumber);
|
||||
newRow.getCells().add(newBlankCell);
|
||||
newBlankCell.getColumn().getCells().add(newBlankCell);
|
||||
newBlankCell.setRow(newRow);
|
||||
context.addReportCell(newBlankCell);
|
||||
}
|
||||
|
||||
private void processSelfBlankCell(DownDuplicate downDuplicate) {
|
||||
Cell newBlankCell = cell.newCell();
|
||||
newBlankCell.setValue(new SimpleValue(""));
|
||||
Row newRow = downDuplicate.newRow(newBlankCell.getRow(), cellRowNumber);
|
||||
newRow.getCells().add(newBlankCell);
|
||||
newBlankCell.getColumn().getCells().add(newBlankCell);
|
||||
newBlankCell.setRow(newRow);
|
||||
Cell leftParentCell = newBlankCell.getLeftParentCell();
|
||||
if (leftParentCell != null) {
|
||||
leftParentCell.addRowChild(newBlankCell);
|
||||
}
|
||||
Cell topParentCell = newBlankCell.getTopParentCell();
|
||||
if (topParentCell != null) {
|
||||
topParentCell.addColumnChild(newBlankCell);
|
||||
}
|
||||
Context context = downDuplicate.getContext();
|
||||
context.addBlankCell(newBlankCell);
|
||||
}
|
||||
|
||||
private void processIncreaseSpanCell(DownDuplicate downDuplicate) {
|
||||
int rowSpan = cell.getRowSpan();
|
||||
Value value = cell.getValue();
|
||||
String leftType = cell.getLeftType();
|
||||
String topType = cell.getTopType();
|
||||
if (isSimpleValue(value, leftType, topType)) {
|
||||
return;
|
||||
}
|
||||
rowSpan += downDuplicate.getRowSize();
|
||||
if (rowSpan == 1) {
|
||||
rowSpan++;
|
||||
}
|
||||
cell.setRowSpan(rowSpan);
|
||||
}
|
||||
|
||||
private boolean isSimpleValue(Value value, String leftType, String topType) {
|
||||
// 判断文本类型是否要合并格子
|
||||
boolean isSimpleValue = value instanceof SimpleValue;
|
||||
boolean isLeftNone = Objects.equals(leftType, UniverDataEnum.cellNone.getName());
|
||||
boolean isTopNone = Objects.equals(topType, UniverDataEnum.cellNone.getName());
|
||||
return isSimpleValue && isLeftNone && isTopNone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,79 @@
|
||||
package com.yunzhupaas.ureport.cell.down;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 3月2日
|
||||
*/
|
||||
public class DownBlankCellApply {
|
||||
private int rowSize;
|
||||
private Cell cell;
|
||||
private Context context;
|
||||
private DownDuplocatorWrapper downDuplocatorWrapper;
|
||||
|
||||
public DownBlankCellApply(int rowSize, Cell cell, Context context, DownDuplocatorWrapper downDuplocatorWrapper) {
|
||||
this.rowSize = rowSize;
|
||||
this.cell = cell;
|
||||
this.context = context;
|
||||
this.downDuplocatorWrapper = downDuplocatorWrapper;
|
||||
}
|
||||
|
||||
public boolean useBlankCell(int index, BindData bindData) {
|
||||
if (context.getBlankCellsMap().size() == 0) {
|
||||
return false;
|
||||
}
|
||||
int nextRowNumber = cell.getRow().getRowNumber() + rowSize * (index - 1) + rowSize;
|
||||
Row nextRow = context.getRow(nextRowNumber);
|
||||
Cell blankCell = null;
|
||||
if (nextRow != null) {
|
||||
blankCell = context.getBlankCell(nextRow, cell.getColumn());
|
||||
}
|
||||
if (blankCell == null) {
|
||||
return false;
|
||||
}
|
||||
context.removeBlankCell(blankCell);
|
||||
blankCell.setValue(cell.getValue());
|
||||
blankCell.setProcessed(true);
|
||||
blankCell.setData(bindData.getValue());
|
||||
blankCell.setBindData(bindData.getDataList());
|
||||
processChildrenCell(cell, blankCell, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processChildrenCell(Cell originalCell, Cell leftParentCell, int index) {
|
||||
List<CellDownDuplicator> children = downDuplocatorWrapper.fetchChildrenDuplicator(originalCell);
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
for (CellDownDuplicator child : children) {
|
||||
Cell childCell = child.getCell();
|
||||
Cell targetCell = getChildBlankCell(childCell, index);
|
||||
if (targetCell == null) {
|
||||
continue;
|
||||
}
|
||||
context.removeBlankCell(targetCell);
|
||||
targetCell.setLeftParentCell(leftParentCell);
|
||||
targetCell.setValue(childCell.getValue());
|
||||
if (targetCell.getTopParentCell() == originalCell) {
|
||||
targetCell.setTopParentCell(leftParentCell);
|
||||
}
|
||||
context.addUnprocessedCell(targetCell);
|
||||
processChildrenCell(childCell, targetCell, index);
|
||||
}
|
||||
}
|
||||
|
||||
private Cell getChildBlankCell(Cell childCell, int index) {
|
||||
int nextChildRowNumber = childCell.getRow().getRowNumber() + rowSize * (index - 1) + rowSize;
|
||||
Row nextChildRow = context.getRow(nextChildRowNumber);
|
||||
Column col = childCell.getColumn();
|
||||
Cell targetCell = context.getBlankCell(nextChildRow, col);
|
||||
return targetCell;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,262 @@
|
||||
package com.yunzhupaas.ureport.cell.down;
|
||||
|
||||
import com.yunzhupaas.ureport.Range;
|
||||
import com.yunzhupaas.ureport.definition.BlankCellInfo;
|
||||
import com.yunzhupaas.ureport.definition.CellDefinition;
|
||||
import com.yunzhupaas.ureport.utils.BuildUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class DownCellbuilder {
|
||||
|
||||
public void buildParentCell(CellDefinition cell, List<CellDefinition> cells) {
|
||||
List<Range> rangeList = new ArrayList<>();
|
||||
Range range = buildChildrenCellRange(cell);
|
||||
List<CellDefinition> parentCells = new ArrayList<>();
|
||||
collectParentCells(cell, parentCells);
|
||||
buildParents(cell, parentCells, range, rangeList);
|
||||
|
||||
Range childRange = buildChildrenCells(cell, rangeList);
|
||||
buildChildrenBlankCells(cell, cells, childRange);
|
||||
Range rowRange = buildRowRange(rangeList);
|
||||
buildRowsBlankCells(cell, cells, rowRange);
|
||||
int start = rowRange.getStart();
|
||||
int end = rowRange.getEnd();
|
||||
int rowNumberStart = cell.getRowNumber();
|
||||
int rowNumberEnd = cell.getRowNumber();
|
||||
int rowSpan = cell.getRowSpan();
|
||||
if (rowSpan > 0) {
|
||||
rowNumberEnd += rowSpan - 1;
|
||||
}
|
||||
int rangeStart = 0;
|
||||
int rangeEnd = 0;
|
||||
if (start != -1) {
|
||||
rangeStart = start - rowNumberStart;
|
||||
}
|
||||
if (end > rowNumberStart && end > rowNumberEnd) {
|
||||
rangeEnd = end - rowNumberStart;
|
||||
} else {
|
||||
rangeEnd = rowNumberEnd - rowNumberStart;
|
||||
}
|
||||
Range duplicateRange = new Range(rangeStart, rangeEnd);
|
||||
cell.setDuplicateRange(duplicateRange);
|
||||
}
|
||||
|
||||
private void buildRowsBlankCells(CellDefinition cell, List<CellDefinition> cells, Range range) {
|
||||
Map<String, BlankCellInfo> blankCellNamesMap = cell.getNewBlankCellsMap();
|
||||
int start = range.getStart();
|
||||
int end = range.getEnd();
|
||||
int nextEnd = 0;
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (CellDefinition cellDef : cells) {
|
||||
String name = cellDef.getName();
|
||||
if (cellPrcessed(cell, name)) {
|
||||
continue;
|
||||
}
|
||||
int rowNumber = cellDef.getRowNumber();
|
||||
if (rowNumber == i) {
|
||||
int offset = rowNumber - cell.getRowNumber();
|
||||
blankCellNamesMap.put(name, new BlankCellInfo(offset, cellDef.getRowSpan(), false));
|
||||
} else if (rowNumber < i) {
|
||||
int endRowNumber = BuildUtils.buildRowNumberEnd(cellDef, rowNumber);
|
||||
if (endRowNumber >= i) {
|
||||
int offset = rowNumber - cell.getRowNumber();
|
||||
blankCellNamesMap.put(name, new BlankCellInfo(offset, cellDef.getRowSpan(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextEnd > end) {
|
||||
buildRowsBlankCells(cell, cells, new Range(end, nextEnd));
|
||||
}
|
||||
}
|
||||
|
||||
private Range buildRowRange(List<Range> rangeList) {
|
||||
Range rowRange = new Range();
|
||||
for (Range range : rangeList) {
|
||||
for (int i = range.getStart(); i <= range.getEnd(); i++) {
|
||||
if (rowRange.getStart() == -1 || i < rowRange.getStart()) {
|
||||
rowRange.setStart(i);
|
||||
}
|
||||
if (rowRange.getEnd() < i) {
|
||||
rowRange.setEnd(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return rowRange;
|
||||
}
|
||||
|
||||
private Range buildChildrenCells(CellDefinition cell, List<Range> rangeList) {
|
||||
Range range = new Range();
|
||||
List<CellDefinition> rowChildrenCells = cell.getRowChildrenCells();
|
||||
for (CellDefinition childCell : rowChildrenCells) {
|
||||
cell.getNewCellNames().add(childCell.getName());
|
||||
int rowNumber = childCell.getRowNumber();
|
||||
int endRowNumber = BuildUtils.buildRowNumberEnd(childCell, rowNumber);
|
||||
rangeList.add(new Range(rowNumber, endRowNumber));
|
||||
if (endRowNumber > range.getEnd()) {
|
||||
range.setEnd(endRowNumber);
|
||||
}
|
||||
if (range.getStart() == -1 || rowNumber < range.getStart()) {
|
||||
range.setStart(rowNumber);
|
||||
}
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
private void buildChildrenBlankCells(CellDefinition cell, List<CellDefinition> cells, Range childRange) {
|
||||
int startRowNumber = cell.getRowNumber();
|
||||
int endRowNumber = BuildUtils.buildRowNumberEnd(cell, startRowNumber);
|
||||
int start = childRange.getStart();
|
||||
int end = childRange.getEnd();
|
||||
if (start != -1 && start < startRowNumber) {
|
||||
startRowNumber = start;
|
||||
}
|
||||
if (end > endRowNumber) {
|
||||
endRowNumber = end;
|
||||
}
|
||||
Map<String, BlankCellInfo> blankCellNamesMap = cell.getNewBlankCellsMap();
|
||||
for (int i = startRowNumber; i <= endRowNumber; i++) {
|
||||
for (CellDefinition c : cells) {
|
||||
if (c.getRowNumber() != i) {
|
||||
continue;
|
||||
}
|
||||
if (c.equals(cell)) {
|
||||
continue;
|
||||
}
|
||||
String name = c.getName();
|
||||
boolean contain = cellPrcessed(cell, name);
|
||||
if (contain) {
|
||||
continue;
|
||||
}
|
||||
int offset = c.getRowNumber() - cell.getRowNumber();
|
||||
blankCellNamesMap.put(name, new BlankCellInfo(offset, c.getRowSpan(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cellPrcessed(CellDefinition cell, String name) {
|
||||
List<String> newCellNames = cell.getNewCellNames();
|
||||
List<String> increaseCellNames = cell.getIncreaseSpanCellNames();
|
||||
Map<String, BlankCellInfo> blankCellNamesMap = cell.getNewBlankCellsMap();
|
||||
boolean contain = cell.getName().equals(name);
|
||||
if (newCellNames.contains(name)) {
|
||||
contain = true;
|
||||
}
|
||||
if (increaseCellNames.contains(name)) {
|
||||
contain = true;
|
||||
}
|
||||
if (blankCellNamesMap.containsKey(name)) {
|
||||
contain = true;
|
||||
}
|
||||
return contain;
|
||||
}
|
||||
|
||||
private void collectParentCells(CellDefinition cell, List<CellDefinition> parentCells) {
|
||||
CellDefinition leftParentCell = cell.getLeftParentCell();
|
||||
if (leftParentCell == null) {
|
||||
return;
|
||||
}
|
||||
parentCells.add(leftParentCell);
|
||||
collectParentCells(leftParentCell, parentCells);
|
||||
}
|
||||
|
||||
private void buildParents(CellDefinition mainCell, List<CellDefinition> parentCells, Range childRange,
|
||||
List<Range> rangeList) {
|
||||
int rowNumberStart = mainCell.getRowNumber();
|
||||
int rowNumberEnd = BuildUtils.buildRowNumberEnd(mainCell, rowNumberStart);
|
||||
rangeList.add(new Range(rowNumberStart, rowNumberEnd));
|
||||
|
||||
int start = childRange.getStart();
|
||||
int end = childRange.getEnd();
|
||||
Map<String, BlankCellInfo> newBlankCellsMap = mainCell.getNewBlankCellsMap();
|
||||
boolean increase = true;
|
||||
for (CellDefinition parentCell : parentCells) {
|
||||
String parentCellName = parentCell.getName();
|
||||
int parentRowNumberStart = parentCell.getRowNumber();
|
||||
int parentRowNumberEnd = BuildUtils.buildRowNumberEnd(parentCell, parentRowNumberStart);
|
||||
int offset = parentRowNumberStart - rowNumberStart;
|
||||
int parentRowSpan = parentCell.getRowSpan();
|
||||
boolean isOut = assertOut(parentCell, mainCell, childRange);
|
||||
if (isOut) {
|
||||
increase = false;
|
||||
boolean doBlank = assertDoBlank(parentCell.getLeftParentCell(), parentCell, mainCell, childRange);
|
||||
if (doBlank) {
|
||||
newBlankCellsMap.put(parentCellName, new BlankCellInfo(offset, parentRowSpan, true));
|
||||
rangeList.add(new Range(parentRowNumberStart, parentRowNumberEnd));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ((start != -1 && start < parentRowNumberStart) || end > parentRowNumberEnd) {
|
||||
newBlankCellsMap.put(parentCellName, new BlankCellInfo(offset, parentRowSpan, true));
|
||||
rangeList.add(new Range(parentRowNumberStart, parentRowNumberEnd));
|
||||
increase = false;
|
||||
continue;
|
||||
}
|
||||
if (increase) {
|
||||
mainCell.getIncreaseSpanCellNames().add(parentCellName);
|
||||
} else {
|
||||
newBlankCellsMap.put(parentCellName, new BlankCellInfo(offset, parentRowSpan, true));
|
||||
rangeList.add(new Range(parentRowNumberStart, parentRowNumberEnd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean assertDoBlank(CellDefinition nextParentCell, CellDefinition parentCell, CellDefinition mainCell,
|
||||
Range childRange) {
|
||||
if (nextParentCell == null) {
|
||||
return false;
|
||||
}
|
||||
boolean isOut = assertOut(nextParentCell, mainCell, childRange);
|
||||
if (isOut) {
|
||||
return assertDoBlank(nextParentCell.getLeftParentCell(), parentCell, mainCell, childRange);
|
||||
}
|
||||
int start = parentCell.getRowNumber();
|
||||
int end = BuildUtils.buildRowNumberEnd(parentCell, start);
|
||||
int nextStart = nextParentCell.getRowNumber();
|
||||
if (nextStart <= end) {
|
||||
return true;
|
||||
}
|
||||
return assertDoBlank(nextParentCell.getLeftParentCell(), parentCell, mainCell, childRange);
|
||||
}
|
||||
|
||||
private boolean assertOut(CellDefinition parentCell, CellDefinition mainCell, Range childRange) {
|
||||
int start = parentCell.getRowNumber();
|
||||
int end = BuildUtils.buildRowNumberEnd(parentCell, start);
|
||||
int rangeStart = childRange.getStart();
|
||||
int rangeEnd = childRange.getEnd();
|
||||
if (rangeStart != -1) {
|
||||
if ((start >= rangeStart && start <= rangeEnd) || (end >= rangeStart && end <= rangeEnd)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int rowStart = mainCell.getRowNumber();
|
||||
int rowEnd = BuildUtils.buildRowNumberEnd(mainCell, rowStart);
|
||||
if ((start >= rowStart && start <= rowEnd) || (end >= rowStart && end <= rowEnd)
|
||||
|| (start <= rowStart && end >= rowEnd)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Range buildChildrenCellRange(CellDefinition mainCell) {
|
||||
Range range = new Range();
|
||||
List<CellDefinition> childrenCells = mainCell.getRowChildrenCells();
|
||||
for (CellDefinition childCell : childrenCells) {
|
||||
int childRowNumberStart = childCell.getRowNumber();
|
||||
int childRowSpan = childCell.getRowSpan();
|
||||
childRowSpan = childRowSpan > 0 ? childRowSpan - 1 : childRowSpan;
|
||||
int childRowNumberEnd = childRowNumberStart + childRowSpan;
|
||||
if (range.getStart() == -1 || childRowNumberStart < range.getStart()) {
|
||||
range.setStart(childRowNumberStart);
|
||||
}
|
||||
if (childRowNumberEnd > range.getEnd()) {
|
||||
range.setEnd(childRowNumberEnd);
|
||||
}
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,60 @@
|
||||
package com.yunzhupaas.ureport.cell.down;
|
||||
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Report;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class DownDuplicate {
|
||||
private int index;
|
||||
private Cell mainCell;
|
||||
private int rowSize;
|
||||
private Context context;
|
||||
private int minRowNumber = -1;
|
||||
private Map<Row, Row> rowMap = new HashMap<>();
|
||||
private List<Row> newRowList = new ArrayList<>();
|
||||
|
||||
public DownDuplicate(Cell mainCell, int rowSize, Context context) {
|
||||
this.mainCell = mainCell;
|
||||
this.rowSize = rowSize;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public Row newRow(Row row, int currentRowNumber) {
|
||||
if (rowMap.containsKey(row)) {
|
||||
return rowMap.get(row);
|
||||
} else {
|
||||
int rowNumber = currentRowNumber;
|
||||
Row newRow = row.newRow();
|
||||
rowNumber = rowNumber + rowSize * (index - 1) + rowSize;
|
||||
if (minRowNumber == -1 || minRowNumber > rowNumber) {
|
||||
minRowNumber = rowNumber;
|
||||
}
|
||||
newRow.setTempRowNumber(rowNumber);
|
||||
newRowList.add(newRow);
|
||||
rowMap.put(row, newRow);
|
||||
return newRow;
|
||||
}
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
if (minRowNumber < 1) {
|
||||
return;
|
||||
}
|
||||
Report report = context.getReport();
|
||||
report.insertRows(minRowNumber, newRowList);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
rowMap.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package com.yunzhupaas.ureport.cell.down;
|
||||
|
||||
import com.yunzhupaas.ureport.cell.DuplicateType;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class DownDuplocatorWrapper {
|
||||
private String mainCellName;
|
||||
private List<CellDownDuplicator> mainCellChildren = new ArrayList<>();
|
||||
private List<CellDownDuplicator> cellDuplicators = new ArrayList<>();
|
||||
private Map<Cell, List<CellDownDuplicator>> createNewDuplicatorsMap = new HashMap<>();
|
||||
private List<Cell> duplicatorCells = new ArrayList<>();
|
||||
|
||||
public DownDuplocatorWrapper(String mainCellName) {
|
||||
this.mainCellName = mainCellName;
|
||||
}
|
||||
|
||||
public void addCellDownDuplicator(CellDownDuplicator duplicator) {
|
||||
if (duplicator.getDuplicateType().equals(DuplicateType.Duplicate)) {
|
||||
addCellDownDuplicatorToMap(duplicator);
|
||||
} else {
|
||||
cellDuplicators.add(duplicator);
|
||||
duplicatorCells.add(duplicator.getCell());
|
||||
}
|
||||
}
|
||||
|
||||
private void addCellDownDuplicatorToMap(CellDownDuplicator duplicator) {
|
||||
Cell leftParentCell = duplicator.getCell().getLeftParentCell();
|
||||
if (leftParentCell.getName().equals(mainCellName)) {
|
||||
mainCellChildren.add(duplicator);
|
||||
}
|
||||
List<CellDownDuplicator> list = null;
|
||||
if (createNewDuplicatorsMap.containsKey(leftParentCell)) {
|
||||
list = createNewDuplicatorsMap.get(leftParentCell);
|
||||
} else {
|
||||
list = new ArrayList<>();
|
||||
createNewDuplicatorsMap.put(leftParentCell, list);
|
||||
}
|
||||
list.add(duplicator);
|
||||
}
|
||||
|
||||
public boolean contains(Cell cell) {
|
||||
return duplicatorCells.contains(cell);
|
||||
}
|
||||
|
||||
public List<CellDownDuplicator> getMainCellChildren() {
|
||||
return mainCellChildren;
|
||||
}
|
||||
|
||||
public List<CellDownDuplicator> fetchChildrenDuplicator(Cell leftParentCell) {
|
||||
return createNewDuplicatorsMap.get(leftParentCell);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,133 @@
|
||||
package com.yunzhupaas.ureport.cell.down;
|
||||
|
||||
import com.yunzhupaas.ureport.Range;
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.cell.CellBuilder;
|
||||
import com.yunzhupaas.ureport.cell.DuplicateType;
|
||||
import com.yunzhupaas.ureport.definition.BlankCellInfo;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2016年11月1日
|
||||
*/
|
||||
public class DownExpandBuilder implements CellBuilder {
|
||||
@Override
|
||||
public Cell buildCell(List<BindData> dataList, Cell cell, Context context) {
|
||||
Range duplicateRange = cell.getDuplicateRange();
|
||||
int mainCellRowNumber = cell.getRow().getRowNumber();
|
||||
Range rowRange = buildRowRange(mainCellRowNumber, duplicateRange);
|
||||
DownDuplocatorWrapper downDuplocatorWrapper = buildCellDownDuplicator(cell, context, rowRange);
|
||||
int rowSize = rowRange.getEnd() - rowRange.getStart() + 1;
|
||||
DownBlankCellApply downBlankCellApply = new DownBlankCellApply(rowSize, cell, context, downDuplocatorWrapper);
|
||||
CellDownDuplicateUnit unit = new CellDownDuplicateUnit(context, downDuplocatorWrapper, cell, mainCellRowNumber,
|
||||
rowSize);
|
||||
Cell lastCell = cell;
|
||||
String groupId = RandomUtil.uuId();
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
BindData bindData = dataList.get(i);
|
||||
if (i == 0) {
|
||||
cell.setData(bindData.getValue());
|
||||
cell.setBindData(bindData.getDataList());
|
||||
cell.setDataList(dataList);
|
||||
cell.setLeftGroupId(groupId);
|
||||
DataUtils.cellList(cell, true, true);
|
||||
continue;
|
||||
}
|
||||
boolean useBlankCell = downBlankCellApply.useBlankCell(i, bindData);
|
||||
if (useBlankCell) {
|
||||
continue;
|
||||
}
|
||||
Cell newCell = cell.newCell();
|
||||
newCell.setRowNumber(newCell.getRowNumber() + i);
|
||||
newCell.setData(bindData.getValue());
|
||||
newCell.setBindData(bindData.getDataList());
|
||||
newCell.setDataList(dataList);
|
||||
newCell.setLeftGroupId(groupId);
|
||||
newCell.setProcessed(true);
|
||||
Cell leftParentCell = cell.getLeftParentCell();
|
||||
if (leftParentCell != null) {
|
||||
leftParentCell.addRowChild(newCell);
|
||||
}
|
||||
Cell topParentCell = cell.getTopParentCell();
|
||||
if (topParentCell != null) {
|
||||
topParentCell.addColumnChild(newCell);
|
||||
}
|
||||
DataUtils.cellList(newCell, true, true);
|
||||
unit.setGroupId(RandomUtil.uuId());
|
||||
unit.duplicate(newCell, i);
|
||||
lastCell = newCell;
|
||||
}
|
||||
unit.complete();
|
||||
return lastCell;
|
||||
}
|
||||
|
||||
private Range buildRowRange(int mainCellRowNumber, Range range) {
|
||||
int start = mainCellRowNumber + range.getStart();
|
||||
int end = mainCellRowNumber + range.getEnd();
|
||||
Range ranges = new Range();
|
||||
ranges.setStart(start);
|
||||
ranges.setEnd(end);
|
||||
return ranges;
|
||||
}
|
||||
|
||||
private DownDuplocatorWrapper buildCellDownDuplicator(Cell cell, Context context, Range range) {
|
||||
DownDuplocatorWrapper duplicatorWrapper = new DownDuplocatorWrapper(cell.getName());
|
||||
buildParentCellDuplicators(cell, cell, duplicatorWrapper);
|
||||
for (int i = range.getStart(); i <= range.getEnd(); i++) {
|
||||
Row row = context.getRow(i);
|
||||
List<Cell> rowCells = row.getCells();
|
||||
for (Cell rowCell : rowCells) {
|
||||
rowCell.setLeftGroupId(RandomUtil.uuId());
|
||||
buildDuplicator(duplicatorWrapper, cell, rowCell, i);
|
||||
}
|
||||
}
|
||||
return duplicatorWrapper;
|
||||
}
|
||||
|
||||
private void buildParentCellDuplicators(Cell cell, Cell mainCell, DownDuplocatorWrapper duplicatorWrapper) {
|
||||
Cell leftParentCell = cell.getLeftParentCell();
|
||||
if (leftParentCell == null) {
|
||||
return;
|
||||
}
|
||||
buildDuplicator(duplicatorWrapper, mainCell, leftParentCell, 0);
|
||||
buildParentCellDuplicators(leftParentCell, mainCell, duplicatorWrapper);
|
||||
}
|
||||
|
||||
private void buildDuplicator(DownDuplocatorWrapper duplicatorWrapper, Cell mainCell, Cell currentCell,
|
||||
int rowNumber) {
|
||||
if (currentCell == mainCell) {
|
||||
return;
|
||||
}
|
||||
String name = currentCell.getName();
|
||||
Map<String, BlankCellInfo> newBlankCellNamesMap = mainCell.getNewBlankCellsMap();
|
||||
List<String> increaseCellNames = mainCell.getIncreaseSpanCellNames();
|
||||
List<String> newCellNames = mainCell.getNewCellNames();
|
||||
if (newBlankCellNamesMap.containsKey(name)) {
|
||||
if (!duplicatorWrapper.contains(currentCell)) {
|
||||
CellDownDuplicator cellDuplicator = new CellDownDuplicator(currentCell, DuplicateType.Blank,
|
||||
newBlankCellNamesMap.get(name), rowNumber);
|
||||
duplicatorWrapper.addCellDownDuplicator(cellDuplicator);
|
||||
}
|
||||
} else if (increaseCellNames.contains(name)) {
|
||||
if (!duplicatorWrapper.contains(currentCell)) {
|
||||
CellDownDuplicator cellDuplicator = new CellDownDuplicator(currentCell, DuplicateType.IncreaseSpan,
|
||||
rowNumber);
|
||||
duplicatorWrapper.addCellDownDuplicator(cellDuplicator);
|
||||
}
|
||||
} else if (newCellNames.contains(name)) {
|
||||
CellDownDuplicator cellDuplicator = new CellDownDuplicator(currentCell, DuplicateType.Duplicate, rowNumber);
|
||||
duplicatorWrapper.addCellDownDuplicator(cellDuplicator);
|
||||
} else if (mainCell.getName().equals(name)) {
|
||||
CellDownDuplicator cellDuplicator = new CellDownDuplicator(currentCell, DuplicateType.Self, rowNumber);
|
||||
duplicatorWrapper.addCellDownDuplicator(cellDuplicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package com.yunzhupaas.ureport.cell.none;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.cell.CellBuilder;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class NoneExpandBuilder implements CellBuilder {
|
||||
|
||||
@Override
|
||||
public Cell buildCell(List<BindData> dataList, Cell cell, Context context) {
|
||||
if (dataList.size() == 1) {
|
||||
BindData bindData = dataList.get(0);
|
||||
cell.setData(bindData.getValue());
|
||||
cell.setBindData(bindData.getDataList());
|
||||
} else {
|
||||
Object obj = null;
|
||||
List<Map<String, Object>> bindData = null;
|
||||
for (BindData data : dataList) {
|
||||
if (obj == null) {
|
||||
obj = data.getValue();
|
||||
} else {
|
||||
obj = obj + "," + data.getValue();
|
||||
}
|
||||
bindData = data.getDataList();
|
||||
}
|
||||
cell.setData(obj);
|
||||
cell.setBindData(bindData);
|
||||
}
|
||||
return cell;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.yunzhupaas.ureport.cell.right;
|
||||
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2016年11月7日
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class CellRightDuplicateUnit {
|
||||
private Cell mainCell;
|
||||
private int mainCellColNumber;
|
||||
private Context context;
|
||||
private String groupId;
|
||||
private RightDuplicate rightDuplicate;
|
||||
private RightDuplocatorWrapper rightDuplocatorWrapper;
|
||||
|
||||
public CellRightDuplicateUnit(Context context, RightDuplocatorWrapper rightDuplocatorWrapper, Cell mainCell,
|
||||
int mainCellColNumber, int colSize) {
|
||||
this.context = context;
|
||||
this.rightDuplocatorWrapper = rightDuplocatorWrapper;
|
||||
this.mainCell = mainCell;
|
||||
this.mainCellColNumber = mainCellColNumber;
|
||||
this.rightDuplicate = new RightDuplicate(mainCell, colSize, context);
|
||||
}
|
||||
|
||||
public void duplicate(Cell cell, int index) {
|
||||
Map<Cell, Cell> newCellMap = new HashMap<>();
|
||||
newCellMap.put(mainCell, cell);
|
||||
rightDuplicate.setIndex(index);
|
||||
for (CellRightDuplicator childDuplicator : rightDuplocatorWrapper.getMainCellChildren()) {
|
||||
Cell newCell = childDuplicator.duplicateChildrenCell(rightDuplicate, cell, mainCell, false);
|
||||
newCell.setDataList(cell.getDataList());
|
||||
newCell.setTopGroupId(groupId);
|
||||
newCellMap.put(childDuplicator.getCell(), newCell);
|
||||
processChildrenCells(newCell, childDuplicator.getCell(), newCellMap, rightDuplicate,
|
||||
childDuplicator.isNonChild());
|
||||
childDuplicator.setNonChild(false);
|
||||
}
|
||||
for (CellRightDuplicator cellDownDuplicator : rightDuplocatorWrapper.getCellDuplicators()) {
|
||||
cellDownDuplicator.duplicate(rightDuplicate, cell);
|
||||
}
|
||||
Column newCol = rightDuplicate.newColumn(cell.getColumn(), mainCellColNumber);
|
||||
cell.setColumn(newCol);
|
||||
newCol.getCells().add(cell);
|
||||
cell.getRow().getCells().add(cell);
|
||||
context.addReportCell(cell);
|
||||
rightDuplicate.reset();
|
||||
for (Cell newCell : newCellMap.values()) {
|
||||
Cell originLeftCell = newCell.getLeftParentCell();
|
||||
if (originLeftCell != null && newCellMap.containsKey(originLeftCell)) {
|
||||
newCell.setLeftParentCell(newCellMap.get(originLeftCell));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
rightDuplicate.complete();
|
||||
}
|
||||
|
||||
private void processChildrenCells(Cell cell, Cell originalCell, Map<Cell, Cell> newCellMap,
|
||||
RightDuplicate rightDuplicate, boolean parentNonChild) {
|
||||
List<CellRightDuplicator> childCellRightDuplicators = rightDuplocatorWrapper
|
||||
.fetchChildrenDuplicator(originalCell);
|
||||
if (childCellRightDuplicators == null) {
|
||||
return;
|
||||
}
|
||||
for (CellRightDuplicator duplicator : childCellRightDuplicators) {
|
||||
Cell newCell = duplicator.duplicateChildrenCell(rightDuplicate, cell, originalCell, parentNonChild);
|
||||
newCell.setTopGroupId(groupId);
|
||||
newCellMap.put(duplicator.getCell(), newCell);
|
||||
processChildrenCells(newCell, duplicator.getCell(), newCellMap, rightDuplicate, duplicator.isNonChild());
|
||||
duplicator.setNonChild(false);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,164 @@
|
||||
package com.yunzhupaas.ureport.cell.right;
|
||||
|
||||
import com.yunzhupaas.enums.UniverDataEnum;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetCellData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.cell.DuplicateType;
|
||||
import com.yunzhupaas.ureport.definition.BlankCellInfo;
|
||||
import com.yunzhupaas.ureport.definition.value.SimpleValue;
|
||||
import com.yunzhupaas.ureport.definition.value.Value;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2016年11月7日
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class CellRightDuplicator {
|
||||
private Cell cell;
|
||||
private int cellColNumber;
|
||||
private DuplicateType duplicateType;
|
||||
private BlankCellInfo blankCellInfo;
|
||||
private boolean nonChild = false;
|
||||
|
||||
public CellRightDuplicator(Cell cell, DuplicateType duplicateType, int cellColNumber) {
|
||||
this.cell = cell;
|
||||
this.duplicateType = duplicateType;
|
||||
this.cellColNumber = cellColNumber;
|
||||
}
|
||||
|
||||
public CellRightDuplicator(Cell cell, DuplicateType duplicateType, BlankCellInfo blankCellInfo, int cellColNumber) {
|
||||
this.cell = cell;
|
||||
this.duplicateType = duplicateType;
|
||||
this.blankCellInfo = blankCellInfo;
|
||||
if (cellColNumber > 0) {
|
||||
this.cellColNumber = cellColNumber;
|
||||
} else {
|
||||
this.cellColNumber = cell.getColumn().getColumnNumber();
|
||||
}
|
||||
}
|
||||
|
||||
public Cell duplicateChildrenCell(RightDuplicate rightDuplicate, Cell topParent, Cell originalCell,
|
||||
boolean parentNonChild) {
|
||||
Cell newCell = cell.newCell();
|
||||
Column newCol = rightDuplicate.newColumn(newCell.getColumn(), cellColNumber);
|
||||
newCol.getCells().add(newCell);
|
||||
newCell.getRow().getCells().add(newCell);
|
||||
newCell.setColumn(newCol);
|
||||
if (newCell.getTopParentCell() == originalCell) {
|
||||
newCell.setTopParentCell(topParent);
|
||||
if (parentNonChild) {
|
||||
nonChild = true;
|
||||
}
|
||||
} else {
|
||||
nonChild = true;
|
||||
}
|
||||
Cell leftParentCell = newCell.getLeftParentCell();
|
||||
if (leftParentCell != null) {
|
||||
leftParentCell.addRowChild(newCell);
|
||||
}
|
||||
Cell topParentCell = newCell.getTopParentCell();
|
||||
if (topParentCell != null) {
|
||||
topParentCell.addColumnChild(newCell);
|
||||
}
|
||||
Value value = newCell.getValue();
|
||||
Context context = rightDuplicate.getContext();
|
||||
String leftType = newCell.getLeftType();
|
||||
String topType = newCell.getTopType();
|
||||
DataUtils.cellList(newCell, true, true);
|
||||
if (value instanceof SimpleValue) {
|
||||
newCell.setData(value.getValue());
|
||||
newCell.setProcessed(true);
|
||||
context.addReportCell(newCell);
|
||||
if (isSimpleValue(value, leftType, topType)) {
|
||||
newCell.setData("");
|
||||
// newCell.setCellData(new UniverSheetCellData());
|
||||
}
|
||||
} else {
|
||||
if (nonChild) {
|
||||
newCell.setValue(new SimpleValue(""));
|
||||
} else {
|
||||
context.addCell(newCell);
|
||||
}
|
||||
}
|
||||
return newCell;
|
||||
}
|
||||
|
||||
public Cell duplicate(RightDuplicate rightDuplicate, Cell newMainCell) {
|
||||
switch (duplicateType) {
|
||||
case Blank:
|
||||
processBlankCell(rightDuplicate, newMainCell);
|
||||
break;
|
||||
case Self:
|
||||
processSelfBlankCell(rightDuplicate);
|
||||
break;
|
||||
case IncreaseSpan:
|
||||
processIncreaseSpanCell(rightDuplicate);
|
||||
break;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
private void processBlankCell(RightDuplicate rightDuplicate, Cell newMainCell) {
|
||||
Context context = rightDuplicate.getContext();
|
||||
Cell newBlankCell = cell.newColumnBlankCell(context, blankCellInfo, rightDuplicate.getMainCell());
|
||||
if (blankCellInfo.isParent() && newMainCell.getTopParentCell() == cell) {
|
||||
newMainCell.setTopParentCell(newBlankCell);
|
||||
}
|
||||
Column col = rightDuplicate.newColumn(newBlankCell.getColumn(), cellColNumber);
|
||||
col.getCells().add(newBlankCell);
|
||||
newBlankCell.getRow().getCells().add(newBlankCell);
|
||||
newBlankCell.setColumn(col);
|
||||
context.addReportCell(newBlankCell);
|
||||
}
|
||||
|
||||
private void processSelfBlankCell(RightDuplicate rightDuplicate) {
|
||||
Cell newBlankCell = cell.newCell();
|
||||
newBlankCell.setValue(new SimpleValue(""));
|
||||
Column newCol = rightDuplicate.newColumn(newBlankCell.getColumn(), cellColNumber);
|
||||
newCol.getCells().add(newBlankCell);
|
||||
newBlankCell.getRow().getCells().add(newBlankCell);
|
||||
newBlankCell.setColumn(newCol);
|
||||
Cell leftParentCell = newBlankCell.getLeftParentCell();
|
||||
if (leftParentCell != null) {
|
||||
leftParentCell.addRowChild(newBlankCell);
|
||||
}
|
||||
Cell topParentCell = newBlankCell.getTopParentCell();
|
||||
if (topParentCell != null) {
|
||||
topParentCell.addColumnChild(newBlankCell);
|
||||
}
|
||||
Context context = rightDuplicate.getContext();
|
||||
context.addBlankCell(newBlankCell);
|
||||
}
|
||||
|
||||
private void processIncreaseSpanCell(RightDuplicate rightDuplicate) {
|
||||
int colSpan = cell.getColSpan();
|
||||
Value value = cell.getValue();
|
||||
String leftType = cell.getLeftType();
|
||||
String topType = cell.getTopType();
|
||||
if (isSimpleValue(value, leftType, topType)) {
|
||||
return;
|
||||
}
|
||||
colSpan += rightDuplicate.getColumnSize();
|
||||
if (colSpan == 1) {
|
||||
colSpan++;
|
||||
}
|
||||
cell.setColSpan(colSpan);
|
||||
}
|
||||
|
||||
private boolean isSimpleValue(Value value, String leftType, String topType) {
|
||||
// 判断文本类型是否要合并格子
|
||||
boolean isSimpleValue = value instanceof SimpleValue;
|
||||
boolean isLeftNone = Objects.equals(leftType, UniverDataEnum.cellNone.getName());
|
||||
boolean isTopNone = Objects.equals(topType, UniverDataEnum.cellNone.getName());
|
||||
return isSimpleValue && isLeftNone && isTopNone;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,74 @@
|
||||
package com.yunzhupaas.ureport.cell.right;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 3月2日
|
||||
*/
|
||||
public class RightBlankCellApply {
|
||||
private int colSize;
|
||||
private Cell cell;
|
||||
private Context context;
|
||||
private RightDuplocatorWrapper rightDuplocatorWrapper;
|
||||
|
||||
public RightBlankCellApply(int colSize, Cell cell, Context context, RightDuplocatorWrapper rightDuplocatorWrapper) {
|
||||
this.colSize = colSize;
|
||||
this.cell = cell;
|
||||
this.context = context;
|
||||
this.rightDuplocatorWrapper = rightDuplocatorWrapper;
|
||||
}
|
||||
|
||||
public boolean useBlankCell(int index, BindData bindData) {
|
||||
if (context.getBlankCellsMap().size() == 0) {
|
||||
return false;
|
||||
}
|
||||
int nextColNumber = cell.getColumn().getColumnNumber() + colSize * (index - 1) + colSize;
|
||||
Column nextCol = context.getColumn(nextColNumber);
|
||||
Cell blankCell = null;
|
||||
if (nextCol != null) {
|
||||
blankCell = context.getBlankCell(cell.getRow(), nextCol);
|
||||
}
|
||||
if (blankCell == null) {
|
||||
return false;
|
||||
}
|
||||
context.removeBlankCell(blankCell);
|
||||
blankCell.setValue(cell.getValue());
|
||||
blankCell.setProcessed(true);
|
||||
blankCell.setData(bindData.getValue());
|
||||
blankCell.setBindData(bindData.getDataList());
|
||||
processChildrenCell(cell, blankCell, index);
|
||||
return true;
|
||||
}
|
||||
|
||||
private void processChildrenCell(Cell originalCell, Cell topParentCell, int index) {
|
||||
List<CellRightDuplicator> children = rightDuplocatorWrapper.fetchChildrenDuplicator(originalCell);
|
||||
if (children == null) {
|
||||
return;
|
||||
}
|
||||
for (CellRightDuplicator child : children) {
|
||||
Cell childCell = child.getCell();
|
||||
int nextChildColNumber = childCell.getColumn().getColumnNumber() + colSize * (index - 1) + colSize;
|
||||
Column nextChildCol = context.getColumn(nextChildColNumber);
|
||||
Row row = childCell.getRow();
|
||||
Cell targetCell = context.getBlankCell(row, nextChildCol);
|
||||
if (targetCell == null) {
|
||||
continue;
|
||||
}
|
||||
context.removeBlankCell(targetCell);
|
||||
targetCell.setTopParentCell(topParentCell);
|
||||
targetCell.setValue(childCell.getValue());
|
||||
if (originalCell == targetCell.getLeftParentCell()) {
|
||||
targetCell.setLeftParentCell(topParentCell);
|
||||
}
|
||||
context.addUnprocessedCell(targetCell);
|
||||
processChildrenCell(childCell, targetCell, index);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
package com.yunzhupaas.ureport.cell.right;
|
||||
|
||||
import com.yunzhupaas.ureport.Range;
|
||||
import com.yunzhupaas.ureport.definition.BlankCellInfo;
|
||||
import com.yunzhupaas.ureport.definition.CellDefinition;
|
||||
import com.yunzhupaas.ureport.utils.BuildUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2月24日
|
||||
*/
|
||||
public class RightCellbuilder {
|
||||
|
||||
public void buildParentCell(CellDefinition cell, List<CellDefinition> cells) {
|
||||
List<Range> rangeList = new ArrayList<>();
|
||||
Range range = buildChildrenCellRange(cell);
|
||||
List<CellDefinition> parentCells = new ArrayList<>();
|
||||
collectParentCells(cell, parentCells);
|
||||
buildParents(cell, parentCells, range, rangeList);
|
||||
|
||||
Range childRange = buildChildrenCells(cell, rangeList);
|
||||
buildChildrenBlankCells(cell, cells, childRange);
|
||||
Range colRange = buildColumnRange(rangeList);
|
||||
buildColumnsBlankCells(cell, cells, colRange);
|
||||
int start = colRange.getStart();
|
||||
int end = colRange.getEnd();
|
||||
int colNumberStart = cell.getColumnNumber();
|
||||
int colNumberEnd = cell.getColumnNumber();
|
||||
int colSpan = cell.getColSpan();
|
||||
if (colSpan > 0) {
|
||||
colNumberEnd += colSpan - 1;
|
||||
}
|
||||
int rangeStart = 0;
|
||||
int rangeEnd = 0;
|
||||
if (start != -1) {
|
||||
rangeStart = start - colNumberStart;
|
||||
}
|
||||
if (end > colNumberStart && end > colNumberEnd) {
|
||||
rangeEnd = end - colNumberStart;
|
||||
} else {
|
||||
rangeEnd = colNumberEnd - colNumberStart;
|
||||
}
|
||||
Range duplicateRange = new Range(rangeStart, rangeEnd);
|
||||
cell.setDuplicateRange(duplicateRange);
|
||||
}
|
||||
|
||||
private void buildColumnsBlankCells(CellDefinition cell, List<CellDefinition> cells, Range range) {
|
||||
Map<String, BlankCellInfo> blankCellNamesMap = cell.getNewBlankCellsMap();
|
||||
int start = range.getStart();
|
||||
int end = range.getEnd();
|
||||
int nextEnd = 0;
|
||||
for (int i = start; i <= end; i++) {
|
||||
for (CellDefinition cellDef : cells) {
|
||||
String name = cellDef.getName();
|
||||
if (cellPrcessed(cell, name)) {
|
||||
continue;
|
||||
}
|
||||
int colNumber = cellDef.getColumnNumber();
|
||||
if (colNumber == i) {
|
||||
int offset = colNumber - cell.getColumnNumber();
|
||||
blankCellNamesMap.put(name, new BlankCellInfo(offset, cellDef.getColSpan(), false));
|
||||
} else if (colNumber < i) {
|
||||
int endColNumber = BuildUtils.buildColNumberEnd(cellDef, colNumber);
|
||||
if (endColNumber >= i) {
|
||||
int offset = colNumber - cell.getColumnNumber();
|
||||
blankCellNamesMap.put(name, new BlankCellInfo(offset, cellDef.getColSpan(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if (nextEnd > end) {
|
||||
buildColumnsBlankCells(cell, cells, new Range(end, nextEnd));
|
||||
}
|
||||
}
|
||||
|
||||
private Range buildColumnRange(List<Range> rangeList) {
|
||||
Range colRange = new Range();
|
||||
for (Range range : rangeList) {
|
||||
for (int i = range.getStart(); i <= range.getEnd(); i++) {
|
||||
if (colRange.getStart() == -1 || i < colRange.getStart()) {
|
||||
colRange.setStart(i);
|
||||
}
|
||||
if (colRange.getEnd() < i) {
|
||||
colRange.setEnd(i);
|
||||
}
|
||||
}
|
||||
}
|
||||
return colRange;
|
||||
}
|
||||
|
||||
private Range buildChildrenCells(CellDefinition cell, List<Range> rangeList) {
|
||||
Range range = new Range();
|
||||
List<CellDefinition> childrenCells = cell.getColumnChildrenCells();
|
||||
for (CellDefinition childCell : childrenCells) {
|
||||
cell.getNewCellNames().add(childCell.getName());
|
||||
int colNumber = childCell.getColumnNumber();
|
||||
int endColNumber = BuildUtils.buildColNumberEnd(childCell, colNumber);
|
||||
rangeList.add(new Range(colNumber, endColNumber));
|
||||
if (endColNumber > range.getEnd()) {
|
||||
range.setEnd(endColNumber);
|
||||
}
|
||||
if (range.getStart() == -1 || colNumber < range.getStart()) {
|
||||
range.setStart(colNumber);
|
||||
}
|
||||
}
|
||||
return range;
|
||||
}
|
||||
|
||||
private void buildChildrenBlankCells(CellDefinition cell, List<CellDefinition> cells, Range childRange) {
|
||||
int startColNumber = cell.getColumnNumber();
|
||||
int endColNumber = BuildUtils.buildColNumberEnd(cell, startColNumber);
|
||||
int start = childRange.getStart();
|
||||
int end = childRange.getEnd();
|
||||
if (start != -1 && start < startColNumber) {
|
||||
startColNumber = start;
|
||||
}
|
||||
if (end > endColNumber) {
|
||||
endColNumber = end;
|
||||
}
|
||||
Map<String, BlankCellInfo> blankCellNamesMap = cell.getNewBlankCellsMap();
|
||||
for (int i = startColNumber; i <= endColNumber; i++) {
|
||||
for (CellDefinition c : cells) {
|
||||
if (c.getColumnNumber() != i) {
|
||||
continue;
|
||||
}
|
||||
if (c.equals(cell)) {
|
||||
continue;
|
||||
}
|
||||
String name = c.getName();
|
||||
boolean contain = cellPrcessed(cell, name);
|
||||
if (contain) {
|
||||
continue;
|
||||
}
|
||||
int offset = c.getColumnNumber() - cell.getColumnNumber();
|
||||
blankCellNamesMap.put(name, new BlankCellInfo(offset, c.getColSpan(), false));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean cellPrcessed(CellDefinition cell, String name) {
|
||||
List<String> newCellNames = cell.getNewCellNames();
|
||||
List<String> increaseCellNames = cell.getIncreaseSpanCellNames();
|
||||
Map<String, BlankCellInfo> blankCellNamesMap = cell.getNewBlankCellsMap();
|
||||
boolean contain = cell.getName().equals(name);
|
||||
if (newCellNames.contains(name)) {
|
||||
contain = true;
|
||||
}
|
||||
if (increaseCellNames.contains(name)) {
|
||||
contain = true;
|
||||
}
|
||||
if (blankCellNamesMap.containsKey(name)) {
|
||||
contain = true;
|
||||
}
|
||||
return contain;
|
||||
}
|
||||
|
||||
private void collectParentCells(CellDefinition cell, List<CellDefinition> parentCells) {
|
||||
CellDefinition topParentCell = cell.getTopParentCell();
|
||||
if (topParentCell == null) {
|
||||
return;
|
||||
}
|
||||
parentCells.add(topParentCell);
|
||||
collectParentCells(topParentCell, parentCells);
|
||||
}
|
||||
|
||||
private void buildParents(CellDefinition mainCell, List<CellDefinition> parentCells, Range childRange,
|
||||
List<Range> rangeList) {
|
||||
int colNumberStart = mainCell.getColumnNumber();
|
||||
int colNumberEnd = BuildUtils.buildColNumberEnd(mainCell, colNumberStart);
|
||||
rangeList.add(new Range(colNumberStart, colNumberEnd));
|
||||
|
||||
int start = childRange.getStart();
|
||||
int end = childRange.getEnd();
|
||||
Map<String, BlankCellInfo> newBlankCellsMap = mainCell.getNewBlankCellsMap();
|
||||
boolean increase = true;
|
||||
for (CellDefinition parentCell : parentCells) {
|
||||
String parentCellName = parentCell.getName();
|
||||
int parentColNumberStart = parentCell.getColumnNumber();
|
||||
int parentColNumberEnd = BuildUtils.buildColNumberEnd(parentCell, parentColNumberStart);
|
||||
int offset = parentColNumberStart - colNumberStart;
|
||||
int parentColSpan = parentCell.getColSpan();
|
||||
boolean isOut = assertOut(parentCell, mainCell, childRange);
|
||||
if (isOut) {
|
||||
increase = false;
|
||||
boolean doBlank = assertDoBlank(parentCell.getTopParentCell(), parentCell, mainCell, childRange);
|
||||
if (doBlank) {
|
||||
newBlankCellsMap.put(parentCellName, new BlankCellInfo(offset, parentColSpan, true));
|
||||
rangeList.add(new Range(parentColNumberStart, parentColNumberEnd));
|
||||
}
|
||||
continue;
|
||||
}
|
||||
if ((start != -1 && start < parentColNumberStart) || end > parentColNumberEnd) {
|
||||
newBlankCellsMap.put(parentCellName, new BlankCellInfo(offset, parentColSpan, true));
|
||||
rangeList.add(new Range(parentColNumberStart, parentColNumberEnd));
|
||||
increase = false;
|
||||
continue;
|
||||
}
|
||||
if (increase) {
|
||||
mainCell.getIncreaseSpanCellNames().add(parentCellName);
|
||||
} else {
|
||||
newBlankCellsMap.put(parentCellName, new BlankCellInfo(offset, parentColSpan, true));
|
||||
rangeList.add(new Range(parentColNumberStart, parentColNumberEnd));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private boolean assertDoBlank(CellDefinition nextParentCell, CellDefinition parentCell, CellDefinition mainCell,
|
||||
Range childRange) {
|
||||
if (nextParentCell == null) {
|
||||
return false;
|
||||
}
|
||||
boolean isOut = assertOut(nextParentCell, mainCell, childRange);
|
||||
if (isOut) {
|
||||
return assertDoBlank(nextParentCell.getTopParentCell(), parentCell, mainCell, childRange);
|
||||
}
|
||||
int start = parentCell.getColumnNumber();
|
||||
int end = BuildUtils.buildColNumberEnd(parentCell, start);
|
||||
int nextStart = nextParentCell.getColumnNumber();
|
||||
if (nextStart <= end) {
|
||||
return true;
|
||||
}
|
||||
return assertDoBlank(nextParentCell.getTopParentCell(), parentCell, mainCell, childRange);
|
||||
}
|
||||
|
||||
private boolean assertOut(CellDefinition parentCell, CellDefinition mainCell, Range childRange) {
|
||||
int start = parentCell.getColumnNumber();
|
||||
int end = BuildUtils.buildColNumberEnd(parentCell, start);
|
||||
int rangeStart = childRange.getStart();
|
||||
int rangeEnd = childRange.getEnd();
|
||||
if (rangeStart != -1) {
|
||||
if ((start >= rangeStart && start <= rangeEnd) || (end >= rangeStart && end <= rangeEnd)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
int colStart = mainCell.getColumnNumber();
|
||||
int colEnd = BuildUtils.buildColNumberEnd(mainCell, colStart);
|
||||
if ((start >= colStart && start <= colEnd) || (end >= colStart && end <= colEnd)
|
||||
|| (start <= colStart && end >= colEnd)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private Range buildChildrenCellRange(CellDefinition mainCell) {
|
||||
Range range = new Range();
|
||||
List<CellDefinition> childrenCells = mainCell.getColumnChildrenCells();
|
||||
for (CellDefinition childCell : childrenCells) {
|
||||
int childColumnNumberStart = childCell.getColumnNumber();
|
||||
int childColSpan = childCell.getColSpan();
|
||||
childColSpan = childColSpan > 0 ? childColSpan - 1 : childColSpan;
|
||||
int childColumnNumberEnd = childColumnNumberStart + childColSpan;
|
||||
if (range.getStart() == -1 || childColumnNumberStart < range.getStart()) {
|
||||
range.setStart(childColumnNumberStart);
|
||||
}
|
||||
if (childColumnNumberEnd > range.getEnd()) {
|
||||
range.setEnd(childColumnNumberEnd);
|
||||
}
|
||||
}
|
||||
return range;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
package com.yunzhupaas.ureport.cell.right;
|
||||
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.ureport.model.Report;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2016年11月10日
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class RightDuplicate {
|
||||
private int index;
|
||||
private int columnSize;
|
||||
private Context context;
|
||||
private Cell mainCell;
|
||||
private int minColNumber = -1;
|
||||
private Map<Column, Column> colMap = new HashMap<>();
|
||||
private List<Column> newColList = new ArrayList<>();
|
||||
|
||||
public RightDuplicate(Cell mainCell, int columnSize, Context context) {
|
||||
this.mainCell = mainCell;
|
||||
this.columnSize = columnSize;
|
||||
this.context = context;
|
||||
}
|
||||
|
||||
public Column newColumn(Column col, int colNumber) {
|
||||
if (colMap.containsKey(col)) {
|
||||
return colMap.get(col);
|
||||
} else {
|
||||
Column newCol = col.newColumn();
|
||||
colNumber = colNumber + columnSize * (index - 1) + columnSize;
|
||||
if (minColNumber == -1 || minColNumber > colNumber) {
|
||||
minColNumber = colNumber;
|
||||
}
|
||||
newCol.setTempColumnNumber(colNumber);
|
||||
newColList.add(newCol);
|
||||
colMap.put(col, newCol);
|
||||
return newCol;
|
||||
}
|
||||
}
|
||||
|
||||
public void complete() {
|
||||
if (minColNumber < 1) {
|
||||
return;
|
||||
}
|
||||
Report report = context.getReport();
|
||||
report.insertColumns(minColNumber, newColList);
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
colMap.clear();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package com.yunzhupaas.ureport.cell.right;
|
||||
|
||||
import com.yunzhupaas.ureport.cell.DuplicateType;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2月25日
|
||||
*/
|
||||
@Setter
|
||||
@Getter
|
||||
public class RightDuplocatorWrapper {
|
||||
private String mainCellName;
|
||||
private List<CellRightDuplicator> mainCellChildren = new ArrayList<>();
|
||||
private List<CellRightDuplicator> cellDuplicators = new ArrayList<>();
|
||||
private Map<Cell, List<CellRightDuplicator>> createNewDuplicatorsMap = new HashMap<>();
|
||||
private List<Cell> duplicatorCells = new ArrayList<>();
|
||||
|
||||
public RightDuplocatorWrapper(String mainCellName) {
|
||||
this.mainCellName = mainCellName;
|
||||
}
|
||||
|
||||
public void addCellRightDuplicator(CellRightDuplicator duplicator) {
|
||||
if (duplicator.getDuplicateType().equals(DuplicateType.Duplicate)) {
|
||||
addCellRightDuplicatorToMap(duplicator);
|
||||
} else {
|
||||
cellDuplicators.add(duplicator);
|
||||
duplicatorCells.add(duplicator.getCell());
|
||||
}
|
||||
}
|
||||
|
||||
private void addCellRightDuplicatorToMap(CellRightDuplicator duplicator) {
|
||||
Cell topParentCell = duplicator.getCell().getTopParentCell();
|
||||
if (topParentCell.getName().equals(mainCellName)) {
|
||||
mainCellChildren.add(duplicator);
|
||||
}
|
||||
List<CellRightDuplicator> list = null;
|
||||
if (createNewDuplicatorsMap.containsKey(topParentCell)) {
|
||||
list = createNewDuplicatorsMap.get(topParentCell);
|
||||
} else {
|
||||
list = new ArrayList<>();
|
||||
createNewDuplicatorsMap.put(topParentCell, list);
|
||||
}
|
||||
list.add(duplicator);
|
||||
}
|
||||
|
||||
public boolean contains(Cell cell) {
|
||||
return duplicatorCells.contains(cell);
|
||||
}
|
||||
|
||||
public List<CellRightDuplicator> getMainCellChildren() {
|
||||
return mainCellChildren;
|
||||
}
|
||||
|
||||
public List<CellRightDuplicator> fetchChildrenDuplicator(Cell topParentCell) {
|
||||
return createNewDuplicatorsMap.get(topParentCell);
|
||||
}
|
||||
|
||||
public List<CellRightDuplicator> getCellDuplicators() {
|
||||
return cellDuplicators;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,140 @@
|
||||
package com.yunzhupaas.ureport.cell.right;
|
||||
|
||||
import com.yunzhupaas.ureport.Range;
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.cell.CellBuilder;
|
||||
import com.yunzhupaas.ureport.cell.DuplicateType;
|
||||
import com.yunzhupaas.ureport.definition.BlankCellInfo;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
import com.yunzhupaas.util.RandomUtil;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2016年11月1日
|
||||
*/
|
||||
|
||||
public class RightExpandBuilder implements CellBuilder {
|
||||
|
||||
@Override
|
||||
public Cell buildCell(List<BindData> dataList, Cell cell, Context context) {
|
||||
Range duplicateRange = cell.getDuplicateRange();
|
||||
int mainCellColNumber = cell.getColumn().getColumnNumber();
|
||||
Range colRange = buildColRange(mainCellColNumber, duplicateRange);
|
||||
|
||||
RightDuplocatorWrapper rightDuplocatorWrapper = buildCellRightDuplicator(cell, context, colRange);
|
||||
|
||||
int colSize = colRange.getEnd() - colRange.getStart() + 1;
|
||||
RightBlankCellApply rightBlankCellApply = new RightBlankCellApply(colSize, cell, context,
|
||||
rightDuplocatorWrapper);
|
||||
CellRightDuplicateUnit unit = new CellRightDuplicateUnit(context, rightDuplocatorWrapper, cell,
|
||||
mainCellColNumber, colSize);
|
||||
Cell lastCell = cell;
|
||||
String groupId = RandomUtil.uuId();
|
||||
for (int i = 0; i < dataList.size(); i++) {
|
||||
BindData bindData = dataList.get(i);
|
||||
if (i == 0) {
|
||||
cell.setData(bindData.getValue());
|
||||
cell.setBindData(bindData.getDataList());
|
||||
cell.setDataList(dataList);
|
||||
cell.setTopGroupId(groupId);
|
||||
DataUtils.cellList(cell, true, true);
|
||||
continue;
|
||||
}
|
||||
boolean useBlank = rightBlankCellApply.useBlankCell(i, bindData);
|
||||
if (useBlank) {
|
||||
continue;
|
||||
}
|
||||
Cell newCell = cell.newCell();
|
||||
newCell.setColumnNumber(cell.getColumnNumber() + i);
|
||||
newCell.setData(bindData.getValue());
|
||||
newCell.setBindData(bindData.getDataList());
|
||||
newCell.setDataList(dataList);
|
||||
newCell.setTopGroupId(groupId);
|
||||
newCell.setProcessed(true);
|
||||
Cell topParentCell = cell.getTopParentCell();
|
||||
if (topParentCell != null) {
|
||||
topParentCell.addColumnChild(newCell);
|
||||
}
|
||||
Cell leftParentCell = cell.getLeftParentCell();
|
||||
if (leftParentCell != null) {
|
||||
leftParentCell.addRowChild(newCell);
|
||||
}
|
||||
DataUtils.cellList(newCell, true, true);
|
||||
unit.setGroupId(RandomUtil.uuId());
|
||||
unit.duplicate(newCell, i);
|
||||
lastCell = newCell;
|
||||
}
|
||||
unit.complete();
|
||||
return lastCell;
|
||||
}
|
||||
|
||||
private Range buildColRange(int mainCellRowNumber, Range range) {
|
||||
int start = mainCellRowNumber + range.getStart();
|
||||
int end = mainCellRowNumber + range.getEnd();
|
||||
Range ranges = new Range();
|
||||
ranges.setStart(start);
|
||||
ranges.setEnd(end);
|
||||
return ranges;
|
||||
}
|
||||
|
||||
private RightDuplocatorWrapper buildCellRightDuplicator(Cell cell, Context context, Range range) {
|
||||
RightDuplocatorWrapper duplicatorWrapper = new RightDuplocatorWrapper(cell.getName());
|
||||
buildParentCellDuplicators(cell, cell, duplicatorWrapper);
|
||||
for (int i = range.getStart(); i <= range.getEnd(); i++) {
|
||||
Column col = context.getColumn(i);
|
||||
List<Cell> colCells = col.getCells();
|
||||
for (Cell colCell : colCells) {
|
||||
colCell.setTopGroupId(RandomUtil.uuId());
|
||||
buildDuplicator(duplicatorWrapper, cell, colCell, i);
|
||||
}
|
||||
}
|
||||
return duplicatorWrapper;
|
||||
}
|
||||
|
||||
private void buildParentCellDuplicators(Cell cell, Cell mainCell, RightDuplocatorWrapper duplicatorWrapper) {
|
||||
Cell topParentCell = cell.getTopParentCell();
|
||||
if (topParentCell == null) {
|
||||
return;
|
||||
}
|
||||
buildDuplicator(duplicatorWrapper, mainCell, topParentCell, 0);
|
||||
buildParentCellDuplicators(topParentCell, mainCell, duplicatorWrapper);
|
||||
}
|
||||
|
||||
private void buildDuplicator(RightDuplocatorWrapper duplicatorWrapper, Cell mainCell, Cell currentCell,
|
||||
int currentCellColNumber) {
|
||||
if (mainCell.equals(currentCell)) {
|
||||
return;
|
||||
}
|
||||
String name = currentCell.getName();
|
||||
Map<String, BlankCellInfo> newBlankCellNamesMap = mainCell.getNewBlankCellsMap();
|
||||
List<String> increaseCellNames = mainCell.getIncreaseSpanCellNames();
|
||||
List<String> newCellNames = mainCell.getNewCellNames();
|
||||
if (newBlankCellNamesMap.containsKey(name)) {
|
||||
if (!duplicatorWrapper.contains(currentCell)) {
|
||||
CellRightDuplicator cellDuplicator = new CellRightDuplicator(currentCell, DuplicateType.Blank,
|
||||
newBlankCellNamesMap.get(name), currentCellColNumber);
|
||||
duplicatorWrapper.addCellRightDuplicator(cellDuplicator);
|
||||
}
|
||||
} else if (increaseCellNames.contains(name)) {
|
||||
if (!duplicatorWrapper.contains(currentCell)) {
|
||||
CellRightDuplicator cellDuplicator = new CellRightDuplicator(currentCell, DuplicateType.IncreaseSpan,
|
||||
currentCellColNumber);
|
||||
duplicatorWrapper.addCellRightDuplicator(cellDuplicator);
|
||||
}
|
||||
} else if (newCellNames.contains(name)) {
|
||||
CellRightDuplicator cellDuplicator = new CellRightDuplicator(currentCell, DuplicateType.Duplicate,
|
||||
currentCellColNumber);
|
||||
duplicatorWrapper.addCellRightDuplicator(cellDuplicator);
|
||||
} else if (mainCell.getName().equals(name)) {
|
||||
CellRightDuplicator cellDuplicator = new CellRightDuplicator(currentCell, DuplicateType.Self,
|
||||
currentCellColNumber);
|
||||
duplicatorWrapper.addCellRightDuplicator(cellDuplicator);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.ureport.compute;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.build.DatasetUtils;
|
||||
import com.yunzhupaas.ureport.definition.value.DatasetValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DatasetValueCompute implements ValueCompute {
|
||||
@Override
|
||||
public List<BindData> compute(Cell cell, Context context) {
|
||||
DatasetValue expr = (DatasetValue) cell.getValue();
|
||||
return DatasetUtils.computeDatasetExpression(expr, cell, context);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,59 @@
|
||||
package com.yunzhupaas.ureport.compute;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.ExpressionValue;
|
||||
import com.yunzhupaas.ureport.expression.data.BindDataListExpressionData;
|
||||
import com.yunzhupaas.ureport.expression.data.ExpressionData;
|
||||
import com.yunzhupaas.ureport.expression.expr.Expression;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* @author
|
||||
* @since 2016年12月27日
|
||||
*/
|
||||
public class ExpressionValueCompute implements ValueCompute {
|
||||
@Override
|
||||
public List<BindData> compute(Cell cell, Context context) {
|
||||
ExpressionValue exprValue = (ExpressionValue) cell.getValue();
|
||||
Expression expr = exprValue.getExpression();
|
||||
List<BindData> list = new ArrayList<>();
|
||||
if (expr != null) {
|
||||
ExpressionData data = expr.execute(cell, cell, context);
|
||||
if (data instanceof BindDataListExpressionData) {
|
||||
BindDataListExpressionData exprData = (BindDataListExpressionData) data;
|
||||
list.addAll(exprData.getData());
|
||||
}
|
||||
Object obj = data.getData();
|
||||
if (obj instanceof List) {
|
||||
List<Object> listData = (List<Object>) obj;
|
||||
for (Object o : listData) {
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(o);
|
||||
list.add(bindData);
|
||||
}
|
||||
} else {
|
||||
if (obj != null) {
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(obj);
|
||||
list.add(bindData);
|
||||
}
|
||||
}
|
||||
}
|
||||
if (list.isEmpty()) {
|
||||
List<Map<String, Object>> rowList = new ArrayList<>();
|
||||
rowList.add(new HashMap<>());
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue("");
|
||||
bindData.setDataList(rowList);
|
||||
list.add(bindData);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package com.yunzhupaas.ureport.compute;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
public class SimpleValueCompute implements ValueCompute {
|
||||
|
||||
@Override
|
||||
public List<BindData> compute(Cell cell, Context context) {
|
||||
List<BindData> list = new ArrayList<>();
|
||||
BindData bindData = new BindData();
|
||||
bindData.setValue(cell.getValue().getValue());
|
||||
list.add(bindData);
|
||||
return list;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
package com.yunzhupaas.ureport.compute;
|
||||
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface ValueCompute {
|
||||
List<BindData> compute(Cell cell, Context context);
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
package com.yunzhupaas.ureport.compute;
|
||||
|
||||
import cn.hutool.core.img.ImgUtil;
|
||||
import com.google.zxing.BarcodeFormat;
|
||||
import com.google.zxing.EncodeHintType;
|
||||
import com.google.zxing.MultiFormatWriter;
|
||||
import com.google.zxing.client.j2se.MatrixToImageConfig;
|
||||
import com.google.zxing.common.BitMatrix;
|
||||
import com.google.zxing.qrcode.decoder.ErrorCorrectionLevel;
|
||||
import com.yunzhupaas.ureport.build.BindData;
|
||||
import com.yunzhupaas.ureport.build.Context;
|
||||
import com.yunzhupaas.ureport.definition.value.ZxingValue;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
import java.awt.*;
|
||||
import java.awt.image.BufferedImage;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Hashtable;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ZxingValueCompute implements ValueCompute {
|
||||
@Override
|
||||
public List<BindData> compute(Cell cell, Context context) {
|
||||
List<BindData> list = new ArrayList<>();
|
||||
ZxingValue value = (ZxingValue) cell.getValue();
|
||||
String format = value.getFormat();
|
||||
BarcodeFormat barcodeForamt = BarcodeFormat.QR_CODE;
|
||||
if (StringUtils.isNotBlank(format)) {
|
||||
barcodeForamt = BarcodeFormat.valueOf(format);
|
||||
}
|
||||
String image = base64Image(barcodeForamt, value);
|
||||
BindData data = new BindData();
|
||||
data.setValue(image);
|
||||
list.add(data);
|
||||
return list;
|
||||
}
|
||||
|
||||
public String base64Image(BarcodeFormat format, ZxingValue zxingValue) {
|
||||
String baset64 = "";
|
||||
try {
|
||||
String value = zxingValue.getValue();
|
||||
int height = zxingValue.getHeight();
|
||||
int width = zxingValue.getWidth();
|
||||
boolean remark = zxingValue.isRemark();
|
||||
// 编码内容, 编码类型, 宽度, 高度, 设置参数
|
||||
Map<EncodeHintType, Object> hints = new Hashtable<>();
|
||||
hints.put(EncodeHintType.CHARACTER_SET, "utf-8");
|
||||
// 设置容错等级
|
||||
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
|
||||
// 设置边距
|
||||
hints.put(EncodeHintType.MARGIN, 0);
|
||||
BitMatrix matrix = new MultiFormatWriter().encode(value, format, width, height, hints);
|
||||
|
||||
// 动态计算增加的高度用于备注文本
|
||||
int textHeight = remark ? 30 : 0;
|
||||
|
||||
String backgroundColor = zxingValue.getBackgroundColor();
|
||||
int background = rgb(backgroundColor, MatrixToImageConfig.WHITE);
|
||||
String foregroundColor = zxingValue.getForegroundColor();
|
||||
int foreground = rgb(foregroundColor, MatrixToImageConfig.BLACK);
|
||||
MatrixToImageConfig config = new MatrixToImageConfig(background, foreground);
|
||||
// 创建带有二维码和备注文本的
|
||||
BufferedImage image = new BufferedImage(width, height + textHeight, BufferedImage.TYPE_INT_RGB);
|
||||
Graphics2D g = image.createGraphics();
|
||||
g.setColor(new Color(background));
|
||||
g.fillRect(0, 0, width, height + textHeight);
|
||||
|
||||
// 绘制二维码到 BufferedImage
|
||||
for (int x = 0; x < width; x++) {
|
||||
for (int y = 0; y < height; y++) {
|
||||
image.setRGB(x, y, matrix.get(x, y) ? foreground : background);
|
||||
}
|
||||
}
|
||||
// 添加备注文本
|
||||
if (remark) {
|
||||
addText(image, value, width, height, textHeight, config);
|
||||
}
|
||||
baset64 = "data:image/jpeg;base64," + ImgUtil.toBase64(image, "jpeg");
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return baset64;
|
||||
}
|
||||
|
||||
private int rgb(String rgbCole, int imageColor) {
|
||||
Color color = null;
|
||||
try {
|
||||
color = new Color(Integer.parseInt(rgbCole.substring(1), 16));
|
||||
} catch (Exception e) {
|
||||
}
|
||||
return color == null ? imageColor : color.getRGB();
|
||||
}
|
||||
|
||||
// 底部添加文本
|
||||
private static void addText(BufferedImage image, String text, int width, int height, int textHeight,
|
||||
MatrixToImageConfig config) {
|
||||
Graphics2D g2 = image.createGraphics();
|
||||
g2.setColor(new Color(config.getPixelOffColor()));
|
||||
g2.setFont(new Font("Arial", Font.PLAIN, 20)); // 设置字体
|
||||
|
||||
// 获取文本的宽度以便居中对齐
|
||||
FontMetrics fm = g2.getFontMetrics();
|
||||
int textWidth = fm.stringWidth(text);
|
||||
int x = (width - textWidth) / 2;
|
||||
|
||||
// 调整 y 坐标位置,将文本稍微上移
|
||||
int padding = 5; // 增加一个 padding 值,让文本上移一点,避免贴得太近
|
||||
int y = height + (textHeight - fm.getHeight()) / 2 + fm.getAscent() - padding;
|
||||
|
||||
// 绘制文本
|
||||
g2.drawString(text, x, y);
|
||||
g2.dispose(); // 释放资源
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,18 @@
|
||||
package com.yunzhupaas.ureport.definition;
|
||||
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class BlankCellInfo {
|
||||
private int offset;
|
||||
private int span;
|
||||
private boolean parent;
|
||||
|
||||
public BlankCellInfo(int offset, int span, boolean parent) {
|
||||
this.offset = offset;
|
||||
this.span = span;
|
||||
this.parent = parent;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,115 @@
|
||||
package com.yunzhupaas.ureport.definition;
|
||||
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetCellData;
|
||||
import com.yunzhupaas.ureport.Range;
|
||||
import com.yunzhupaas.ureport.definition.value.Value;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetColumnData;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetRowData;
|
||||
import com.yunzhupaas.ureport.model.StyleModel;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class CellDefinition {
|
||||
private int rowNumber;
|
||||
private int columnNumber;
|
||||
private int rowSpan;
|
||||
private int colSpan;
|
||||
private String name;
|
||||
private Value value;
|
||||
private StyleModel styleModel;
|
||||
private UniverSheetRowData sheetRowData;
|
||||
private UniverSheetColumnData sheetColumnData;
|
||||
|
||||
private String linkUrl;
|
||||
private String linkTargetWindow;
|
||||
|
||||
private boolean fillBlankRows;
|
||||
/**
|
||||
* 允许填充空白行时fillBlankRows=true,要求当前数据行数必须是multiple定义的行数的倍数,否则就补充空白行
|
||||
*/
|
||||
private int multiple;
|
||||
|
||||
private Expand expand = Expand.None;
|
||||
|
||||
@JsonIgnore
|
||||
private Range duplicateRange;
|
||||
@JsonIgnore
|
||||
private List<String> increaseSpanCellNames = new ArrayList<>();
|
||||
@JsonIgnore
|
||||
private Map<String, BlankCellInfo> newBlankCellsMap = new HashMap<>();
|
||||
@JsonIgnore
|
||||
private List<String> newCellNames = new ArrayList<>();
|
||||
|
||||
private UniverSheetCellData cellData;
|
||||
|
||||
/**
|
||||
* 左父格类型
|
||||
*/
|
||||
private String leftType;
|
||||
/**
|
||||
* 上父格类型
|
||||
*/
|
||||
private String topType;
|
||||
/**
|
||||
* 当前单元格左父格名
|
||||
*/
|
||||
private String leftParentCellName;
|
||||
/**
|
||||
* 当前单元格上父格名
|
||||
*/
|
||||
private String topParentCellName;
|
||||
/**
|
||||
* 当前单元格左父格
|
||||
*/
|
||||
@JsonIgnore
|
||||
private CellDefinition leftParentCell;
|
||||
/**
|
||||
* 当前单元格上父格
|
||||
*/
|
||||
@JsonIgnore
|
||||
private CellDefinition topParentCell;
|
||||
/**
|
||||
* 当前单无格所在行的所有子格
|
||||
*/
|
||||
@JsonIgnore
|
||||
private List<CellDefinition> rowChildrenCells = new ArrayList<>();
|
||||
/**
|
||||
* 当前单无格所在列的所有子格
|
||||
*/
|
||||
@JsonIgnore
|
||||
private List<CellDefinition> columnChildrenCells = new ArrayList<>();
|
||||
|
||||
protected Cell newCell() {
|
||||
Cell cell = new Cell();
|
||||
cell.setValue(value);
|
||||
cell.setName(name);
|
||||
cell.setRowSpan(rowSpan);
|
||||
cell.setColSpan(colSpan);
|
||||
cell.setExpand(expand);
|
||||
cell.setDuplicateRange(duplicateRange);
|
||||
cell.setRowNumber(rowNumber);
|
||||
cell.setColumnNumber(columnNumber);
|
||||
cell.setStyleModel(styleModel);
|
||||
cell.setSheetRowData(sheetRowData);
|
||||
cell.setSheetColumnData(sheetColumnData);
|
||||
cell.setCellData(cellData);
|
||||
cell.setNewBlankCellsMap(newBlankCellsMap);
|
||||
cell.setIncreaseSpanCellNames(increaseSpanCellNames);
|
||||
cell.setNewCellNames(newCellNames);
|
||||
cell.setFillBlankRows(fillBlankRows);
|
||||
cell.setMultiple(multiple);
|
||||
cell.setLeftType(leftType);
|
||||
cell.setTopType(topType);
|
||||
return cell;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.yunzhupaas.ureport.definition;
|
||||
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetColumnData;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public class ColumnDefinition {
|
||||
private int columnNumber;
|
||||
private boolean freeze;
|
||||
private UniverSheetColumnData sheetColumnData;
|
||||
|
||||
protected Column newColumn(List<Column> columns) {
|
||||
Column col = new Column(columns);
|
||||
col.setFreeze(freeze);
|
||||
col.setSheetColumnData(sheetColumnData);
|
||||
return col;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,5 @@
|
||||
package com.yunzhupaas.ureport.definition;
|
||||
|
||||
public enum Expand {
|
||||
Right, Down, None
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package com.yunzhupaas.ureport.definition;
|
||||
|
||||
import com.yunzhupaas.ureport.build.Dataset;
|
||||
import com.yunzhupaas.ureport.model.Cell;
|
||||
import com.yunzhupaas.ureport.model.Column;
|
||||
import com.yunzhupaas.ureport.model.Report;
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
import com.yunzhupaas.ureport.utils.DataUtils;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class ReportDefinition {
|
||||
private String reportFullName;
|
||||
private CellDefinition rootCell;
|
||||
private List<CellDefinition> cells;
|
||||
private List<RowDefinition> rows;
|
||||
private List<ColumnDefinition> columns;
|
||||
private Map<String, Dataset> datasetMap;
|
||||
|
||||
public Report newReport() {
|
||||
Report report = new Report();
|
||||
report.setReportFullName(reportFullName);
|
||||
List<Row> reportRows = new ArrayList<>();
|
||||
List<Column> reportColumns = new ArrayList<>();
|
||||
report.setRows(reportRows);
|
||||
report.setColumns(reportColumns);
|
||||
Map<Integer, Row> rowMap = new HashMap<>();
|
||||
for (RowDefinition rowDef : rows) {
|
||||
Row newRow = rowDef.newRow(reportRows);
|
||||
report.insertRow(newRow, rowDef.getRowNumber());
|
||||
rowMap.put(rowDef.getRowNumber(), newRow);
|
||||
}
|
||||
Map<Integer, Column> columnMap = new HashMap<>();
|
||||
for (ColumnDefinition columnDef : columns) {
|
||||
Column newColumn = columnDef.newColumn(reportColumns);
|
||||
report.insertColumn(newColumn, columnDef.getColumnNumber());
|
||||
columnMap.put(columnDef.getColumnNumber(), newColumn);
|
||||
}
|
||||
Map<CellDefinition, Cell> cellMap = new HashMap<>();
|
||||
for (CellDefinition cellDef : cells) {
|
||||
Cell cell = cellDef.newCell();
|
||||
cellMap.put(cellDef, cell);
|
||||
Row targetRow = rowMap.get(cellDef.getRowNumber());
|
||||
cell.setRow(targetRow);
|
||||
targetRow.getCells().add(cell);
|
||||
Column targetColumn = columnMap.get(cellDef.getColumnNumber());
|
||||
cell.setColumn(targetColumn);
|
||||
targetColumn.getCells().add(cell);
|
||||
|
||||
if (cellDef.getLeftParentCell() == null && cellDef.getTopParentCell() == null) {
|
||||
report.setRootCell(cell);
|
||||
}
|
||||
report.addCell(cell);
|
||||
}
|
||||
for (CellDefinition cellDef : cells) {
|
||||
Cell targetCell = cellMap.get(cellDef);
|
||||
CellDefinition leftParentCellDef = cellDef.getLeftParentCell();
|
||||
if (leftParentCellDef != null) {
|
||||
targetCell.setLeftParentCell(cellMap.get(leftParentCellDef));
|
||||
} else {
|
||||
targetCell.setLeftParentCell(null);
|
||||
}
|
||||
CellDefinition topParentCellDef = cellDef.getTopParentCell();
|
||||
if (topParentCellDef != null) {
|
||||
targetCell.setTopParentCell(cellMap.get(topParentCellDef));
|
||||
} else {
|
||||
targetCell.setTopParentCell(null);
|
||||
}
|
||||
DataUtils.cellList(targetCell, true, true);
|
||||
}
|
||||
// for (CellDefinition cellDef : cells) {
|
||||
// Cell targetCell = cellMap.get(cellDef);
|
||||
//
|
||||
// List<CellDefinition> rowChildrenCellDefinitions =
|
||||
// cellDef.getRowChildrenCells();
|
||||
// for (CellDefinition childCellDef : rowChildrenCellDefinitions) {
|
||||
// Cell childCell = cellMap.get(childCellDef);
|
||||
// targetCell.addRowChild(childCell);
|
||||
// }
|
||||
// List<CellDefinition> columnChildrenCellDefinitions =
|
||||
// cellDef.getColumnChildrenCells();
|
||||
// for (CellDefinition childCellDef : columnChildrenCellDefinitions) {
|
||||
// Cell childCell = cellMap.get(childCellDef);
|
||||
// targetCell.addColumnChild(childCell);
|
||||
// }
|
||||
// }
|
||||
return report;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
package com.yunzhupaas.ureport.definition;
|
||||
|
||||
import com.yunzhupaas.ureport.model.Row;
|
||||
import com.yunzhupaas.univer.sheet.UniverSheetRowData;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@Getter
|
||||
@Setter
|
||||
public class RowDefinition {
|
||||
private int rowNumber;
|
||||
private boolean freeze;
|
||||
private UniverSheetRowData sheetRowData;
|
||||
|
||||
protected Row newRow(List<Row> rows) {
|
||||
Row row = new Row(rows);
|
||||
row.setRowKey("r" + rowNumber);
|
||||
row.setFreeze(freeze);
|
||||
row.setSheetRowData(sheetRowData);
|
||||
return row;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user