280 lines
10 KiB
C#
280 lines
10 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Data.SqlClient;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using System.Web.Http;
|
|
using BLL;
|
|
|
|
|
|
namespace WebAPI.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 报表查询统计
|
|
/// </summary>
|
|
public class ReportQueryController: ApiController
|
|
{
|
|
#region 根据人员二维码获取焊工业绩
|
|
/// <summary>
|
|
/// 根据人员二维码获取焊工业绩
|
|
/// </summary>
|
|
/// <param name="personId"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData GetWelderPerformanceByQRC(string personId)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
responeData.data = APIReportQueryService.GetWelderPerformanceByQRC(personId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
#endregion
|
|
|
|
#region 根据焊工号获取焊工业绩
|
|
/// <summary>
|
|
/// 根据焊工号获取焊工业绩
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="welderCode"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData GetWelderPerformanceByWelderCode(string projectId, string welderCode)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
responeData.data = APIReportQueryService.GetWelderPerformanceByWelderCode(projectId, welderCode);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
#endregion
|
|
|
|
#region 根据人员ID获取焊工合格项目
|
|
/// <summary>
|
|
/// 根据人员ID获取焊工合格项目
|
|
/// </summary>
|
|
/// <param name="personId"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData GetWelderQualify(string personId)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
responeData.data = APIReportQueryService.getWelderQualify(personId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
#endregion
|
|
|
|
#region 焊工资质预警
|
|
/// <summary>
|
|
/// 焊工资质预警
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData GetWelderQualifyWarning(string projectId)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
responeData.data = APIReportQueryService.GetWelderQualifyWarning(projectId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 焊工一次合格率低于96%预警
|
|
/// <summary>
|
|
/// 焊工一次合格率低于96%预警
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData GetWelderOnePassRateWarning(string projectId)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
responeData.data = APIReportQueryService.GetWelderOnePassRateWarning(projectId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region 根据焊口ID获取焊口信息和焊接信息
|
|
/// <summary>
|
|
/// 根据焊口ID获取焊口信息和焊接信息
|
|
/// </summary>
|
|
/// <param name="weldJointId"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData GetJointCompreInfo(string weldJointId)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
responeData.data = APIReportQueryService.GetJointCompreInfo(weldJointId);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
#endregion
|
|
|
|
|
|
#region 多维度查询报表
|
|
/// <summary>
|
|
/// 多维度查询报表
|
|
/// </summary>
|
|
/// <param name="projectId"></param>
|
|
/// <param name="unitId"></param>
|
|
/// <param name="unitWorkId"></param>
|
|
/// <param name="pipeLineId"></param>
|
|
/// <param name="material"></param>
|
|
/// <param name="startTime"></param>
|
|
/// <param name="endTime"></param>
|
|
/// <returns></returns>
|
|
public Model.ResponeData GetReportQueryByRequir(string projectId, string unitId, string unitWorkId, string pipeLineId, string material, string startTime, string endTime)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
responeData.data = APIReportQueryService.GetReportQueryByRequir(projectId, unitId, unitWorkId, pipeLineId, material, startTime, endTime);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
#endregion
|
|
|
|
public Model.ResponeData GetReportQueryByProjectId(string projectId, string unitId)
|
|
{
|
|
var responeData = new Model.ResponeData();
|
|
try
|
|
{
|
|
List<Dictionary<string, string>> res = new List<Dictionary<string, string>>();
|
|
Dictionary<string, Dictionary<string, string>> tempDic = new Dictionary<string, Dictionary<string, string>>();
|
|
|
|
string 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 = @projectId";
|
|
if (!string.IsNullOrEmpty(unitId) || unitId != CommonService.GetThisUnitId())
|
|
{
|
|
sql31 += " AND pw_isoinfo.UnitId = @unitId";
|
|
}
|
|
sql31 += " GROUP BY WorkArea.WorkAreaId, WorkArea.WorkAreaName";
|
|
|
|
SqlCommand command = new SqlCommand(sql31);
|
|
command.Parameters.AddWithValue("@projectId", projectId);
|
|
if (!string.IsNullOrEmpty(unitId))
|
|
{
|
|
command.Parameters.AddWithValue("@unitId", unitId);
|
|
}
|
|
|
|
DataTable tb31 = SQLHelper.GetDataTableRunCommand(command);
|
|
if (tb31 != null)
|
|
{
|
|
foreach (DataRow row in tb31.Rows)
|
|
{
|
|
Dictionary<string, string> dic = new Dictionary<string, string>();
|
|
dic.Add("WorkAreaName", row["WorkAreaName"].ToString());
|
|
dic.Add("finishRate", (100.0 * Funs.GetNewDoubleOrZero(row["finished_total_jot"].ToString()) / Funs.GetNewDoubleOrZero(row["total_jot"].ToString())).ToString("#0.00"));
|
|
tempDic.Add(row["WorkAreaName"].ToString(), dic);
|
|
res.Add(dic);
|
|
}
|
|
}
|
|
|
|
string sql41 = @"SELECT WorkArea.WorkAreaId, WorkArea.WorkAreaName, SUM(cht_totalfilm) total_film, SUM(cht_passfilm) 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 = @projectId";
|
|
if (!string.IsNullOrEmpty(unitId) || unitId != CommonService.GetThisUnitId())
|
|
{
|
|
sql41 += " AND IsoInfo.UnitId = @unitId";
|
|
}
|
|
sql41 += " GROUP BY WorkArea.WorkAreaId, WorkArea.WorkAreaName";
|
|
|
|
SqlCommand command2 = new SqlCommand(sql41);
|
|
command2.Parameters.AddWithValue("@projectId", projectId);
|
|
if (!string.IsNullOrEmpty(unitId))
|
|
{
|
|
command2.Parameters.AddWithValue("@unitId", unitId);
|
|
}
|
|
|
|
DataTable tb41 = SQLHelper.GetDataTableRunCommand(command2);
|
|
if (tb41 != null)
|
|
{
|
|
foreach (DataRow row in tb41.Rows)
|
|
{
|
|
Dictionary<string, string> dic;
|
|
if (tempDic.TryGetValue(row["WorkAreaName"].ToString(), out dic))
|
|
{
|
|
dic.Add("passRate", (100.0 * Funs.GetNewDoubleOrZero(row["pass_film"].ToString()) / Funs.GetNewDoubleOrZero(row["total_film"].ToString())).ToString("#0.00"));
|
|
}
|
|
else
|
|
{
|
|
dic = new Dictionary<string, string>();
|
|
dic.Add("WorkAreaName", row["WorkAreaName"].ToString());
|
|
dic.Add("finishRate", "0");
|
|
dic.Add("passRate", (100.0 * Funs.GetNewDoubleOrZero(row["pass_film"].ToString()) / Funs.GetNewDoubleOrZero(row["total_film"].ToString())).ToString("#0.00"));
|
|
res.Add(dic);
|
|
}
|
|
}
|
|
}
|
|
|
|
responeData.data = res;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
responeData.code = 0;
|
|
responeData.message = ex.Message;
|
|
}
|
|
|
|
return responeData;
|
|
}
|
|
}
|
|
} |