package com.qianwen.smartman.modules.notify.service.impl; import cn.hutool.core.collection.CollUtil; import cn.hutool.core.convert.Convert; import cn.hutool.core.util.StrUtil; import cn.hutool.json.JSONUtil; import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.support.SFunction; import java.lang.invoke.SerializedLambda; import java.util.ArrayList; import java.util.Date; import java.util.List; import java.util.stream.Collectors; import com.qianwen.smartman.common.constant.DictConstant; import com.qianwen.smartman.common.utils.ExtraLambdaQueryWrapper; import com.qianwen.smartman.common.utils.Lambda; import com.qianwen.core.mp.base.BaseServiceImpl; import com.qianwen.core.tool.utils.Func; import com.qianwen.core.tool.utils.SpringUtil; import com.qianwen.core.websocket.distribute.MessageDO; import com.qianwen.core.websocket.distribute.RedisMessageDistributor; import com.qianwen.smartman.modules.notify.convert.NoticeConvert; import com.qianwen.smartman.modules.notify.entity.Notice; import com.qianwen.smartman.modules.notify.entity.NotifySystem; import com.qianwen.smartman.modules.notify.mapper.NoticeMapper; import com.qianwen.smartman.modules.notify.service.INoticeService; import com.qianwen.smartman.modules.notify.service.INotifySystemService; import com.qianwen.smartman.modules.notify.vo.NoticeAddVO; import com.qianwen.smartman.modules.notify.vo.NoticeSelectVO; import com.qianwen.smartman.modules.notify.vo.NoticeUpdateVO; import com.qianwen.smartman.modules.notify.vo.NoticeVO; import com.qianwen.smartman.modules.notify.websocket.InternalMessageResponseJsonWebSocketMessage; import com.qianwen.smartman.modules.system.entity.Dict; import com.qianwen.smartman.modules.system.entity.User; import com.qianwen.smartman.modules.system.service.IDictService; import com.qianwen.smartman.modules.system.service.IUserService; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Lazy; import org.springframework.stereotype.Service; @Service /* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/service/impl/NoticeServiceImpl.class */ public class NoticeServiceImpl extends BaseServiceImpl implements INoticeService { @Autowired private IUserService userService; @Autowired @Lazy private INotifySystemService notifySystemService; @Autowired private IDictService dictService; private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) { String implMethodName = lambda.getImplMethodName(); boolean z = true; switch (implMethodName.hashCode()) { case -1601031533: if (implMethodName.equals("getDictKey")) { z = false; break; } break; case -75622813: if (implMethodName.equals("getCode")) { z = true; break; } break; case 98245393: if (implMethodName.equals("getId")) { z = true; break; } break; } switch (z) { case false: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dict") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { return (v0) -> { return v0.getDictKey(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dict") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { return (v0) -> { return v0.getDictKey(); }; } break; case true: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) { return (v0) -> { return v0.getId(); }; } break; case true: if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dict") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { return (v0) -> { return v0.getCode(); }; } if (lambda.getImplMethodKind() == 5 && lambda.getFunctionalInterfaceClass().equals("com/baomidou/mybatisplus/core/toolkit/support/SFunction") && lambda.getFunctionalInterfaceMethodName().equals("apply") && lambda.getFunctionalInterfaceMethodSignature().equals("(Ljava/lang/Object;)Ljava/lang/Object;") && lambda.getImplClass().equals("org/springblade/modules/system/entity/Dict") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) { return (v0) -> { return v0.getCode(); }; } break; } throw new IllegalArgumentException("Invalid lambda deserialization"); } @Override // org.springblade.modules.notify.service.INoticeService public IPage selectNoticePage(IPage page, NoticeSelectVO selectVO) { String typeId = selectVO.getCategory(); if (Func.isNotEmpty(typeId)) { int[] ids = StrUtil.splitToInt(typeId, ","); List typeIds = Convert.toList(Integer.class, ids); selectVO.setCategoryIds(typeIds); } return ((NoticeMapper) this.baseMapper).selectNoticePage(page, selectVO); } @Override // org.springblade.modules.notify.service.INoticeService public NoticeVO saveNotice(NoticeAddVO vo) { Notice notice = NoticeConvert.INSTANCE.convert(vo); save(notice); sentMessage(notice); Integer category = notice.getCategory(); NoticeVO convert = NoticeConvert.INSTANCE.convert(notice); Dict dict = (Dict) this.dictService.getOne(((ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) Lambda.create().eq((v0) -> { return v0.getCode(); }, DictConstant.NOTICE_CODE)).eq((v0) -> { return v0.getDictKey(); }, category.toString())).limit()); if (Func.isNotEmpty(dict)) { String dictValue = dict.getDictValue(); convert.setCategoryName(dictValue); } return convert; } @Override // org.springblade.modules.notify.service.INoticeService public NoticeVO updateNotice(NoticeUpdateVO vo) { Notice notice = NoticeConvert.INSTANCE.convert(vo); updateById(notice); sentMessage(notice); Integer category = notice.getCategory(); NoticeVO convert = NoticeConvert.INSTANCE.convert(notice); Dict dict = (Dict) this.dictService.getOne(((ExtraLambdaQueryWrapper) ((ExtraLambdaQueryWrapper) Lambda.create().eq((v0) -> { return v0.getCode(); }, DictConstant.NOTICE_CODE)).eq((v0) -> { return v0.getDictKey(); }, category.toString())).limit()); if (Func.isNotEmpty(dict)) { String dictValue = dict.getDictValue(); convert.setCategoryName(dictValue); } return convert; } private void sentMessage(Notice notice) { Long id = notice.getId(); List users = this.userService.list(Wrappers.lambdaQuery().select(new SFunction[]{(v0) -> { return v0.getId(); }})); List usersIds = (List) users.stream().map((v0) -> { return v0.getId(); }).collect(Collectors.toList()); List notifySystems = new ArrayList<>(); Date date = new Date(); if (Func.isNotEmpty(usersIds)) { for (Long userId : usersIds) { NotifySystem notifySystem = new NotifySystem(); notifySystem.setNotifyType(2); notifySystem.setNotifyTime(date); notifySystem.setSourceId(Func.toStr(id)); notifySystem.setBusinessName(notice.getTitle()); notifySystem.setNotifyUser(Func.toStr(userId)); notifySystem.setStatus(0); notifySystems.add(notifySystem); } this.notifySystemService.saveBatch(notifySystems); for (NotifySystem notifySystem2 : notifySystems) { RedisMessageDistributor messageDistributor = (RedisMessageDistributor) SpringUtil.getBean(RedisMessageDistributor.class); MessageDO messageDO = new MessageDO(); messageDO.setNeedBroadcast(Boolean.FALSE); messageDO.setSessionKeys(CollUtil.newArrayList(new Object[]{notifySystem2.getNotifyUser()})); InternalMessageResponseJsonWebSocketMessage internalMessageResponseJsonWebSocketMessage = new InternalMessageResponseJsonWebSocketMessage(); internalMessageResponseJsonWebSocketMessage.setHaveUnread(true); internalMessageResponseJsonWebSocketMessage.setNotifySystemId(String.valueOf(notifySystem2.getId())); internalMessageResponseJsonWebSocketMessage.setNotifyType(2); messageDO.setMessageText(JSONUtil.toJsonStr(internalMessageResponseJsonWebSocketMessage)); messageDistributor.distribute(messageDO); } } } }