Commit 07b48ee2 authored by 黄重's avatar 黄重

提交结构化代码

parent e4055cb3
...@@ -38,7 +38,7 @@ public class ComparisonData { ...@@ -38,7 +38,7 @@ public class ComparisonData {
} }
public String putComparisonContent(String rowId, String titleId, String itemId, String value) { public String putComparisonContent(String rowId, String titleId, String itemId, String value) {
// System.out.println( "keys:" +rowId +","+ titleId+","+itemId + " value :" + value + "\r\n"); System.out.println( "keys:" +rowId +","+ titleId+","+itemId + " value :" + value + "\r\n");
return comparisonContentMap.put(Keys.of(rowId, titleId, itemId), value); return comparisonContentMap.put(Keys.of(rowId, titleId, itemId), value);
} }
......
...@@ -90,7 +90,7 @@ public class ComparisonTable extends KTable { ...@@ -90,7 +90,7 @@ public class ComparisonTable extends KTable {
if (row == 0) return Optional.of(titleColList.get(col / itemSize)).map(Column::getName).orElse(""); if (row == 0) return Optional.of(titleColList.get(col / itemSize)).map(Column::getName).orElse("");
if (row == 1) return Optional.of(itemColList.get(col % itemSize)).map(Column::getName).orElse(""); if (row == 1) return Optional.of(itemColList.get(col % itemSize)).map(Column::getName).orElse("");
try { try {
System.out.println( "keys:" +rowList.get(row - 2) +","+ titleColList.get(col / itemSize).getId()+","+itemColList.get(col % itemSize).getId() + " value :" + comparisonContentMap.get(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId())) + "\r\n"); // System.out.println( "get keys:" +rowList.get(row - 2) +","+ titleColList.get(col / itemSize).getId()+","+itemColList.get(col % itemSize).getId() + " value :" + comparisonContentMap.get(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId())) + "\r\n");
// System.out.println(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId())); // System.out.println(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId()));
// System.out.println(comparisonContentMap.get(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId()))); // System.out.println(comparisonContentMap.get(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId())));
return Optional.of(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId())).map(comparisonContentMap::get).orElse(""); return Optional.of(Keys.of(rowList.get(row - 2), titleColList.get(col / itemSize).getId(), itemColList.get(col % itemSize).getId())).map(comparisonContentMap::get).orElse("");
......
...@@ -2,7 +2,6 @@ package com.gx.obe.struct.composite; ...@@ -2,7 +2,6 @@ package com.gx.obe.struct.composite;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional;
import java.util.OptionalInt; import java.util.OptionalInt;
import java.util.function.Function; import java.util.function.Function;
import java.util.stream.Collectors; import java.util.stream.Collectors;
...@@ -32,9 +31,6 @@ import com.gx.obe.util.utils.CollectionUtils; ...@@ -32,9 +31,6 @@ import com.gx.obe.util.utils.CollectionUtils;
import com.gx.obe.util.utils.StringUtils; import com.gx.obe.util.utils.StringUtils;
import com.gx.obe.web.entity.Supplier; import com.gx.obe.web.entity.Supplier;
import net.sf.json.JSONArray;
import net.sf.json.JSONObject;
public class TemplateTableComparisonComposite extends Composite { public class TemplateTableComparisonComposite extends Composite {
private final TemplateTableService templateTableService = new TemplateTableService(); private final TemplateTableService templateTableService = new TemplateTableService();
...@@ -55,13 +51,26 @@ public class TemplateTableComparisonComposite extends Composite { ...@@ -55,13 +51,26 @@ public class TemplateTableComparisonComposite extends Composite {
RxSwt.run(() -> getComparisonData(tenderId, relChapterType, dataCode, supplierList)).checkWidget(this).exe(comparisonData::set); RxSwt.run(() -> getComparisonData(tenderId, relChapterType, dataCode, supplierList)).checkWidget(this).exe(comparisonData::set);
} }
/**
* 小范本类型数据加载
* @param tenderId
* @param relChapterType
* @param dataCode
* @param supplierList
* @return
*/
private ComparisonData getComparisonData(String tenderId, String relChapterType, String dataCode, List<Supplier> supplierList) { private ComparisonData getComparisonData(String tenderId, String relChapterType, String dataCode, List<Supplier> supplierList) {
/**
* 小范本解析
*/
//获取解析入库的小范本数据
List<TemplateTable> templateTableList = templateTableService.getTemplateTableList(tenderId, relChapterType, dataCode); List<TemplateTable> templateTableList = templateTableService.getTemplateTableList(tenderId, relChapterType, dataCode);
if (CollectionUtils.isNull(templateTableList)) { if (CollectionUtils.isNull(templateTableList)) {
return null; return null;
} }
// List<Tr> trList = null; // List<Tr> trList = null;
int rowCount = 0; int rowCount = 0;
//获取供应商行数最多作为展示表格的行数
Map<String, TemplateTable> templateTableMap = templateTableList.stream().collect(Collectors.toMap(TemplateTable::getSupplierId, Function.identity())); Map<String, TemplateTable> templateTableMap = templateTableList.stream().collect(Collectors.toMap(TemplateTable::getSupplierId, Function.identity()));
for(TemplateTable templateTable : templateTableList) { for(TemplateTable templateTable : templateTableList) {
TableXML2 tableXML = JsonUtil.jsonToBean(templateTable.getTableInfo(), TableXML2.class); TableXML2 tableXML = JsonUtil.jsonToBean(templateTable.getTableInfo(), TableXML2.class);
...@@ -69,10 +78,12 @@ public class TemplateTableComparisonComposite extends Composite { ...@@ -69,10 +78,12 @@ public class TemplateTableComparisonComposite extends Composite {
rowCount = tableXML.getBodyList().size(); rowCount = tableXML.getBodyList().size();
} }
} }
//获取招标文件的小范本,解析表头
TemplateTable templateTable = templateTableMap.get(Constants.BIDDING_ID); TemplateTable templateTable = templateTableMap.get(Constants.BIDDING_ID);
if (templateTable == null) { if (templateTable == null) {
return null; return null;
} }
//表头解析
TableXML2 tableXML = JsonUtil.jsonToBean(templateTable.getTableInfo(), TableXML2.class); TableXML2 tableXML = JsonUtil.jsonToBean(templateTable.getTableInfo(), TableXML2.class);
if (tableXML == null) { if (tableXML == null) {
return null; return null;
...@@ -82,10 +93,6 @@ public class TemplateTableComparisonComposite extends Composite { ...@@ -82,10 +93,6 @@ public class TemplateTableComparisonComposite extends Composite {
return null; return null;
} }
Tr head = headList.get(0); Tr head = headList.get(0);
OptionalInt indexCol = IntStream.range(0, head.getTds().length).filter(i -> "序号".equals(head.getTds()[i].getContent())).findAny();
if (!indexCol.isPresent()) {
return null;
}
ComparisonData comparisonData = new ComparisonData(); ComparisonData comparisonData = new ComparisonData();
// for(Tr tr : tableXML.getBodyList()) { // for(Tr tr : tableXML.getBodyList()) {
// System.out.println(getContent(tr, indexCol.getAsInt())); // System.out.println(getContent(tr, indexCol.getAsInt()));
...@@ -94,66 +101,51 @@ public class TemplateTableComparisonComposite extends Composite { ...@@ -94,66 +101,51 @@ public class TemplateTableComparisonComposite extends Composite {
for(int index = 0; index < rowCount; index++) { for(int index = 0; index < rowCount; index++) {
comparisonData.addRow((index + 1) + ""); comparisonData.addRow((index + 1) + "");
} }
// tableXML.getBodyList().forEach(body -> Optional.ofNullable(getContent(body, indexCol.getAsInt())).filter(StringUtils::isNotEmpty).ifPresent(comparisonData::addRow)); //表头列
for(Supplier supplier : supplierList) { for(Supplier supplier : supplierList) {
comparisonData.addTitleCol(new Column(supplier.getId(), supplier.getSupplierName())); comparisonData.addTitleCol(new Column(supplier.getId(), supplier.getSupplierName()));
} }
// supplierList.forEach(supplier -> { //供应商数据插入
// comparisonData.addTitleCol(new Column(supplier.getId(), supplier.getSupplierName()));
// });
for(int index = 0;index < head.getTds().length; index++) { for(int index = 0;index < head.getTds().length; index++) {
comparisonDataInit(templateTableMap, tableXML, head, indexCol.getAsInt(), index, supplierList, comparisonData); comparisonDataInit(templateTableMap, tableXML, head, index, supplierList, comparisonData);
} }
// IntStream.range(0, head.getTds().length).forEach(i -> {
// comparisonDataInit(templateTableMap, tableXML, head, indexCol.getAsInt(), i, supplierList, comparisonData);
// });
return comparisonData; return comparisonData;
} }
private void comparisonDataInit(Map<String, TemplateTable> templateTableMap, TableXML2 tableXML, Tr head, int indexCol, int col, List<Supplier> supplierList, ComparisonData comparisonData) { private void comparisonDataInit(Map<String, TemplateTable> templateTableMap, TableXML2 tableXML, Tr head, int col, List<Supplier> supplierList, ComparisonData comparisonData) {
Td td = head.getTds()[col]; Td td = head.getTds()[col];
// supplierList.forEach(supplier -> {
// supplierComparisonDataInit(templateTableMap, indexCol, col, supplier, comparisonData);
// });
for(Supplier supplier : supplierList) { for(Supplier supplier : supplierList) {
supplierComparisonDataInit(templateTableMap, indexCol, col, supplier, comparisonData); supplierComparisonDataInit(templateTableMap, col, supplier, comparisonData);
} }
// comparisonData.addItemCol(new Column(col + "", td.getContent()));
comparisonData.addItemCol(new Column(col + "", td.getContent())); comparisonData.addItemCol(new Column(col + "", td.getContent()));
// if (td.isNeedFill()) {
// } else {
// comparisonData.addHeadCol(new Column(col + "", td.getContent()));
// tableXML.getBodyList().forEach(body -> {
// comparisonData.putHeadContent(getContent(body, indexCol), col + "", getContent(body, col));
// });
// }
} }
private void supplierComparisonDataInit(Map<String, TemplateTable> templateTableMap, int indexCol, int col, Supplier supplier, ComparisonData comparisonData) { private void supplierComparisonDataInit(Map<String, TemplateTable> templateTableMap, int col, Supplier supplier, ComparisonData comparisonData) {
TemplateTable supplierTemplateTable = templateTableMap.get(supplier.getId()); TemplateTable supplierTemplateTable = templateTableMap.get(supplier.getId());
if (supplierTemplateTable == null) { if (supplierTemplateTable == null) {
return; return;
} }
TableXML2 supplierTableXML = JsonUtil.jsonToBean(supplierTemplateTable.getTableInfo(), TableXML2.class); TableXML2 supplierTableXML = JsonUtil.jsonToBean(supplierTemplateTable.getTableInfo(), TableXML2.class);
// System.out.println(supplierTemplateTable.getTableInfo());
if (supplierTableXML == null) { if (supplierTableXML == null) {
return; return;
} }
for(Tr tes: supplierTableXML.getBodyList()) { //
comparisonData.putComparisonContent(getContent(tes, indexCol), supplier.getId(), col + "", getContent(tes, col)); int trIndex = 0;
for(Tr tr: supplierTableXML.getBodyList()) {
int tdIndex = 0;
for(Td td : tr.getTds()) {
comparisonData.putComparisonContent(trIndex + "", supplier.getId(), tdIndex + "", td.getContent());
// System.out.println(" put :" + tdIndex + " : "+ supplier.getId() +" : "+ col + "; " + td.getContent());
tdIndex++;
}
trIndex++;
} }
// System.out.println(comparisonData.getComparisonContentMap()); //
// System.out.println();
// supplierTableXML.getBodyList().forEach(body -> {
// comparisonData.putComparisonContent(getContent(body, indexCol), supplier.getId(), col + "", getContent(body, col));
// });
} }
private String getContent(Tr tr, int col) {
// System.out.println(col);
// System.out.println(tr.getTds()[col].getContent());
return tr.getTds()[col].getContent();
}
@Override @Override
protected void checkSubclass() {} protected void checkSubclass() {}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment