Mrp Workload

This commit is contained in:
Sedat ÖZTÜRK 2025-12-10 17:48:50 +03:00
parent 83165cbc9f
commit adc45fad30
7 changed files with 297 additions and 38 deletions

View file

@ -10179,9 +10179,9 @@
},
{
"resourceName": "Platform",
"key": "App.Mrp.PlanningGantt",
"tr": "Planlama Gantt",
"en": "Planning Gantt"
"key": "App.Mrp.Workload",
"tr": "Workload",
"en": "Workload"
},
{
"resourceName": "Platform",

View file

@ -1862,7 +1862,7 @@ public class ListFormSeeder_Mrp : IDataSeedContributor, ITransientDependency
EditingFormJson = JsonSerializer.Serialize(new List<EditingFormDto>() {
new() {
Order=1, ColCount=2, ColSpan=1, ItemType="group", Items= [
new EditingFormItemDto { Order = 1, DataField = "OrderNumber", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 1, DataField = "OrderNumber", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox, EditorOptions = EditorOptionValues.Disabled },
new EditingFormItemDto { Order = 2, DataField = "OrderTypeId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 3, DataField = "StatusId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 4, DataField = "Priority", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
@ -2500,17 +2500,17 @@ public class ListFormSeeder_Mrp : IDataSeedContributor, ITransientDependency
EditingFormJson = JsonSerializer.Serialize(new List<EditingFormDto>() {
new() {
Order=1, ColCount=2, ColSpan=1, ItemType="group", Items= [
new EditingFormItemDto { Order = 1, DataField = "WorkorderNumber", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 1, DataField = "WorkorderNumber", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextBox, EditorOptions = EditorOptionValues.Disabled },
new EditingFormItemDto { Order = 2, DataField = "ProductionOrderId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 3, DataField = "OperationId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 4, DataField = "MaterialId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 5, DataField = "WorkcenterId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 6, DataField = "StatusId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox, EditorOptions=EditorOptionValues.ShowClearButton },
new EditingFormItemDto { Order = 7, DataField = "Sequence", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox },
new EditingFormItemDto { Order = 8, DataField = "PlannedStartDate", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 9, DataField = "PlannedEndDate", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 10, DataField = "ActualStartDate", ColSpan = 1, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 11, DataField = "ActualEndDate", ColSpan = 1, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 7, DataField = "PlannedStartDate", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 8, DataField = "PlannedEndDate", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 9, DataField = "ActualStartDate", ColSpan = 1, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 10, DataField = "ActualEndDate", ColSpan = 1, EditorType2=EditorTypes.dxDateBox, EditorOptions=EditorOptionValues.DateTimeFormat },
new EditingFormItemDto { Order = 11, DataField = "Sequence", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox },
new EditingFormItemDto { Order = 12, DataField = "PlannedQuantity", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 13, DataField = "ConfirmedQuantity", ColSpan = 1, EditorType2=EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat },
new EditingFormItemDto { Order = 14, DataField = "ScrapQuantity", ColSpan = 1, EditorType2=EditorTypes.dxNumberBox, EditorOptions=EditorOptionValues.NumberStandartFormat },
@ -2851,8 +2851,195 @@ public class ListFormSeeder_Mrp : IDataSeedContributor, ITransientDependency
#endregion
}
#endregion
#region Production Order Workload
listFormName = AppCodes.Mrp.Workload;
if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == listFormName))
{
var listForm = await _listFormRepository.InsertAsync(
new ListForm()
{
ListFormType = ListFormTypeEnum.List,
ExportJson = DefaultExportJson,
IsSubForm = false,
ShowNote = true,
LayoutJson = DefaultLayoutJson("gantt"),
CultureName = LanguageCodes.En,
ListFormCode = listFormName,
Name = listFormName,
Title = listFormName,
DataSourceCode = SeedConsts.DataSources.DefaultCode,
IsTenant = true,
IsBranch = false,
IsOrganizationUnit = false,
Description = listFormName,
SelectCommandType = SelectCommandTypeEnum.Table,
SelectCommand = TableNameResolver.GetFullViewName(nameof(TableNameEnum.ProductionOrder)),
KeyFieldName = "Id",
KeyFieldDbSourceType = DbType.Guid,
DefaultFilter = DefaultFilterJson,
SortMode = GridOptions.SortModeSingle,
FilterRowJson = DefaultFilterRowJson,
HeaderFilterJson = DefaultHeaderFilterJson,
SearchPanelJson = DefaultSearchPanelJson,
GroupPanelJson = DefaultGroupPanelJson,
SelectionJson = DefaultSelectionSingleJson,
ColumnOptionJson = DefaultColumnOptionJson,
PermissionJson = DefaultPermissionJson(listFormName),
GanttOptionJson = JsonSerializer.Serialize(new GanttOptionDto
{
KeyExpr = "Id",
ParentIdExpr = "ParentId",
RootValue = null,
AutoExpandAll = true,
TitleExpr = "Name",
StartExpr = "StartDate",
EndExpr = "EndDate",
ProgressExpr = "Progress",
ScaleType = "weeks"
}),
DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.ProductionOrder)),
DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson,
PagerOptionJson = DefaultPagerOptionJson,
EditingOptionJson = DefaultEditingOptionJson(listFormName, 800, 400, true, true, true, true, false),
InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson,
EditingFormJson = JsonSerializer.Serialize(new List<EditingFormDto>()
{
new() {
Order=1, ColCount=2, ColSpan=1, ItemType="group", Items =[
new EditingFormItemDto { Order = 1, DataField="Name", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox },
new EditingFormItemDto { Order = 2, DataField="Progress", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox },
new EditingFormItemDto { Order = 3, DataField="StartDate", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxDateBox, EditorOptions = EditorOptionValues.DateFormat },
new EditingFormItemDto { Order = 4, DataField="EndDate", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxDateBox, EditorOptions = EditorOptionValues.DateFormat },
new EditingFormItemDto { Order = 5, DataField="Description", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea },
]}
}),
}, autoSave: true
);
#region Project Task Workload Fields
await _listFormFieldRepository.InsertManyAsync([
new() {
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.Guid,
FieldName = "Id",
Width = 100,
ListOrderNo = 1,
Visible = false,
IsActive = true,
IsDeleted = false,
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),
PivotSettingsJson = DefaultPivotSettingsJson
},
new() {
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.Guid,
FieldName = "ParentId",
Width = 200,
ListOrderNo = 2,
Visible = false,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),
PivotSettingsJson = DefaultPivotSettingsJson
},
new() {
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "Name",
Width = 200,
ListOrderNo = 3,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
SortIndex = 1,
SortDirection = GridColumnOptions.SortOrderAsc,
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),
PivotSettingsJson = DefaultPivotSettingsJson
},
new() {
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.String,
FieldName = "Description",
Width = 400,
ListOrderNo = 4,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),
PivotSettingsJson = DefaultPivotSettingsJson
},
new() {
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.Date,
FieldName = "StartDate",
Alignment = "center",
Width = 100,
ListOrderNo = 5,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),
PivotSettingsJson = DefaultPivotSettingsJson
},
new() {
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.Date,
FieldName = "EndDate",
Alignment = "center",
Width = 100,
ListOrderNo = 6,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),
PivotSettingsJson = DefaultPivotSettingsJson
},
new() {
ListFormCode = listForm.ListFormCode,
CultureName = LanguageCodes.En,
SourceDbType = DbType.Decimal,
FieldName = "Progress",
Format = "fixedPoint",
Alignment = "right",
Width = 70,
ListOrderNo = 7,
Visible = true,
IsActive = true,
IsDeleted = false,
AllowSearch = true,
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),
PivotSettingsJson = DefaultPivotSettingsJson,
EditorOptions=EditorOptionValues.NumberStandartFormat
},
]);
#endregion
}
#endregion
}
}

View file

@ -2166,14 +2166,6 @@ public class ListFormSeeder_Project : IDataSeedContributor, ITransientDependency
IsActive = true,
IsDeleted = false,
AllowSearch = true,
LookupJson = JsonSerializer.Serialize(new LookupDto
{
DataSourceType = UiLookupDataSourceTypeEnum.Query,
DisplayExpr = "Name",
ValueExpr = "Key",
LookupQuery = LookupQueryValues.DefaultLookupQuery(nameof(TableNameEnum.Projects), "Id", "Name"),
CascadeEmptyFields = "PhaseId"
}),
ValidationRuleJson = DefaultValidationRuleRequiredJson,
ColumnCustomizationJson = DefaultColumnCustomizationJson,
PermissionJson = DefaultFieldPermissionJson(listForm.Name),

View file

@ -3113,12 +3113,12 @@
},
{
"ParentCode": "App.Mrp",
"Code": "App.Mrp.PlanningGantt",
"DisplayName": "App.Mrp.PlanningGantt",
"Code": "App.Mrp.Workload",
"DisplayName": "App.Mrp.Workload",
"Order": 4,
"Url": "/admin/mrp/planning-gantt",
"Url": "/admin/list/App.Mrp.Workload",
"Icon": "FcTimeline",
"RequiredPermissionName": "App.Mrp.PlanningGantt",
"RequiredPermissionName": "App.Mrp.Workload",
"IsDisabled": false
},
{

View file

@ -13313,17 +13313,17 @@
},
{
"GroupName": "App.Mrp",
"Name": "App.Mrp.PlanningGantt",
"Name": "App.Mrp.Workload",
"ParentName": null,
"DisplayName": "App.Mrp.PlanningGantt",
"DisplayName": "App.Mrp.Workload",
"IsEnabled": true,
"MultiTenancySide": 3,
"MenuGroup": "Erp"
},
{
"GroupName": "App.Mrp",
"Name": "App.Mrp.PlanningGantt.Create",
"ParentName": "App.Mrp.PlanningGantt",
"Name": "App.Mrp.Workload.Create",
"ParentName": "App.Mrp.Workload",
"DisplayName": "Create",
"IsEnabled": true,
"MultiTenancySide": 3,
@ -13331,8 +13331,8 @@
},
{
"GroupName": "App.Mrp",
"Name": "App.Mrp.PlanningGantt.Update",
"ParentName": "App.Mrp.PlanningGantt",
"Name": "App.Mrp.Workload.Update",
"ParentName": "App.Mrp.Workload",
"DisplayName": "Update",
"IsEnabled": true,
"MultiTenancySide": 3,
@ -13340,8 +13340,8 @@
},
{
"GroupName": "App.Mrp",
"Name": "App.Mrp.PlanningGantt.Delete",
"ParentName": "App.Mrp.PlanningGantt",
"Name": "App.Mrp.Workload.Delete",
"ParentName": "App.Mrp.Workload",
"DisplayName": "Delete",
"IsEnabled": true,
"MultiTenancySide": 3,
@ -13349,8 +13349,8 @@
},
{
"GroupName": "App.Mrp",
"Name": "App.Mrp.PlanningGantt.Export",
"ParentName": "App.Mrp.PlanningGantt",
"Name": "App.Mrp.Workload.Export",
"ParentName": "App.Mrp.Workload",
"DisplayName": "Export",
"IsEnabled": true,
"MultiTenancySide": 3,
@ -13358,8 +13358,8 @@
},
{
"GroupName": "App.Mrp",
"Name": "App.Mrp.PlanningGantt.Import",
"ParentName": "App.Mrp.PlanningGantt",
"Name": "App.Mrp.Workload.Import",
"ParentName": "App.Mrp.Workload",
"DisplayName": "Import",
"IsEnabled": true,
"MultiTenancySide": 3,
@ -13367,8 +13367,8 @@
},
{
"GroupName": "App.Mrp",
"Name": "App.Mrp.PlanningGantt.Note",
"ParentName": "App.Mrp.PlanningGantt",
"Name": "App.Mrp.Workload.Note",
"ParentName": "App.Mrp.Workload",
"DisplayName": "Note",
"IsEnabled": true,
"MultiTenancySide": 3,

View file

@ -642,6 +642,7 @@ public static class SeedConsts
public const string ProductionOrderItem = Default + ".ProductionOrderItem";
public const string WorkorderStatus = Default + ".WorkorderStatus";
public const string Workorder = Default + ".Workorder";
public const string Workload = Default + ".Workload";
}
}

View file

@ -40,7 +40,9 @@ public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency
await CreateOrUpdateMovementItemViewAsync(dbContext, nameof(TableNameEnum.MovementItem));
await CreateOrUpdateMovementTransferViewAsync(dbContext, nameof(TableNameEnum.TransferItem));
await CreateOrUpdateMovementTransferViewAsync(dbContext, nameof(TableNameEnum.TransferItem));
await CreateOrUpdateProductionOrderViewAsync(dbContext, nameof(TableNameEnum.ProductionOrder));
_logger.LogInformation("Database view seeding completed successfully.");
}
@ -285,5 +287,82 @@ public class DatabaseViewSeeder : IDataSeedContributor, ITransientDependency
throw;
}
}
/// <summary>
/// Creates or updates the V_T_Str_MovementTransfer view
/// </summary>
private async Task CreateOrUpdateProductionOrderViewAsync(PlatformDbContext dbContext, string tableName)
{
string fullViewName = TableNameResolver.GetFullViewName(tableName);
try
{
var createViewSql = $@"
IF EXISTS (SELECT * FROM sys.views WHERE object_id = OBJECT_ID(N'[dbo].[{fullViewName}]'))
DROP VIEW [dbo].[{fullViewName}];
EXEC('
CREATE VIEW [dbo].[{fullViewName}]
AS
SELECT
Mrp_T_ProductionOrder.TenantId,
Mrp_T_ProductionWorkorder.ProductionOrderId AS Id,
NULL AS ParentId,
Scp_T_Material.[Name] AS Name,
''PO '' + Mrp_T_ProductionOrder.OrderNumber AS Description,
Mrp_T_ProductionOrder.PlannedStartDate AS StartDate,
Mrp_T_ProductionOrder.PlannedEndDate AS EndDate,
(Mrp_T_ProductionOrder.ConfirmedQuantity * 1.0 / Mrp_T_ProductionOrder.PlannedQuantity) * 100.00 AS Progress,
Mrp_T_ProductionWorkorder.[IsDeleted]
FROM Mrp_T_ProductionOrder
INNER JOIN Mrp_T_ProductionWorkorder
ON Mrp_T_ProductionOrder.Id = Mrp_T_ProductionWorkorder.ProductionOrderId
INNER JOIN Scp_T_Material
ON Mrp_T_ProductionWorkorder.MaterialId = Scp_T_Material.Id
GROUP BY
Mrp_T_ProductionOrder.TenantId,
Mrp_T_ProductionWorkorder.ProductionOrderId,
Scp_T_Material.[Name],
Mrp_T_ProductionOrder.OrderNumber,
Mrp_T_ProductionOrder.PlannedStartDate,
Mrp_T_ProductionOrder.PlannedEndDate,
Mrp_T_ProductionOrder.PlannedQuantity,
Mrp_T_ProductionOrder.ConfirmedQuantity,
Mrp_T_ProductionWorkorder.[IsDeleted]
UNION ALL
SELECT
Mrp_T_ProductionWorkorder.TenantId,
Mrp_T_ProductionWorkorder.Id,
Mrp_T_ProductionWorkorder.ProductionOrderId,
CONVERT(varchar, Mrp_T_ProductionWorkorder.Sequence)
+ ''-) '' + Mrp_T_Operation.Name AS Name,
''WO '' + Mrp_T_ProductionWorkorder.WorkorderNumber
+ '' - '' + Mnt_T_Workcenter.Name AS Description,
Mrp_T_ProductionWorkorder.PlannedStartDate AS StartDate,
Mrp_T_ProductionWorkorder.PlannedEndDate AS EndDate,
(Mrp_T_ProductionWorkorder.ConfirmedQuantity * 1.0 /
Mrp_T_ProductionWorkorder.PlannedQuantity) * 100.00 AS Progress,
Mrp_T_ProductionWorkorder.[IsDeleted]
FROM Mrp_T_ProductionWorkorder
INNER JOIN Mrp_T_Operation
ON Mrp_T_ProductionWorkorder.OperationId = Mrp_T_Operation.Id
INNER JOIN Mnt_T_Workcenter
ON Mrp_T_ProductionWorkorder.WorkcenterId = Mnt_T_Workcenter.Id
');
";
await dbContext.Database.ExecuteSqlRawAsync(createViewSql);
_logger.LogInformation($"Created/Updated {fullViewName} view successfully.");
}
catch (Exception ex)
{
_logger.LogError(ex, $"Error occurred while creating {fullViewName} view.");
throw;
}
}
}