1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
package com.yanzuoguang.dao.impl;
/**
* 行转列实体
*
* @author 颜佐光
*/
public class CaseSqlModel {
public final static int GROUP_TYPE_SUM = 0;
public final static int GROUP_TYPE_COUNT = 1;
public final static int GROUP_TYPE_AVG = 2;
public final static int GROUP_TYPE_MIN = 3;
public final static int GROUP_TYPE_MAX = 4;
public CaseSqlModel(String caseField, String caseValue, String valueField, String toName) {
this(GROUP_TYPE_SUM, caseField, caseValue, valueField, toName);
}
public CaseSqlModel(int groupType, String caseField, String caseValue, String valueField, String toName) {
this.groupType = groupType;
this.caseField = caseField;
this.caseValue = caseValue;
this.valueField = valueField;
this.toName = toName;
this.andWhere = "";
}
public CaseSqlModel(String caseField, String caseValue, Object value, String toName, String andWhere) {
this(GROUP_TYPE_SUM, caseField, caseValue, value, toName, andWhere);
}
public CaseSqlModel(int groupType, String caseField, String caseValue, Object value, String toName, String andWhere) {
this.groupType = groupType;
this.caseField = caseField;
this.caseValue = caseValue;
this.value = value;
this.toName = toName;
this.andWhere = andWhere;
}
public CaseSqlModel(String caseField, String caseValue, String valueField, String toName, String andWhere) {
this(GROUP_TYPE_SUM, caseField, caseValue, valueField, toName, andWhere);
}
public CaseSqlModel(int groupType, String caseField, String caseValue, String valueField, String toName, String andWhere) {
this.groupType = groupType;
this.caseField = caseField;
this.caseValue = caseValue;
this.valueField = valueField;
this.toName = toName;
this.andWhere = andWhere;
}
/**
* 统计纬度
*/
private int groupType;
/**
* 需要判断的字段
*/
private String caseField;
/**
* 需要判断的值
*/
private String caseValue;
/**
* 需要统计的字段,和 value 只能存在一个,ValueField优先级更高
*/
private String valueField;
/**
* 需要统计的值,和 ValueField只能存在一个,ValueField优先级更高
*/
private Object value;
/**
* 目标字段名称
*/
private String toName;
/**
* 需要判断的CASE字段的附加条件
*/
private String andWhere;
public int getGroupType() {
return groupType;
}
public void setGroupType(int groupType) {
this.groupType = groupType;
}
public String getCaseField() {
return caseField;
}
public void setCaseField(String caseField) {
this.caseField = caseField;
}
public String getCaseValue() {
return caseValue;
}
public void setCaseValue(String caseValue) {
this.caseValue = caseValue;
}
public String getValueField() {
return valueField;
}
public void setValueField(String valueField) {
this.valueField = valueField;
}
public Object getValue() {
return value;
}
public void setValue(Object value) {
this.value = value;
}
public String getToName() {
return toName;
}
public void setToName(String toName) {
this.toName = toName;
}
public String getAndWhere() {
return andWhere;
}
public void setAndWhere(String andWhere) {
this.andWhere = andWhere;
}
}