提交代码

This commit is contained in:
高飞 2025-05-12 15:06:16 +08:00
parent 171050aa44
commit 2cda26443d
4 changed files with 345 additions and 36 deletions

View File

@ -0,0 +1,140 @@
CREATE 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 joint.RT_FilmNum IS NOT NULL and joint.RT_FilmNum>0 and (select COUNT(*) from dbo.HJGL_BO_QualityRating where JOT_ID=joint.JOT_ID and FilmNum is not null)>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 (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 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 (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

@ -45,6 +45,7 @@
</f:Label>
<f:ToolbarFill ID="ToolbarFill1" runat="server">
</f:ToolbarFill>
<f:Button ID="BtnAnalyse2" Text="按焊工统计" Icon="ChartPie" runat="server" Hidden="true" OnClick="BtnAnalyse2_Click"></f:Button>
<f:Button ID="BtnAnalyse" Text="统计" Icon="ChartPie" runat="server" OnClick="BtnAnalyse_Click"></f:Button>
<f:Button ID="btnOut" OnClick="btnOut_Click" runat="server" Text="导出" Icon="TableGo"
EnableAjax="false" DisableControlBeforePostBack="false">

View File

@ -7,6 +7,7 @@
using System.Text;
using BLL;
using Newtonsoft.Json.Linq;
using System.Linq;
using AspNet = System.Web.UI.WebControls;
public partial class WelderPerformance : PageBase
@ -74,51 +75,120 @@
string filmPassRate = "";
string jointPassRate = "";
foreach (DataRow row in tb.Rows)
{
totalSize += Convert.ToDouble(row["totalSize"]);
totalJoint += Convert.ToInt32(row["totalJoint"]);
JointNum1 += Convert.ToInt32(row["JointNum1"]);
totalfilm += Convert.ToInt32(row["totalfilm"]);
JointPassNum1 += Convert.ToInt32(row["JointPassNum1"]);
totalPassfilm += Convert.ToInt32(row["totalPassfilm"]);
//foreach (DataRow row in tb.Rows)
//{
// totalSize += Convert.ToDouble(row["totalSize"]);
// totalJoint += Convert.ToInt32(row["totalJoint"]);
// JointNum1 += Convert.ToInt32(row["JointNum1"]);
// totalfilm += Convert.ToInt32(row["totalfilm"]);
// JointPassNum1 += Convert.ToInt32(row["JointPassNum1"]);
// totalPassfilm += Convert.ToInt32(row["totalPassfilm"]);
RepairJoint1 += Convert.ToInt32(row["RepairJoint1"]);
repairFilm1 += Convert.ToInt32(row["repairFilm1"]);
RepairJoint2 += Convert.ToInt32(row["RepairJoint2"]);
repairFilm2 += Convert.ToInt32(row["repairFilm2"]);
RepairJoint3 += Convert.ToInt32(row["RepairJoint3"]);
repairFilm3 += Convert.ToInt32(row["repairFilm3"]);
}
if (totalfilm != 0)
// RepairJoint1 += Convert.ToInt32(row["RepairJoint1"]);
// repairFilm1 += Convert.ToInt32(row["repairFilm1"]);
// RepairJoint2 += Convert.ToInt32(row["RepairJoint2"]);
// repairFilm2 += Convert.ToInt32(row["repairFilm2"]);
// RepairJoint3 += Convert.ToInt32(row["RepairJoint3"]);
// repairFilm3 += Convert.ToInt32(row["repairFilm3"]);
//}
//if (totalfilm != 0)
//{
// filmPassRate = (totalPassfilm * 100.0 / totalfilm * 1.0).ToString("0.00") + "%";
//}
//if (JointNum1 != 0)
//{
// jointPassRate = (JointPassNum1 * 100.0 / JointNum1 * 1.0).ToString("0.00") + "%";
//}
string projectIds = String.Join(",", drpProject.SelectedValueArray);
List<SqlParameter> listStr = new List<SqlParameter>();
if (this.drpIns.SelectedValue != BLL.Const._Null)
{
filmPassRate = (totalPassfilm * 100.0 / totalfilm * 1.0).ToString("0.00") + "%";
listStr.Add(new SqlParameter("@installationId", this.drpIns.SelectedValue));
}
if (JointNum1 != 0)
else
{
jointPassRate = (JointPassNum1 * 100.0 / JointNum1 * 1.0).ToString("0.00") + "%";
listStr.Add(new SqlParameter("@installationId", null));
}
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@unitcode", this.drpUnit.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@unitcode", null));
}
if (this.drpSteel.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@steel", this.drpSteel.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@steel", null));
}
if (this.drpWloName.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@WED_ID", this.drpWloName.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@WED_ID", null));
}
if (!string.IsNullOrEmpty(this.txtStarTime.Text))
{
listStr.Add(new SqlParameter("@date1", Convert.ToDateTime(this.txtStarTime.Text)));
}
else
{
listStr.Add(new SqlParameter("@date1", null));
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
listStr.Add(new SqlParameter("@date2", Convert.ToDateTime(this.txtEndTime.Text).AddDays(1)));
}
else
{
listStr.Add(new SqlParameter("@date2", null));
}
if (this.drpProject.SelectedValueArray.Length > 0 && this.drpProject.SelectedValueArray[0] != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@projectId", projectIds));
}
else
{
listStr.Add(new SqlParameter("@projectId", null));
}
SqlParameter[] parameter = listStr.ToArray();
DataTable tbSum = SQLHelper.GetDataTableRunProc("HJGL_sp_rpt_welderPerformanceSum", parameter);
if (tbSum.Rows.Count > 0)
{
JObject summary = new JObject();
summary.Add("tfNumber", "合计");
summary.Add("totalJoint", totalJoint.ToString());
summary.Add("totalSize", totalSize.ToString("F2"));
summary.Add("JointNum1", JointNum1.ToString());
summary.Add("totalfilm", totalfilm.ToString());
summary.Add("JointPassNum1", JointPassNum1.ToString());
summary.Add("totalPassfilm", totalPassfilm.ToString());
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());
summary.Add("RepairJoint1", RepairJoint1.ToString());
summary.Add("repairFilm1", repairFilm1.ToString());
summary.Add("RepairJoint2", RepairJoint2.ToString());
summary.Add("repairFilm2", repairFilm2.ToString());
summary.Add("RepairJoint3", RepairJoint3.ToString());
summary.Add("repairFilm3", repairFilm3.ToString());
summary.Add("JointPassRate", jointPassRate.ToString());
summary.Add("JointFilmPassRate", filmPassRate.ToString());
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") + "%");
Grid1.SummaryData = summary;
}
}
}
@ -207,6 +277,84 @@
Grid1.DataBind();
}
/// <summary>
/// 绑定数据
/// </summary>
private void BindGrid2()
{
string projectIds = String.Join(",", drpProject.SelectedValueArray);
List<SqlParameter> listStr = new List<SqlParameter>();
if (this.drpIns.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@installationId", this.drpIns.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@installationId", null));
}
if (this.drpUnit.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@unitcode", this.drpUnit.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@unitcode", null));
}
if (this.drpSteel.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@steel", this.drpSteel.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@steel", null));
}
if (this.drpWloName.SelectedValue != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@WED_ID", this.drpWloName.SelectedValue));
}
else
{
listStr.Add(new SqlParameter("@WED_ID", null));
}
if (!string.IsNullOrEmpty(this.txtStarTime.Text))
{
listStr.Add(new SqlParameter("@date1", Convert.ToDateTime(this.txtStarTime.Text)));
}
else
{
listStr.Add(new SqlParameter("@date1", null));
}
if (!string.IsNullOrEmpty(this.txtEndTime.Text))
{
listStr.Add(new SqlParameter("@date2", Convert.ToDateTime(this.txtEndTime.Text).AddDays(1)));
}
else
{
listStr.Add(new SqlParameter("@date2", null));
}
if (this.drpProject.SelectedValueArray.Length > 0 && this.drpProject.SelectedValueArray[0] != BLL.Const._Null)
{
listStr.Add(new SqlParameter("@projectId", projectIds));
}
else
{
listStr.Add(new SqlParameter("@projectId", null));
}
SqlParameter[] parameter = listStr.ToArray();
tb = SQLHelper.GetDataTableRunProc("HJGL_sp_rpt_welderPerformance2", parameter);
this.Grid1.RecordCount = tb.Rows.Count;
tb = GetFilteredTable(Grid1.FilteredData, tb);
var table = this.GetPagedDataTable(Grid1, tb);
Grid1.DataSource = table;
Grid1.DataBind();
}
#endregion
#region
@ -253,6 +401,17 @@
BindGrid();
OutputSummaryData();
}
/// <summary>
/// 统计
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void BtnAnalyse2_Click(object sender, EventArgs e)
{
BindGrid2();
OutputSummaryData();
}
#endregion
#region

View File

@ -147,6 +147,15 @@ namespace FineUIPro.Web.HJGL.WeldingReport {
/// </remarks>
protected global::FineUIPro.ToolbarFill ToolbarFill1;
/// <summary>
/// BtnAnalyse2 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button BtnAnalyse2;
/// <summary>
/// BtnAnalyse 控件。
/// </summary>