yangys
2024-04-02 6bed83e92f67954cd2135071133329f2205efe4f
smart-man-boot/src/main/java/com/qianwen/smartman/modules/notify/jobHandler/BusinessNotifyJob.java
@@ -1,22 +1,18 @@
package com.qianwen.smartman.modules.notify.jobHandler;
import com.baomidou.mybatisplus.core.conditions.Wrapper;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.core.toolkit.support.SFunction;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
import java.lang.invoke.SerializedLambda;
import java.time.LocalDateTime;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import org.assertj.core.util.Lists;
import com.qianwen.smartman.common.constant.NotifyConstant;
import org.springframework.stereotype.Component;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.common.constant.NotifyConstant;
import com.qianwen.smartman.modules.cps.entity.MaintainProject;
import com.qianwen.smartman.modules.cps.service.IMaintainProjectService;
import com.qianwen.smartman.modules.notify.business.BusinessSend;
@@ -29,7 +25,9 @@
import com.qianwen.smartman.modules.tpm.enums.MaintainGenerateEnum;
import com.qianwen.smartman.modules.tpm.enums.MaintainPlanStatusEnum;
import com.qianwen.smartman.modules.tpm.service.IMaintainPlanService;
import org.springframework.stereotype.Component;
import com.xxl.job.core.biz.model.ReturnT;
import com.xxl.job.core.handler.annotation.XxlJob;
import com.xxl.job.core.log.XxlJobLogger;
@Component
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/jobHandler/BusinessNotifyJob.class */
@@ -39,92 +37,6 @@
    private final IBusinessNotifyStateService businessNotifyStateService;
    private final IMaintainProjectService maintainProjectService;
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -798691761:
                if (implMethodName.equals("getMaintainDate")) {
                    z = true;
                    break;
                }
                break;
            case 98245393:
                if (implMethodName.equals("getId")) {
                    z = true;
                    break;
                }
                break;
            case 112409713:
                if (implMethodName.equals("getPlanStatus")) {
                    z = false;
                    break;
                }
                break;
            case 1404342513:
                if (implMethodName.equals("getBusinessId")) {
                    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/tpm/entity/MaintainPlan") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getPlanStatus();
                    };
                }
                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/tpm/entity/MaintainPlan") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getPlanStatus();
                    };
                }
                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/tpm/entity/MaintainPlan") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getPlanStatus();
                    };
                }
                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/BusinessNotifyState") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getBusinessId();
                    };
                }
                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();
                    };
                }
                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();
                    };
                }
                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/tpm/entity/MaintainPlan") && lambda.getImplMethodSignature().equals("()Ljava/time/LocalDateTime;")) {
                    return (v0) -> {
                        return v0.getMaintainDate();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
    public BusinessNotifyJob(final IMaintainPlanService maintainPlanService, final BusinessSendFactory businessSendFactory, final IBusinessNotifyStateService businessNotifyStateService, final IMaintainProjectService maintainProjectService) {
        this.maintainPlanService = maintainPlanService;
@@ -139,7 +51,7 @@
        LocalDateTime now = LocalDateTime.now();
        BusinessSend businessSend = this.businessSendFactory.getBusinessSend(NotifyConstant.MAINTAIN_OVERDUE);
        List<BusinessNotifyState> businessNotifyStates = this.businessNotifyStateService.listByBusinessKey(NotifyConstant.MAINTAIN_OVERDUE);
        Map<Long, List<BusinessNotifyState>> mapByBusinessId = (Map) businessNotifyStates.stream().collect(Collectors.groupingBy((v0) -> {
        Map<Long, List<BusinessNotifyState>> mapByBusinessId = businessNotifyStates.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getBusinessId();
        }));
        Set<Long> businessIds = mapByBusinessId.keySet();
@@ -147,35 +59,41 @@
            return ReturnT.SUCCESS;
        }
        List<Long> expireIds = deleteExpireState(businessIds);
        expireIds.forEach(businessIds::remove);
        /*
        businessIds.getClass();
        expireIds.forEach((v1) -> {
            r1.remove(v1);
        });
        });*/
        List<MaintainPlan> list = this.maintainPlanService.list(Wrappers.<MaintainPlan>lambdaQuery()
                .lt(true, MaintainPlan::getMaintainDate, now)
                .in(MaintainPlan::getPlanStatus, Lists.list(new Integer[] {MaintainPlanStatusEnum.T1.getType(), MaintainPlanStatusEnum.T2.getType() } )).in(MaintainPlan::getId, businessIds));
        /*
        List<MaintainPlan> list = this.maintainPlanService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().lt(true, (v0) -> {
            return v0.getMaintainDate();
        }, now).in((v0) -> {
            return v0.getPlanStatus();
        }, Lists.list(new Integer[]{Integer.valueOf(MaintainPlanStatusEnum.T1.getType()), Integer.valueOf(MaintainPlanStatusEnum.T2.getType())}))).in((v0) -> {
            return v0.getId();
        }, businessIds));
        }, businessIds));*/
        if (Func.isEmpty(list)) {
            return ReturnT.SUCCESS;
        }
        for (MaintainPlan maintainPlan : list) {
            Long id = maintainPlan.getId();
            List<BusinessNotifyState> states = mapByBusinessId.get(id);
            List<Long> empIds = (List) states.stream().filter(item -> {
            List<Long> empIds = states.stream().filter(item -> {
                return Func.equals(item.getPersonType(), Integer.valueOf(ObjectTypeEnum.EMP.getCode()));
            }).map((v0) -> {
                return v0.getPersonId();
            }).collect(Collectors.toList());
            List<Long> empIds2 = (List) empIds.stream().distinct().collect(Collectors.toList());
            List<Long> orgIds = (List) states.stream().filter(item2 -> {
            List<Long> empIds2 = empIds.stream().distinct().collect(Collectors.toList());
            List<Long> orgIds = states.stream().filter(item2 -> {
                return Func.equals(item2.getPersonType(), Integer.valueOf(ObjectTypeEnum.ORG.getCode()));
            }).map((v0) -> {
                return v0.getPersonId();
            }).collect(Collectors.toList());
            businessSend.sendMessage(maintainPlan, NotifyBusinessSendDTO.builder().empIds(empIds2).orgIds((List) orgIds.stream().distinct().collect(Collectors.toList())).build());
            businessSend.sendMessage(maintainPlan, NotifyBusinessSendDTO.builder().empIds(empIds2).orgIds(orgIds.stream().distinct().collect(Collectors.toList())).build());
        }
        XxlJobLogger.log("定时发送成功,:{}", new Object[]{now});
        return ReturnT.SUCCESS;
@@ -183,24 +101,33 @@
    private List<Long> deleteExpireState(Set<Long> businessIds) {
        if (Func.isEmpty(businessIds)) {
            return new ArrayList();
            return new ArrayList<>();
        }
        List<MaintainPlan> deleteStatePlans = this.maintainPlanService.list(Wrappers.<MaintainPlan>lambdaQuery()
              .select( MaintainPlan::getId).in(MaintainPlan::getPlanStatus, Lists.list(new Integer[] { Integer.valueOf(MaintainPlanStatusEnum.T3.getType()),MaintainPlanStatusEnum.T4.getType(), MaintainPlanStatusEnum.T5.getType() }))
              .in(MaintainPlan::getId, businessIds));
        /*
        List<MaintainPlan> deleteStatePlans = this.maintainPlanService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().select(new SFunction[]{(v0) -> {
            return v0.getId();
        }}).in((v0) -> {
            return v0.getPlanStatus();
        }, Lists.list(new Integer[]{Integer.valueOf(MaintainPlanStatusEnum.T3.getType()), Integer.valueOf(MaintainPlanStatusEnum.T4.getType()), Integer.valueOf(MaintainPlanStatusEnum.T5.getType())}))).in((v0) -> {
            return v0.getId();
        }, businessIds));
        }, businessIds));*/
        if (Func.isEmpty(deleteStatePlans)) {
            return new ArrayList();
            return new ArrayList<>();
        }
        List<Long> waitDeleteBusinessIds = deleteStatePlans.stream().map(MaintainPlan::getId).collect(Collectors.toList());
        /*
        List<Long> waitDeleteBusinessIds = (List) deleteStatePlans.stream().map((v0) -> {
            return v0.getId();
        }).collect(Collectors.toList());
        }).collect(Collectors.toList());*/
        this.businessNotifyStateService.remove(Wrappers.<BusinessNotifyState>lambdaQuery().in(BusinessNotifyState::getBusinessId, waitDeleteBusinessIds));
        /*
        this.businessNotifyStateService.remove((Wrapper) Wrappers.lambdaQuery().in((v0) -> {
            return v0.getBusinessId();
        }, waitDeleteBusinessIds));
        }, waitDeleteBusinessIds));*/
        return waitDeleteBusinessIds;
    }
@@ -211,7 +138,7 @@
        LocalDateTime now = LocalDateTime.now();
        BusinessSend businessSend = this.businessSendFactory.getBusinessSend(NotifyConstant.MAINTENANCE_WARNING);
        List<BusinessNotifyState> businessNotifyStates = this.businessNotifyStateService.listByBusinessKey(NotifyConstant.MAINTENANCE_WARNING);
        Map<Long, List<BusinessNotifyState>> businessStateMap = (Map) businessNotifyStates.stream().collect(Collectors.groupingBy((v0) -> {
        Map<Long, List<BusinessNotifyState>> businessStateMap = businessNotifyStates.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getBusinessId();
        }));
        Set<Long> businessIds = businessStateMap.keySet();
@@ -219,19 +146,25 @@
            return ReturnT.SUCCESS;
        }
        List<Long> expireIds = deleteExpireState(businessIds);
        expireIds.forEach(businessIds::remove);
        /*
        businessIds.getClass();
        expireIds.forEach((v1) -> {
            r1.remove(v1);
        });
        });*/
        List<MaintainPlan> list = this.maintainPlanService.list(Wrappers.<MaintainPlan>lambdaQuery()
                .in(MaintainPlan::getPlanStatus, Lists.list(new Integer[] {MaintainPlanStatusEnum.T1.getType(), MaintainPlanStatusEnum.T2.getType() }))
                .in(MaintainPlan::getId, businessIds));
        /*
        List<MaintainPlan> list = this.maintainPlanService.list((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().in((v0) -> {
            return v0.getPlanStatus();
        }, Lists.list(new Integer[]{Integer.valueOf(MaintainPlanStatusEnum.T1.getType()), Integer.valueOf(MaintainPlanStatusEnum.T2.getType())}))).in((v0) -> {
            return v0.getId();
        }, businessIds));
        }, businessIds));*/
        if (Func.isEmpty(list)) {
            return ReturnT.SUCCESS;
        }
        Map<Integer, List<MaintainPlan>> planMap = (Map) list.stream().collect(Collectors.groupingBy((v0) -> {
        Map<Integer, List<MaintainPlan>> planMap =list.stream().collect(Collectors.groupingBy((v0) -> {
            return v0.getIsAuto();
        }));
        if (planMap.containsKey(Integer.valueOf(MaintainGenerateEnum.T0.getType()))) {
@@ -246,13 +179,13 @@
        }
        if (planMap.containsKey(Integer.valueOf(MaintainGenerateEnum.T1.getType()))) {
            List<MaintainPlan> maintainPlans = planMap.get(Integer.valueOf(MaintainGenerateEnum.T1.getType()));
            List<Long> projectIds = (List) maintainPlans.stream().map((v0) -> {
            List<Long> projectIds = maintainPlans.stream().map((v0) -> {
                return v0.getProjectId();
            }).filter((v0) -> {
                return Func.isNotEmpty(v0);
            }).collect(Collectors.toList());
            List<MaintainProject> maintainProjects = this.maintainProjectService.listByIds(projectIds);
            Map<Long, MaintainProject> projectMap = (Map) maintainProjects.stream().collect(Collectors.toMap((v0) -> {
            Map<Long, MaintainProject> projectMap = maintainProjects.stream().collect(Collectors.toMap((v0) -> {
                return v0.getId();
            }, item -> {
                return item;
@@ -273,12 +206,12 @@
        for (MaintainPlan maintainPlan : waitSends) {
            Long id = maintainPlan.getId();
            List<BusinessNotifyState> states = businessStateMap.get(id);
            List<Long> empIds = (List) states.stream().filter(item2 -> {
            List<Long> empIds = states.stream().filter(item2 -> {
                return Func.equals(item2.getPersonType(), Integer.valueOf(ObjectTypeEnum.EMP.getCode()));
            }).map((v0) -> {
                return v0.getPersonId();
            }).collect(Collectors.toList());
            List<Long> orgIds = (List) states.stream().filter(item3 -> {
            List<Long> orgIds = states.stream().filter(item3 -> {
                return Func.equals(item3.getPersonType(), Integer.valueOf(ObjectTypeEnum.ORG.getCode()));
            }).map((v0) -> {
                return v0.getPersonId();