Browse Source

feat: 一键删除及一些针对碧桂园的处理

upgrade
Zhenfei.Li 4 years ago
parent
commit
f4c9b19b3e
  1. BIN
      fr-plugin-hwExcelExport-1.8.3.zip
  2. 5
      src/main/java/com/fr/plugin/decision/core/ExcelDmlBean.java
  3. 4
      src/main/java/com/fr/plugin/decision/request/handler/CheckSizeHandler.java
  4. 110
      src/main/java/com/fr/plugin/decision/request/handler/UpgradeHandler.java
  5. 9
      src/main/resources/com/fr/plugin/hw/decision/js/pane/left.linklist.js
  6. 8
      src/main/resources/com/fr/plugin/hw/decision/js/pane/left.linklist.model.js
  7. 2
      src/main/resources/com/fr/plugin/hw/decision/js/table.info.model.js

BIN
fr-plugin-hwExcelExport-1.8.3.zip

Binary file not shown.

5
src/main/java/com/fr/plugin/decision/core/ExcelDmlBean.java

@ -34,7 +34,10 @@ public class ExcelDmlBean {
}
table = new Table(schema, tableName);
rowCount = tableValue.get(tableColName.get(0)).size();
rowCount = 0;
if (tableValue.size() > 0 && tableColName.size() > 0) {
rowCount = tableValue.get(tableColName.get(0)).size();
};
}
public List<Boolean> getTablePrimaryKey() {

4
src/main/java/com/fr/plugin/decision/request/handler/CheckSizeHandler.java

@ -6,7 +6,7 @@ import com.finebi.common.impl.vo.table.FineExcelBusinessTable;
import com.finebi.dashboard.impl.service.helper.FineDashBoardTableHelper;
import com.finebi.direct.burger.api.service.FineUserInfoService;
import com.finebi.direct.common.api.cell.context.CellCreator;
import com.finebi.direct.common.api.cell.user.authority.UserAuthority;
import com.finebi.common.api.cell.user.authority.UserAuthority;
import com.finebi.direct.common.impl.engine.BurgerTableDataCellImpl;
import com.finebi.foundation.api.service.FineService;
import com.finebi.foundation.api.service.context.BaseContext;
@ -43,7 +43,7 @@ public class CheckSizeHandler extends HWAbstractHandler {
if (fineBusinessTable instanceof FineExcelBusinessTable) {
try {
UserAuthority authorityUser = getFineUserInfoService().getUserAuthority(req);
Optional<BIDetailResult> data = new BurgerTableDataCellImpl().getRealDataWithAuth(fineBusinessTable, new ConfLimitInfo(30000, new ConfPageInfo()), authorityUser);
Optional<BIDetailResult> data = new BurgerTableDataCellImpl().getRealDataWithAuth(fineBusinessTable, new ConfLimitInfo(500000, new ConfPageInfo()), authorityUser);
BIDetailResult detailResult = data.get();
JSONObject excel = JSONObject.create();

110
src/main/java/com/fr/plugin/decision/request/handler/UpgradeHandler.java

@ -11,7 +11,7 @@ import com.finebi.common.impl.vo.relation.FineBusinessRelation;
import com.finebi.common.impl.vo.table.FineDBBusinessTable;
import com.finebi.direct.burger.api.service.FineTableService;
import com.finebi.direct.burger.api.service.FineUserInfoService;
import com.finebi.direct.common.api.cell.user.authority.UserAuthority;
import com.finebi.common.api.cell.user.authority.UserAuthority;
import com.finebi.foundation.api.reponse.FineRespond;
import com.finebi.foundation.api.service.FineService;
import com.finebi.foundation.api.service.context.BaseContext;
@ -32,6 +32,7 @@ import com.fr.third.fasterxml.jackson.databind.JsonMappingException;
import com.fr.third.fasterxml.jackson.databind.ObjectMapper;
import com.fr.third.org.apache.poi.hssf.usermodel.HSSFSheet;
import com.fr.third.org.apache.poi.hssf.usermodel.HSSFWorkbook;
import com.fr.third.v2.org.apache.poi.xssf.streaming.SXSSFWorkbook;
import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFSheet;
import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFWorkbook;
import com.finebi.direct.common.api.cell.context.CellCreator;
@ -71,28 +72,31 @@ public class UpgradeHandler extends HWAbstractHandler {
JSONObject finalResult = JSONObject.create();
List<FineBusinessTable> allTables = CellCreator.getCellProvider().tableCell().getAllTableWithoutAuth();
allTables.forEach(fineBusinessTable -> {
allTables.stream().filter(fineBusinessTable -> fineBusinessTable instanceof FineExcelBusinessTable).limit(15).forEach(fineBusinessTable -> {
Map<String, List> values = new HashMap<String, List>();
if (fineBusinessTable instanceof FineExcelBusinessTable) {
JSONArray items = JSONArray.create();
FineAttachment sheetInfo = ((FineExcelBusinessTable) fineBusinessTable).getBaseAttach();
String attachId = sheetInfo.getId();
String fileName = sheetInfo.getFileName();
int sheetNo = 0;
JSONArray items = JSONArray.create();
FineAttachment sheetInfo = ((FineExcelBusinessTable) fineBusinessTable).getBaseAttach();
String attachId = sheetInfo.getId();
String fileName = sheetInfo.getFileName();
int sheetNo = 0;
List<FineBusinessField> fields = ((FineExcelBusinessTable) fineBusinessTable).getExcelFields();
List<FineBusinessField> fields = ((FineExcelBusinessTable) fineBusinessTable).getExcelFields();
try {
if (fileName.endsWith(".xlsx")) {
XSSFWorkbook excelWork = HWUtils.getExcelWork(attachId);
if(excelWork != null){
XSSFSheet sheet = excelWork.getSheetAt(sheetNo);
SXSSFWorkbook swb = new SXSSFWorkbook(excelWork,100);
XSSFWorkbook xssfWorkbook = swb.getXSSFWorkbook();
XSSFSheet sheet = xssfWorkbook.getSheetAt(sheetNo);
JSONObject tableCol = JSONObject.create();
for(int i = 0; i < fields.size(); i++){
FineBusinessField field = fields.get(i);
tableCol.put(field.getName(), i);
JSONObject item = new JSONObject();
item.put("colLength", "255");
item.put("colLength", "8000");
item.put("colName", field.getName());
item.put("colType", this.getFieldSqlType(field.getType()));
item.put("excelCol", i);
@ -112,7 +116,7 @@ public class UpgradeHandler extends HWAbstractHandler {
tableCol.put(field.getName(), i);
JSONObject item = new JSONObject();
item.put("colLength", "255");
item.put("colLength", "8000");
item.put("colName", field.getName());
item.put("colType", this.getFieldSqlType(field.getType()));
item.put("excelCol", i);
@ -123,62 +127,62 @@ public class UpgradeHandler extends HWAbstractHandler {
values = HWUtils.get2003SheetContent(sheetAt,0, tableCol);
}
}
} catch (Exception e) {
e.printStackTrace();
}
String schema = "";
String tableName = fineBusinessTable.getName();
String schema = "";
String tableName = fineBusinessTable.getName();
ExcelDmlAction excelDmlAction = ActionFactory.getInstance().create("add");
ExcelDmlAction excelDmlAction = ActionFactory.getInstance().create("add");
excelDmlAction.setExcelDmlBean( new ExcelDmlBean(connection, schema, tableName, items, values) );
excelDmlAction.setExcelDmlBean( new ExcelDmlBean(connection, schema, tableName, items, values) );
try {
JSONObject dmlResult = excelDmlAction.execute();
importDbResult.put(dmlResult);
try {
JSONObject dmlResult = excelDmlAction.execute();
importDbResult.put(dmlResult);
if (StringUtils.equals("success", dmlResult.getString("status")) && dmlResult.getBoolean("addLink")) {
ExcelLinkService.getInstance().addLink(tableName, connection, schema, tableName, createUser);
FineLoggerFactory.getLogger().info("HW_excel导入:FineDB 新增数据成功" + tableName);
}
if (StringUtils.equals("success", dmlResult.getString("status")) && dmlResult.getBoolean("addLink")) {
ExcelLinkService.getInstance().addLink(tableName, connection, schema, tableName, createUser);
FineLoggerFactory.getLogger().info("HW_excel导入:FineDB 新增数据成功" + tableName);
}
if (StringUtils.equals("success", dmlResult.getString("status")) || StringUtils.contains(dmlResult.getString("errorText"), "exist")) {
ObjectMapper mapper = new ObjectMapper();
JSONObject table = JSONObject.create().put("tableName", fineBusinessTable.getName()).put("connectionName", connection);
JSONArray tables = JSONArray.create().put(table);
JSONObject tablesBean = JSONObject.create().put("tables", tables);
try{
UserAuthority authorityUser = getFineUserInfoService().getUserAuthority(req);
if (StringUtils.equals("success", dmlResult.getString("status")) || StringUtils.contains(dmlResult.getString("errorText"), "exist")) {
ObjectMapper mapper = new ObjectMapper();
JSONObject table = JSONObject.create().put("tableName", fineBusinessTable.getName()).put("connectionName", connection);
JSONArray tables = JSONArray.create().put(table);
JSONObject tablesBean = JSONObject.create().put("tables", tables);
try{
UserAuthority authorityUser = getFineUserInfoService().getUserAuthority(req);
Optional<FineBusinessPackage> packageIdWithoutAuth = CellCreator.getCellProvider().packageCell().getPackageByTableNameWithoutAuth(tableName);
FineBusinessPackage businessPackage = packageIdWithoutAuth.get();
String packId = businessPackage.getId();
Optional<FineBusinessPackage> packageIdWithoutAuth = CellCreator.getCellProvider().packageCell().getPackageByTableNameWithoutAuth(tableName);
FineBusinessPackage businessPackage = packageIdWithoutAuth.get();
String packId = businessPackage.getId();
List<FineBusinessRelation> fineBusinessRelations = CellCreator.getCellProvider().relationPathCell().getRelationsByTableNameWithoutAuth(fineBusinessTable.getName());
List<FineBusinessRelation> fineBusinessRelations = CellCreator.getCellProvider().relationPathCell().getRelationsByTableNameWithoutAuth(fineBusinessTable.getName());
CellCreator.getCellProvider().tableCell().removeTable(fineBusinessTable.getName(), CellCreator.getCellProvider().userCellProvider().authorityCell().getSuperAuthority());
CellCreator.getCellProvider().tableCell().removeTable(fineBusinessTable.getName(), CellCreator.getCellProvider().userCellProvider().authorityCell().getSuperAuthority());
// String packId = "__my_analysis__" + fineBusinessTable.getCreateByWithId() + "1";
try {
String tableString = tablesBean.toString();
FineBusinessTable[] businessTables = createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), authorityUser.getUser().getInfo().getUserId());
TableAddResponseBean responed = getTableService().addNewTable(packId, authorityUser, businessTables);
CellCreator.getCellProvider().relationPathCell().addRelations(fineBusinessRelations, authorityUser);
addDbResult.put(FineRespond.success(responed));
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch(Exception e){
try {
String tableString = tablesBean.toString();
FineBusinessTable[] businessTables = createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), authorityUser.getUser().getInfo().getUserId());
TableAddResponseBean responed = getTableService().addNewTable(packId, authorityUser, businessTables);
CellCreator.getCellProvider().relationPathCell().addRelations(fineBusinessRelations, authorityUser);
addDbResult.put(FineRespond.success(responed));
} catch (JsonMappingException e) {
e.printStackTrace();
} catch (JsonGenerationException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
} catch(Exception e){
e.printStackTrace();
}
} catch(Exception e){
e.printStackTrace();
}
} catch(Exception e){
e.printStackTrace();
}
});

9
src/main/resources/com/fr/plugin/hw/decision/js/pane/left.linklist.js

@ -45,6 +45,15 @@
self.linkListPane = _ref;
}
}, top: 10, left: 0, right: 0, bottom: 10
}, {
el: {
type: "bi.button",
text: "一键删除",
height: 24,
handler: function () {
self.store.deleteAllLink();
}
}, top: -34, left: 100, right: 50, bottom: -10
}]
};
},

8
src/main/resources/com/fr/plugin/hw/decision/js/pane/left.linklist.model.js

@ -89,6 +89,14 @@
BI.emptyFn)
},
//删除全部: 仅内部人员使用
deleteAllLink: function(){
var self = this;
BI.each(self.model.linklist, function (i, v) {
self.deleteLink(v.id);
});
},
setSelectedLink: function(v){
this.model.selectedLink = v;
}

2
src/main/resources/com/fr/plugin/hw/decision/js/table.info.model.js

@ -5,7 +5,7 @@
return {
items: [],
connection: "",
schema: "",
schema: "guest",
tableName: "",
excelItems: [],
infoId: o.infoId,

Loading…
Cancel
Save