From fef14ca0b7821b01508ee42d07133a5098525010 Mon Sep 17 00:00:00 2001 From: Kris <2893855659@qq.com> Date: Wed, 27 Aug 2025 19:09:27 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90feat=E3=80=91=20=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E5=90=8C=E6=AD=A5=EF=BC=8C=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E6=9B=B4=E6=96=B0=E6=98=AF=E5=90=A6=E5=A4=B1=E8=B4=A5=EF=BC=8C?= =?UTF-8?q?=E4=BB=A5=E5=8F=8A=E5=A4=B1=E8=B4=A5=E4=BF=A1=E6=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../celnet/datadump/mapper/CustomMapper.java | 2 +- .../service/impl/CommonServiceImpl.java | 14 ++++++++ .../impl/DataImportNewServiceImpl.java | 36 +++++++++++++------ src/main/resources/mapper/CustomMapper.xml | 2 +- 4 files changed, 42 insertions(+), 12 deletions(-) diff --git a/src/main/java/com/celnet/datadump/mapper/CustomMapper.java b/src/main/java/com/celnet/datadump/mapper/CustomMapper.java index b81b271..abe1cf1 100644 --- a/src/main/java/com/celnet/datadump/mapper/CustomMapper.java +++ b/src/main/java/com/celnet/datadump/mapper/CustomMapper.java @@ -88,7 +88,7 @@ public interface CustomMapper { * @param api * @param newId */ - public void updateByField(@Param("maps") List> maps, @Param("tableName") String api, @Param("newId") String newId); + public void updateByNewId(@Param("maps") List> maps, @Param("tableName") String api, @Param("newId") String newId); /** * 插入方法 diff --git a/src/main/java/com/celnet/datadump/service/impl/CommonServiceImpl.java b/src/main/java/com/celnet/datadump/service/impl/CommonServiceImpl.java index 0445497..b259cb7 100644 --- a/src/main/java/com/celnet/datadump/service/impl/CommonServiceImpl.java +++ b/src/main/java/com/celnet/datadump/service/impl/CommonServiceImpl.java @@ -1079,6 +1079,7 @@ public class CommonServiceImpl implements CommonService { map.put("comment", "新sfid"); map.put("name", "new_id"); list.add(map); + fields.add("new_id"); // 构建索引 @@ -1108,6 +1109,19 @@ public class CommonServiceImpl implements CommonService { map2.put("name", "all_data"); list.add(map2); } + //是否更新 + Map map3 = Maps.newHashMap(); + map3.put("type", "tinyint(1) DEFAULT 0"); + map3.put("comment", "是否更新"); + map3.put("name", "is_update"); + list.add(map3); + + //是否更新 + Map map4 = Maps.newHashMap(); + map4.put("type", "text"); + map4.put("comment", "更新错误信息"); + map4.put("name", "error_message"); + list.add(map4); customMapper.createTable(apiName, label, list, index); // 生成字段映射 diff --git a/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java b/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java index 71b1903..8949c4a 100644 --- a/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java +++ b/src/main/java/com/celnet/datadump/service/impl/DataImportNewServiceImpl.java @@ -738,20 +738,20 @@ public class DataImportNewServiceImpl implements DataImportNewService { if (1 == param.getType()) { if (api.endsWith("Share")){ - sql = "where RowCause = 'Manual' and new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "'"; - sql2 = "RowCause = 'Manual' and new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' order by Id asc limit "; + sql = "where RowCause = 'Manual' and is_update != 1 and new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "'"; + sql2 = "RowCause = 'Manual' and is_update != 1 and new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' order by Id asc limit "; }else { - sql = "where new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "'"; - sql2 = "new_id is not null and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' order by Id asc limit "; + sql = "where new_id is not null and is_update != 1 and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "'"; + sql2 = "new_id is not null and is_update != 1 and CreatedDate >= '" + beginDateStr + "' and CreatedDate < '" + endDateStr + "' order by Id asc limit "; } }else { String updateDateField = dataFieldService.returnUpdateDateField(api); if (api.endsWith("Share")){ - sql = "where RowCause = 'Manual' and new_id is not null and "+updateDateField+" >= '" + beginDateStr + "' "; - sql2 = "RowCause = 'Manual' and new_id is not null and "+updateDateField+" >= '" + beginDateStr + "' order by Id asc limit "; + sql = "where RowCause = 'Manual' and is_update != 1 and new_id is not null and "+updateDateField+" >= '" + beginDateStr + "' "; + sql2 = "RowCause = 'Manual' and is_update != 1 and new_id is not null and "+updateDateField+" >= '" + beginDateStr + "' order by Id asc limit "; }else { - sql = "where new_id is not null and "+updateDateField+" >= '" + beginDateStr + "' "; - sql2 = "new_id is not null and "+updateDateField+" >= '" + beginDateStr + "' order by Id asc limit "; + sql = "where new_id is not null and and is_update != 1 "+updateDateField+" >= '" + beginDateStr + "' "; + sql2 = "new_id is not null and is_update != 1 and "+updateDateField+" >= '" + beginDateStr + "' order by Id asc limit "; } } //表内数据总量 @@ -881,11 +881,27 @@ public class DataImportNewServiceImpl implements DataImportNewService { SaveResult[] saveResults = partnerConnection.update(accounts); for (SaveResult saveResult : saveResults) { if (!saveResult.getSuccess()) { + List> maps = new ArrayList<>(); + Map linkMap = new HashMap<>(); + linkMap.put("key", "is_update"); + linkMap.put("value", 2); + maps.add(linkMap); + Map linkMap1 = new HashMap<>(); + linkMap1.put("key", "error_message"); + linkMap1.put("value", saveResult.getErrors()); + maps.add(linkMap1); + customMapper.updateByNewId(maps,api, saveResult.getId()); Map map = returnErrorAccountsDetails(accounts, list, saveResult.getId()); String format = String.format("数据更新 error, api name: %s, \nparam: %s, \ncause:\n%s, \n数据实体类:\n%s", api, com.alibaba.fastjson2.JSON.toJSONString(param, DataDumpParam.getFilter()), JSON.toJSONString(saveResult),JSON.toJSONString(map)); - EmailUtil.send("DataDump ERROR", format); + log.info(format); return; }else { + List> maps = new ArrayList<>(); + Map linkMap = new HashMap<>(); + linkMap.put("key", "is_update"); + linkMap.put("value", 1); + maps.add(linkMap); + customMapper.updateByNewId(maps,api, saveResult.getId()); targetCount ++; } } @@ -2654,7 +2670,7 @@ public class DataImportNewServiceImpl implements DataImportNewService { maps.add(paramMap); } } - customMapper.updateByField(maps, api, id); + customMapper.updateByNewId(maps, api, id); } catch (Throwable throwable) { if (throwable.toString().contains("interrupt")) { log.error("may interrupt error:", throwable); diff --git a/src/main/resources/mapper/CustomMapper.xml b/src/main/resources/mapper/CustomMapper.xml index 35f4663..c1e17cd 100644 --- a/src/main/resources/mapper/CustomMapper.xml +++ b/src/main/resources/mapper/CustomMapper.xml @@ -77,7 +77,7 @@ - + UPDATE `${tableName}` SET new_id = #{newId}