sunpengfei
2025-08-12 e1441e1a14841f322af3e1ca65490fb8b7993970
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
using FlexJobApi.Core;
using Furion.DatabaseAccessor;
using MediatR;
using Microsoft.EntityFrameworkCore;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace FlexJobApi.FlexJobServer.Application
{
    /// <summary>
    /// 任务人员查询处理器
    /// </summary>
    public class TaskUserQueryHandler(
        IRepository<TaskInfoUser> rep) : 
        IRequestHandler<GetTaskUsersQuery, GetTaskUsersQueryResult>,
        IRequestHandler<GetArrangeTaskUsersQuery, GetArrangeTaskUsersQueryResult>
    {
        private readonly IRepository<TaskInfoUser> rep = rep;
 
        /// <summary>
        /// B端查询应聘报名分页列表信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<GetTaskUsersQueryResult> Handle(GetTaskUsersQuery request, CancellationToken cancellationToken)
        {
            var logier = JwtUtils.GetCurrentLogier();
            var q = rep.AsQueryable().AsNoTracking()
                .OrderBy(it => it.CreatedTime)
                .Where(it => it.TaskInfo.EnterpriseId == logier.EnterpriseId && it.TaskInfoId == request.Id);
            var s = q
                .Select(it => new GetTaskUsersQueryResultItem
                {
                    Id = it.Id,
                    Avatar = it.EnterpriseEmployee.User.Avatar,
                    Name = it.EnterpriseEmployee.User.Name,
                    Identity = it.EnterpriseEmployee.User.Identity,
                    ContactPhoneNumber = it.EnterpriseEmployee.User.ContactPhoneNumber,
                    Gender = it.EnterpriseEmployee.User.Gender,
                    Age = it.EnterpriseEmployee.User.Age,
                    IsReal = it.EnterpriseEmployee.User.IsReal,
                    RealMethod = it.EnterpriseEmployee.User.RealMethod,
                    PersonalIdentityCode = it.EnterpriseEmployee.User.PersonalIdentityCode,
                    PersonalIdentityContent = it.EnterpriseEmployee.User.PersonalIdentity.Content,
                    EducationalBackgroundCode = it.EnterpriseEmployee.User.EducationalBackgroundCode,
                    EducationalBackgroundContent = it.EnterpriseEmployee.User.EducationalBackground.Content,
                    TaskCount = it.EnterpriseEmployee.User.TaskInfoUsers.Count(tu => tu.EnterpriseEmployee.HireStatus == EnumTaskUserHireStatus.Pass),
                    WorkSeniority = it.EnterpriseEmployee.User.WorkSeniority,
                    WorkExperience = it.EnterpriseEmployee.User.WorkExperience,
                    HireStatus = it.EnterpriseEmployee.HireStatus
                });
            return await request.PageModel.GetPagedListAsync<GetTaskUsersQueryResult, GetTaskUsersQueryResultItem>(s, cancellationToken);
        }
 
        /// <summary>
        /// B端查询人员安排分页列表信息
        /// </summary>
        /// <param name="request"></param>
        /// <param name="cancellationToken"></param>
        /// <returns></returns>
        public async Task<GetArrangeTaskUsersQueryResult> Handle(GetArrangeTaskUsersQuery request, CancellationToken cancellationToken)
        {
            var logier = JwtUtils.GetCurrentLogier();
            var q = rep.AsQueryable().AsNoTracking()
                .OrderBy(it => it.CreatedTime)
                .Where(it => 
                    it.TaskInfo.EnterpriseId == logier.EnterpriseId 
                    && it.TaskInfoId == request.Id
                    && it.EnterpriseEmployee.HireStatus == EnumTaskUserHireStatus.Pass
                    && it.EnterpriseEmployee.UserSignContractStatus == EnumTaskUserSignContractStatus.Pass
                    && it.EnterpriseEmployee.EnterpriseSignContractStatus == EnumTaskUserSignContractStatus.Pass);
            if (request.ArrangeStatus.HasValue)
            {
                q = q.Where(it=>it.ArrangeStatus == request.ArrangeStatus);
            }
            if (request.Keywords.IsNotNull())
            {
                q = q.Where(it =>
                    it.EnterpriseEmployee.User.Name.Contains(request.Keywords)
                    || it.EnterpriseEmployee.User.Identity.Contains(request.Keywords)
                    || it.EnterpriseEmployee.User.PhoneNumber.Contains(request.Keywords));
            }
            var s = q
                .Select(it => new GetArrangeTaskUsersQueryResultItem
                {
                    Id = it.Id,
                    Avatar = it.EnterpriseEmployee.User.Avatar,
                    Name = it.EnterpriseEmployee.User.Name,
                    Identity = it.EnterpriseEmployee.User.Identity,
                    ContactPhoneNumber = it.EnterpriseEmployee.User.ContactPhoneNumber,
                    Gender = it.EnterpriseEmployee.User.Gender,
                    Age = it.EnterpriseEmployee.User.Age,
                    IsReal = it.EnterpriseEmployee.User.IsReal,
                    RealMethod = it.EnterpriseEmployee.User.RealMethod,
                    PersonalIdentityCode = it.EnterpriseEmployee.User.PersonalIdentityCode,
                    PersonalIdentityContent = it.EnterpriseEmployee.User.PersonalIdentity.Content,
                    EducationalBackgroundCode = it.EnterpriseEmployee.User.EducationalBackgroundCode,
                    EducationalBackgroundContent = it.EnterpriseEmployee.User.EducationalBackground.Content,
                    TaskCount = it.EnterpriseEmployee.User.TaskInfoUsers.Count(tu => tu.EnterpriseEmployee.HireStatus == EnumTaskUserHireStatus.Pass),
                    WorkSeniority = it.EnterpriseEmployee.User.WorkSeniority,
                    WorkExperience = it.EnterpriseEmployee.User.WorkExperience,
                    ArrangeStatus = it.ArrangeStatus
                });
            return await request.PageModel.GetPagedListAsync<GetArrangeTaskUsersQueryResult, GetArrangeTaskUsersQueryResultItem>(s, cancellationToken);
        }
    }
}