|
@@ -3,10 +3,7 @@ package com.njyunzhi.pet_identity.controller;
|
3
|
3
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
4
|
4
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
5
|
5
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
6
|
|
-import com.njyunzhi.pet_identity.common.BaseController;
|
7
|
|
-import com.njyunzhi.pet_identity.common.Constants;
|
8
|
|
-import com.njyunzhi.pet_identity.common.ResponseBean;
|
9
|
|
-import com.njyunzhi.pet_identity.common.StringUtils;
|
|
6
|
+import com.njyunzhi.pet_identity.common.*;
|
10
|
7
|
import com.njyunzhi.pet_identity.entity.*;
|
11
|
8
|
import com.njyunzhi.pet_identity.service.ITaCardNoService;
|
12
|
9
|
import com.njyunzhi.pet_identity.service.ITaOrderService;
|
|
@@ -27,8 +24,10 @@ import org.springframework.web.bind.annotation.RequestParam;
|
27
|
24
|
import com.njyunzhi.pet_identity.service.ITaApplicationService;
|
28
|
25
|
import org.springframework.web.bind.annotation.RestController;
|
29
|
26
|
|
|
27
|
+import javax.servlet.http.HttpServletResponse;
|
30
|
28
|
import java.time.LocalDateTime;
|
31
|
29
|
import java.util.ArrayList;
|
|
30
|
+import java.util.List;
|
32
|
31
|
|
33
|
32
|
/**
|
34
|
33
|
* <p>
|
|
@@ -58,6 +57,12 @@ public class TaApplicationController extends BaseController {
|
58
|
57
|
@Autowired
|
59
|
58
|
public ITaCardNoService iTaCardNoService;
|
60
|
59
|
|
|
60
|
+ @Autowired
|
|
61
|
+ HttpUtils httpUtils;
|
|
62
|
+
|
|
63
|
+ @Autowired
|
|
64
|
+ ZipUtil zipUtil;
|
|
65
|
+
|
61
|
66
|
/**
|
62
|
67
|
* 分页查询列表
|
63
|
68
|
* @param pageNum
|
|
@@ -140,6 +145,58 @@ public class TaApplicationController extends BaseController {
|
140
|
145
|
return ResponseBean.success(result);
|
141
|
146
|
}
|
142
|
147
|
|
|
148
|
+ @RequestMapping(value="/admin/application/card/export",method= RequestMethod.POST)
|
|
149
|
+ @ApiOperation(value="发证导出", notes = "发证导出", httpMethod = "POST", response = ResponseBean.class)
|
|
150
|
+ public ResponseBean exportCard(@ApiParam("证件号列表") @RequestBody List<String> cardNoList,
|
|
151
|
+ HttpServletResponse response) throws Exception {
|
|
152
|
+ List<TaPetIdentity> taPetIdentityList = iTaPetIdentityService.getListByCard(cardNoList);
|
|
153
|
+
|
|
154
|
+ if (null == taPetIdentityList || taPetIdentityList.size() < 1) {
|
|
155
|
+ return ResponseBean.error("未找到导出数据");
|
|
156
|
+ }
|
|
157
|
+
|
|
158
|
+ List<ZipUtil.ZFile> zipFiles = new ArrayList<>();
|
|
159
|
+
|
|
160
|
+ // 批量生成图片
|
|
161
|
+ for (TaPetIdentity item : taPetIdentityList) {
|
|
162
|
+ // 如果是企业
|
|
163
|
+ if (!StringUtils.isEmpty(item.getOrgName())) {
|
|
164
|
+ item.setPersonName(item.getOrgName());
|
|
165
|
+ }
|
|
166
|
+
|
|
167
|
+ // 下载图片
|
|
168
|
+ if (!StringUtils.isEmpty(item.getPetImg1())) {
|
|
169
|
+ ZipUtil.ZFile f = buildImage(item.getPetImg1());
|
|
170
|
+ zipFiles.add(f);
|
|
171
|
+ item.setPetImg1(StringUtils.trimEnd(f.getName(), ".jpg"));
|
|
172
|
+ }
|
|
173
|
+ if (!StringUtils.isEmpty(item.getQrImage())) {
|
|
174
|
+ ZipUtil.ZFile f = buildImage(item.getQrImage());
|
|
175
|
+ zipFiles.add(f);
|
|
176
|
+ item.setQrImage(StringUtils.trimEnd(f.getName(), ".jpg"));
|
|
177
|
+ }
|
|
178
|
+ }
|
|
179
|
+
|
|
180
|
+ // 生成 excel 文档
|
|
181
|
+ byte[] excelData = ExcelUtils.buildExcel(TaPetIdentity.class, taPetIdentityList, null);
|
|
182
|
+ ZipUtil.ZFile f = new ZipUtil.ZFile();
|
|
183
|
+ String fname = StringUtils.random(16);
|
|
184
|
+ f.setName(fname + ".xlsx");
|
|
185
|
+ f.setData(excelData);
|
|
186
|
+ zipFiles.add(f);
|
|
187
|
+
|
|
188
|
+ zipUtil.flushMixFile(response, zipFiles);
|
|
189
|
+ return null;
|
|
190
|
+ }
|
|
191
|
+
|
|
192
|
+ private ZipUtil.ZFile buildImage(String imgURL) {
|
|
193
|
+ ZipUtil.ZFile f = new ZipUtil.ZFile();
|
|
194
|
+ String fname = StringUtils.random(16);
|
|
195
|
+ f.setName(fname + ".jpg");
|
|
196
|
+ f.setData(httpUtils.download(imgURL));
|
|
197
|
+ return f;
|
|
198
|
+ }
|
|
199
|
+
|
143
|
200
|
|
144
|
201
|
/**
|
145
|
202
|
* 分页查询列表
|
|
@@ -371,6 +428,51 @@ public class TaApplicationController extends BaseController {
|
371
|
428
|
}
|
372
|
429
|
}
|
373
|
430
|
|
|
431
|
+ /**
|
|
432
|
+ * 绑卡
|
|
433
|
+ * @param id 实体ID
|
|
434
|
+ * @param makeCardParam 实体对象
|
|
435
|
+ * @return
|
|
436
|
+ */
|
|
437
|
+ @RequestMapping(value="/admin/application/{id}/bindCard",method= RequestMethod.PUT)
|
|
438
|
+ @ApiOperation(value="绑卡", notes = "绑卡", httpMethod = "PUT", response = ResponseBean.class)
|
|
439
|
+ public ResponseBean bindCard(@ApiParam("对象ID") @PathVariable Integer id,
|
|
440
|
+ @ApiParam("更新内容") @RequestBody MakeCardParam makeCardParam) throws Exception{
|
|
441
|
+ SysUser sysUser = currentUser();
|
|
442
|
+ if (!checkRole(sysUser.getRoleName(), Constants.USER_MAKER)) {
|
|
443
|
+ return ResponseBean.error("暂无权限");
|
|
444
|
+ }
|
|
445
|
+
|
|
446
|
+ TaApplication taApplication = iTaApplicationService.getById(id);
|
|
447
|
+ if (null == taApplication || taApplication.getStatus() == Constants.STATUS_DELETE) {
|
|
448
|
+ return ResponseBean.error("未找到数据");
|
|
449
|
+ }
|
|
450
|
+
|
|
451
|
+ if (StringUtils.isEmpty(makeCardParam.getCardNo())) {
|
|
452
|
+ return ResponseBean.error("卡号不能为空");
|
|
453
|
+ } else {
|
|
454
|
+ TaCardNo taCardNo = iTaCardNoService.getUnuseCard(makeCardParam.getCardNo());
|
|
455
|
+ if (taCardNo == null) {
|
|
456
|
+ return ResponseBean.error("卡号无效或者已使用");
|
|
457
|
+ }
|
|
458
|
+
|
|
459
|
+ // 将卡号置为已使用
|
|
460
|
+ taCardNo.setStatus(Constants.STATUS_NORMAL);
|
|
461
|
+ iTaCardNoService.updateById(taCardNo);
|
|
462
|
+
|
|
463
|
+ TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", makeCardParam.getCardNo(), false, true);
|
|
464
|
+ if (null != taPetIdentity) {
|
|
465
|
+ return ResponseBean.error("卡号已被占用");
|
|
466
|
+ }
|
|
467
|
+ }
|
|
468
|
+
|
|
469
|
+ taApplication.setOriginCardNo(makeCardParam.getCardNo());
|
|
470
|
+ iTaApplicationService.updateById(taApplication);
|
|
471
|
+ TaPetIdentity newCard = iTaPetIdentityService.createNewCard(taApplication, makeCardParam);
|
|
472
|
+ return ResponseBean.success(newCard);
|
|
473
|
+ }
|
|
474
|
+
|
|
475
|
+
|
374
|
476
|
/**
|
375
|
477
|
* 发证
|
376
|
478
|
* @param id 实体ID
|
|
@@ -415,26 +517,6 @@ public class TaApplicationController extends BaseController {
|
415
|
517
|
}
|
416
|
518
|
}
|
417
|
519
|
|
418
|
|
- if (StringUtils.isEmpty(makeCardParam.getCardNo())) {
|
419
|
|
- return ResponseBean.error("卡号不能为空");
|
420
|
|
- } else {
|
421
|
|
- TaCardNo taCardNo = iTaCardNoService.getUnuseCard(makeCardParam.getCardNo());
|
422
|
|
- if (taCardNo == null) {
|
423
|
|
- return ResponseBean.error("卡号无效或者已使用");
|
424
|
|
- }
|
425
|
|
-
|
426
|
|
- // 将卡号置为已使用
|
427
|
|
- taCardNo.setStatus(Constants.STATUS_NORMAL);
|
428
|
|
- iTaCardNoService.updateById(taCardNo);
|
429
|
|
-
|
430
|
|
- TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", makeCardParam.getCardNo(), false, true);
|
431
|
|
- if (null != taPetIdentity) {
|
432
|
|
- return ResponseBean.error("卡号已被占用");
|
433
|
|
- }
|
434
|
|
- }
|
435
|
|
-
|
436
|
|
- // 关联证件
|
437
|
|
- taApplication.setOriginCardNo(makeCardParam.getCardNo());
|
438
|
520
|
taApplication.setMakeStatus(Constants.MAKE_STATUS_MADE);
|
439
|
521
|
taApplication.setMakeDate(LocalDateTime.now());
|
440
|
522
|
taApplication.setMakeUser(sysUser.getUserId());
|
|
@@ -443,10 +525,14 @@ public class TaApplicationController extends BaseController {
|
443
|
525
|
taApplication.setTrackingNo(makeCardParam.getTrackingNo());
|
444
|
526
|
taApplication.setStatus(Constants.WORKFLOW_STATUS_MADE);
|
445
|
527
|
|
446
|
|
- if (iTaApplicationService.updateById(taApplication)){
|
447
|
|
- TaPetIdentity newCard = iTaPetIdentityService.createNewCard(taApplication, makeCardParam);
|
|
528
|
+ TaPetIdentity taPetIdentity = iTaPetIdentityService.getExistBy("card_no", taApplication.getOriginCardNo(), false, true);
|
|
529
|
+ if (!taApplication.getApplyType().equals(Constants.APPLY_TYPE_REISSUE)) {
|
|
530
|
+ // 新办 续期,都需要重置有效期
|
|
531
|
+ iTaPetIdentityService.updateCardDate(taPetIdentity.getCardNo());
|
|
532
|
+ }
|
448
|
533
|
|
449
|
|
- return ResponseBean.success(newCard);
|
|
534
|
+ if (iTaApplicationService.updateById(taApplication)){
|
|
535
|
+ return ResponseBean.success(taApplication);
|
450
|
536
|
} else {
|
451
|
537
|
return ResponseBean.error("修改失败, 请重试", ResponseBean.ERROR_UNAVAILABLE);
|
452
|
538
|
}
|