|
@@ -1,25 +1,53 @@
|
|
|
package com.qlm.service;
|
|
package com.qlm.service;
|
|
|
|
|
|
|
|
|
|
+import java.time.LocalDateTime;
|
|
|
|
|
+import java.time.format.DateTimeFormatter;
|
|
|
import java.util.ArrayList;
|
|
import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
import java.util.HashMap;
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
-import java.util.Set;
|
|
|
|
|
import java.util.Map.Entry;
|
|
import java.util.Map.Entry;
|
|
|
-import java.util.stream.Collectors;
|
|
|
|
|
|
|
+import java.util.Set;
|
|
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.jfinal.aop.Before;
|
|
import com.jfinal.aop.Before;
|
|
|
|
|
+import com.jfinal.kit.PropKit;
|
|
|
|
|
+import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
|
|
|
+import com.jfinal.plugin.activerecord.CaseInsensitiveContainerFactory;
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
|
|
+import com.jfinal.plugin.activerecord.dialect.OracleDialect;
|
|
|
import com.jfinal.plugin.activerecord.tx.Tx;
|
|
import com.jfinal.plugin.activerecord.tx.Tx;
|
|
|
|
|
+import com.jfinal.plugin.druid.DruidPlugin;
|
|
|
import com.qlm.log.Log;
|
|
import com.qlm.log.Log;
|
|
|
import com.qlm.tools.MD5Utils;
|
|
import com.qlm.tools.MD5Utils;
|
|
|
import com.qlm.tools.WxUtil;
|
|
import com.qlm.tools.WxUtil;
|
|
|
|
|
|
|
|
public class UploadService {
|
|
public class UploadService {
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
|
+ con();
|
|
|
|
|
+ update();
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ public static void con(){
|
|
|
|
|
+ DruidPlugin oraclePlugin = new DruidPlugin("jdbc:oracle:thin:@192.168.0.183:61521/orcl", "pxl","xuwei417");
|
|
|
|
|
+
|
|
|
|
|
+ oraclePlugin.setDriverClass("oracle.jdbc.OracleDriver");
|
|
|
|
|
+ oraclePlugin.setValidationQuery("select 1 from dual");
|
|
|
|
|
+ oraclePlugin.start();
|
|
|
|
|
+
|
|
|
|
|
+ ActiveRecordPlugin oracleArp = new ActiveRecordPlugin("oracle", oraclePlugin);
|
|
|
|
|
+ oracleArp.setDialect(new OracleDialect());
|
|
|
|
|
+ oracleArp.setContainerFactory(new CaseInsensitiveContainerFactory());
|
|
|
|
|
+ oracleArp.start();
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
@Before(Tx.class)
|
|
@Before(Tx.class)
|
|
|
public void upload(String data){
|
|
public void upload(String data){
|
|
@@ -130,18 +158,21 @@ public class UploadService {
|
|
|
return;
|
|
return;
|
|
|
}
|
|
}
|
|
|
isRunning = true;
|
|
isRunning = true;
|
|
|
- int pageSize = 1000;
|
|
|
|
|
try{
|
|
try{
|
|
|
- for (int pageNumber = 1; pageNumber <100000000; pageNumber++) {
|
|
|
|
|
- int pageStart = (pageNumber - 1) * pageSize + 1;
|
|
|
|
|
- int pageEnd = pageSize*pageNumber;
|
|
|
|
|
|
|
+ // 获取当前时间
|
|
|
|
|
+ LocalDateTime now = LocalDateTime.now();
|
|
|
|
|
+
|
|
|
|
|
+ // 获取昨天的当前时间(减去 1 天)
|
|
|
|
|
+ LocalDateTime yesterdaySameTime = now.minusDays(1);
|
|
|
|
|
+
|
|
|
|
|
+ // 格式化输出(可选)
|
|
|
|
|
+ DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
|
|
|
|
|
+ String formattedTime = yesterdaySameTime.format(formatter);
|
|
|
|
|
|
|
|
- String udfSqlString = "SELECT * FROM (SELECT a.*, ROWNUM rnum FROM (SELECT * FROM WMS_PROD.V_TMSO_RETURN_H) a WHERE ROWNUM <= ?) WHERE rnum > ?";
|
|
|
|
|
- List<Record> find = Db.use("oracle").find(udfSqlString,pageEnd,pageStart);
|
|
|
|
|
- if(find.isEmpty()){
|
|
|
|
|
- break;
|
|
|
|
|
- }
|
|
|
|
|
|
|
|
|
|
|
|
+ String udfSqlString = "SELECT * FROM WMS_PROD.V_TMSO_RETURN_H WHERE DELIVERYTIME >= TO_DATE('"+formattedTime+"', 'YYYY-MM-DD HH24:MI:SS')";
|
|
|
|
|
+ List<Record> find = Db.use("oracle").find(udfSqlString);
|
|
|
|
|
+ Log.info("执行同步数据查询:数据量,"+find.size());
|
|
|
List<Record> list = new ArrayList<Record>();
|
|
List<Record> list = new ArrayList<Record>();
|
|
|
for (Record record : find) {
|
|
for (Record record : find) {
|
|
|
String orderNo = record.getStr("ORDERNO");//发货单号
|
|
String orderNo = record.getStr("ORDERNO");//发货单号
|
|
@@ -197,13 +228,12 @@ public class UploadService {
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
WxUtil.batchSaveIgnore("deliveryorders", list, "");
|
|
WxUtil.batchSaveIgnore("deliveryorders", list, "");
|
|
|
- }
|
|
|
|
|
- Log.info("执行同步数据:完成");
|
|
|
|
|
- }catch(Exception e){
|
|
|
|
|
- e.printStackTrace();
|
|
|
|
|
- }finally{
|
|
|
|
|
- isRunning = false;
|
|
|
|
|
- }
|
|
|
|
|
|
|
+ Log.info("执行同步数据:完成,"+find.size());
|
|
|
|
|
+ }catch(Exception e){
|
|
|
|
|
+ e.printStackTrace();
|
|
|
|
|
+ }finally{
|
|
|
|
|
+ isRunning = false;
|
|
|
|
|
+ }
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}
|