|
@@ -20,6 +20,7 @@ import cn.hutool.core.util.StrUtil;
|
20
|
20
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
21
|
21
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
22
|
22
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
23
|
+import com.unis.rotationPlan.info.modular.rpWarnThreshold.mapper.RpWarnThresholdMapper;
|
23
|
24
|
import io.swagger.annotations.ApiModelProperty;
|
24
|
25
|
import org.springframework.stereotype.Service;
|
25
|
26
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -53,6 +54,9 @@ public class FsStorageSubsidySettleServiceImpl extends ServiceImpl<FsStorageSubs
|
53
|
54
|
@Resource
|
54
|
55
|
private FsStorageSubsidySettleMapper fsStorageSubsidySettleMapper;
|
55
|
56
|
|
|
57
|
+ @Resource
|
|
58
|
+ private RpWarnThresholdMapper rpWarnThresholdMapper;
|
|
59
|
+
|
56
|
60
|
@Override
|
57
|
61
|
public Page<FsStorageSubsidySettle> page(FsStorageSubsidySettlePageParam fsStorageSubsidySettlePageParam) {
|
58
|
62
|
QueryWrapper<FsStorageSubsidySettle> queryWrapper = new QueryWrapper<>();
|
|
@@ -111,77 +115,159 @@ public class FsStorageSubsidySettleServiceImpl extends ServiceImpl<FsStorageSubs
|
111
|
115
|
@Override
|
112
|
116
|
public void addFsStorageSubsidySettle() {
|
113
|
117
|
int year = LocalDate.now().getYear();
|
|
118
|
+
|
|
119
|
+ LocalDate today = LocalDate.now();
|
|
120
|
+
|
|
121
|
+ // 获取当前月份
|
|
122
|
+ int ys = today.getMonthValue();
|
114
|
123
|
//查询data_kcgl_kcyjd_default单位
|
115
|
|
- List<Map<String,Object>> list= fsStorageSubsidySettleMapper.getOrgAndKcSum(year);
|
116
|
|
- for (int j = 0; j < list.size(); j++) {
|
117
|
124
|
|
|
125
|
+ List<Map<String, Object>> listOrg = fsStorageSubsidySettleMapper.selectOrgInfo();
|
|
126
|
+
|
|
127
|
+ for (int i = 0; i < listOrg.size(); i++) {
|
|
128
|
+ Map<String, Object> mapOrg = listOrg.get(i);
|
|
129
|
+ String orgId = mapOrg.getOrDefault("orgId", "").toString();
|
118
|
130
|
|
119
|
131
|
/**
|
120
|
132
|
* 原粮
|
121
|
133
|
*/
|
122
|
|
- Map<String, Object> map = list.get(j);
|
123
|
|
- String orgId = map.getOrDefault("UnitID", "").toString();
|
124
|
|
- // 获取 qmkc 的值,如果没有则默认为 0.0
|
125
|
|
- BigDecimal qmkc = NumberUtil.toBigDecimal(map.getOrDefault("qmkc", "0.0").toString());
|
|
134
|
+ FsStorageSubsidySettle fsStorageSubsidySettle = new FsStorageSubsidySettle();
|
126
|
135
|
|
127
|
|
- // 获取 ys 的值,如果没有则默认为 1(避免除以零)
|
128
|
|
- int ys = Integer.parseInt(map.getOrDefault("ys", "1").toString());
|
|
136
|
+ BigDecimal averageRawGrainInventoryEmpty = new BigDecimal(0.0);/** 储备粮-原粮平均库存数量-平均正常轮空期内轮空数量 */
|
|
137
|
+ BigDecimal averageRawGrainInventory = new BigDecimal(0.00); /** 储备粮-原粮平均库存数量-小计 */
|
|
138
|
+ BigDecimal averageRawGrainInventoryPhysical = new BigDecimal(0.0);/** 储备粮-原粮平均库存数量-平均月末实物库存 */
|
|
139
|
+ List<Map<String, Object>> listyy = fsStorageSubsidySettleMapper.getOrgAndKcSum(year,orgId);
|
|
140
|
+ for (int j = 0; j < listyy.size(); j++) {
|
|
141
|
+ Map<String, Object> map = listyy.get(j);
|
129
|
142
|
|
130
|
|
- // 计算平均库存,如果 ys 不为零则进行除法运算
|
131
|
|
- BigDecimal averageRawGrainInventoryPhysical = new BigDecimal(0.0);
|
132
|
|
- if (ys != 0) {
|
133
|
|
- averageRawGrainInventoryPhysical = qmkc.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
134
|
|
- }
|
135
|
|
- FsStorageSubsidySettle fsStorageSubsidySettle = new FsStorageSubsidySettle();
|
136
|
|
- fsStorageSubsidySettle.setAverageInventory(averageRawGrainInventoryPhysical); //平均月末实物库存
|
137
|
|
-
|
138
|
|
- //根据单位 和 日期 查询架空期
|
139
|
|
- Map<String, Object> staetAndEnd = fsStorageSubsidySettleMapper.getStaetAndEnd(orgId, year);
|
140
|
|
- LocalDateTime startTime = (LocalDateTime)map.getOrDefault("rotationStart", LocalDateTime.now()); //开始时间
|
141
|
|
- LocalDateTime endTime = (LocalDateTime)map.getOrDefault("rotationEnd", LocalDateTime.now()); //截至时间
|
142
|
|
- // 获取 quantity 的值,如果没有则默认为 0.0
|
143
|
|
- BigDecimal quantity = NumberUtil.toBigDecimal(map.getOrDefault("quantity", "0.0").toString());
|
144
|
|
- BigDecimal averageRawGrainInventoryEmpty =new BigDecimal(0.0);
|
145
|
|
- BigDecimal averageRawGrainInventory =new BigDecimal(0.00);
|
146
|
|
- if (ys != 0) {
|
147
|
|
- averageRawGrainInventoryEmpty = qmkc.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
|
143
|
+ // 获取 qmkc 的值,如果没有则默认为 0.0
|
|
144
|
+ BigDecimal qmkc = NumberUtil.toBigDecimal(map.getOrDefault("qmkc", "0.0").toString());
|
|
145
|
+
|
|
146
|
+ // 获取 ys 的值,如果没有则默认为 1(避免除以零)
|
|
147
|
+ //int ys = Integer.parseInt(map.getOrDefault("ys", "1").toString());
|
|
148
|
+
|
|
149
|
+ // 计算平均库存,如果 ys 不为零则进行除法运算
|
|
150
|
+ if (ys != 0) {
|
|
151
|
+ averageRawGrainInventoryPhysical = qmkc.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
|
152
|
+ }
|
|
153
|
+
|
|
154
|
+ fsStorageSubsidySettle.setAverageInventory(averageRawGrainInventoryPhysical); //平均月末实物库存
|
|
155
|
+
|
|
156
|
+ //根据单位 和 日期 查询架空期
|
|
157
|
+ Map<String, Object> staetAndEnd = fsStorageSubsidySettleMapper.getStaetAndEnd(orgId, year);
|
|
158
|
+ LocalDateTime startTime = (LocalDateTime) map.getOrDefault("rotationStart", LocalDateTime.now()); //开始时间
|
|
159
|
+ LocalDateTime endTime = (LocalDateTime) map.getOrDefault("rotationEnd", LocalDateTime.now()); //截至时间
|
|
160
|
+ // 获取 quantity 的值,如果没有则默认为 0.0
|
|
161
|
+ BigDecimal quantity = NumberUtil.toBigDecimal(map.getOrDefault("quantity", "0.0").toString());
|
|
162
|
+
|
|
163
|
+ if (ys != 0) {
|
|
164
|
+ averageRawGrainInventoryEmpty = quantity.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
|
165
|
+ }
|
|
166
|
+ fsStorageSubsidySettle.setAverageRawGrainInventoryEmpty(averageRawGrainInventoryEmpty);//平均正常轮空期内轮空数量
|
|
167
|
+ averageRawGrainInventory = averageRawGrainInventoryPhysical.add(averageRawGrainInventoryEmpty);
|
|
168
|
+ averageRawGrainInventory = averageRawGrainInventory.multiply(new BigDecimal("0.2"));
|
|
169
|
+ fsStorageSubsidySettle.setAverageRawGrainInventory(averageRawGrainInventory);//(1)
|
148
|
170
|
}
|
149
|
|
- fsStorageSubsidySettle.setAverageRawGrainInventoryEmpty(averageRawGrainInventoryEmpty);//平均正常轮空期内轮空数量
|
150
|
|
- averageRawGrainInventory=averageRawGrainInventoryPhysical.add(averageRawGrainInventoryEmpty);
|
151
|
|
- averageRawGrainInventory=averageRawGrainInventory.multiply(new BigDecimal("0.2"));
|
152
|
|
- fsStorageSubsidySettle.setAverageRawGrainInventory(averageRawGrainInventory);//(1)
|
|
171
|
+
|
|
172
|
+
|
153
|
173
|
|
154
|
174
|
/**
|
155
|
175
|
* 成品粮
|
156
|
176
|
*
|
157
|
177
|
*/
|
158
|
|
- BigDecimal averageProcessedGrainInventory= new BigDecimal(0.0);//(2) /** 储备粮-成品粮平均库存数量-小计 */
|
159
|
|
- BigDecimal averageProcessedGrainInventoryPhysical= new BigDecimal(0.0); /** 储备粮-成品粮平均库存数量-平均月末实物库存 */
|
160
|
|
- BigDecimal averageProcessedGrainInventoryEmpty= new BigDecimal(0.0); /** 储备粮-成品粮平均库存数量-平均正常轮空期内轮空数量 */
|
|
178
|
+ BigDecimal averageProcessedGrainInventoryEmpty = new BigDecimal(0.0); /** 储备粮-成品粮平均库存数量-平均正常轮空期内轮空数量 */
|
|
179
|
+ //根据年度和orgId 查询 -成品粮购销计划
|
|
180
|
+ List<Map<String, Object>> list1 = rpWarnThresholdMapper.getGopsPlans(year, orgId);
|
|
181
|
+ BigDecimal sjlcsl = new BigDecimal(0.0);
|
|
182
|
+ BigDecimal sjsysl = new BigDecimal(0.0);
|
|
183
|
+ for (int j1 = 0; j1 < list1.size(); j1++) {
|
|
184
|
+ Map<String, Object> map1 = list1.get(j1);
|
|
185
|
+ LocalDateTime firstTime = (LocalDateTime) map1.getOrDefault("startTime", LocalDateTime.now()); //第一车出库时间
|
|
186
|
+ LocalDateTime firstDayOfNextMonth = firstTime.plusMonths(1).withDayOfMonth(1);
|
|
187
|
+ LocalDateTime futureDate = firstDayOfNextMonth.plusMonths(4);
|
|
188
|
+ LocalDateTime endTime = (LocalDateTime) map1.get("endTime");
|
|
189
|
+ if (endTime != null && endTime.isBefore(futureDate)) {
|
|
190
|
+ BigDecimal wcsl = (BigDecimal) map1.getOrDefault("wcsl", BigDecimal.ZERO);
|
|
191
|
+ sjlcsl = sjlcsl.add(wcsl);
|
|
192
|
+ BigDecimal sysl = (BigDecimal) map1.getOrDefault("sysl", BigDecimal.ZERO);
|
|
193
|
+ sjsysl = sjsysl.add(sysl);
|
|
194
|
+ }
|
|
195
|
+
|
|
196
|
+ }
|
|
197
|
+ if (ys != 0) {
|
|
198
|
+ averageProcessedGrainInventoryEmpty = sjlcsl.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
|
199
|
+ }
|
|
200
|
+ fsStorageSubsidySettle.setAverageProcessedGrainInventoryEmpty(averageProcessedGrainInventoryEmpty);/** 储备粮-成品粮平均库存数量-平均正常轮空期内轮空数量 */
|
|
201
|
+
|
|
202
|
+ BigDecimal averageProcessedGrainInventoryPhysical = new BigDecimal(0.0); /** 储备粮-成品粮平均库存数量-平均月末实物库存 */
|
|
203
|
+ if (ys != 0) {
|
|
204
|
+ averageProcessedGrainInventoryPhysical = sjsysl.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
|
205
|
+ }
|
|
206
|
+ fsStorageSubsidySettle.setAverageProcessedGrainInventoryPhysical(averageProcessedGrainInventoryPhysical);/** 储备粮-成品粮平均库存数量-平均月末实物库存 */
|
161
|
207
|
|
|
208
|
+ BigDecimal averageProcessedGrainInventory = new BigDecimal(0.0);//(2) /** 储备粮-成品粮平均库存数量-小计 */
|
162
|
209
|
|
163
|
210
|
|
164
|
211
|
BigDecimal averageInventory = new BigDecimal(0.0);/** 储备粮平均库存数量 */
|
165
|
|
- averageInventory=averageRawGrainInventory.add(averageProcessedGrainInventory);
|
|
212
|
+ averageInventory = averageRawGrainInventory.add(averageProcessedGrainInventoryEmpty);
|
166
|
213
|
fsStorageSubsidySettle.setAverageOilInventory(averageInventory);//(1)+(2)
|
|
214
|
+
|
167
|
215
|
/**
|
168
|
216
|
* 保管费用补贴
|
169
|
217
|
*/
|
170
|
|
- BigDecimal storageSubsidyStandardRawGrain = new BigDecimal(0.0);//(1) /** 储备粮-原粮保管费用补贴(标准:0.12元/公斤)应拨数 */
|
171
|
|
- storageSubsidyStandardRawGrain=averageRawGrainInventory.multiply(new BigDecimal("0.12"));//单位:万元
|
|
218
|
+ BigDecimal storageSubsidyStandardRawGrain = new BigDecimal(0.0);//(1) /** 储备粮-原粮保管费用补贴(标准:0.12元/公斤)应拨数 */
|
|
219
|
+ storageSubsidyStandardRawGrain = averageRawGrainInventory.multiply(new BigDecimal("0.12"));//单位:万元
|
172
|
220
|
fsStorageSubsidySettle.setStorageSubsidyRawGrain(storageSubsidyStandardRawGrain);
|
173
|
221
|
|
174
|
|
- BigDecimal storageSubsidyProcessedGrain = new BigDecimal(0.0);/** 储备粮-成品粮保管费用补贴(标准:0.20元/公斤)应拨数 */
|
|
222
|
+ BigDecimal storageSubsidyProcessedGrain = new BigDecimal(0.0);/** 储备粮-成品粮保管费用补贴(标准:0.20元/公斤)应拨数 */
|
175
|
223
|
storageSubsidyProcessedGrain = averageProcessedGrainInventory.multiply(new BigDecimal("0.20"));//单位:万元
|
176
|
224
|
fsStorageSubsidySettle.setStorageSubsidyProcessedGrain(storageSubsidyProcessedGrain);
|
177
|
225
|
|
178
|
|
- BigDecimal storageSubsidyRawGrain = new BigDecimal(0.0);//(3)+(4) /** 储备粮-原粮保管费用补贴应拨数 */
|
179
|
|
- storageSubsidyRawGrain=storageSubsidyStandardRawGrain.add(storageSubsidyProcessedGrain);
|
|
226
|
+ BigDecimal storageSubsidyRawGrain = new BigDecimal(0.0);//(3)+(4) /** 储备粮-原粮保管费用补贴应拨数 */
|
|
227
|
+
|
|
228
|
+ storageSubsidyRawGrain = storageSubsidyStandardRawGrain.add(storageSubsidyProcessedGrain);
|
180
|
229
|
fsStorageSubsidySettle.setStorageSubsidyRawGrain(storageSubsidyRawGrain);
|
|
230
|
+ /**
|
|
231
|
+ * 储备油
|
|
232
|
+ */
|
|
233
|
+ BigDecimal averageOilInventoryPhysical = new BigDecimal(0.0);/** 储备油-储油平均库存数量-平均月末实物库存 */
|
|
234
|
+ BigDecimal averageOilInventoryEmpty = new BigDecimal(0.0);/** 储备油-储油平均库存数量-平均正常轮空期内轮空数量 */
|
|
235
|
+ BigDecimal averageOilInventory = new BigDecimal(0.0);/** 储备油-储油平均库存数量-小计 */
|
|
236
|
+ List<Map<String, Object>> list2 = fsStorageSubsidySettleMapper.getOrgAndYlKcSum(year, orgId);
|
|
237
|
+ for (int j2 = 0; j2< list2.size(); j2++) {
|
|
238
|
+ Map<String, Object> mapy = listyy.get(j2);
|
|
239
|
+ // 获取 qmkc 的值,如果没有则默认为 0.0
|
|
240
|
+ BigDecimal qmkc = NumberUtil.toBigDecimal(mapy.getOrDefault("qmkc", "0.0").toString());
|
181
|
241
|
|
|
242
|
+ // 获取 ys 的值,如果没有则默认为 1(避免除以零)
|
|
243
|
+ //int ys = Integer.parseInt(map.getOrDefault("ys", "1").toString());
|
182
|
244
|
|
|
245
|
+ // 计算平均库存,如果 ys 不为零则进行除法运算
|
|
246
|
+ if (ys != 0) {
|
|
247
|
+ averageOilInventoryPhysical = qmkc.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
|
248
|
+ }
|
183
|
249
|
|
|
250
|
+ fsStorageSubsidySettle.setAverageOilInventoryPhysical(averageOilInventoryPhysical); //平均月末实物库存
|
184
|
251
|
|
|
252
|
+ //根据单位 和 日期 查询架空期
|
|
253
|
+ Map<String, Object> staetAndEnd = fsStorageSubsidySettleMapper.getStaetAndEnd(orgId, year);
|
|
254
|
+ LocalDateTime startTime = (LocalDateTime) mapy.getOrDefault("rotationStart", LocalDateTime.now()); //开始时间
|
|
255
|
+ LocalDateTime endTime = (LocalDateTime) mapy.getOrDefault("rotationEnd", LocalDateTime.now()); //截至时间
|
|
256
|
+ // 获取 quantity 的值,如果没有则默认为 0.0
|
|
257
|
+ BigDecimal quantity = NumberUtil.toBigDecimal(mapy.getOrDefault("quantity", "0.0").toString());
|
|
258
|
+
|
|
259
|
+ if (ys != 0) {
|
|
260
|
+ averageOilInventoryEmpty = quantity.divide(BigDecimal.valueOf(ys), 2, BigDecimal.ROUND_HALF_UP);
|
|
261
|
+ }
|
|
262
|
+ fsStorageSubsidySettle.setAverageOilInventoryEmpty(averageOilInventoryEmpty);//平均正常轮空期内轮空数量
|
|
263
|
+ averageOilInventory = averageOilInventoryPhysical.add(averageOilInventoryEmpty);
|
|
264
|
+
|
|
265
|
+ BigDecimal storageSubsidyOil = new BigDecimal(0.0);/** 储备油-油料保管费用补贴(标准:0.40元/公斤)应拨数 */
|
|
266
|
+ storageSubsidyOil = averageOilInventory.multiply(new BigDecimal("0.2"));
|
|
267
|
+ fsStorageSubsidySettle.setStorageSubsidyOil(storageSubsidyOil);//(5)
|
|
268
|
+
|
|
269
|
+ }
|
|
270
|
+ this.save(fsStorageSubsidySettle);
|
185
|
271
|
}
|
186
|
272
|
|
187
|
273
|
}
|