Browse Source

特殊序号

master
zhizhi wu 4 years ago
parent
commit
cca510913d
  1. 11
      src/main/java/com/ccsens/yanyuan/service/TalkingPenService.java
  2. 2
      src/main/java/com/ccsens/yanyuan/util/YanYuanConstant.java
  3. 2
      src/main/resources/mapper_dao/ToolFindDifferenceDao.xml

11
src/main/java/com/ccsens/yanyuan/service/TalkingPenService.java

@ -82,6 +82,11 @@ public class TalkingPenService implements ITalkingPenService {
*/ */
@Override @Override
public void dealIndex(TalkingPenDto talkingPen) throws Exception { public void dealIndex(TalkingPenDto talkingPen) throws Exception {
if (talkingPen.getValue() == 128847481L) {
log.info("当前的序号是:{},是特殊码,发送8", talkingPen.getValue());
sendAudio(8, talkingPen.getAuthId());
return;
}
YanYuanConstant.Card card = YanYuanConstant.Card.getByCardIndex(talkingPen.getValue()); YanYuanConstant.Card card = YanYuanConstant.Card.getByCardIndex(talkingPen.getValue());
byte type = card == null ? YanYuanConstant.CardType.INDEX : card.getType(); byte type = card == null ? YanYuanConstant.CardType.INDEX : card.getType();
long value = card == null ? talkingPen.getValue() : card.getRealIndex(); long value = card == null ? talkingPen.getValue() : card.getRealIndex();
@ -472,7 +477,7 @@ public class TalkingPenService implements ITalkingPenService {
log.info("{}缓存:{}", key, o); log.info("{}缓存:{}", key, o);
if (currents.size() >= max) { if (currents.size() >= max) {
log.info("{}正确数量已经大等于最大正确数:{}", trainCardId, max); log.info("{}正确数量已经大等于最大正确数:{}", trainCardId, max);
if (o == null) { if (o == null || (Integer)o < max) {
sendAudio(YanYuanConstant.Equipment.AUDIO_DIFFERENCE_COMPLETE, authId); sendAudio(YanYuanConstant.Equipment.AUDIO_DIFFERENCE_COMPLETE, authId);
} }
return; return;
@ -486,7 +491,7 @@ public class TalkingPenService implements ITalkingPenService {
trainCorrectDao.insertSelective(correct); trainCorrectDao.insertSelective(correct);
currents.add(curPointPlace); currents.add(curPointPlace);
} }
if (o == null) { if (o == null || (Integer)o < currents.size()) {
int audioIndex = currents.size() >= max ? YanYuanConstant.Equipment.AUDIO_DIFFERENCE_COMPLETE : int audioIndex = currents.size() >= max ? YanYuanConstant.Equipment.AUDIO_DIFFERENCE_COMPLETE :
YanYuanConstant.Equipment.AUDIO_DIFFERENCE_CURRENT; YanYuanConstant.Equipment.AUDIO_DIFFERENCE_CURRENT;
sendAudio(audioIndex, authId); sendAudio(audioIndex, authId);
@ -684,6 +689,7 @@ public class TalkingPenService implements ITalkingPenService {
//记录一下点读笔发送的语音,时长1分钟,若1分钟内发送过相同的内容,则不再发送(时长待定,该判断待讨论) //记录一下点读笔发送的语音,时长1分钟,若1分钟内发送过相同的内容,则不再发送(时长待定,该判断待讨论)
String key = StrUtil.format(YanYuanConstant.Equipment.TALKING_PEN_AUDIO_KEY, talkingPenSerial); String key = StrUtil.format(YanYuanConstant.Equipment.TALKING_PEN_AUDIO_KEY, talkingPenSerial);
Object o = redisUtil.get(key); Object o = redisUtil.get(key);
log.info("发送语音:key:{}, value:{},即将发送的语音:{},笔的序号:{}", key, o, value, talkingPenSerial);
if (o != null) { if (o != null) {
int oldValue = (Integer) o; int oldValue = (Integer) o;
if (oldValue == YanYuanConstant.Equipment.AUDIO_NO_TRAINEE) { if (oldValue == YanYuanConstant.Equipment.AUDIO_NO_TRAINEE) {
@ -724,6 +730,7 @@ public class TalkingPenService implements ITalkingPenService {
log.info("给点读笔发送消息:{}", inMessage); log.info("给点读笔发送消息:{}", inMessage);
//发送消息 //发送消息
messageService.sendTo(inMessage); messageService.sendTo(inMessage);
redisUtil.set(key, value, YanYuanConstant.Equipment.TALKING_PEN_JUDGE_AUDIO_TIME);
} }

2
src/main/java/com/ccsens/yanyuan/util/YanYuanConstant.java

@ -155,7 +155,7 @@ public class YanYuanConstant {
* 点读笔判断找不同是否正确 * 点读笔判断找不同是否正确
*/ */
public final static String TALKING_PEN_JUDGE_AUDIO_KEY = "talking_pen_judge_{}_audio"; public final static String TALKING_PEN_JUDGE_AUDIO_KEY = "talking_pen_judge_{}_audio";
public final static long TALKING_PEN_JUDGE_AUDIO_TIME = 60; public final static long TALKING_PEN_JUDGE_AUDIO_TIME = 10;
/** /**
* 点读笔试题查询下一个 * 点读笔试题查询下一个
*/ */

2
src/main/resources/mapper_dao/ToolFindDifferenceDao.xml

@ -2,6 +2,6 @@
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd"> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ccsens.yanyuan.persist.dao.ToolFindDifferenceDao"> <mapper namespace="com.ccsens.yanyuan.persist.dao.ToolFindDifferenceDao">
<select id="getDifferenceNum" resultType="java.lang.Integer"> <select id="getDifferenceNum" resultType="java.lang.Integer">
SELECT count(*) FROM t_tool_find_difference WHERE card_id = #{cardId} and rec_status = 0 SELECT max(which_place) FROM t_tool_find_difference WHERE card_id = #{cardId} and rec_status = 0
</select> </select>
</mapper> </mapper>
Loading…
Cancel
Save