Explorar o código

年度预算-历史数据同步(系统已执行和计算已执行)

lgl hai 11 meses
pai
achega
f1c7bf1c5c

+ 6 - 0
src/main/java/com/liang/dao/PrjAnnualbudgetDao.java

@@ -149,5 +149,11 @@ public interface PrjAnnualbudgetDao {
149 149
     void updateSJYZXSum(Integer rws);
150 150
 
151 151
     PrjAnnualbudget queryByRws1(@Param("rws") Integer rws, @Param("nf") Integer nf);
152
+
153
+    void updateXTJSYZXByNysId(@Param("rwsId") Integer rwsId, @Param("nf") String nf, @Param("nysId") Integer nysId);
154
+
155
+    void updateSJYZXByNysId(@Param("rwsId") Integer rwsId, @Param("nf") String nf, @Param("nysId") Integer nysId);
156
+
157
+    void updateSJYZXSumByNysId(@Param("rwsId") Integer rwsId, @Param("nf") String nf, @Param("nysId") Integer nysId);
152 158
 }
153 159
 

+ 22 - 1
src/main/java/com/liang/service/impl/PrjAnnualbudgetServiceImpl.java

@@ -12,10 +12,15 @@ import org.springframework.stereotype.Service;
12 12
 import org.springframework.data.domain.Page;
13 13
 import org.springframework.data.domain.PageImpl;
14 14
 import org.springframework.data.domain.PageRequest;
15
+import org.springframework.transaction.annotation.Transactional;
16
+import org.springframework.web.bind.annotation.GetMapping;
17
+import org.springframework.web.bind.annotation.PathVariable;
18
+import org.springframework.web.bind.annotation.RestController;
15 19
 
16 20
 import javax.annotation.Resource;
17 21
 import java.util.List;
18 22
 import java.util.Map;
23
+import java.util.stream.Collectors;
19 24
 
20 25
 /**
21 26
  * 年度预算(PrjAnnualbudget)表服务实现类
@@ -24,6 +29,7 @@ import java.util.Map;
24 29
  * @since 2023-05-17 08:56:50
25 30
  */
26 31
 @Service("prjAnnualbudgetService")
32
+@RestController
27 33
 public class PrjAnnualbudgetServiceImpl implements PrjAnnualbudgetService {
28 34
     @Resource
29 35
     private PrjAnnualbudgetDao prjAnnualbudgetDao;
@@ -150,9 +156,24 @@ public class PrjAnnualbudgetServiceImpl implements PrjAnnualbudgetService {
150 156
             prjAnnualbudgetDao.updateSJYZXSum(rws);
151 157
         }
152 158
     }
159
+    @GetMapping("/updateSJYZXAndXTJSYZX/{rwsId}/{nysId}")
160
+    @Transactional(rollbackFor = Exception.class)
161
+    public void updateSJYZXAndXTJSYZX(@PathVariable("rwsId")Integer rwsId, @PathVariable("nysId")Integer nysId) {
162
+        List<PrjAnnualbudget> prjAnnualbudgets = prjAnnualbudgetDao.listByRws(rwsId);
163
+        //第一年的年度预算不需要更新
164
+        if (!Collections.isEmpty(prjAnnualbudgets) && !prjAnnualbudgets.get(0).getId().equals(nysId)) {
165
+            PrjAnnualbudget annualbudget = prjAnnualbudgets.stream().filter(item -> item.getId().equals(nysId)).collect(Collectors.toList()).get(0);
166
+            //更新 系统计算已执行
167
+            prjAnnualbudgetDao.updateXTJSYZXByNysId(rwsId,annualbudget.getNf(),annualbudget.getId());
168
+            //更新 历史年度预算的实际已执行
169
+            prjAnnualbudgetDao.updateSJYZXByNysId(rwsId,annualbudget.getNf(),annualbudget.getId());
170
+            //更新已执行总计
171
+            prjAnnualbudgetDao.updateSJYZXSumByNysId(rwsId,annualbudget.getNf(),annualbudget.getId());
172
+        }
173
+    }
153 174
 
154 175
     @Override
155 176
     public PrjAnnualbudget queryByRws1(Integer rws, Integer nf) {
156
-        return prjAnnualbudgetDao.queryByRws1(rws,nf);
177
+        return prjAnnualbudgetDao.queryByRws1(rws, nf);
157 178
     }
158 179
 }

+ 47 - 0
src/main/resources/mapper/PrjAnnualbudgetDao.xml

@@ -483,6 +483,52 @@
483 483
             prj_AnnualBudget
484 484
             where RWS = #{rws} order by nf desc )
485 485
     </update>
486
+    <update id="updateXTJSYZXByNysId">
487
+        update A
488
+        set A.XTJSYZX = B.xtjsyzx from prj_AnnualBudgetDetail A
489
+        inner join (SELECT
490
+         fymc, sum(ysje) xtjsyzx
491
+         from  prj_AnnualBudgetDetail
492
+         where nys in  (SELECT ID from prj_AnnualBudget where RWS = #{rwsId} and nf &lt; #{nf} )
493
+            group by fymc) B
494
+        on A.FYMC = B.fymc
495
+        where
496
+            NYS = #{nysId}
497
+    </update>
498
+    <update id="updateSJYZXByNysId">
499
+        update A
500
+        set A.sjyzx = B.BZJE from prj_AnnualBudgetDetail A
501
+        inner join (SELECT convert(decimal(18,2),(sum(BZJE)/10000))  BZJE ,pa.fymc
502
+	        from(SELECT	id ,fylb
503
+	  	from sta_BudgetApproval
504
+		where	nys in (
505
+			select	id
506
+			from prj_AnnualBudget
507
+			where rws = #{rwsId} and nf &lt; #{nf} )) sb
508
+            left join sta_Reimbursement sa on sa.fysq = sb.id
509
+            LEFT join prj_AnnualBudgetDetail pa on pa.id = sb.fylb
510
+            group by pa.fymc ) B
511
+        on A.FYMC = B.fymc
512
+        where
513
+            NYS = #{nysId}
514
+    </update>
515
+    <update id="updateSJYZXSumByNysId">
516
+        update A
517
+        set A.sjyzx = B.BZJE from prj_AnnualBudgetDetail A
518
+        inner join (SELECT	sum(BZJE) BZJE ,pa.fymc
519
+	        from(SELECT	id ,fylb
520
+	  	from sta_BudgetApproval
521
+		where	nys in (
522
+			select	id
523
+			from prj_AnnualBudget
524
+			where rws = #{rwsId} and nf &lt; #{nf} )) sb
525
+            left join sta_Reimbursement sa on sa.fysq = sb.id
526
+            LEFT join prj_AnnualBudgetDetail pa on pa.id = sb.fylb
527
+            group by pa.fymc ) B
528
+        on A.FYMC = B.fymc
529
+        where
530
+            NYS = #{nysId}
531
+    </update>
486 532
 
487 533
     <!--已申请费用的预算-->
488 534
     <select id="getFysqBudgetList">
@@ -496,6 +542,7 @@
496 542
         select *
497 543
         from prj_AnnualBudget
498 544
         where rws = #{rws}
545
+        order by nf asc
499 546
     </select>
500 547
     <select id="getNYSSum" resultType="java.math.BigDecimal">
501 548
         SELECT sum(pan.sjyzx) sjyzx