material not work com 4
This commit is contained in:
parent
74bda6e3f8
commit
64db0e8a91
@ -1,12 +1,17 @@
|
|||||||
using ProductionInCehOTP.Entities.Enums;
|
using ProductionInCehOTP.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProductionInCehOTP.Entities;
|
namespace ProductionInCehOTP.Entities;
|
||||||
|
|
||||||
public class ArrivalMaterials
|
public class ArrivalMaterials
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DisplayName("Дата")]
|
||||||
public DateTime Date { get; private set; }
|
public DateTime Date { get; private set; }
|
||||||
|
[DisplayName("Перечь поставленных материалов")]
|
||||||
public NameOfMaterials Name { get; private set; }
|
public NameOfMaterials Name { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Количество")]
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public static ArrivalMaterials CreateArrivalMaterials(int id, DateTime Date, NameOfMaterials name, int count)
|
public static ArrivalMaterials CreateArrivalMaterials(int id, DateTime Date, NameOfMaterials name, int count)
|
||||||
|
@ -1,16 +1,31 @@
|
|||||||
|
|
||||||
using ProductionInCehOTP.Entities.Enums;
|
using ProductionInCehOTP.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProductionInCehOTP.Entities;
|
namespace ProductionInCehOTP.Entities;
|
||||||
|
|
||||||
public class Material
|
public class Material
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Материал")]
|
||||||
public NameOfMaterials Name { get; private set; }
|
public NameOfMaterials Name { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Номеер поставки")]
|
||||||
public int ArrivalMaterialID { get; private set; }
|
public int ArrivalMaterialID { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Количество переданного")]
|
||||||
|
|
||||||
|
public string CountToProduct => MaterialForProducts != null ?
|
||||||
|
string.Join(", ", MaterialForProducts.Select(x => $"{x.Name}{x.Count}")) :
|
||||||
|
string.Empty;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public IEnumerable<MaterialForProduct> MaterialForProducts { get; private set; }
|
public IEnumerable<MaterialForProduct> MaterialForProducts { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата передачи в производство")]
|
||||||
public DateTime DateArrivalToProduct { get; private set; }
|
public DateTime DateArrivalToProduct { get; private set; }
|
||||||
|
|
||||||
public static Material TransferMaterial(int id, NameOfMaterials name, int arrivalMaterialsID, DateTime dateArrivalToProduct,IEnumerable<MaterialForProduct> materialForProducts )
|
public static Material TransferMaterial(int id, NameOfMaterials name, int arrivalMaterialsID, DateTime dateArrivalToProduct,IEnumerable<MaterialForProduct> materialForProducts )
|
||||||
{
|
{
|
||||||
return new Material
|
return new Material
|
||||||
@ -23,16 +38,12 @@ public class Material
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Material TransferMaterial(TempMaterialForProduct tempMaterialForProduct, IEnumerable<MaterialForProduct> materialForProducts)
|
public void SetMaterialForProduct(IEnumerable<MaterialForProduct> materialForProducts)
|
||||||
{
|
{
|
||||||
return new Material
|
if(materialForProducts != null && materialForProducts.Any())
|
||||||
{
|
{
|
||||||
Id = tempMaterialForProduct.ID,
|
MaterialForProducts = materialForProducts;
|
||||||
Name = tempMaterialForProduct.Name,
|
}
|
||||||
ArrivalMaterialID = tempMaterialForProduct.ArrivalMaterialID,
|
|
||||||
DateArrivalToProduct = tempMaterialForProduct.DateArrivalToProduct,
|
|
||||||
MaterialForProducts = materialForProducts
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,6 +10,8 @@ public class MaterialForProduct
|
|||||||
{
|
{
|
||||||
public int ProductID { get; private set; }
|
public int ProductID { get; private set; }
|
||||||
public int MaterialID { get; private set; }
|
public int MaterialID { get; private set; }
|
||||||
|
|
||||||
|
public string Name { get; private set; }
|
||||||
public int Count { get; private set; }
|
public int Count { get; private set; }
|
||||||
|
|
||||||
public static MaterialForProduct CreateDependenceMaterialsToProduct(int productID, int materialsId, int count)
|
public static MaterialForProduct CreateDependenceMaterialsToProduct(int productID, int materialsId, int count)
|
||||||
|
@ -1,10 +1,17 @@
|
|||||||
namespace ProductionInCehOTP.Entities;
|
using System.ComponentModel;
|
||||||
|
|
||||||
|
namespace ProductionInCehOTP.Entities;
|
||||||
|
|
||||||
public class PlanWork
|
public class PlanWork
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[DisplayName("Запланированное количество готовой продукции")]
|
||||||
public int Plan { get; private set; }
|
public int Plan { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дата установки плана")]
|
||||||
public DateTime Date { get; private set; } = DateTime.Now;
|
public DateTime Date { get; private set; } = DateTime.Now;
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int WorkerId { get; private set; }
|
public int WorkerId { get; private set; }
|
||||||
|
|
||||||
public IEnumerable<PlanWorkForProduct> PlanWorkForProducts { get; private set; } = [];
|
public IEnumerable<PlanWorkForProduct> PlanWorkForProducts { get; private set; } = [];
|
||||||
|
@ -1,13 +1,22 @@
|
|||||||
using ProductionInCehOTP.Entities.Enums;
|
using ProductionInCehOTP.Entities.Enums;
|
||||||
|
using System.ComponentModel;
|
||||||
|
|
||||||
namespace ProductionInCehOTP.Entities;
|
namespace ProductionInCehOTP.Entities;
|
||||||
|
|
||||||
public class Product
|
public class Product
|
||||||
{
|
{
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Наименование продукта")]
|
||||||
public string Name { get; private set; }
|
public string Name { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Цена")]
|
||||||
public int Price { get; private set; }
|
public int Price { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Официальный регистрационный номер")]
|
||||||
public string ProductionId { get; private set; }
|
public string ProductionId { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Наименование типа изделия")]
|
||||||
public NameOfProductTypes ProductionTypeID { get; private set; }
|
public NameOfProductTypes ProductionTypeID { get; private set; }
|
||||||
|
|
||||||
public static Product CreateProducts(int id, string name, int price, string productionId, NameOfProductTypes productionType)
|
public static Product CreateProducts(int id, string name, int price, string productionId, NameOfProductTypes productionType)
|
||||||
|
@ -1,21 +0,0 @@
|
|||||||
using ProductionInCehOTP.Entities.Enums;
|
|
||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
|
|
||||||
namespace ProductionInCehOTP.Entities;
|
|
||||||
|
|
||||||
public class TempMaterialForProduct
|
|
||||||
{
|
|
||||||
public int ID { get; private set; }
|
|
||||||
|
|
||||||
public NameOfMaterials Name { get; private set; }
|
|
||||||
public int ArrivalMaterialID { get; private set; }
|
|
||||||
|
|
||||||
public int MaterialID { get; private set; }
|
|
||||||
|
|
||||||
public DateTime DateArrivalToProduct { get; private set; }
|
|
||||||
public int Count { get; private set; }
|
|
||||||
}
|
|
@ -1,13 +1,24 @@
|
|||||||
using System.Runtime.CompilerServices;
|
using System.ComponentModel;
|
||||||
|
using System.Runtime.CompilerServices;
|
||||||
|
|
||||||
namespace ProductionInCehOTP.Entities;
|
namespace ProductionInCehOTP.Entities;
|
||||||
|
|
||||||
public class Worker
|
public class Worker
|
||||||
{
|
{
|
||||||
|
|
||||||
public int Id { get; private set; }
|
public int Id { get; private set; }
|
||||||
|
[Browsable(false)]
|
||||||
public string Name { get; private set; } = string.Empty;
|
public string Name { get; private set; } = string.Empty;
|
||||||
|
[DisplayName("ФИО(разряд)")]
|
||||||
|
public string NameClass => $"{Name}({Class})";
|
||||||
|
|
||||||
|
[DisplayName("Рабочий стаж")]
|
||||||
public DateTime Experience { get; private set; }
|
public DateTime Experience { get; private set; }
|
||||||
|
|
||||||
|
[Browsable(false)]
|
||||||
public int Class { get; private set; }
|
public int Class { get; private set; }
|
||||||
|
|
||||||
|
[DisplayName("Дневная норма выработки")]
|
||||||
public int PlanWork { get; private set; }
|
public int PlanWork { get; private set; }
|
||||||
|
|
||||||
public static Worker CreateWorker(int id, string name, DateTime experience, int classOfWorker, int planWorkID)
|
public static Worker CreateWorker(int id, string name, DateTime experience, int classOfWorker, int planWorkID)
|
||||||
|
@ -82,8 +82,12 @@ namespace ProductionInCehOTP.Forms.ArrivalsMaterials_Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _arrivalMaterialsRepository.GetArrivalMaterials();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _arrivalMaterialsRepository.GetArrivalMaterials();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
|
||||||
|
}
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -32,6 +32,9 @@ namespace ProductionInCehOTP.Forms.Material_Forms
|
|||||||
private void LoadList()
|
private void LoadList()
|
||||||
{
|
{
|
||||||
dataGridViewData.DataSource = _materialRepository.GetMaterials();
|
dataGridViewData.DataSource = _materialRepository.GetMaterials();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["DateArrivalToProduct"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void FormMaterials_Load(object sender, EventArgs e)
|
private void FormMaterials_Load(object sender, EventArgs e)
|
||||||
|
@ -28,7 +28,7 @@ namespace ProductionInCehOTP.Forms
|
|||||||
ColumnProduct.ValueMember = "Id";
|
ColumnProduct.ValueMember = "Id";
|
||||||
|
|
||||||
comboBoxName.DataSource = workerRepository.GetWorkers();
|
comboBoxName.DataSource = workerRepository.GetWorkers();
|
||||||
comboBoxName.DisplayMember = "Name";
|
comboBoxName.DisplayMember = "NameClass";
|
||||||
comboBoxName.ValueMember = "Id";
|
comboBoxName.ValueMember = "Id";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -20,7 +20,7 @@ namespace ProductionInCehOTP.Forms.PlanWork_Forms
|
|||||||
{
|
{
|
||||||
private readonly IUnityContainer _container;
|
private readonly IUnityContainer _container;
|
||||||
private readonly IPlanWorkRepository _planWorkRepository;
|
private readonly IPlanWorkRepository _planWorkRepository;
|
||||||
public FormPlansWork(IUnityContainer container,IPlanWorkRepository planWorkRepository)
|
public FormPlansWork(IUnityContainer container, IPlanWorkRepository planWorkRepository)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
_container = container ??
|
_container = container ??
|
||||||
@ -40,8 +40,13 @@ namespace ProductionInCehOTP.Forms.PlanWork_Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка добавления элемента", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка добавления элемента", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _planWorkRepository.GetPlanWorks();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _planWorkRepository.GetPlanWorks();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["Date"].DefaultCellStyle.Format = "dddd.MM.yyyy";
|
||||||
|
|
||||||
|
}
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -93,7 +93,11 @@ namespace ProductionInCehOTP.Forms
|
|||||||
MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
MessageBox.Show(ex.Message, "Ошибка при загрузке данных", MessageBoxButtons.OK, MessageBoxIcon.Error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _productRepository.GetProducts();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
dataGridViewData.DataSource = _productRepository.GetProducts();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
}
|
||||||
|
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
|
@ -81,8 +81,14 @@ namespace ProductionInCehOTP.Forms
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
private void LoadList() => dataGridViewData.DataSource = _workerRepository.GetWorkers();
|
private void LoadList()
|
||||||
|
{
|
||||||
|
|
||||||
|
dataGridViewData.DataSource = _workerRepository.GetWorkers();
|
||||||
|
dataGridViewData.Columns["Id"].Visible = false;
|
||||||
|
dataGridViewData.Columns["DateArrivalToProduct"].DefaultCellStyle.Format = "dd MMMM yyyy hh:mm";
|
||||||
|
|
||||||
|
}
|
||||||
private bool TryGetIdentifierFromSelectedRow(out int id)
|
private bool TryGetIdentifierFromSelectedRow(out int id)
|
||||||
{
|
{
|
||||||
id = 0;
|
id = 0;
|
||||||
|
@ -29,16 +29,32 @@ public class MaterialRepository : IMaterialReposirory
|
|||||||
{
|
{
|
||||||
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
using var connection = new NpgsqlConnection(_connectionString.ConnectionString);
|
||||||
var querySelect = @"
|
var querySelect = @"
|
||||||
SELECT mat.*, mp.MaterialID, mp.Count
|
SELECT mat.*,
|
||||||
FROM Material mat
|
mfp.Count as countofmaterialtoproduct,
|
||||||
INNER JOIN material_product mp ON mp.MaterialID = mat.id";
|
pr.Name as nameofproduct
|
||||||
var material =
|
from material mat
|
||||||
connection.Query<TempMaterialForProduct>(querySelect);
|
inner join material_product mfp on mfp.MaterialId = mat.id
|
||||||
_logger.LogDebug("Полученные объекты: {json}",
|
left join product pr on pr.productiontypeid = mfp.productid";
|
||||||
JsonConvert.SerializeObject(material));
|
var materialDict = new Dictionary<int, List<MaterialForProduct>>();
|
||||||
|
|
||||||
return material.GroupBy(x => x.ID, y => y,
|
var material = connection.Query<Material, MaterialForProduct, Material>(querySelect,
|
||||||
(key, value) => Material.TransferMaterial(value.First(), value.Select(z => MaterialForProduct.CreateDependenceMaterialsToProduct(0,z.MaterialID, z.Count)))).ToList();
|
(matat, material) =>
|
||||||
|
{
|
||||||
|
if (!materialDict.TryGetValue(matat.Id, out var frr))
|
||||||
|
{
|
||||||
|
frr = [];
|
||||||
|
materialDict.Add(matat.Id, frr);
|
||||||
|
}
|
||||||
|
frr.Add(material);
|
||||||
|
return matat;
|
||||||
|
}, splitOn: "Count", param: new {name, arrivalMaterialsid});
|
||||||
|
_logger.LogDebug("Полученные объекты {json}", JsonConvert.SerializeObject(material));
|
||||||
|
return materialDict.Select(x =>
|
||||||
|
{
|
||||||
|
var fr = material.First(y => y.Id == x.Key);
|
||||||
|
fr.SetMaterialForProduct(x.Value);
|
||||||
|
return fr;
|
||||||
|
}).ToArray();
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user