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