148 lines
5.5 KiB
C#
148 lines
5.5 KiB
C#
using APT.BaseData.Domain.Entities;
|
||
using APT.BaseData.Domain.Entities.FM;
|
||
using APT.BaseData.Domain.IServices.FM;
|
||
using APT.Infrastructure.Core;
|
||
using APT.MS.Domain.Entities.BS;
|
||
using APT.MS.Domain.Enums;
|
||
using APT.Utility;
|
||
using APT.WebApi.Models;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
|
||
namespace APT.BS.WebApi.Controllers.Api
|
||
{
|
||
[Route("api/BS/BSPlanSet")]
|
||
public partial class BSPlanSetController : AuthorizeApiController<T_BS_PLAN_SET>
|
||
{
|
||
/// <summary>
|
||
/// 排序分页查询数据
|
||
/// </summary>
|
||
/// <param name="pageFilter">分页过滤实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("OrderPagedDescription")]
|
||
public PagedActionResult<T_BS_PLAN_SET> OrderPagedDescription([FromBody] KeywordPageFilter pageFilter)
|
||
{
|
||
//return SafeGetPagedData<bool>(() =>
|
||
//{
|
||
|
||
//});
|
||
pageFilter.IgnoreDataRule = true;
|
||
//参考 NotificationTask
|
||
var result = this.GetOrderPageEntities<T_BS_PLAN_SET>(null, pageFilter);
|
||
if (result.TotalCount > 0)
|
||
{
|
||
List<T_BS_PLAN_SET> listCHECK_TYPE_LEVEL = result.Data.ToList();
|
||
//foreach (var item in listCHECK_TYPE_LEVEL)
|
||
//{
|
||
// item.Nav_CheckTypeLevel.CheckLevelDescription = ((MS.Domain.Enums.HMLevleEnum)item.Nav_CheckTypeLevel.CheckLevel).GetDescription();
|
||
//}
|
||
result.Data = listCHECK_TYPE_LEVEL;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 获得单条实体数据
|
||
/// </summary>
|
||
/// <param name="filter">过滤实体</param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("GetInfo")]
|
||
public JsonActionResult<T_BS_PLAN_SET> Get([FromBody] KeywordFilter filter)
|
||
{
|
||
//this.ActionOrderEntities(null, filter);
|
||
//this.GetEntities(null,filter);
|
||
JsonActionResult<T_BS_PLAN_SET> result = WitEntity(null, filter);
|
||
try
|
||
{
|
||
//result.Data.Nav_CheckTypeLevel.CheckLevelDescription = ((HMLevleEnum)(result.Data.Nav_CheckTypeLevel.CheckLevel)).GetDescription();
|
||
}
|
||
catch
|
||
{
|
||
return result;
|
||
}
|
||
return result;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 更新
|
||
/// </summary>
|
||
/// <param name="entity"></param>
|
||
/// <returns></returns>
|
||
[HttpPost, Route("FullUpdate")]
|
||
public JsonActionResult<bool> FullUpdate([FromBody] T_BS_PLAN_SET entity)
|
||
{
|
||
return SafeExecute<bool>(() =>
|
||
{
|
||
var ListSetObject = entity.Nav_ListSetObject;
|
||
entity.Nav_ListSetObject = null;
|
||
|
||
var ListSetDepObject = entity.Nav_ListSetDepObject;
|
||
entity.Nav_ListSetDepObject = null;
|
||
int rowIndex = 1;
|
||
foreach (var item in ListSetDepObject)
|
||
{
|
||
if (!item.DEPARTMENT_ID.HasValue)
|
||
{
|
||
throw new Exception("请设置部门,行:" + rowIndex + "!");
|
||
}
|
||
rowIndex++;
|
||
}
|
||
|
||
var listDepOut = entity.Nav_ListDepOut;
|
||
entity.Nav_ListDepOut = null;
|
||
if (listDepOut != null && listDepOut.Any())
|
||
{
|
||
foreach (var item in listDepOut)
|
||
item.Nav_Department = null;
|
||
}
|
||
|
||
var listArea = entity.Nav_ListArea;
|
||
entity.Nav_ListArea = null;
|
||
if (listArea != null && listArea.Any())
|
||
{
|
||
foreach (var item in listArea)
|
||
item.Nav_Area = null;
|
||
}
|
||
if (entity.Nav_UserSend != null)
|
||
entity.Nav_UserSend = null;
|
||
if (entity.USER_ID_SEND.HasValue)
|
||
{
|
||
if (ListSetDepObject != null && ListSetDepObject.Any())
|
||
{
|
||
if (ListSetDepObject.Count > 1)
|
||
{
|
||
throw new Exception("有设置接收人时,【部门范围】最多只能设置一条信息!");
|
||
}
|
||
else
|
||
{
|
||
foreach (var item in ListSetDepObject)
|
||
{
|
||
if (!item.DEPARTMENT_ID.HasValue)
|
||
{
|
||
throw new Exception("有设置接收人时,【部门范围】得设置对应部门!");
|
||
}
|
||
}
|
||
}
|
||
}
|
||
}
|
||
this.UnifiedCommit(() =>
|
||
{
|
||
if (entity != null)
|
||
UpdateEntityNoCommit(entity);
|
||
if (ListSetObject != null && ListSetObject.Any())
|
||
BantchSaveEntityNoCommit(ListSetObject);
|
||
if (ListSetDepObject != null && ListSetDepObject.Any())
|
||
BantchSaveEntityNoCommit(ListSetDepObject);
|
||
if (listDepOut != null && listDepOut.Any())
|
||
BantchSaveEntityNoCommit(listDepOut);
|
||
if (listArea != null && listArea.Any())
|
||
BantchSaveEntityNoCommit(listArea);
|
||
});
|
||
return true;
|
||
});
|
||
}
|
||
}
|
||
}
|