liupeng 4 lat temu
rodzic
commit
5c68cbb2fe

+ 6 - 2
code/sapparent/sapservice/src/main/java/org/fouram/mapper/SapUserMapper.xml

@@ -37,7 +37,11 @@
 		update sap_user set avatar=#{avatar} where personId=#{personId}
 	</update>
 	
-	<update id="updateResult">
+	<update id="updateResultByUserId">
+		update sap_user set result=#{result} where userId=#{userId}
+	</update>
+	
+	<update id="updateResultByPersonId">
 		update sap_user set result=#{result} where personId=#{personId}
 	</update>
 	
@@ -101,7 +105,7 @@
 	
 	<select id="selectToBeConfirmedPrimaryList" resultType="SapUser">
 		select * from sap_user 
-		where isPrimary = 1 and delFlag = 0 and result in ('ENTRY','LEAVE','SENSITIVE')
+		where isPrimary = 1 and (delFlag = 0 or delFlag = 1) and result in ('ENTRY','LEAVE','SENSITIVE')
 		<if test="type != null and type != ''">
 			and result = #{type} 
 		</if>

+ 35 - 29
code/sapparent/sapservice/src/main/java/org/fouram/service/SapUserService.java

@@ -100,12 +100,36 @@ public class SapUserService extends BaseService {
 					this.updateSapUser(sapUser);
 				}
 			}
+
+			// 验证sap是否为垃圾数据
+			sapUserDb = this.selectByUserId(sapUser.getUserId());
+			String checkResult = checkUserGarbageOrBlacklist(sapUserDb);
+			if (StringUtils.isNotBlank(checkResult)) {
+				updateResultByUserId(checkResult, sapUserDb.getUserId());
+			}
 		}
 		// 更新所有无效数据为LEAVE
 		this.updateResultByDelFlag(SapUserResultEnum.LEAVE, DelFlagEnum.UNABLE);
 	}
 
 	/**
+	 * 判断是不是垃圾数据或者黑名单
+	 * 
+	 * @param sapUser
+	 * @return
+	 * @throws Exception
+	 */
+	public String checkUserGarbageOrBlacklist(SapUser sapUser) throws Exception {
+		if (Tools.isEmpty(sapUser.getPersonId()) || Tools.isEmpty(sapUser.getFirstOrgName())
+				|| WebConstants.INGORE_PERSONIDS.contains("," + sapUser.getPersonId() + ",")) {
+			return SapUserResultEnum.GARBAGE.getCode();
+		} else if (sapBlacklistService.findByUserId(sapUser.getPersonId()) != null) {
+			return SapUserResultEnum.BLACKLIST.getCode();
+		}
+		return null;
+	}
+
+	/**
 	 * 更新异常情况,敏感数据、入职
 	 * 
 	 * @throws Exception
@@ -116,8 +140,7 @@ public class SapUserService extends BaseService {
 		for (SapUser sapUser : normalList) {
 			resultEnum = checkSensitiveOrEntryData(sapUser);
 			if (resultEnum != null) {
-				sapUser.setResult(resultEnum.getCode());
-				this.updateResult(sapUser);
+				this.updateResultByPersonId(resultEnum.getCode(), sapUser.getPersonId());
 			}
 		}
 	}
@@ -166,8 +189,7 @@ public class SapUserService extends BaseService {
 
 	public void updateSyncWxResult(String personId) throws Exception {
 		String result = createOrUpdateWXUser(personId);
-		SapUser entity = SapUser.builder().personId(personId).result(result).build();
-		update("SapUserMapper.updateResult", entity);
+		updateResultByPersonId(result, personId);
 	}
 
 	private String createOrUpdateWXUser(String personId) throws Exception {
@@ -190,10 +212,6 @@ public class SapUserService extends BaseService {
 		Long[] fourthWxDepartIdList = new Long[sapUsers.size()];
 		for (int i = 0; i < sapUsers.size(); i++) {
 			SapUser sapUser = sapUsers.get(i);
-			String checkResult = checkSapUser(sapUser);
-			if (StringUtils.isNotBlank(checkResult)) {
-				return checkResult;
-			}
 			firstWxDepartIdList[i] = sapUser.getFirstWxDepartId();
 			secondWxDepartIdList[i] = sapUser.getSecondWxDepartId();
 			thirdWxDepartIdList[i] = sapUser.getThirdWxDepartId();
@@ -205,23 +223,6 @@ public class SapUserService extends BaseService {
 				primarySapUser.getFirstOrgName());
 	}
 
-	/**
-	 * 判断是不是垃圾数据或者黑名单
-	 * 
-	 * @param sapUser
-	 * @return
-	 * @throws Exception
-	 */
-	public String checkSapUser(SapUser sapUser) throws Exception {
-		if (Tools.isEmpty(sapUser.getPersonId()) || Tools.isEmpty(sapUser.getFirstOrgName())
-				|| WebConstants.INGORE_PERSONIDS.contains("," + sapUser.getPersonId() + ",")) {
-			return SapUserResultEnum.GARBAGE.getCode();
-		} else if (sapBlacklistService.findByUserId(sapUser.getPersonId()) != null) {
-			return SapUserResultEnum.BLACKLIST.getCode();
-		}
-		return null;
-	}
-
 	public SapUser selectByUserId(String userId) throws Exception {
 		return (SapUser) findObject("SapUserMapper.selectByUserId", userId);
 	}
@@ -330,9 +331,15 @@ public class SapUserService extends BaseService {
 			}
 		}
 	}
+	
+	public void updateResultByUserId(String result, String userId) throws Exception {
+		SapUser sapUser = SapUser.builder().userId(userId).result(result).build();
+		update("SapUserMapper.updateResultByUserId", sapUser);
+	}
 
-	public void updateResult(SapUser sapUser) throws Exception {
-		update("SapUserMapper.updateResult", sapUser);
+	public void updateResultByPersonId(String result, String personId) throws Exception {
+		SapUser sapUser = SapUser.builder().personId(personId).result(result).build();
+		update("SapUserMapper.updateResultByPersonId", sapUser);
 	}
 
 	public void deleteQuitUserByUserId(String userId, String oprUserId) throws Exception {
@@ -352,8 +359,7 @@ public class SapUserService extends BaseService {
 	}
 
 	public void updateIngore(String personId) throws Exception {
-		SapUser sapUser = SapUser.builder().personId(personId).result(SapUserResultEnum.INGORE.getCode()).build();
-		update("SapUserMapper.updateResult", sapUser);
+		updateResultByPersonId(SapUserResultEnum.INGORE.getCode(), personId);
 	}
 
 	public void updateAllNormalSyncWxResult() throws Exception {