Commit b973369b authored by yanzg's avatar yanzg

表结构修改

parent fc3b2c85
...@@ -55,12 +55,15 @@ public class DataDaoVo<T> { ...@@ -55,12 +55,15 @@ public class DataDaoVo<T> {
/** /**
* 获取结果 * 获取结果
* *
* @param hisitories 历史数据
* @param mapHistory 历史数据映射 * @param mapHistory 历史数据映射
* @param nows  当前数据 * @param nows 当前数据
* @param keyFunc  获取主键函数 * @param keyFunc 获取主键函数
* @return * @return 返回值
*/ */
private void addResult(Map<String, T> mapHistory, List<T> nows, DataDaoKey<T> keyFunc) { private void addResult(List<T> hisitories, Map<String, T> mapHistory, List<T> nows, DataDaoKey<T> keyFunc) {
// 需要删除的集合
List<T> historyRemove = new ArrayList<>(hisitories);
// 返回集 // 返回集
if (nows != null) { if (nows != null) {
for (T now : nows) { for (T now : nows) {
...@@ -73,7 +76,7 @@ public class DataDaoVo<T> { ...@@ -73,7 +76,7 @@ public class DataDaoVo<T> {
this.creates.add(now); this.creates.add(now);
this.mapNow.put(key, now); this.mapNow.put(key, now);
} else { } else {
mapHistory.remove(key); historyRemove.remove(his);
boolean isChange = keyFunc.set(his, now); boolean isChange = keyFunc.set(his, now);
if (isChange) { if (isChange) {
this.updates.add(his); this.updates.add(his);
...@@ -82,7 +85,7 @@ public class DataDaoVo<T> { ...@@ -82,7 +85,7 @@ public class DataDaoVo<T> {
} }
} }
} }
this.removes.addAll(mapHistory.values()); this.removes.addAll(historyRemove);
} }
...@@ -95,7 +98,7 @@ public class DataDaoVo<T> { ...@@ -95,7 +98,7 @@ public class DataDaoVo<T> {
*/ */
public void add(List<T> hisitories, List<T> nows, DataDaoKey<T> keyFunc) { public void add(List<T> hisitories, List<T> nows, DataDaoKey<T> keyFunc) {
Map<String, T> mapHistory = getMapHistory(hisitories, keyFunc); Map<String, T> mapHistory = getMapHistory(hisitories, keyFunc);
addResult(mapHistory, nows, keyFunc); addResult(hisitories, mapHistory, nows, keyFunc);
} }
...@@ -115,7 +118,7 @@ public class DataDaoVo<T> { ...@@ -115,7 +118,7 @@ public class DataDaoVo<T> {
toNows.add(t); toNows.add(t);
} }
} }
addResult(mapHistory, toNows, keyFunc); addResult(hisitories, mapHistory, toNows, keyFunc);
} }
/** /**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment