This commit is contained in:
高飞 2025-06-11 14:48:23 +08:00
parent ea4dc8fd8f
commit 536ca5debe
2 changed files with 199 additions and 29 deletions

View File

@ -0,0 +1,146 @@
ALTER PROC [dbo].[HJGL_sp_rpt_welderPerformanceSum]
@unitcode VARCHAR(50) = NULL,
@steel VARCHAR(50) = NULL,
@WED_ID NVARCHAR(50) = NULL,
@date1 DATETIME = NULL,
@date2 DATETIME = NULL,
@projectId NVARCHAR(500) = NULL,
@installationId NVARCHAR(50)=NULL
AS
/*焊工业绩分析*/
SELECT
NEWID() AS Id,
-------------start
CAST(ISNULL(total.totalSize,0) AS DECIMAL(19,2)) AS totalSize, --
ISNULL(total.totalJoint,0) AS totalJoint, --
ISNULL(JointNum1.JointNum1,0) AS JointNum1, --
ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0) AS JointPassNum1, --
ISNULL(JointNoPassNum1.JointNoPassNum1,0) AS RepairJoint1, --
ISNULL(RepairJoint2.RepairJoint2,0) AS RepairJoint2, --
ISNULL(RepairJoint3.RepairJoint3,0) AS RepairJoint3, --
CAST((CASE ISNULL((ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0)),0) WHEN 0 THEN 0
ELSE (CASE(ISNULL(JointNum1.JointNum1,0)) WHEN 0 THEN 0
ELSE 1.0 * ISNULL((ISNULL(JointNum1.JointNum1,0)-ISNULL(JointNoPassNum1.JointNoPassNum1,0)),0)/(1.0 * JointNum1.JointNum1)
END)END) AS DECIMAL(19,3)) AS JointPassRate , ---
ISNULL(JointNum1.totalfilm,0) AS totalfilm, --
(ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0)) AS totalPassfilm, --
ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0) AS repairFilm1, --
ISNULL(RepairJoint2.repairFilm2,0) AS repairFilm2, --
ISNULL(RepairJoint3.repairFilm3,0) AS repairFilm3, --
CAST((CASE (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0)) WHEN 0 THEN 0
ELSE (CASE(ISNULL(JointNum1.totalfilm,0)) WHEN 0 THEN 0
ELSE 1.0 * (ISNULL(JointNum1.totalfilm,0)- ISNULL(JointNoPassNum2.JointNoPassFilmNum2,0))/(1.0 * JointNum1.totalfilm)
END) END) AS DECIMAL(19,3)) AS JointFilmPassRate ---
FROM
-- --
(SELECT SUM(joint.JOT_Size) AS totalSize,COUNT(*) AS totalJoint
,joint.ProjectId,joint.InstallationId,iso.BSU_ID
FROM HJGL_PW_JointInfo joint
LEFT JOIN HJGL_PW_IsoInfo iso ON iso.ISO_ID = joint.ISO_ID
LEFT JOIN HJGL_BO_WeldReportMain report ON joint.DReportID = report.DReportID
WHERE joint.DReportID IS NOT NULL
AND (report.JOT_WeldDate >= @date1 OR @date1 IS NULL) AND (report.JOT_WeldDate <= @date2 OR @date2 IS NULL)
AND (joint.ste_id=@steel OR @steel IS NULL)
GROUP BY joint.ProjectId,joint.InstallationId,iso.BSU_ID) AS total
-- , ,
LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS JointNum1, SUM(joint.RT_FilmNum) AS totalfilm,
joint.ProjectId,joint.InstallationId,iso.BSU_ID
FROM HJGL_PW_JointInfo joint
LEFT JOIN HJGL_PW_IsoInfo iso ON iso.ISO_ID = joint.ISO_ID
WHERE joint.PointType='点口' AND (select COUNT(*) from dbo.HJGL_BO_QualityRating a
left join HJGL_CH_TrustItem b on a.CH_TrustItemID=b.CH_TrustItemID
left join HJGL_CH_Trust c on b.CH_TrustID=c.CH_TrustID where a.JOT_ID=joint.JOT_ID and FilmNum is not null and c.CH_NDTMethod='20d2cbca-8b3d-434b-b1c1-181796986fa5')>0
AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_BO_QualityRating WHERE JOT_ID=joint.JOT_ID)>= @date1 OR @date1 IS NULL)
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_BO_QualityRating WHERE JOT_ID=joint.JOT_ID)<= @date2 OR @date2 IS NULL)
GROUP BY joint.ProjectId,joint.InstallationId,iso.BSU_ID) AS JointNum1
ON JointNum1.ProjectId=total.ProjectId AND JointNum1.InstallationId = total.InstallationId
AND JointNum1.BSU_ID = total.BSU_ID
--
LEFT JOIN (SELECT COUNT(distinct joint.JOT_ID) AS JointNoPassNum1,
joint.ProjectId,joint.InstallationId,iso.BSU_ID
FROM HJGL_PW_JointInfo joint
LEFT JOIN HJGL_PW_IsoInfo iso ON iso.ISO_ID = joint.ISO_ID
left join dbo.HJGL_CH_RepairItemRecord rr on rr.JOT_ID=joint.JOT_ID
WHERE joint.PointType='点口' AND rr.NDT_ID='20d2cbca-8b3d-434b-b1c1-181796986fa5'
AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL and rr.RepairMark='R1'
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')>= @date1 OR @date1 IS NULL)
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')<= @date2 OR @date2 IS NULL)
GROUP BY joint.ProjectId,joint.InstallationId,iso.BSU_ID) AS JointNoPassNum1
ON JointNoPassNum1.ProjectId=total.ProjectId AND JointNoPassNum1.InstallationId = total.InstallationId
AND JointNoPassNum1.BSU_ID = total.BSU_ID
--
LEFT JOIN (SELECT count(rr.RepairItemRecordId) as JointNoPassFilmNum2,
joint.ProjectId,joint.InstallationId,iso.BSU_ID
FROM dbo.HJGL_CH_RepairItemRecord rr
left join HJGL_PW_JointInfo joint on rr.JOT_ID=joint.JOT_ID
LEFT JOIN HJGL_PW_IsoInfo iso ON iso.ISO_ID = joint.ISO_ID
WHERE joint.PointType='点口' and rr.NDT_ID='20d2cbca-8b3d-434b-b1c1-181796986fa5'
--AND (joint.RT1_RepairFilm IS NOT NULL or (select top 1 CH_TrustItemID from dbo.HJGL_CH_TrustItem ti where ti.JOT_ID=joint.JOT_ID and ti.States='4') is not null)
AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL and rr.RepairMark='R1'
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')>= @date1 OR @date1 IS NULL)
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R1')<= @date2 OR @date2 IS NULL)
GROUP BY joint.ProjectId,joint.InstallationId,iso.BSU_ID) AS JointNoPassNum2
ON JointNoPassNum2.ProjectId=total.ProjectId AND JointNoPassNum2.InstallationId = total.InstallationId
AND JointNoPassNum2.BSU_ID = total.BSU_ID
--,
LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS RepairJoint2, SUM(ISNULL(joint.RT2_RepairFilmNum,0)) AS RepairFilm2,
joint.ProjectId,joint.InstallationId,iso.BSU_ID
FROM HJGL_PW_JointInfo joint
LEFT JOIN HJGL_PW_IsoInfo iso ON iso.ISO_ID = joint.ISO_ID
WHERE joint.PointType='点口' AND joint.RT2_RepairFilm IS NOT NULL
AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R2')>= @date1 OR @date1 IS NULL)
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R2')<= @date2 OR @date2 IS NULL)
GROUP BY joint.ProjectId,joint.InstallationId,iso.BSU_ID) AS RepairJoint2
ON RepairJoint2.ProjectId=total.ProjectId AND RepairJoint2.InstallationId = total.InstallationId
AND RepairJoint2.BSU_ID = total.BSU_ID
--,
LEFT JOIN (SELECT COUNT(joint.JOT_ID) AS RepairJoint3, SUM(ISNULL(joint.RT3_RepairFilmNum,0)) AS RepairFilm3,
joint.ProjectId,joint.InstallationId,iso.BSU_ID
FROM HJGL_PW_JointInfo joint
LEFT JOIN HJGL_PW_IsoInfo iso ON iso.ISO_ID = joint.ISO_ID
WHERE joint.PointType='点口' AND joint.RT3_RepairFilm IS NOT NULL
AND (joint.ste_id=@steel OR @steel IS NULL) AND joint.dreportid IS NOT NULL
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R3')>= @date1 OR @date1 IS NULL)
AND ((SELECT TOP 1 SignDate FROM dbo.HJGL_CH_RepairItemRecord WHERE JOT_ID=joint.JOT_ID AND RepairMark='R3')<= @date2 OR @date2 IS NULL)
GROUP BY joint.ProjectId,joint.InstallationId,iso.BSU_ID) AS RepairJoint3
ON RepairJoint3.ProjectId=total.ProjectId AND RepairJoint3.InstallationId = total.InstallationId
AND RepairJoint3.BSU_ID = total.BSU_ID
LEFT JOIN Base_Project project ON total.ProjectId=project.ProjectId
WHERE
(CHARINDEX(total.ProjectId,@projectId)>0 OR @projectId IS NULL)
AND (total.InstallationId = @installationId OR @installationId IS NULL)
AND (total.BSU_ID=@unitcode OR @unitcode IS NULL)
--AND (total.Welder = @WED_ID OR @WED_ID IS NULL)
GO

View File

@ -60,20 +60,8 @@
{
if (tb != null)
{
double totalSize = 0.0f;
int totalJoint = 0;
int JointNum1 = 0;
int totalfilm = 0;
int JointPassNum1 = 0;
int totalPassfilm = 0;
int RepairJoint1 = 0;
int repairFilm1 = 0;
int RepairJoint2 = 0;
int repairFilm2 = 0;
int RepairJoint3 = 0;
int repairFilm3 = 0;
string filmPassRate = "";
string jointPassRate = "";
string JointPassRate = "";
string JointFilmPassRate = "";
//foreach (DataRow row in tb.Rows)
//{
@ -170,21 +158,46 @@
{
JObject summary = new JObject();
summary.Add("tfNumber", "合计");
summary.Add("totalJoint", tbSum.Rows[0]["totalJoint"].ToString());
summary.Add("totalSize", tbSum.Rows[0]["totalSize"].ToString());
summary.Add("JointNum1", tbSum.Rows[0]["JointNum1"].ToString());
summary.Add("totalfilm", tbSum.Rows[0]["totalfilm"].ToString());
summary.Add("JointPassNum1", tbSum.Rows[0]["JointPassNum1"].ToString());
summary.Add("totalPassfilm", tbSum.Rows[0]["totalPassfilm"].ToString());
decimal totalJoint = 0, totalSize = 0, JointNum1 = 0, totalfilm = 0, JointPassNum1 = 0, totalPassfilm = 0,
RepairJoint1 = 0, repairFilm1 = 0, RepairJoint2 = 0, repairFilm2 = 0, RepairJoint3 = 0, repairFilm3 = 0;
for (int i = 0; i < tbSum.Rows.Count; i++)
{
totalJoint += Funs.GetNewIntOrZero(tbSum.Rows[i]["totalJoint"].ToString());
totalSize += Funs.GetNewDecimalOrZero(tbSum.Rows[i]["totalSize"].ToString());
JointNum1 += Funs.GetNewIntOrZero(tbSum.Rows[i]["JointNum1"].ToString());
totalfilm += Funs.GetNewIntOrZero(tbSum.Rows[i]["totalfilm"].ToString());
JointPassNum1 += Funs.GetNewIntOrZero(tbSum.Rows[i]["JointPassNum1"].ToString());
totalPassfilm += Funs.GetNewIntOrZero(tbSum.Rows[i]["totalPassfilm"].ToString());
RepairJoint1 += Funs.GetNewIntOrZero(tbSum.Rows[i]["RepairJoint1"].ToString());
repairFilm1 += Funs.GetNewIntOrZero(tbSum.Rows[i]["repairFilm1"].ToString());
RepairJoint2 += Funs.GetNewIntOrZero(tbSum.Rows[i]["RepairJoint2"].ToString());
repairFilm2 += Funs.GetNewIntOrZero(tbSum.Rows[i]["repairFilm2"].ToString());
RepairJoint3 += Funs.GetNewIntOrZero(tbSum.Rows[i]["RepairJoint3"].ToString());
repairFilm3 += Funs.GetNewIntOrZero(tbSum.Rows[i]["repairFilm3"].ToString());
}
summary.Add("totalJoint", totalJoint.ToString("0.##"));
summary.Add("totalSize", totalSize.ToString("0.##"));
summary.Add("JointNum1", JointNum1.ToString("0.##"));
summary.Add("totalfilm", totalfilm.ToString("0.##"));
summary.Add("JointPassNum1", JointPassNum1.ToString("0.##"));
summary.Add("totalPassfilm", totalPassfilm.ToString("0.##"));
summary.Add("RepairJoint1", tbSum.Rows[0]["RepairJoint1"].ToString());
summary.Add("repairFilm1", tbSum.Rows[0]["repairFilm1"].ToString());
summary.Add("RepairJoint2", tbSum.Rows[0]["RepairJoint2"].ToString());
summary.Add("repairFilm2", tbSum.Rows[0]["repairFilm2"].ToString());
summary.Add("RepairJoint3", tbSum.Rows[0]["RepairJoint3"].ToString());
summary.Add("repairFilm3", tbSum.Rows[0]["repairFilm3"].ToString());
summary.Add("JointPassRate", (Funs.GetNewDecimalOrZero(tbSum.Rows[0]["JointPassRate"].ToString()) * 100).ToString("0.00") + "%");
summary.Add("JointFilmPassRate", (Funs.GetNewDecimalOrZero(tbSum.Rows[0]["JointFilmPassRate"].ToString()) * 100).ToString("0.00") + "%");
summary.Add("RepairJoint1", RepairJoint1.ToString("0.##"));
summary.Add("repairFilm1", repairFilm1.ToString("0.##"));
summary.Add("RepairJoint2", RepairJoint2.ToString("0.##"));
summary.Add("repairFilm2", repairFilm2.ToString("0.##"));
summary.Add("RepairJoint3", RepairJoint3.ToString("0.##"));
summary.Add("repairFilm3", repairFilm3.ToString("0.##"));
if (JointNum1 > 0)
{
JointPassRate= (decimal.Round(JointPassNum1 / JointNum1, 4) * 100).ToString("0.00") + "%";
}
if (totalfilm > 0)
{
JointFilmPassRate = (decimal.Round(totalPassfilm / totalfilm, 4) * 100).ToString("0.00") + "%";
}
summary.Add("JointPassRate", JointPassRate);
summary.Add("JointFilmPassRate", JointFilmPassRate);
Grid1.SummaryData = summary;
}
@ -547,7 +560,18 @@
Response.ContentType = "application/excel";
Response.ContentEncoding = System.Text.Encoding.UTF8;
Grid1.PageSize = 100000;
BindGrid();
if (hdType.Text == "1")
{
BindGrid();
}
else if (hdType.Text == "2")
{
BindGrid2();
}
else if (hdType.Text == "3")
{
BindGrid3();
}
Response.Write(GetGridTableHtml(Grid1));
Response.End();
}