|
@@ -6,12 +6,14 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
6
|
import com.njyunzhi.pet_identity.common.BaseController;
|
7
|
7
|
import com.njyunzhi.pet_identity.common.ResponseBean;
|
8
|
8
|
import com.njyunzhi.pet_identity.common.StringUtils;
|
|
9
|
+import com.njyunzhi.pet_identity.common.ZipUtil;
|
9
|
10
|
import com.njyunzhi.pet_identity.entity.TaSequence;
|
10
|
11
|
import com.njyunzhi.pet_identity.service.ITaSequenceService;
|
11
|
12
|
import com.njyunzhi.pet_identity.vo.BatchCardParams;
|
12
|
13
|
import io.swagger.annotations.Api;
|
13
|
14
|
import io.swagger.annotations.ApiOperation;
|
14
|
15
|
import io.swagger.annotations.ApiParam;
|
|
16
|
+import net.lingala.zip4j.ZipFile;
|
15
|
17
|
import org.slf4j.Logger;
|
16
|
18
|
import org.slf4j.LoggerFactory;
|
17
|
19
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -24,6 +26,10 @@ import com.njyunzhi.pet_identity.service.ITaCardNoService;
|
24
|
26
|
import com.njyunzhi.pet_identity.entity.TaCardNo;
|
25
|
27
|
import org.springframework.web.bind.annotation.RestController;
|
26
|
28
|
|
|
29
|
+import javax.servlet.http.HttpServletResponse;
|
|
30
|
+import java.util.ArrayList;
|
|
31
|
+import java.util.List;
|
|
32
|
+
|
27
|
33
|
/**
|
28
|
34
|
* <p>
|
29
|
35
|
* 卡号库 前端控制器
|
|
@@ -46,6 +52,9 @@ public class TaCardNoController extends BaseController {
|
46
|
52
|
@Autowired
|
47
|
53
|
public ITaSequenceService iTaSequenceService;
|
48
|
54
|
|
|
55
|
+ @Autowired
|
|
56
|
+ public ZipUtil zipUtil;
|
|
57
|
+
|
49
|
58
|
/**
|
50
|
59
|
* 分页查询列表
|
51
|
60
|
* @param pageNum
|
|
@@ -55,10 +64,19 @@ public class TaCardNoController extends BaseController {
|
55
|
64
|
@RequestMapping(value="/cardNo",method= RequestMethod.GET)
|
56
|
65
|
@ApiOperation(value="列表", notes = "列表", httpMethod = "GET", response = ResponseBean.class)
|
57
|
66
|
public ResponseBean taCardNoList(@ApiParam("页码") @RequestParam(value ="pageNum",defaultValue = "1") Integer pageNum,
|
58
|
|
- @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize) throws Exception{
|
|
67
|
+ @ApiParam("单页数据量") @RequestParam(value ="pageSize",defaultValue = "10") Integer pageSize,
|
|
68
|
+ @ApiParam("前缀") @RequestParam(value ="prefix", required = false) String prefix,
|
|
69
|
+ @ApiParam("起始号码") @RequestParam(value ="start", required = false) Integer start,
|
|
70
|
+ @ApiParam("终止号码") @RequestParam(value ="end", required = false) Integer end) throws Exception{
|
|
71
|
+
|
|
72
|
+ if (StringUtils.isEmpty(prefix) && (null != start || null != end)) {
|
|
73
|
+ return ResponseBean.error("卡号前缀不能为空");
|
|
74
|
+ }
|
59
|
75
|
|
60
|
76
|
IPage<TaCardNo> pg = new Page<>(pageNum, pageSize);
|
61
|
77
|
QueryWrapper<TaCardNo> queryWrapper = new QueryWrapper<>();
|
|
78
|
+ queryWrapper.ge(null != start, "card_no", iTaCardNoService.getFormatNo(prefix, start));
|
|
79
|
+ queryWrapper.le(null != end, "card_no", iTaCardNoService.getFormatNo(prefix, end));
|
62
|
80
|
queryWrapper.orderByDesc("create_date");
|
63
|
81
|
|
64
|
82
|
IPage<TaCardNo> result = iTaCardNoService.page(pg, queryWrapper);
|
|
@@ -66,6 +84,42 @@ public class TaCardNoController extends BaseController {
|
66
|
84
|
}
|
67
|
85
|
|
68
|
86
|
|
|
87
|
+ /**
|
|
88
|
+ * 分页查询列表
|
|
89
|
+ * @return
|
|
90
|
+ */
|
|
91
|
+ @RequestMapping(value="/cardNo/export",method= RequestMethod.GET)
|
|
92
|
+ @ApiOperation(value="导出", notes = "导出", httpMethod = "GET", response = ResponseBean.class)
|
|
93
|
+ public ResponseBean export(@ApiParam("前缀") @RequestParam(value ="prefix") String prefix,
|
|
94
|
+ @ApiParam("起始号码") @RequestParam(value ="start", required = false) Integer start,
|
|
95
|
+ @ApiParam("终止号码") @RequestParam(value ="end", required = false) Integer end,
|
|
96
|
+ HttpServletResponse response) throws Exception{
|
|
97
|
+
|
|
98
|
+ if (StringUtils.isEmpty(prefix)) {
|
|
99
|
+ return ResponseBean.error("卡号前缀不能为空");
|
|
100
|
+ }
|
|
101
|
+
|
|
102
|
+ QueryWrapper<TaCardNo> queryWrapper = new QueryWrapper<>();
|
|
103
|
+ queryWrapper.ge(null != start, "card_no", iTaCardNoService.getFormatNo(prefix, start));
|
|
104
|
+ queryWrapper.le(null != end, "card_no", iTaCardNoService.getFormatNo(prefix, end));
|
|
105
|
+ queryWrapper.orderByDesc("create_date");
|
|
106
|
+
|
|
107
|
+ List<TaCardNo> result = iTaCardNoService.list(queryWrapper);
|
|
108
|
+
|
|
109
|
+ List<ZipUtil.RFile> files = new ArrayList<>();
|
|
110
|
+ if (null != result && result.size() > 0) {
|
|
111
|
+ for (TaCardNo item : result) {
|
|
112
|
+ ZipUtil.RFile f = new ZipUtil.RFile();
|
|
113
|
+ f.setName(item.getCardNo() + ".png");
|
|
114
|
+ f.setUrl(item.getQrImage());
|
|
115
|
+ }
|
|
116
|
+ }
|
|
117
|
+
|
|
118
|
+ ZipFile data = zipUtil.zipLink(files);
|
|
119
|
+ zipUtil.flush(response, data);
|
|
120
|
+ return null;
|
|
121
|
+ }
|
|
122
|
+
|
69
|
123
|
/**
|
70
|
124
|
* 分页查询列表
|
71
|
125
|
* @param id
|