yangys
2024-05-06 e19227de97d21c10fd22536f85c8153e63072d0c
smart-man-boot/src/main/java/com/qianwen/smartman/modules/notify/service/impl/BusinessNotifyServiceImpl.java
@@ -1,11 +1,5 @@
package com.qianwen.smartman.modules.notify.service.impl;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import java.lang.invoke.SerializedLambda;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.Collections;
@@ -13,18 +7,23 @@
import java.util.Map;
import java.util.Objects;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import com.qianwen.smartman.common.cache.RegionCache;
import com.qianwen.smartman.common.constant.NotifyConstant;
import com.qianwen.smartman.common.utils.MessageUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qianwen.core.cache.utils.CacheUtil;
import com.qianwen.core.log.exception.ServiceException;
import com.qianwen.core.mp.base.BaseEntity;
import com.qianwen.core.mp.base.BaseServiceImpl;
import com.qianwen.core.tool.node.ForestNodeMerger;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.common.constant.NotifyConstant;
import com.qianwen.smartman.common.utils.MessageUtils;
import com.qianwen.smartman.modules.cps.entity.Employee;
import com.qianwen.smartman.modules.cps.service.IEmployeeService;
import com.qianwen.smartman.modules.notify.convert.BusinessNotifyConvert;
@@ -47,10 +46,9 @@
import com.qianwen.smartman.modules.notify.vo.NotifyBusinessTreeVO;
import com.qianwen.smartman.modules.notify.vo.NotifyDefaultObjectVO;
import com.qianwen.smartman.modules.system.service.IDictService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
@Transactional(rollbackFor = {Exception.class})
@Service
@@ -68,136 +66,6 @@
    @Lazy
    private NotifyBusinessManager notifyBusinessManager;
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -1462663655:
                if (implMethodName.equals("getNotifyType")) {
                    z = true;
                    break;
                }
                break;
            case -330190124:
                if (implMethodName.equals("getNotifyTemplateId")) {
                    z = true;
                    break;
                }
                break;
            case -75106384:
                if (implMethodName.equals("getType")) {
                    z = true;
                    break;
                }
                break;
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = true;
                    break;
                }
                break;
            case 584947017:
                if (implMethodName.equals("getBusinessKey")) {
                    z = false;
                    break;
                }
                break;
            case 803533544:
                if (implMethodName.equals("getStatus")) {
                    z = true;
                    break;
                }
                break;
            case 931069238:
                if (implMethodName.equals("getBusiness")) {
                    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/notify/entity/BusinessNotify") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getBusinessKey();
                    };
                }
                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/notify/entity/BusinessNotify") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getBusinessKey();
                    };
                }
                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/notify/entity/BusinessNotify") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getBusinessKey();
                    };
                }
                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/notify/entity/NotifyConfigEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getType();
                    };
                }
                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/notify/entity/NotifyTemplateEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getType();
                    };
                }
                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/notify/entity/NotifyConfigEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getType();
                    };
                }
                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/notify/entity/BusinessNotify") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getNotifyTemplateId();
                    };
                }
                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/notify/entity/BusinessNotify") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getNotifyType();
                    };
                }
                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/notify/entity/BusinessNotify") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getNotifyType();
                    };
                }
                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/notify/entity/NotifyTemplateEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getBusiness();
                    };
                }
                break;
            case RegionCache.VILLAGE_LEVEL /* 5 */:
                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();
                    };
                }
                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/core/mp/base/BaseEntity") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
    public BusinessNotifyServiceImpl(final NotifyConfigServiceImpl notifyConfigService, final INotifyTemplateService notifyTemplateService, final BusinessNotifyMapper businessNotifyMapper, final IDictService dictService, final IEmployeeService employeeService, final INotifyDefaultPersonService notifyDefaultPersonService, final NotifyBusinessManager notifyBusinessManager) {
        this.notifyConfigService = notifyConfigService;
@@ -221,13 +89,15 @@
    @Override // org.springblade.modules.notify.service.IBusinessNotifyService
    public List<BusinessNotifyDTO> list(String businessKey) {
        Map<String, NotifyTypeInfo> typeInfoMap = this.notifyConfigService.getNotifyInfo();
        Map<String, BusinessNotifyDTO> businessMap = this.businessNotifyMapper.businessList(businessKey).stream().collect(Collectors.toMap(BusinessNotifyDTO::getNotifyType, notifyBusiness -> notifyBusiness));
        /*
        Map<String, BusinessNotifyDTO> businessMap = (Map) this.businessNotifyMapper.businessList(businessKey).stream().collect(Collectors.toMap((v0) -> {
            return v0.getNotifyType();
        }, notifyBusiness -> {
            return notifyBusiness;
        }));
        }));*/
        Map<String, NotifyConfigEntity> configMap = this.notifyConfigService.getConfigs(CollectionUtil.list(Boolean.FALSE.booleanValue(), typeInfoMap.keySet()));
        configMap.forEach(typeId, config -> {
        configMap.forEach((typeId, config) -> {
            BusinessNotifyDTO businessNotify = (BusinessNotifyDTO) businessMap.get(typeId);
            boolean isExit = ObjectUtil.isNull(businessNotify);
            BusinessNotifyDTO businessNotify2 = isExit ? new BusinessNotifyDTO() : businessNotify;
@@ -244,6 +114,12 @@
            businessMap.put(typeId, businessNotify2);
        });
        List<BusinessNotifyDTO> result = new ArrayList<>();
        typeInfoMap.keySet().stream().map(businessMap::get).forEach(dto -> {
            if (dto != null)
              result.add(dto);
          });
        /*
        Stream<String> stream = typeInfoMap.keySet().stream();
        businessMap.getClass();
        stream.map((v1) -> {
@@ -252,7 +128,7 @@
            if (dto != null) {
                result.add(dto);
            }
        });
        });*/
        return result;
    }
@@ -263,23 +139,29 @@
            CacheUtil.evict("blade:notify", "template:id:", templateEntity.getId(), false);
        }
        checkTemplateAndType(notifyBusinessVO);
        NotifyConfigEntity entity = this.notifyConfigService.getOne(Wrappers.<NotifyConfigEntity>lambdaQuery()
                .eq(NotifyConfigEntity::getType, notifyBusinessVO.getBusinessNotify().getNotifyType()));
        /*
        NotifyConfigEntity entity = (NotifyConfigEntity) this.notifyConfigService.getOne((Wrapper) Wrappers.lambdaQuery().eq((v0) -> {
            return v0.getType();
        }, notifyBusinessVO.getBusinessNotify().getNotifyType()));
        }, notifyBusinessVO.getBusinessNotify().getNotifyType()));*/
        notifyBusinessVO.getBusinessNotify().setNotifyId(entity.getId());
        this.notifyTemplateService.save(notifyBusinessVO.getTemplateEntity());
        notifyBusinessVO.getBusinessNotify().setNotifyTemplateId(notifyBusinessVO.getTemplateEntity().getId());
        save((BaseEntity) notifyBusinessVO.getBusinessNotify());
        save(notifyBusinessVO.getBusinessNotify());
        return notifyBusinessVO;
    }
    @Override // org.springblade.modules.notify.service.IBusinessNotifyService
    public Boolean change(NotifyBusinessChangeStatusVO changeStatusVO) {
       BusinessNotify businessNotify = (BusinessNotify)getOne(Wrappers.lambdaQuery(BusinessNotify.class)
               .eq(BusinessNotify::getBusinessKey, changeStatusVO.getBusinessKey()).eq(BusinessNotify::getNotifyType, changeStatusVO.getNotifyType()));
       /*
        BusinessNotify businessNotify = (BusinessNotify) getOne((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery(BusinessNotify.class).eq((v0) -> {
            return v0.getBusinessKey();
        }, changeStatusVO.getBusinessKey())).eq((v0) -> {
            return v0.getNotifyType();
        }, changeStatusVO.getNotifyType()));
        }, changeStatusVO.getNotifyType()));*/
        if (Objects.isNull(businessNotify)) {
            throw new ServiceException(MessageUtils.message("notify.business.template.status.not.be.change", new Object[0]));
        }
@@ -299,33 +181,38 @@
    @Override // org.springblade.modules.notify.service.IBusinessNotifyService
    public boolean remove(Long templateId) {
        this.notifyTemplateService.removeById(templateId);
        return remove(Wrappers.lambdaQuery(BusinessNotify.class).eq(BusinessNotify::getNotifyTemplateId, templateId));
        /*
        return remove((Wrapper) Wrappers.lambdaQuery(BusinessNotify.class).eq((v0) -> {
            return v0.getNotifyTemplateId();
        }, templateId));
        }, templateId));*/
    }
    public List<Long> getNoticeEmpIds(List<Long> orgIds, List<Long> empIds) {
        List<Employee> employees = this.employeeService.listByOrgIds(orgIds);
        List<Long> itemEmpIds = (List) employees.stream().map((v0) -> {
        List<Long> itemEmpIds = employees.stream().map((v0) -> {
            return v0.getId();
        }).collect(Collectors.toList());
        empIds.addAll(itemEmpIds);
        return (List) empIds.stream().distinct().collect(Collectors.toList());
        return empIds.stream().distinct().collect(Collectors.toList());
    }
    @Override // org.springblade.modules.notify.service.IBusinessNotifyService
    public void sendMessage(NotifySendDTO notifySendDTO) {
        String businessKey = notifySendDTO.getBusinessKey();
        List<BusinessNotify> list = list(Wrappers.<BusinessNotify>lambdaQuery().eq(BusinessNotify::getStatus, 1)
              .eq(BusinessNotify::getBusinessKey, businessKey));
        /*
        List<BusinessNotify> list = list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
            return v0.getStatus();
        }, 1)).eq((v0) -> {
            return v0.getBusinessKey();
        }, businessKey));
        List<Long> templateIds = (List) list.stream().map((v0) -> {
        }, businessKey));*/
        List<Long> templateIds = list.stream().map((v0) -> {
            return v0.getNotifyTemplateId();
        }).collect(Collectors.toList());
        List<NotifyTemplateEntity> notifyTemplateEntities = this.notifyTemplateService.listByIds(templateIds);
        Map<Long, NotifyTemplateEntity> tempMap = (Map) notifyTemplateEntities.stream().collect(Collectors.toMap((v0) -> {
        Map<Long, NotifyTemplateEntity> tempMap = notifyTemplateEntities.stream().collect(Collectors.toMap((v0) -> {
            return v0.getId();
        }, item -> {
            return item;
@@ -358,32 +245,45 @@
    }
    private void checkTemplate(NotifyTemplateEntity notifyTemplateEntity) {
       long count = this.notifyTemplateService.count(Wrappers.<NotifyTemplateEntity>lambdaQuery()
               .ne(BaseEntity::getId, notifyTemplateEntity.getId())
               .eq(NotifyTemplateEntity::getType, notifyTemplateEntity.getType())
               .eq(NotifyTemplateEntity::getBusiness, notifyTemplateEntity.getBusiness()));
       /*
        long count = this.notifyTemplateService.count((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().ne((v0) -> {
            return v0.getId();
        }, notifyTemplateEntity.getId())).eq((v0) -> {
            return v0.getType();
        }, notifyTemplateEntity.getType())).eq((v0) -> {
            return v0.getBusiness();
        }, notifyTemplateEntity.getBusiness()));
        }, notifyTemplateEntity.getBusiness()));*/
        if (count > 0) {
            throw new ServiceException(MessageUtils.message("notify.business.template.not.be.repeated", new Object[0]));
        }
    }
    private void checkTemplateAndType(NotifyBusinessSaveVO business) {
       long count = count(Wrappers.lambdaQuery(BusinessNotify.class)
               .ne(Func.isNotEmpty(business.getBusinessNotify().getId()), BaseEntity::getId, business.getBusinessNotify().getId())
               .eq(BusinessNotify::getNotifyType, business.getBusinessNotify().getNotifyType())
               .eq(BusinessNotify::getBusinessKey, business.getBusinessNotify().getBusinessKey()));
       /*
        long count = count((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery(BusinessNotify.class).ne(Func.isNotEmpty(business.getBusinessNotify().getId()), (v0) -> {
            return v0.getId();
        }, business.getBusinessNotify().getId()).eq((v0) -> {
            return v0.getNotifyType();
        }, business.getBusinessNotify().getNotifyType())).eq((v0) -> {
            return v0.getBusinessKey();
        }, business.getBusinessNotify().getBusinessKey()));
        }, business.getBusinessNotify().getBusinessKey()));*/
        if (count > 0) {
            throw new ServiceException(MessageUtils.message("notify.business.template.not.be.repeated", new Object[0]));
        }
        long typeCount = this.notifyConfigService.count(Wrappers.<NotifyConfigEntity>lambdaQuery()
                .eq(NotifyConfigEntity::getType, business.getBusinessNotify().getNotifyType()));
        /*
        long typeCount = this.notifyConfigService.count((Wrapper) Wrappers.lambdaQuery().eq((v0) -> {
            return v0.getType();
        }, business.getBusinessNotify().getNotifyType()));
        }, business.getBusinessNotify().getNotifyType()));*/
        if (typeCount <= 0) {
            throw new ServiceException(MessageUtils.message("notify.service.config.is.null", new Object[0]));
        }