|  | @@ -12,6 +12,7 @@ using OASystem.Domain.Entities.PersonnelModule;
 | 
	
		
			
				|  |  |  using OASystem.Domain.ViewModels.PersonnelModule;
 | 
	
		
			
				|  |  |  using OASystem.Domain.ViewModels.QiYeWeChat;
 | 
	
		
			
				|  |  |  using OASystem.Infrastructure.Repositories.PersonnelModule;
 | 
	
		
			
				|  |  | +using System.Collections;
 | 
	
		
			
				|  |  |  using System.Data;
 | 
	
		
			
				|  |  |  using System.Diagnostics;
 | 
	
		
			
				|  |  |  using System.Globalization;
 | 
	
	
		
			
				|  | @@ -32,6 +33,7 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |          private readonly WageSheetRepository _wageSheetRep;
 | 
	
		
			
				|  |  |          private readonly UsersRepository _usersRep;
 | 
	
		
			
				|  |  |          private readonly TaskAllocationRepository _taskAllocationRep;
 | 
	
		
			
				|  |  | +        private readonly SqlSugarClient _sqlSugar;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          private readonly IHubContext<ChatHub, IChatClient> _hubContext;
 | 
	
		
			
				|  |  |          private readonly GoodsRepository _goodsRep;
 | 
	
	
		
			
				|  | @@ -48,13 +50,15 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |          /// <param name="taskAllocationRep"></param>
 | 
	
		
			
				|  |  |          /// <param name="hubContext"></param>
 | 
	
		
			
				|  |  |          /// <param name="goodsRep"></param>
 | 
	
		
			
				|  |  | +        /// <param name="sqlSugar"></param>
 | 
	
		
			
				|  |  |          public PersonnelModuleController(IQiYeWeChatApiService qiYeWeChatApiService,
 | 
	
		
			
				|  |  |                                           WageSheetRepository wageSheetRep,
 | 
	
		
			
				|  |  |                                           UsersRepository usersRep,
 | 
	
		
			
				|  |  |                                           IMapper mapper,
 | 
	
		
			
				|  |  |                                           TaskAllocationRepository taskAllocationRep,
 | 
	
		
			
				|  |  |                                           IHubContext<ChatHub, IChatClient> hubContext,
 | 
	
		
			
				|  |  | -                                         GoodsRepository goodsRep
 | 
	
		
			
				|  |  | +                                         GoodsRepository goodsRep,
 | 
	
		
			
				|  |  | +                                         SqlSugarClient sqlSugar
 | 
	
		
			
				|  |  |              )
 | 
	
		
			
				|  |  |          {
 | 
	
		
			
				|  |  |              _mapper = mapper;
 | 
	
	
		
			
				|  | @@ -63,6 +67,8 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |              _wageSheetRep = wageSheetRep;
 | 
	
		
			
				|  |  |              _result = new Result();
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +            _sqlSugar = sqlSugar;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |              url = AppSettingsHelper.Get("ExcelBaseUrl");
 | 
	
		
			
				|  |  |              path = AppSettingsHelper.Get("ExcelBasePath");
 | 
	
		
			
				|  |  |              if (!System.IO.Directory.Exists(path))
 | 
	
	
		
			
				|  | @@ -2038,5 +2044,109 @@ namespace OASystem.API.Controllers
 | 
	
		
			
				|  |  |              return Ok(await _goodsRep.GoodsReceiveDel(id, currUserInfo.UserId));
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  |          #endregion
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        #region 员工绩效
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        /// <summary>
 | 
	
		
			
				|  |  | +        /// 员工绩效组成结构获取
 | 
	
		
			
				|  |  | +        /// </summary>
 | 
	
		
			
				|  |  | +        /// <param name="userid"></param>
 | 
	
		
			
				|  |  | +        /// <returns></returns>
 | 
	
		
			
				|  |  | +        [HttpGet]
 | 
	
		
			
				|  |  | +        public IActionResult GetPerformanceList(int userid)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var jw = JsonView(false);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            string sql_CTE = @"-- 定义递归查询的CTE
 | 
	
		
			
				|  |  | +WITH PerAssessmentSettingsCTE AS (
 | 
	
		
			
				|  |  | +    -- 选择指定ID的记录作为起点
 | 
	
		
			
				|  |  | +    SELECT
 | 
	
		
			
				|  |  | +        pac.Id,
 | 
	
		
			
				|  |  | +        pac.Name,
 | 
	
		
			
				|  |  | +        pac.AssessmentProportion,
 | 
	
		
			
				|  |  | +        pac.AssessmentStandard,
 | 
	
		
			
				|  |  | +        pac.ParentId,
 | 
	
		
			
				|  |  | +        1 AS Depth
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +    FROM
 | 
	
		
			
				|  |  | +        Per_AssessmentSetting pac 
 | 
	
		
			
				|  |  | +    INNER JOIN
 | 
	
		
			
				|  |  | +    	Per_AssessmentContentSetting pacs 
 | 
	
		
			
				|  |  | +    ON 
 | 
	
		
			
				|  |  | +    	pac.id = pacs.assessmentSettingid AND  pacs.isdel = 0
 | 
	
		
			
				|  |  | +    	
 | 
	
		
			
				|  |  | +    WHERE
 | 
	
		
			
				|  |  | +        pacs.userid = 302
 | 
	
		
			
				|  |  | +	AND  
 | 
	
		
			
				|  |  | +		pac.isdel = 0
 | 
	
		
			
				|  |  | +        
 | 
	
		
			
				|  |  | +    UNION ALL
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +    -- 递归部分,选择所有子级记录
 | 
	
		
			
				|  |  | +    SELECT
 | 
	
		
			
				|  |  | +        ps.Id,
 | 
	
		
			
				|  |  | +        ps.Name,
 | 
	
		
			
				|  |  | +        ps.AssessmentProportion,
 | 
	
		
			
				|  |  | +        ps.AssessmentStandard,
 | 
	
		
			
				|  |  | +        ps.ParentId,
 | 
	
		
			
				|  |  | +        CAST(caste.Depth as int) + 1
 | 
	
		
			
				|  |  | +    FROM
 | 
	
		
			
				|  |  | +        Per_AssessmentSetting ps 
 | 
	
		
			
				|  |  | +    	
 | 
	
		
			
				|  |  | +    INNER JOIN PerAssessmentSettingsCTE caste ON ps.Id  = caste.ParentId)
 | 
	
		
			
				|  |  | +                                             
 | 
	
		
			
				|  |  | +                                             
 | 
	
		
			
				|  |  | +-- 从CTE中选择最终结果
 | 
	
		
			
				|  |  | +SELECT * FROM PerAssessmentSettingsCTE
 | 
	
		
			
				|  |  | +OPTION (MAXRECURSION 0); -- 允许无限递归      ";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            var result_CTE =  _sqlSugar.Ado.SqlQuery<Per_AssessmentSetting>(sql_CTE);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            var ids = result_CTE.Select(x => x.Id);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            var List = _sqlSugar.Queryable<Per_AssessmentSetting>()
 | 
	
		
			
				|  |  | +                        .LeftJoin<Per_AssessmentContentSetting>((a, b) => a.Id == b.AssessmentSettingId && b.IsDel == 0)
 | 
	
		
			
				|  |  | +                        .Where((a, b) => a.IsDel == 0 && ids.Contains(a.Id))
 | 
	
		
			
				|  |  | +                        .Select((a, b) => new TreeNode
 | 
	
		
			
				|  |  | +                        {
 | 
	
		
			
				|  |  | +                            Id = a.Id,
 | 
	
		
			
				|  |  | +                            Name = a.Name,
 | 
	
		
			
				|  |  | +                            ParentId = a.ParentId,
 | 
	
		
			
				|  |  | +                            AssessmentProportion = a.AssessmentProportion, //占比
 | 
	
		
			
				|  |  | +                            AssessmentStandard = a.AssessmentStandard, //描述
 | 
	
		
			
				|  |  | +                            AssessmentProportionChi = b.AssessmentProportionChi, //占比
 | 
	
		
			
				|  |  | +                            UserId = b.UserId,
 | 
	
		
			
				|  |  | +                            JobId = b.JobId,
 | 
	
		
			
				|  |  | +                            AssessmentSettingId = b.AssessmentSettingId,
 | 
	
		
			
				|  |  | +                            Fixed = b.Fixed,
 | 
	
		
			
				|  |  | +                            TargetValue = b.TargetValue,
 | 
	
		
			
				|  |  | +                            AssessmentProportion_Percentage = a.AssessmentProportion * 100
 | 
	
		
			
				|  |  | +                        })
 | 
	
		
			
				|  |  | +                        .ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            var rootNodeList = List.Where(x => x.ParentId == 0);
 | 
	
		
			
				|  |  | +            var rootResult = rootNodeList.Select(x => BuildSubTree(x, List));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            jw.Data = rootResult;
 | 
	
		
			
				|  |  | +            jw.Code = 200;
 | 
	
		
			
				|  |  | +            jw.Msg = "成功";
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            return Ok(jw);
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        private TreeNode BuildSubTree(TreeNode parent, List<TreeNode> nodes)
 | 
	
		
			
				|  |  | +        {
 | 
	
		
			
				|  |  | +            var children = nodes
 | 
	
		
			
				|  |  | +                .Where(n => n.ParentId == parent.Id)
 | 
	
		
			
				|  |  | +                .Select(n => BuildSubTree(n, nodes))
 | 
	
		
			
				|  |  | +                .ToList();
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +            parent.Children = children;
 | 
	
		
			
				|  |  | +            return parent;
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        #endregion
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |