Преглед изворни кода

费用管理-资料费科研费号问题

lgl пре 11 месеци
родитељ
комит
e25be3a7b1

+ 12 - 15
src/main/java/com/liang/controller/StaSourceFeeController.java

@@ -1,9 +1,12 @@
1 1
 package com.liang.controller;
2 2
 
3
+import cn.hutool.core.util.StrUtil;
3 4
 import com.github.pagehelper.PageInfo;
4 5
 import com.liang.common.JsonTool;
5 6
 import com.liang.common.base.BaseController;
6 7
 import com.liang.common.base.BaseResult;
8
+import com.liang.common.exception.CustomException;
9
+import com.liang.common.utils.Tools;
7 10
 import com.liang.entity.StaSourceFee;
8 11
 import com.liang.service.StaSourceFeeService;
9 12
 import org.springframework.data.domain.Page;
@@ -110,25 +113,19 @@ public class StaSourceFeeController extends BaseController {
110 113
     public BaseResult batchInsert(@RequestBody String data, @PathVariable Integer zb) {
111 114
         //删除资料费
112 115
         staSourceFeeService.deleteByZb(zb);
113
-        DateFormat dateFormat = new SimpleDateFormat("yyyy");
114
-
115 116
         List<StaSourceFee> expenseList = JsonTool.parseArray(data, StaSourceFee.class);
116
-        for (int i = 0; i < expenseList.size(); i++) {
117
-            String partBh = "科研费号(" + dateFormat.format(new Date()) + ")";
118
-            String kyfh = GetApproveRecordBH(partBh);
119
-            expenseList.get(i).setKyfh(kyfh);
120
-            expenseList.get(i).setZb(zb);
117
+        if (Tools.isEmpty(expenseList) || Tools.isEmpty(data)) {
118
+            throw new CustomException("请录入差旅费");
121 119
         }
122
-        if (expenseList.size() > 0) {
123
-            int num = staSourceFeeService.insertBatch(expenseList);
124
-            if (num == expenseList.size()) {
125
-                return BaseResult.success("差旅费保存成功!");
126
-            } else {
127
-                return BaseResult.failure("差旅费保存失败!");
128
-            }
120
+        expenseList.forEach(item->item.setZb(zb));
121
+
122
+        int num = staSourceFeeService.insertBatch(expenseList);
123
+        if (num == expenseList.size()) {
124
+            return BaseResult.success("差旅费保存成功!");
129 125
         } else {
130
-            return BaseResult.success("没有要保存的信息");
126
+            return BaseResult.failure("差旅费保存失败!");
131 127
         }
128
+
132 129
     }
133 130
 
134 131
     private String GetApproveRecordBH(String partBh) {

+ 10 - 1
src/main/resources/mapper/StaSourceFeeDao.xml

@@ -191,8 +191,17 @@
191 191
 
192 192
     <!--获取资料费列表-->
193 193
     <select id="getZlfList" resultMap="StaSourceFeeMap">
194
-        select e.*
194
+        select  e.ID,
195
+                e.ZB,
196
+                e.FYSQ,
197
+                e.BZFY,
198
+                e.TSMC,
199
+                e.CBS,
200
+                e.SL,
201
+                e.ZJ,
202
+                sb.bh kyfh
195 203
         from sta_SourceFee e
204
+        left join  sta_BudgetApproval sb on sb.id = e.zb
196 205
         where ZB = #{zb}
197 206
     </select>
198 207