PC
2024-03-31 8c9ba6667b89cc0494d05b5da4355dde205b8d4a
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
package com.qianwen.smartman.modules.notify.service.impl;
 
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.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.stream.Collectors;
import com.qianwen.core.mp.base.BaseServiceImpl;
import com.qianwen.core.tool.utils.Func;
import com.qianwen.smartman.modules.cps.entity.CommonGroup;
import com.qianwen.smartman.modules.cps.entity.Employee;
import com.qianwen.smartman.modules.cps.service.ICommonGroupService;
import com.qianwen.smartman.modules.cps.service.IEmployeeService;
import com.qianwen.smartman.modules.notify.convert.BusinessNotifyStateConvert;
import com.qianwen.smartman.modules.notify.dto.BusinessNotifyStateDTO;
import com.qianwen.smartman.modules.notify.entity.BusinessNotifyState;
import com.qianwen.smartman.modules.notify.enums.ObjectTypeEnum;
import com.qianwen.smartman.modules.notify.mapper.BusinessNotifyStateMapper;
import com.qianwen.smartman.modules.notify.service.IBusinessNotifyStateService;
import com.qianwen.smartman.modules.notify.vo.BusinessNotifyStateVO;
import com.qianwen.smartman.modules.sync.constant.DingConstant;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
 
@Service
/* loaded from: blade-api.jar:BOOT-INF/classes/org/springblade/modules/notify/service/impl/BusinessNotifyStateServiceImpl.class */
public class BusinessNotifyStateServiceImpl extends BaseServiceImpl<BusinessNotifyStateMapper, BusinessNotifyState> implements IBusinessNotifyStateService {
    @Autowired
    private IEmployeeService employeeService;
    @Autowired
    private ICommonGroupService commonGroupService;
 
    private static /* synthetic */ Object $deserializeLambda$(SerializedLambda lambda) {
        String implMethodName = lambda.getImplMethodName();
        boolean z = true;
        switch (implMethodName.hashCode()) {
            case -1492577373:
                if (implMethodName.equals("getGroupType")) {
                    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 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/notify/entity/BusinessNotifyState") && 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/BusinessNotifyState") && 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/BusinessNotifyState") && lambda.getImplMethodSignature().equals("()Ljava/lang/Long;")) {
                    return (v0) -> {
                        return v0.getBusinessId();
                    };
                }
                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/modules/cps/entity/CommonGroup") && 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/cps/entity/CommonGroup") && lambda.getImplMethodSignature().equals("()Ljava/lang/String;")) {
                    return (v0) -> {
                        return v0.getGroupType();
                    };
                }
                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/cps/entity/CommonGroup") && lambda.getImplMethodSignature().equals("()Ljava/lang/Integer;")) {
                    return (v0) -> {
                        return v0.getStatus();
                    };
                }
                break;
        }
        throw new IllegalArgumentException("Invalid lambda deserialization");
    }
 
    @Override // org.springblade.modules.notify.service.IBusinessNotifyStateService
    public List<BusinessNotifyState> listByBusinessKey(String businessKey) {
        return listByBusinessKeyAndBusinessId(businessKey, null);
    }
 
    @Override // org.springblade.modules.notify.service.IBusinessNotifyStateService
    public BusinessNotifyStateVO getByBusinessKeyAndBusinessId(String businessKey, Long businessId) {
        List<BusinessNotifyState> states = listByBusinessKeyAndBusinessId(businessKey, businessId);
        return buildBusinessNotifyStateVO(states);
    }
 
    private BusinessNotifyStateVO buildBusinessNotifyStateVO(List<BusinessNotifyState> states) {
        BusinessNotifyStateVO stateVO = new BusinessNotifyStateVO();
        Map<Integer, Set<Long>> notifyStateMap = (Map) states.parallelStream().collect(Collectors.groupingBy((v0) -> {
            return v0.getPersonType();
        }, Collectors.mapping((v0) -> {
            return v0.getPersonId();
        }, Collectors.toSet())));
        if (notifyStateMap.containsKey(Integer.valueOf(ObjectTypeEnum.EMP.getCode()))) {
            Set<Long> ids = notifyStateMap.get(Integer.valueOf(ObjectTypeEnum.EMP.getCode()));
            List<Employee> employees = this.employeeService.listByIds(ids);
            List<BusinessNotifyStateDTO> stateDTOS = BusinessNotifyStateConvert.INSTANCE.convertByEmpList(employees);
            stateVO.setEmpList(stateDTOS);
        }
        if (notifyStateMap.containsKey(Integer.valueOf(ObjectTypeEnum.ORG.getCode()))) {
            Set<Long> ids2 = notifyStateMap.get(Integer.valueOf(ObjectTypeEnum.ORG.getCode()));
            List<CommonGroup> list = this.commonGroupService.list((Wrapper) ((LambdaQueryWrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
                return v0.getStatus();
            }, true)).in((v0) -> {
                return v0.getId();
            }, ids2)).eq((v0) -> {
                return v0.getGroupType();
            }, DingConstant.GROUPTYPE));
            List<BusinessNotifyStateDTO> stateDTOS2 = BusinessNotifyStateConvert.INSTANCE.convertByOrgList(list);
            stateVO.setOrgList(stateDTOS2);
        }
        return stateVO;
    }
 
    private List<BusinessNotifyState> listByBusinessKeyAndBusinessId(String businessKey, Long businessId) {
        boolean notEmpty = Func.isNotEmpty(businessId);
        return list(((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
            return v0.getBusinessKey();
        }, businessKey)).eq(notEmpty, (v0) -> {
            return v0.getBusinessId();
        }, businessId));
    }
 
    @Override // org.springblade.modules.notify.service.IBusinessNotifyStateService
    @Transactional(rollbackFor = {Exception.class})
    public void saveBatchByIds(String businessKey, Long businessId, List<Long> empIds, List<Long> orgIds) {
        deleteListByBusinessId(businessKey, businessId);
        List<BusinessNotifyState> states = new ArrayList<>();
        for (Long empId : empIds) {
            BusinessNotifyState businessNotifyState = new BusinessNotifyState();
            businessNotifyState.setBusinessKey(businessKey);
            businessNotifyState.setPersonId(empId);
            businessNotifyState.setBusinessId(businessId);
            businessNotifyState.setPersonType(Integer.valueOf(ObjectTypeEnum.EMP.getCode()));
            states.add(businessNotifyState);
        }
        for (Long orgId : orgIds) {
            BusinessNotifyState businessNotifyState2 = new BusinessNotifyState();
            businessNotifyState2.setBusinessKey(businessKey);
            businessNotifyState2.setPersonId(orgId);
            businessNotifyState2.setBusinessId(businessId);
            businessNotifyState2.setPersonType(Integer.valueOf(ObjectTypeEnum.EMP.getCode()));
            states.add(businessNotifyState2);
        }
        saveBatch(states);
    }
 
    void deleteListByBusinessId(String businessKey, Long businessId) {
        remove((Wrapper) ((LambdaQueryWrapper) Wrappers.lambdaQuery().eq((v0) -> {
            return v0.getBusinessKey();
        }, businessKey)).eq((v0) -> {
            return v0.getBusinessId();
        }, businessId));
    }
}