From bb18ce8f60c68206cf153598ce9dd6dee59ee2a9 Mon Sep 17 00:00:00 2001 From: taojinlong Date: Sat, 6 May 2023 12:30:13 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AF=86=E5=88=AB=20mysql=20BIGINT=20UN?= =?UTF-8?q?SIGNED?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/dataset/ExtractDataService.java | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java index 35651738da..a97a74f52d 100644 --- a/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java +++ b/backend/src/main/java/io/dataease/service/dataset/ExtractDataService.java @@ -1310,6 +1310,17 @@ public class ExtractDataService { .replace("ExcelCompletion", ""); } + String handleMysqlBIGINTUNSIGNEDStr = ""; + if (datasourceType.equals(DatasourceTypes.mysql)) { + for (DatasetTableField datasetTableField : datasetTableFields) { + if(datasetTableField.getType().equalsIgnoreCase("BIGINT UNSIGNED")){ + handleMysqlBIGINTUNSIGNEDStr = handleMysqlBIGINTUNSIGNEDStr + handleMysqlBIGINTUNSIGNED.replace("BIGINTUNSIGNEDFIELD", datasetTableField.getDataeaseName()) + "; \n"; + } + } + } + tmp_code = tmp_code.replace("handleMysqlBIGINTUNSIGNED", handleMysqlBIGINTUNSIGNEDStr); + + UserDefinedJavaClassDef userDefinedJavaClassDef = new UserDefinedJavaClassDef(UserDefinedJavaClassDef.ClassType.TRANSFORM_CLASS, "Processor", tmp_code); userDefinedJavaClassDef.setActive(true); @@ -1403,6 +1414,16 @@ public class ExtractDataService { " }catch (Exception e){}\n" + " }"; + private final static String handleMysqlBIGINTUNSIGNED = "if(filed.equalsIgnoreCase(BIGINTUNSIGNEDFIELD)){\n" + + "\t\t\tif(tmp != null && tmp.endsWith(\".0\")){\n" + + " \ttry {\n" + + " Long.valueOf(tmp.substring(0, tmp.length()-2));\n" + + " get(Fields.Out, filed).setValue(r, tmp.substring(0, tmp.length()-2));\n" + + " get(Fields.Out, filed).getValueMeta().setType(2);\n" + + " }catch (Exception e){}\n" + + " \t\t}\n" + + "\t\t}"; + private final static String handleWraps = " if(tmp != null && ( tmp.contains(\"\\r\") || tmp.contains(\"\\n\"))){\n" + "\t\t\ttmp = tmp.trim();\n" + " tmp = tmp.replaceAll(\"\\r\",\" \");\n" + @@ -1445,6 +1466,7 @@ public class ExtractDataService { " List fields = Arrays.asList(\"Column_Fields\".split(\",\"));\n" + " for (String filed : fields) {\n" + " String tmp = get(Fields.In, filed).getString(r);\n" + + "handleMysqlBIGINTUNSIGNED \n" + "handleCharset \n" + "handleWraps \n" + "ExcelCompletion \n" +