Browse Source

企业收支结余

Signed-off-by: tangsong <86121657@qq.com>
tangsong 4 months ago
parent
commit
00de176ee2

+ 5 - 1
unis-plugin/unis-plugin-biz/src/main/java/com/unis/financialSupervision/modular/fsEnterpriseBalanceStatistic/mapper/FsEnterpriseBalanceStatisticMapper.java

@@ -26,6 +26,7 @@ import com.unis.financialSupervision.modular.fsEnterpriseBalanceStatistic.param.
26
 import org.apache.ibatis.annotations.Param;
26
 import org.apache.ibatis.annotations.Param;
27
 import org.apache.ibatis.annotations.Select;
27
 import org.apache.ibatis.annotations.Select;
28
 
28
 
29
+import java.math.BigDecimal;
29
 import java.util.List;
30
 import java.util.List;
30
 
31
 
31
 /**
32
 /**
@@ -48,9 +49,10 @@ public interface FsEnterpriseBalanceStatisticMapper extends BaseMapper<FsEnterpr
48
      * @param orgId 库 区 ID
49
      * @param orgId 库 区 ID
49
      * @param grainVarietyId 品种Id
50
      * @param grainVarietyId 品种Id
50
      * @param year 年
51
      * @param year 年
52
+     * @param month 月
51
      * @return
53
      * @return
52
      */
54
      */
53
-    FsEnterpriseBalanceStatistic getRotationPlan(@Param("orgId") Integer orgId, @Param("grainVarietyId") Integer grainVarietyId, @Param("year") Integer year);
55
+    FsEnterpriseBalanceStatistic getRotationPlan(@Param("orgId") Integer orgId, @Param("grainVarietyId") Integer grainVarietyId, @Param("year") Integer year,@Param("month")Integer month);
54
 
56
 
55
     List<FsEnterpriseBalanceStatisticVO> getList(@Param("pageParam") FsEnterpriseBalanceStatisticPageParam pageParam);
57
     List<FsEnterpriseBalanceStatisticVO> getList(@Param("pageParam") FsEnterpriseBalanceStatisticPageParam pageParam);
56
 
58
 
@@ -63,4 +65,6 @@ public interface FsEnterpriseBalanceStatisticMapper extends BaseMapper<FsEnterpr
63
     IPage<FsEnterpriseBalanceStatisticVO> selectMyMapsPage(Page<FsEnterpriseBalanceStatisticVO> p,@Param(Constants.WRAPPER)QueryWrapper<FsEnterpriseBalanceStatisticVO> queryWrapper);
65
     IPage<FsEnterpriseBalanceStatisticVO> selectMyMapsPage(Page<FsEnterpriseBalanceStatisticVO> p,@Param(Constants.WRAPPER)QueryWrapper<FsEnterpriseBalanceStatisticVO> queryWrapper);
64
 
66
 
65
     List<CostBalanceVO> getCostBalanceList(@Param("costBalanceParam") CostBalanceParam costBalanceParam);
67
     List<CostBalanceVO> getCostBalanceList(@Param("costBalanceParam") CostBalanceParam costBalanceParam);
68
+
69
+    FsEnterpriseBalanceStatistic getStorageCostAccrued(@Param("orgId") Integer orgId, @Param("grainVarietyId") Integer grainVarietyId);
66
 }
70
 }

+ 29 - 2
unis-plugin/unis-plugin-biz/src/main/java/com/unis/financialSupervision/modular/fsEnterpriseBalanceStatistic/mapper/mapping/FsEnterpriseBalanceStatisticMapper.xml

@@ -36,6 +36,8 @@
36
 
36
 
37
 		planQuantity*1000 as rotationPlanQuantity,
37
 		planQuantity*1000 as rotationPlanQuantity,
38
 		IFNULL((ckslSum+rkslSum)/(planQuantity*1000)*100,0) rotationCompletionRate,
38
 		IFNULL((ckslSum+rkslSum)/(planQuantity*1000)*100,0) rotationCompletionRate,
39
+		IFNULL(rkslSum,0.0)*IFNULL(b.standard_value, 0.0)/10000 as rotationCostAccrued,
40
+		IFNULL(ckslSum,0.0)*IFNULL(b.standard_value, 0.0)/10000 as rotationCostExpenditure,
39
 		IFNULL(b.standard_value, 0.0) as rotationCostStandard
41
 		IFNULL(b.standard_value, 0.0) as rotationCostStandard
40
  FROM (SELECT
42
  FROM (SELECT
41
             g.org_id,
43
             g.org_id,
@@ -48,7 +50,7 @@
48
                                     depot_qh.data_kcgl_fcbgz_default m1
50
                                     depot_qh.data_kcgl_fcbgz_default m1
49
                     INNER JOIN depot_qh.data_crkyw_ckcmz_default m2 ON m1.DataID = m2.DataID
51
                     INNER JOIN depot_qh.data_crkyw_ckcmz_default m2 ON m1.DataID = m2.DataID
50
                     INNER JOIN depot_qh.data_crkyw_ckrmdj_default m3 ON m3.bizno = m2.bizno
52
                     INNER JOIN depot_qh.data_crkyw_ckrmdj_default m3 ON m3.bizno = m2.bizno
51
-                    where m3.jhdID = a.rp_report_id AND m3.lspz = #{grainVarietyId}
53
+                    where m3.jhdID = a.rp_report_id AND m3.lspz = #{grainVarietyId} and DATE_FORMAT(m1.rq,'%m') = #{month}
52
             )  as "ckslSum",
54
             )  as "ckslSum",
53
              IFNULL(SUM(e.plan_quantity),0.0) as "inPlanQuantity",
55
              IFNULL(SUM(e.plan_quantity),0.0) as "inPlanQuantity",
54
             (   SELECT
56
             (   SELECT
@@ -57,7 +59,7 @@
57
                                     depot_qh.data_kcgl_fcbgz_default m1
59
                                     depot_qh.data_kcgl_fcbgz_default m1
58
                     INNER JOIN depot_qh.data_crkyw_cpz_default m2 ON m1.DataID = m2.DataID
60
                     INNER JOIN depot_qh.data_crkyw_cpz_default m2 ON m1.DataID = m2.DataID
59
                     INNER JOIN depot_qh.data_crkyw_rmdj_default m3 ON m3.bizno = m2.bizno
61
                     INNER JOIN depot_qh.data_crkyw_rmdj_default m3 ON m3.bizno = m2.bizno
60
-                    where m3.jhdh = a.rp_report_id  AND m3.lspz = #{grainVarietyId}
62
+                    where m3.jhdh = a.rp_report_id  AND m3.lspz = #{grainVarietyId} and DATE_FORMAT(m1.rq,'%m') = #{month}
61
             )  as "rkslSum"
63
             )  as "rkslSum"
62
     FROM
64
     FROM
63
      province_all.biz_rp_issuance a
65
      province_all.biz_rp_issuance a
@@ -222,4 +224,29 @@ AND b.grain_variety_id =#{grainVarietyId} and b.standard_type = 1
222
             a. MONTH
224
             a. MONTH
223
     ) x
225
     ) x
224
     </select>
226
     </select>
227
+    <select id="getStorageCostAccrued" resultType="com.unis.financialSupervision.modular.fsEnterpriseBalanceStatistic.entity.FsEnterpriseBalanceStatistic">
228
+        SELECT
229
+		kcsl*IFNULL(b.standard_value, 0.0)/10000 as storageCostAccrued,
230
+		IFNULL(ckslSum,0.0)*IFNULL(b.standard_value, 0.0)/10000 as storageCostExpenditure
231
+         FROM (
232
+                    SELECT
233
+                        g.org_id,
234
+                 a.kcsl ,
235
+            (   SELECT
236
+                     IFNULL(sum(m1.zcsl),0.0) as cksl
237
+                                    FROM
238
+                                    depot_qh.data_kcgl_fcbgz_default m1
239
+                                    INNER JOIN depot_qh.data_crkyw_ckcmz_default m2 ON m1.DataID = m2.DataID
240
+                                    INNER JOIN depot_qh.data_crkyw_ckrmdj_default m3 ON m3.bizno = m2.bizno
241
+                                    where m3.UnitID = a.UnitID AND m3.lspz = a.pz
242
+                    )  as "ckslSum"
243
+            FROM
244
+            depot_qh.data_kcgl_kcsw_default a
245
+            right JOIN  depot_qh.org_info  g on g.org_id = a.UnitID
246
+         where g.org_id = #{orgId}  AND a.pz = #{grainVarietyId}
247
+            GROUP BY g.org_id
248
+        ) x
249
+        LEFT JOIN depot_qh.business_fs_cost_standard b ON x.org_id = b.org_id
250
+        AND b.grain_variety_id =#{grainVarietyId} and b.standard_type = 2
251
+    </select>
225
 </mapper>
252
 </mapper>

+ 69 - 6
unis-plugin/unis-plugin-biz/src/main/java/com/unis/financialSupervision/modular/fsEnterpriseBalanceStatistic/service/impl/FsEnterpriseBalanceStatisticServiceImpl.java

@@ -44,6 +44,7 @@ import javax.servlet.http.HttpServletResponse;
44
 import java.io.File;
44
 import java.io.File;
45
 import java.io.IOException;
45
 import java.io.IOException;
46
 import java.io.InputStream;
46
 import java.io.InputStream;
47
+import java.math.BigDecimal;
47
 import java.util.List;
48
 import java.util.List;
48
 
49
 
49
 /**
50
 /**
@@ -77,12 +78,74 @@ public class FsEnterpriseBalanceStatisticServiceImpl extends ServiceImpl<FsEnter
77
         for (FsEnterpriseBalanceStatistic balanceStatistic:balanceStatisticList) {
78
         for (FsEnterpriseBalanceStatistic balanceStatistic:balanceStatisticList) {
78
             Integer orgId = balanceStatistic.getOrgId();
79
             Integer orgId = balanceStatistic.getOrgId();
79
             Integer grainVarietyId = balanceStatistic.getGrainVarietyId();
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
             QueryWrapper<FsEnterpriseBalanceStatistic> queryWrapper = new QueryWrapper<>();
151
             QueryWrapper<FsEnterpriseBalanceStatistic> queryWrapper = new QueryWrapper<>();