Browse Source

feat: 增加excel数据量检测功能

upgrade-final
Zhenfei.Li 5 years ago
parent
commit
40694215b3
  1. 3
      src/main/java/com/fr/plugin/decision/request/HWHandlerProvider.java
  2. 3
      src/main/java/com/fr/plugin/decision/request/HWURLAliasProvider.java
  3. 4
      src/main/java/com/fr/plugin/decision/request/handler/CheckNameHandler.java
  4. 55
      src/main/java/com/fr/plugin/decision/request/handler/CheckSizeHandler.java
  5. 3
      src/main/java/com/fr/plugin/decision/request/handler/UpgradeHandler.java
  6. 4
      src/main/resources/com/fr/plugin/hw/decision/js/hw.option.js
  7. 66
      src/main/resources/com/fr/plugin/hw/decision/js/pane/check/check.js
  8. 19
      src/main/resources/com/fr/plugin/hw/decision/js/pane/check/check.model.js
  9. 4
      src/main/resources/com/fr/plugin/hw/decision/js/pane/panes.js
  10. 2
      src/main/resources/com/fr/plugin/hw/decision/js/pane/upgrade/upgrade.js
  11. 7
      src/main/resources/com/fr/plugin/hw/decision/js/utils.js

3
src/main/java/com/fr/plugin/decision/request/HWHandlerProvider.java

@ -16,7 +16,8 @@ public class HWHandlerProvider extends AbstractHttpHandlerProvider {
new ExcelFiledHandler(),
new TableDataImport(),
new UpgradeHandler(),
new CheckHandler()
new CheckNameHandler(),
new CheckSizeHandler()
};
}
}

3
src/main/java/com/fr/plugin/decision/request/HWURLAliasProvider.java

@ -17,7 +17,8 @@ public class HWURLAliasProvider extends AbstractURLAliasProvider {
URLAliasFactory.createPluginAlias(ExcelFiledHandler.PATH, ExcelFiledHandler.PATH,false),
URLAliasFactory.createPluginAlias(TableDataImport.PATH, TableDataImport.PATH,false),
URLAliasFactory.createPluginAlias(UpgradeHandler.PATH, UpgradeHandler.PATH,false),
URLAliasFactory.createPluginAlias(CheckHandler.PATH, CheckHandler.PATH,false),
URLAliasFactory.createPluginAlias(CheckNameHandler.PATH, CheckNameHandler.PATH,false),
URLAliasFactory.createPluginAlias(CheckSizeHandler.PATH, CheckSizeHandler.PATH,false),
};
}
}

4
src/main/java/com/fr/plugin/decision/request/handler/CheckHandler.java → src/main/java/com/fr/plugin/decision/request/handler/CheckNameHandler.java

@ -19,8 +19,8 @@ import java.sql.DatabaseMetaData;
import java.util.ArrayList;
import java.sql.ResultSet;
public class CheckHandler extends HWAbstractHandler {
public static final String PATH="/excelmng/check";
public class CheckNameHandler extends HWAbstractHandler {
public static final String PATH="/excelmng/check/name";
@Override
protected void deal(HttpServletRequest req, HttpServletResponse res, JSONObject para, JSONObject result) throws Exception {

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

@ -0,0 +1,55 @@
package com.fr.plugin.decision.request.handler;
import com.finebi.common.api.cell.context.CellCreator;
import com.finebi.common.authority.api.FineAuthorityUtils;
import com.finebi.common.authority.decision.role.FineAuthorityUser;
import com.finebi.common.impl.vo.table.FineBusinessTable;
import com.finebi.common.impl.vo.table.FineExcelBusinessTable;
import com.finebi.direct.common.impl.engine.BurgerTableDataCellImpl;
import com.finebi.burger.api.bean.configuration.table.page.ConfLimitInfo;
import com.finebi.burger.api.bean.configuration.table.page.ConfPageInfo;
import com.finebi.foundation.api.structure.result.BIDetailResult;
import com.fr.json.JSONObject;
import com.fr.web.utils.WebUtils;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
public class CheckSizeHandler extends HWAbstractHandler {
public static final String PATH="/excelmng/check/size";
@Override
protected void deal(HttpServletRequest req, HttpServletResponse res, JSONObject para, JSONObject result) throws Exception {
JSONObject finalResult = JSONObject.create();
ArrayList<JSONObject> excelList = new ArrayList<JSONObject>();
List<FineBusinessTable> allTables = CellCreator.getCellProvider().tableCell().getAllTableWithoutAuth();
allTables.forEach(fineBusinessTable -> {
if (fineBusinessTable instanceof FineExcelBusinessTable) {
try {
FineAuthorityUser authorityUser = FineAuthorityUtils.getAuth(req);
Optional<BIDetailResult> data = new BurgerTableDataCellImpl().getRealDataWithAuth(fineBusinessTable, new ConfLimitInfo(30000, new ConfPageInfo()), authorityUser);
BIDetailResult detailResult = data.get();
JSONObject excel = JSONObject.create();
excel.put("transferName", fineBusinessTable.getTransferName()).
put("rowCount", detailResult.totalRowSize());
excelList.add(excel);
} catch(Exception e){
e.printStackTrace();
}
}
});
WebUtils.printAsJSON(res, finalResult.put("data", excelList));
}
@Override
public String getPath() {
return PATH;
}
}

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

@ -169,8 +169,7 @@ public class UpgradeHandler extends HWAbstractHandler {
} catch (IOException e) {
e.printStackTrace();
}
}
catch(Exception e){
} catch(Exception e){
e.printStackTrace();
}
}

4
src/main/resources/com/fr/plugin/hw/decision/js/hw.option.js

@ -38,6 +38,9 @@
BI.$import(commPath + "/pane/upgrade/upgrade.js");
BI.$import(commPath + "/pane/upgrade/upgrade.model.js");
BI.$import(commPath + "/pane/check/check.js");
BI.$import(commPath + "/pane/check/check.model.js");
BI.config("dec.constant.management.navigation", function (items) {
items.push({
@ -100,5 +103,6 @@
{value: "export", text: "Excel数据管理"},
{value: "auth", text: "Excel权限管理"},
{value: "upgrade", text: "一键升级旧Excel"},
{value: "check", text: "检测excel"},
]);
})();

66
src/main/resources/com/fr/plugin/hw/decision/js/pane/check/check.js

@ -0,0 +1,66 @@
!(function () {
var UpgradePane = BI.inherit(BI.Widget, {
props: {
baseCls: "dec-mng-check"
},
_store: function () {
return BI.Models.getModel("dec.model.mng.check");
},
watch: {
result: function (items) {
this.list.populate(this._createItems(items));
this.count.setText("excel表总数: " + BI.size(items));
}
},
render: function () {
var self = this;
return {
type: "bi.vertical",
width: 640,
hgap: 50,
vgap: 50,
items: [{
type: "bi.center_adapt",
items: [{
type: "bi.button",
width: 200,
text: "检测所有excel的大小",
handler: self.store.getResult
}]
}, {
type: "bi.center_adapt",
items: [{
type: "bi.label",
text: "excel表总数: 0",
ref: function (_ref) {
self.count = _ref;
}
}]
}, {
type: "bi.vertical",
ref: function (_ref) {
self.list = _ref;
}
}]
};
},
_createItems: function (items) {
return BI.map(items, function (idx, item) {
var text = "【" + item.transferName + "】数据量: " + item.rowCount;
return {
type: "bi.horizontal",
items: [{
type: "bi.label",
textAlign: "left",
text: text
}]
}
});
}
});
BI.shortcut("dec.mng.check", UpgradePane);
})();

19
src/main/resources/com/fr/plugin/hw/decision/js/pane/check/check.model.js

@ -0,0 +1,19 @@
!(function () {
var Model = BI.inherit(Fix.Model, {
state: function () {
return {
result: []
};
},
actions: {
getResult: function () {
var self = this;
Dec.HW.checkSize({}, function (res) {
self.model.result = res.data;
});
}
}
});
BI.model("dec.model.mng.check", Model);
})();

4
src/main/resources/com/fr/plugin/hw/decision/js/pane/panes.js

@ -64,6 +64,10 @@
return {
type: "dec.mng.upgrade"
};
case "check":
return {
type: "dec.mng.check"
};
}
}
}]

2
src/main/resources/com/fr/plugin/hw/decision/js/pane/upgrade/upgrade.js

@ -58,7 +58,7 @@
width: 200,
text: "重名检测",
handler: function () {
Dec.HW.check({
Dec.HW.checkName({
connection: self.connection.getValue()[0]
}, function (res) {
var tip = "以下excel与数据库中已存在的表重名:"

7
src/main/resources/com/fr/plugin/hw/decision/js/utils.js

@ -25,8 +25,11 @@
upgrade: function (config, callback) {
Dec.reqPost("/url/excelmng/upgrade", config, callback)
},
check: function (config, callback) {
Dec.reqPost("/url/excelmng/check", config, callback)
checkName: function (config, callback) {
Dec.reqPost("/url/excelmng/check/name", config, callback)
},
checkSize: function (config, callback) {
Dec.reqPost("/url/excelmng/check/size", config, callback)
}
})
})();
Loading…
Cancel
Save