|
|
@@ -1,6 +1,9 @@
|
|
|
+
|
|
|
package com.qlm.service;
|
|
|
|
|
|
+import java.sql.SQLException;
|
|
|
import java.text.SimpleDateFormat;
|
|
|
+import java.util.ArrayList;
|
|
|
import java.util.Date;
|
|
|
import java.util.HashMap;
|
|
|
import java.util.HashSet;
|
|
|
@@ -10,10 +13,14 @@ import java.util.Set;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.jfinal.aop.Before;
|
|
|
import com.jfinal.kit.HttpKit;
|
|
|
import com.jfinal.plugin.activerecord.ActiveRecordPlugin;
|
|
|
import com.jfinal.plugin.activerecord.Db;
|
|
|
+import com.jfinal.plugin.activerecord.IAtom;
|
|
|
import com.jfinal.plugin.activerecord.Record;
|
|
|
+import com.jfinal.plugin.activerecord.tx.Tx;
|
|
|
+import com.jfinal.plugin.activerecord.tx.TxConfig;
|
|
|
import com.jfinal.plugin.druid.DruidPlugin;
|
|
|
import com.qlm.log.Log;
|
|
|
|
|
|
@@ -30,8 +37,9 @@ public class WmesService {
|
|
|
uploadData();
|
|
|
}
|
|
|
|
|
|
- public static void uploadData(){
|
|
|
-
|
|
|
+ @Before(Tx.class)
|
|
|
+ @TxConfig("oracle")
|
|
|
+ public static void transData(){
|
|
|
List<Record> find = Db.find("select * from jinzai_upload_master where upload_time is null limit 200");
|
|
|
|
|
|
if(find.isEmpty()){
|
|
|
@@ -39,17 +47,11 @@ public class WmesService {
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- JSONObject bigData = new JSONObject();
|
|
|
- JSONObject data = new JSONObject();
|
|
|
-
|
|
|
- bigData.put("data", data);
|
|
|
-
|
|
|
-
|
|
|
- JSONArray header = new JSONArray();
|
|
|
- SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
|
|
|
-
|
|
|
- data.put("header", header);
|
|
|
+ long start = System.currentTimeMillis();
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
+
|
|
|
+ SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
|
|
|
+ List<Record> datas = new ArrayList<Record>();
|
|
|
for (Record record : find) {
|
|
|
|
|
|
String task_no = record.getStr("task_no");
|
|
|
@@ -67,61 +69,125 @@ public class WmesService {
|
|
|
|
|
|
String format = sdf.format(guo_time);
|
|
|
|
|
|
- JSONObject obj1 = new JSONObject();
|
|
|
|
|
|
- obj1.put("warehouseid", "JZPJ");
|
|
|
- obj1.put("asnno", task_no);//工单号
|
|
|
-
|
|
|
- obj1.put("serialno", id);//箱码
|
|
|
-
|
|
|
- obj1.put("sku", pinxiang);//物料编码
|
|
|
-
|
|
|
-
|
|
|
- obj1.put("traceId", duo_code);//托盘码
|
|
|
-
|
|
|
- obj1.put("addtime", format);//关联时间
|
|
|
- obj1.put("udf06", "tm");
|
|
|
- header.add(obj1);
|
|
|
+ Record data = new Record();
|
|
|
+ data.set("WAREHOUSEID", "JZPJ");
|
|
|
+ data.set("ASNNO", task_no);
|
|
|
+ data.set("SKU", pinxiang);
|
|
|
+ data.set("TRACEID", duo_code);
|
|
|
+ data.set("UDF06", "tm");
|
|
|
+ data.set("ADDTIME", format);
|
|
|
+ datas.add(data);
|
|
|
}
|
|
|
+ String udfSqlString = "delete FROM WMS_PROD.CUS_ASN_SERIALNO where SERIALNO in ("
|
|
|
+ + sb + ") and UDF06 ='tm'";
|
|
|
+ boolean result = Db.use("oracle").tx(new IAtom() {
|
|
|
+ @Override
|
|
|
+ public boolean run() throws SQLException {
|
|
|
+ Db.use("oracle").update(udfSqlString);
|
|
|
+ Db.use("oracle").batchSave("CUS_ASN_SERIALNO", datas, 300);
|
|
|
+ return true; // 事务提交
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
- Map<String,String> headers = new HashMap<>();
|
|
|
- headers.put("Content-Type","application/json");
|
|
|
- try{
|
|
|
- long start = System.currentTimeMillis();
|
|
|
- String post = HttpKit.post("http://192.168.0.190:18080/datahubjson/WMS_EM/?method=QRCODE&apptoken=BAB75C8B843F1C92AC3FFE3BD2A06A5F×tamp=2024-06-25%2015:59:16&sign=1&format=JSON", bigData.toString(),headers);
|
|
|
- Log.info("第一次上传:"+post+",箱码:"+sb);
|
|
|
- Thread.sleep(2000);
|
|
|
- String udfSqlString = "SELECT SERIALNO FROM WMS_PROD.RUKUXIANGMA where SERIALNO in ("+sb+") and UDF06 ='tm'";
|
|
|
- List<Record> exists = Db.use("oracle").find(udfSqlString);
|
|
|
- Set<String> wmsSet =new HashSet<String>();
|
|
|
- for (Record record : exists) {
|
|
|
- String SERIALNO = record.getStr("SERIALNO");
|
|
|
- wmsSet.add(SERIALNO);
|
|
|
- }
|
|
|
-
|
|
|
- if(exists.size() != find.size()){
|
|
|
- StringBuilder diff = new StringBuilder();
|
|
|
- for (Record record : find) {
|
|
|
- String id = record.getStr("id");
|
|
|
- if(!wmsSet.contains(id)){
|
|
|
- diff.append(id);
|
|
|
- diff.append(",");
|
|
|
- }
|
|
|
- }
|
|
|
- Log.info("上传数据不一致,"+diff);
|
|
|
- post = HttpKit.post("http://192.168.0.190:18080/datahubjson/WMS_EM/?method=QRCODE&apptoken=BAB75C8B843F1C92AC3FFE3BD2A06A5F×tamp=2024-06-25%2015:59:16&sign=1&format=JSON", bigData.toString(),headers);
|
|
|
- Log.info("第二次上传:"+post+",箱码:"+sb);
|
|
|
- }
|
|
|
-
|
|
|
- int count = 0;
|
|
|
- if(sb.length()>0){
|
|
|
- count = Db.update("update jinzai_upload_master set upload_time = ? where id in ("+sb+")",new Date());
|
|
|
- }
|
|
|
- long end = System.currentTimeMillis();
|
|
|
- Log.info("同步到wms成功,耗时:"+(end-start)+",箱码数量:"+count);
|
|
|
- }catch(Exception e){
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
+ long end = System.currentTimeMillis();
|
|
|
+ Log.info("同步到wms中间库,"+result+",耗时:" + (end - start) + ",箱码数量:" + datas.size());
|
|
|
+
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void uploadData(){
|
|
|
+ transData();
|
|
|
+// List<Record> find = Db.find("select * from jinzai_upload_master where upload_time is null limit 200");
|
|
|
+//
|
|
|
+// if(find.isEmpty()){
|
|
|
+// Log.info("当前无数据,不同步");
|
|
|
+// return;
|
|
|
+// }
|
|
|
+//
|
|
|
+// JSONObject bigData = new JSONObject();
|
|
|
+// JSONObject data = new JSONObject();
|
|
|
+//
|
|
|
+// bigData.put("data", data);
|
|
|
+//
|
|
|
+//
|
|
|
+// JSONArray header = new JSONArray();
|
|
|
+// SimpleDateFormat sdf = new SimpleDateFormat("yyyy.MM.dd HH:mm:ss");
|
|
|
+//
|
|
|
+// data.put("header", header);
|
|
|
+// StringBuilder sb = new StringBuilder();
|
|
|
+// for (Record record : find) {
|
|
|
+//
|
|
|
+// String task_no = record.getStr("task_no");
|
|
|
+// String id = record.getStr("id");
|
|
|
+// if(sb.length()>0){
|
|
|
+// sb.append(",");
|
|
|
+// }
|
|
|
+// sb.append("'"+id+"'");
|
|
|
+//
|
|
|
+// String duo_code = record.getStr("duo_code");
|
|
|
+//
|
|
|
+// String pinxiang = record.getStr("sku");
|
|
|
+//
|
|
|
+// Date guo_time = record.getDate("guo_time");
|
|
|
+//
|
|
|
+// String format = sdf.format(guo_time);
|
|
|
+//
|
|
|
+// JSONObject obj1 = new JSONObject();
|
|
|
+//
|
|
|
+// obj1.put("warehouseid", "JZPJ");
|
|
|
+// obj1.put("asnno", task_no);//工单号
|
|
|
+//
|
|
|
+// obj1.put("serialno", id);//箱码
|
|
|
+//
|
|
|
+// obj1.put("sku", pinxiang);//物料编码
|
|
|
+//
|
|
|
+//
|
|
|
+// obj1.put("traceId", duo_code);//托盘码
|
|
|
+//
|
|
|
+// obj1.put("addtime", format);//关联时间
|
|
|
+// obj1.put("udf06", "tm");
|
|
|
+// header.add(obj1);
|
|
|
+// }
|
|
|
+//
|
|
|
+// Map<String,String> headers = new HashMap<>();
|
|
|
+// headers.put("Content-Type","application/json");
|
|
|
+// try{
|
|
|
+// long start = System.currentTimeMillis();
|
|
|
+// String post = HttpKit.post("http://192.168.0.190:18080/datahubjson/WMS_EM/?method=QRCODE&apptoken=BAB75C8B843F1C92AC3FFE3BD2A06A5F×tamp=2024-06-25%2015:59:16&sign=1&format=JSON", bigData.toString(),headers);
|
|
|
+// Log.info("第一次上传:"+post+",箱码:"+sb);
|
|
|
+// Thread.sleep(2000);
|
|
|
+// String udfSqlString = "SELECT SERIALNO FROM WMS_PROD.RUKUXIANGMA where SERIALNO in ("+sb+") and UDF06 ='tm'";
|
|
|
+// List<Record> exists = Db.use("oracle").find(udfSqlString);
|
|
|
+// Set<String> wmsSet =new HashSet<String>();
|
|
|
+// for (Record record : exists) {
|
|
|
+// String SERIALNO = record.getStr("SERIALNO");
|
|
|
+// wmsSet.add(SERIALNO);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(exists.size() != find.size()){
|
|
|
+// StringBuilder diff = new StringBuilder();
|
|
|
+// for (Record record : find) {
|
|
|
+// String id = record.getStr("id");
|
|
|
+// if(!wmsSet.contains(id)){
|
|
|
+// diff.append(id);
|
|
|
+// diff.append(",");
|
|
|
+// }
|
|
|
+// }
|
|
|
+// Log.info("上传数据不一致,"+diff);
|
|
|
+// post = HttpKit.post("http://192.168.0.190:18080/datahubjson/WMS_EM/?method=QRCODE&apptoken=BAB75C8B843F1C92AC3FFE3BD2A06A5F×tamp=2024-06-25%2015:59:16&sign=1&format=JSON", bigData.toString(),headers);
|
|
|
+// Log.info("第二次上传:"+post+",箱码:"+sb);
|
|
|
+// }
|
|
|
+//
|
|
|
+// int count = 0;
|
|
|
+// if(sb.length()>0){
|
|
|
+// count = Db.update("update jinzai_upload_master set upload_time = ? where id in ("+sb+")",new Date());
|
|
|
+// }
|
|
|
+// long end = System.currentTimeMillis();
|
|
|
+// Log.info("同步到wms成功,耗时:"+(end-start)+",箱码数量:"+count);
|
|
|
+// }catch(Exception e){
|
|
|
+// e.printStackTrace();
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|