1代码合并
This commit is contained in:
@@ -1,7 +1,5 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data;
|
||||
using System.Data.SqlClient;
|
||||
using System.Linq;
|
||||
using System.Net;
|
||||
using System.Net.Http;
|
||||
@@ -186,95 +184,5 @@ namespace WebAPI.Controllers
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user