added graphics page and 2 graphics
This commit is contained in:
parent
ae9d5eb54c
commit
000fcfef44
@ -54,7 +54,7 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
else if (model.DateFrom != null && model.DateTo != null && model.UserId.HasValue)
|
||||
{
|
||||
return context.OrderInfos
|
||||
.Include(x => x.User)
|
||||
@ -62,6 +62,14 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.DateFrom != null && model.DateTo != null)
|
||||
{
|
||||
return context.OrderInfos
|
||||
.Include(x => x.User)
|
||||
.Where(x => x.DateCreate >= model.DateFrom.Value.ToUniversalTime() && x.DateCreate <= model.DateTo.Value.ToUniversalTime())
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.UserId.HasValue)
|
||||
{
|
||||
return context.OrderInfos
|
||||
|
@ -86,6 +86,19 @@ namespace FurnitureAssemblyDatabaseImplement.Implements
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
else if (model.RoleId != 0)
|
||||
{
|
||||
return context.Users
|
||||
.Include(x => x.Sets)
|
||||
.Include(x => x.Orders)
|
||||
.Include(x => x.FurnitureModules)
|
||||
.Include(x => x.Furnitures)
|
||||
.Include(x => x.Materials)
|
||||
.Include(x => x.Role)
|
||||
.Where(x => x.RoleId == model.RoleId)
|
||||
.Select(x => x.GetViewModel)
|
||||
.ToList();
|
||||
}
|
||||
return new();
|
||||
}
|
||||
public List<UserViewModel> GetFullList()
|
||||
|
@ -49,6 +49,7 @@ namespace FurnitureAssemblyDatabaseImplement.Models
|
||||
}
|
||||
CustomerName = model.CustomerName;
|
||||
PaymentType = model.PaymentType;
|
||||
DateCreate = model.DateCreate.ToUniversalTime();
|
||||
UserId = model.UserId;
|
||||
Sum = model.Sum;
|
||||
}
|
||||
|
@ -15,10 +15,12 @@ namespace FurnitureAssemblyRestApi.Controllers
|
||||
{
|
||||
private readonly ILogger _logger;
|
||||
private readonly IOrderInfoLogic _orderInfo;
|
||||
public OrderInfoController(ILogger<OrderInfoController> logger, IOrderInfoLogic orderInfo)
|
||||
private readonly IUserLogic _user;
|
||||
public OrderInfoController(ILogger<OrderInfoController> logger, IOrderInfoLogic orderInfo, IUserLogic user)
|
||||
{
|
||||
_logger = logger;
|
||||
_orderInfo = orderInfo;
|
||||
_user = user;
|
||||
}
|
||||
|
||||
[HttpGet]
|
||||
@ -60,6 +62,54 @@ namespace FurnitureAssemblyRestApi.Controllers
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<List<OrderInfoViewModel>>? GetOrderInfoListByDate()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<List<OrderInfoViewModel>> list = new List<List<OrderInfoViewModel>>();
|
||||
for (int i = 1; i <= 12; i++)
|
||||
{
|
||||
var resp = _orderInfo.ReadList(new OrderInfoSearchModel
|
||||
{
|
||||
DateFrom = new DateTime(DateTime.Today.Year - 1, i, 1, 0, 0, 0),
|
||||
DateTo = new DateTime(DateTime.Today.Year - 1, i, DateTime.DaysInMonth(DateTime.Today.Year - 1, i) - 1, 23, 59, 59)
|
||||
});
|
||||
list.Add(resp == null ? null : resp);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов по времени}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpGet]
|
||||
public List<Tuple<string, double>>? GetGraphicUsersByPreviousMonth()
|
||||
{
|
||||
try
|
||||
{
|
||||
List<Tuple<string, double>> list = new List<Tuple<string, double>>();
|
||||
List<UserViewModel> users = _user.ReadList(new UserSearchModel { RoleId = 4 });
|
||||
foreach (var user in users)
|
||||
{
|
||||
var resp = _orderInfo.ReadList(new OrderInfoSearchModel
|
||||
{
|
||||
DateFrom = new DateTime(DateTime.Today.Year, DateTime.Today.Month-1, 1, 0, 0, 0),
|
||||
DateTo = new DateTime(DateTime.Today.Year, DateTime.Today.Month - 1, DateTime.DaysInMonth(DateTime.Today.Year, DateTime.Today.Month - 1), 23, 59, 59),
|
||||
UserId = user.Id
|
||||
});
|
||||
list.Add(new Tuple<string, double>(user.Name, resp.Sum(x => x.Sum)));
|
||||
}
|
||||
return list;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
_logger.LogError(ex, "Ошибка получения списка заказов по времени}");
|
||||
throw;
|
||||
}
|
||||
}
|
||||
[HttpPost]
|
||||
public OrderInfoViewModel? AddOrderInfo(OrderInfoBindingModel model)
|
||||
{
|
||||
|
@ -96,7 +96,7 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
APIClient.User = null;
|
||||
throw new Exception("Данному сотруднику вход запрещен");
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
Response.Redirect("Orders");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Register()
|
||||
@ -455,7 +455,7 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
counts[i]
|
||||
));
|
||||
}
|
||||
Response.Redirect("Index");
|
||||
Response.Redirect("AddFurnitureModulesInSet");
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Orders()
|
||||
@ -711,5 +711,41 @@ namespace FurnitureAssemblyWorkerClientApp.Controllers
|
||||
html += $"<h3 style=\"align-self: self-start;\">Итого: {result.Item2}</h3>";
|
||||
return html;
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult GraphicOrdersByPreviousYear()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View(APIClient.GetRequest<List<List<OrderInfoViewModel>>>($"api/orderinfo/getorderinfolistbydate"));
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult Graphics()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public IActionResult GraphicUsersByPreviousMonth()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
return Redirect("~/Home/Enter");
|
||||
}
|
||||
return View();
|
||||
}
|
||||
[HttpGet]
|
||||
public List<Tuple<string, double>> GetGraphicUsersByPreviousMonth()
|
||||
{
|
||||
if (APIClient.User == null)
|
||||
{
|
||||
throw new Exception("Вы как суда попали? Суда вход только авторизованным");
|
||||
}
|
||||
return APIClient.GetRequest<List<Tuple<string, double>>>($"api/orderinfo/getgraphicusersbypreviousmonth");
|
||||
}
|
||||
}
|
||||
}
|
@ -16,6 +16,7 @@ builder.Services.AddTransient<AbstractWorkerSaveToExcel, SaveToExcel>();
|
||||
builder.Services.AddTransient<AbstractWorkerSaveToPdf, SaveToPdf>();
|
||||
builder.Services.AddTransient<AbstractWorkerSaveToWord, SaveToWord>();
|
||||
|
||||
builder.Services.AddHttpContextAccessor();
|
||||
// Add services to the container.
|
||||
builder.Services.AddControllersWithViews();
|
||||
|
||||
@ -38,6 +39,6 @@ app.UseAuthorization();
|
||||
|
||||
app.MapControllerRoute(
|
||||
name: "default",
|
||||
pattern: "{controller=Home}/{action=Index}/{id?}");
|
||||
pattern: "{controller=Home}/{action=Orders}/{id?}");
|
||||
|
||||
app.Run();
|
||||
|
@ -0,0 +1,140 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@model List<List<OrderInfoViewModel>>
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "График продаж за предыдущий год";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
if (Model == null)
|
||||
{
|
||||
<h3 class="display-4">График продаж за предыдущий год</h3>
|
||||
return;
|
||||
}
|
||||
|
||||
<div id="chartdiv" style="height: 700px;">
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
|
||||
/**
|
||||
* ---------------------------------------
|
||||
* This demo was created using amCharts 5.
|
||||
*
|
||||
* For more information visit:
|
||||
* https://www.amcharts.com/
|
||||
*
|
||||
* Documentation is available at:
|
||||
* https://www.amcharts.com/docs/v5/
|
||||
* ---------------------------------------
|
||||
*/
|
||||
|
||||
// Create root element
|
||||
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
||||
var root = am5.Root.new("chartdiv");
|
||||
|
||||
|
||||
// Set themes
|
||||
// https://www.amcharts.com/docs/v5/concepts/themes/
|
||||
root.setThemes([
|
||||
am5themes_Animated.new(root)
|
||||
]);
|
||||
|
||||
|
||||
// Create chart
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/
|
||||
var chart = root.container.children.push(am5xy.XYChart.new(root, {
|
||||
panX: false,
|
||||
panY: false,
|
||||
wheelX: "panX",
|
||||
wheelY: "zoomX",
|
||||
layout: root.verticalLayout
|
||||
}));
|
||||
|
||||
|
||||
// Add legend
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/legend-xy-series/
|
||||
var legend = chart.children.push(
|
||||
am5.Legend.new(root, {
|
||||
centerX: am5.p50,
|
||||
x: am5.p50
|
||||
})
|
||||
);
|
||||
|
||||
var data = [
|
||||
{ year: "1", europe: @Model[0].Sum(x => x.Sum) },
|
||||
{ year: "2", europe: @Model[1].Sum(x => x.Sum) },
|
||||
{ year: "3", europe: @Model[2].Sum(x => x.Sum) },
|
||||
{ year: "4", europe: @Model[3].Sum(x => x.Sum) },
|
||||
{ year: "5", europe: @Model[4].Sum(x => x.Sum) },
|
||||
{ year: "6", europe: @Model[5].Sum(x => x.Sum) },
|
||||
{ year: "7", europe: @Model[6].Sum(x => x.Sum) },
|
||||
{ year: "8", europe: @Model[7].Sum(x => x.Sum) },
|
||||
{ year: "9", europe: @Model[8].Sum(x => x.Sum) },
|
||||
{ year: "10", europe: @Model[9].Sum(x => x.Sum) },
|
||||
{ year: "11", europe: @Model[10].Sum(x => x.Sum) },
|
||||
{ year: "12", europe: @Model[11].Sum(x => x.Sum) }
|
||||
];
|
||||
|
||||
|
||||
// Create axes
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
||||
var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
|
||||
categoryField: "year",
|
||||
renderer: am5xy.AxisRendererX.new(root, {
|
||||
cellStartLocation: 0.1,
|
||||
cellEndLocation: 0.9
|
||||
}),
|
||||
tooltip: am5.Tooltip.new(root, {})
|
||||
}));
|
||||
|
||||
xAxis.data.setAll(data);
|
||||
|
||||
var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
|
||||
renderer: am5xy.AxisRendererY.new(root, {})
|
||||
}));
|
||||
|
||||
|
||||
// Add series
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
||||
function makeSeries(name, fieldName) {
|
||||
var series = chart.series.push(am5xy.ColumnSeries.new(root, {
|
||||
name: name,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
valueYField: fieldName,
|
||||
categoryXField: "year",
|
||||
stacked: true
|
||||
}));
|
||||
|
||||
series.events.on("datavalidated", function () {
|
||||
yAxis.setAll({
|
||||
min: yAxis.getPrivate("min"),
|
||||
max: yAxis.getPrivate("max"),
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
});
|
||||
|
||||
series.data.setAll(data);
|
||||
series.appear();
|
||||
}
|
||||
|
||||
makeSeries("Europe", "europe");
|
||||
|
||||
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
||||
orientation: "horizontal"
|
||||
}));
|
||||
|
||||
|
||||
// Make stuff animate on load
|
||||
// https://www.amcharts.com/docs/v5/concepts/animations/
|
||||
chart.appear(1000, 100);
|
||||
|
||||
</script>
|
||||
}
|
@ -0,0 +1,117 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "График продаж продавцов за предыдущий месяц";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<h3 class="display-4">График продаж продавцов за предыдущий месяц</h3>
|
||||
|
||||
<div id="chartdiv" style="height: 700px;">
|
||||
</div>
|
||||
}
|
||||
</div>
|
||||
|
||||
@section Scripts {
|
||||
<script>
|
||||
$.ajax({
|
||||
method: "GET",
|
||||
url: "/Home/GetGraphicUsersByPreviousMonth",
|
||||
success: function (result) {
|
||||
|
||||
var data = [];
|
||||
|
||||
result.forEach((el) => {
|
||||
data.push({year: el.item1, europe: el.item2});
|
||||
});
|
||||
|
||||
// Create root element
|
||||
// https://www.amcharts.com/docs/v5/getting-started/#Root_element
|
||||
var root = am5.Root.new("chartdiv");
|
||||
|
||||
|
||||
// Set themes
|
||||
// https://www.amcharts.com/docs/v5/concepts/themes/
|
||||
root.setThemes([
|
||||
am5themes_Animated.new(root)
|
||||
]);
|
||||
|
||||
|
||||
// Create chart
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/
|
||||
var chart = root.container.children.push(am5xy.XYChart.new(root, {
|
||||
panX: false,
|
||||
panY: false,
|
||||
wheelX: "panX",
|
||||
wheelY: "zoomX",
|
||||
layout: root.verticalLayout
|
||||
}));
|
||||
|
||||
|
||||
// Add legend
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/legend-xy-series/
|
||||
var legend = chart.children.push(
|
||||
am5.Legend.new(root, {
|
||||
centerX: am5.p50,
|
||||
x: am5.p50
|
||||
})
|
||||
);
|
||||
|
||||
// Create axes
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/axes/
|
||||
var xAxis = chart.xAxes.push(am5xy.CategoryAxis.new(root, {
|
||||
categoryField: "year",
|
||||
renderer: am5xy.AxisRendererX.new(root, {
|
||||
cellStartLocation: 0.1,
|
||||
cellEndLocation: 0.9
|
||||
}),
|
||||
tooltip: am5.Tooltip.new(root, {})
|
||||
}));
|
||||
|
||||
xAxis.data.setAll(data);
|
||||
|
||||
var yAxis = chart.yAxes.push(am5xy.ValueAxis.new(root, {
|
||||
renderer: am5xy.AxisRendererY.new(root, {})
|
||||
}));
|
||||
|
||||
|
||||
// Add series
|
||||
// https://www.amcharts.com/docs/v5/charts/xy-chart/series/
|
||||
function makeSeries(name, fieldName) {
|
||||
var series = chart.series.push(am5xy.ColumnSeries.new(root, {
|
||||
name: name,
|
||||
xAxis: xAxis,
|
||||
yAxis: yAxis,
|
||||
valueYField: fieldName,
|
||||
categoryXField: "year",
|
||||
stacked: true
|
||||
}));
|
||||
|
||||
series.events.on("datavalidated", function () {
|
||||
yAxis.setAll({
|
||||
min: yAxis.getPrivate("min"),
|
||||
max: yAxis.getPrivate("max"),
|
||||
start: 0,
|
||||
end: 1
|
||||
});
|
||||
});
|
||||
|
||||
series.data.setAll(data);
|
||||
series.appear();
|
||||
}
|
||||
|
||||
makeSeries("Europe", "europe");
|
||||
|
||||
chart.set("scrollbarX", am5.Scrollbar.new(root, {
|
||||
orientation: "horizontal"
|
||||
}));
|
||||
|
||||
|
||||
// Make stuff animate on load
|
||||
// https://www.amcharts.com/docs/v5/concepts/animations/
|
||||
chart.appear(1000, 100);
|
||||
}
|
||||
});
|
||||
</script>
|
||||
}
|
@ -0,0 +1,19 @@
|
||||
@using FurnitureAssemblyContracts.ViewModels
|
||||
|
||||
|
||||
@{
|
||||
ViewData["Title"] = "Графики";
|
||||
}
|
||||
|
||||
<div class="text-center">
|
||||
<h1 class="display-4">Графики</h1>
|
||||
</div>
|
||||
|
||||
<div class="text-center">
|
||||
@{
|
||||
<div>
|
||||
<a asp-action="GraphicOrdersByPreviousYear">График продаж за предыдущий год</a>
|
||||
<a asp-action="GraphicUsersByPreviousMonth">График продаж продавцов за предыдущий месяц</a>
|
||||
</div>
|
||||
}
|
||||
</div>
|
@ -7,6 +7,9 @@
|
||||
<link rel="stylesheet" href="~/lib/bootstrap/dist/css/bootstrap.min.css" />
|
||||
<link rel="stylesheet" href="~/css/site.css" asp-append-version="true" />
|
||||
<link rel="stylesheet" href="~/FurnitureAssemblyClientApp.styles.css" asp-append-version="true" />
|
||||
<script src="//cdn.amcharts.com/lib/5/index.js"></script>
|
||||
<script src="//cdn.amcharts.com/lib/5/xy.js"></script>
|
||||
<script src="//cdn.amcharts.com/lib/5/themes/Animated.js"></script>
|
||||
</head>
|
||||
<body>
|
||||
<header>
|
||||
@ -40,6 +43,9 @@
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Privacy">Личные данные</a>
|
||||
</li>
|
||||
<li class="nav-item">
|
||||
<a class="nav-link text-dark" asp-area="" asp-controller="Home" asp-action="Graphics">Графики</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user