班组及人员同步
This commit is contained in:
parent
17168d6dfe
commit
8edf84f622
@ -33,6 +33,7 @@ using System.Threading.Tasks;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using APT.WebApi.Models;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using Microsoft.CodeAnalysis.CSharp.Syntax;
|
||||
|
||||
namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
{
|
||||
@ -1445,7 +1446,69 @@ namespace APT.PP.WebApi.Controllers.Api.PP
|
||||
return true;
|
||||
});
|
||||
}
|
||||
[HttpPost, Route("UserPersonSync")]
|
||||
public JsonActionResult<bool> UserPersonSync([FromBody] KeywordPageFilter pageFilter)
|
||||
{
|
||||
return SafeExecute<bool>(() =>
|
||||
{
|
||||
try
|
||||
{
|
||||
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId.Value;
|
||||
BaseFilter baseFilter = new BaseFilter(orgId);
|
||||
baseFilter.SelectField = new string[] { "ID","NAME", "USER_ID" };
|
||||
var depats = this.GetEntities<T_FM_DEPARTMENT>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0 && t.DEPARTMENT_TYPE == (int)FMDepartmentType.Class, baseFilter).ToList();
|
||||
var depatIds = depats.Select(t => t.ID).ToList();
|
||||
baseFilter.SelectField = new string[] { "ID", "DEPARTMENT_ID", "PERSON_ID" };
|
||||
var users = this.GetEntities<T_FM_USER>(t => !t.IS_DELETED && t.ENABLE_STATUS == 0 && !t.CODE.Contains("admin") && t.DEPARTMENT_ID != null && depatIds.Contains((Guid)t.DEPARTMENT_ID), baseFilter).ToList();
|
||||
List<T_FM_TEAM> teamInfos = new List<T_FM_TEAM>();
|
||||
List<T_FM_TEAM_PERSON> teamPersons = new List<T_FM_TEAM_PERSON>();
|
||||
if (depats != null && depats.Any())
|
||||
{
|
||||
foreach (var item in depats)
|
||||
{
|
||||
T_FM_TEAM team = new T_FM_TEAM();
|
||||
team.NAME = item.NAME;
|
||||
team.CHARGE_PERSON_ID = item.USER_ID;
|
||||
team.DEPARTMENT_ID = item.ID;
|
||||
team.ORG_ID = orgId;
|
||||
teamInfos.Add(team);
|
||||
var teamPersonTemps = users.Where(t => t.DEPARTMENT_ID == item.ID && t.PERSON_ID!=null).Select(m=>m.PERSON_ID).ToList();
|
||||
if (teamPersonTemps != null && teamPersonTemps.Any())
|
||||
{
|
||||
foreach (var person in teamPersonTemps)
|
||||
{
|
||||
T_FM_TEAM_PERSON teamPerson = new T_FM_TEAM_PERSON();
|
||||
teamPerson.PERSON_ID = (Guid)person;
|
||||
teamPerson.TEAM_ID = team.ID;
|
||||
teamPerson.ORG_ID = orgId;
|
||||
teamPersons.Add(teamPerson);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
this.UnifiedCommit(() =>
|
||||
{
|
||||
if (teamInfos!=null && teamInfos.Any())
|
||||
{
|
||||
BantchAddEntityNoCommit(teamInfos);
|
||||
}
|
||||
if (teamPersons != null && teamPersons.Any())
|
||||
{
|
||||
BantchAddEntityNoCommit(teamPersons);
|
||||
}
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
if (!string.IsNullOrEmpty(ex.StackTrace))
|
||||
throw new Exception("错误日志:[StackTrace]" + ex.StackTrace);
|
||||
else
|
||||
throw new Exception("【" + HttpContext.Request.Path + "】错误日志:[Message]" + ex.Message);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
}
|
||||
#region wyw 2023 首页
|
||||
|
||||
//1、隐患原因分析统计 功能需求 按 年度统计
|
||||
|
||||
Loading…
Reference in New Issue
Block a user