using BLL;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace FineUIPro.Web
{
    public partial class mainMenu_HJGL : PageBase
    {
        public string PassRate
        {
            get
            {
                return (string)ViewState["PassRate"];
            }
            set
            {
                ViewState["PassRate"] = value;
            }
        }
        public string WelderNum
        {
            get
            {
                return (string)ViewState["WelderNum"];
            }
            set
            {
                ViewState["WelderNum"] = value;
            }
        }
        public string WelderNumDef
        {
            get
            {
                return (string)ViewState["WelderNumDef"];
            }
            set
            {
                ViewState["WelderNumDef"] = value;
            }
        }
        public string xArr31
        {
            get
            {
                return (string)ViewState["xArr31"];
            }
            set
            {
                ViewState["xArr31"] = value;
            }
        }

        public string data310
        {
            get
            {
                return (string)ViewState["data310"];
            }
            set
            {
                ViewState["data310"] = value;
            }
        }

        public string xArr32
        {
            get
            {
                return (string)ViewState["xArr32"];
            }
            set
            {
                ViewState["xArr32"] = value;
            }
        }

        public string data320
        {
            get
            {
                return (string)ViewState["data320"];
            }
            set
            {
                ViewState["data320"] = value;
            }
        }

        public string xArr41
        {
            get
            {
                return (string)ViewState["xArr41"];
            }
            set
            {
                ViewState["xArr41"] = value;
            }
        }

        public string data41
        {
            get
            {
                return (string)ViewState["data41"];
            }
            set
            {
                ViewState["data41"] = value;
            }
        }
        public string xArr42
        {
            get
            {
                return (string)ViewState["xArr42"];
            }
            set
            {
                ViewState["xArr42"] = value;
            }
        }

        public string data42
        {
            get
            {
                return (string)ViewState["data42"];
            }
            set
            {
                ViewState["data42"] = value;
            }
        }
        public string data21
        {
            get
            {
                return (string)ViewState["data21"];
            }
            set
            {
                ViewState["data21"] = value;
            }
        }
        public string data22
        {
            get
            {
                return (string)ViewState["data22"];
            }
            set
            {
                ViewState["data22"] = value;
            }
        }
        public string xArr11
        {
            get
            {
                return (string)ViewState["xArr11"];
            }
            set
            {
                ViewState["xArr11"] = value;
            }
        }

        public string data11
        {
            get
            {
                return (string)ViewState["data11"];
            }
            set
            {
                ViewState["data11"] = value;
            }
        }
        public string data55
        {
            get
            {
                return (string)ViewState["data55"];
            }
            set
            {
                ViewState["data55"] = value;
            }
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                WelderNumDef = string.Empty;
                var punit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x=>x.ProjectId==CurrUser.LoginProjectId&&x.UnitId==CurrUser.UnitId);

                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId||(punit!=null && (punit.UnitType== BLL.Const.ProjectUnitType_3|| punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    var welders = from x in Funs.DB.BS_Welder where x.ProjectId == CurrUser.LoginProjectId && x.WED_IfOnGuard == true select x;
                    var projectUnits = from x in Funs.DB.Base_Unit
                                       join y in Funs.DB.Project_ProjectUnit on x.UnitId equals y.UnitId
                                       where y.ProjectId == CurrUser.LoginProjectId && y.UnitType == BLL.Const.ProjectUnitType_2
                                       select x;
                    WelderNum = welders.Count().ToString();
                    foreach (var item in projectUnits)
                    {
                        WelderNumDef += (item.UnitName + ":  " + welders.Count(x => x.WED_Unit == item.UnitId).ToString() + "|");
                    }
                    if (!string.IsNullOrEmpty(WelderNumDef))
                    {
                        WelderNumDef = WelderNumDef.Substring(0, WelderNumDef.Length - 1);
                    }
                }
                else
                {
                    var welders = from x in Funs.DB.BS_Welder where x.ProjectId == CurrUser.LoginProjectId && x.WED_Unit == CurrUser.UnitId && x.WED_IfOnGuard == true select x;
                    WelderNum = welders.Count().ToString();
                    var unitName = BLL.UnitService.GetUnitNameByUnitId(CurrUser.UnitId);
                    WelderNumDef += (unitName + ":  " + welders.Count().ToString());
                }
                string strSql = "";
                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {

                    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.JOT_ID
                                 where ProjectId = '" + CurrUser.LoginProjectId + "'";
                }
                else
                {
                    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.JOT_ID
                                left join PW_IsoInfo IsoInfo on IsoInfo.ISO_ID=JointInfo.ISO_ID
                                 where JointInfo.ProjectId = '" + CurrUser.LoginProjectId + "' and UnitId='" + CurrUser.UnitId + "'";
                }
                //    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());
                        PassRate = "" + ((int)rate);
                    }
                    catch (Exception ex)
                    {
                        PassRate = "0";
                    }
                }



                string sql41 = "";

                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql41 = @"select WorkArea.WorkAreaId,WorkArea.WorkAreaName ,SUM(cht_totalfilm) AS  total_film
                                 , SUM(cht_passfilm) AS pass_film from CH_CheckItem ch_checkitem left
                                join PW_JointInfo JointInfo on JointInfo.JOT_ID = ch_checkitem.JOT_ID
                                left join PW_IsoInfo IsoInfo on IsoInfo.ISO_ID=JointInfo.ISO_ID
								left join ProjectData_WorkArea WorkArea on WorkArea.WorkAreaId = IsoInfo.WorkAreaId								 
								where JointInfo.ProjectId = '" + CurrUser.LoginProjectId + @"'
                                group by WorkArea.WorkAreaId,WorkArea.WorkAreaName";
                }
                else
                {
                    sql41 = @"select WorkArea.WorkAreaId,WorkArea.WorkAreaName ,SUM(cht_totalfilm) AS  total_film
                                 , SUM(cht_passfilm) AS pass_film from CH_CheckItem ch_checkitem left
                                join PW_JointInfo JointInfo on JointInfo.JOT_ID = ch_checkitem.JOT_ID
                                left join PW_IsoInfo IsoInfo on IsoInfo.ISO_ID=JointInfo.ISO_ID
								left join ProjectData_WorkArea WorkArea on WorkArea.WorkAreaId = IsoInfo.WorkAreaId								 
								 where JointInfo.ProjectId = '" + CurrUser.LoginProjectId + @"' and IsoInfo.UnitId='" + CurrUser.UnitId + @"'
								 group by WorkArea.WorkAreaId,WorkArea.WorkAreaName";
                }
                DataTable tb41 = SQLHelper.GetDataTableRunText(sql41);

                if (tb41 != null)
                {
                    string xarr = "";
                    string data = "";
                    foreach (DataRow row in tb41.Rows)
                    {
                        xarr += "\"" + row["WorkAreaName"].ToString() + "\",";
                        data += (100.0 * Funs.GetNewDoubleOrZero(row["pass_film"].ToString()) / Funs.GetNewDoubleOrZero(row["total_film"].ToString())).ToString("#0.00") + ",";

                    }

                    xArr41 = xarr.TrimEnd(',');
                    data41 = data.TrimEnd(',');
                }

                string sql42 = "";

                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql42 = @"select unit.UnitId,unit.UnitName ,SUM(cht_totalfilm) AS  total_film
                                 , SUM(cht_passfilm) AS pass_film from CH_CheckItem ch_checkitem left
                                join PW_JointInfo JointInfo on JointInfo.JOT_ID = ch_checkitem.JOT_ID
                                left join PW_IsoInfo IsoInfo on IsoInfo.ISO_ID=JointInfo.ISO_ID
								left join Base_Unit unit on unit.UnitId = IsoInfo.UnitId								 
								where JointInfo.ProjectId = '" + CurrUser.LoginProjectId + @"'
                                group by unit.UnitId,unit.UnitName";
                }
                else
                {
                    sql42 = @"select unit.UnitId,unit.UnitName ,SUM(cht_totalfilm) AS  total_film
                                 , SUM(cht_passfilm) AS pass_film from CH_CheckItem ch_checkitem left
                                join PW_JointInfo JointInfo on JointInfo.JOT_ID = ch_checkitem.JOT_ID
                                left join PW_IsoInfo IsoInfo on IsoInfo.ISO_ID=JointInfo.ISO_ID
								left join Base_Unit unit on unit.UnitId = IsoInfo.UnitId								 
								 where JointInfo.ProjectId = '" + CurrUser.LoginProjectId + @"' and IsoInfo.UnitId='" + CurrUser.UnitId + @"'
								 group by unit.UnitId,unit.UnitName";
                }
                DataTable tb42 = SQLHelper.GetDataTableRunText(sql42);

                if (tb41 != null)
                {
                    string xarr = "";
                    string data = "";
                    foreach (DataRow row in tb42.Rows)
                    {
                        xarr += "\"" + row["UnitName"].ToString() + "\",";
                        data += (100.0 * Funs.GetNewDoubleOrZero(row["pass_film"].ToString()) / Funs.GetNewDoubleOrZero(row["total_film"].ToString())).ToString("#0.00") + ",";

                    }

                    xArr42 = xarr.TrimEnd(',');
                    data42 = data.TrimEnd(',');
                }


                string sql31 = "";
                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql31 = @"SELECT  WorkArea.WorkAreaId,WorkArea.WorkAreaName, sum(JOT_Size) total_jot ,
			                    SUM(JOT_DoneDin)  finished_total_jot
			                    FROM pw_jointinfo 
			                    LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID 
                                LEFT JOIN  ProjectData_WorkArea WorkArea on WorkArea.WorkAreaId = pw_isoinfo.WorkAreaId	
								 where pw_jointinfo.ProjectId = '" + CurrUser.LoginProjectId + @"' group by WorkArea.WorkAreaId,WorkArea.WorkAreaName";
                }
                else
                {
                    sql31 = @"SELECT  WorkArea.WorkAreaId,WorkArea.WorkAreaName,sum(JOT_Size) total_jot ,  
			                    SUM(JOT_DoneDin)  finished_total_jot
			                    FROM pw_jointinfo 
			                    LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID  		
                                LEFT JOIN  ProjectData_WorkArea WorkArea on WorkArea.WorkAreaId = pw_isoinfo.WorkAreaId	
								 where pw_jointinfo.ProjectId = '" + CurrUser.LoginProjectId + @"' and pw_isoinfo.UnitId='" + CurrUser.UnitId + @"'  group by WorkArea.WorkAreaId,WorkArea.WorkAreaName";

                }
                DataTable tb31 = SQLHelper.GetDataTableRunText(sql31);
                if (tb31 != null)
                {
                    string xarr = "";
                    string datat0 = "";
                    foreach (DataRow row in tb31.Rows)
                    {
                        xarr += "\"" + row["WorkAreaName"].ToString() + "(" + (Funs.GetNewDoubleOrZero(row["finished_total_jot"].ToString()) / 10000).ToString("0.##") + "/" + (Funs.GetNewDoubleOrZero(row["total_jot"].ToString()) / 10000).ToString("0.##") + ")\",";
                        datat0 += (100.0 * Funs.GetNewDoubleOrZero(row["finished_total_jot"].ToString()) / Funs.GetNewDoubleOrZero(row["total_jot"].ToString())).ToString("#0.00") + ",";

                    }

                    xArr31 = xarr.TrimEnd(',');
                    data310 = datat0.TrimEnd(',');
                }


                string sql32 = "";
                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql32 = @"SELECT  unit.UnitId,unit.UnitName, SUM(JOT_Size) total_jot ,
			                    SUM(  JOT_DoneDin )  finished_total_jot
			                    FROM pw_jointinfo 
			                    LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID 
                           	    left join Base_Unit unit on unit.UnitId =   pw_isoinfo.UnitId	
								 where pw_jointinfo.ProjectId = '" + CurrUser.LoginProjectId + @"' group by unit.UnitId,unit.UnitName";
                }
                else
                {
                    sql32 = @"SELECT  unit.UnitId,unit.UnitName,SUM(JOT_Size) total_jot ,  
			                    SUM(JOT_DoneDin)  finished_total_jot
			                    FROM pw_jointinfo 
			                    LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID  		
                                left join Base_Unit unit on unit.UnitId =  pw_isoinfo.UnitId	
								 where pw_jointinfo.ProjectId = '" + CurrUser.LoginProjectId + @"' and pw_isoinfo.UnitId='" + CurrUser.UnitId + @"'  group by unit.UnitId,unit.UnitName";

                }
                DataTable tb32 = SQLHelper.GetDataTableRunText(sql32);
                if (tb32 != null)
                {
                    string xarr = "";
                    string datat0 = "";
                    foreach (DataRow row in tb32.Rows)
                    {
                        xarr += "\"" + row["UnitName"].ToString() + "(" + (Funs.GetNewDoubleOrZero(row["finished_total_jot"].ToString()) / 10000).ToString("0.##") + "/" + (Funs.GetNewDoubleOrZero(row["total_jot"].ToString()) / 10000).ToString("0.##") + ")\",";
                        datat0 += (100.0 * Funs.GetNewDoubleOrZero(row["finished_total_jot"].ToString()) / Funs.GetNewDoubleOrZero(row["total_jot"].ToString())).ToString("#0.00") + ",";

                    }

                    xArr32 = xarr.TrimEnd(',');
                    data320 = datat0.TrimEnd(',');
                }


                string sql5 = "";
                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql5 = @"select Defects_Definition ,count(*) as num from CH_CheckItem a left join CH_Check b on a.CHT_CheckID=b.CHT_CheckID
                            where b.ProjectId='" + CurrUser.LoginProjectId + @"'  and Defects_Definition <>'' and CHT_CheckResult='不合格'  
                            group by Defects_Definition    ";
                }
                else
                {
                    sql5 = @"select Defects_Definition ,count(*) as num from CH_CheckItem a left join CH_Check b on a.CHT_CheckID=b.CHT_CheckID
                            where b.ProjectId='" + CurrUser.LoginProjectId + @"'  and Defects_Definition <>'' and b.UnitId='" + CurrUser.UnitId + @"' and CHT_CheckResult='不合格' 
                            group by Defects_Definition    ";
                }
                DataTable tb5 = SQLHelper.GetDataTableRunText(sql5);
                if (tb5 != null && tb5.Rows.Count > 0)
                {
                    foreach (DataRow row in tb5.Rows)
                    {
                        data55 += "{ value:  " + row["num"].ToString() + @", name: '" + row["Defects_Definition"].ToString() + "' },";
                    }
                    data55 = data55.TrimEnd(',');
                }
                string sql6 = "";
                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql6 = @"SELECT COUNT(*) total_jot , SUM(case when pw_isoinfo.[Is_Standard] = 0 then JOT_Size else pw_jointinfo.JOT_Size end) AS total_din
			                    ,SUM(JOT_DoneDin) AS finished_total_din ,
			                    SUM(CASE WHEN DReportID is not null THEN 1 ELSE 0 END)  finished_total_jot
			                    FROM pw_jointinfo 
			                    LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID  						 
								 where pw_jointinfo.ProjectId = '" + CurrUser.LoginProjectId + @"' ";
                }
                else
                {
                    sql6 = @"SELECT COUNT(*) total_jot , SUM(case when pw_isoinfo.[Is_Standard] = 0 then JOT_Size else pw_jointinfo.JOT_Size end) AS total_din
			                    ,SUM(JOT_DoneDin) AS finished_total_din ,
			                    SUM(CASE WHEN DReportID is not null THEN 1 ELSE 0 END)  finished_total_jot
			                    FROM pw_jointinfo 
			                    LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID  						 
								 where pw_jointinfo.ProjectId = '" + CurrUser.LoginProjectId + @"' and pw_isoinfo.UnitId='" + CurrUser.UnitId + @"'";

                }
                DataTable tb6 = SQLHelper.GetDataTableRunText(sql6);

                if (tb6 != null && tb6.Rows.Count > 0)
                {
                    int total_jot = 0;
                    int finished_total_jot = 0;
                    if (tb6.Rows[0]["total_jot"] != DBNull.Value)
                    {
                        total_jot = int.Parse(tb6.Rows[0]["total_jot"].ToString());
                    }
                    if (tb6.Rows[0]["finished_total_jot"] != DBNull.Value)
                    {
                        finished_total_jot = int.Parse(tb6.Rows[0]["finished_total_jot"].ToString());
                    }

                    double total_din = 0;
                    double finished_total_din = 0;

                    if (tb6.Rows[0]["total_din"] != DBNull.Value)
                    {
                        total_din = double.Parse(tb6.Rows[0]["total_din"].ToString());
                    }
                    if (tb6.Rows[0]["finished_total_din"] != DBNull.Value)
                    {
                        finished_total_din = double.Parse(tb6.Rows[0]["finished_total_din"].ToString());
                    }
                    data21 = @"{ value: " + finished_total_din + @", name: '已完成' },
                            { value: " + (total_din - finished_total_din) + @", name: '未完成' }";

                    data22 = @"{ value:  " + finished_total_jot + @", name: '已完成' },
                            { value: " + (total_jot - finished_total_jot) + @", name: '未完成' }";
                }
                else
                {
                    data21 = @"{ value: 0, name: '已完成' },
                            { value: 0, name: '未完成' }";

                    data22 = @"{ value: 0, name: '已完成' },
                            { value: 0, name: '未完成' }";
                }



                string sql11 = "";
                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql11 = @"SELECT DAY(jot_welddate) as [day],MONTH(jot_welddate) as [month],
                             COUNT(*) finished_total_jot_bq ,
                             SUM(
                             case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else pw_jointinfo.JOT_DoneDin end 
                             ) AS finished_total_din_bq	 
			                            FROM pw_jointinfo 
			                            LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
			                            LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid 
			                             WHERE  pw_isoinfo.ProjectId = '" + this.CurrUser.LoginProjectId + "'  and jot_welddate >='" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "' and jot_welddate <'" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + "'" +
                                        @"GROUP BY DAY(jot_welddate),MONTH(jot_welddate) ";
                }
                else
                {
                    sql11 = @"SELECT DAY(jot_welddate) as [day],MONTH(jot_welddate) as [month],
                             COUNT(*) finished_total_jot_bq ,
                             SUM(
                             case when pw_isoinfo.[Is_Standard] = 0 then JOT_DoneDin else pw_jointinfo.JOT_DoneDin end 
                             ) AS finished_total_din_bq	 
			                            FROM pw_jointinfo 
			                            LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
			                            LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid 
			                             WHERE  pw_isoinfo.ProjectId = '" + this.CurrUser.LoginProjectId + "' and pw_isoinfo.UnitId ='" + this.CurrUser.UnitId + "'  and jot_welddate >='" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "' and jot_welddate <'" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + "'" +
                                        @"GROUP BY DAY(jot_welddate),MONTH(jot_welddate) ";
                }


                DataTable tb11 = SQLHelper.GetDataTableRunText(sql11);

                string sql12 = "";
                if (CurrUser.UnitId == Const.UnitId_TCC || CurrUser.UserId == Const.hfnbdId || (punit != null && (punit.UnitType == BLL.Const.ProjectUnitType_3 || punit.UnitType == BLL.Const.ProjectUnitType_4)))
                {
                    sql12 = @"   select [day],[month], COUNT(distinct JOT_CellWelder)  as WelderNum from(SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
                               JOT_CellWelder
                               FROM pw_jointinfo
                               LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
                               LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
                               WHERE  pw_isoinfo.ProjectId = '" + this.CurrUser.LoginProjectId + "' and jot_welddate >= '" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "' and jot_welddate < '" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + "'" +

                               @"union   
                        SELECT DAY(jot_welddate) as [day],MONTH(jot_welddate) as [month], 
		                        JOT_FloorWelder  
		                        FROM pw_jointinfo 
		                        LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
		                        LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid 
		                        WHERE  pw_isoinfo.ProjectId = '" + this.CurrUser.LoginProjectId + "' and   jot_welddate >='" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "' and jot_welddate <'" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + "'" +
                               @") as a  group by [day],[month]";

                }
                else
                {
                    sql12 = @" select [day],[month], COUNT(distinct JOT_CellWelder)  as WelderNum from(SELECT DAY(jot_welddate) as [day], MONTH(jot_welddate) as [month],
                                JOT_CellWelder
                               FROM pw_jointinfo
                               LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
                               LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid
                               WHERE  pw_isoinfo.ProjectId = '" + this.CurrUser.LoginProjectId + "' and pw_isoinfo.UnitId = '" + this.CurrUser.UserId + "' and jot_welddate >= '" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "' and jot_welddate < '" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + "'" +

                               @"union   
                        SELECT DAY(jot_welddate) as [day],MONTH(jot_welddate) as [month], 
		                        JOT_FloorWelder  
		                        FROM pw_jointinfo 
		                        LEFT JOIN pw_isoinfo  ON pw_jointinfo.ISO_ID = pw_isoinfo.ISO_ID
		                        LEFT JOIN BO_WeldReportMain ON BO_WeldReportMain.dreportid = pw_jointinfo.dreportid 
		                        WHERE  pw_isoinfo.ProjectId = '" + this.CurrUser.LoginProjectId + "' and pw_isoinfo.UnitId ='" + this.CurrUser.UserId + "'  and jot_welddate >='" + DateTime.Now.AddDays(-7).ToString("yyyy-MM-dd") + "' and jot_welddate <'" + DateTime.Now.AddDays(1).ToString("yyyy-MM-dd") + "'" +
                               @") as a  group by [day],[month]";
                }
                DataTable tb12 = SQLHelper.GetDataTableRunText(sql12);
                DateTime temp = DateTime.Now.AddDays(-7);
                string data1 = "";
                string xarr1 = "";
                for (int i = 0; i < 7; i++)
                {
                    int WelderNum = 0;
                    double finished_total_din_bq = 0;

                    foreach (DataRow row in tb11.Rows)
                    {
                        if (row["day"].ToString() == temp.Day.ToString() && row["month"].ToString() == temp.Month.ToString())
                        {
                            finished_total_din_bq = Funs.GetNewDoubleOrZero(row["finished_total_din_bq"].ToString());

                        }
                    }
                    foreach (DataRow row in tb12.Rows)
                    {
                        if (row["day"].ToString() == temp.Day.ToString() && row["month"].ToString() == temp.Month.ToString())
                        {
                            WelderNum = Funs.GetNewIntOrZero(row["WelderNum"].ToString());
                        }
                    }
                    xarr1 += "'" + temp.Day.ToString() + "(" + finished_total_din_bq + "吋/" + WelderNum + "人)',";
                    if (WelderNum > 0)
                        data1 += (finished_total_din_bq / WelderNum).ToString("0.00") + ",";
                    else
                        data1 += "0,";
                    temp = temp.AddDays(1);
                }
                xArr11 = xarr1.TrimEnd(',');
                data11 = data1.TrimEnd(',');

            }
        }
    }
}