From 12846820dd7f40a3dee88000d55701ffa220010c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=8F=8D=E7=BC=96=E8=AF=91=E5=B7=A5=E4=BD=9C=E5=8C=BA?= Date: Tue, 5 May 2026 23:49:16 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20P1=20partial=20=E2=80=94=20CpImageStoreP?= =?UTF-8?q?ersonSynManager=2038=E2=86=9210?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Fixed: - RedisCallback cast on 6 execute() calls - Set cast to Set in checkHandleSynTaskException (4 locations) - Removed (Object) from hasKey call - Fixed Lists.newArrayList((Object[])new String[]{x}) → Lists.newArrayList(x) (2 locations) - Added RedisCallback import Remaining: 10 errors — lambda effectively-final violations (Java 8) --- .../service/CpImageStorePersonSynManager.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/maven-ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/CpImageStorePersonSynManager.java b/maven-ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/CpImageStorePersonSynManager.java index 0b73952f..a69e3ddf 100644 --- a/maven-ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/CpImageStorePersonSynManager.java +++ b/maven-ninca-common-component-organization/cwos-component-organization-service/src/main/java/cn/cloudwalk/service/organization/service/CpImageStorePersonSynManager.java @@ -31,6 +31,7 @@ import java.util.List; import java.util.Map; import java.util.Set; import java.util.stream.Collectors; +import org.springframework.data.redis.core.RedisCallback; import javax.annotation.PostConstruct; import javax.annotation.Resource; import org.apache.commons.lang3.StringUtils; @@ -229,7 +230,7 @@ extends AbstractImagStoreService { try { this.logger.info("CpImageStorePersonSynManager handleGroupPersonSynTask lockHandleSynTaskRes : 加锁消费图库{}成功", (Object)imageStoreId); String synQueueHeadDataKey = SYN_QUEUE_HEAD_DATA + imageStoreId; - if (this.redisTemplate.hasKey((Object)synQueueHeadDataKey).booleanValue()) { + if (this.redisTemplate.hasKey(synQueueHeadDataKey).booleanValue()) { this.logger.warn("CpImageStorePersonSynManager handleGroupPersonSynTask synQueueHeadDataKey : 已存在同步任务队首数据{}", (Object)synQueueHeadDataKey); this.groupPersonSyn(imageStoreId, synQueueHeadDataKey); } else { @@ -414,10 +415,10 @@ extends AbstractImagStoreService { ImgStorePerson personExpiryDate; List associatedPersonExpiryDateAfterUpdate; this.logger.info("CpImageStorePersonSynManager handleImageStoreIncrementSyn 单人员更新注册照:{},{}", (Object)synData.getPersonId(), (Object)synData.getOldImageId()); - Map associatedPersonResultsAfterUpdate2 = this.cpImageStorePersonManager.getGroupPersonRefByPersons(waitSyncImageStore.getId(), Lists.newArrayList((Object[])new String[]{synData.getPersonId()})); - Map associatedPersonResultsBeforeUpdate = this.cpImageStorePersonManager.getOldAssociatedPersonIds(waitSyncImageStore.getId(), Lists.newArrayList((Object[])new String[]{synData.getPersonId()})); + Map associatedPersonResultsAfterUpdate2 = this.cpImageStorePersonManager.getGroupPersonRefByPersons(waitSyncImageStore.getId(), Lists.newArrayList(synData.getPersonId())); + Map associatedPersonResultsBeforeUpdate = this.cpImageStorePersonManager.getOldAssociatedPersonIds(waitSyncImageStore.getId(), Lists.newArrayList(synData.getPersonId())); GroupPersonRef refAfterUpdate = associatedPersonResultsAfterUpdate2.get(synData.getPersonId()); - if (refAfterUpdate != null && CollectionUtil.isNotEmpty((Collection)(associatedPersonExpiryDateAfterUpdate = this.imgStorePersonMapper.selectExpiryDateByIds((List)Lists.newArrayList((Object[])new String[]{synData.getPersonId()})))) && ((personExpiryDate = (ImgStorePerson)associatedPersonExpiryDateAfterUpdate.get(0)).getExpiryBeginDate() != null || personExpiryDate.getExpiryEndDate() != null)) { + if (refAfterUpdate != null && CollectionUtil.isNotEmpty((Collection)(associatedPersonExpiryDateAfterUpdate = this.imgStorePersonMapper.selectExpiryDateByIds((List)Lists.newArrayList(synData.getPersonId())))) && ((personExpiryDate = (ImgStorePerson)associatedPersonExpiryDateAfterUpdate.get(0)).getExpiryBeginDate() != null || personExpiryDate.getExpiryEndDate() != null)) { refAfterUpdate.setExpiryBeginDate(personExpiryDate.getExpiryBeginDate()); refAfterUpdate.setExpiryEndDate(personExpiryDate.getExpiryEndDate()); refAfterUpdate.setStatus(Short.valueOf(this.checkGroupPersonStatus(personExpiryDate.getExpiryBeginDate(), personExpiryDate.getExpiryEndDate()))); @@ -461,45 +462,45 @@ extends AbstractImagStoreService { public Long addWaitSynTask(String imageStoreId, String jsonData) { this.logger.info("addWaitSynTask - 图库待同步任务队列队尾新增任务 imageStoreId:{}; jsonData: {}", (Object)imageStoreId, (Object)jsonData); - return (Long)this.redisTemplate.execute(connection -> (Long)connection.eval(this.addWaitSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), jsonData.getBytes()})); + return (Long)this.redisTemplate.execute((RedisCallback) connection -> (Long)connection.eval(this.addWaitSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), jsonData.getBytes()})); } public Long lockHandleSynTask(String imageStoreId) { - return (Long)this.redisTemplate.execute(connection -> (Long)connection.eval(this.lockHandleSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), this.serverInstanceId.getBytes(), this.lockHandleSynTaskSecond.getBytes()})); + return (Long)this.redisTemplate.execute((RedisCallback) connection -> (Long)connection.eval(this.lockHandleSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), this.serverInstanceId.getBytes(), this.lockHandleSynTaskSecond.getBytes()})); } public Long lockHeadSynTask(String imageStoreId) { - return (Long)this.redisTemplate.execute(connection -> (Long)connection.eval(this.lockHeadSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 1, (byte[][])new byte[][]{imageStoreId.getBytes(), imageStoreId.getBytes(), this.serverInstanceId.getBytes(), String.valueOf(this.taskIsAllThreshold).getBytes()})); + return (Long)this.redisTemplate.execute((RedisCallback) connection -> (Long)connection.eval(this.lockHeadSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 1, (byte[][])new byte[][]{imageStoreId.getBytes(), imageStoreId.getBytes(), this.serverInstanceId.getBytes(), String.valueOf(this.taskIsAllThreshold).getBytes()})); } public Long handleSuccessSynTask(String imageStoreId) { - return (Long)this.redisTemplate.execute(connection -> (Long)connection.eval(this.handleSuccessSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), this.serverInstanceId.getBytes()})); + return (Long)this.redisTemplate.execute((RedisCallback) connection -> (Long)connection.eval(this.handleSuccessSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), this.serverInstanceId.getBytes()})); } public Long handleFailSynTask(String imageStoreId) { - return (Long)this.redisTemplate.execute(connection -> (Long)connection.eval(this.handleFailSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), this.serverInstanceId.getBytes()})); + return (Long)this.redisTemplate.execute((RedisCallback) connection -> (Long)connection.eval(this.handleFailSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.INTEGER, 0, (byte[][])new byte[][]{imageStoreId.getBytes(), this.serverInstanceId.getBytes()})); } public void refreshHandleSynTaskLockExpireTime() { - byte[] res = (byte[])this.redisTemplate.execute(connection -> (byte[])connection.eval(this.refreshHandleSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.VALUE, 0, (byte[][])new byte[][]{this.serverInstanceId.getBytes(), this.lockHandleSynTaskSecond.getBytes()})); + byte[] res = (byte[])this.redisTemplate.execute((RedisCallback) connection -> (byte[])connection.eval(this.refreshHandleSynTaskRedisScript.getScriptAsString().getBytes(), ReturnType.VALUE, 0, (byte[][])new byte[][]{this.serverInstanceId.getBytes(), this.lockHandleSynTaskSecond.getBytes()})); this.logger.info("CpImageStorePersonSynManager refreshHandleSynTaskLockExpireTime : {}", (Object)new String(res)); } public void checkHandleSynTaskException() { - Set synQueueHeadDataKeys = (java.lang.String) this.redisTemplate.keys((Object)"group_person_syn_queue_head_data:*"); + Set synQueueHeadDataKeys = this.redisTemplate.keys("group_person_syn_queue_head_data:*"); synQueueHeadDataKeys.forEach(synQueueHeadDataKey -> { String imageStoreId = synQueueHeadDataKey.replaceFirst(SYN_QUEUE_HEAD_DATA, ""); - Set lockKeys = (java.lang.String) this.redisTemplate.keys((Object)(imageStoreId + ":*")); + Set lockKeys = this.redisTemplate.keys(imageStoreId + ":*"); if (Collections3.isEmpty((Collection)lockKeys)) { this.logger.info("CpImageStorePersonSynManager checkHandleSynTaskException 消费加锁"); this.handleFailSynTask(imageStoreId); this.handleGroupPersonSynTask(imageStoreId); } }); - Set waitSynTaskKeys = (java.lang.String) this.redisTemplate.keys((Object)"group_person_wait_syn_task:*"); + Set waitSynTaskKeys = this.redisTemplate.keys("group_person_wait_syn_task:*"); waitSynTaskKeys.forEach(waitSynTaskKey -> { String imageStoreId = waitSynTaskKey.replaceFirst(WAIT_SYN_TASK_KEY, ""); - Set lockKeys = (java.lang.String) this.redisTemplate.keys((Object)(imageStoreId + ":*")); + Set lockKeys = this.redisTemplate.keys(imageStoreId + ":*"); if (Collections3.isEmpty((Collection)lockKeys)) { this.logger.info("CpImageStorePersonSynManager checkHandleSynTaskException 未消费"); this.handleFailSynTask(imageStoreId);