|
@@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletResponse;
|
44
|
44
|
import java.io.File;
|
45
|
45
|
import java.io.IOException;
|
46
|
46
|
import java.io.InputStream;
|
|
47
|
+import java.math.BigDecimal;
|
47
|
48
|
import java.util.List;
|
48
|
49
|
|
49
|
50
|
/**
|
|
@@ -77,12 +78,74 @@ public class FsEnterpriseBalanceStatisticServiceImpl extends ServiceImpl<FsEnter
|
77
|
78
|
for (FsEnterpriseBalanceStatistic balanceStatistic:balanceStatisticList) {
|
78
|
79
|
Integer orgId = balanceStatistic.getOrgId();
|
79
|
80
|
Integer grainVarietyId = balanceStatistic.getGrainVarietyId();
|
80
|
|
- //得到轮换计划数据
|
81
|
|
- FsEnterpriseBalanceStatistic rotationPlan = fsEnterpriseBalanceStatisticMapper.getRotationPlan(orgId,grainVarietyId,year);
|
82
|
|
- if (rotationPlan != null){
|
83
|
|
- balanceStatistic.setRotationPlanQuantity(rotationPlan.getRotationPlanQuantity()); //轮换计划数量
|
84
|
|
- balanceStatistic.setRotationCompletionRate(rotationPlan.getRotationCompletionRate()); //轮换完成率
|
85
|
|
- balanceStatistic.setRotationCostStandard(rotationPlan.getRotationCostStandard()); //轮换费用标准
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+ //保管费只进行本年累计,如果月份为0,则不获取上月累计数据
|
|
84
|
+ BigDecimal storageCostAccrued = BigDecimal.ZERO;
|
|
85
|
+ BigDecimal storageCostExpenditure = BigDecimal.ZERO;
|
|
86
|
+ BigDecimal storageCostBalance = BigDecimal.ZERO;
|
|
87
|
+ Integer storageCostOverdraftMonth = 0; //保管费超支月数
|
|
88
|
+ //轮换费只进行本年累计,如果月份为0,则不获取上月累计数据
|
|
89
|
+ BigDecimal rotationCostAccrued = BigDecimal.ZERO;
|
|
90
|
+ BigDecimal rotationCostExpenditure = BigDecimal.ZERO;
|
|
91
|
+ BigDecimal rotationCostBalance = BigDecimal.ZERO;
|
|
92
|
+ Integer rotationCostOverdraftMonth = 0; //轮换费超支月数
|
|
93
|
+ if (month != 1){
|
|
94
|
+ //查询上月数据
|
|
95
|
+ QueryWrapper<FsEnterpriseBalanceStatistic> preQueryWrapper = new QueryWrapper<>();
|
|
96
|
+ preQueryWrapper.lambda()
|
|
97
|
+ .eq(FsEnterpriseBalanceStatistic::getOrgId,orgId)
|
|
98
|
+ .eq(FsEnterpriseBalanceStatistic::getPlanYear,year)
|
|
99
|
+ .eq(FsEnterpriseBalanceStatistic::getMonth,month-1)
|
|
100
|
+ .eq(FsEnterpriseBalanceStatistic::getGrainVarietyId,grainVarietyId);
|
|
101
|
+ FsEnterpriseBalanceStatistic balanceStatistic_pre = super.getOne(preQueryWrapper,false);
|
|
102
|
+ if (balanceStatistic_pre !=null){
|
|
103
|
+ //保管费相关
|
|
104
|
+ storageCostAccrued = balanceStatistic_pre.getStorageCostAccrued();
|
|
105
|
+ storageCostExpenditure = balanceStatistic_pre.getStorageCostExpenditure();
|
|
106
|
+ storageCostOverdraftMonth = balanceStatistic_pre.getStorageCostOverdraftMonth();
|
|
107
|
+ //轮换费相关
|
|
108
|
+ rotationCostAccrued = balanceStatistic_pre.getRotationCostAccrued();
|
|
109
|
+ rotationCostExpenditure = balanceStatistic_pre.getRotationCostExpenditure();
|
|
110
|
+ rotationCostOverdraftMonth = balanceStatistic_pre.getRotationCostOverdraftMonth();
|
|
111
|
+
|
|
112
|
+ }
|
|
113
|
+ //获取本月保管费用相关数据
|
|
114
|
+ FsEnterpriseBalanceStatistic storageCost = fsEnterpriseBalanceStatisticMapper.getStorageCostAccrued(orgId,grainVarietyId);
|
|
115
|
+ if (storageCost != null){
|
|
116
|
+ storageCostAccrued = NumberUtil.add(storageCostAccrued,storageCost.getStorageCostAccrued());
|
|
117
|
+ storageCostExpenditure = NumberUtil.add(storageCostExpenditure,storageCost.getStorageCostExpenditure());
|
|
118
|
+ storageCostBalance = NumberUtil.sub(storageCostAccrued,storageCostExpenditure); //负数为超支
|
|
119
|
+ balanceStatistic.setStorageCostOverdraftWarning(1); //未超支
|
|
120
|
+ if (NumberUtil.compare(storageCostBalance.doubleValue(),0.0) <0){
|
|
121
|
+ storageCostOverdraftMonth +=1; //
|
|
122
|
+ balanceStatistic.setStorageCostOverdraftWarning(2); //超支
|
|
123
|
+ }
|
|
124
|
+ balanceStatistic.setStorageCostAccrued(storageCostAccrued);
|
|
125
|
+ balanceStatistic.setStorageCostExpenditure(storageCostExpenditure);
|
|
126
|
+ balanceStatistic.setStorageCostBalance(storageCostBalance);
|
|
127
|
+ balanceStatistic.setRotationCostOverdraftMonth(storageCostOverdraftMonth);
|
|
128
|
+ }
|
|
129
|
+ //得到轮换计划数据,及本月轮换出库,入库轮换金额
|
|
130
|
+ FsEnterpriseBalanceStatistic rotationPlan = fsEnterpriseBalanceStatisticMapper.getRotationPlan(orgId,grainVarietyId,year,month);
|
|
131
|
+ if (rotationPlan != null){
|
|
132
|
+ balanceStatistic.setRotationPlanQuantity(rotationPlan.getRotationPlanQuantity()); //轮换计划数量
|
|
133
|
+ balanceStatistic.setRotationCompletionRate(rotationPlan.getRotationCompletionRate()); //轮换完成率
|
|
134
|
+ balanceStatistic.setRotationCostStandard(rotationPlan.getRotationCostStandard()); //轮换费用标准
|
|
135
|
+ rotationCostAccrued = NumberUtil.add(rotationCostAccrued,rotationPlan.getRotationCostAccrued());
|
|
136
|
+ rotationCostExpenditure = NumberUtil.add(rotationCostExpenditure,rotationPlan.getRotationCostExpenditure());
|
|
137
|
+ rotationCostBalance = NumberUtil.sub(rotationCostAccrued,rotationCostExpenditure); //负数为超支
|
|
138
|
+ balanceStatistic.setRotationCostOverdraftWarning(1); //未 超支
|
|
139
|
+ if (NumberUtil.compare(rotationCostBalance.doubleValue(),0.0) <0){
|
|
140
|
+ rotationCostOverdraftMonth +=1; //
|
|
141
|
+ balanceStatistic.setRotationCostOverdraftWarning(2); //超支
|
|
142
|
+ }
|
|
143
|
+ balanceStatistic.setRotationCostAccrued(rotationCostAccrued);
|
|
144
|
+ balanceStatistic.setRotationCostExpenditure(rotationCostExpenditure);
|
|
145
|
+ balanceStatistic.setRotationCostBalance(rotationCostBalance);
|
|
146
|
+ balanceStatistic.setRotationCostOverdraftMonth(rotationCostOverdraftMonth);
|
|
147
|
+
|
|
148
|
+ }
|
86
|
149
|
}
|
87
|
150
|
//进行保存,查询是 否 存在查询条件的数据
|
88
|
151
|
QueryWrapper<FsEnterpriseBalanceStatistic> queryWrapper = new QueryWrapper<>();
|