using BLL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Web.Services; using System.Data.SqlClient; using System.Data; using Newtonsoft.Json; namespace FineUIPro.Web.common { public partial class main_copy_index : PageBase { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { this.ProjectId = string.Empty; if (this.CurrUser != null) { this.ProjectId = this.CurrUser.LoginProjectId; } var project = BLL.ProjectService.GetProjectByProjectId(this.ProjectId); if (project != null && project.StartDate != null) { ProjectDate = string.Format("{0:yyyy-MM-dd}", project.StartDate); var dateSpan = DateTime.Now - project.StartDate; var days = string.Format("{0:D4}", (int)dateSpan.Value.TotalDays); ProjectDay1 = days.Substring(days.Length - 1, 1); ProjectDay2 = days.Substring(days.Length - 2, 1); ProjectDay3 = days.Substring(days.Length - 3, 1); ProjectDay4 = days.Substring(days.Length - 4, 1); } else { ProjectDay1 = "0"; ProjectDay2 = "0"; ProjectDay3 = "0"; ProjectDay4 = "0"; } getDayReportDetails = (from x in Funs.DB.SitePerson_DayReportDetail join y in Funs.DB.SitePerson_DayReport on x.DayReportId equals y.DayReportId where y.ProjectId == this.ProjectId select x).ToList(); getProjectUnits = (from x in Funs.DB.Project_ProjectUnit where x.ProjectId == this.ProjectId select x).ToList(); } } private static List getDayReportDetails; private static List getProjectUnits; public string ProjectDate { get { return (string)ViewState["ProjectDate"]; } set { ViewState["ProjectDate"] = value; } } public string ProjectDay1 { get { return (string)ViewState["ProjectDay1"]; } set { ViewState["ProjectDay1"] = value; } } public string ProjectDay2 { get { return (string)ViewState["ProjectDay2"]; } set { ViewState["ProjectDay2"] = value; } } public string ProjectDay3 { get { return (string)ViewState["ProjectDay3"]; } set { ViewState["ProjectDay3"] = value; } } public string ProjectDay4 { get { return (string)ViewState["ProjectDay4"]; } set { ViewState["ProjectDay4"] = value; } } public string ProjectId { get { return (string)ViewState["ProjectId"]; } set { ViewState["ProjectId"] = value; } } [WebMethod] public static string getSitePerson() { var list = SitePerson_DayReportService.getMonthChart(); return Newtonsoft.Json.JsonConvert.SerializeObject(list); } protected string SitePerson { get { Model.SGGLDB db = Funs.DB; Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); List series = new List(); Model.SingleSerie s = new Model.SingleSerie(); List listdata = new List(); foreach (var item in getProjectUnits) { listCategories.Add(UnitService.GetShortUnitNameByUnitId(item.UnitId)); decimal total = getDayReportDetails.Where(x => x.UnitId == item.UnitId).Sum(x => x.PersonWorkTime ?? 0); listdata.Add(Convert.ToDouble(total)); } s.data = listdata; series.Add(s); businessColumn.categories = listCategories; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } protected int TodoNum; protected string toDo { get { var getDataList = Funs.DB.Sp_Main_GetToDoItems(this.CurrUser.UserId, CurrUser.LoginProjectId).ToList(); string strNoticeHtml = string.Empty; if (getDataList.Count >= 8) { foreach (var item in getDataList) { strNoticeHtml += "
  • " + item.Content + "
  • "; } } else { if (getDataList.Count > 0) { foreach (var item in getDataList) { strNoticeHtml += "
  • " + item.Content + "
  • "; } int addRowNum = 8 - getDataList.Count; for (int i = 0; i < addRowNum; i++) { strNoticeHtml += "
  • "; } } } TodoNum = getDataList.Count; return "
      " + strNoticeHtml + "
    "; } } protected int ToWarnNum; protected string toWarn { get { Model.SGGLDB db = Funs.DB; var personQualitys = from x in db.SitePerson_Person join y in db.QualityAudit_PersonQuality on x.PersonId equals y.PersonId join z in db.Base_WorkPost on x.WorkPostId equals z.WorkPostId join a in db.Base_Unit on x.UnitId equals a.UnitId where (y.LimitDate < DateTime.Now || y.LimitDate <= DateTime.Now.AddDays(30)) && x.ProjectId == this.ProjectId && z.PostType == Const.PostType_2 select new { x.PersonName,a.UnitName, y.LimitDate }; var equipmentQualitys = from x in db.QualityAudit_EquipmentQuality join y in db.Base_Unit on x.UnitId equals y.UnitId join z in db.Base_SpecialEquipment on x.SpecialEquipmentId equals z.SpecialEquipmentId where (x.LimitDate < DateTime.Now || x.LimitDate <= DateTime.Now.AddDays(30)) && x.ProjectId == this.ProjectId select new { y.UnitName,z.SpecialEquipmentName, x.EquipmentQualityName, x.SizeModel, x.LimitDate }; string strNoticeHtml = string.Empty; if (personQualitys.Count() + equipmentQualitys.Count() >= 8) { foreach (var item in personQualitys) { if (item.LimitDate < DateTime.Now) { int day = ((TimeSpan)(DateTime.Now - item.LimitDate)).Days; strNoticeHtml += "
  • " + item.UnitName+"-" + item.PersonName + "的资质已经过期" + day + "天" + "
  • "; } else { int day = ((TimeSpan)(item.LimitDate - DateTime.Now)).Days; strNoticeHtml += "
  • " + item.UnitName + "-" + item.PersonName + "的资质还有" + day + "天到期" + "
  • "; } } foreach (var item in equipmentQualitys) { if (item.LimitDate < DateTime.Now) { int day = ((TimeSpan)(DateTime.Now - item.LimitDate)).Days; strNoticeHtml += "
  • " + item.UnitName + "-" + item.EquipmentQualityName + "(" + item.SizeModel + ")的资质已经过期" + day + "天" + "
  • "; } else { int day = ((TimeSpan)(item.LimitDate - DateTime.Now)).Days; strNoticeHtml += "
  • " + item.UnitName + "-" + item.EquipmentQualityName + "(" + item.SizeModel + ")的资质还有" + day + "天到期" + "
  • "; } } } else { if (personQualitys.Count() > 0) { foreach (var item in personQualitys) { if (item.LimitDate < DateTime.Now) { int day = ((TimeSpan)(DateTime.Now - item.LimitDate)).Days; strNoticeHtml += "
  • " + item.UnitName + "-" + item.PersonName + "的资质已经过期" + day + "天" + "
  • "; } else { int day = ((TimeSpan)(item.LimitDate - DateTime.Now)).Days; strNoticeHtml += "
  • " + item.UnitName + "-" + item.PersonName + "的资质还有" + day + "天到期" + "
  • "; } } foreach (var item in equipmentQualitys) { if (item.LimitDate < DateTime.Now) { int day = ((TimeSpan)(DateTime.Now - item.LimitDate)).Days; strNoticeHtml += "
  • " + item.UnitName + "-" + item.EquipmentQualityName + "(" + item.SizeModel + ")的资质已经过期" + day + "天" + "
  • "; } else { int day = ((TimeSpan)(item.LimitDate - DateTime.Now)).Days; strNoticeHtml += "
  • " + item.UnitName + "-" + item.EquipmentQualityName + "(" + item.SizeModel + ")的资质还有" + day + "天到期" + "
  • "; } } int addRowNum = 8 - personQualitys.Count() - equipmentQualitys.Count(); for (int i = 0; i < addRowNum; i++) { strNoticeHtml += "
  • "; } } } ToWarnNum = personQualitys.Count()+ equipmentQualitys.Count(); return "
      " + strNoticeHtml + "
    "; } } protected string WorkingPeople { get { string unitname = "["; string unitData = "["; if (!string.IsNullOrEmpty(this.ProjectId)) { string strSql = @"select pu.UnitId ,u.UnitName,u.ShortUnitName,count(*) as num from SitePerson_Person pu left join Base_Project p on pu.projectId = p.projectId left join Base_Unit u on pu.UnitId = u.UnitId where pu.projectId=@ProjectId group by pu.UnitId ,u.UnitName,u.ShortUnitName"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); foreach (DataRow dr in tb.Rows) { if (!string.IsNullOrEmpty(dr["ShortUnitName"].ToString())) { unitname += "\"" + dr["ShortUnitName"].ToString() + "\","; } else { unitname += "\"" + dr["UnitName"].ToString() + "\","; } unitData += "" + dr["num"].ToString() + ","; } unitname = unitname.TrimEnd(','); unitData = unitData.TrimEnd(','); } unitname += "]"; unitData += "]"; return "{\"unitNames\":" + unitname + " ,\"data\":" + unitData + "}"; } } protected string WorkingRole { get { string roleName = "["; string roleData = "["; if (!string.IsNullOrEmpty(this.ProjectId)) { string strSql = @"select r.WorkPostId ,r.WorkPostName,count(*) as num from SitePerson_Person pu left join Base_Project p on pu.projectId = p.projectId left join Base_WorkPost r on r.WorkPostId = pu.WorkPostId where pu.projectId=@ProjectId group by r.WorkPostId ,r.WorkPostName"; List listStr = new List(); listStr.Add(new SqlParameter("@ProjectId", this.ProjectId)); SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter); foreach (DataRow dr in tb.Rows) { roleName += "\"" + dr["WorkPostName"].ToString() + "\","; roleData += "" + dr["num"].ToString() + ","; } roleName = roleName.TrimEnd(','); roleData = roleData.TrimEnd(','); } roleName += "]"; roleData += "]"; return "{\"roleName\":" + roleName + " ,\"data\":" + roleData + "}"; } } protected string RectifyNoticesUnit { get { Model.SGGLDB db = Funs.DB; Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); List series = new List(); Model.SingleSerie s = new Model.SingleSerie(); List listdata = new List(); List listdata2 = new List(); var hazardRegisters = from x in db.View_Hazard_HazardRegister where x.ProjectId == this.ProjectId select x; if (hazardRegisters.Count() > 0) { var units = hazardRegisters.Select(x => x.ResponsibleUnit).Distinct().ToList(); foreach (var unit in units) { listCategories.Add(UnitService.GetShortUnitNameByUnitId(unit)); int state1 = hazardRegisters.Count(x => x.ResponsibleUnit == unit && x.States == "1"); int state2 = hazardRegisters.Count(x => x.ResponsibleUnit == unit); listdata.Add(Convert.ToDouble(state1)); listdata2.Add(Convert.ToDouble(state2)); } s.data = listdata; s.data2 = listdata2; series.Add(s); } businessColumn.categories = listCategories; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } protected string RectifyNoticesHiddenHazardType { get { Model.SGGLDB db = Funs.DB; Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); List series = new List(); Model.SingleSerie s = new Model.SingleSerie(); List listdata = new List(); List listdata2 = new List(); var hazardRegisters = from x in db.View_Hazard_HazardRegister where x.ProjectId == this.ProjectId select x; if (hazardRegisters.Count() > 0) { var types = hazardRegisters.Select(x => x.RegisterTypesName).Distinct().ToList(); foreach (var type in types) { listCategories.Add(type); int state1 = hazardRegisters.Count(x => x.RegisterTypesName == type && x.States == "1"); int state2 = hazardRegisters.Count(x => x.RegisterTypesName == type); listdata.Add(Convert.ToDouble(state1)); listdata2.Add(Convert.ToDouble(state2)); } s.data = listdata; s.data2 = listdata2; series.Add(s); } businessColumn.categories = listCategories; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } protected string getHiddenHazardType(string HiddenHazardType) { switch (HiddenHazardType) { case "1": return "一般"; case "2": return "较大"; case "3": return "重大"; } return ""; } protected void imgBtn_Click(object sender, ImageClickEventArgs e) { //Model.InformationProject_Notice notice = BLL.NoticeService.GetNoticeById(this.hdNoticeId.Value); //if (notice != null) //{ // BLL.APIUserService.getSaveUserRead(BLL.Const.ServerNoticeMenuId, notice.ProjectId, this.CurrUser.UserId, notice.NoticeId); //} } #region 安全问题整改率 protected string anquanwentizhenggailv { get { var checks = from x in Funs.DB.View_Hazard_HazardRegister where x.ProjectId == this.ProjectId select x; var total = checks.Count(); if (total > 0) { return "" + Math.Round(100.0 * checks.Where(x => x.States == "3").Count() / total, 2); } else { return "100"; } } } #endregion #region 质量问题整改率 protected string zhiliangwentizhenggailv { get { var checks = JointCheckDetailService.GetTotalJointCheckDetailListByTime(CurrUser.LoginProjectId, DateTime.Now); var total= checks.Count(); if (total > 0) { return "" + Math.Round(100.0 * checks.Where( x => x.OK == 1).Count() / total, 2); } else { return "100"; } } } #endregion protected string hanjieyicihegelv { get { string strSql = @"select SUM(cht_totalfilm) AS current_total_film , SUM(cht_passfilm) AS current_pass_film from CH_CheckItem ch_checkitem left join PW_JointInfo JointInfo on JointInfo.JOT_ID = ch_checkitem.CHT_CheckID where ProjectId = '" + CurrUser.LoginProjectId + "'"; // SqlParameter[] parameter = listStr.ToArray(); DataTable tb = SQLHelper.GetDataTableRunText(strSql); if (tb != null && tb.Rows.Count > 0) { try { var rate = 100 * double.Parse(tb.Rows[0]["current_pass_film"].ToString()) / double.Parse(tb.Rows[0]["current_total_film"].ToString()); return "" + ((int)rate); } catch (Exception ex) { return "0"; } } return "0"; } } #region 质量问题统计 protected string Two { get { List series = new List(); Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); businessColumn.title = "质量问题统计"; businessColumn.xFontNum = 14; var units = BLL.ProjectUnitService.GetProjectUnitListByProjectIdUnitType(CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2); var checks = JointCheckDetailService.GetTotalJointCheckDetailListByTime(CurrUser.LoginProjectId, DateTime.Now); Model.SingleSerie s = new Model.SingleSerie(); Model.SingleSerie s2 = new Model.SingleSerie(); List listdata = new List(); List listdata2 = new List(); int okNum = 0; foreach (var unit in units) { listCategories.Add(BLL.UnitService.GetShortUnitNameByUnitId(unit.UnitId)); var unitChecks = checks.Where(x => x.UnitId == unit.UnitId); okNum = unitChecks.Where(x => x.OK == 1).Count(); listdata.Add(unitChecks.Count() - okNum); listdata2.Add(okNum); } s.data = listdata; s2.data = listdata2; series.Add(s); series.Add(s2); businessColumn.categories = listCategories; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } protected string Two2 { get { //List series = new List(); //Model.BusinessColumn businessColumn = new Model.BusinessColumn(); //List listCategories = new List(); //businessColumn.title = "质量问题统计"; //businessColumn.xFontNum = 2; //var unitWorks = BLL.UnitWorkService.GetUnitWorkLists(CurrUser.LoginProjectId); //var checks = JointCheckDetailService.GetTotalJointCheckDetailListByTime(CurrUser.LoginProjectId, DateTime.Now); //Model.SingleSerie s = new Model.SingleSerie(); //Model.SingleSerie s2 = new Model.SingleSerie(); //List listdata = new List(); //List listdata2 = new List(); //int okNum = 0; //foreach (var unitWork in unitWorks) //{ // listCategories.Add(unitWork.UnitWorkName); // var unitChecks = checks.Where(x => x.UnitWorkId == unitWork.UnitWorkId); // okNum = unitChecks.Where(x => x.OK == 1).Count(); // listdata.Add(unitChecks.Count() - okNum); // listdata2.Add(okNum); //} //s.data = listdata; //s2.data = listdata2; //series.Add(s); //series.Add(s2); //businessColumn.categories = listCategories; //businessColumn.series = series; //return JsonConvert.SerializeObject(businessColumn); return ""; } } protected string Two3 { get { List series = new List(); Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); businessColumn.title = "质量问题统计"; businessColumn.xFontNum = 4; var cns = BLL.CNProfessionalService.GetList(); var checks = JointCheckDetailService.GetTotalJointCheckDetailListByTime(CurrUser.LoginProjectId, DateTime.Now); Model.SingleSerie s = new Model.SingleSerie(); Model.SingleSerie s2 = new Model.SingleSerie(); List listdata = new List(); List listdata2 = new List(); int okNum = 0; foreach (var cn in cns) { listCategories.Add(cn.ProfessionalName); var unitChecks = checks.Where(x => x.CNProfessionalCode == cn.CNProfessionalId); okNum = unitChecks.Where(x => x.OK == 1).Count(); listdata.Add(unitChecks.Count() - okNum); listdata2.Add(okNum); } s.data = listdata; s2.data = listdata2; series.Add(s); series.Add(s2); businessColumn.categories = listCategories; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } protected string Two4 { get { List series = new List(); Model.BusinessColumn businessColumn = new Model.BusinessColumn(); List listCategories = new List(); businessColumn.title = "质量问题统计"; businessColumn.xFontNum = 4; var checks = JointCheckDetailService.GetTotalJointCheckDetailListByTime(CurrUser.LoginProjectId, DateTime.Now); var questionTypes = checks.Select(x => x.QuestionTypeStr).Distinct().ToList(); Model.SingleSerie s = new Model.SingleSerie(); Model.SingleSerie s2 = new Model.SingleSerie(); List listdata = new List(); List listdata2 = new List(); int okNum = 0; foreach (var questionType in questionTypes) { listCategories.Add(questionType); var unitChecks = checks.Where(x => x.QuestionTypeStr == questionType); okNum = unitChecks.Where(x => x.OK == 1).Count(); listdata.Add(unitChecks.Count() - okNum); listdata2.Add(okNum); } s.data = listdata; s2.data = listdata2; series.Add(s); series.Add(s2); businessColumn.categories = listCategories; businessColumn.series = series; return JsonConvert.SerializeObject(businessColumn); } } #endregion #region 焊工总数 protected string welderNum { get { return Funs.DB.SitePerson_Person.Where(x => x.ProjectId == CurrUser.LoginProjectId).Count().ToString(); } } #endregion } }