11 changed files with 187 additions and 9 deletions
@ -0,0 +1,81 @@ |
|||||||
|
package com.fr.plugin.decision.request.handler; |
||||||
|
|
||||||
|
import com.finebi.activate.foundation.StableManager; |
||||||
|
import com.finebi.common.impl.vo.table.FineBusinessTable; |
||||||
|
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.direct.common.impl.engine.BurgerTableDataCellImpl; |
||||||
|
import com.finebi.foundation.api.service.FineService; |
||||||
|
import com.finebi.foundation.api.service.context.BaseContext; |
||||||
|
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.finebi.foundation.constant.BICommonConstants; |
||||||
|
import com.finebi.widget.direct.impl.provider.authority.AuthorityUserHelper; |
||||||
|
import com.fr.json.JSONObject; |
||||||
|
import com.fr.log.FineLoggerFactory; |
||||||
|
import com.fr.plugin.decision.utils.JdbcUtils; |
||||||
|
import com.fr.web.utils.WebUtils; |
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletRequest; |
||||||
|
import javax.servlet.http.HttpServletResponse; |
||||||
|
import java.sql.Connection; |
||||||
|
import java.sql.DatabaseMetaData; |
||||||
|
import java.sql.ResultSet; |
||||||
|
import java.sql.SQLException; |
||||||
|
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 { |
||||||
|
UserAuthority authorityUser = getFineUserInfoService().getUserAuthority(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; |
||||||
|
} |
||||||
|
|
||||||
|
protected static FineUserInfoService getFineUserInfoService() { |
||||||
|
return getBean(FineUserInfoService.class); |
||||||
|
} |
||||||
|
|
||||||
|
private static <T extends FineService> T getBean(Class<T> annotatedClass) { |
||||||
|
return getContext().getServiceBean(annotatedClass); |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* service获取集合 |
||||||
|
*/ |
||||||
|
private static BaseContext getContext() { |
||||||
|
return StableManager.getContext(); |
||||||
|
} |
||||||
|
} |
@ -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); |
||||||
|
})(); |
@ -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); |
||||||
|
})(); |
Loading…
Reference in new issue