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 转发到其他砂站 *