Commit d8f160ec940fb7cb611636f3acea60c8b4086a3b
1 parent
388c2eb1
update
Showing
2 changed files
with
22 additions
and
7 deletions
pom.xml
| @@ -156,6 +156,11 @@ | @@ -156,6 +156,11 @@ | ||
| 156 | <artifactId>poi-ooxml</artifactId> | 156 | <artifactId>poi-ooxml</artifactId> |
| 157 | <version>3.16</version> | 157 | <version>3.16</version> |
| 158 | </dependency> | 158 | </dependency> |
| 159 | + <dependency> | ||
| 160 | + <groupId>com.google.guava</groupId> | ||
| 161 | + <artifactId>guava</artifactId> | ||
| 162 | + <version>27.0.1-jre</version> | ||
| 163 | + </dependency> | ||
| 159 | </dependencies> | 164 | </dependencies> |
| 160 | 165 | ||
| 161 | <build> | 166 | <build> |
src/main/java/com/cnlive/shenhe/api/AudioControllerApi.java
| @@ -5,6 +5,7 @@ import com.cnlive.shenhe.bean.ErrorEnum; | @@ -5,6 +5,7 @@ import com.cnlive.shenhe.bean.ErrorEnum; | ||
| 5 | import com.cnlive.shenhe.bean.ResponseBean; | 5 | import com.cnlive.shenhe.bean.ResponseBean; |
| 6 | import com.cnlive.shenhe.entity.ShyAudio; | 6 | import com.cnlive.shenhe.entity.ShyAudio; |
| 7 | import com.cnlive.shenhe.serviceImpl.AudioServiceImpl; | 7 | import com.cnlive.shenhe.serviceImpl.AudioServiceImpl; |
| 8 | +import com.google.common.collect.EvictingQueue; | ||
| 8 | import org.slf4j.Logger; | 9 | import org.slf4j.Logger; |
| 9 | import org.slf4j.LoggerFactory; | 10 | import org.slf4j.LoggerFactory; |
| 10 | import org.springframework.beans.factory.annotation.Autowired; | 11 | import org.springframework.beans.factory.annotation.Autowired; |
| @@ -26,6 +27,8 @@ public class AudioControllerApi { | @@ -26,6 +27,8 @@ public class AudioControllerApi { | ||
| 26 | 27 | ||
| 27 | private static Logger logger = LoggerFactory.getLogger(AudioControllerApi.class); | 28 | private static Logger logger = LoggerFactory.getLogger(AudioControllerApi.class); |
| 28 | 29 | ||
| 30 | + private static EvictingQueue<String> queue = EvictingQueue.create(50); | ||
| 31 | + | ||
| 29 | @Autowired | 32 | @Autowired |
| 30 | AudioServiceImpl audioService; | 33 | AudioServiceImpl audioService; |
| 31 | 34 | ||
| @@ -60,18 +63,24 @@ public class AudioControllerApi { | @@ -60,18 +63,24 @@ public class AudioControllerApi { | ||
| 60 | try { | 63 | try { |
| 61 | ShyAudio shyAudio = JSONObject.parseObject(param, ShyAudio.class); | 64 | ShyAudio shyAudio = JSONObject.parseObject(param, ShyAudio.class); |
| 62 | ShyAudio audioMsg = audioService.getAudioMsg(shyAudio.getAudioId()); | 65 | ShyAudio audioMsg = audioService.getAudioMsg(shyAudio.getAudioId()); |
| 63 | - if (audioMsg != null) { | 66 | + if (audioMsg == null) { |
| 67 | + synchronized (AudioControllerApi.class) { | ||
| 68 | + if (!queue.contains(shyAudio.getAudioId())) { | ||
| 69 | + queue.add(shyAudio.getAudioId()); | ||
| 70 | + shyAudio.setCreateTime(new Date()); | ||
| 71 | + shyAudio.setState(0); | ||
| 72 | + //目前直接设置为人工审 | ||
| 73 | + shyAudio.setShenhe_type(3); | ||
| 74 | + shyAudio.setReceive(0); | ||
| 75 | + audioService.importAudioMsg(shyAudio); | ||
| 76 | + } | ||
| 77 | + } | ||
| 78 | + } else { | ||
| 64 | shyAudio.setId(audioMsg.getId()); | 79 | shyAudio.setId(audioMsg.getId()); |
| 65 | shyAudio.setUpdateTime(new Date()); | 80 | shyAudio.setUpdateTime(new Date()); |
| 66 | audioService.updateAudioMsg(shyAudio); | 81 | audioService.updateAudioMsg(shyAudio); |
| 67 | return new ResponseBean(ErrorEnum.SUCCESS); | 82 | return new ResponseBean(ErrorEnum.SUCCESS); |
| 68 | } | 83 | } |
| 69 | - shyAudio.setCreateTime(new Date()); | ||
| 70 | - shyAudio.setState(0); | ||
| 71 | - //目前直接设置为人工审 | ||
| 72 | - shyAudio.setShenhe_type(3); | ||
| 73 | - shyAudio.setReceive(0); | ||
| 74 | - audioService.importAudioMsg(shyAudio); | ||
| 75 | } catch (Exception e) { | 84 | } catch (Exception e) { |
| 76 | e.printStackTrace(); | 85 | e.printStackTrace(); |
| 77 | return new ResponseBean(ErrorEnum.ERROR); | 86 | return new ResponseBean(ErrorEnum.ERROR); |
| @@ -79,4 +88,4 @@ public class AudioControllerApi { | @@ -79,4 +88,4 @@ public class AudioControllerApi { | ||
| 79 | return new ResponseBean(ErrorEnum.SUCCESS); | 88 | return new ResponseBean(ErrorEnum.SUCCESS); |
| 80 | } | 89 | } |
| 81 | 90 | ||
| 82 | -} | 91 | -} |
| 92 | +} | ||
| 83 | \ No newline at end of file | 93 | \ No newline at end of file |