增加组织调整功能
This commit is contained in:
parent
2537e129af
commit
0eeb6b4633
@ -1,18 +1,27 @@
|
||||
using APT.BaseData.Domain.IServices;
|
||||
using APT.BaseData.Domain.Enums.PF;
|
||||
using APT.BaseData.Domain.IServices;
|
||||
using APT.BaseData.Domain.IServices.OP;
|
||||
using APT.BaseData.Services.Services.OP;
|
||||
using APT.Infrastructure.Core;
|
||||
using APT.Migrations;
|
||||
using APT.MS.Domain.Entities.SK;
|
||||
using APT.Utility;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using APT.Utility;
|
||||
using System.Linq.Expressions;
|
||||
using System;
|
||||
|
||||
namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
{
|
||||
[Route("api/FM/Organization")]
|
||||
public class OrganizationController : AuthorizeTreeApiController<T_FM_ORGANIZATION>
|
||||
{
|
||||
|
||||
{
|
||||
IOPTenantDBConnService OPTenantDBConnService { get; set; }
|
||||
public OrganizationController(IOPTenantDBConnService opTenantDBConnService)
|
||||
{
|
||||
OPTenantDBConnService = opTenantDBConnService;
|
||||
}
|
||||
/// <summary>
|
||||
/// 查询
|
||||
/// </summary>
|
||||
@ -188,6 +197,38 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
filter.OrgId = null;
|
||||
filter.IgnoreOrgRule = true;
|
||||
return WitEntity(null, filter);
|
||||
}
|
||||
/// <summary>
|
||||
/// 从集团取数据
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("JTOrderEntities")]
|
||||
public JsonActionResult<IEnumerable<T_FM_ORGANIZATION>> JTOrderEntities([FromBody] KeywordFilter filter)
|
||||
{
|
||||
var orgId = filter.OrgId;
|
||||
filter.OrgId = null;
|
||||
filter.IgnoreOrgRule = true;
|
||||
var result = new JsonActionResult<IEnumerable<T_FM_ORGANIZATION>>();
|
||||
string strConn = OPTenantDBConnService.GetConnByORGID(new Guid(FilePathHead.JY.GetDescription()));
|
||||
Dictionary<string, DbOrder> orders = new Dictionary<string, DbOrder>();
|
||||
orders.Add("CREATE_TIME", DbOrder.DESC);
|
||||
using (var context = new MigrationContext(strConn))
|
||||
{
|
||||
Expression<Func<T_FM_ORGANIZATION, bool>> expression = t => true;
|
||||
var parentRule = filter.FilterGroup.Rules.FirstOrDefault(i => i.Field == "PARENT_ID");
|
||||
if (parentRule != null && string.IsNullOrEmpty(parentRule.Value.ToString()))
|
||||
{
|
||||
expression = expression.And(i => i.ID == orgId);
|
||||
}
|
||||
var temps = context.GetOrderEntities(expression, orders, null);
|
||||
if (temps != null && temps.Any())
|
||||
{
|
||||
result.Data = temps.ToList();
|
||||
result.TotalCount = result.Data.Count();
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1557,6 +1557,50 @@ namespace APT.FM.WebApi.Controllers.Api.FM
|
||||
throw new Exception("组织架构错误,请联系管理员");
|
||||
return user;
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新用户公司
|
||||
/// </summary>
|
||||
/// <param name="filter"></param>
|
||||
/// <returns></returns>
|
||||
[HttpPost, Route("ChangeCompany")]
|
||||
public JsonActionResult<bool> ChangeCompany([FromBody] KeywordFilter filter)
|
||||
{
|
||||
return SafeExecute<bool>(() =>
|
||||
{
|
||||
var userID = filter.Keyword;
|
||||
var userIDGUID = new Guid(userID);
|
||||
var OrgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
||||
BaseFilter BaseFilter = new BaseFilter(OrgId);
|
||||
var user = this.GetEntity<T_FM_USER>(userID);
|
||||
if (!string.IsNullOrEmpty(filter.Parameter1))
|
||||
{
|
||||
var orgIDGUID = new Guid(filter.Parameter1);
|
||||
using (var context = new MigrationContext(ConfigurationManager.ConnectionStrings["default"]))
|
||||
{
|
||||
var allUser = context.GetEntity<T_OP_ALLUSER>(t => t.CODE == user.CODE, new string[] { "ID,CODE,ORG_ID,TENANT" });
|
||||
if (allUser != null)
|
||||
{
|
||||
allUser.TENANT = filter.Parameter1.Substring(0,3);
|
||||
allUser.ORG_ID = orgIDGUID;
|
||||
context.UpdateEntity(allUser);
|
||||
context.SaveChanges();
|
||||
}
|
||||
}
|
||||
user.ENABLE_STATUS = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new Exception("请先选择公司");
|
||||
}
|
||||
this.UnifiedCommit(() =>
|
||||
{
|
||||
this.UpdateEntityNoCommit(user);
|
||||
|
||||
});
|
||||
return true;
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user