From ff8b904fd730846fadd76fb94c7b9cbde4e134b3 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Mon, 27 Dec 2021 13:34:52 +0800
Subject: [PATCH] 上岗证已制证修改

---
 src/main/java/org/springblade/modules/accreditation/service/impl/AccreditationRecordsServiceImpl.java |   85 ++++++++++++++++++++++++++++++++++++------
 1 files changed, 72 insertions(+), 13 deletions(-)

diff --git a/src/main/java/org/springblade/modules/accreditation/service/impl/AccreditationRecordsServiceImpl.java b/src/main/java/org/springblade/modules/accreditation/service/impl/AccreditationRecordsServiceImpl.java
index 3d19de5..c763ebb 100644
--- a/src/main/java/org/springblade/modules/accreditation/service/impl/AccreditationRecordsServiceImpl.java
+++ b/src/main/java/org/springblade/modules/accreditation/service/impl/AccreditationRecordsServiceImpl.java
@@ -61,19 +61,47 @@
 			records.setAuditStatus(1);
 			records.setType(accreditationRecords.getType());
 			records.setUserId(Long.parseLong(id));
-			//新增
-			this.save(records);
+			//判断类型,如果是上岗证则判断是否有申请,有申请的不在新增记录
+			if (accreditationRecords.getType()==1){
+				//查询当前人员是否有申请记录
+				int count  = baseMapper.getAccreditationRecordsByUserIdCount(id);
+				if (count<1){
+					//新增
+					this.save(records);
 
-			//内网新增
-			String s = "insert into sys_accreditation_records(id,user_id,create_time,create_user,status,type,audit_status) " +
-				"values(" + "'" + records.getId() + "'" + ","
-				+ "'" + records.getUserId() + "'" + ","
-				+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(records.getCreateTime()) + "'" + ","
-				+ "'" + records.getCreateUser() +"'" + ","
-				+ "'" + records.getStatus() +"'" + ","
-				+ "'" + records.getType() +"'" + ","
-				+"'" + records.getAuditStatus() + "'" + ")";
-			FtpUtil.sqlFileUpload(s);
+					//内网新增
+					String s = "insert into sys_accreditation_records(id,user_id,create_time,create_user,status,type,audit_status) " +
+						"values(" + "'" + records.getId() + "'" + ","
+						+ "'" + records.getUserId() + "'" + ","
+						+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(records.getCreateTime()) + "'" + ","
+						+ "'" + records.getCreateUser() +"'" + ","
+						+ "'" + records.getStatus() +"'" + ","
+						+ "'" + records.getType() +"'" + ","
+						+"'" + records.getAuditStatus() + "'" + ")";
+					FtpUtil.sqlFileUpload(s);
+				}
+			}
+			//判断类型,如果是证书的,审核未通过的可以再次申请,审核通过的,暂时不给于新增记录
+			if (accreditationRecords.getType()==2){
+				//查询当前人员是否有待审核和审核通过的记录数
+				int count  = baseMapper.getAccreditationRecordsByUserIdAuditCount(id,2);
+				if (count<1){
+					//新增
+					this.save(records);
+
+					//内网新增
+					String s = "insert into sys_accreditation_records(id,user_id,create_time,create_user,status,type,audit_status) " +
+						"values(" + "'" + records.getId() + "'" + ","
+						+ "'" + records.getUserId() + "'" + ","
+						+ "'" + new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(records.getCreateTime()) + "'" + ","
+						+ "'" + records.getCreateUser() +"'" + ","
+						+ "'" + records.getStatus() +"'" + ","
+						+ "'" + records.getType() +"'" + ","
+						+"'" + records.getAuditStatus() + "'" + ")";
+					FtpUtil.sqlFileUpload(s);
+				}
+			}
+
 		});
 		return true;
 	}
@@ -107,6 +135,12 @@
 				excel.setRealName(accreditationRecordsVo.getRealName());
 				excel.setIdCardNo(accreditationRecordsVo.getIdCardNo());
 				excel.setDeptName(accreditationRecordsVo.getDeptName());
+				if (accreditationRecordsVo.getSex().equals("1")){
+					excel.setSex("男");
+				}else {
+					excel.setSex("女");
+				}
+				excel.setPaperTime(new SimpleDateFormat("yyyy-MM-dd").format(new Date()));
 				//如果头像有
 				if (null != accreditationRecordsVo.getAvatar() && accreditationRecordsVo.getAvatar() != "") {
 					try {
@@ -160,7 +194,32 @@
 	public List<AccreditationRecordsVo> exportSecurityBookPapers(AccreditationRecordsVo accreditationRecords) {
 		//查询数据
 		List<AccreditationRecordsVo> accreditationRecordsVos = baseMapper.exportSecurityBookPapers(accreditationRecords);
-		System.out.println("accreditationRecordsVos = " + accreditationRecordsVos.size());
+//		System.out.println("accreditationRecordsVos = " + accreditationRecordsVos.size());
 		return accreditationRecordsVos;
 	}
+
+	/**
+	 * 批量修改为已制证
+	 * @param accreditationRecords 制证记录信息对象
+	 */
+	@Override
+	public boolean batchAccreditation(AccreditationRecordsVo accreditationRecords) {
+		//读取ids
+		List<String> list = Arrays.asList(accreditationRecords.getIds().split(","));
+		//遍历
+		list.forEach(id->{
+			AccreditationRecords records = new AccreditationRecords();
+			records.setStatus(2);
+			records.setId(Long.parseLong(id));
+			//更新
+			this.updateById(records);
+
+			//内网同步
+			String s =
+				"update sys_accreditation_records set status = " + accreditationRecords.getStatus() + "" +
+					"where id = " + "'" + accreditationRecords.getId() + "'";
+			FtpUtil.sqlFileUpload(s);
+		});
+		return true;
+	}
 }

--
Gitblit v1.9.3