This commit is contained in:
sardq 2024-05-28 15:00:14 +04:00
parent 940fde0056
commit d299065071
17 changed files with 98 additions and 39 deletions

View File

@ -9,7 +9,7 @@ namespace FactoryContracts.ViewModels
public int Id { get; set; }
public int ClientId { get; set; }
public int PlanProductionId { get; set; }
public int? PlanProductionId { get; set; }
[DisplayName("ФИО исполнителя")]
public string ImplementerFIO { get; set; } = string.Empty;

View File

@ -23,4 +23,8 @@
<ProjectReference Include="..\FactoryContracts\FactoryContracts.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="Migrations\" />
</ItemGroup>
</Project>

View File

@ -21,15 +21,12 @@ namespace FactoryDatabaseImplement.Implements
public List<ExecutionPhaseViewModel> GetFilteredList(ExecutionPhaseSearchModel model)
{
if (string.IsNullOrEmpty(model.ExecutionPhaseName))
{
return new();
}
using var context = new FactoryDatabase();
return context.ExecutionPhases
.Include(x => x.Client)
.Include(x => x.PlanProduction)
.Where(x => x.ExecutionPhaseName.Contains(model.ExecutionPhaseName))
.Where(x => x.ExecutionPhaseName.Contains(model.ExecutionPhaseName) || (x.ClientId == model.ClientId))
.Select(x => x.GetViewModel)
.ToList();
}

View File

@ -59,9 +59,16 @@ namespace FactoryDatabaseImplement.Implements
.Select(x => x.GetViewModel)
.ToList();
}
return new();
return context.PlanProductions
.Where(x => x.ClientId == model.ClientId)
.Include(x => x.Client)
.Include(x => x.Workpieces)
.ThenInclude(x => x.Workpiece)
.ToList()
.Select(x => x.GetViewModel)
.ToList();
}
}
public List<PlanProductionViewModel> GetFullList()
{
@ -70,7 +77,6 @@ namespace FactoryDatabaseImplement.Implements
.Include (x => x.Client)
.Include(x => x.Workpieces)
.ThenInclude(x => x.Workpiece)
.ToList()
.Select(x =>x.GetViewModel)
.ToList();
}
@ -82,9 +88,7 @@ namespace FactoryDatabaseImplement.Implements
if (newPlanProduction == null)
{
return null;
}
}
context.PlanProductions.Add(newPlanProduction);
context.SaveChanges();
return newPlanProduction.GetViewModel;

View File

@ -23,10 +23,6 @@ namespace FactoryDatabaseImplement.Implements
public List<WorkpieceViewModel> GetFilteredList(WorkpieceSearchModel model)
{
if (string.IsNullOrEmpty(model.WorkpieceName))
{
return new();
}
using var context = new FactoryDatabase();
if (model.DateFrom.HasValue)
return context.Workpieces.Where(x => x.ClientId == model.ClientId).Where(x => x.DateCreate <= model.DateTo && x.DateCreate >= model.DateFrom).Select(x => x.GetViewModel).ToList();
@ -34,7 +30,7 @@ namespace FactoryDatabaseImplement.Implements
.Include(x => x.Client)
.Include(x => x.Products)
.ThenInclude(x => x.Product)
.Where(x => x.WorkpieceName.Contains(model.WorkpieceName))
.Where(x => x.WorkpieceName.Contains(model.WorkpieceName) || (x.ClientId == model.ClientId))
.ToList()
.Select(x => x.GetViewModel)
.ToList();

View File

@ -12,7 +12,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace FactoryDatabaseImplement.Migrations
{
[DbContext(typeof(FactoryDatabase))]
[Migration("20240524172651_InitCreate")]
[Migration("20240528082259_InitCreate")]
partial class InitCreate
{
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@ -71,7 +71,8 @@ namespace FactoryDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<int>("PlanProductionId")
b.Property<int?>("PlanProductionId")
.IsRequired()
.HasColumnType("integer");
b.Property<int>("Status")
@ -299,6 +300,9 @@ namespace FactoryDatabaseImplement.Migrations
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<string>("Material")
.IsRequired()
.HasColumnType("text");

View File

@ -79,7 +79,8 @@ namespace FactoryDatabaseImplement.Migrations
WorkpieceName = table.Column<string>(type: "text", nullable: false),
ClientId = table.Column<int>(type: "integer", nullable: false),
Material = table.Column<string>(type: "text", nullable: false),
Cost = table.Column<double>(type: "double precision", nullable: false)
Cost = table.Column<double>(type: "double precision", nullable: false),
DateCreate = table.Column<DateTime>(type: "timestamp without time zone", nullable: false)
},
constraints: table =>
{

View File

@ -69,7 +69,8 @@ namespace FactoryDatabaseImplement.Migrations
.IsRequired()
.HasColumnType("text");
b.Property<int>("PlanProductionId")
b.Property<int?>("PlanProductionId")
.IsRequired()
.HasColumnType("integer");
b.Property<int>("Status")
@ -297,6 +298,9 @@ namespace FactoryDatabaseImplement.Migrations
b.Property<double>("Cost")
.HasColumnType("double precision");
b.Property<DateTime>("DateCreate")
.HasColumnType("timestamp without time zone");
b.Property<string>("Material")
.IsRequired()
.HasColumnType("text");

View File

@ -15,7 +15,7 @@ namespace FactoryDatabaseImplement.Models
public virtual Client Client { get; private set; } = new();
[Required]
public int PlanProductionId { get; private set; }
public int? PlanProductionId { get; private set; }
public virtual PlanProduction PlanProduction { get; private set; } = new();
[Required]

View File

@ -59,9 +59,9 @@ namespace FactoryWorkerApp.Controllers
}
[HttpPost]
public void Register(string name, string login, string email, string password1, string password2)
public void Register(string name, string login, string email, string password, string passwordConfirm)
{
if (password1 == password2 && _logic.Register(new() { Email = email, Login = login, Role = ClientRole.Работник, Password = password1 }))
if (password == passwordConfirm && _logic.Register(new() { Email = email, Login = login, Role = ClientRole.Работник, Password = password }))
{
Response.Redirect("Index");
}
@ -73,7 +73,7 @@ namespace FactoryWorkerApp.Controllers
{
if (Client.user != null)
{
var list = _logic.GetWorkpieces(Client.user.Id); ;
var list = _logic.GetWorkpieces(Client.user.Id);
if (list != null)
return View(list);
return View(new List<WorkpieceViewModel>());
@ -250,12 +250,12 @@ namespace FactoryWorkerApp.Controllers
var startDate = DateTime.Parse(startDateStr);
var endDate = DateTime.Parse(endDateStr).AddDays(1);
var values = _logic.GetTimeReport(startDate, endDate, UserId);
//var values = _logic.GetTimeReport(startDate, endDate, UserId);
ViewBag.StartDate = startDate;
ViewBag.EndDate = endDate;
return View(values);
return View();
}
@ -291,18 +291,21 @@ namespace FactoryWorkerApp.Controllers
}
[HttpPost]
// доделать
public IActionResult ExecutionPhase(int id, string title, int planId)
public IActionResult ExecutionPhase(int id, string name, ExecutionPhaseStatus status, string impFIO, int planId)
{
ExecutionPhaseBindingModel model = new ExecutionPhaseBindingModel();
model.Id = id;
model.ExecutionPhaseName = title;
model.ExecutionPhaseName = name;
model.ClientId = Client.user!.Id;
model.PlanProductionId = planId;
if (model.PlanProductionId.HasValue)
model.ImplementerFIO = impFIO;
model.Status = status;
if (id!=0)
{
_logic.UpdateExecutionPhase(model);
}
_logic.CreateExecutionPhase(model);
else
_logic.CreateExecutionPhase(model);
return RedirectToAction("ExecutionPhases");
}

View File

@ -15,6 +15,7 @@
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\FactoryBuisinessLogic\FactoryBuisinessLogic.csproj" />
<ProjectReference Include="..\FactoryDatabaseImplement\FactoryDatabaseImplement.csproj" />
</ItemGroup>

View File

@ -1,3 +1,8 @@
using FactoryContracts.BusinessLogicsContracts;
using FactoryBusinessLogic.BusinessLogics;
using FactoryBuisinessLogic.BusinessLogics;
using FactoryContracts.StoragesContracts;
using FactoryDatabaseImplement.Implements;
using FactoryWorkerApp;
var builder = WebApplication.CreateBuilder(args);
@ -5,6 +10,31 @@ var builder = WebApplication.CreateBuilder(args);
// Add services to the container.
builder.Services.AddControllersWithViews();
builder.Logging.SetMinimumLevel(LogLevel.Trace);
builder.Services.AddTransient<IClientStorage, ClientStorage>();
builder.Services.AddTransient<IWorkpieceStorage, WorkpieceStorage>();
builder.Services.AddTransient<IProductStorage, ProductStorage>();
builder.Services.AddTransient<IPlanProductionStorage, PlanProductionStorage>();
builder.Services.AddTransient<IExecutionPhaseStorage, ExecutionPhaseStorage>();
builder.Services.AddTransient<IMachineStorage, MachineStorage>();
builder.Services.AddTransient<IClientLogic, ClientLogic>();
builder.Services.AddTransient<IWorkpieceLogic, WorkpieceLogic>();
builder.Services.AddTransient<IProductLogic, ProductLogic>();
builder.Services.AddTransient<IPlanProductionLogic, PlanProductionLogic>();
builder.Services.AddTransient<IExecutionPhaseLogic, ExecutionPhaseLogic>();
builder.Services.AddTransient<IMachineLogic, MachineLogic>();
builder.Services.AddTransient<WorkerLogic>();
builder.Services.AddSession(options =>
{
options.IdleTimeout = TimeSpan.FromMinutes(30);
options.Cookie.HttpOnly = true;
options.Cookie.IsEssential = true;
});
var app = builder.Build();
// Configure the HTTP request pipeline.

View File

@ -4,7 +4,7 @@
@model ExecutionPhaseViewModel;
@{
ViewData["Title"] = "Workpiece";
ViewData["Title"] = "Execution Phase";
}
<div class="text-center">
<h2 class="display-4">Заготовка</h2>
@ -12,18 +12,24 @@
<form method="post">
<div class="row">
<div class="col-4">План производства:</div>
<select id="PlanProductionSelect" class="form-control">
<div class="col-8">
<select id="planId" class="form-control">
<option value="">Выберите план</option>
@foreach (var planProduction in ViewBag.AllPlans)
{
<option value="@planProduction.Id">@planProduction.PlanProductionName</option>
<option value="@planProduction.Id">@planProduction.ProductionName</option>
}
</select>
</div>
</div>
<div class="row">
<div class="col-4">Название:</div>
<div class="col-8"><input type="text" name="name" id="name" value="@Model.ExecutionPhaseName"/></div>
</div>
<div class="row">
<div class="col-4">ФИО исполнителя:</div>
<div class="col-8"><input type="text" name="impFIO" id="impFIO" value="@Model.ImplementerFIO" /></div>
</div>
<div class="row">
<div class="col-4">Статус:</div>
<div class="col-8">

View File

@ -65,7 +65,10 @@
<a asp-action="ExecutionPhase" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<a asp-action="DeleteExecutionPhase" asp-route-id="@item.Id" class="btn btn-danger">Удалить</a>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}

View File

@ -18,7 +18,7 @@
</div>
<div class="row">
<div class="col-4">Срок выполнения:</div>
<div class="col-8"><input asp-format="{0:yyyy-MM-dd}" id="deadline" name="deadline" value="@Model.Deadline" /></div>
<div class="col-8"><input type="date" id="deadline" name="deadline" value="@Model.Deadline" /></div>
</div>
<div class="row">
<div class="col-8"></div>

View File

@ -59,8 +59,11 @@
<a asp-action="PlanProduction" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<a asp-action="DelePlanProduction" asp-route-id="@item.Id" class="btn btn-danger">Удалить</a>
</td>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}
</tbody>

View File

@ -58,7 +58,10 @@
<a asp-action="Workpiece" asp-route-id="@item.Id" class="btn btn-primary">Изменить</a>
</td>
<td>
<a asp-action="DeletWorkpiece" asp-route-id="@item.Id" class="btn btn-danger">Удалить</a>
<form method="post">
<input type="text" title="id" name="id" value="@item.Id" hidden="hidden" />
<input type="submit" class="btn btn-danger" value="Удалить" />
</form>
</td>
</tr>
}