|
@@ -2,9 +2,6 @@ package com.njyunzhi.invoice.controller;
|
2
|
2
|
|
3
|
3
|
import com.alibaba.excel.EasyExcel;
|
4
|
4
|
import com.alibaba.excel.ExcelWriter;
|
5
|
|
-import com.alibaba.excel.metadata.Head;
|
6
|
|
-import com.alibaba.excel.support.ExcelTypeEnum;
|
7
|
|
-import com.alibaba.excel.write.merge.AbstractMergeStrategy;
|
8
|
5
|
import com.alibaba.excel.write.metadata.WriteSheet;
|
9
|
6
|
import com.alibaba.excel.write.metadata.fill.FillConfig;
|
10
|
7
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
@@ -13,26 +10,18 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
13
|
10
|
import com.njyunzhi.invoice.common.*;
|
14
|
11
|
import com.njyunzhi.invoice.common.excel.MergeRowStrategy;
|
15
|
12
|
import com.njyunzhi.invoice.entity.TaInvoiceDetail;
|
|
13
|
+import com.njyunzhi.invoice.entity.TaInvoiceFill;
|
16
|
14
|
import com.njyunzhi.invoice.service.ITaInvoiceDetailService;
|
|
15
|
+import com.njyunzhi.invoice.service.ITaInvoiceFillService;
|
17
|
16
|
import io.swagger.annotations.Api;
|
18
|
17
|
import io.swagger.annotations.ApiOperation;
|
19
|
18
|
import io.swagger.annotations.ApiParam;
|
20
|
|
-import org.apache.poi.ss.usermodel.Cell;
|
21
|
|
-import org.apache.poi.ss.usermodel.Sheet;
|
22
|
19
|
import org.slf4j.Logger;
|
23
|
20
|
import org.slf4j.LoggerFactory;
|
24
|
21
|
import org.springframework.beans.factory.annotation.Autowired;
|
25
|
|
-import org.springframework.web.bind.annotation.PathVariable;
|
26
|
|
-import org.springframework.web.bind.annotation.RequestBody;
|
27
|
|
-import org.springframework.web.bind.annotation.RequestMapping;
|
28
|
|
-import org.springframework.web.bind.annotation.RequestMethod;
|
29
|
|
-import org.springframework.web.bind.annotation.RequestParam;
|
30
|
|
-import com.njyunzhi.invoice.service.ITaInvoiceFillService;
|
31
|
|
-import com.njyunzhi.invoice.entity.TaInvoiceFill;
|
32
|
|
-import org.springframework.web.bind.annotation.RestController;
|
|
22
|
+import org.springframework.web.bind.annotation.*;
|
33
|
23
|
|
34
|
24
|
import javax.servlet.http.HttpServletResponse;
|
35
|
|
-import java.io.File;
|
36
|
25
|
import java.io.InputStream;
|
37
|
26
|
import java.util.HashMap;
|
38
|
27
|
import java.util.List;
|
|
@@ -41,8 +30,8 @@ import java.util.stream.Collectors;
|
41
|
30
|
|
42
|
31
|
/**
|
43
|
32
|
* <p>
|
44
|
|
- * 报销主表 前端控制器
|
45
|
|
- * </p>
|
|
33
|
+ * 报销主表 前端控制器
|
|
34
|
+ * </p>
|
46
|
35
|
*
|
47
|
36
|
* @author yansen
|
48
|
37
|
* @since 2022-07-04
|
|
@@ -66,19 +55,22 @@ public class TaInvoiceFillController extends BaseController {
|
66
|
55
|
|
67
|
56
|
/**
|
68
|
57
|
* 分页查询列表
|
|
58
|
+ *
|
69
|
59
|
* @param pageNum
|
70
|
60
|
* @param pageSize
|
71
|
61
|
* @return
|
72
|
62
|
*/
|
73
|
|
- @RequestMapping(value="/{client}/invoice",method= RequestMethod.GET)
|
74
|
|
- @ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
|
63
|
+ @RequestMapping(value = "/{client}/invoice", method = RequestMethod.GET)
|
|
64
|
+ @ApiOperation(value = "列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
75
|
65
|
public ResponseBean taInvoiceFillList(@ApiParam("客户端") @PathVariable String client,
|
76
|
|
- @ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
77
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
78
|
|
- @ApiParam("班级名称") @RequestParam(value ="name", required = false) String name) throws Exception{
|
|
66
|
+ @ApiParam("页码") @RequestParam(value = "pageNum", defaultValue = "1") Integer pageNum,
|
|
67
|
+ @ApiParam("单页数据量") @RequestParam(value = "pageSize", defaultValue = "10") Integer pageSize,
|
|
68
|
+ @ApiParam("班级名称") @RequestParam(value = "name", required = false) String name,
|
|
69
|
+ @ApiParam("状态") @RequestParam(value = "status", required = false) String status) throws Exception {
|
79
|
70
|
IPage<TaInvoiceFill> pg = new Page<>(pageNum, pageSize);
|
80
|
71
|
QueryWrapper<TaInvoiceFill> queryWrapper = new QueryWrapper<>();
|
81
|
72
|
queryWrapper.gt("status", Constants.STATUS_DELETE);
|
|
73
|
+ queryWrapper.eq(!StringUtils.isEmpty(status),"status", status);
|
82
|
74
|
queryWrapper.like(!StringUtils.isEmpty(name), "name", "%" + name + "%");
|
83
|
75
|
queryWrapper.orderByAsc("create_date");
|
84
|
76
|
|
|
@@ -91,10 +83,10 @@ public class TaInvoiceFillController extends BaseController {
|
91
|
83
|
return ResponseBean.success(result);
|
92
|
84
|
}
|
93
|
85
|
|
94
|
|
- @RequestMapping(value="/admin/invoice/{id}/export",method= RequestMethod.POST)
|
95
|
|
- @ApiOperation(value="导出", notes = "导出", httpMethod = "POST", response = ResponseBean.class)
|
|
86
|
+ @RequestMapping(value = "/admin/invoice/{id}/export", method = RequestMethod.POST)
|
|
87
|
+ @ApiOperation(value = "导出", notes = "导出", httpMethod = "POST", response = ResponseBean.class)
|
96
|
88
|
public void export(@ApiParam("班级ID") @PathVariable String id,
|
97
|
|
- HttpServletResponse response) throws Exception {
|
|
89
|
+ HttpServletResponse response) throws Exception {
|
98
|
90
|
TaInvoiceFill invoiceFill = iTaInvoiceFillService.getById(id);
|
99
|
91
|
if (null == invoiceFill) {
|
100
|
92
|
throw new Exception("为找到班级信息");
|
|
@@ -109,7 +101,7 @@ public class TaInvoiceFillController extends BaseController {
|
109
|
101
|
|
110
|
102
|
response.setContentType("application/vnd.ms-excel");
|
111
|
103
|
response.setCharacterEncoding("utf-8");
|
112
|
|
- response.setHeader("Content-disposition", "attachment;filename="+expFile);
|
|
104
|
+ response.setHeader("Content-disposition", "attachment;filename=" + expFile);
|
113
|
105
|
|
114
|
106
|
List<Object> mergeDataList = list.stream().map(x -> x.getPersonName()).collect(Collectors.toList());
|
115
|
107
|
ExcelWriter excelWriter = EasyExcel.write(response.getOutputStream(), TaInvoiceDetail.class).withTemplate(inputStream).build();
|
|
@@ -126,71 +118,75 @@ public class TaInvoiceFillController extends BaseController {
|
126
|
118
|
|
127
|
119
|
/**
|
128
|
120
|
* 保存对象
|
|
121
|
+ *
|
129
|
122
|
* @param taInvoiceFill 实体对象
|
130
|
123
|
* @return
|
131
|
124
|
*/
|
132
|
|
- @RequestMapping(value="/admin/invoice",method= RequestMethod.POST)
|
133
|
|
- @ApiOperation(value="保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
134
|
|
- public ResponseBean taInvoiceFillAdd(@ApiParam("保存内容") @RequestBody TaInvoiceFill taInvoiceFill) throws Exception{
|
|
125
|
+ @RequestMapping(value = "/admin/invoice", method = RequestMethod.POST)
|
|
126
|
+ @ApiOperation(value = "保存", notes = "保存", httpMethod = "POST", response = ResponseBean.class)
|
|
127
|
+ public ResponseBean taInvoiceFillAdd(@ApiParam("保存内容") @RequestBody TaInvoiceFill taInvoiceFill) throws Exception {
|
135
|
128
|
|
136
|
129
|
if (null == taInvoiceFill.getStatus()) {
|
137
|
130
|
taInvoiceFill.setStatus(Constants.STATUS_READY);
|
138
|
131
|
}
|
139
|
132
|
|
140
|
|
- if (iTaInvoiceFillService.save(taInvoiceFill)){
|
|
133
|
+ if (iTaInvoiceFillService.save(taInvoiceFill)) {
|
141
|
134
|
return ResponseBean.success(taInvoiceFill);
|
142
|
|
- }else {
|
|
135
|
+ } else {
|
143
|
136
|
return ResponseBean.error("保存失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
144
|
137
|
}
|
145
|
138
|
}
|
146
|
139
|
|
147
|
140
|
/**
|
148
|
141
|
* 根据id删除对象
|
149
|
|
- * @param id 实体ID
|
|
142
|
+ *
|
|
143
|
+ * @param id 实体ID
|
150
|
144
|
*/
|
151
|
|
- @RequestMapping(value="/admin/invoice/{id}", method= RequestMethod.DELETE)
|
152
|
|
- @ApiOperation(value="删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
153
|
|
- public ResponseBean taInvoiceFillDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
154
|
|
- if(iTaInvoiceFillService.removeLogicById(id)){
|
|
145
|
+ @RequestMapping(value = "/admin/invoice/{id}", method = RequestMethod.DELETE)
|
|
146
|
+ @ApiOperation(value = "删除", notes = "删除", httpMethod = "DELETE", response = ResponseBean.class)
|
|
147
|
+ public ResponseBean taInvoiceFillDelete(@ApiParam("对象ID") @PathVariable String id) throws Exception {
|
|
148
|
+ if (iTaInvoiceFillService.removeLogicById(id)) {
|
155
|
149
|
return ResponseBean.success("success");
|
156
|
|
- }else {
|
|
150
|
+ } else {
|
157
|
151
|
return ResponseBean.error("删除失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
158
|
152
|
}
|
159
|
153
|
}
|
160
|
154
|
|
161
|
155
|
/**
|
162
|
156
|
* 修改对象
|
163
|
|
- * @param id 实体ID
|
|
157
|
+ *
|
|
158
|
+ * @param id 实体ID
|
164
|
159
|
* @param taInvoiceFill 实体对象
|
165
|
160
|
* @return
|
166
|
161
|
*/
|
167
|
|
- @RequestMapping(value="/admin/invoice/{id}",method= RequestMethod.PUT)
|
168
|
|
- @ApiOperation(value="更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
|
162
|
+ @RequestMapping(value = "/admin/invoice/{id}", method = RequestMethod.PUT)
|
|
163
|
+ @ApiOperation(value = "更新", notes = "更新", httpMethod = "PUT", response = ResponseBean.class)
|
169
|
164
|
public ResponseBean taInvoiceFillUpdate(@ApiParam("对象ID") @PathVariable String id,
|
170
|
|
- @ApiParam("更新内容") @RequestBody TaInvoiceFill taInvoiceFill) throws Exception{
|
|
165
|
+ @ApiParam("更新内容") @RequestBody TaInvoiceFill taInvoiceFill) throws Exception {
|
171
|
166
|
|
172
|
167
|
taInvoiceFill.setInvoiceId(id);
|
173
|
|
- if (iTaInvoiceFillService.updateById(taInvoiceFill)){
|
|
168
|
+ if (iTaInvoiceFillService.updateById(taInvoiceFill)) {
|
174
|
169
|
return ResponseBean.success(iTaInvoiceFillService.getById(id));
|
175
|
|
- }else {
|
|
170
|
+ } else {
|
176
|
171
|
return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
177
|
172
|
}
|
178
|
173
|
}
|
179
|
174
|
|
180
|
175
|
/**
|
181
|
176
|
* 根据id查询对象
|
182
|
|
- * @param id 实体ID
|
|
177
|
+ *
|
|
178
|
+ * @param id 实体ID
|
183
|
179
|
*/
|
184
|
|
- @RequestMapping(value="/admin/invoice/{id}",method= RequestMethod.GET)
|
185
|
|
- @ApiOperation(value="详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
186
|
|
- public ResponseBean taInvoiceFillGet(@ApiParam("对象ID") @PathVariable String id) throws Exception{
|
|
180
|
+ @RequestMapping(value = "/admin/invoice/{id}", method = RequestMethod.GET)
|
|
181
|
+ @ApiOperation(value = "详情", notes = "详情", httpMethod = "GET", response = ResponseBean.class)
|
|
182
|
+ public ResponseBean taInvoiceFillGet(@ApiParam("对象ID") @PathVariable String id) throws Exception {
|
187
|
183
|
return ResponseBean.success(iTaInvoiceFillService.getById(id));
|
188
|
184
|
}
|
189
|
185
|
|
190
|
186
|
|
191
|
|
- @RequestMapping(value="/h5/invoice/{invoiceId}",method= RequestMethod.GET)
|
192
|
|
- @ApiOperation(value="获取报销单", notes = "获取报销单", httpMethod = "GET", response = ResponseBean.class)
|
193
|
|
- public ResponseBean getInvoice(@ApiParam("班级ID") @PathVariable(value ="invoiceId") String invoiceId) throws Exception{
|
|
187
|
+ @RequestMapping(value = "/h5/invoice/{invoiceId}", method = RequestMethod.GET)
|
|
188
|
+ @ApiOperation(value = "获取报销单", notes = "获取报销单", httpMethod = "GET", response = ResponseBean.class)
|
|
189
|
+ public ResponseBean getInvoice(@ApiParam("班级ID") @PathVariable(value = "invoiceId") String invoiceId) throws Exception {
|
194
|
190
|
TaInvoiceFill taInvoiceFill = iTaInvoiceFillService.getById(invoiceId);
|
195
|
191
|
if (null == taInvoiceFill || taInvoiceFill.getStatus() != Constants.STATUS_NORMAL) {
|
196
|
192
|
return ResponseBean.error("报销单不存在");
|