From 8edf84f622a05dbaae9e3a1f8473c78865585245 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BD=95=E7=BE=8E=E8=8D=A3?= <10755671+mei-rong-he@user.noreply.gitee.com> Date: Mon, 10 Nov 2025 14:50:35 +0800 Subject: [PATCH] =?UTF-8?q?=E7=8F=AD=E7=BB=84=E5=8F=8A=E4=BA=BA=E5=91=98?= =?UTF-8?q?=E5=90=8C=E6=AD=A5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Controllers/Api/FMController.cs | 65 ++++++++++++++++++- 1 file changed, 64 insertions(+), 1 deletion(-) diff --git a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FMController.cs b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FMController.cs index 872d8c4..41a409e 100644 --- a/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FMController.cs +++ b/APT.MicroApi/APT.PP.WebApi/Controllers/Api/FMController.cs @@ -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 { @@ -1444,8 +1445,70 @@ namespace APT.PP.WebApi.Controllers.Api.PP } return true; }); + } + [HttpPost, Route("UserPersonSync")] + public JsonActionResult UserPersonSync([FromBody] KeywordPageFilter pageFilter) + { + return SafeExecute(() => + { + 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 => !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 => !t.IS_DELETED && t.ENABLE_STATUS == 0 && !t.CODE.Contains("admin") && t.DEPARTMENT_ID != null && depatIds.Contains((Guid)t.DEPARTMENT_ID), baseFilter).ToList(); + List teamInfos = new List(); + List teamPersons = new List(); + 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、隐患原因分析统计 功能需求 按 年度统计