|
@@ -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) {
|