From 4c8f0b682260c93d0814bc092206dfdf0ae24c58 Mon Sep 17 00:00:00 2001 From: xjm Date: Tue, 16 Apr 2024 17:39:31 +0800 Subject: [PATCH] =?UTF-8?q?=E5=AE=A1=E6=A0=B8=E8=AE=A2=E5=8D=95=E5=8F=96?= =?UTF-8?q?=E6=B6=88=E7=94=B3=E8=AF=B7=E6=8E=A5=E5=8F=A3=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ssjygl/synctask/SyncTaskService.java | 56 +++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java index aa085ae..04f55c0 100644 --- a/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java +++ b/ssjygl-xsx-service/src/main/java/com/cowr/service/ssjygl/synctask/SyncTaskService.java @@ -16,6 +16,7 @@ import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Db; import com.jfinal.plugin.activerecord.IAtom; import com.jfinal.plugin.activerecord.Record; +import org.apache.commons.collections4.CollectionUtils; import java.math.BigDecimal; import java.sql.SQLException; @@ -334,6 +335,8 @@ public class SyncTaskService { } } + list = listFilter(tablename,list); + int[] ret = Db.batchSave(tablename, list, list.size()); if (ret.length != list.size()) { @@ -568,6 +571,59 @@ public class SyncTaskService { } } + + // 过滤新增数据 + private List listFilter(String tablename, List list) { + + List removeList = new ArrayList<>(); + if ("order_temp".equals(tablename)){ + // sn + for (Record o : list) { + String sn = o.getStr("sn"); + Record first = Db.findFirst("select * from " + tablename + " where sn = ?", sn); + if (o.toJson().equals(first.toJson())){ + removeList.add(o); + } + } + } + if ("ticket_log".equals(tablename)){ + // id + for (Record o : list) { + String id = o.getStr("id"); + Record first = Db.findFirst("select * from " + tablename + " where sn = ?", id); + if (o.toJson().equals(first.toJson())){ + removeList.add(o); + } + } + } + if ("action_cmd_log".equals(tablename)){ + // id + for (Record o : list) { + String id = o.getStr("id"); + Record first = Db.findFirst("select * from " + tablename + " where sn = ?", id); + if (o.toJson().equals(first.toJson())){ + removeList.add(o); + } + } + } + if ("transport".equals(tablename)){ + // id + for (Record o : list) { + String id = o.getStr("id"); + Record first = Db.findFirst("select * from " + tablename + " where sn = ?", id); + if (o.toJson().equals(first.toJson())){ + removeList.add(o); + } + } + } + + if (CollectionUtils.isNotEmpty(removeList)){ + list.removeAll(removeList); + } + + return list; + } + /** * 将收到的 auth_license 转发到其他砂站 *