From 8782a61b92d8dc1f8d3fd7d16a517fa934ac7e96 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 15 Nov 2021 20:59:33 +0800
Subject: [PATCH] 枪支,车辆批量导入,制证申请修改,审核通过状态修改为未制证

---
 src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java |  104 ++++++++++++++++++++++++++++++++++++++++++++--------
 1 files changed, 88 insertions(+), 16 deletions(-)

diff --git a/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java b/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
index c1ca392..4900cc0 100644
--- a/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
+++ b/src/main/java/org/springblade/modules/accreditation/controller/AccreditationRecordsController.java
@@ -12,7 +12,9 @@
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.FTP.FtpUtil;
+import org.springblade.modules.accreditation.excel.ExportSecurityBookPaperExcel;
 import org.springblade.modules.accreditation.excel.ExportSecurityPaperExcel;
+import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.service.IUserService;
 import org.springblade.modules.accreditation.entity.AccreditationRecords;
 import org.springblade.modules.accreditation.service.AccreditationRecordsService;
@@ -81,15 +83,39 @@
 	@PostMapping("/audit")
 	public R audit(@RequestBody AccreditationRecords accreditationRecords){
 		accreditationRecords.setAuditTime(new Date());
+
 		boolean b = accreditationRecordsService.updateById(accreditationRecords);
-		//内网同步
-		String s =
-			"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
-				",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
-				",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
-				",audit_user = " + accreditationRecords.getAuditUser() + " " +
-				"where id = " + "'" + accreditationRecords.getId() + "'";
-		FtpUtil.sqlFileUpload(s);
+		//审核通过
+		if (accreditationRecords.getAuditStatus()==2){
+			//修改为未制证状态
+			AccreditationRecords records = accreditationRecordsService.getById(accreditationRecords);
+			User user = userService.getById(records.getUserId());
+			user.setUserType(7);
+			user.setUpdateTime(new Date());
+			//更新
+			userService.updateById(user);
+
+			//内网同步
+			String s =
+				"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+					",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+					",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+					",audit_user = " + accreditationRecords.getAuditUser() + " " +
+					"where id = " + "'" + accreditationRecords.getId() + "';" +
+				"update blade_user set user_type = " + user.getUserType() + "" +
+					",update_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "" +
+					"where id = " + "'" + user.getId() + "'";
+			FtpUtil.sqlFileUpload(s);
+		}else {
+			//内网同步
+			String s =
+				"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+					",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+					",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+					",audit_user = " + accreditationRecords.getAuditUser() + " " +
+					"where id = " + "'" + accreditationRecords.getId() + "'";
+			FtpUtil.sqlFileUpload(s);
+		}
 		//返回
 		return R.status(b);
 	}
@@ -109,14 +135,37 @@
 			accreditationRecords.setId(Long.parseLong(id));
 			accreditationRecords.setAuditTime(new Date());
 			accreditationRecordsService.updateById(accreditationRecords);
-			//内网同步
-			String s =
-				"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
-					",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
-					",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
-					",audit_user = " + accreditationRecords.getAuditUser() + " " +
-					"where id = " + "'" + accreditationRecords.getId() + "'";
-			FtpUtil.sqlFileUpload(s);
+			//审核通过
+			if (accreditationRecords.getAuditStatus()==2){
+				//修改为未制证状态
+				AccreditationRecords records = accreditationRecordsService.getById(id);
+				User user = userService.getById(records.getUserId());
+				user.setUserType(7);
+				user.setUpdateTime(new Date());
+				//更新
+				userService.updateById(user);
+
+				//内网同步
+				String s =
+					"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+						",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+						",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+						",audit_user = " + accreditationRecords.getAuditUser() + " " +
+						"where id = " + "'" + accreditationRecords.getId() + "';" +
+					"update blade_user set user_type = " + user.getUserType() + "" +
+						",update_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "" +
+						"where id = " + "'" + user.getId() + "'";
+				FtpUtil.sqlFileUpload(s);
+			}else {
+				//内网同步
+				String s =
+					"update sys_accreditation_records set audit_status = " + accreditationRecords.getAuditStatus() + "" +
+						",audit_detail = " + accreditationRecords.getAuditDetail() + "" +
+						",audit_time = " + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(accreditationRecords.getAuditTime()) + "" +
+						",audit_user = " + accreditationRecords.getAuditUser() + " " +
+						"where id = " + "'" + accreditationRecords.getId() + "'";
+				FtpUtil.sqlFileUpload(s);
+			}
 		});
 		//返回
 		return R.status(true);
@@ -202,4 +251,27 @@
 	}
 
 
+	/**
+	 * 导出证书制证信息
+	 */
+	@GetMapping("export-security-book-paper")
+	public void exportSecurityBookPaper(AccreditationRecordsVo accreditationRecords, HttpServletResponse response) throws IOException {
+		//按条件查询成绩数据
+		List<ExportSecurityBookPaperExcel> excels = accreditationRecordsService.exportSecurityBookPaper(accreditationRecords);
+		String fileName = null;
+		try {
+			response.setContentType("application/vnd.ms-excel");
+			response.setCharacterEncoding(org.apache.commons.codec.Charsets.UTF_8.name());
+			fileName = URLEncoder.encode("证书制证数据"+ DateUtil.time(), Charsets.UTF_8.name());
+			response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
+			//修改单元格格式为文本格式
+			EasyExcel.write(response.getOutputStream(), ExportSecurityBookPaperExcel.class)
+				.sheet("证书制证数据表")
+				.doWrite(excels);
+		} catch (Throwable var6) {
+			throw var6;
+		}
+	}
+
+
 }

--
Gitblit v1.9.3