|
|
@ -1,5 +1,8 @@ |
|
|
|
package com.fr.plugin.decision.request.handler; |
|
|
|
package com.fr.plugin.decision.request.handler; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import com.finebi.burger.api.request.configuration.table.DataBaseAddTableRequestBean; |
|
|
|
|
|
|
|
import com.finebi.common.api.cell.user.authority.UserAuthority; |
|
|
|
|
|
|
|
import com.finebi.common.api.vo.table.FineBusinessTable; |
|
|
|
import com.fr.decision.webservice.v10.user.UserService; |
|
|
|
import com.fr.decision.webservice.v10.user.UserService; |
|
|
|
import com.fr.json.JSONArray; |
|
|
|
import com.fr.json.JSONArray; |
|
|
|
import com.fr.json.JSONObject; |
|
|
|
import com.fr.json.JSONObject; |
|
|
@ -10,6 +13,9 @@ import com.fr.plugin.decision.core.action.ExcelDmlAction; |
|
|
|
import com.fr.plugin.decision.dao.ExcelLinkService; |
|
|
|
import com.fr.plugin.decision.dao.ExcelLinkService; |
|
|
|
import com.fr.plugin.decision.utils.JdbcUtils; |
|
|
|
import com.fr.plugin.decision.utils.JdbcUtils; |
|
|
|
import com.fr.stable.StringUtils; |
|
|
|
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.fr.third.org.apache.poi.hssf.usermodel.HSSFSheet; |
|
|
|
import com.fr.third.org.apache.poi.hssf.usermodel.HSSFSheet; |
|
|
|
import com.fr.third.org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
|
|
import com.fr.third.org.apache.poi.hssf.usermodel.HSSFWorkbook; |
|
|
|
import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
|
import com.fr.third.v2.org.apache.poi.xssf.usermodel.XSSFSheet; |
|
|
@ -18,6 +24,7 @@ import com.fr.web.utils.WebUtils; |
|
|
|
|
|
|
|
|
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletRequest; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
import javax.servlet.http.HttpServletResponse; |
|
|
|
|
|
|
|
import java.io.IOException; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.sql.Connection; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
@ -80,6 +87,33 @@ public class TableDataImport extends HWAbstractHandler { |
|
|
|
ExcelLinkService.getInstance().addLink(name, connection, schema, tableName, createUser); |
|
|
|
ExcelLinkService.getInstance().addLink(name, connection, schema, tableName, createUser); |
|
|
|
FineLoggerFactory.getLogger().info("HW_excel导入:FineDB 新增数据成功" + name); |
|
|
|
FineLoggerFactory.getLogger().info("HW_excel导入:FineDB 新增数据成功" + name); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (StringUtils.equals("success", dmlResult.getString("status")) || StringUtils.contains(dmlResult.getString("errorText"), "existed")) { |
|
|
|
|
|
|
|
ObjectMapper mapper = new ObjectMapper(); |
|
|
|
|
|
|
|
JSONObject table = JSONObject.create().put("tableName", tableName).put("connectionName", connection); |
|
|
|
|
|
|
|
JSONArray tables = JSONArray.create().put(table); |
|
|
|
|
|
|
|
JSONObject tablesBean = JSONObject.create().put("tables", tables); |
|
|
|
|
|
|
|
try{ |
|
|
|
|
|
|
|
UserAuthority authorityUser = UpgradeHandler.getFineUserInfoService().getUserAuthority(req); |
|
|
|
|
|
|
|
String userId = authorityUser.getUser().getInfo().getUserId(); |
|
|
|
|
|
|
|
String packId = "__my_analysis__" + userId + 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try { |
|
|
|
|
|
|
|
String tableString = tablesBean.toString(); |
|
|
|
|
|
|
|
FineBusinessTable[] businessTables = UpgradeHandler.createBusinessTablesFromDBNewAddTableInfo(mapper.readValue(tableString, DataBaseAddTableRequestBean.class), userId); |
|
|
|
|
|
|
|
UpgradeHandler.getTableService().addNewTable(packId, authorityUser, businessTables); |
|
|
|
|
|
|
|
} catch (JsonMappingException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} catch (JsonGenerationException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} catch (IOException e) { |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} catch(Exception e){ |
|
|
|
|
|
|
|
e.printStackTrace(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
WebUtils.printAsJSON(res, dmlResult); |
|
|
|
WebUtils.printAsJSON(res, dmlResult); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|