diff --git a/.vs/SGGL_CWCEC/v17/.wsuo b/.vs/SGGL_CWCEC/v17/.wsuo index 9975ed55..fe8cfccf 100644 Binary files a/.vs/SGGL_CWCEC/v17/.wsuo and b/.vs/SGGL_CWCEC/v17/.wsuo differ diff --git a/SGGL/FineUIPro.Web/CQMS/ManageReport/MonthReportEdit.aspx.cs b/SGGL/FineUIPro.Web/CQMS/ManageReport/MonthReportEdit.aspx.cs index 8f81e010..eebd2a10 100644 --- a/SGGL/FineUIPro.Web/CQMS/ManageReport/MonthReportEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/CQMS/ManageReport/MonthReportEdit.aspx.cs @@ -3,11 +3,14 @@ using System.Collections.Generic; using System.Data; using System.Data.SqlClient; using System.Linq; +using System.Runtime.Remoting.Metadata.W3cXsd2001; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using BLL; +using FineUIPro.Web.DataShow; using Model; +using NPOI.SS.Formula.Functions; using SgManager.AI; using AspNet = System.Web.UI.WebControls; namespace FineUIPro.Web.CQMS.ManageReport @@ -895,21 +898,42 @@ namespace FineUIPro.Web.CQMS.ManageReport { projectStartDate = project.StartDate.Value; } - //所有集合 - List totalManagementList = BLL.NCRManagementService.GetNCRManagementListByDate(this.CurrUser.LoginProjectId, startDate, endDate); - List unitNames = (from x in totalManagementList select x.ReceiveUnit).Distinct().ToList(); - foreach (var item in unitNames) + var units = from x in Funs.DB.Project_ProjectUnit + join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId + where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_2 + orderby y.UnitCode + select new { x.UnitId, y.UnitName }; + var db = Funs.DB; + foreach (var item in units) { - //当期集合 - List managementList = BLL.NCRManagementService.GetNCRManagementListByUnitNameAndDate(this.CurrUser.LoginProjectId, item, startDate, endDate); - //累计集合 - List sumManagementList = BLL.NCRManagementService.GetNCRManagementListByUnitNameAndDate(this.CurrUser.LoginProjectId, item, projectStartDate, DateTime.Now); + + var query = from c in db.Comprehensive_NCRManagement + + join u in db.Base_Unit on c.ReceiveUnit equals u.UnitId into unitJoin + + from u in unitJoin.DefaultIfEmpty() + where c.ProjectId == this.CurrUser.LoginProjectId && c.ReceiveUnit == item.UnitId + select new + + { + c.NCRManagementId, + c.ProjectId, + u.UnitId, + u.UnitName, + c.IssuedDate, + c.Status + + }; + + var AllList = query.ToList(); + var unitNCRStatic = query + .Where(x => (x.IssuedDate >= Convert.ToDateTime(startDate) && x.IssuedDate <= Convert.ToDateTime(endDate))); Model.NCRReportStatisc NCRStatisc = new Model.NCRReportStatisc(); NCRStatisc.Num = i; - NCRStatisc.WorkName = BLL.UnitService.getUnitNamesUnitIds(item); - NCRStatisc.CurrentPeriodOkNum = managementList.Count(x => x.Status == "3"); - NCRStatisc.OKNum = sumManagementList.Count(x => x.Status == "3"); - NCRStatisc.CheckNum = sumManagementList.Count; + NCRStatisc.WorkName = item.UnitName; + NCRStatisc.CurrentPeriodOkNum = unitNCRStatic.Count(x => x.Status == "3" ); + NCRStatisc.OKNum = AllList.Count(x => x.Status == "3"); + NCRStatisc.CheckNum = AllList.Count(); if (NCRStatisc.CheckNum != 0)//被除数不能为零 { NCRStatisc.OKRate = Math.Round((double)NCRStatisc.OKNum / (double)NCRStatisc.CheckNum * 100, 2) + "%";//保留两位小数、后四舍五入 @@ -1179,7 +1203,8 @@ namespace FineUIPro.Web.CQMS.ManageReport DateTime endDate = Convert.ToDateTime(this.txtEndDate.Text.Trim()); DateTime projectStartDate = Convert.ToDateTime("2015-01-01"); Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); - var unitList= UnitService.GetUnitListByProjectId(this.CurrUser.LoginProjectId).Select(x=>x.UnitId).ToList(); + List StatisticsList = new List(); + var unitList= UnitService.GetUnitListByProjectId(this.CurrUser.LoginProjectId).Select(x=>x.UnitId).ToList(); if (project != null) { if (project.StartDate != null) @@ -1187,51 +1212,129 @@ namespace FineUIPro.Web.CQMS.ManageReport projectStartDate = Convert.ToDateTime(project.StartDate); } } - int i = 1; - var q = from x in db.Solution_CQMSConstructSolution - where x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate) && unitList.Contains(x.UnitId) &&x.ProjectId==this.CurrUser.LoginProjectId - group x by new { x.UnitId, State = x.State == "3", ProjectId = x.ProjectId == project.ProjectId } - into g - select new - { - UnitName=BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), - Count = g.Key.UnitId.Count(), - }; + int i = 1; + var units = from x in Funs.DB.Project_ProjectUnit + join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId + where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_2 + orderby y.UnitCode + select new { x.UnitId, y.UnitName }; - var total = from x in db.Solution_CQMSConstructSolution - where x.CompileDate >= projectStartDate && x.CompileDate <= DateTime.Now && unitList.Contains(x.UnitId) && x.ProjectId == this.CurrUser.LoginProjectId - group x by new { x.UnitId, ProjectId = x.ProjectId == project.ProjectId } - into g - select new - { - UnitName = BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), - Count = g.Key.UnitId.Count(), - }; - var result = q.ToList().Select((item, index) => new + foreach (var item in units) { - Index = index + 1, - item.UnitName, - item.Count, - AllCount= (int)total.ToList().Where(x => x.UnitName == item.UnitName).Select(x=>x.Count).FirstOrDefault() - }); - if (result.Count()>0) //增加总计 - { - int totalCount = result.Sum(item => item.Count); - int totalAllCount = result.Sum(item => item.AllCount); - result = result.Concat(new[] - { - new + var query = from c in db.Solution_CQMSConstructSolution + + join u in db.Base_Unit on c.UnitId equals u.UnitId into unitJoin + + from u in unitJoin.DefaultIfEmpty() + + where c.ProjectId == this.CurrUser.LoginProjectId && c.UnitId == item.UnitId + select new + { - Index = result.Count() + 1, - UnitName = "合计", - Count = totalCount, - AllCount= totalAllCount - } - }); + c.ConstructSolutionId, + c.ProjectId, + u.UnitId, + u.UnitName, + c.State, + c.CompileDate + + }; + + var AllList = query.ToList(); + var unitNCRStatic = query + .Where(x => (x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate))); + Model.CQMSConstructSolutionStatisc NCRStatisc = new Model.CQMSConstructSolutionStatisc(); + NCRStatisc.Num = i; + NCRStatisc.UnitName = item.UnitName; + NCRStatisc.CheckNum = unitNCRStatic.Count(x => x.State == "3"); + NCRStatisc.AllNum = AllList.Count(); + + StatisticsList.Add(NCRStatisc); + i++; + } + if (StatisticsList.Count() > 0) //增加总计 + { + Model.CQMSConstructSolutionStatisc StatisticsLast = new Model.CQMSConstructSolutionStatisc(); + StatisticsLast.Num = StatisticsList.Count() + 1; + StatisticsLast.UnitName = "合计"; + foreach (Model.CQMSConstructSolutionStatisc item in StatisticsList) + { + StatisticsLast.CheckNum += item.CheckNum; + StatisticsLast.AllNum += item.AllNum; + } + + StatisticsList.Add(StatisticsLast); + } + else + { + Model.CQMSConstructSolutionStatisc StatisticsLast = new Model.CQMSConstructSolutionStatisc(); + StatisticsLast.Num = 0; + StatisticsLast.UnitName = "合计"; + StatisticsLast.CheckNum = 0; + StatisticsLast.AllNum = 0; + StatisticsList.Add(StatisticsLast); + } - this.gvConstructionStatistics.DataSource = result; + //var q = from x in db.Solution_CQMSConstructSolution + // join y in units on x.UnitId equals y.UnitId + // where x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate) && unitList.Contains(x.UnitId) &&x.ProjectId==this.CurrUser.LoginProjectId + // group x by new { x.UnitId, State = x.State == "3", ProjectId = x.ProjectId == project.ProjectId } + // into g + // select new + // { + // UnitName=BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), + // Count = g.Key.UnitId.Count(), + // }; + + //var total = from x in db.Solution_CQMSConstructSolution + // join y in units on x.UnitId equals y.UnitId + // where x.CompileDate >= projectStartDate && x.CompileDate <= DateTime.Now && unitList.Contains(x.UnitId) && x.ProjectId == this.CurrUser.LoginProjectId + // group x by new { x.UnitId, ProjectId = x.ProjectId == project.ProjectId } + // into g + // select new + // { + // UnitName = BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), + // Count = g.Key.UnitId.Count(), + // }; + + //var total = from x in units + // join y in db.Solution_CQMSConstructSolution on x.UnitId equals y.UnitId into unitJoin + // from u in unitJoin.DefaultIfEmpty() + // where u.ProjectId == this.CurrUser.LoginProjectId + // select new + // { + // UnitName= x.UnitName, + // u.ConstructSolutionId, + // u.CompileDate + + // }; + //var result = total.ToList().Select((item, index) => new + //{ + // Index = index + 1, + // item.UnitName, + // Count = (int)total.ToList().Where(x => x.UnitName == item.UnitName && x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate)).Count(), + // AllCount = (int)total.ToList().Where(x => x.UnitName == item.UnitName).Count() + + //}); + //if (result.Count()>0) //增加总计 + //{ + // int totalCount = result.Sum(item => item.Count); + // int totalAllCount = result.Sum(item => item.AllCount); + // result = result.Concat(new[] + // { + // new + // { + // Index = result.Count() + 1, + // UnitName = "合计", + // Count = totalCount, + // AllCount= totalAllCount + // } + // }); + //} + + this.gvConstructionStatistics.DataSource = StatisticsList; this.gvConstructionStatistics.DataBind(); } diff --git a/SGGL/FineUIPro.Web/CQMS/ManageReport/WeekReportEdit.aspx.cs b/SGGL/FineUIPro.Web/CQMS/ManageReport/WeekReportEdit.aspx.cs index f81cdc75..1b5f32b6 100644 --- a/SGGL/FineUIPro.Web/CQMS/ManageReport/WeekReportEdit.aspx.cs +++ b/SGGL/FineUIPro.Web/CQMS/ManageReport/WeekReportEdit.aspx.cs @@ -893,21 +893,42 @@ namespace FineUIPro.Web.CQMS.ManageReport { projectStartDate = project.StartDate.Value; } - //所有集合 - List totalManagementList = BLL.NCRManagementService.GetNCRManagementListByDate(this.CurrUser.LoginProjectId, startDate, endDate); - List unitNames = (from x in totalManagementList select x.ReceiveUnit).Distinct().ToList(); - foreach (var item in unitNames) + var units = from x in Funs.DB.Project_ProjectUnit + join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId + where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_2 + orderby y.UnitCode + select new { x.UnitId, y.UnitName }; + var db = Funs.DB; + foreach (var item in units) { - //当期集合 - List managementList = BLL.NCRManagementService.GetNCRManagementListByUnitNameAndDate(this.CurrUser.LoginProjectId, item, startDate, endDate); - //累计集合 - List sumManagementList = BLL.NCRManagementService.GetNCRManagementListByUnitNameAndDate(this.CurrUser.LoginProjectId, item, projectStartDate, DateTime.Now); + + var query = from c in db.Comprehensive_NCRManagement + + join u in db.Base_Unit on c.ReceiveUnit equals u.UnitId into unitJoin + + from u in unitJoin.DefaultIfEmpty() + where c.ProjectId == this.CurrUser.LoginProjectId && c.ReceiveUnit == item.UnitId + select new + + { + c.NCRManagementId, + c.ProjectId, + u.UnitId, + u.UnitName, + c.IssuedDate, + c.Status + + }; + + var AllList = query.ToList(); + var unitNCRStatic = query + .Where(x => (x.IssuedDate >= Convert.ToDateTime(startDate) && x.IssuedDate <= Convert.ToDateTime(endDate))); Model.NCRReportStatisc NCRStatisc = new Model.NCRReportStatisc(); NCRStatisc.Num = i; - NCRStatisc.WorkName = BLL.UnitService.getUnitNamesUnitIds(item); - NCRStatisc.CurrentPeriodOkNum = managementList.Count(x => x.Status == "3"); - NCRStatisc.OKNum = sumManagementList.Count(x => x.Status == "3"); - NCRStatisc.CheckNum = sumManagementList.Count; + NCRStatisc.WorkName = item.UnitName; + NCRStatisc.CurrentPeriodOkNum = unitNCRStatic.Count(x => x.Status == "3"); + NCRStatisc.OKNum = AllList.Count(x => x.Status == "3"); + NCRStatisc.CheckNum = AllList.Count(); if (NCRStatisc.CheckNum != 0)//被除数不能为零 { NCRStatisc.OKRate = Math.Round((double)NCRStatisc.OKNum / (double)NCRStatisc.CheckNum * 100, 2) + "%";//保留两位小数、后四舍五入 @@ -1177,6 +1198,7 @@ namespace FineUIPro.Web.CQMS.ManageReport DateTime endDate = Convert.ToDateTime(this.txtEndDate.Text.Trim()); DateTime projectStartDate = Convert.ToDateTime("2015-01-01"); Model.Base_Project project = BLL.ProjectService.GetProjectByProjectId(this.CurrUser.LoginProjectId); + List StatisticsList = new List(); var unitList = UnitService.GetUnitListByProjectId(this.CurrUser.LoginProjectId).Select(x => x.UnitId).ToList(); if (project != null) { @@ -1186,50 +1208,128 @@ namespace FineUIPro.Web.CQMS.ManageReport } } int i = 1; - var q = from x in db.Solution_CQMSConstructSolution - where x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate) && unitList.Contains(x.UnitId) && x.ProjectId == this.CurrUser.LoginProjectId - group x by new { x.UnitId, State = x.State == "3", ProjectId = x.ProjectId == project.ProjectId } - into g - select new - { - UnitName = BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), - Count = g.Key.UnitId.Count(), - }; + var units = from x in Funs.DB.Project_ProjectUnit + join y in Funs.DB.Base_Unit on x.UnitId equals y.UnitId + where x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_2 + orderby y.UnitCode + select new { x.UnitId, y.UnitName }; - var total = from x in db.Solution_CQMSConstructSolution - where x.CompileDate >= projectStartDate && x.CompileDate <= DateTime.Now && unitList.Contains(x.UnitId) && x.ProjectId == this.CurrUser.LoginProjectId - group x by new { x.UnitId, ProjectId = x.ProjectId == project.ProjectId } - into g - select new - { - UnitName = BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), - Count = g.Key.UnitId.Count(), - }; - var result = q.ToList().Select((item, index) => new + foreach (var item in units) { - Index = index + 1, - item.UnitName, - item.Count, - AllCount = (int)total.ToList().Where(x => x.UnitName == item.UnitName).Select(x => x.Count).FirstOrDefault() - }); - if (result.Count() > 0) //增加总计 + var query = from c in db.Solution_CQMSConstructSolution + + join u in db.Base_Unit on c.UnitId equals u.UnitId into unitJoin + + from u in unitJoin.DefaultIfEmpty() + + where c.ProjectId == this.CurrUser.LoginProjectId && c.UnitId == item.UnitId + select new + + { + c.ConstructSolutionId, + c.ProjectId, + u.UnitId, + u.UnitName, + c.State, + c.CompileDate + + }; + + var AllList = query.ToList(); + var unitNCRStatic = query + .Where(x => (x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate))); + Model.CQMSConstructSolutionStatisc NCRStatisc = new Model.CQMSConstructSolutionStatisc(); + NCRStatisc.Num = i; + NCRStatisc.UnitName = item.UnitName; + NCRStatisc.CheckNum = unitNCRStatic.Count(x => x.State == "3"); + NCRStatisc.AllNum = AllList.Count(); + + StatisticsList.Add(NCRStatisc); + i++; + } + if (StatisticsList.Count() > 0) //增加总计 { - int totalCount = result.Sum(item => item.Count); - int totalAllCount = result.Sum(item => item.AllCount); - result = result.Concat(new[] + Model.CQMSConstructSolutionStatisc StatisticsLast = new Model.CQMSConstructSolutionStatisc(); + StatisticsLast.Num = StatisticsList.Count() + 1; + StatisticsLast.UnitName = "合计"; + foreach (Model.CQMSConstructSolutionStatisc item in StatisticsList) { - new - { - Index = result.Count() + 1, - UnitName = "合计", - Count = totalCount, - AllCount= totalAllCount - } - }); + StatisticsLast.CheckNum += item.CheckNum; + StatisticsLast.AllNum += item.AllNum; + } + + StatisticsList.Add(StatisticsLast); + } + else + { + Model.CQMSConstructSolutionStatisc StatisticsLast = new Model.CQMSConstructSolutionStatisc(); + StatisticsLast.Num = 0; + StatisticsLast.UnitName = "合计"; + StatisticsLast.CheckNum = 0; + StatisticsLast.AllNum = 0; + StatisticsList.Add(StatisticsLast); + } - this.gvConstructionStatistics.DataSource = result; + //var q = from x in db.Solution_CQMSConstructSolution + // join y in units on x.UnitId equals y.UnitId + // where x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate) && unitList.Contains(x.UnitId) &&x.ProjectId==this.CurrUser.LoginProjectId + // group x by new { x.UnitId, State = x.State == "3", ProjectId = x.ProjectId == project.ProjectId } + // into g + // select new + // { + // UnitName=BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), + // Count = g.Key.UnitId.Count(), + // }; + + //var total = from x in db.Solution_CQMSConstructSolution + // join y in units on x.UnitId equals y.UnitId + // where x.CompileDate >= projectStartDate && x.CompileDate <= DateTime.Now && unitList.Contains(x.UnitId) && x.ProjectId == this.CurrUser.LoginProjectId + // group x by new { x.UnitId, ProjectId = x.ProjectId == project.ProjectId } + // into g + // select new + // { + // UnitName = BLL.UnitService.GetUnitNameByUnitId(g.Key.UnitId), + // Count = g.Key.UnitId.Count(), + // }; + + //var total = from x in units + // join y in db.Solution_CQMSConstructSolution on x.UnitId equals y.UnitId into unitJoin + // from u in unitJoin.DefaultIfEmpty() + // where u.ProjectId == this.CurrUser.LoginProjectId + // select new + // { + // UnitName= x.UnitName, + // u.ConstructSolutionId, + // u.CompileDate + + // }; + //var result = total.ToList().Select((item, index) => new + //{ + // Index = index + 1, + // item.UnitName, + // Count = (int)total.ToList().Where(x => x.UnitName == item.UnitName && x.CompileDate >= Convert.ToDateTime(startDate) && x.CompileDate <= Convert.ToDateTime(endDate)).Count(), + // AllCount = (int)total.ToList().Where(x => x.UnitName == item.UnitName).Count() + + //}); + //if (result.Count()>0) //增加总计 + //{ + // int totalCount = result.Sum(item => item.Count); + // int totalAllCount = result.Sum(item => item.AllCount); + // result = result.Concat(new[] + // { + // new + // { + // Index = result.Count() + 1, + // UnitName = "合计", + // Count = totalCount, + // AllCount= totalAllCount + // } + // }); + //} + + this.gvConstructionStatistics.DataSource = StatisticsList; this.gvConstructionStatistics.DataBind(); } diff --git a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj index f835c6a8..7c88210d 100644 --- a/SGGL/FineUIPro.Web/FineUIPro.Web.csproj +++ b/SGGL/FineUIPro.Web/FineUIPro.Web.csproj @@ -15092,12 +15092,14 @@ TailTermHandle.aspx + ASPXCodeBehind TailTermHandle.aspx TailTermHandleList.aspx + ASPXCodeBehind TailTermHandleList.aspx diff --git a/SGGL/Model/CQMS/CQMSConstructSolutionStatisc.cs b/SGGL/Model/CQMS/CQMSConstructSolutionStatisc.cs new file mode 100644 index 00000000..7eb22b73 --- /dev/null +++ b/SGGL/Model/CQMS/CQMSConstructSolutionStatisc.cs @@ -0,0 +1,48 @@ +namespace Model +{ + public class CQMSConstructSolutionStatisc + { + private int num; + /// + /// 序号 + /// + public int Num + { + get { return num; } + set { num = value; } + } + + private string unitName; + /// + /// 接收单位 + /// + public string UnitName + { + get { return unitName; } + set { unitName = value; } + } + + private int checkNum; + /// + /// 审批完成数 + /// + public int CheckNum + { + get { return checkNum; } + set { checkNum = value; } + } + + private int allNum; + /// + /// 已完成 + /// + public int AllNum + { + get { return allNum; } + set { allNum = value; } + } + + + + } +} \ No newline at end of file diff --git a/SGGL/Model/Model.csproj b/SGGL/Model/Model.csproj index 132bd4b1..8321533c 100644 --- a/SGGL/Model/Model.csproj +++ b/SGGL/Model/Model.csproj @@ -170,6 +170,7 @@ +