|
|
@@ -61,12 +61,12 @@ public class PatientClientService {
|
|
|
List<EditRecordModifyResult.ModificationComparisonMap> timeline = new ArrayList<>();
|
|
|
BusInfusionModifyEntity prevRecord = null;
|
|
|
|
|
|
- for (BusInfusionModifyEntity currentRecord : allModifyRecords){
|
|
|
+ for (BusInfusionModifyEntity currentRecord : allModifyRecords) {
|
|
|
EditRecordModifyResult.ModificationComparisonMap timeNode = new EditRecordModifyResult.ModificationComparisonMap();
|
|
|
timeNode.setModifyTime(currentRecord.getModifyTime());
|
|
|
- if (prevRecord == null){
|
|
|
+ if (prevRecord == null) {
|
|
|
timeNode.setComparisons(buildInitialComparisons(currentRecord));
|
|
|
- }else {
|
|
|
+ } else {
|
|
|
timeNode.setComparisons(buildComparisons(prevRecord, currentRecord));
|
|
|
}
|
|
|
timeline.add(timeNode);
|
|
|
@@ -75,11 +75,11 @@ public class PatientClientService {
|
|
|
result.setDataList(timeline);
|
|
|
return result;
|
|
|
|
|
|
- }
|
|
|
+ }
|
|
|
|
|
|
- //首次对比
|
|
|
+ //从第二个开始对比
|
|
|
private List<ModificationComparison> buildComparisons(BusInfusionModifyEntity prevRecord, BusInfusionModifyEntity currentRecord) {
|
|
|
- List<ModificationComparison> diffs = new ArrayList<>();
|
|
|
+ List<ModificationComparison> diffs = new ArrayList<>();
|
|
|
|
|
|
// 动态对比字段
|
|
|
addIfChanged(diffs, "总量", prevRecord.getTotalDose(), currentRecord.getTotalDose());
|
|
|
@@ -91,6 +91,7 @@ public class PatientClientService {
|
|
|
return diffs;
|
|
|
}
|
|
|
|
|
|
+ //首次对比
|
|
|
private List<ModificationComparison> buildInitialComparisons(BusInfusionModifyEntity currentRecord) {
|
|
|
List<ModificationComparison> comparisons = new ArrayList<>();
|
|
|
|
|
|
@@ -110,6 +111,7 @@ public class PatientClientService {
|
|
|
.newValue(formatValue(newVal))
|
|
|
.build();
|
|
|
}
|
|
|
+
|
|
|
// 添加变化项
|
|
|
private void addIfChanged(
|
|
|
List<ModificationComparison> list,
|
|
|
@@ -121,16 +123,18 @@ public class PatientClientService {
|
|
|
list.add(buildComparison(fieldName, oldVal, newVal));
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
// 值等值判断
|
|
|
private boolean isEqual(Object a, Object b) {
|
|
|
if (a == null && b == null) return true;
|
|
|
if (a == null || b == null) return false;
|
|
|
|
|
|
if (a instanceof BigDecimal && b instanceof BigDecimal) {
|
|
|
- return ((BigDecimal)a).compareTo((BigDecimal)b) == 0;
|
|
|
+ return ((BigDecimal) a).compareTo((BigDecimal) b) == 0;
|
|
|
}
|
|
|
return a.equals(b);
|
|
|
}
|
|
|
+
|
|
|
// 值格式化方法
|
|
|
private String formatValue(Object value) {
|
|
|
if (value == null) return "0";
|