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
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
package com.gx.obe.struct.composite;
import java.util.List;
import java.util.Optional;
import java.util.function.Consumer;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.eclipse.swt.SWT;
import org.eclipse.swt.core.widgets.ELink;
import org.eclipse.swt.core.widgets.ESepator;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.events.MouseListener;
import org.eclipse.swt.layout.FillLayout;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Label;
import com.gx.obe.ColorConstants;
import com.gx.obe.bind.prop.Prop;
import com.gx.obe.common.widget.button.RectangleRadioButton;
import com.gx.obe.component.handler.TabHandler;
import com.gx.obe.component.rx.RxSwt;
import com.gx.obe.components.core.Constants;
import com.gx.obe.components.core.global.Global;
import com.gx.obe.components.core.inter.PdfFileView;
import com.gx.obe.struct.beans.ModelData;
import com.gx.obe.struct.enums.DataCategoryEnum;
import com.gx.obe.struct.enums.EvaluationFactorTypeEnum;
import com.gx.obe.struct.enums.ModelDataTypeEnum;
import com.gx.obe.struct.handler.RelChapterTypeHandler;
import com.gx.obe.struct.parse.BidFileIndexTreeXmlParse;
import com.gx.obe.struct.service.EvaluationContentService;
import com.gx.obe.struct.service.ModelDataService;
import com.gx.obe.util.utils.CollectionUtils;
import com.gx.obe.web.entity.evaluation.EvaluationContent;
import com.swtdesigner.SWTResourceManager;
public class EvaluationContentComposite extends Composite {
private final EvaluationContentService evaluationContentService = new EvaluationContentService();
private final ModelDataService modelDataService = new ModelDataService();
private final String tenderId;
private final Prop<EvaluationContentData> evaluationContentData = new Prop<>();
private final Prop<PdfFileData> pdfFileData = new Prop<>();
private final Prop<String> tips = new Prop<>();
private final Prop<Boolean> showFile = new Prop<>();
private final Prop<Boolean> showSwitch = new Prop<>(false);
private class RootNodeChapterData {
private String name;
private String type;
}
private class EvaluationContentData {
private String supplierId;
private EvaluationFactorTypeEnum factorTypeEnum;
private List<EvaluationContent> evaluationContentList;
}
private class PdfFileData {
private String url;
private int pageNum;
}
public EvaluationContentComposite(Composite parent, String tenderId) {
super(parent, SWT.NONE);
this.tenderId = tenderId;
setBackground(SWTResourceManager.getColor(SWT.COLOR_WHITE));
setBackgroundMode(SWT.INHERIT_FORCE);
GridLayout gridLayout = new GridLayout(1, false);
gridLayout.verticalSpacing = 0;
gridLayout.marginHeight = 0;
gridLayout.marginWidth = 0;
setLayout(gridLayout);
Composite composite_5 = new Composite(this, SWT.NONE);
composite_5.setLayoutData(new GridData(SWT.FILL, SWT.FILL, false, false, 1, 1));
GridLayout gl_composite_5 = new GridLayout(2, false);
gl_composite_5.marginHeight = 0;
gl_composite_5.marginWidth = 0;
composite_5.setLayout(gl_composite_5);
Composite composite = new Composite(composite_5, SWT.NONE);
composite.setLayoutData(new GridData(SWT.FILL, SWT.BOTTOM, true, true, 1, 1));
RowLayout rl_composite = new RowLayout(SWT.HORIZONTAL);
rl_composite.marginBottom = 0;
rl_composite.marginTop = 0;
composite.setLayout(rl_composite);
TabHandler<RectangleRadioButton> handler = new TabHandler<>(composite, t -> new RectangleRadioButton(t, SWT.NONE));
Composite composite_6 = new Composite(composite_5, SWT.NONE);
GridLayout gl_composite_6 = new GridLayout(1, false);
gl_composite_6.marginHeight = 4;
composite_6.setLayout(gl_composite_6);
ELink link = new ELink(composite_6, SWT.NONE);
link.addMouseListener(MouseListener.mouseUpAdapter($ -> showFile.replace(t -> !t)));
link.setText("切换视图");
showSwitch.bind(link::setVisible);
ESepator label_1 = new ESepator(this, SWT.HORIZONTAL);
label_1.setLayoutData(new GridData(SWT.FILL, SWT.CENTER, true, false, 1, 1));
label_1.setBackground(ColorConstants.SKIN_BG);
StackLayout stackLayout = new StackLayout();
Composite composite_1 = new Composite(this, SWT.NONE);
composite_1.setLayout(stackLayout);
composite_1.setLayoutData(new GridData(SWT.FILL, SWT.FILL, true, true, 1, 1));
Consumer<Composite> topControl = t -> {
stackLayout.topControl = t;
composite_1.layout();
};
ModelDataComposite composite_2 = new ModelDataComposite(composite_1, tenderId);
Composite composite_3 = new Composite(composite_1, SWT.NONE);
composite_3.setLayout(new FillLayout(SWT.HORIZONTAL));
PdfFileView load = Global.PDF_FILE_VIEW.load(composite_3, SWT.NONE);
load.setFileNotExistMessage("文件不存在,请检查是否已下载投标文件!");
pdfFileData.bind(t -> load.openFile(t.url, t.pageNum));
Composite composite_4 = new Composite(composite_1, SWT.NONE);
composite_4.setLayout(new GridLayout(1, false));
Label label = new Label(composite_4, SWT.WRAP);
label.setForeground(SWTResourceManager.getColor(200, 200, 200));
label.setFont(SWTResourceManager.getFont("宋体", 20, SWT.BOLD));
label.setLayoutData(new GridData(SWT.CENTER, SWT.CENTER, true, true, 1, 1));
tips.bind(t -> {
label.setText(t);
label.getParent().layout();
});
showFile.bind(t -> {
if (t) topControl.accept(composite_3);
else topControl.accept(composite_2);
});
evaluationContentData.bind(d -> {
showSwitch.set(false);
handler.start();
if (CollectionUtils.isNull(d.evaluationContentList)) {
rootNodeChapter(handler, d.factorTypeEnum, t -> {
showFile.set(true);
RxSwt.run(() -> getFilePath(d.supplierId, t.type)).checkWidget(this).exe(pdfFileData::set);
});
} else {
handler.listHand(d.evaluationContentList, EvaluationContent::getEvalPointName, t -> {
showSwitch.set(false);
switch (DataCategoryEnum.MAP.getOrDefault(t.getDataCategory(), DataCategoryEnum.NULL)) {
case MD:
getModelData(t.getRelChapterType(), d.supplierId, md -> {
if (md == null) {
topControl.accept(composite_4);
tips.set("当前供应商未检测到" + t.getEvalPointName() + ",请检查是否已解析结构化数据!");
} else {
if (ModelDataTypeEnum.EQ_ProjectLeader.getKey().equals(md.getRelChapterType())) {
showSwitch.set(true);
showFile.set(false);
composite_2.refresh(t, md);
RxSwt.run(() -> getFilePath(d.supplierId, "EnterpriseQualification_technology")).checkWidget(this).exe(pdfFileData::set);
} else {
showFile.set(false);
composite_2.refresh(t, md);
}
}
});
break;
case TDI:
case TT:
case NULL:
showFile.set(true);
RxSwt.run(() -> getFilePath(d.supplierId, t.getRelChapterType())).checkWidget(this).exe(pdfFileData::set);
break;
}
});
}
handler.end();
});
}
private void rootNodeChapter(TabHandler<RectangleRadioButton> handler, EvaluationFactorTypeEnum factorTypeEnum, Consumer<RootNodeChapterData> callback) {
handler.listHand(initRootNodeChapterList(factorTypeEnum).map(t -> {
String[] split = t.split("-", 2);
RootNodeChapterData chapterData = new RootNodeChapterData();
chapterData.type = split[0];
chapterData.name = split[1];
return chapterData;
}).collect(Collectors.toList()), t -> t.name, callback);
}
private void getModelData(String _relChapterType, String supplierId, Consumer<ModelData> consumer) {
RelChapterTypeHandler typeHandler = new RelChapterTypeHandler(_relChapterType);
Optional<ModelDataTypeEnum> modelDataTypeEnum = Optional.of(typeHandler.getRelChapterType()).map(ModelDataTypeEnum.MAP::get);
String relChapterType = modelDataTypeEnum.map(ModelDataTypeEnum.EQ_ProjectLeader::equals).orElse(false) ? typeHandler.getRelChapterType() : _relChapterType;
RxSwt.run(() -> modelDataService.getModelData(tenderId, supplierId, relChapterType, relChapterType)).checkWidget(this).exe(consumer);
}
private Stream<String> initRootNodeChapterList(EvaluationFactorTypeEnum factorTypeEnum) {
if (EvaluationFactorTypeEnum.BUSINESS == factorTypeEnum) {
return Stream.of("Business-商务标");
}
if (EvaluationFactorTypeEnum.TECHNOLOGY == factorTypeEnum) {
return Stream.of("Technology-技术标");
}
return Stream.of("Business-商务标", "Technology-技术标", "Price-报价");
}
public void refresh(String supplierId, String factorCode, EvaluationFactorTypeEnum factorTypeEnum) {
RxSwt.run(() -> {
EvaluationContentData evaluationContentData = new EvaluationContentData();
evaluationContentData.supplierId = supplierId;
evaluationContentData.factorTypeEnum = factorTypeEnum;
evaluationContentData.evaluationContentList = evaluationContentService.getEvaluationContentListByFactorCode(tenderId, factorCode);
return evaluationContentData;
}).checkWidget(this).exe(evaluationContentData::set);
}
private PdfFileData getFilePath(String supplierId, String relChapterType) {
BidFileIndexTreeXmlParse bidFileIndexTreeXmlParse = new BidFileIndexTreeXmlParse(Constants.getBidFilePath(tenderId, supplierId), relChapterType);
PdfFileData pdfFileData = new PdfFileData();
pdfFileData.url = bidFileIndexTreeXmlParse.getRootNodeFilePath();
pdfFileData.pageNum = bidFileIndexTreeXmlParse.getPageNumInGenerateFile();
return pdfFileData;
}
@Override
protected void checkSubclass() {}
}