Compare commits
No commits in common. 'upgrade-final' and 'master' have entirely different histories.
upgrade-fi
...
master
28 changed files with 60 additions and 772 deletions
Binary file not shown.
@ -1,80 +0,0 @@ |
|||||||
package com.fr.plugin.decision.request.handler; |
|
||||||
|
|
||||||
import com.finebi.activate.foudation.StableManager; |
|
||||||
import com.finebi.common.impl.vo.table.FineBusinessTable; |
|
||||||
import com.finebi.common.impl.vo.table.FineExcelBusinessTable; |
|
||||||
import com.finebi.common.api.cell.context.CellCreator; |
|
||||||
import com.finebi.foundation.api.service.context.BaseContext; |
|
||||||
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.util.List; |
|
||||||
import java.sql.SQLException; |
|
||||||
import java.sql.DatabaseMetaData; |
|
||||||
import java.util.ArrayList; |
|
||||||
import java.sql.ResultSet; |
|
||||||
|
|
||||||
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 { |
|
||||||
|
|
||||||
String connection = para.getString("connection"); |
|
||||||
|
|
||||||
Connection conn = JdbcUtils.getConnection(connection); |
|
||||||
|
|
||||||
if (conn == null){ |
|
||||||
FineLoggerFactory.getLogger().error("HW_excel校验重名:数据链接 " + connection + " 获取异常" ); |
|
||||||
WebUtils.printAsJSON(res, new JSONObject().put("status","fail").put("errorText","获取数据连接异常")); |
|
||||||
return; |
|
||||||
} |
|
||||||
List<String> tables = getTables(conn); |
|
||||||
|
|
||||||
JSONObject finalResult = JSONObject.create(); |
|
||||||
|
|
||||||
ArrayList<String> excelList = new ArrayList<String>(); |
|
||||||
|
|
||||||
List<FineBusinessTable> allTables = CellCreator.getCellProvider().tableCell().getAllTableWithoutAuth(); |
|
||||||
allTables.forEach(fineBusinessTable -> { |
|
||||||
if (fineBusinessTable instanceof FineExcelBusinessTable) { |
|
||||||
excelList.add(fineBusinessTable.getName()); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
tables.retainAll(excelList); |
|
||||||
|
|
||||||
WebUtils.printAsJSON(res, finalResult.put("checkResult", tables)); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPath() { |
|
||||||
return PATH; |
|
||||||
} |
|
||||||
|
|
||||||
/** |
|
||||||
* service获取集合 |
|
||||||
*/ |
|
||||||
private static BaseContext getContext() { |
|
||||||
return StableManager.getContext(); |
|
||||||
} |
|
||||||
|
|
||||||
/**获取数据库中所有表名称 |
|
||||||
* @param conn |
|
||||||
* @return |
|
||||||
* @throws SQLException |
|
||||||
*/ |
|
||||||
private static List<String> getTables(Connection conn) throws SQLException { |
|
||||||
DatabaseMetaData databaseMetaData = conn.getMetaData(); |
|
||||||
ResultSet tables = databaseMetaData.getTables(null, null, "%", null); |
|
||||||
ArrayList<String> tablesList = new ArrayList<String>(); |
|
||||||
while (tables.next()) { |
|
||||||
tablesList.add(tables.getString("TABLE_NAME")); |
|
||||||
} |
|
||||||
return tablesList; |
|
||||||
} |
|
||||||
} |
|
@ -1,55 +0,0 @@ |
|||||||
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(500000, 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; |
|
||||||
} |
|
||||||
} |
|
@ -1,215 +0,0 @@ |
|||||||
package com.fr.plugin.decision.request.handler; |
|
||||||
|
|
||||||
import com.finebi.activate.foundation.StableManager; |
|
||||||
import com.finebi.burger.api.bean.configuration.table.field.FineBusinessField; |
|
||||||
import com.finebi.burger.api.bean.configuration.table.page.ConfLimitInfo; |
|
||||||
import com.finebi.burger.api.bean.configuration.table.page.ConfPageInfo; |
|
||||||
import com.finebi.burger.api.request.configuration.table.DataBaseAddTableItemRequestBean; |
|
||||||
import com.finebi.burger.api.request.configuration.table.DataBaseAddTableRequestBean; |
|
||||||
import com.finebi.burger.api.response.configuration.table.TableAddResponseBean; |
|
||||||
import com.finebi.burger.api.service.FineTableService; |
|
||||||
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.pack.FineBusinessPackage; |
|
||||||
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.common.api.cell.user.authority.UserAuthority; |
|
||||||
import com.finebi.direct.common.impl.engine.BurgerTableDataCellImpl; |
|
||||||
import com.finebi.foundation.api.reponse.FineRespond; |
|
||||||
import com.finebi.foundation.api.service.FineService; |
|
||||||
import com.finebi.foundation.api.service.context.BaseContext; |
|
||||||
import com.finebi.foundation.api.structure.result.BIDetailResult; |
|
||||||
import com.finebi.utils.CompareUtils; |
|
||||||
import com.fr.decision.webservice.v10.user.UserService; |
|
||||||
import com.fr.json.JSONArray; |
|
||||||
import com.fr.json.JSONObject; |
|
||||||
import com.fr.log.FineLoggerFactory; |
|
||||||
import com.fr.plugin.decision.HWUtils; |
|
||||||
import com.fr.plugin.decision.core.ActionFactory; |
|
||||||
import com.fr.plugin.decision.core.ExcelDmlBean; |
|
||||||
import com.fr.plugin.decision.core.action.ExcelDmlAction; |
|
||||||
import com.fr.plugin.decision.dao.ExcelLinkService; |
|
||||||
import com.fr.plugin.decision.utils.JdbcUtils; |
|
||||||
import com.fr.stable.StringUtils; |
|
||||||
import com.fr.third.fasterxml.jackson.core.JsonGenerationException; |
|
||||||
import com.fr.third.fasterxml.jackson.databind.JsonMappingException; |
|
||||||
import com.fr.third.fasterxml.jackson.databind.ObjectMapper; |
|
||||||
import com.finebi.direct.common.api.cell.context.CellCreator; |
|
||||||
import com.finebi.common.impl.vo.table.FineBusinessTable; |
|
||||||
import com.finebi.common.impl.vo.table.FineExcelBusinessTable; |
|
||||||
import com.fr.web.utils.WebUtils; |
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletRequest; |
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse; |
|
||||||
import java.io.IOException; |
|
||||||
import java.sql.Connection; |
|
||||||
import java.util.HashMap; |
|
||||||
import java.util.List; |
|
||||||
import java.util.Map; |
|
||||||
import java.util.Optional; |
|
||||||
|
|
||||||
public class UpgradeHandler extends HWAbstractHandler { |
|
||||||
public static final String PATH="/excelmng/upgrade"; |
|
||||||
@Override |
|
||||||
protected void deal(HttpServletRequest req, HttpServletResponse res, JSONObject para, JSONObject result) throws Exception { |
|
||||||
|
|
||||||
String connection = para.getString("connection"); |
|
||||||
FineAuthorityUser authorityUser = FineAuthorityUtils.getAuth(req); |
|
||||||
|
|
||||||
Connection conn = JdbcUtils.getConnection(connection); |
|
||||||
|
|
||||||
if (conn == null){ |
|
||||||
FineLoggerFactory.getLogger().error("HW_excel导入:数据链接 " + connection + " 获取异常" ); |
|
||||||
WebUtils.printAsJSON(res, new JSONObject().put("status","fail").put("errorText","获取数据连接异常")); |
|
||||||
return; |
|
||||||
} |
|
||||||
|
|
||||||
final String createUser = UserService.getInstance().getCurrentUserIdFromCookie(req); |
|
||||||
|
|
||||||
JSONArray importDbResult = JSONArray.create(); |
|
||||||
JSONArray addDbResult = JSONArray.create(); |
|
||||||
JSONObject finalResult = JSONObject.create(); |
|
||||||
|
|
||||||
List<FineBusinessTable> allTables = CellCreator.getCellProvider().tableCell().getAllTableWithoutAuth(); |
|
||||||
|
|
||||||
allTables.stream().filter(fineBusinessTable -> fineBusinessTable instanceof FineExcelBusinessTable).limit(15).forEach(fineBusinessTable -> { |
|
||||||
Map<String, List> values = new HashMap<String, List>(); |
|
||||||
JSONArray items = JSONArray.create(); |
|
||||||
|
|
||||||
List<FineBusinessField> fields = ((FineExcelBusinessTable) fineBusinessTable).getExcelFields(); |
|
||||||
|
|
||||||
try { |
|
||||||
Optional<BIDetailResult> optionalBIDetailResult = new BurgerTableDataCellImpl().getRealDataWithAuth(fineBusinessTable, new ConfLimitInfo(500000, new ConfPageInfo(500000, 1)), authorityUser); |
|
||||||
BIDetailResult detailResult = optionalBIDetailResult.get(); |
|
||||||
values = HWUtils.getValues(fields, detailResult); |
|
||||||
for(int i = 0; i < fields.size(); i++){ |
|
||||||
FineBusinessField field = fields.get(i); |
|
||||||
JSONObject item = new JSONObject(); |
|
||||||
item.put("colLength", "8000"); |
|
||||||
item.put("colName", field.getName()); |
|
||||||
item.put("colType", this.getFieldSqlType(field.getType())); |
|
||||||
item.put("excelCol", i); |
|
||||||
item.put("id", field.getId()); |
|
||||||
items.put(item); |
|
||||||
} |
|
||||||
} catch (Exception e){ |
|
||||||
e.printStackTrace(); |
|
||||||
}; |
|
||||||
|
|
||||||
String schema = "guest"; |
|
||||||
String tableName = fineBusinessTable.getName(); |
|
||||||
|
|
||||||
ExcelDmlAction excelDmlAction = ActionFactory.getInstance().create("add"); |
|
||||||
|
|
||||||
excelDmlAction.setExcelDmlBean( new ExcelDmlBean(connection, schema, tableName, items, values) ); |
|
||||||
|
|
||||||
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")) || 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{ |
|
||||||
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()); |
|
||||||
|
|
||||||
CellCreator.getCellProvider().tableCell().removeTable(fineBusinessTable.getName(), FineAuthorityUser.ROOT_USER_ID); |
|
||||||
// String packId = "__my_analysis__" + fineBusinessTable.getCreateByWithId() + "1";
|
|
||||||
try { |
|
||||||
String tableString = tablesBean.toString(); |
|
||||||
FineBusinessTable[] businessTables = createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), authorityUser.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(); |
|
||||||
} |
|
||||||
}); |
|
||||||
|
|
||||||
WebUtils.printAsJSON(res, finalResult.put("importDbResult", importDbResult).put("addDbResult", addDbResult)); |
|
||||||
} |
|
||||||
|
|
||||||
@Override |
|
||||||
public String getPath() { |
|
||||||
return PATH; |
|
||||||
} |
|
||||||
|
|
||||||
protected static FineTableService getTableService() { |
|
||||||
return (FineTableService)getBean(FineTableService.class); |
|
||||||
} |
|
||||||
|
|
||||||
private static <T extends FineService> T getBean(Class<T> annotatedClass) { |
|
||||||
return getContext().getServiceBean(annotatedClass); |
|
||||||
} |
|
||||||
private static BaseContext getContext() { |
|
||||||
return StableManager.getContext(); |
|
||||||
} |
|
||||||
|
|
||||||
private int getFieldSqlType(int fieldType) { |
|
||||||
if (CompareUtils.isEqual(fieldType, 16)) { |
|
||||||
return 12; |
|
||||||
} else if (CompareUtils.isEqual(fieldType, 32)) { |
|
||||||
return 8; |
|
||||||
} else if (CompareUtils.isEqual(fieldType, 48)) { |
|
||||||
return 91; |
|
||||||
} |
|
||||||
return 12; |
|
||||||
} |
|
||||||
|
|
||||||
public static FineBusinessTable[] createBusinessTablesFromDBNewAddTableInfo(DataBaseAddTableRequestBean bean, String userId) { |
|
||||||
List<DataBaseAddTableItemRequestBean> items = bean.getTables(); |
|
||||||
FineBusinessTable[] businessTables = new FineBusinessTable[items.size()]; |
|
||||||
for (int i = 0; i < businessTables.length; i++) { |
|
||||||
DataBaseAddTableItemRequestBean item = items.get(i); |
|
||||||
FineBusinessTable table = createBusinessTableByItem(item, userId); |
|
||||||
businessTables[i] = table; |
|
||||||
} |
|
||||||
return businessTables; |
|
||||||
} |
|
||||||
|
|
||||||
private static FineBusinessTable createBusinessTableByItem(DataBaseAddTableItemRequestBean item, String userId) { |
|
||||||
|
|
||||||
return createDBBusinessTable(item, userId); |
|
||||||
} |
|
||||||
|
|
||||||
private static FineBusinessTable createDBBusinessTable(DataBaseAddTableItemRequestBean item, String userId) { |
|
||||||
FineDBBusinessTable table = new FineDBBusinessTable(); |
|
||||||
table.setConnectionName(item.getConnectionName()); |
|
||||||
table.setTableName(item.getDbTableName()); |
|
||||||
table.setCreateByWithId(userId); |
|
||||||
String tableName = getTableNameWithConnection(item); |
|
||||||
table.setId(tableName); |
|
||||||
table.setName(tableName); |
|
||||||
return table; |
|
||||||
} |
|
||||||
|
|
||||||
private static String getTableNameWithConnection(DataBaseAddTableItemRequestBean itemBean) { |
|
||||||
return itemBean.getDbTableName(); |
|
||||||
} |
|
||||||
} |
|
@ -1,15 +0,0 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
|
||||||
<module type="JAVA_MODULE" version="4"> |
|
||||||
<component name="NewModuleRootManager"> |
|
||||||
<output url="file://$USER_HOME$/env/direct-bi/WEB-INF/plugins/plugin-com.fr.plugin.hw.import.excel-2.0.0/classes" /> |
|
||||||
<output-test url="file://$MODULE_DIR$/../../../../direct-bi/nuclear-maven/classes/test/main" /> |
|
||||||
<exclude-output /> |
|
||||||
<content url="file://$MODULE_DIR$"> |
|
||||||
<sourceFolder url="file://$MODULE_DIR$/java" isTestSource="false" /> |
|
||||||
</content> |
|
||||||
<orderEntry type="inheritedJdk" /> |
|
||||||
<orderEntry type="sourceFolder" forTests="false" /> |
|
||||||
<orderEntry type="library" name="lib" level="project" /> |
|
||||||
<orderEntry type="module" module-name="direct-common-adapter" /> |
|
||||||
</component> |
|
||||||
</module> |
|
@ -1,66 +0,0 @@ |
|||||||
!(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); |
|
||||||
})(); |
|
@ -1,19 +0,0 @@ |
|||||||
!(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); |
|
||||||
})(); |
|
@ -1,148 +0,0 @@ |
|||||||
!(function () { |
|
||||||
var UpgradePane = BI.inherit(BI.Widget, { |
|
||||||
props: { |
|
||||||
baseCls: "dec-mng-upgrade" |
|
||||||
}, |
|
||||||
|
|
||||||
_store: function () { |
|
||||||
return BI.Models.getModel("dec.model.mng.upgrade"); |
|
||||||
}, |
|
||||||
|
|
||||||
watch: { |
|
||||||
addDbResult: function (v) { |
|
||||||
this.addList.populate(this._createAddItems(v)); |
|
||||||
}, |
|
||||||
importDbResult: function (v) { |
|
||||||
this.importList.populate(this._createImportItems(v)); |
|
||||||
} |
|
||||||
}, |
|
||||||
|
|
||||||
beforeInit: function (callback) { |
|
||||||
this.store.initData(callback); |
|
||||||
}, |
|
||||||
|
|
||||||
render: function () { |
|
||||||
var self = this; |
|
||||||
return { |
|
||||||
type: "bi.vertical", |
|
||||||
width: 640, |
|
||||||
vgap: 15, |
|
||||||
items: [{ |
|
||||||
type: "bi.vertical_adapt", |
|
||||||
items: [{ |
|
||||||
type: "bi.label", |
|
||||||
textAlign: "right", |
|
||||||
cls: "dec-font-weight-bold", |
|
||||||
text: "数据源:", |
|
||||||
title: "数据源", |
|
||||||
width: 100 |
|
||||||
}, { |
|
||||||
el: { |
|
||||||
type: "bi.text_value_combo", |
|
||||||
lgap: 4, |
|
||||||
cls: "bi-border", |
|
||||||
textAlign: "left", |
|
||||||
items: this.model.connectionItems, |
|
||||||
width: 480, |
|
||||||
height: 22, |
|
||||||
ref: function (_ref) { |
|
||||||
self.connection = _ref; |
|
||||||
} |
|
||||||
}, |
|
||||||
lgap: 10 |
|
||||||
}] |
|
||||||
}, { |
|
||||||
type: "bi.center_adapt", |
|
||||||
items: [{ |
|
||||||
type: "bi.button", |
|
||||||
width: 200, |
|
||||||
text: "重名检测", |
|
||||||
handler: function () { |
|
||||||
Dec.HW.checkName({ |
|
||||||
connection: self.connection.getValue()[0] |
|
||||||
}, function (res) { |
|
||||||
var tip = "以下excel与数据库中已存在的表重名:" |
|
||||||
BI.each(res.checkResult, function (i, tableName) { |
|
||||||
tip += "\n" + tableName; |
|
||||||
}) |
|
||||||
BI.Msg.toast(tip, { |
|
||||||
autoClose: false, |
|
||||||
level: "warning" |
|
||||||
}); |
|
||||||
}); |
|
||||||
} |
|
||||||
}, { |
|
||||||
type: "bi.button", |
|
||||||
width: 200, |
|
||||||
text: "升级旧Excel", |
|
||||||
handler: function () { |
|
||||||
Dec.HW.upgrade({ |
|
||||||
connection: self.connection.getValue()[0] |
|
||||||
}, function (res) { |
|
||||||
self.store.setAddDbResult(res.addDbResult); |
|
||||||
self.store.setImportDbResult(res.importDbResult); |
|
||||||
}); |
|
||||||
} |
|
||||||
}] |
|
||||||
}, { |
|
||||||
type: "bi.vertical", |
|
||||||
items: [{ |
|
||||||
type: "bi.label", |
|
||||||
text: "------Excel导入成数据库表报错信息------", |
|
||||||
textAlign: "left" |
|
||||||
}, { |
|
||||||
type: "bi.button_group", |
|
||||||
height: 300, |
|
||||||
items: [], |
|
||||||
layouts: [{ |
|
||||||
type: "bi.vertical", |
|
||||||
scrolly: true |
|
||||||
}], |
|
||||||
ref: function (_ref) { |
|
||||||
self.importList = _ref; |
|
||||||
} |
|
||||||
}, { |
|
||||||
type: "bi.label", |
|
||||||
text: "------从数据库表创建到自助数据集报错信息------", |
|
||||||
textAlign: "left" |
|
||||||
}, { |
|
||||||
type: "bi.button_group", |
|
||||||
height: 300, |
|
||||||
items: [], |
|
||||||
layouts: [{ |
|
||||||
type: "bi.vertical", |
|
||||||
scrolly: true |
|
||||||
}], |
|
||||||
ref: function (_ref) { |
|
||||||
self.addList = _ref; |
|
||||||
} |
|
||||||
}] |
|
||||||
}] |
|
||||||
}; |
|
||||||
}, |
|
||||||
|
|
||||||
_createAddItems: function (array) { |
|
||||||
var items = BI.filter(array, function (idx, item) { |
|
||||||
return !item.success; |
|
||||||
}); |
|
||||||
return BI.map(items, function (idx, item) { |
|
||||||
return { |
|
||||||
type: "bi.label", |
|
||||||
textAlign: "left", |
|
||||||
text: item.errorMsg |
|
||||||
} |
|
||||||
}); |
|
||||||
}, |
|
||||||
|
|
||||||
_createImportItems: function (array) { |
|
||||||
return BI.map(array, function (idx, item) { |
|
||||||
return { |
|
||||||
type: "bi.label", |
|
||||||
textAlign: "left", |
|
||||||
text: item.status === "failed" ? item.errorText : item.text |
|
||||||
} |
|
||||||
}) |
|
||||||
} |
|
||||||
}); |
|
||||||
BI.shortcut("dec.mng.upgrade", UpgradePane); |
|
||||||
})(); |
|
@ -1,33 +0,0 @@ |
|||||||
!(function () { |
|
||||||
var Model = BI.inherit(Fix.Model, { |
|
||||||
state: function () { |
|
||||||
return { |
|
||||||
connectionItems: [], |
|
||||||
addDbResult: [], |
|
||||||
importDbResult: [] |
|
||||||
}; |
|
||||||
}, |
|
||||||
|
|
||||||
actions: { |
|
||||||
initData: function (callback) { |
|
||||||
var self = this; |
|
||||||
Dec.Utils.getConnections(function (res) { |
|
||||||
self.model.connectionItems = BI.map(res, function (i, val) { |
|
||||||
return { |
|
||||||
text: val.connectionName || "", |
|
||||||
value: val.connectionName || "" |
|
||||||
}; |
|
||||||
}); |
|
||||||
callback(); |
|
||||||
}); |
|
||||||
}, |
|
||||||
setAddDbResult: function (result) { |
|
||||||
this.model.addDbResult = result; |
|
||||||
}, |
|
||||||
setImportDbResult: function (result) { |
|
||||||
this.model.importDbResult = result; |
|
||||||
} |
|
||||||
} |
|
||||||
}); |
|
||||||
BI.model("dec.model.mng.upgrade", Model); |
|
||||||
})(); |
|
Loading…
Reference in new issue