Explorar el Código

common-util 改为项目内本地 jar;修复 max(org_id) 按字符串字典序取最大值的问题

lifuchao hace 3 semanas
padre
commit
c9571c113b

BIN
lib/common-util-2.0-SNAPSHOT.jar


+ 7 - 0
pom.xml

@@ -61,10 +61,13 @@
61 61
             <artifactId>guava</artifactId>
62 62
             <version>27.1-jre</version>
63 63
         </dependency>
64
+        <!-- 公司私有包,中央仓库没有,直接用项目内的 jar,不再从仓库解析 -->
64 65
         <dependency>
65 66
             <groupId>com.gct.common.util</groupId>
66 67
             <artifactId>common-util</artifactId>
67 68
             <version>2.0-SNAPSHOT</version>
69
+            <scope>system</scope>
70
+            <systemPath>${project.basedir}/lib/common-util-2.0-SNAPSHOT.jar</systemPath>
68 71
         </dependency>
69 72
         <dependency>
70 73
             <groupId>com.oracle</groupId>
@@ -203,6 +206,10 @@
203 206
             <plugin>
204 207
                 <groupId>org.springframework.boot</groupId>
205 208
                 <artifactId>spring-boot-maven-plugin</artifactId>
209
+                <configuration>
210
+                    <!-- system scope 的 jar 默认不打进 BOOT-INF/lib,这里必须打开,否则运行时找不到 SGTUtil 等类 -->
211
+                    <includeSystemScope>true</includeSystemScope>
212
+                </configuration>
206 213
             </plugin>
207 214
             <plugin>
208 215
                 <groupId>org.apache.maven.plugins</groupId>

+ 4 - 3
src/main/java/com/gct/tools/etlcamelhuge/routeconfig/CamelJDBCConfiguration.java

@@ -63,13 +63,14 @@ public class CamelJDBCConfiguration {
63 63
                     org = 0;
64 64
                     orgIdPreList = new HashMap<>();
65 65
                 })
66
-                        //先取已有的最大 org_id,新机构从这个值往后排
67
-                        .setBody(simple("select max(org_id) from centralbase.cb_pc_organization"))
66
+                        //org_id 在库里存的是字符串,直接 max 会按字典序比较("9" 会大于 "10"),
67
+                        //所以先转成整数再取最大值,新机构从这个值往后排
68
+                        .setBody(simple("select max(org_id::int) from centralbase.cb_pc_organization"))
68 69
                         .to("jdbc:centralbase")
69 70
                         .process(exchange -> {
70 71
                     HashMap<String, Object> aRow = exchange.getIn().getBody(HashMap.class);
71 72
                     Object max = aRow == null ? null : aRow.get("max");
72
-                    //max(org_id) 的返回类型由列类型决定(numeric 会返回 BigDecimal,toString 得到 "5.00"),
73
+                    //sql 里已经转成整数,这里再兜一层:驱动可能返回 Integer/BigDecimal/String,
73 74
                     //统一按数值解析再取整,避免 Integer.valueOf 抛 NumberFormatException
74 75
                     org = max == null || StringUtils.isEmpty(max) ? Integer.valueOf(0) : new BigDecimal(max.toString().trim()).intValue();
75 76
                 })