486 lines
19 KiB
C#
486 lines
19 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.Data;
|
||
using System.Linq;
|
||
using BLL;
|
||
|
||
namespace FineUIPro.Web.Transfer.Chart
|
||
{
|
||
public partial class Instrumentation : PageBase
|
||
{
|
||
#region 定义项
|
||
/// <summary>
|
||
/// 项目主键
|
||
/// </summary>
|
||
public string ProjectId
|
||
{
|
||
get
|
||
{
|
||
return (string)ViewState["ProjectId"];
|
||
}
|
||
set
|
||
{
|
||
ViewState["ProjectId"] = value;
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
#region 加载页面
|
||
/// <summary>
|
||
/// 加载页面
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void Page_Load(object sender, EventArgs e)
|
||
{
|
||
if (!IsPostBack)
|
||
{
|
||
this.ProjectId = this.CurrUser.LoginProjectId;
|
||
if (!string.IsNullOrEmpty(Request.Params["projectId"]))
|
||
{
|
||
this.ProjectId = Request.Params["projectId"];
|
||
}
|
||
|
||
//this.AnalyseData();
|
||
}
|
||
}
|
||
#endregion
|
||
|
||
protected void drpdateType_SelectedIndexChanged(object sender, EventArgs e) {
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
txtStarTime.Hidden = false;
|
||
txtEndTime.Hidden = false;
|
||
|
||
txtStarTime1.Hidden = true;
|
||
txtEndTime1.Hidden = true;
|
||
}
|
||
else {
|
||
txtStarTime1.Hidden = false;
|
||
txtEndTime1.Hidden = false;
|
||
|
||
txtStarTime.Hidden = true;
|
||
txtEndTime.Hidden = true;
|
||
}
|
||
}
|
||
|
||
#region 统计
|
||
/// <summary>
|
||
/// 统计方法
|
||
/// </summary>
|
||
private void AnalyseData()
|
||
{
|
||
if (string.IsNullOrEmpty(ProjectId))
|
||
{
|
||
Alert.ShowInTop("项目未获取到,请刷新页面。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
var sTime = DateTime.Now.AddDays(-7);
|
||
var eTime = DateTime.Now; ;
|
||
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
if (string.IsNullOrEmpty(txtStarTime.Text) || string.IsNullOrEmpty(txtEndTime.Text))
|
||
{
|
||
Alert.ShowInTop("请选择日期。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else {
|
||
sTime = Convert.ToDateTime(txtStarTime.Text);
|
||
|
||
eTime = Convert.ToDateTime(txtEndTime.Text).AddMonths(1).AddDays(-1);
|
||
}
|
||
}
|
||
else {
|
||
if (string.IsNullOrEmpty(txtStarTime1.Text) || string.IsNullOrEmpty(txtEndTime1.Text))
|
||
{
|
||
Alert.ShowInTop("请选择日期。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else {
|
||
sTime = Convert.ToDateTime(txtStarTime1.Text);
|
||
eTime = Convert.ToDateTime(txtEndTime1.Text);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
////如果没有填写日期,则是七天内的
|
||
//if (!string.IsNullOrEmpty(txtStarTime.Text) && !string.IsNullOrEmpty(txtEndTime.Text))
|
||
// {
|
||
|
||
|
||
//}
|
||
|
||
//查询当前日期中的system的具体数目,去除重复
|
||
var list = Funs.DB.View_TransferDetail.Where(x => x.Projectid == ProjectId
|
||
&& x.FDate >= sTime && x.FDate <= eTime).ToList();
|
||
|
||
var SystemList = (from x in list select x.SystemName).Distinct();
|
||
|
||
//先加载左侧system 树菜单
|
||
LoadData(SystemList);
|
||
|
||
DataTable dtTime = new DataTable();
|
||
dtTime.Columns.Add("日期", typeof(string));
|
||
dtTime.Columns.Add("Finished", typeof(string));
|
||
dtTime.Columns.Add("In Progress", typeof(string));
|
||
dtTime.Columns.Add("Not Start", typeof(string));
|
||
|
||
var systemBol = false;
|
||
for (var i = sTime; i <= eTime; i=returnDay(i))
|
||
{
|
||
var finishedCount = 0;
|
||
var inProgress = 0;
|
||
var notStart = 0;
|
||
DataRow rowTime = dtTime.NewRow();
|
||
Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem();
|
||
|
||
//按年月
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
rowTime["日期"] = string.Format("{0:yyyy-MM}", i);
|
||
}
|
||
else {
|
||
rowTime["日期"] = string.Format("{0:yyyy-MM-dd}", i);
|
||
}
|
||
|
||
|
||
//根据日期查询当前system的数量
|
||
var systemListbyDate = Funs.DB.View_TransferDetail.Where(x => x.Projectid == ProjectId
|
||
&& x.FDate >= Convert.ToDateTime(rowTime["日期"])
|
||
&& x.FDate < Convert.ToDateTime(rowTime["日期"]).AddDays(1)).ToList();
|
||
//如果按年月
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
systemListbyDate = Funs.DB.View_TransferDetail.Where(x => x.Projectid == ProjectId
|
||
&& x.FDate >= Convert.ToDateTime(rowTime["日期"])
|
||
&& x.FDate < Convert.ToDateTime(rowTime["日期"]).AddMonths(1)).ToList();
|
||
}
|
||
|
||
|
||
//查询TestPackage 去重
|
||
var testpackageList = (from x in systemListbyDate select x.TestPackage).Distinct();
|
||
|
||
if (testpackageList.ToList().Count>0)
|
||
{
|
||
systemBol = true;
|
||
}
|
||
foreach (var item in testpackageList)
|
||
{
|
||
//查询当前日期每个testpackage的数量
|
||
var systemSumCount = systemListbyDate.Where(x => x.TestPackage == item).ToList().Count;
|
||
|
||
//子系统中完成的数量
|
||
var subSystemSumCount = systemListbyDate.Where(x => x.TestPackage == item &&
|
||
x.Status.ToLower() == "finished").ToList().Count;
|
||
|
||
//子系统中没完成的情况
|
||
var subSystemSumNotStartCount = systemListbyDate.Where(x => x.TestPackage == item &&
|
||
(x.Status.ToLower() == "not start"|| x.Status=="" || x.Status==null )).ToList().Count;
|
||
|
||
//如果总数量等于完成的数量,完成量+1
|
||
if (systemSumCount == subSystemSumCount)
|
||
{
|
||
//如果都是完成,需要最后 12表 test packge 必须是Finished才能是完成
|
||
var punchlistFromList= Funs.DB.Transfer_PunchlistFrom.Where(x=>x.ProjectId==ProjectId
|
||
&& x.Test_Package==item
|
||
).ToList();
|
||
|
||
////如果按年月
|
||
//if (drpdateType.SelectedValue == "0") {
|
||
// punchlistFromList = Funs.DB.Transfer_PunchlistFrom.Where(x => x.ProjectId == ProjectId
|
||
// && x.Test_Package == item
|
||
// && x.PUNCH_ITEM_FINISH_DATE >= Convert.ToDateTime(rowTime["日期"])
|
||
// && x.PUNCH_ITEM_FINISH_DATE < Convert.ToDateTime(rowTime["日期"]).AddMonths(1)).ToList();
|
||
//}
|
||
|
||
//如果查到
|
||
if (punchlistFromList.Count > 0)
|
||
{
|
||
//12表当前日期完成的数量
|
||
var punchlistFromFinshCount = punchlistFromList.Where(x => x.PUNCH_ITEM_STATUS.ToLower() == "finished").ToList().Count();
|
||
//如果完成的数量等于总得数量,则是完成
|
||
if (punchlistFromFinshCount == punchlistFromList.Count)
|
||
{
|
||
finishedCount += 1;
|
||
}
|
||
else {
|
||
inProgress += 1;
|
||
}
|
||
}
|
||
else {
|
||
finishedCount += 1;
|
||
}
|
||
}
|
||
//如果总数量等于not start,未开始量+1
|
||
else if (systemSumCount== subSystemSumNotStartCount)
|
||
{
|
||
notStart += 1;
|
||
}
|
||
else {
|
||
inProgress += 1;
|
||
}
|
||
}
|
||
rowTime["Finished"] = finishedCount;
|
||
rowTime["In Progress"] = inProgress;
|
||
rowTime["Not Start"] = notStart;
|
||
dtTime.Rows.Add(rowTime);
|
||
|
||
}
|
||
if (systemBol)
|
||
{
|
||
this.ChartUc.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "PROGRESS REPORT", this.drpChartType.SelectedValue, 1100, 600, false));
|
||
}
|
||
|
||
|
||
|
||
}
|
||
|
||
public DateTime returnDay(DateTime x) {
|
||
//按年月
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
x = x.AddMonths(1);
|
||
return x;
|
||
}
|
||
else
|
||
{
|
||
x = x.AddDays(1);
|
||
return x;
|
||
}
|
||
}
|
||
|
||
public class CheckAnalysisModel
|
||
{
|
||
public string itemType { get; set; }
|
||
public int count { get; set; }
|
||
}
|
||
#endregion
|
||
|
||
/// <summary>
|
||
/// 统计分析
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void BtnAnalyse_Click(object sender, EventArgs e)
|
||
{
|
||
this.AnalyseData();
|
||
}
|
||
|
||
protected void drpChartType_SelectedIndexChanged(object sender, EventArgs e)
|
||
{
|
||
this.AnalyseData();
|
||
}
|
||
|
||
private void LoadData(IEnumerable<String> list)
|
||
{
|
||
this.trRectify.Nodes.Clear();
|
||
this.trRectify.ShowBorder = false;
|
||
this.trRectify.ShowHeader = false;
|
||
this.trRectify.EnableIcons = true;
|
||
this.trRectify.AutoScroll = true;
|
||
this.trRectify.EnableSingleClickExpand = true;
|
||
TreeNode rootNode = new TreeNode
|
||
{
|
||
Text = "全部",
|
||
NodeID = "ALL",
|
||
EnableClickEvent = true,
|
||
Expanded = true
|
||
};
|
||
this.trRectify.Nodes.Add(rootNode);
|
||
BoundTree(rootNode.Nodes, list);
|
||
this.trRectify.AutoScroll = true;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 加载树
|
||
/// </summary>
|
||
/// <param name="nodes"></param>
|
||
/// <param name="menuId"></param>
|
||
private void BoundTree(TreeNodeCollection nodes, IEnumerable<String> list)
|
||
{
|
||
TreeNode tn = null;
|
||
foreach (var item in list)
|
||
{
|
||
tn = new TreeNode
|
||
{
|
||
Text = item.ToString(),
|
||
NodeID = item.ToString(),
|
||
EnableClickEvent = true
|
||
};
|
||
nodes.Add(tn);
|
||
}
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
#region 点击树节点
|
||
protected void trRectify_NodeCommand(object sender, TreeCommandEventArgs e) {
|
||
var SystemName = this.trRectify.SelectedNodeID;
|
||
if (SystemName == "ALL")
|
||
{
|
||
AnalyseData();
|
||
}
|
||
else
|
||
{
|
||
var sTime = DateTime.Now.AddDays(-7);
|
||
var eTime = DateTime.Now; ;
|
||
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
if (string.IsNullOrEmpty(txtStarTime.Text) || string.IsNullOrEmpty(txtEndTime.Text))
|
||
{
|
||
Alert.ShowInTop("请选择日期。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
sTime = Convert.ToDateTime(txtStarTime.Text);
|
||
|
||
eTime = Convert.ToDateTime(txtEndTime.Text).AddMonths(1).AddDays(-1);
|
||
}
|
||
}
|
||
else
|
||
{
|
||
if (string.IsNullOrEmpty(txtStarTime1.Text) || string.IsNullOrEmpty(txtEndTime1.Text))
|
||
{
|
||
Alert.ShowInTop("请选择日期。", MessageBoxIcon.Warning);
|
||
return;
|
||
}
|
||
else
|
||
{
|
||
sTime = Convert.ToDateTime(txtStarTime1.Text);
|
||
eTime = Convert.ToDateTime(txtEndTime1.Text);
|
||
}
|
||
}
|
||
//var sTime = DateTime.Now.AddDays(-7);
|
||
//var eTime = DateTime.Now; ;
|
||
|
||
////如果没有填写日期,则是七天内的
|
||
//if (!string.IsNullOrEmpty(txtStarTime.Text) && !string.IsNullOrEmpty(txtEndTime.Text))
|
||
//{
|
||
// sTime = Convert.ToDateTime(txtStarTime.Text);
|
||
// eTime = Convert.ToDateTime(txtEndTime.Text);
|
||
|
||
//}
|
||
|
||
|
||
DataTable dtTime = new DataTable();
|
||
dtTime.Columns.Add("日期", typeof(string));
|
||
dtTime.Columns.Add("Finished", typeof(string));
|
||
dtTime.Columns.Add("In Progress", typeof(string));
|
||
dtTime.Columns.Add("Not Start", typeof(string));
|
||
|
||
var systemBol = false;
|
||
for (var i = sTime; i <= eTime; i = returnDay(i))
|
||
{
|
||
var finishedCount = 0;
|
||
var inProgress = 0;
|
||
var notStart = 0;
|
||
DataRow rowTime = dtTime.NewRow();
|
||
Model.SpTDesktopItem newspItem = new Model.SpTDesktopItem();
|
||
|
||
//按年月
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
rowTime["日期"] = string.Format("{0:yyyy-MM}", i);
|
||
}
|
||
else
|
||
{
|
||
rowTime["日期"] = string.Format("{0:yyyy-MM-dd}", i);
|
||
}
|
||
|
||
//根据日期查询当前system的数量
|
||
var systemListbyDate = Funs.DB.View_TransferDetail.Where(x => x.Projectid == ProjectId && x.SystemName == SystemName
|
||
&& x.FDate >= Convert.ToDateTime(rowTime["日期"])
|
||
&& x.FDate < Convert.ToDateTime(rowTime["日期"]).AddDays(1)).ToList();
|
||
|
||
//如果按年月
|
||
if (drpdateType.SelectedValue == "0")
|
||
{
|
||
systemListbyDate = Funs.DB.View_TransferDetail.Where(x => x.Projectid == ProjectId && x.SystemName == SystemName
|
||
&& x.FDate >= Convert.ToDateTime(rowTime["日期"])
|
||
&& x.FDate < Convert.ToDateTime(rowTime["日期"]).AddMonths(1)).ToList();
|
||
}
|
||
|
||
|
||
//查询TestPackage 去重
|
||
var testpackageList = (from x in systemListbyDate select x.TestPackage).Distinct();
|
||
|
||
if (testpackageList.ToList().Count > 0)
|
||
{
|
||
systemBol = true;
|
||
}
|
||
foreach (var item in testpackageList)
|
||
{
|
||
//查询当前日期每个testpackage的数量
|
||
var systemSumCount = systemListbyDate.Where(x => x.TestPackage == item).ToList().Count;
|
||
|
||
//子系统中完成的数量
|
||
var subSystemSumCount = systemListbyDate.Where(x => x.TestPackage == item &&
|
||
x.Status.ToLower() == "finished").ToList().Count;
|
||
|
||
//子系统中没完成的情况
|
||
var subSystemSumNotStartCount = systemListbyDate.Where(x => x.TestPackage == item &&
|
||
(x.Status.ToLower() == "not start" || x.Status == "" || x.Status == null)).ToList().Count;
|
||
|
||
//如果总数量等于完成的数量,完成量+1
|
||
if (systemSumCount == subSystemSumCount)
|
||
{
|
||
//如果都是完成,需要最后 12表 test packge 必须是Finished才能是完成
|
||
var punchlistFromList = Funs.DB.Transfer_PunchlistFrom.Where(x => x.ProjectId == ProjectId
|
||
&& x.SystemName==SystemName
|
||
&& x.Test_Package == item
|
||
).ToList();
|
||
|
||
//&& x.PUNCH_ITEM_FINISH_DATE >= Convert.ToDateTime(rowTime["日期"])
|
||
//&& x.PUNCH_ITEM_FINISH_DATE < Convert.ToDateTime(rowTime["日期"]).AddDays(1)
|
||
//如果查到
|
||
if (punchlistFromList.Count > 0)
|
||
{
|
||
//12表当前日期完成的数量
|
||
var punchlistFromFinshCount = punchlistFromList.Where(x => x.PUNCH_ITEM_STATUS.ToLower() == "finished").ToList().Count();
|
||
//如果完成的数量等于总得数量,则是完成
|
||
if (punchlistFromFinshCount == punchlistFromList.Count)
|
||
{
|
||
finishedCount += 1;
|
||
}
|
||
else
|
||
{
|
||
inProgress += 1;
|
||
}
|
||
}
|
||
else
|
||
{
|
||
finishedCount += 1;
|
||
}
|
||
}
|
||
//如果总数量等于not start,未开始量+1
|
||
else if (systemSumCount == subSystemSumNotStartCount)
|
||
{
|
||
notStart += 1;
|
||
}
|
||
else
|
||
{
|
||
inProgress += 1;
|
||
}
|
||
}
|
||
rowTime["Finished"] = finishedCount;
|
||
rowTime["In Progress"] = inProgress;
|
||
rowTime["Not Start"] = notStart;
|
||
dtTime.Rows.Add(rowTime);
|
||
|
||
}
|
||
if (systemBol)
|
||
{
|
||
this.ChartUc.CreateChart(BLL.ChartControlService.GetDataSourceChart(dtTime, "SYSTEM PROGRESS REPORT", this.drpChartType.SelectedValue, 1100, 600, false));
|
||
}
|
||
}
|
||
|
||
}
|
||
#endregion
|
||
}
|
||
} |