xinjiang/SGGL/FineUIPro.Web/HJGL/WeldingReport/OneWeekDeviceReport.aspx.cs

649 lines
30 KiB
C#

using BLL;
using FineUIPro.Web.Controls;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Text;
using AspNet = System.Web.UI.WebControls;
namespace FineUIPro.Web.HJGL.WeldingReport
{
public partial class OneWeekDeviceReport : PageBase
{
#region
/// <summary>
/// 加载页面
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
Funs.DropDownPageSize(this.ddlPageSize);
this.ddlPageSize.SelectedValue = this.Grid1.PageSize.ToString();
List<Model.Base_Unit> units = new List<Model.Base_Unit>();
txtEndDate.SelectedDate = DateTime.Now ;
txtStartDate.SelectedDate = DateTime.Now .AddDays(-7);
var pUnit = BLL.ProjectUnitService.GetProjectUnitByUnitIdProjectId(this.CurrUser.LoginProjectId, this.CurrUser.UnitId);
if (pUnit == null || pUnit.UnitType == Const.ProjectUnitType_1)
{
units = BLL.UnitService.GetUnitByProjectIdUnitTypeList(this.CurrUser.LoginProjectId, BLL.Const.ProjectUnitType_2);
//this.drpUnit.Enabled = false;
this.drpUnit.DataTextField = "UnitName";
this.drpUnit.DataValueField = "UnitId";
this.drpUnit.DataSource = units;
this.drpUnit.DataBind();
Funs.FineUIPleaseSelect(this.drpUnit);
}
else
{
units = BLL.UnitService.GetSubUnitsListBySupervisorUnitId(this.CurrUser.ProjectId, this.CurrUser.UnitId);
this.drpUnit.Enabled = false;
this.drpUnit.DataTextField = "UnitName";
this.drpUnit.DataValueField = "UnitId";
this.drpUnit.DataSource = units;
this.drpUnit.DataBind();
this.drpUnit.SelectedValue = CurrUser.UnitId;
}
//BindGrid();
}
}
#endregion
#region BindGrid
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid()
{
string strSql = @" SELECT IsoInfo.ISO_ID+Unit.UnitId ISO_ID ,
WorkArea.ProjectId
,Unit.UnitCode --单位代码
,Unit.UnitName --单位名称
,WorkArea.WorkAreaCode
,WorkArea.WorkAreaName
,IsoInfo.ISO_IsoNo
,tfm.jotNnum tfmjotNnum
,tfm.passdonedin tfmpassdonedin
,tfm.nopassdonedin tfmnopassdonedin
,CAST((CASE ISNULL(tfm.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(tfm.passdonedin , 0)-ISNULL(tfm.nopassdonedin , 0)) /(1.0 * tfm.passdonedin) END) AS DECIMAL(19,2))
AS tfmpassrate
,tofd.jotNnum tofdjotNnum
,tofd.passdonedin tofdpassdonedin
,tofd.nopassdonedin tofdnopassdonedin
,CAST((CASE ISNULL(tofd.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(tofd.passdonedin , 0)-ISNULL(tofd.nopassdonedin , 0)) /(1.0 * tofd.passdonedin) END) AS DECIMAL(19,2))
AS tofdpassrate
,ut.jotNnum utjotNnum
,ut.passdonedin utpassdonedin
,ut.nopassdonedin utnopassdonedin
,CAST((CASE ISNULL(ut.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(ut.passdonedin , 0)-ISNULL(ut.nopassdonedin , 0)) /(1.0 * ut.passdonedin) END) AS DECIMAL(19,2))
AS utpassrate
,mt.jotNnum mtjotNnum
,mt.passdonedin mtpassdonedin
,mt.nopassdonedin mtnopassdonedin
,CAST((CASE ISNULL(mt.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(mt.passdonedin , 0)-ISNULL(mt.nopassdonedin , 0)) /(1.0 * mt.passdonedin) END) AS DECIMAL(19,2))
AS mtpassrate
,pt.jotNnum ptjotNnum
,pt.passdonedin ptpassdonedin
,pt.nopassdonedin ptnopassdonedin
,CAST((CASE ISNULL(pt.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(pt.passdonedin , 0)-ISNULL(pt.nopassdonedin , 0)) /(1.0 * pt.passdonedin) END) AS DECIMAL(19,2))
AS ptpassrate
,tfmback.jotNnum tfmbackjotNnum
,tfmback.passdonedin tfmbackpassdonedin
,tfmback.nopassdonedin tfmbacknopassdonedin
,CAST((CASE ISNULL(tfmback.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(tfmback.passdonedin , 0)-ISNULL(tfmback.nopassdonedin , 0)) /(1.0 * tfmback.passdonedin) END) AS DECIMAL(19,2))
AS tfmbackpassrate
,tofdback.jotNnum tofdbackjotNnum
,tofdback.passdonedin tofdbackpassdonedin
,tofdback.nopassdonedin tofdbacknopassdonedin
,CAST((CASE ISNULL(tofdback.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(tofdback.passdonedin , 0)-ISNULL(tofdback.nopassdonedin , 0)) /(1.0 * tofdback.passdonedin) END) AS DECIMAL(19,2))
AS tofdbackpassrate
,utback.jotNnum utbackjotNnum
,utback.passdonedin utbackpassdonedin
,utback.nopassdonedin utbacknopassdonedin
,CAST((CASE ISNULL(utback.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(utback.passdonedin , 0)-ISNULL(utback.nopassdonedin , 0)) /(1.0 * utback.passdonedin) END) AS DECIMAL(19,2))
AS utbackpassrate
,mtback.jotNnum mtbackjotNnum
,mtback.passdonedin mtbackpassdonedin
,mtback.nopassdonedin mtbacknopassdonedin
,CAST((CASE ISNULL(mtback.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(mtback.passdonedin , 0)-ISNULL(mtback.nopassdonedin , 0)) /(1.0 * mtback.passdonedin) END) AS DECIMAL(19,2))
AS mtbackpassrate
,ptback.jotNnum ptbackjotNnum
,ptback.passdonedin ptbackpassdonedin
,ptback.nopassdonedin ptbacknopassdonedin
,CAST((CASE ISNULL(ptback.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(ptback.passdonedin , 0)-ISNULL(ptback.nopassdonedin , 0)) /(1.0 * ptback.passdonedin) END) AS DECIMAL(19,2))
AS ptbackpassrate
,tfmtotal.jotNnum tfmtotaljotNnum
,tfmtotal.passdonedin tfmtotalpassdonedin
,tfmtotal.nopassdonedin tfmtotalnopassdonedin
,CAST((CASE ISNULL(tfmtotal.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(tfmtotal.passdonedin , 0)-ISNULL(tfmtotal.nopassdonedin , 0)) /(1.0 * tfmtotal.passdonedin) END) AS DECIMAL(19,2))
AS tfmtotalpassrate
,tofdtotal.jotNnum tofdtotaljotNnum
,tofdtotal.passdonedin tofdtotalpassdonedin
,tofdtotal.nopassdonedin tofdtotalnopassdonedin
,CAST((CASE ISNULL(tofdtotal.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(tofdtotal.passdonedin , 0)-ISNULL(tofdtotal.nopassdonedin , 0)) /(1.0 * tofdtotal.passdonedin) END) AS DECIMAL(19,2))
AS tofdtotalpassrate
,uttotal.jotNnum uttotaljotNnum
,uttotal.passdonedin uttotalpassdonedin
,uttotal.nopassdonedin uttotalnopassdonedin
,CAST((CASE ISNULL(uttotal.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(uttotal.passdonedin , 0)-ISNULL(uttotal.nopassdonedin , 0)) /(1.0 * uttotal.passdonedin) END) AS DECIMAL(19,2))
AS uttotalpassrate
,mttotal.jotNnum mttotaljotNnum
,mttotal.passdonedin mttotalpassdonedin
,mttotal.nopassdonedin mttotalnopassdonedin
,CAST((CASE ISNULL(mttotal.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(mttotal.passdonedin , 0)-ISNULL(mttotal.nopassdonedin , 0)) /(1.0 * mttotal.passdonedin) END) AS DECIMAL(19,2))
AS mttotalpassrate
,pttotal.jotNnum pttotaljotNnum
,pttotal.passdonedin pttotalpassdonedin
,pttotal.nopassdonedin pttotalnopassdonedin
,CAST((CASE ISNULL(pttotal.passdonedin,0) WHEN 0 THEN 0
ELSE 100.0 * (ISNULL(pttotal.passdonedin , 0)-ISNULL(pttotal.nopassdonedin , 0)) /(1.0 * pttotal.passdonedin) END) AS DECIMAL(19,2))
AS pttotalpassrate
from ProjectData_WorkArea AS WorkArea
LEFT JOIN Base_Unit AS Unit ON WorkArea.UnitId =Unit.UnitId
LEFT JOIN PW_IsoInfo AS IsoInfo on IsoInfo.WorkAreaId = WorkArea.WorkAreaId
--3D-TFM
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('0087dd66-263d-4f7f-8ab7-f4d42b96d815') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2
group by a.ISO_ID
) as tfm on tfm.ISO_ID= IsoInfo.ISO_ID
--tofd
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('1b5a29de-b9dd-40af-9176-3f0156e1268b','4ba5ff2a-0a8a-4f60-b549-b2604f72c43e','7d28665b-21fc-45a0-affd-d7b28b9791e1') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2
group by a.ISO_ID
) as tofd on tofd.ISO_ID= IsoInfo.ISO_ID
--UT
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('a5e9c1bb-1fad-4e65-82bf-03003cc56ab4') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2
group by a.ISO_ID
) as ut on ut.ISO_ID= IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('c1a39a7f-141f-4243-a23d-34f4c9026d5f') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2
group by a.ISO_ID
) as mt on mt.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' and c.CH_TrustID=e.CH_TrustID then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_NDTMethod in ('2460a5e3-b5fb-40d6-942e-3092ddc11a72') and e.CHT_CheckDate >= @date1 and e.CHT_CheckDate < @date2
group by a.ISO_ID
) as pt on pt.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('0087dd66-263d-4f7f-8ab7-f4d42b96d815') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2
group by a.ISO_ID
) as tfmback on tfmback.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('1b5a29de-b9dd-40af-9176-3f0156e1268b','4ba5ff2a-0a8a-4f60-b549-b2604f72c43e','7d28665b-21fc-45a0-affd-d7b28b9791e1') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2
group by a.ISO_ID
) as tofdback on tofdback.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('a5e9c1bb-1fad-4e65-82bf-03003cc56ab4') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2
group by a.ISO_ID
) as utback on utback.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格'then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('c1a39a7f-141f-4243-a23d-34f4c9026d5f') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2
group by a.ISO_ID
) as mtback on mtback.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when d.CHT_CheckResult='合格'then jot_donedin else 0 end) as passdonedin,SUM(case when d.CHT_CheckResult!='合格' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID=d.CHT_CheckID
where a.ProjectId=@ProjectId and c.CH_TrustType='2' and a.JOT_JointStatus !='102' and c.CH_NDTMethod in ('2460a5e3-b5fb-40d6-942e-3092ddc11a72') and e.CH_TrustID=c.CH_TrustID and c.CH_TrustDate >= @date1 and c.CH_TrustDate < @date2
group by a.ISO_ID
) as ptback on ptback.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID
where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('0087dd66-263d-4f7f-8ab7-f4d42b96d815')
group by a.ISO_ID
) as tfmtotal on tfmtotal.ISO_ID= IsoInfo.ISO_ID
--tofd
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID
where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('1b5a29de-b9dd-40af-9176-3f0156e1268b','4ba5ff2a-0a8a-4f60-b549-b2604f72c43e','7d28665b-21fc-45a0-affd-d7b28b9791e1')
group by a.ISO_ID
) as tofdtotal on tofdtotal.ISO_ID= IsoInfo.ISO_ID
--UT
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID
where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('a5e9c1bb-1fad-4e65-82bf-03003cc56ab4')
group by a.ISO_ID
) as uttotal on uttotal.ISO_ID= IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID
where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('c1a39a7f-141f-4243-a23d-34f4c9026d5f')
group by a.ISO_ID
) as mttotal on mttotal.ISO_ID = IsoInfo.ISO_ID
LEFT JOIN (
SELECT COUNT(distinct a.JOT_ID) as jotNnum, SUM(case when c.CH_TrustType='1' then jot_donedin else 0 end) as passdonedin,SUM(case when c.CH_TrustType='2' and JOT_JointStatus !='102' then DefectLength else 0 end) as nopassdonedin, a.ISO_ID
from PW_JointInfo a
left join CH_TrustItem b on a.JOT_ID = b.JOT_ID
left join CH_Trust c on b.CH_TrustID = c.CH_TrustID
left join CH_CheckItem d on a.JOT_ID = d.JOT_ID
left join CH_Check e on e.CHT_CheckID = d.CHT_CheckID and e.CH_TrustID = c.CH_TrustID
where a.ProjectId=@ProjectId and e.CHT_CheckDate is not null and c.CH_NDTMethod in ('2460a5e3-b5fb-40d6-942e-3092ddc11a72')
group by a.ISO_ID
) as pttotal on pttotal.ISO_ID = IsoInfo.ISO_ID
where IsoInfo.ProjectId=@ProjectId and ( IsoInfo.Is_Standard=@IsStandard OR @IsStandard = '') ";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
listStr.Add(new SqlParameter("@date2", this.txtEndDate.SelectedDate.Value.AddDays(1).ToString("yyyy-MM-dd")));
listStr.Add(new SqlParameter("@date1", this.txtStartDate.SelectedDate.Value.ToString("yyyy-MM-dd")));
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
strSql += " and WorkArea.UnitId= @UnitId ";
listStr.Add(new SqlParameter("@UnitId", this.drpUnit.SelectedValue));
}
if (this.cb_IsStandard.SelectedIndexArray != null && this.cb_IsStandard.SelectedIndexArray.Length == 1)
{
listStr.Add(new SqlParameter("@IsStandard", this.cb_IsStandard.SelectedValueArray[0]));
}
else
{
listStr.Add(new SqlParameter("@IsStandard", ""));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tb1 = SQLHelper.GetDataTableRunText(strSql, parameter);
Grid1.RecordCount = tb1.Rows.Count;
Grid1.DataSource = tb1;
Grid1.DataBind();
}
/// <summary>
/// 改变索引事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_PageIndexChange(object sender, GridPageEventArgs e)
{
BindGrid();
}
/// <summary>
/// 分页下拉选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void ddlPageSize_SelectedIndexChanged(object sender, EventArgs e)
{
Grid1.PageSize = Convert.ToInt32(ddlPageSize.SelectedValue);
BindGrid();
}
/// <summary>
/// 排序
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_Sort(object sender, FineUIPro.GridSortEventArgs e)
{
this.BindGrid();
}
#endregion
#region
/// <summary>
/// 开始日期选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtStartDate_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.txtStartDate.Text.Trim()))
{
this.txtEndDate.Text = Funs.GetNewDateTime(this.txtStartDate.Text.Trim()).Value.AddDays(6).ToShortDateString();
}
}
/// <summary>
/// 结束日期选择事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void txtEndDate_TextChanged(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(this.txtEndDate.Text.Trim()))
{
this.txtStartDate.Text = Funs.GetNewDateTime(this.txtEndDate.Text.Trim()).Value.AddDays(-6).ToShortDateString();
}
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Window1_Close(object sender, WindowCloseEventArgs e)
{
this.BindGrid();
// 显示列
//var c = UserShowColumnsService.GetColumnsByUserId(this.CurrUser.UserId, Const.UnitAreaQualityMenuId);
//if (c != null)
//{
// this.GetShowColumn(c.Columns);
//}
}
/// <summary>
/// 显示的列
/// </summary>
/// <param name="column"></param>
private void GetShowColumn(string column)
{
if (!string.IsNullOrEmpty(column))
{
for (int i = 0; i < Grid1.Columns.Count; i++)
{
this.Grid1.Columns[i].Hidden = true;
}
List<string> columns = column.Split(',').ToList();
foreach (var item in columns)
{
this.Grid1.Columns[Convert.ToInt32(item)].Hidden = false;
}
}
}
#region
/// <summary>
/// 统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void BtnAnalyse_Click(object sender, EventArgs e)
{
if (!txtStartDate.SelectedDate.HasValue|| !txtEndDate.SelectedDate.HasValue)
{
Alert.ShowInTop("请选择日期!", MessageBoxIcon.Warning);
return;
}
BindGrid();
//OutputSummaryData();
}
#endregion
#region
/// 导出按钮
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnOut_Click(object sender, EventArgs e)
{
Response.ClearContent();
string filename = Funs.GetNewFileName();
Response.AddHeader("content-disposition", "attachment; filename=" + System.Web.HttpUtility.UrlEncode("储罐/管道每周焊接量统计表" + filename, System.Text.Encoding.UTF8) + ".xls");
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}
/// <summary>
/// 导出方法
/// </summary>
/// <param name="grid"></param>
/// <returns></returns>
private string GetGridTableHtml(Grid grid)
{
StringBuilder sb = new StringBuilder();
MultiHeaderTable mht = new MultiHeaderTable();
mht.ResolveMultiHeaderTable(Grid1.Columns);
sb.Append("<meta http-equiv=\"content-type\" content=\"application/excel; charset=UTF-8\"/>");
sb.Append("<table cellspacing=\"0\" rules=\"all\" border=\"1\" style=\"border-collapse:collapse;\">");
foreach (List<object[]> rows in mht.MultiTable)
{
sb.Append("<tr>");
foreach (object[] cell in rows)
{
int rowspan = Convert.ToInt32(cell[0]);
int colspan = Convert.ToInt32(cell[1]);
GridColumn column = cell[2] as GridColumn;
sb.AppendFormat("<th{0}{1}{2}>{3}</th>",
rowspan != 1 ? " rowspan=\"" + rowspan + "\"" : "",
colspan != 1 ? " colspan=\"" + colspan + "\"" : "",
colspan != 1 ? " style=\"text-align:center;\"" : "",
column.HeaderText);
}
sb.Append("</tr>");
}
int j = 0;
foreach (GridRow row in grid.Rows)
{
sb.Append("<tr>");
int i = 0;
foreach (GridColumn column in mht.Columns)
{
string html = row.Values[column.ColumnIndex].ToString();
if (column.ColumnID == "tfNumber")
{
html = (row.FindControl("labNumber1") as AspNet.Label).Text;
}
sb.AppendFormat("<td >{0}</td>", html);
i++;
}
j++;
sb.Append("</tr>");
}
var sumary = grid.SummaryData;
if (sumary != null)
{
sb.Append("<tr>");
foreach (GridColumn column in grid.Columns)
{
try
{
if (column is GroupField)
{
if (((GroupField)column).Columns != null)
{
foreach (var item in ((GroupField)column).Columns)
{
if (!column.Hidden)
{
if (sumary.ContainsKey(item.ColumnID))
{
sb.AppendFormat("<td style=\"text-align:center;vnd.ms-excel.numberformat:@\" >{0}</td>", sumary.GetValue(item.ColumnID).ToString());
}
else
{
sb.AppendFormat("<td style=\"text-align:center;vnd.ms-excel.numberformat:@\" >{0}</td>", "");
}
}
}
}
}
else if (column is RenderField)
{
if (!column.Hidden)
{
if (sumary.ContainsKey(column.ColumnID))
{
sb.AppendFormat("<td style=\"text-align:center;vnd.ms-excel.numberformat:@\" >{0}</td>", sumary.GetValue(column.ColumnID).ToString());
}
else
{
sb.AppendFormat("<td style=\"text-align:center;vnd.ms-excel.numberformat:@\" >{0}</td>", "");
}
}
}
else
{
if (!column.Hidden)
{
sb.AppendFormat("<td style=\"text-align:center;vnd.ms-excel.numberformat:@\" >{0}</td>", "");
}
}
}
catch (Exception e)
{
sb.AppendFormat("<td style=\"text-align:center;vnd.ms-excel.numberformat:@\" >{0}</td>", "");
}
}
sb.Append("</tr>");
}
sb.Append("</table>");
return sb.ToString();
}
#endregion
#region
/// <summary>
/// 单位下拉选择事件
/// </summary>
/// <param name = "sender" ></ param >
/// < param name="e"></param>
protected void drpUnit_SelectedIndexChanged(object sender, EventArgs e)
{
}
#endregion
}
}