d657dfde99
展示公司焊接统计,支持维护菜单和看板标题,并按用户权限限制项目入口。
81 lines
4.1 KiB
C#
81 lines
4.1 KiB
C#
using BLL;
|
||
using Newtonsoft.Json;
|
||
using System;
|
||
using System.Collections.Generic;
|
||
using System.Globalization;
|
||
using System.Linq;
|
||
using System.Web;
|
||
|
||
namespace FineUIPro.Web.common
|
||
{
|
||
public partial class main : PageBase
|
||
{
|
||
protected Model.CompanyWeldingDashboard Welding;
|
||
protected List<Model.CompanyWeldingProject> ProgressProjects, QualityProjects;
|
||
protected decimal LargestProjectDine;
|
||
protected DateTime AsOfDate;
|
||
protected string ChartsJson;
|
||
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
AsOfDate = DateTime.Today;
|
||
Welding = HJGLData_HJGLService.GetCompanyWeldingDashboard(AsOfDate);
|
||
ProgressProjects = Welding.Projects.OrderByDescending(x => x.RemainingDine).ThenBy(x => x.ProjectName).ToList();
|
||
QualityProjects = Welding.Projects.OrderBy(x => !x.CurrentMonth.FirstPassRate.HasValue)
|
||
.ThenBy(x => x.CurrentMonth.FirstPassRate).ThenBy(x => x.ProjectName).ToList();
|
||
LargestProjectDine = Welding.Projects.Select(x => x.TotalDine).DefaultIfEmpty().Max();
|
||
|
||
var points = new List<object>();
|
||
string tooltipFormat = GetGlobalResourceObject("UiText", "T_项目名称") + ":{0}\n"
|
||
+ GetGlobalResourceObject("UiText", "T_开工日期") + ":{1:yyyy-MM-dd}\n"
|
||
+ GetGlobalResourceObject("UiText", "T_竣工日期") + ":{2:yyyy-MM-dd}\n"
|
||
+ GetGlobalResourceObject("UiText", "T_项目地址") + ":{3}";
|
||
foreach (var project in Welding.Projects.Where(x => !string.IsNullOrWhiteSpace(x.MapCoordinates)))
|
||
{
|
||
var coordinates = project.MapCoordinates.Split(',');
|
||
decimal longitude, latitude;
|
||
if (coordinates.Length != 2
|
||
|| !decimal.TryParse(coordinates[0], NumberStyles.Float, CultureInfo.InvariantCulture, out longitude)
|
||
|| !decimal.TryParse(coordinates[1], NumberStyles.Float, CultureInfo.InvariantCulture, out latitude)
|
||
|| Math.Abs(longitude) > 180 || Math.Abs(latitude) > 90)
|
||
continue;
|
||
|
||
points.Add(new
|
||
{
|
||
name = project.ProjectName,
|
||
value = new[] { longitude, latitude },
|
||
tooltipText = string.Format(tooltipFormat, project.ProjectName, project.StartDate, project.EndDate, project.ProjectAddress),
|
||
url = ProjectUrl(project.ProjectId)
|
||
});
|
||
}
|
||
ChartsJson = JsonConvert.SerializeObject(new
|
||
{
|
||
points,
|
||
months = Welding.Months.Select(x => new
|
||
{
|
||
label = x.Month.ToString(UiLanguage.Current == "en" ? "MMM" : "M月", CultureInfo.CurrentUICulture),
|
||
dine = x.CompletedDine,
|
||
rate = x.FirstPassRate * 100m
|
||
}),
|
||
quality = QualityProjects.Where(x => x.CurrentMonth.TotalFilms > 0).Select(x => new
|
||
{
|
||
name = x.ProjectName, rate = x.CurrentMonth.FirstPassRate * 100m, url = ProjectUrl(x.ProjectId)
|
||
}),
|
||
companyRate = Welding.MonthFirstPassRate * 100m,
|
||
labels = new
|
||
{
|
||
volume = TextFor("完成焊接量_万达因"), rate = TextFor("焊接一次合格率"),
|
||
dine = TextFor("达因")
|
||
}
|
||
}, new JsonSerializerSettings { StringEscapeHandling = StringEscapeHandling.EscapeHtml });
|
||
}
|
||
|
||
protected string TextFor(string key) => (string)GetGlobalResourceObject("UiText", "T_" + key);
|
||
protected string ProjectUrl(string id) => ResolveUrl("~/indexProject.aspx?projectId=" + HttpUtility.UrlEncode(id));
|
||
protected static string Dine(decimal value) => value.ToString("#,0.############################");
|
||
protected static string Rate(decimal? value) => value?.ToString("0.00%") ?? "--";
|
||
protected static string Width(decimal part, decimal total) =>
|
||
(total > 0 ? part / total : 0m).ToString("0.####%", CultureInfo.InvariantCulture);
|
||
}
|
||
}
|