Commit 857f9129 by danmo

修复活码新增和扫描任务中存在的bug

1 parent 1d7c5644
...@@ -96,12 +96,12 @@ public class ChatMsgCheckListener implements MessageListener { ...@@ -96,12 +96,12 @@ public class ChatMsgCheckListener implements MessageListener {
allSensitiveRules.forEach(weSensitive -> { allSensitiveRules.forEach(weSensitive -> {
List<String> patternWords = Arrays.asList(weSensitive.getPatternWords().split(",")); List<String> patternWords = Arrays.asList(weSensitive.getPatternWords().split(","));
List<String> users = weSensitiveService.getScopeUsers(weSensitive.getAuditUserScope()); List<String> users = weSensitiveService.getScopeUsers(weSensitive.getAuditUserScope());
log.info("handleSensitiveHit: >>>>>>>>>>>>>>>>>>>>>>finalContent:{}, patternWords:{},users:{},from:{}", finalContent, JSONObject.toJSONString(patternWords), JSONObject.toJSONString(users), fromId); //log.info("handleSensitiveHit: >>>>>>>>>>>>>>>>>>>>>>finalContent:{}, patternWords:{},users:{},from:{}", finalContent, JSONObject.toJSONString(patternWords), JSONObject.toJSONString(users), fromId);
if (StringUtils.isNotBlank(finalContent) if (StringUtils.isNotBlank(finalContent)
&& !CollectionUtils.isEmpty(users) && !CollectionUtils.isEmpty(users)
&& users.stream().anyMatch(fromId::equals)) { && users.stream().anyMatch(fromId::equals)) {
WeChatContactSensitiveMsg wccsm = hitSensitive(patternWords, fromId, finalContent); WeChatContactSensitiveMsg wccsm = hitSensitive(patternWords, fromId, finalContent);
log.info("handleSensitiveHit: >>>>>>>>>>>>>>>>>>>>>> wccsm:{}",JSONObject.toJSONString(wccsm)); //log.info("handleSensitiveHit: >>>>>>>>>>>>>>>>>>>>>> wccsm:{}",JSONObject.toJSONString(wccsm));
if (wccsm != null) { if (wccsm != null) {
wccsm.setMsgId(msgId); wccsm.setMsgId(msgId);
wccsm.setFromId(fromId); wccsm.setFromId(fromId);
...@@ -119,7 +119,7 @@ public class ChatMsgCheckListener implements MessageListener { ...@@ -119,7 +119,7 @@ public class ChatMsgCheckListener implements MessageListener {
private WeChatContactSensitiveMsg hitSensitive(List<String> patternWords, String user, String content) { private WeChatContactSensitiveMsg hitSensitive(List<String> patternWords, String user, String content) {
WeChatContactSensitiveMsg weChatContactSensitiveMsg = new WeChatContactSensitiveMsg(); WeChatContactSensitiveMsg weChatContactSensitiveMsg = new WeChatContactSensitiveMsg();
String patternWordStr = patternWords.stream().filter(content.trim()::contains).collect(Collectors.joining(",")); String patternWordStr = patternWords.stream().filter(content.trim()::contains).collect(Collectors.joining(","));
log.info("hitSensitive: >>>>>>>>>>>>>>>>>>>>>> patternWordStr:{}",patternWordStr); //log.info("hitSensitive: >>>>>>>>>>>>>>>>>>>>>> patternWordStr:{}",patternWordStr);
if (StringUtils.isNotEmpty(patternWordStr)) { if (StringUtils.isNotEmpty(patternWordStr)) {
weChatContactSensitiveMsg.setContent(content); weChatContactSensitiveMsg.setContent(content);
weChatContactSensitiveMsg.setSendStatus(0); weChatContactSensitiveMsg.setSendStatus(0);
......
...@@ -22,6 +22,7 @@ import org.springframework.stereotype.Component; ...@@ -22,6 +22,7 @@ import org.springframework.stereotype.Component;
import java.util.Arrays; import java.util.Arrays;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**
...@@ -43,29 +44,30 @@ public class WeQrCodeUpdateTask { ...@@ -43,29 +44,30 @@ public class WeQrCodeUpdateTask {
private WeExternalContactClient externalContactClient; private WeExternalContactClient externalContactClient;
public void qrCodeUpdateTask() { public void qrCodeUpdateTask() {
Date date = new Date(); List<WeQrScopeVo> weQrScopeList = weQrScopeService.getWeQrScopeByTime(DateUtil.formatDateTime(new Date()));
Week week = DateUtil.dayOfWeekEnum(date);
String formatTime = DateUtil.formatTime(date);
List<WeQrScopeVo> weQrScopeList = weQrScopeService.getWeQrScopeByTime(week.getValue(), formatTime);
log.info("活码使用范围修改任务 weQrScopeList {}", JSONObject.toJSONString(weQrScopeList)); log.info("活码使用范围修改任务 weQrScopeList {}", JSONObject.toJSONString(weQrScopeList));
if (CollectionUtil.isNotEmpty(weQrScopeList)) { if (CollectionUtil.isNotEmpty(weQrScopeList)) {
List<WeQrScopeVo> weCustomizeQrScopeList = weQrScopeList.stream().filter(item -> ObjectUtil.equal(1, item.getType())).collect(Collectors.toList()); Map<Long, List<WeQrScopeVo>> qrCodeMap = weQrScopeList.stream().collect(Collectors.groupingBy(WeQrScopeVo::getQrId));
if (CollectionUtil.isNotEmpty(weCustomizeQrScopeList)) { qrCodeMap.forEach((qrId,scopeList) ->{
weCustomizeQrScopeList.forEach(this::extracted); WeQrCode weQrCode = weQrCodeService.getById(qrId);
} else { WeQrScopeVo weCustomizeQrScope = weQrScopeList.stream()
WeQrScopeVo weDefaultQrScope = weQrScopeList.stream().filter(item -> ObjectUtil.equal(0, item.getType())).findFirst().orElse(null); .filter(item -> ObjectUtil.equal(1, item.getType())).findFirst().orElse(null);
if (weDefaultQrScope != null) { if(weCustomizeQrScope != null){
extracted(weDefaultQrScope); extracted(weCustomizeQrScope,weQrCode.getConfigId());
} }else {
WeQrScopeVo weDefaultQrScope = weQrScopeList.stream()
.filter(item -> ObjectUtil.equal(0, item.getType())).findFirst().orElse(null);
extracted(weDefaultQrScope,weQrCode.getConfigId());
} }
});
} }
} }
private void extracted(WeQrScopeVo weQrScope) { private void extracted(WeQrScopeVo weQrScope, String configId) {
WeQrCode weQrCode = weQrCodeService.getById(weQrScope.getQrId()); log.info("extracted ->>>>>>>>>>weQrScope:{}",JSONObject.toJSONString(weQrScope));
String configId = weQrCode.getConfigId(); WeExternalContactDto query = new WeExternalContactDto();
WeContactWayDto contactWay = externalContactClient.getContactWay(configId); query.setConfig_id(configId);
WeContactWayDto contactWay = externalContactClient.getContactWay(query);
if (contactWay != null && ObjectUtil.equal(0, contactWay.getErrcode())) { if (contactWay != null && ObjectUtil.equal(0, contactWay.getErrcode())) {
String userIds = ""; String userIds = "";
String partys = ""; String partys = "";
......
...@@ -27,5 +27,5 @@ public interface WeExternalContactClient { ...@@ -27,5 +27,5 @@ public interface WeExternalContactClient {
WeExternalContactDto delContactWay(@JSONBody WeExternalContactDto query); WeExternalContactDto delContactWay(@JSONBody WeExternalContactDto query);
@Request(url = "/externalcontact/get_contact_way", type = "POST") @Request(url = "/externalcontact/get_contact_way", type = "POST")
WeContactWayDto getContactWay(@Query("configId") String configId); WeContactWayDto getContactWay(@JSONBody WeExternalContactDto query);
} }
...@@ -24,6 +24,6 @@ public interface WeQrScopeMapper extends BaseMapper<WeQrScope> { ...@@ -24,6 +24,6 @@ public interface WeQrScopeMapper extends BaseMapper<WeQrScope> {
List<WeQrScopeVo> getWeQrScopeByQrIds(@Param("qrIds") List<Long> qrIds); List<WeQrScopeVo> getWeQrScopeByQrIds(@Param("qrIds") List<Long> qrIds);
List<WeQrScopeVo> getWeQrScopeByTime(@Param("value") Integer value, @Param("formatTime") String formatTime); List<WeQrScopeVo> getWeQrScopeByTime(@Param("formatTime") String formatTime);
} }
...@@ -45,9 +45,7 @@ public interface IWeQrScopeService extends IService<WeQrScope> { ...@@ -45,9 +45,7 @@ public interface IWeQrScopeService extends IService<WeQrScope> {
/** /**
* 查询当前时间使用范围活码数据 * 查询当前时间使用范围活码数据
* @param value
* @param formatTime
* @return * @return
*/ */
List<WeQrScopeVo> getWeQrScopeByTime(Integer value, String formatTime); List<WeQrScopeVo> getWeQrScopeByTime(String formatTime);
} }
...@@ -66,6 +66,7 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop ...@@ -66,6 +66,7 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop
if(CollectionUtil.isNotEmpty(userInfo.getWorkCycle())){ if(CollectionUtil.isNotEmpty(userInfo.getWorkCycle())){
weQrScope.setWorkCycle(userInfo.getWorkCycle().stream().map(String::valueOf).collect(Collectors.joining(","))); weQrScope.setWorkCycle(userInfo.getWorkCycle().stream().map(String::valueOf).collect(Collectors.joining(",")));
} }
weQrScope.setType(userInfo.getType());
weQrScope.setBeginTime(userInfo.getBeginTime()); weQrScope.setBeginTime(userInfo.getBeginTime());
weQrScope.setEndTime(userInfo.getEndTime()); weQrScope.setEndTime(userInfo.getEndTime());
return weQrScope; return weQrScope;
...@@ -97,7 +98,7 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop ...@@ -97,7 +98,7 @@ public class IWeQrScopeServiceImpl extends ServiceImpl<WeQrScopeMapper, WeQrScop
} }
@Override @Override
public List<WeQrScopeVo> getWeQrScopeByTime(Integer value, String formatTime) { public List<WeQrScopeVo> getWeQrScopeByTime(String formatTime) {
return this.baseMapper.getWeQrScopeByTime(value,formatTime); return this.baseMapper.getWeQrScopeByTime(formatTime);
} }
} }
...@@ -76,9 +76,9 @@ ...@@ -76,9 +76,9 @@
wqs.user_id, wqs.user_id,
wqs.party wqs.party
from we_qr_scope wqs from we_qr_scope wqs
where find_in_set(#{value},wqs.work_cycle) where find_in_set(dayofweek(curdate())-1,wqs.work_cycle)
and str_to_date(wqs.begin_time,'%H:%i:%S') &lt;= str_to_date(#{formatTime},'%H:%i:%S') and date_format(concat(date_format(curdate(),'%Y-%m-%d '),wqs.begin_time), '%H:%i:%s') &lt;= date_format(#{formatTime},'%H:%i:%s')
and str_to_date(wqs.end_time ,'%H:%i:%S') &gt;= str_to_date(#{formatTime},'%H:%i:%S') and date_format(concat(date_format(curdate(),'%Y-%m-%d '),wqs.end_time), '%H:%i:%s') &gt;= date_format(#{formatTime},'%H:%i:%s')
and wqs.del_flag = 0 and wqs.del_flag = 0
</select> </select>
</mapper> </mapper>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!