Time:01-22
CodePudding user response:
didn't do a null value judgment, have the attribute is null,
public void the receive (UserAudioProgress audioProgress) {The log. The debug (" received audio process message: "+ audioProgress); //1. Statistics update play amount String playKey=CommonConstants. CacheKey. REDIS_COUNT_AUDIO_PLAY + audioProgress. GetBizId () + ":" + audioProgress. GetCreateUserId (); /* * if the user does not have played today the audio, then store the key, and set the expiry time for 23:59:59 today, and returns null, update the playback volume if there is a value that has been statistics stored value must be of type string, or it will go wrong */String playVal=redisService. GetAndSet (playKey, "1", DateUtil endOfDay (new Date ())); If (StrUtil isBlank (playVal)) {//play amount + 1 AudioInfoService. UpdatePlayNum (audioProgress getBizId ()); } //2. Keep learning progress //query whether the existing users watch the progress of the audio QueryWrapper 've=new QueryWrapper<> (a); 've. Eq (" BIZ_ID ", audioProgress getBizId ()); 've. Eq (" CREATE_USER_ID, "audioProgress getCreateUserId ()); UserAudioProgress oldEntity=userAudioProgressService. GetOne ('ve); Boolean notNull=ObjectUtil. IsNotNull (oldEntity); Boolean hasNewProgress=true;//there is new progress If (notNull) {/* * if the schedule has been in existence, judge progress size, progress is greater than the saved data to continue to insert audio progress, prevent due to server hang up before was not consumed or other network information pollution data, at the same time also can ensure that data idempotence */OldEntity. SetPreEndTime (audioProgress getPreEndTime ()); OldEntity. SetModifyUserId (audioProgress getCreateUserId ()); OldEntity. SetModifyDate (new Date ()); HasNewProgress=audioProgress. GetTotalTime () & gt; OldEntity. GetTotalTime (); If (hasNewProgress) {OldEntity. SetTotalTime (audioProgress getTotalTime ()); OldEntity. SetProgress (audioProgress getProgress ()); } If (oldEntity. GetProgress (.) doubleValue () & gt;=CommonConstants. STANDARD_PROGRESS) {OldEntity. SetIsFinish (SysParamsEnum. STATUS_YES. GetCode ()); } UserAudioProgressService. Update (oldEntity, New QueryWrapper (a). Eq (" UUID, "oldEntity. GetUuid ())); } else {If (audioProgress. GetProgress (.) doubleValue () & gt;=CommonConstants. STANDARD_PROGRESS) {AudioProgress. SetIsFinish (SysParamsEnum. STATUS_YES. GetCode ()); } //if no progress is the first time to watch, save progress UserAudioProgressService. Save (audioProgress); } //3. Record the user history AudioInfo AudioInfo=userHistory (notNull? OldEntity: audioProgress); //4. Record the user credits //have to update the new schedule credits If (hasNewProgress) {SaveCredit (audioProgress audioInfo); } }
Page link:https//www.codepudding.com/Backend/99439.html