Commit b4bfa3f9 by 墨竹

refactor:增加redis锁

parent 6d569a98
......@@ -38,6 +38,7 @@ import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.stream.Collectors;
@Service
......@@ -314,12 +315,20 @@ public class ExternalClerkRelatedApiServiceImpl implements ExternalClerkRelatedA
log.info("企业外部联系人id为空");
return false;
}
String lockKey = "updateNewExternalUserid_" + wxEnterpriseId;
if (RedisUtil.isLocked(lockKey)) {
log.info("redis锁,lockKey:{}",lockKey);
return false;
}
RedisUtil.lock(lockKey,1L,TimeUnit.DAYS,0L);
try {
updateNewExUserId(tabHaobanWxEnterprise.getWxEnterpriseId(), tabHaobanWxEnterprise.getCorpid());
log.info("企业外部联系人id end,wxEnterpriseId:{}", wxEnterpriseId);
RedisUtil.unlock(lockKey);
return true;
} catch (Exception e) {
log.info("企业外部联系人id异常,wxEnterpriseId:{},{}", wxEnterpriseId, e.getMessage(), e);
RedisUtil.unlock(lockKey);
return false;
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment