diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json b/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json index 3a23f77a..09935111 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/LanguagesData.json @@ -9428,7 +9428,7 @@ }, { "resourceName": "Platform", - "key": "App.Maintenance.Plans", + "key": "App.Maintenance.Plan", "tr": "Bakım Planları", "en": "Maintenance Plans" }, diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs index 2bf43933..7c43c38d 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs +++ b/api/src/Erp.Platform.DbMigrator/Seeds/ListFormSeeder_Maintenance.cs @@ -693,6 +693,580 @@ public class ListFormSeeder_Maintenance : IDataSeedContributor, ITransientDepend #endregion } #endregion + + #region Maintenance Plan + if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.Plan)) + { + var listForm = await _listFormRepository.InsertAsync( + new ListForm() + { + ListFormType = ListFormTypeEnum.List, + IsSubForm = false, + ShowNote = true, + LayoutJson = DefaultLayoutJson, + CultureName = LanguageCodes.En, + ListFormCode = ListFormCodes.Lists.Plan, + Name = AppCodes.Maintenance.Plan, + Title = AppCodes.Maintenance.Plan, + DataSourceCode = SeedConsts.DataSources.DefaultCode, + IsTenant = true, + IsBranch = false, + IsOrganizationUnit = false, + Description = AppCodes.Maintenance.Plan, + SelectCommandType = SelectCommandTypeEnum.Table, + SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.MaintenancePlan)), + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + DefaultFilter = DefaultFilterJson, + SortMode = GridOptions.SortModeSingle, + FilterRowJson = DefaultFilterRowJson, + HeaderFilterJson = DefaultHeaderFilterJson, + SearchPanelJson = DefaultSearchPanelJson, + GroupPanelJson = DefaultGroupPanelJson, + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(AppCodes.Maintenance.Plan), + DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.MaintenancePlan)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + EditingOptionJson = DefaultEditingOptionJson(AppCodes.Maintenance.Plan, 500, 500, true, true, true, true, false), + EditingFormJson = JsonSerializer.Serialize(new List() { + new() { + Order=1, ColCount=2, ColSpan=1, Caption="General", ItemType="group", Items= + [ + new() { Order = 1, DataField = "Code", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxTextBox }, + new() { Order = 2, DataField = "WorkCenterId", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new() { Order = 3, DataField = "PlanType", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new() { Order = 4, DataField = "Priority", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxSelectBox }, + new() { Order = 5, DataField = "Description", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea }, + ]}, + new() { + Order=1, ColCount=2, ColSpan=1, Caption="Frequency", ItemType="group", Items= + [ + new() { Order = 1, DataField = "Frequency", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox }, + new() { Order = 2, DataField = "FrequencyUnit", ColSpan = 1, EditorType2 = EditorTypes.dxSelectBox }, + new() { Order = 3, DataField = "EstimatedDuration", ColSpan = 1, EditorType2 = EditorTypes.dxNumberBox }, + ]}, + new() { + Order=1, ColCount=2, ColSpan=1, Caption="Other", ItemType="group", Items= + [ + new() { Order = 1, DataField = "Instructions", ColSpan = 2, EditorType2 = EditorTypes.dxTextArea }, + new() { Order = 2, DataField = "RequiredSkillsJson", ColSpan = 2, EditorType2 = EditorTypes.dxTagBox }, + new() { Order = 3, DataField = "NextDue", ColSpan = 1, IsRequired = true, EditorType2 = EditorTypes.dxDateBox }, + new() { Order = 4, DataField = "IsActive", ColSpan = 1, EditorType2 = EditorTypes.dxCheckBox }, + ]} + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "Frequency", FieldDbType = DbType.Boolean, Value = "1", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "IsActive", FieldDbType = DbType.Boolean, Value = "true", CustomValueType = FieldCustomValueTypeEnum.Value }, + new() { FieldName = "EstimatedDuration", FieldDbType = DbType.Boolean, Value = "60", CustomValueType = FieldCustomValueTypeEnum.Value }, + }), + CommandColumnJson = JsonSerializer.Serialize(new CommandColumnDto[] { + new() { + Hint = "Manage", + Text ="Manage", + UrlTarget="_blank", + AuthName = AppCodes.Maintenance.Plan, + Url=$"/admin/form/{utils.GetDefaultFormCodes(ListFormCodes.Lists.Plan)}/@Id" + }, + }), + }, autoSave: true + ); + + #region MaintenancePlan 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.String, + FieldName = "Code", + Width = 150, + ListOrderNo = 2, + 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.Guid, + FieldName = "WorkCenterId", + Width = 350, + ListOrderNo = 3, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Workcenter), "Id", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "PlanType", + Width = 500, + ListOrderNo = 4, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.StaticData, + ValueExpr = "key", + DisplayExpr = "name", + LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { + new () { Key = "Önleyici", Name = "Önleyici" }, + new () { Key = "Tahminsel", Name = "Tahminsel" }, + new () { Key = "Düzeltici", Name = "Düzeltici" }, + new () { Key = "Duruma Bağlı", Name = "Duruma Bağlı" }, + }), + }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Priority", + Width = 100, + ListOrderNo = 5, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.StaticData, + ValueExpr = "key", + DisplayExpr = "name", + LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { + new () { Key = "Düşük", Name = "Düşük" }, + new () { Key = "Normal", Name = "Normal" }, + new () { Key = "Yüksek", Name = "Yüksek" }, + new () { Key = "Acil", Name = "Acil" }, + }), + }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Description", + Width = 100, + ListOrderNo = 5, + 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.Int32, + FieldName = "Frequency", + 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.String, + FieldName = "FrequencyUnit", + Width = 100, + ListOrderNo = 7, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = JsonSerializer.Serialize(new LookupDto + { + DataSourceType = UiLookupDataSourceTypeEnum.StaticData, + ValueExpr = "key", + DisplayExpr = "name", + LookupQuery = JsonSerializer.Serialize(new LookupDataDto[] { + new () { Key = "Günlük", Name = "Günlük" }, + new () { Key = "Haftalık", Name = "Haftalık" }, + new () { Key = "Aylık", Name = "Aylık" }, + new () { Key = "Yıllık", Name = "Yıllık" }, + new () { Key = "Saatlik", Name = "Saatlik" }, + new () { Key = "Döngü", Name = "Döngü" }, + }), + }), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Int32, + FieldName = "EstimatedDuration", + Width = 100, + ListOrderNo = 8, + 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.String, + FieldName = "Instructions", + Width = 100, + ListOrderNo = 9, + 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.String, + FieldName = "RequiredSkillsJson", + Width = 100, + ListOrderNo = 10, + 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 = "NextDue", + Width = 100, + ListOrderNo = 11, + 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.Boolean, + FieldName = "IsActive", + Width = 100, + ListOrderNo = 12, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ], autoSave: true); + #endregion + } + #endregion + + #region Maintenance Plan Material + if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.PlanMaterial)) + { + var listForm = await _listFormRepository.InsertAsync( + new ListForm() + { + ListFormType = ListFormTypeEnum.List, + IsSubForm = false, + ShowNote = true, + LayoutJson = DefaultLayoutJson, + CultureName = LanguageCodes.En, + ListFormCode = ListFormCodes.Lists.PlanMaterial, + Name = AppCodes.Maintenance.PlanMaterial, + Title = AppCodes.Maintenance.PlanMaterial, + DataSourceCode = SeedConsts.DataSources.DefaultCode, + IsTenant = true, + IsBranch = false, + IsOrganizationUnit = false, + Description = AppCodes.Maintenance.PlanMaterial, + SelectCommandType = SelectCommandTypeEnum.Table, + SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.MaintenancePlanMaterial)), + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + DefaultFilter = DefaultFilterJson, + SortMode = GridOptions.SortModeSingle, + FilterRowJson = DefaultFilterRowJson, + HeaderFilterJson = DefaultHeaderFilterJson, + SearchPanelJson = DefaultSearchPanelJson, + GroupPanelJson = DefaultGroupPanelJson, + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(AppCodes.Maintenance.PlanMaterial), + DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.MaintenancePlanMaterial)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + EditingOptionJson = DefaultEditingOptionJson(AppCodes.Maintenance.PlanMaterial, 500, 250, true, true, true, true, false), + EditingFormJson = JsonSerializer.Serialize(new List() { + new() { + Order=1, ColCount=1, ColSpan=1, ItemType="group", Items= [ + new EditingFormItemDto { Order = 1, DataField = "MaterialId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 2, DataField = "Quantity", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxNumberBox }, + ]} + }), + FormFieldsDefaultValueJson = JsonSerializer.Serialize(new FieldsDefaultValue[] { + new() { FieldName = "Quantity", FieldDbType = DbType.Decimal, Value = "0", CustomValueType = FieldCustomValueTypeEnum.Value } + }), + }, autoSave: true + ); + + #region Maintenance Plan Material 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 = "MaterialId", + Width = 150, + ListOrderNo = 2, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Material), "Id", "Name"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.Decimal, + FieldName = "Quantity", + Width = 350, + ListOrderNo = 3, + Visible = true, + IsActive = true, + IsDeleted = false, + SortIndex = 1, + SortDirection = GridColumnOptions.SortOrderAsc, + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ], autoSave: true); + #endregion + } + #endregion + + #region Maintenance Plan Employee + if (!await _listFormRepository.AnyAsync(a => a.ListFormCode == ListFormCodes.Lists.PlanEmployee)) + { + var listForm = await _listFormRepository.InsertAsync( + new ListForm() + { + ListFormType = ListFormTypeEnum.List, + IsSubForm = false, + ShowNote = true, + LayoutJson = DefaultLayoutJson, + CultureName = LanguageCodes.En, + ListFormCode = ListFormCodes.Lists.PlanEmployee, + Name = AppCodes.Maintenance.PlanEmployee, + Title = AppCodes.Maintenance.PlanEmployee, + DataSourceCode = SeedConsts.DataSources.DefaultCode, + IsTenant = true, + IsBranch = false, + IsOrganizationUnit = false, + Description = AppCodes.Maintenance.PlanEmployee, + SelectCommandType = SelectCommandTypeEnum.Table, + SelectCommand = TableNameResolver.GetFullTableName(nameof(TableNameEnum.MaintenancePlanEmployee)), + KeyFieldName = "Id", + KeyFieldDbSourceType = DbType.Guid, + DefaultFilter = DefaultFilterJson, + SortMode = GridOptions.SortModeSingle, + FilterRowJson = DefaultFilterRowJson, + HeaderFilterJson = DefaultHeaderFilterJson, + SearchPanelJson = DefaultSearchPanelJson, + GroupPanelJson = DefaultGroupPanelJson, + SelectionJson = DefaultSelectionSingleJson, + ColumnOptionJson = DefaultColumnOptionJson, + PermissionJson = DefaultPermissionJson(AppCodes.Maintenance.PlanEmployee), + DeleteCommand = DefaultDeleteCommand(nameof(TableNameEnum.MaintenancePlanEmployee)), + DeleteFieldsDefaultValueJson = DefaultDeleteFieldsDefaultValueJson, + PagerOptionJson = DefaultPagerOptionJson, + InsertFieldsDefaultValueJson = DefaultInsertFieldsDefaultValueJson, + EditingOptionJson = DefaultEditingOptionJson(AppCodes.Maintenance.PlanEmployee, 500, 250, true, true, true, true, false), + EditingFormJson = JsonSerializer.Serialize(new List() { + new() { + Order=1, ColCount=1, ColSpan=1, ItemType="group", Items= [ + new EditingFormItemDto { Order = 1, DataField = "EmployeeId", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxSelectBox }, + new EditingFormItemDto { Order = 2, DataField = "Description", ColSpan = 1, IsRequired = true, EditorType2=EditorTypes.dxTextArea }, + ]} + }), + }, autoSave: true + ); + + #region Maintenance Plan Employee 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 = "EmployeeId", + Width = 150, + ListOrderNo = 2, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + LookupJson = LookupQueryValues.DefaultLookupQueryJson(nameof(TableNameEnum.Employee), "Id", "FullName"), + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + new() { + ListFormCode = listForm.ListFormCode, + CultureName = LanguageCodes.En, + SourceDbType = DbType.String, + FieldName = "Description", + Width = 350, + ListOrderNo = 3, + Visible = true, + IsActive = true, + IsDeleted = false, + AllowSearch = true, + ValidationRuleJson = DefaultValidationRuleRequiredJson, + ColumnCustomizationJson = DefaultColumnCustomizationJson, + PermissionJson = DefaultFieldPermissionJson(listForm.Name), + PivotSettingsJson = DefaultPivotSettingsJson + }, + ], autoSave: true); + #endregion + } + #endregion + + // Maintenance Plan ile Maintenance Plan Material ve Maintenance Plan Employee arasında Sub Forms ilişkisinin kurulması + await utils.CloneListFormWithFieldsAsync( + _listFormRepository, + _listFormFieldRepository, + ListFormCodes.Lists.Plan, + JsonSerializer.Serialize(new List() { + new { + TabTitle = "Materials", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.PlanMaterial, + Relation = new List() { + new { + ParentFieldName = "Id", + DbType = DbType.Guid, + ChildFieldName = "MaintenancePlanId" + } + } + }, + new { + TabTitle = "Employees", + TabType = ListFormTabTypeEnum.List, + Code = ListFormCodes.Lists.PlanEmployee, + Relation = new List() { + new { + ParentFieldName = "Id", + DbType = DbType.Guid, + ChildFieldName = "MaintenancePlanId" + } + } + } + }) + ); } } diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json index 04eebb16..15174080 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/MenusData.json @@ -2427,12 +2427,12 @@ }, { "ParentCode": "App.Maintenance", - "Code": "App.Maintenance.Plans", - "DisplayName": "App.Maintenance.Plans", + "Code": "App.Maintenance.Plan", + "DisplayName": "App.Maintenance.Plan", "Order": 5, - "Url": "/admin/maintenance/plans", + "Url": "/admin/list/list-maintenanceplan", "Icon": "FcPlanner", - "RequiredPermissionName": "App.Maintenance.Plans", + "RequiredPermissionName": "App.Maintenance.Plan", "IsDisabled": false }, { @@ -2445,16 +2445,6 @@ "RequiredPermissionName": "App.Maintenance.Calendar", "IsDisabled": false }, - { - "ParentCode": "App.Maintenance", - "Code": "App.Maintenance.Teams", - "DisplayName": "App.Maintenance.Teams", - "Order": 7, - "Url": "/admin/maintenance/teams", - "Icon": "FcConferenceCall", - "RequiredPermissionName": "App.Maintenance.Teams", - "IsDisabled": false - }, { "ParentCode": "App.Maintenance", "Code": "App.Maintenance.Faults", diff --git a/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json b/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json index 933d6824..92e8908e 100644 --- a/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json +++ b/api/src/Erp.Platform.DbMigrator/Seeds/PermissionsData.json @@ -6567,17 +6567,17 @@ }, { "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Plans", + "Name": "App.Maintenance.Plan", "ParentName": null, - "DisplayName": "App.Maintenance.Plans", + "DisplayName": "App.Maintenance.Plan", "IsEnabled": true, "MultiTenancySide": 3, "MenuGroup": "Erp" }, { "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Plans.Create", - "ParentName": "App.Maintenance.Plans", + "Name": "App.Maintenance.Plan.Create", + "ParentName": "App.Maintenance.Plan", "DisplayName": "Create", "IsEnabled": true, "MultiTenancySide": 3, @@ -6585,8 +6585,8 @@ }, { "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Plans.Update", - "ParentName": "App.Maintenance.Plans", + "Name": "App.Maintenance.Plan.Update", + "ParentName": "App.Maintenance.Plan", "DisplayName": "Update", "IsEnabled": true, "MultiTenancySide": 3, @@ -6594,8 +6594,8 @@ }, { "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Plans.Delete", - "ParentName": "App.Maintenance.Plans", + "Name": "App.Maintenance.Plan.Delete", + "ParentName": "App.Maintenance.Plan", "DisplayName": "Delete", "IsEnabled": true, "MultiTenancySide": 3, @@ -6603,8 +6603,8 @@ }, { "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Plans.Export", - "ParentName": "App.Maintenance.Plans", + "Name": "App.Maintenance.Plan.Export", + "ParentName": "App.Maintenance.Plan", "DisplayName": "Export", "IsEnabled": true, "MultiTenancySide": 3, @@ -6612,8 +6612,8 @@ }, { "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Plans.Import", - "ParentName": "App.Maintenance.Plans", + "Name": "App.Maintenance.Plan.Import", + "ParentName": "App.Maintenance.Plan", "DisplayName": "Import", "IsEnabled": true, "MultiTenancySide": 3, @@ -6621,8 +6621,8 @@ }, { "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Plans.Note", - "ParentName": "App.Maintenance.Plans", + "Name": "App.Maintenance.Plan.Note", + "ParentName": "App.Maintenance.Plan", "DisplayName": "Note", "IsEnabled": true, "MultiTenancySide": 3, @@ -6691,69 +6691,6 @@ "MultiTenancySide": 3, "MenuGroup": "Erp" }, - { - "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Teams", - "ParentName": null, - "DisplayName": "App.Maintenance.Teams", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp" - }, - { - "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Teams.Create", - "ParentName": "App.Maintenance.Teams", - "DisplayName": "Create", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp" - }, - { - "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Teams.Update", - "ParentName": "App.Maintenance.Teams", - "DisplayName": "Update", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp" - }, - { - "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Teams.Delete", - "ParentName": "App.Maintenance.Teams", - "DisplayName": "Delete", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp" - }, - { - "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Teams.Export", - "ParentName": "App.Maintenance.Teams", - "DisplayName": "Export", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp" - }, - { - "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Teams.Import", - "ParentName": "App.Maintenance.Teams", - "DisplayName": "Import", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp" - }, - { - "GroupName": "App.Maintenance", - "Name": "App.Maintenance.Teams.Note", - "ParentName": "App.Maintenance.Teams", - "DisplayName": "Note", - "IsEnabled": true, - "MultiTenancySide": 3, - "MenuGroup": "Erp" - }, { "GroupName": "App.Maintenance", "Name": "App.Maintenance.Faults", diff --git a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs index d5ca3e48..3c6f45cc 100644 --- a/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs +++ b/api/src/Erp.Platform.Domain.Shared/Enums/TableNameEnum.cs @@ -161,5 +161,8 @@ public enum TableNameEnum WorkcenterType, WorkcenterStatus, Workcenter, - WorkcenterSpecification + WorkcenterSpecification, + MaintenancePlan, + MaintenancePlanMaterial, + MaintenancePlanEmployee } diff --git a/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs b/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs index ec2cad39..1a1f586b 100644 --- a/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs +++ b/api/src/Erp.Platform.Domain.Shared/PlatformConsts.cs @@ -536,7 +536,9 @@ public static class PlatformConsts public const string WorkcenterType = "list-workcentertype"; public const string WorkcenterStatus = "list-workcenterstatus"; public const string Workcenter = "list-workcenter"; - + public const string Plan = "list-maintenanceplan"; + public const string PlanMaterial = "list-maintenanceplanmaterial"; + public const string PlanEmployee = "list-maintenanceplanemployee"; } } diff --git a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs index 21b3b5c8..cf6a4ef1 100644 --- a/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs +++ b/api/src/Erp.Platform.Domain.Shared/TableNameResolver.cs @@ -190,6 +190,9 @@ public static class TableNameResolver { nameof(TableNameEnum.WorkcenterStatus), (TablePrefix.TenantByName, MenuPrefix.Maintenance) }, { nameof(TableNameEnum.Workcenter), (TablePrefix.TenantByName, MenuPrefix.Maintenance) }, { nameof(TableNameEnum.WorkcenterSpecification), (TablePrefix.TenantByName, MenuPrefix.Maintenance) }, + { nameof(TableNameEnum.MaintenancePlan), (TablePrefix.TenantByName, MenuPrefix.Maintenance) }, + { nameof(TableNameEnum.MaintenancePlanMaterial), (TablePrefix.TenantByName, MenuPrefix.Maintenance) }, + { nameof(TableNameEnum.MaintenancePlanEmployee), (TablePrefix.TenantByName, MenuPrefix.Maintenance) }, // 🔹 ACCOUNTING diff --git a/api/src/Erp.Platform.Domain/Data/SeedConsts.cs b/api/src/Erp.Platform.Domain/Data/SeedConsts.cs index bd17ee87..2bc53fe7 100644 --- a/api/src/Erp.Platform.Domain/Data/SeedConsts.cs +++ b/api/src/Erp.Platform.Domain/Data/SeedConsts.cs @@ -526,6 +526,9 @@ public static class SeedConsts public const string WorkcenterType = Default + ".WorkcenterType"; public const string WorkcenterStatus = Default + ".WorkcenterStatus"; public const string Workcenter = Default + ".Workcenter"; + public const string Plan = Default + ".Plan"; + public const string PlanMaterial = Default + ".PlanMaterial"; + public const string PlanEmployee = Default + ".PlanEmployee"; } public static class Accounting diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlan.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlan.cs new file mode 100644 index 00000000..b6f39753 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlan.cs @@ -0,0 +1,29 @@ +using System; +using System.Collections.Generic; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class MaintenancePlan : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public string Code { get; set; } + public string WorkCenterId { get; set; } + public string PlanType { get; set; } + public string Priority { get; set; } + public string Description { get; set; } + public int Frequency { get; set; } + public string FrequencyUnit { get; set; } + public int EstimatedDuration { get; set; } + public string Instructions { get; set; } + public DateTime NextDue { get; set; } + public bool IsActive { get; set; } + public DateTime? LastExecuted { get; set; } + + // Collections + public string RequiredSkillsJson { get; set; } + public List Materials { get; set; } + public List Employees { get; set; } +} diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlanEmployee.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlanEmployee.cs new file mode 100644 index 00000000..86f05eae --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlanEmployee.cs @@ -0,0 +1,18 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class MaintenancePlanEmployee : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public Guid MaintenancePlanId { get; set; } + public MaintenancePlan MaintenancePlan { get; set; } + + public Guid EmployeeId { get; set; } + public DateTime StartDate { get; set; } + public DateTime EndDate { get; set; } + public string Description { get; set; } +} \ No newline at end of file diff --git a/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlanMaterial.cs b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlanMaterial.cs new file mode 100644 index 00000000..43671307 --- /dev/null +++ b/api/src/Erp.Platform.Domain/Entities/Tenant/Maintenance/MaintenancePlanMaterial.cs @@ -0,0 +1,16 @@ +using System; +using Volo.Abp.Domain.Entities.Auditing; +using Volo.Abp.MultiTenancy; + +namespace Erp.Platform.Entities; + +public class MaintenancePlanMaterial : FullAuditedEntity, IMultiTenant +{ + public Guid? TenantId { get; set; } + + public Guid MaintenancePlanId { get; set; } + public MaintenancePlan MaintenancePlan { get; set; } + + public Guid MaterialId { get; set; } + public decimal Quantity { get; set; } +} \ No newline at end of file diff --git a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs index 79afba10..061f3568 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/EntityFrameworkCore/PlatformDbContext.cs @@ -236,6 +236,7 @@ public class PlatformDbContext : public DbSet WorkcenterStatuses { get; set; } public DbSet Workcenters { get; set; } public DbSet WorkcenterSpecifications { get; set; } + public DbSet MaintenancePlans { get; set; } #endregion public PlatformDbContext(DbContextOptions options) @@ -2748,5 +2749,54 @@ public class PlatformDbContext : .HasForeignKey(x => x.WorkcenterId) .OnDelete(DeleteBehavior.Cascade); }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.MaintenancePlan)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.Code).IsRequired().HasMaxLength(100); + b.Property(x => x.WorkCenterId).IsRequired().HasMaxLength(100); + b.Property(x => x.PlanType).IsRequired().HasMaxLength(50); + b.Property(x => x.Priority).HasMaxLength(50); + b.Property(x => x.Description).HasMaxLength(1000); + b.Property(x => x.Frequency).IsRequired(); + b.Property(x => x.FrequencyUnit).IsRequired().HasMaxLength(50); + b.Property(x => x.EstimatedDuration).IsRequired(); + b.Property(x => x.Instructions).IsRequired().HasMaxLength(2000); + b.Property(x => x.RequiredSkillsJson).HasMaxLength(1000); + b.Property(x => x.NextDue).IsRequired(); + b.Property(x => x.IsActive); + b.Property(x => x.LastExecuted).IsRequired(); + }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.MaintenancePlanMaterial)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.MaintenancePlanId).IsRequired(); + b.Property(x => x.MaterialId).IsRequired(); + b.Property(x => x.Quantity).HasPrecision(18, 2).HasDefaultValue(0); + + b.HasOne(x => x.MaintenancePlan) + .WithMany(x => x.Materials) + .HasForeignKey(x => x.MaintenancePlanId) + .OnDelete(DeleteBehavior.Cascade); + }); + + builder.Entity(b => + { + b.ToTable(TableNameResolver.GetFullTableName(nameof(TableNameEnum.MaintenancePlanEmployee)), Prefix.DbSchema); + b.ConfigureByConvention(); + + b.Property(x => x.MaintenancePlanId).IsRequired(); + b.Property(x => x.EmployeeId).IsRequired(); + + b.HasOne(x => x.MaintenancePlan) + .WithMany(x => x.Employees) + .HasForeignKey(x => x.MaintenancePlanId) + .OnDelete(DeleteBehavior.Cascade); + }); } } diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120065949_Initial.Designer.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120142319_Initial.Designer.cs similarity index 98% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120065949_Initial.Designer.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120142319_Initial.Designer.cs index b7371bc3..7aa32bb0 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120065949_Initial.Designer.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120142319_Initial.Designer.cs @@ -13,7 +13,7 @@ using Volo.Abp.EntityFrameworkCore; namespace Erp.Platform.Migrations { [DbContext(typeof(PlatformDbContext))] - [Migration("20251120065949_Initial")] + [Migration("20251120142319_Initial")] partial class Initial { /// @@ -5922,6 +5922,221 @@ namespace Erp.Platform.Migrations b.ToTable("Crm_T_LossReason", (string)null); }); + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlan", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("EstimatedDuration") + .HasColumnType("int"); + + b.Property("Frequency") + .HasColumnType("int"); + + b.Property("FrequencyUnit") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Instructions") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastExecuted") + .HasColumnType("datetime2"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("NextDue") + .HasColumnType("datetime2"); + + b.Property("PlanType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Priority") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RequiredSkillsJson") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("WorkCenterId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Mnt_T_MaintenancePlan", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanEmployee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaintenancePlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("MaintenancePlanId"); + + b.ToTable("Mnt_T_MaintenancePlanEmployee", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanMaterial", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaintenancePlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("Quantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("MaintenancePlanId"); + + b.ToTable("Mnt_T_MaintenancePlanMaterial", (string)null); + }); + modelBuilder.Entity("Erp.Platform.Entities.Material", b => { b.Property("Id") @@ -14155,6 +14370,28 @@ namespace Erp.Platform.Migrations .IsRequired(); }); + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanEmployee", b => + { + b.HasOne("Erp.Platform.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany("Employees") + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MaintenancePlan"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanMaterial", b => + { + b.HasOne("Erp.Platform.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany("Materials") + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MaintenancePlan"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Material", b => { b.HasOne("Erp.Platform.Entities.Currency", "Currency") @@ -15131,6 +15368,13 @@ namespace Erp.Platform.Migrations b.Navigation("Opportunities"); }); + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlan", b => + { + b.Navigation("Employees"); + + b.Navigation("Materials"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Material", b => { b.Navigation("AlternativeUoms"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120065949_Initial.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120142319_Initial.cs similarity index 98% rename from api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120065949_Initial.cs rename to api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120142319_Initial.cs index 2622a203..00c549ad 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120065949_Initial.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/20251120142319_Initial.cs @@ -1276,6 +1276,38 @@ namespace Erp.Platform.Migrations table.PrimaryKey("PK_Hr_T_Template360", x => x.Id); }); + migrationBuilder.CreateTable( + name: "Mnt_T_MaintenancePlan", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + Code = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + WorkCenterId = table.Column(type: "nvarchar(100)", maxLength: 100, nullable: false), + PlanType = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + Priority = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: true), + Description = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + Frequency = table.Column(type: "int", nullable: false), + FrequencyUnit = table.Column(type: "nvarchar(50)", maxLength: 50, nullable: false), + EstimatedDuration = table.Column(type: "int", nullable: false), + Instructions = table.Column(type: "nvarchar(2000)", maxLength: 2000, nullable: false), + NextDue = table.Column(type: "datetime2", nullable: false), + IsActive = table.Column(type: "bit", nullable: false), + LastExecuted = table.Column(type: "datetime2", nullable: false), + RequiredSkillsJson = table.Column(type: "nvarchar(1000)", maxLength: 1000, nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Mnt_T_MaintenancePlan", x => x.Id); + }); + migrationBuilder.CreateTable( name: "Mnt_T_WorkcenterStatus", columns: table => new @@ -3032,6 +3064,64 @@ namespace Erp.Platform.Migrations onDelete: ReferentialAction.Cascade); }); + migrationBuilder.CreateTable( + name: "Mnt_T_MaintenancePlanEmployee", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + MaintenancePlanId = table.Column(type: "uniqueidentifier", nullable: false), + EmployeeId = table.Column(type: "uniqueidentifier", nullable: false), + StartDate = table.Column(type: "datetime2", nullable: false), + EndDate = table.Column(type: "datetime2", nullable: false), + Description = table.Column(type: "nvarchar(max)", nullable: true), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Mnt_T_MaintenancePlanEmployee", x => x.Id); + table.ForeignKey( + name: "FK_Mnt_T_MaintenancePlanEmployee_Mnt_T_MaintenancePlan_MaintenancePlanId", + column: x => x.MaintenancePlanId, + principalTable: "Mnt_T_MaintenancePlan", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + + migrationBuilder.CreateTable( + name: "Mnt_T_MaintenancePlanMaterial", + columns: table => new + { + Id = table.Column(type: "uniqueidentifier", nullable: false), + TenantId = table.Column(type: "uniqueidentifier", nullable: true), + MaintenancePlanId = table.Column(type: "uniqueidentifier", nullable: false), + MaterialId = table.Column(type: "uniqueidentifier", nullable: false), + Quantity = table.Column(type: "decimal(18,2)", precision: 18, scale: 2, nullable: false, defaultValue: 0m), + CreationTime = table.Column(type: "datetime2", nullable: false), + CreatorId = table.Column(type: "uniqueidentifier", nullable: true), + LastModificationTime = table.Column(type: "datetime2", nullable: true), + LastModifierId = table.Column(type: "uniqueidentifier", nullable: true), + IsDeleted = table.Column(type: "bit", nullable: false, defaultValue: false), + DeleterId = table.Column(type: "uniqueidentifier", nullable: true), + DeletionTime = table.Column(type: "datetime2", nullable: true) + }, + constraints: table => + { + table.PrimaryKey("PK_Mnt_T_MaintenancePlanMaterial", x => x.Id); + table.ForeignKey( + name: "FK_Mnt_T_MaintenancePlanMaterial_Mnt_T_MaintenancePlan_MaintenancePlanId", + column: x => x.MaintenancePlanId, + principalTable: "Mnt_T_MaintenancePlan", + principalColumn: "Id", + onDelete: ReferentialAction.Cascade); + }); + migrationBuilder.CreateTable( name: "OpenIddictAuthorizations", columns: table => new @@ -6344,6 +6434,16 @@ namespace Erp.Platform.Migrations table: "Hr_T_SurveyResponse", column: "SurveyId"); + migrationBuilder.CreateIndex( + name: "IX_Mnt_T_MaintenancePlanEmployee_MaintenancePlanId", + table: "Mnt_T_MaintenancePlanEmployee", + column: "MaintenancePlanId"); + + migrationBuilder.CreateIndex( + name: "IX_Mnt_T_MaintenancePlanMaterial_MaintenancePlanId", + table: "Mnt_T_MaintenancePlanMaterial", + column: "MaintenancePlanId"); + migrationBuilder.CreateIndex( name: "IX_Mnt_T_Workcenter_DepartmentId", table: "Mnt_T_Workcenter", @@ -7052,6 +7152,12 @@ namespace Erp.Platform.Migrations migrationBuilder.DropTable( name: "Hr_T_SurveyQuestionOption"); + migrationBuilder.DropTable( + name: "Mnt_T_MaintenancePlanEmployee"); + + migrationBuilder.DropTable( + name: "Mnt_T_MaintenancePlanMaterial"); + migrationBuilder.DropTable( name: "Mnt_T_WorkcenterSpecification"); @@ -7262,6 +7368,9 @@ namespace Erp.Platform.Migrations migrationBuilder.DropTable( name: "Hr_T_SurveyQuestion"); + migrationBuilder.DropTable( + name: "Mnt_T_MaintenancePlan"); + migrationBuilder.DropTable( name: "Mnt_T_Workcenter"); diff --git a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs index 691160c8..cfa6baa3 100644 --- a/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs +++ b/api/src/Erp.Platform.EntityFrameworkCore/Migrations/PlatformDbContextModelSnapshot.cs @@ -5919,6 +5919,221 @@ namespace Erp.Platform.Migrations b.ToTable("Crm_T_LossReason", (string)null); }); + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlan", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("Code") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("EstimatedDuration") + .HasColumnType("int"); + + b.Property("Frequency") + .HasColumnType("int"); + + b.Property("FrequencyUnit") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Instructions") + .IsRequired() + .HasMaxLength(2000) + .HasColumnType("nvarchar(2000)"); + + b.Property("IsActive") + .HasColumnType("bit"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastExecuted") + .HasColumnType("datetime2"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("NextDue") + .HasColumnType("datetime2"); + + b.Property("PlanType") + .IsRequired() + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("Priority") + .HasMaxLength(50) + .HasColumnType("nvarchar(50)"); + + b.Property("RequiredSkillsJson") + .HasMaxLength(1000) + .HasColumnType("nvarchar(1000)"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.Property("WorkCenterId") + .IsRequired() + .HasMaxLength(100) + .HasColumnType("nvarchar(100)"); + + b.HasKey("Id"); + + b.ToTable("Mnt_T_MaintenancePlan", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanEmployee", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("Description") + .HasColumnType("nvarchar(max)"); + + b.Property("EmployeeId") + .HasColumnType("uniqueidentifier"); + + b.Property("EndDate") + .HasColumnType("datetime2"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaintenancePlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("StartDate") + .HasColumnType("datetime2"); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("MaintenancePlanId"); + + b.ToTable("Mnt_T_MaintenancePlanEmployee", (string)null); + }); + + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanMaterial", b => + { + b.Property("Id") + .HasColumnType("uniqueidentifier"); + + b.Property("CreationTime") + .HasColumnType("datetime2") + .HasColumnName("CreationTime"); + + b.Property("CreatorId") + .HasColumnType("uniqueidentifier") + .HasColumnName("CreatorId"); + + b.Property("DeleterId") + .HasColumnType("uniqueidentifier") + .HasColumnName("DeleterId"); + + b.Property("DeletionTime") + .HasColumnType("datetime2") + .HasColumnName("DeletionTime"); + + b.Property("IsDeleted") + .ValueGeneratedOnAdd() + .HasColumnType("bit") + .HasDefaultValue(false) + .HasColumnName("IsDeleted"); + + b.Property("LastModificationTime") + .HasColumnType("datetime2") + .HasColumnName("LastModificationTime"); + + b.Property("LastModifierId") + .HasColumnType("uniqueidentifier") + .HasColumnName("LastModifierId"); + + b.Property("MaintenancePlanId") + .HasColumnType("uniqueidentifier"); + + b.Property("MaterialId") + .HasColumnType("uniqueidentifier"); + + b.Property("Quantity") + .ValueGeneratedOnAdd() + .HasPrecision(18, 2) + .HasColumnType("decimal(18,2)") + .HasDefaultValue(0m); + + b.Property("TenantId") + .HasColumnType("uniqueidentifier") + .HasColumnName("TenantId"); + + b.HasKey("Id"); + + b.HasIndex("MaintenancePlanId"); + + b.ToTable("Mnt_T_MaintenancePlanMaterial", (string)null); + }); + modelBuilder.Entity("Erp.Platform.Entities.Material", b => { b.Property("Id") @@ -14152,6 +14367,28 @@ namespace Erp.Platform.Migrations .IsRequired(); }); + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanEmployee", b => + { + b.HasOne("Erp.Platform.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany("Employees") + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MaintenancePlan"); + }); + + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlanMaterial", b => + { + b.HasOne("Erp.Platform.Entities.MaintenancePlan", "MaintenancePlan") + .WithMany("Materials") + .HasForeignKey("MaintenancePlanId") + .OnDelete(DeleteBehavior.Cascade) + .IsRequired(); + + b.Navigation("MaintenancePlan"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Material", b => { b.HasOne("Erp.Platform.Entities.Currency", "Currency") @@ -15128,6 +15365,13 @@ namespace Erp.Platform.Migrations b.Navigation("Opportunities"); }); + modelBuilder.Entity("Erp.Platform.Entities.MaintenancePlan", b => + { + b.Navigation("Employees"); + + b.Navigation("Materials"); + }); + modelBuilder.Entity("Erp.Platform.Entities.Material", b => { b.Navigation("AlternativeUoms");