|
|
@ -1,8 +1,9 @@ |
|
|
|
package com.fr.plugin.decision.request.handler; |
|
|
|
package com.fr.plugin.decision.request.handler; |
|
|
|
|
|
|
|
|
|
|
|
import com.finebi.activate.foundation.StableManager; |
|
|
|
import com.finebi.activate.foundation.StableManager; |
|
|
|
import com.finebi.burger.api.bean.configuration.table.attachment.FineAttachment; |
|
|
|
|
|
|
|
import com.finebi.burger.api.bean.configuration.table.field.FineBusinessField; |
|
|
|
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.DataBaseAddTableItemRequestBean; |
|
|
|
import com.finebi.burger.api.request.configuration.table.DataBaseAddTableRequestBean; |
|
|
|
import com.finebi.burger.api.request.configuration.table.DataBaseAddTableRequestBean; |
|
|
|
import com.finebi.burger.api.response.configuration.table.TableAddResponseBean; |
|
|
|
import com.finebi.burger.api.response.configuration.table.TableAddResponseBean; |
|
|
@ -12,9 +13,11 @@ import com.finebi.common.impl.vo.table.FineDBBusinessTable; |
|
|
|
import com.finebi.direct.burger.api.service.FineTableService; |
|
|
|
import com.finebi.direct.burger.api.service.FineTableService; |
|
|
|
import com.finebi.direct.burger.api.service.FineUserInfoService; |
|
|
|
import com.finebi.direct.burger.api.service.FineUserInfoService; |
|
|
|
import com.finebi.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.reponse.FineRespond; |
|
|
|
import com.finebi.foundation.api.reponse.FineRespond; |
|
|
|
import com.finebi.foundation.api.service.FineService; |
|
|
|
import com.finebi.foundation.api.service.FineService; |
|
|
|
import com.finebi.foundation.api.service.context.BaseContext; |
|
|
|
import com.finebi.foundation.api.service.context.BaseContext; |
|
|
|
|
|
|
|
import com.finebi.foundation.api.structure.result.BIDetailResult; |
|
|
|
import com.finebi.utils.CompareUtils; |
|
|
|
import com.finebi.utils.CompareUtils; |
|
|
|
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; |
|
|
@ -30,11 +33,6 @@ import com.fr.stable.StringUtils; |
|
|
|
import com.fr.third.fasterxml.jackson.core.JsonGenerationException; |
|
|
|
import com.fr.third.fasterxml.jackson.core.JsonGenerationException; |
|
|
|
import com.fr.third.fasterxml.jackson.databind.JsonMappingException; |
|
|
|
import com.fr.third.fasterxml.jackson.databind.JsonMappingException; |
|
|
|
import com.fr.third.fasterxml.jackson.databind.ObjectMapper; |
|
|
|
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; |
|
|
|
import com.finebi.direct.common.api.cell.context.CellCreator; |
|
|
|
import com.finebi.common.impl.vo.table.FineBusinessTable; |
|
|
|
import com.finebi.common.impl.vo.table.FineBusinessTable; |
|
|
|
import com.finebi.common.impl.vo.table.FineExcelBusinessTable; |
|
|
|
import com.finebi.common.impl.vo.table.FineExcelBusinessTable; |
|
|
@ -56,6 +54,7 @@ public class UpgradeHandler extends HWAbstractHandler { |
|
|
|
protected void deal(HttpServletRequest req, HttpServletResponse res, JSONObject para, JSONObject result) throws Exception { |
|
|
|
protected void deal(HttpServletRequest req, HttpServletResponse res, JSONObject para, JSONObject result) throws Exception { |
|
|
|
|
|
|
|
|
|
|
|
String connection = para.getString("connection"); |
|
|
|
String connection = para.getString("connection"); |
|
|
|
|
|
|
|
UserAuthority authorityUser = getFineUserInfoService().getUserAuthority(req); |
|
|
|
|
|
|
|
|
|
|
|
Connection conn = JdbcUtils.getConnection(connection); |
|
|
|
Connection conn = JdbcUtils.getConnection(connection); |
|
|
|
|
|
|
|
|
|
|
@ -75,57 +74,22 @@ public class UpgradeHandler extends HWAbstractHandler { |
|
|
|
allTables.stream().filter(fineBusinessTable -> fineBusinessTable instanceof FineExcelBusinessTable).limit(15).forEach(fineBusinessTable -> { |
|
|
|
allTables.stream().filter(fineBusinessTable -> fineBusinessTable instanceof FineExcelBusinessTable).limit(15).forEach(fineBusinessTable -> { |
|
|
|
Map<String, List> values = new HashMap<String, List>(); |
|
|
|
Map<String, List> values = new HashMap<String, List>(); |
|
|
|
JSONArray items = JSONArray.create(); |
|
|
|
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 { |
|
|
|
try { |
|
|
|
if (fileName.endsWith(".xlsx")) { |
|
|
|
Optional<BIDetailResult> optionalBIDetailResult = new BurgerTableDataCellImpl().getRealDataWithAuth(fineBusinessTable, new ConfLimitInfo(500000, new ConfPageInfo(500000, 1)), authorityUser); |
|
|
|
|
|
|
|
BIDetailResult detailResult = optionalBIDetailResult.get(); |
|
|
|
XSSFWorkbook excelWork = HWUtils.getExcelWork(attachId); |
|
|
|
values = HWUtils.getValues(fields, detailResult); |
|
|
|
if(excelWork != null){ |
|
|
|
for(int i = 0; i < fields.size(); i++){ |
|
|
|
SXSSFWorkbook swb = new SXSSFWorkbook(excelWork,100); |
|
|
|
FineBusinessField field = fields.get(i); |
|
|
|
XSSFWorkbook xssfWorkbook = swb.getXSSFWorkbook(); |
|
|
|
JSONObject item = new JSONObject(); |
|
|
|
XSSFSheet sheet = xssfWorkbook.getSheetAt(sheetNo); |
|
|
|
item.put("colLength", "8000"); |
|
|
|
JSONObject tableCol = JSONObject.create(); |
|
|
|
item.put("colName", field.getName()); |
|
|
|
for(int i = 0; i < fields.size(); i++){ |
|
|
|
item.put("colType", this.getFieldSqlType(field.getType())); |
|
|
|
FineBusinessField field = fields.get(i); |
|
|
|
item.put("excelCol", i); |
|
|
|
tableCol.put(field.getName(), i); |
|
|
|
item.put("id", field.getId()); |
|
|
|
|
|
|
|
items.put(item); |
|
|
|
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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
values = HWUtils.getSheetContent(sheet, 0, tableCol); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} else if (fileName.endsWith(".xls")) { |
|
|
|
|
|
|
|
HSSFWorkbook excel2003Work = HWUtils.getExcel2003Work(attachId); |
|
|
|
|
|
|
|
if(excel2003Work != null){ |
|
|
|
|
|
|
|
HSSFSheet sheetAt = excel2003Work.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", "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); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
values = HWUtils.get2003SheetContent(sheetAt,0, tableCol); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} catch (Exception e) { |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
e.printStackTrace(); |
|
|
@ -153,8 +117,6 @@ public class UpgradeHandler extends HWAbstractHandler { |
|
|
|
JSONArray tables = JSONArray.create().put(table); |
|
|
|
JSONArray tables = JSONArray.create().put(table); |
|
|
|
JSONObject tablesBean = JSONObject.create().put("tables", tables); |
|
|
|
JSONObject tablesBean = JSONObject.create().put("tables", tables); |
|
|
|
try{ |
|
|
|
try{ |
|
|
|
UserAuthority authorityUser = getFineUserInfoService().getUserAuthority(req); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Optional<FineBusinessPackage> packageIdWithoutAuth = CellCreator.getCellProvider().packageCell().getPackageByTableNameWithoutAuth(tableName); |
|
|
|
Optional<FineBusinessPackage> packageIdWithoutAuth = CellCreator.getCellProvider().packageCell().getPackageByTableNameWithoutAuth(tableName); |
|
|
|
FineBusinessPackage businessPackage = packageIdWithoutAuth.get(); |
|
|
|
FineBusinessPackage businessPackage = packageIdWithoutAuth.get(); |
|
|
|
String packId = businessPackage.getId(); |
|
|
|
String packId = businessPackage.getId(); |
|
|
|