From 8b375fe00a241b3a769b82fe3dac8d1c9dce8a02 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Thu, 16 Jun 2022 14:36:07 +0800
Subject: [PATCH] 模拟考试修改

---
 src/main/java/org/springblade/modules/equipage/controller/GunController.java |  110 +++++++++++++++++++++++++++++++++++-------------------
 1 files changed, 71 insertions(+), 39 deletions(-)

diff --git a/src/main/java/org/springblade/modules/equipage/controller/GunController.java b/src/main/java/org/springblade/modules/equipage/controller/GunController.java
index f3f428e..2d5dc02 100644
--- a/src/main/java/org/springblade/modules/equipage/controller/GunController.java
+++ b/src/main/java/org/springblade/modules/equipage/controller/GunController.java
@@ -12,6 +12,7 @@
 import org.springblade.core.mp.support.Condition;
 import org.springblade.core.mp.support.Query;
 import org.springblade.core.tool.api.R;
+import org.springblade.core.tool.utils.BeanUtil;
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.Func;
 import org.springblade.modules.FTP.FtpUtil;
@@ -20,6 +21,8 @@
 import org.springblade.modules.equipage.excel.GunImporter;
 import org.springblade.modules.equipage.service.GunService;
 import org.springblade.modules.equipage.vo.GunVo;
+import org.springblade.modules.member.entity.Member;
+import org.springblade.modules.system.service.MyAsyncService;
 import org.springframework.web.bind.annotation.*;
 import org.springframework.web.multipart.MultipartFile;
 
@@ -30,6 +33,7 @@
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @author zhongrj
@@ -42,11 +46,13 @@
 public class GunController {
 
 	private final GunService gunService;
+	private final MyAsyncService myAsyncService;
 
 	/**
 	 * 自定义分页
+	 *
 	 * @param query page,size
-	 * @param gun 枪支信息对象
+	 * @param gun   枪支信息对象
 	 */
 	@GetMapping("/page")
 	public R<IPage<GunVo>> page(GunVo gun, Query query) {
@@ -56,6 +62,7 @@
 
 	/**
 	 * 新增
+	 *
 	 * @param gun 枪支信息对象
 	 */
 	@PostMapping("/save")
@@ -66,6 +73,7 @@
 
 	/**
 	 * 修改
+	 *
 	 * @param gun 枪支信息对象
 	 */
 	@PostMapping("/update")
@@ -75,68 +83,92 @@
 
 	/**
 	 * 新增或修改
+	 *
 	 * @param gun 枪支信息对象
 	 */
 	@PostMapping("/submit")
-	public R submit(@RequestBody Gun gun){
+	public R submit(@RequestBody Gun gun) {
 		boolean status = false;
-		if (null==gun.getId()) {
+		//脱敏处理
+		Gun gun1 = Objects.requireNonNull(BeanUtil.copy(gun, Gun.class));
+		gun1.setCardNumber("***");
+		gun1.setIssueTime(null);
+		gun1.setValidTime(null);
+		if (null!=gun1.getIssueUnit() && !gun1.getIssueUnit().equals("")){
+			gun1.setIssueUnit("***");
+		}
+		if (null!=gun1.getGunMode() && !gun1.getGunMode().equals("")){
+			gun1.setGunMode("***");
+		}
+		if (null!=gun1.getPersonInCharge() && !gun1.getPersonInCharge().equals("")){
+			gun1.setPersonInCharge("***");
+		}
+		if (null!=gun1.getCardNo() && !gun1.getCardNo().equals("")){
+			gun1.setCardNo("***");
+		}
+		gun1.setValidTime(null);
+		if (null == gun.getId()) {
 			//新增
-			status = gunService.save(gun);
-
-			//数据同步
-			String s1 =
-				"insert into sys_gun(id,issue_unit,card_number,gun_mode," +
-					"dept_id,person_in_charge,issue_time,valid_time,jurisdiction,card_no) " +
-					"values(" + "'" + gun.getId() + "'" + "," +
-					"'" + gun.getIssueUnit() + "'" + "," +
-					"'" + gun.getCardNumber() + "'" + "," +
-					"'" + gun.getGunMode() + "'" + "," +
-					"'" + gun.getDeptId() + "'" + "," +
-					"'" + gun.getPersonInCharge() + "'" + "," +
-					"'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" + "," +
-					"'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" + "," +
-					"'" +gun.getCardNo() + "'" + "," +
-					"'" +gun.getJurisdiction() + "'" + ")";
-			FtpUtil.sqlFileUpload(s1);
-		}else {
+			status = gunService.save(gun1);
+			if (status) {
+				//数据同步
+				String s1 =
+					"insert into sys_gun(id,issue_unit,card_number,gun_mode," +
+						"dept_id,person_in_charge,issue_time,valid_time,jurisdiction,card_no) " +
+						"values(" + "'" + gun1.getId() + "'" + "," +
+						"'" + gun.getIssueUnit() + "'" + "," +
+						"'" + gun.getCardNumber() + "'" + "," +
+						"'" + gun.getGunMode() + "'" + "," +
+						"'" + gun.getDeptId() + "'" + "," +
+						"'" + gun.getPersonInCharge() + "'" + "," +
+						"'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" + "," +
+						"'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" + "," +
+						"'" + gun.getCardNo() + "'" + "," +
+						"'" + gun.getJurisdiction() + "'" + ")";
+				myAsyncService.FTP(s1);
+			}
+		} else {
 			//修改
-			status = gunService.updateById(gun);
-			//内网同步
-			String s1 =
-				"update sys_gun set issue_unit = " + "'" + gun.getIssueUnit() + "'" +
-					",card_number = " + "'" + gun.getCardNumber() + "'" +
-					",gun_mode = " + "'" + gun.getGunMode() + "'" +
-					",dept_id = " + "'" + gun.getDeptId() + "'" +
-					",person_in_charge = " + "'" + gun.getJurisdiction() + "'" +
-					",issue_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" +
-					",valid_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" +
-					",jurisdiction = " + "'" + gun.getJurisdiction() + "'" +
-					",card_no = " + "'" + gun.getCardNo() + "'" +
-					" " +"where id = " + "'" + gun.getId() + "'";
-			FtpUtil.sqlFileUpload(s1);
+			status = gunService.updateById(gun1);
+			if (status) {
+				//内网同步
+				String s1 =
+					"update sys_gun set issue_unit = " + "'" + gun.getIssueUnit() + "'" +
+						",card_number = " + "'" + gun.getCardNumber() + "'" +
+						",gun_mode = " + "'" + gun.getGunMode() + "'" +
+						",dept_id = " + "'" + gun.getDeptId() + "'" +
+						",person_in_charge = " + "'" + gun.getJurisdiction() + "'" +
+						",issue_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getIssueTime()) + "'" +
+						",valid_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd").format(gun.getValidTime()) + "'" +
+						",jurisdiction = " + "'" + gun.getJurisdiction() + "'" +
+						",card_no = " + "'" + gun.getCardNo() + "'" +
+						" " + "where id = " + "'" + gun.getId() + "'";
+				myAsyncService.FTP(s1);
+			}
 		}
 		return R.status(status);
 	}
 
 	/**
 	 * 删除
+	 *
 	 * @param ids 枪支信息ids 数组
 	 */
 	@PostMapping("/remove")
 	public R remove(@ApiParam(value = "主键集合") @RequestParam String ids) {
 		//内网删除
 		List<Long> list = Func.toLongList(ids);
-		list.forEach(id ->{
+		list.forEach(id -> {
 			//内网同步
 			String s1 = "delete from sys_gun where id = " + "'" + id + "'";
-			FtpUtil.sqlFileUpload(s1);
+			myAsyncService.FTP(s1);
 		});
 		return R.status(gunService.removeByIds(Func.toLongList(ids)));
 	}
 
 	/**
 	 * 详情
+	 *
 	 * @param gun 枪支信息对象
 	 */
 	@GetMapping("/detail")
@@ -152,7 +184,7 @@
 	 */
 	@PostMapping("import-gun")
 	public R importGun(MultipartFile file, Integer isCovered, String deptId) {
-		GunImporter gunImporter = new GunImporter(gunService, false,deptId);
+		GunImporter gunImporter = new GunImporter(gunService, false, deptId);
 		ExcelUtil.save(file, gunImporter, GunExcel.class);
 		return R.success("操作成功");
 	}
@@ -176,7 +208,7 @@
 		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());
+			fileName = URLEncoder.encode("枪支导入数据模板" + DateUtil.time(), Charsets.UTF_8.name());
 			response.setHeader("Content-disposition", "attachment;filename=" + fileName + ".xlsx");
 			//修改单元格格式为文本格式
 			EasyExcel.write(response.getOutputStream(), GunExcel.class).sheet("枪支数据表").registerWriteHandler(new RowWriteHandler()).doWrite(list);

--
Gitblit v1.9.3