Commit b68a8a78 by ruyun.zhang@suvalue.com

Merge remote-tracking branch 'origin/develop' into develop

parents fe91b30b dccc03bb
...@@ -533,19 +533,24 @@ public ApiResponse DepttypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB ...@@ -533,19 +533,24 @@ public ApiResponse DepttypeDelete([CustomizeValidator(RuleSet = "Delete"), FromB
[HttpPost] [HttpPost]
public ApiResponse GetAccountingList([FromBody] AccoungingRequest request) 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); return new ApiResponse(ResponseType.ParameterError);
var list = _configService.GetAccountingList(request) ?? new List<cof_accounting>(); var result = _configService.GetAccountingList(request);
switch (request.Type) switch (request.Type)
{ {
case 1: case (int)AccountTypeEnum.List: //返回accounting列表
default: //返回accounting列表 default:
return new ApiResponse(ResponseType.OK, "ok", list); return new ApiResponse(ResponseType.OK, AccountTypeEnum.List.ToString(), result);
case 3: //返回核算单元类型
return new ApiResponse(ResponseType.OK, "ok", list.Select(t => new TitleValue { Title = t.UnitType, Value = t.UnitType }).ToDistinct()); case (int)AccountTypeEnum.UnitType: //返回核算单元类型
case 2: //返回核算单元 var unittypes = result.Select(t => new TitleValue { Title = t.UnitType, Value = t.UnitType }).ToDistinct();
return new ApiResponse(ResponseType.OK, "ok", list.Select(t => new TitleValue { Title = t.AccountingUnit, Value = t.AccountingUnit }).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 ...@@ -8,7 +8,7 @@ public class AccoungingRequest
public int AllotId { get; set; } public int AllotId { get; set; }
/// <summary> /// <summary>
/// 1 返回accounting列表 2 返回核算单元 3 返回核算单元类型 /// 1 返回accounting列表 2 返回核算单元类型 3 返回核算单元
/// </summary> /// </summary>
public int Type { get; set; } public int Type { get; set; }
...@@ -17,4 +17,13 @@ public class AccoungingRequest ...@@ -17,4 +17,13 @@ public class AccoungingRequest
/// </summary> /// </summary>
public string UnitType { get; set; } public string UnitType { get; set; }
} }
public enum AccountTypeEnum
{
List = 1,
UnitType = 2,
AccountingUnit = 3
}
} }
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
using System.Text; using System.Text;
using Performance.EntityModels.Entity; using Performance.EntityModels.Entity;
using Performance.Repository.Repository; using Performance.Repository.Repository;
using System.Linq.Expressions;
namespace Performance.Services namespace Performance.Services
{ {
...@@ -643,15 +644,11 @@ public bool AgainDelete(CofAgainRequest request) ...@@ -643,15 +644,11 @@ public bool AgainDelete(CofAgainRequest request)
/// <returns></returns> /// <returns></returns>
public List<cof_accounting> GetAccountingList(AccoungingRequest request) public List<cof_accounting> GetAccountingList(AccoungingRequest request)
{ {
switch (request.Type) Expression<Func<cof_accounting, bool>> exp = t => t.AllotId == request.AllotId;
{ if (request.Type == (int)AccountTypeEnum.AccountingUnit && !string.IsNullOrEmpty(request.UnitType))
case 1: //返回accounting列表 exp = exp.And(t => t.UnitType == request.UnitType);
case 3: //返回核算单元类型
default: return cofaccountingRepository.GetEntities(exp) ?? new List<cof_accounting>();
return cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId);
case 2: //返回核算单元
return cofaccountingRepository.GetEntities(t => t.AllotId == request.AllotId && t.UnitType == request.UnitType);
}
} }
/// <summary> /// <summary>
...@@ -743,7 +740,7 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request) ...@@ -743,7 +740,7 @@ public bool BatchSaveAccounting(int allotId, SaveCollectData request)
if (!unitType.Contains(data?.UnitType) && !string.IsNullOrEmpty(data?.UnitType)) return false; if (!unitType.Contains(data?.UnitType) && !string.IsNullOrEmpty(data?.UnitType)) return false;
if (getAccounts != null) 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); var any = accounts.Any(t => t.AccountingUnit == data?.AccountingUnit && t.UnitType == data?.UnitType);
if (!string.IsNullOrEmpty(data.AccountingUnit) && !string.IsNullOrEmpty(data.UnitType) && !any) 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