From 7b291d619aa70e5bb33f2b1caabe7f4b0bd003d9 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Fri, 10 Jun 2022 17:28:15 +0800
Subject: [PATCH] 制证数据更新

---
 src/main/java/org/springblade/modules/system/controller/UserController.java |  104 ++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 100 insertions(+), 4 deletions(-)

diff --git a/src/main/java/org/springblade/modules/system/controller/UserController.java b/src/main/java/org/springblade/modules/system/controller/UserController.java
index 455691d..93125ae 100644
--- a/src/main/java/org/springblade/modules/system/controller/UserController.java
+++ b/src/main/java/org/springblade/modules/system/controller/UserController.java
@@ -42,6 +42,9 @@
 import org.springblade.core.tool.constant.RoleConstant;
 import org.springblade.core.tool.utils.DateUtil;
 import org.springblade.core.tool.utils.StringPool;
+import org.springblade.modules.FTP.MyAsyncService;
+import org.springblade.modules.accreditation.entity.AccreditationRecords;
+import org.springblade.modules.accreditation.service.AccreditationRecordsService;
 import org.springblade.modules.system.entity.User;
 import org.springblade.modules.system.excel.SecurityExcel;
 import org.springblade.modules.system.excel.UserExcel;
@@ -55,9 +58,9 @@
 
 import javax.servlet.http.HttpServletResponse;
 import javax.validation.Valid;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Map;
+import java.text.SimpleDateFormat;
+import java.util.*;
+import java.util.stream.Collectors;
 
 import static org.springblade.core.cache.constant.CacheConstant.USER_CACHE;
 
@@ -74,6 +77,12 @@
 public class UserController {
 
 	private final IUserService userService;
+
+
+	private final MyAsyncService myAsyncService;
+
+
+	private final AccreditationRecordsService accreditationRecordsService;
 
 	/**
 	 * 查询单条
@@ -140,7 +149,7 @@
 		@ApiImplicitParam(name = "account", value = "账号名", paramType = "query", dataType = "string"),
 		@ApiImplicitParam(name = "realName", value = "姓名", paramType = "query", dataType = "string")
 	})
-	public R<IPage<UserVO>> pages(@ApiIgnore User user, Query query) {
+	public R<IPage<UserVO>> pages(@ApiIgnore UserVO user, Query query) {
 		IPage<User> pages = userService.selectUserPages(Condition.getPage(query), user);
 		return R.data(UserWrapper.build().pageVO(pages));
 	}
@@ -190,6 +199,15 @@
 	public R update(@Valid @RequestBody User user) {
 		CacheUtil.clear(USER_CACHE);
 		return R.status(userService.updateUser(user));
+	}
+
+	/**
+	 * 修改用户信息
+	 */
+	@PostMapping("/updateUser")
+	public R updateUser(@Valid @RequestBody User user) {
+		user.setUpdateTime(new Date());
+		return R.status(userService.updateById(user));
 	}
 
 	/**
@@ -372,5 +390,83 @@
 		return R.success("吊销成功");
 	}
 
+	/**
+	 * 查询押运人员
+	 *
+	 * @return
+	 */
+	@GetMapping("/selectPeo")
+	public R selectPeo(@ApiIgnore UserVO user) {
+		List list = userService.selectPeo(user);
+		return R.data(list);
+	}
+
+	/**
+	 * 查询保安员信息
+	 * @param user
+	 * @return
+	 */
+	@GetMapping("/getSecurityInfoByIdCardNo")
+	public R getSecurityInfoByIdCardNo(User user){
+		return R.data(userService.getSecurityInfoByIdCardNo(user));
+	}
+
+
+	/**
+	 * 修改发证时间
+	 */
+	@PostMapping("/updatePaperTime")
+	public R updatePaperTime(@RequestBody User user) {
+		user.setPaperTime(new Date());
+		user.setUpdateTime(new Date());
+		userService.updateById(user);
+		String paperTime = null;
+		//发证日期处理
+		if (user.getPaperTime() == null) {
+			paperTime = null;
+		} else {
+			paperTime = new SimpleDateFormat("yyyy-MM-dd").format(user.getPaperTime());
+		}
+		//更新制证记录制证状态
+		AccreditationRecords accreditationRecords = new AccreditationRecords();
+		accreditationRecords.setUserId(user.getId());
+		//审核通过的
+		accreditationRecords.setAuditStatus(2);
+		//未制证的记录
+		accreditationRecords.setStatus(1);
+		//查询
+		List<AccreditationRecords> list = accreditationRecordsService.list(Condition.getQueryWrapper(accreditationRecords));
+		if (list.size() > 0) {
+			//排序
+			List<AccreditationRecords> collect = list.stream().sorted(Comparator.comparing(AccreditationRecords::getId).reversed()).collect(Collectors.toList());
+			//取出第一个
+			AccreditationRecords accreditationRecords1 = collect.get(0);
+			//修改为已制证状态
+			accreditationRecords1.setStatus(2);
+			//记录打印时间
+			accreditationRecords1.setPaperTime(new Date());
+			//更新
+			accreditationRecordsService.updateById(accreditationRecords1);
+			//同步
+			String s1 =
+				"update blade_user set paper_time = " + "'" + paperTime + "'"
+					+ ",user_type = " + "'" + user.getUserType() + "'"
+					+ ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'"
+					+ " " + "where id = " + "'" + user.getId() + "';" +
+				"update sys_accreditation_records set status = " + "'" + accreditationRecords1.getStatus() + "'" +
+					" " + "where id = " + "'" + accreditationRecords1.getId() + "'";
+			myAsyncService.FTP(s1);
+			//返回
+			return R.success("修改成功");
+		}
+
+		String s1 =
+			"update blade_user set paper_time = " + "'" + paperTime + "'"
+				+ ",user_type = " + "'" + user.getUserType() + "'"
+				+ ",update_time = " + "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(user.getUpdateTime()) + "'"
+				+ " " + "where id = " + "'" + user.getId() + "'";
+		myAsyncService.FTP(s1);
+		return R.success("修改成功");
+	}
 
 }

--
Gitblit v1.9.3