Commit d9945f8a by lcx

核算单元修改

parent 11c4b9c9
......@@ -533,19 +533,24 @@ public ApiResponse DepttypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB
[HttpPost]
public ApiResponse GetAccountingList([FromBody] AccoungingRequest request)
{
if (request.AllotId == 0 || !new int[] { 1, 2, 3 }.Contains(request.Type))
var enumItems = EnumHelper.GetItems<AccountTypeEnum>();
if (request.AllotId == 0 || !enumItems.Select(t => t.Value).Contains(request.Type))
return new ApiResponse(ResponseType.ParameterError);
var list = _configService.GetAccountingList(request) ?? new List<cof_accounting>();
var result = _configService.GetAccountingList(request);
switch (request.Type)
{
case 1:
default: //返回accounting列表
return new ApiResponse(ResponseType.OK, "ok", list);
case 3: //返回核算单元类型
return new ApiResponse(ResponseType.OK, "ok", list.Select(t => new TitleValue { Title = t.UnitType, Value = t.UnitType }).ToDistinct());
case 2: //返回核算单元
return new ApiResponse(ResponseType.OK, "ok", list.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct());
case (int)AccountTypeEnum.List: //返回accounting列表
default:
return new ApiResponse(ResponseType.OK, AccountTypeEnum.List.ToString(), result);
case (int)AccountTypeEnum.UnitType: //返回核算单元类型
var unittypes = result.Select(t => new TitleValue { Title = t.UnitType, Value = t.UnitType }).ToDistinct();
return new ApiResponse(ResponseType.OK, AccountTypeEnum.UnitType.ToString(), unittypes);
case (int)AccountTypeEnum.AccountingUnit: //返回核算单元
var accountingunits = result.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).ToDistinct();
return new ApiResponse(ResponseType.OK, AccountTypeEnum.AccountingUnit.ToString(), accountingunits);
}
}
......
......@@ -8,7 +8,7 @@ public class AccoungingRequest
public int AllotId { get; set; }
/// <summary>
/// 1 返回accounting列表 2 返回核算单元 3 返回核算单元类型
/// 1 返回accounting列表 2 返回核算单元类型 3 返回核算单元
/// </summary>
public int Type { get; set; }
......@@ -17,4 +17,13 @@ public class AccoungingRequest
/// </summary>
public string UnitType { get; set; }
}
public enum AccountTypeEnum
{
List = 1,
UnitType = 2,
AccountingUnit = 3
}
}
......@@ -11,6 +11,7 @@
using System.Text;
using Performance.EntityModels.Entity;
using Performance.Repository.Repository;
using System.Linq.Expressions;
namespace Performance.Services
{
......@@ -643,15 +644,11 @@ public bool AgainDelete(CofAgainRequest request)
/// <returns></returns>
public List<cof_accounting> GetAccountingList(AccoungingRequest request)
{
switch (request.Type)
{
case 1: //返回accounting列表
case 3: //返回核算单元类型
default:
return cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId);
case 2: //返回核算单元
return cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId && t.UnitType == request.UnitType);
}
Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == request.AllotId;
if (request.Type == (int)AccountTypeEnum.AccountingUnit && !string.IsNullOrEmpty(request.UnitType))
exp = exp.And(t => t.UnitType == request.UnitType);
return cofaccountingRepository.GetEntities(exp) ?? new List<cof_accounting>();
}
/// <summary>
......@@ -743,7 +740,7 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
if (!unitType.Contains(data?.UnitType) && !string.IsNullOrEmpty(data?.UnitType)) return false;
if (getAccounts != null)
if (getAccounts.Any(t => t.AccountingUnit == data?.AccountingUnit && t.UnitType == data?.UnitType))continue;
if (getAccounts.Any(t => t.AccountingUnit == data?.AccountingUnit && t.UnitType == data?.UnitType)) continue;
var any = accounts.Any(t => t.AccountingUnit == data?.AccountingUnit && t.UnitType == data?.UnitType);
if (!string.IsNullOrEmpty(data.AccountingUnit) && !string.IsNullOrEmpty(data.UnitType) && !any)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment