|
|
@@ -2,6 +2,7 @@ package com.ruoyi.web.modules.industryservice.service.impl;
|
|
2
|
2
|
|
|
3
|
3
|
import java.util.ArrayList;
|
|
4
|
4
|
import java.util.List;
|
|
|
5
|
+import java.util.Objects;
|
|
5
|
6
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
6
|
7
|
import org.springframework.stereotype.Service;
|
|
7
|
8
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
@@ -40,7 +41,7 @@ public class BizDisposableIncomeServiceImpl implements IBizDisposableIncomeServi
|
|
40
|
41
|
{
|
|
41
|
42
|
DisposableIncomeValidation.validateRowForSave(row);
|
|
42
|
43
|
assertUniqueYear(row.getStatYear(), null);
|
|
43
|
|
- applyMissingGrowth(row);
|
|
|
44
|
+ applyGrowthForSave(row, null);
|
|
44
|
45
|
return bizDisposableIncomeMapper.insertBizDisposableIncome(row);
|
|
45
|
46
|
}
|
|
46
|
47
|
|
|
|
@@ -53,9 +54,9 @@ public class BizDisposableIncomeServiceImpl implements IBizDisposableIncomeServi
|
|
53
|
54
|
throw new ServiceException("主键不能为空");
|
|
54
|
55
|
}
|
|
55
|
56
|
DisposableIncomeValidation.validateRowForSave(row);
|
|
56
|
|
- requireExistingRow(row.getId());
|
|
|
57
|
+ BizDisposableIncome existing = requireExistingRow(row.getId());
|
|
57
|
58
|
assertUniqueYear(row.getStatYear(), row.getId());
|
|
58
|
|
- applyMissingGrowth(row);
|
|
|
59
|
+ applyGrowthForSave(row, existing);
|
|
59
|
60
|
return bizDisposableIncomeMapper.updateBizDisposableIncome(row);
|
|
60
|
61
|
}
|
|
61
|
62
|
|
|
|
@@ -88,15 +89,27 @@ public class BizDisposableIncomeServiceImpl implements IBizDisposableIncomeServi
|
|
88
|
89
|
return YakHerdInventoryYearSupport.resolveYearOptions();
|
|
89
|
90
|
}
|
|
90
|
91
|
|
|
91
|
|
- /** 增幅、增速未填时,按上年可支配收入公式补齐 */
|
|
92
|
|
- private void applyMissingGrowth(BizDisposableIncome row)
|
|
|
92
|
+ /**
|
|
|
93
|
+ * 年份或可支配收入变更时按新口径强制重算;否则仅对未填的增幅/增速补齐。
|
|
|
94
|
+ */
|
|
|
95
|
+ private void applyGrowthForSave(BizDisposableIncome row, BizDisposableIncome existing)
|
|
93
|
96
|
{
|
|
94
|
97
|
if (row == null || row.getStatYear() == null)
|
|
95
|
98
|
{
|
|
96
|
99
|
return;
|
|
97
|
100
|
}
|
|
98
|
101
|
BizDisposableIncome previous = bizDisposableIncomeMapper.selectByStatYear(row.getStatYear() - 1);
|
|
99
|
|
- DisposableIncomeGrowthSupport.fillMissingGrowth(row, previous);
|
|
|
102
|
+ boolean yearOrIncomeChanged = existing != null && (!Objects.equals(existing.getStatYear(), row.getStatYear())
|
|
|
103
|
+ || !DisposableIncomeGrowthSupport.sameDecimal(existing.getRuralDisposableIncome(),
|
|
|
104
|
+ row.getRuralDisposableIncome()));
|
|
|
105
|
+ if (yearOrIncomeChanged)
|
|
|
106
|
+ {
|
|
|
107
|
+ DisposableIncomeGrowthSupport.recalculateGrowth(row, previous);
|
|
|
108
|
+ }
|
|
|
109
|
+ else
|
|
|
110
|
+ {
|
|
|
111
|
+ DisposableIncomeGrowthSupport.fillMissingGrowth(row, previous);
|
|
|
112
|
+ }
|
|
100
|
113
|
}
|
|
101
|
114
|
|
|
102
|
115
|
private void assertUniqueYear(Integer statYear, Long excludeId)
|
|
|
@@ -108,12 +121,13 @@ public class BizDisposableIncomeServiceImpl implements IBizDisposableIncomeServi
|
|
108
|
121
|
}
|
|
109
|
122
|
}
|
|
110
|
123
|
|
|
111
|
|
- private void requireExistingRow(Long id)
|
|
|
124
|
+ private BizDisposableIncome requireExistingRow(Long id)
|
|
112
|
125
|
{
|
|
113
|
126
|
BizDisposableIncome existing = bizDisposableIncomeMapper.selectBizDisposableIncomeById(id);
|
|
114
|
127
|
if (existing == null)
|
|
115
|
128
|
{
|
|
116
|
129
|
throw new ServiceException("记录不存在或已删除");
|
|
117
|
130
|
}
|
|
|
131
|
+ return existing;
|
|
118
|
132
|
}
|
|
119
|
133
|
}
|