This commit is contained in:
2021-09-02 23:16:59 +00:00
parent 9fe90d5fa9
commit b5544de604
5 changed files with 125 additions and 2 deletions

View File

@@ -8,7 +8,7 @@ namespace AyaNova.DataList
{
public PartInventoryRequestDataList()
{
DefaultListAType = AyaType.PurchaseOrder;
DefaultListAType = AyaType.PartInventoryRequestDataList;
SQLFrom = "from viewworkorder "
+ "left join aworkorderstatus on (viewworkorder.laststatusid = aworkorderstatus.id) "
+ "left join acustomer on (viewworkorder.customerid=acustomer.id) "

View File

@@ -167,7 +167,8 @@ namespace AyaNova.Biz
[CoreBizObject]
PMItemUnit = 88,
PMItemOutsideService = 89,
PartInventoryDataList = 90//for list/reporting only, synthetic object
PartInventoryDataList = 90,//for list/reporting only, synthetic object
PartInventoryRequestDataList = 91//for list/reporting only, synthetic object

View File

@@ -63,6 +63,8 @@ namespace AyaNova.Biz
return new PartInventoryBiz(ct, userId, translationId, roles);
case AyaType.PartInventoryDataList:
return new PartInventoryDataListBiz(ct, userId, translationId, roles);
case AyaType.PartInventoryRequestDataList:
return new PartInventoryRequestDataListBiz(ct, userId, translationId, roles);
case AyaType.Project:

View File

@@ -257,8 +257,24 @@ namespace AyaNova.Biz
Select = AuthorizationRoles.All
});
/////////////////////////////////////////////////////////////////
//PartInventoryRequestDataList
// same as PO
//
roles.Add(AyaType.PartInventoryRequestDataList, new BizRoleSet()
{
Change = AuthorizationRoles.Inventory
| AuthorizationRoles.BizAdmin
| AuthorizationRoles.Accounting,
ReadFullRecord = AuthorizationRoles.Service
| AuthorizationRoles.InventoryRestricted
| AuthorizationRoles.BizAdminRestricted
| AuthorizationRoles.ServiceRestricted,
Select = AuthorizationRoles.All
});
////////////////////////////////////////////////////////////
//Project
//

View File

@@ -0,0 +1,104 @@
using System;
using System.Threading.Tasks;
using Microsoft.EntityFrameworkCore;
using System.Linq;
using AyaNova.Util;
using AyaNova.Api.ControllerHelpers;
using AyaNova.Models;
using Newtonsoft.Json.Linq;
using System.Collections.Generic;
namespace AyaNova.Biz
{
internal class PartInventoryRequestDataListBiz : BizObject, IReportAbleObject, IExportAbleObject
{
internal PartInventoryRequestDataListBiz(AyContext dbcontext, long currentUserId, long userTranslationId, AuthorizationRoles UserRoles)
{
ct = dbcontext;
UserId = currentUserId;
UserTranslationId = userTranslationId;
CurrentUserRoles = UserRoles;
BizType = AyaType.PartInventoryRequestDataList;
}
internal static PartInventoryRequestDataListBiz GetBiz(AyContext ct, Microsoft.AspNetCore.Http.HttpContext httpContext = null)
{
if (httpContext != null)
return new PartInventoryRequestDataListBiz(ct, UserIdFromContext.Id(httpContext.Items), UserTranslationIdFromContext.Id(httpContext.Items), UserRolesFromContext.Roles(httpContext.Items));
else
return new PartInventoryRequestDataListBiz(ct, 1, ServerBootConfig.AYANOVA_DEFAULT_TRANSLATION_ID, AuthorizationRoles.BizAdmin);
}
////////////////////////////////////////////////////////////////////////////////////////////////
//REPORTING
//
public async Task<JArray> GetReportData(DataListSelectedRequest dataListSelectedRequest)
{
var idList = dataListSelectedRequest.SelectedRowIds;
JArray ReportData = new JArray();
while (idList.Any())
{
var batch = idList.Take(IReportAbleObject.REPORT_DATA_BATCH_SIZE);
idList = idList.Skip(IReportAbleObject.REPORT_DATA_BATCH_SIZE).ToArray();
//query for this batch, comes back in db natural order unfortunately
var batchResults = await ct.ViewPartRequestList.AsNoTracking().Where(z => batch.Contains(z.RequestId)).ToArrayAsync();
//order the results back into original
var orderedList = from id in batch join z in batchResults on id equals z.RequestId select z;
//cache frequent viz data
var AyaTypesEnumList = await AyaNova.Api.Controllers.EnumListController.GetEnumList(
StringUtil.TrimTypeName(typeof(AyaType).ToString()),
UserTranslationId,
CurrentUserRoles);
// using (var command = ct.Database.GetDbConnection().CreateCommand())
// {
// ct.Database.OpenConnection();
foreach (ViewPartRequestList w in orderedList)
{
//await PopulateVizFields(w, AyaTypesEnumList, command);
var jo = JObject.FromObject(w);
ReportData.Add(jo);
}
//}
}
return ReportData;
}
// //populate viz fields from provided object
// private async Task PopulateVizFields(VPartInventoryList o, List<NameIdItem> ayaTypesEnumList, System.Data.Common.DbCommand cmd)
// {
// o.PartViz = await ct.Part.AsNoTracking().Where(x => x.Id == o.PartId).Select(x => x.PartNumber).FirstOrDefaultAsync();
// o.PartWarehouseViz = await ct.PartWarehouse.AsNoTracking().Where(x => x.Id == o.PartWarehouseId).Select(x => x.Name).FirstOrDefaultAsync();
// if (o.SourceType != null)
// o.SourceTypeViz = ayaTypesEnumList.Where(x => x.Id == (long)o.SourceType).Select(x => x.Name).First();
// if (o.SourceType != null && o.SourceId != null)
// o.SourceViz = BizObjectNameFetcherDirect.Name((AyaType)o.SourceType, (long)o.SourceId, cmd);
// }
////////////////////////////////////////////////////////////////////////////////////////////////
// IMPORT EXPORT
//
public async Task<JArray> GetExportData(DataListSelectedRequest dataListSelectedRequest)
{
//for now just re-use the report data code
//this may turn out to be the pattern for most biz object types but keeping it seperate allows for custom usage from time to time
return await GetReportData(dataListSelectedRequest);
}
/////////////////////////////////////////////////////////////////////
}//eoc
}//eons