提交代码
This commit is contained in:
@@ -12,6 +12,11 @@ using static FineUIPro.Web.TestRun.Report.ScheduleSetUp;
|
||||
using NPOI.SS.Formula.Functions;
|
||||
using Model;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using System.Reflection;
|
||||
using static FineUIPro.Web.TestRun.Report.PreRunSchedule;
|
||||
using Aspose.Words;
|
||||
using static FineUIPro.Web.TestRun.Report.TestRunSchedule;
|
||||
using System.Web.UI.DataVisualization.Charting;
|
||||
|
||||
namespace FineUIPro.Web
|
||||
{
|
||||
@@ -20,6 +25,8 @@ namespace FineUIPro.Web
|
||||
public string oneArrStr { get; set; }
|
||||
public string oneDataStr { get; set; }
|
||||
public string twoDataStr { get; set; }
|
||||
public string fourDecisionStr { get; set; }
|
||||
|
||||
protected void Page_Load(object sender, EventArgs e)
|
||||
{
|
||||
if (!IsPostBack)
|
||||
@@ -32,6 +39,7 @@ namespace FineUIPro.Web
|
||||
{
|
||||
OneYsc();
|
||||
TwoSc();
|
||||
FourDecision();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -63,27 +71,86 @@ namespace FineUIPro.Web
|
||||
}
|
||||
else
|
||||
{
|
||||
string strSql = @"select a.WorkPackId,a.WorkPackName,(select COUNT(1) from PreRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId) as AllNum,(select COUNT(1) from PreRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=0) as ProgressNum,(select COUNT(1) from PreRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=1) as CompleteNum from PreRun_WorkPackage as a order by a.Sort"; List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
if (tb.Rows.Count > 0)
|
||||
List<string> SubSystemIds = new List<string>();
|
||||
var devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 4).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
var allCompleteNum = float.Parse(tb.Compute("sum(CompleteNum)", "").ToString());
|
||||
var allSumNum = float.Parse(tb.Compute("sum(AllNum)", "").ToString());
|
||||
var allrate = (float)Math.Round(allCompleteNum / allSumNum * 100, 2, MidpointRounding.AwayFromZero);
|
||||
SubSystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
var result = new List<Run_ScheduleSetUpDto>();
|
||||
string allStr = $"select a.SubSystemId,a.SystemId,b.WorkPackId,b.WorkPackName,b.WorkPackType,(select count(1) from PreRun_SubPropertySelect as gd where gd.SubSystemId = a.SubSystemId) as GdallNum,(select count(1) from PreRun_SubTechnologySelect as sb where sb.SubSystemId = a.SubSystemId) as SballNum,(select count(1) from PreRun_SubInstrumentSelect as sy where sy.SubSystemId = a.SubSystemId) as SyallNum from PreRun_SubSysWorkPackage as a inner join PreRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where a.SubSystemId in ('{string.Join("','", SubSystemIds)}') order by a.WorkPackCode asc";
|
||||
var dt = SQLHelper.GetDataTableRunText(allStr);
|
||||
string inspectStr = $"select a.WorkPackId,b.WorkPackName,b.Sort,SUM(case ISNULL(a.InspectIsClose, 0) when 1 then 1 else 0 end) as CloseNum,SUM(case ISNULL(a.InspectIsClose, 0) when 0 then 1 else 0 end) as NoCloseNum,COUNT(1) as AllNum from PreRun_SubInspectTerm as a inner join PreRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where 1=1 and a.ProjectId = '{this.CurrUser.LoginProjectId}' and a.SubSystemId in ('{string.Join("','", SubSystemIds)}') group by a.WorkPackId,b.WorkPackName,b.Sort order by b.Sort asc";
|
||||
var inspectDt = SQLHelper.GetDataTableRunText(inspectStr);
|
||||
var inspectlist = DataTableToList<WorkPackageInspectDto>(inspectDt);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
//获取所有子系统数量
|
||||
var inspects = Funs.DB.PreRun_SubInspectTerm.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && SubSystemIds.Contains(x.SubSystemId));
|
||||
var querylist = DataTableToList<QuerySubSysWorkPackage>(dt);
|
||||
var queryGroup = querylist.GroupBy(x => new { x.WorkPackId, x.WorkPackName, x.WorkPackType }).Select(p => new
|
||||
{
|
||||
p.Key.WorkPackId,
|
||||
p.Key.WorkPackName,
|
||||
p.Key.WorkPackType
|
||||
});
|
||||
int progressNum = 0;
|
||||
int completeNum = 0;
|
||||
float allCompleteNum = 0;
|
||||
float allProgressNum = 0;
|
||||
int allNum = 0;
|
||||
int allSumNum = 0;
|
||||
List<float> oneDataArr = new List<float>();
|
||||
List<string> oneDataData = new List<string>();
|
||||
foreach (var itemPack in queryGroup)
|
||||
{
|
||||
var itemQueryList = querylist.Where(x => x.WorkPackId == itemPack.WorkPackId).ToList();
|
||||
var subsystemids = itemQueryList.ConvertAll(a => a.SubSystemId).Distinct();
|
||||
allNum = itemQueryList.Count(x => x.WorkPackId == itemPack.WorkPackId);
|
||||
foreach (var itemsubid in subsystemids)
|
||||
{
|
||||
if (inspects.Count(x => x.SubSystemId == itemsubid) > 0)
|
||||
{
|
||||
var itemQuerylist = itemQueryList.FirstOrDefault(x => x.SubSystemId == itemsubid && x.WorkPackId == itemPack.WorkPackId);
|
||||
if (inspects.Count(x => x.SubInspectId == itemsubid && x.InspectIsClose != 1) > 0)
|
||||
{
|
||||
progressNum += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
var closeInspect = inspects.Where(x => x.SubInspectId == itemsubid && x.InspectIsClose == 1);
|
||||
var closeNums = closeInspect.Count() > 0 ? closeInspect.Select(x => x.PropertyTechnologyId.Split(',').Count()).Sum(x => x) : 0;
|
||||
if (allNum > closeNums)
|
||||
{
|
||||
progressNum += 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
completeNum += 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
progressNum += 1;
|
||||
}
|
||||
}
|
||||
var rate = completeNum > 0 ? (float)Math.Round((float)completeNum / (float)allNum * 100, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
if (rate > 100) rate = 100;
|
||||
|
||||
allSumNum += allNum;
|
||||
allCompleteNum += completeNum;
|
||||
allProgressNum += progressNum;
|
||||
oneDataArr.Add(rate);
|
||||
oneDataData.Add(itemPack.WorkPackName);
|
||||
}
|
||||
|
||||
var allrate = allCompleteNum > 0 ? (float)Math.Round(allCompleteNum / allSumNum * 100, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
if (allrate > 100) allrate = 100;
|
||||
oneArr.Add(allrate);
|
||||
oneData.Add("全部");
|
||||
foreach (DataRow row in tb.Rows)
|
||||
{
|
||||
float allNum = float.Parse(row["AllNum"].ToString());
|
||||
float completeNum = float.Parse(row["CompleteNum"].ToString());
|
||||
var rate = completeNum > 0 ? (float)Math.Round((completeNum / allNum * 100), 2, MidpointRounding.AwayFromZero) : 0;
|
||||
if (rate > 100) rate = 100;
|
||||
oneArr.Add(rate);
|
||||
oneData.Add(row["WorkPackName"].ToString());
|
||||
}
|
||||
oneArr.AddRange(oneDataArr);
|
||||
oneData.AddRange(oneDataData);
|
||||
}
|
||||
}
|
||||
oneArrStr = JsonConvert.SerializeObject(oneArr);
|
||||
@@ -117,21 +184,37 @@ namespace FineUIPro.Web
|
||||
}
|
||||
else
|
||||
{
|
||||
string strSql = @"select a.WorkPackId,a.WorkPackName,(select COUNT(1) from TestRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId) as AllNum,(select COUNT(1) from TestRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=0) as ProgressNum,(select COUNT(1) from TestRun_SubInspectTerm as b where b.WorkPackId=a.WorkPackId and b.ProjectId=@ProjectId and ISNULL(b.InspectIsClose,0)=1) as CompleteNum from TestRun_WorkPackage as a order by a.Sort"; List<SqlParameter> listStr = new List<SqlParameter>();
|
||||
listStr.Add(new SqlParameter("@ProjectId", this.CurrUser.LoginProjectId));
|
||||
SqlParameter[] parameter = listStr.ToArray();
|
||||
DataTable tb = SQLHelper.GetDataTableRunText(strSql, parameter);
|
||||
if (tb.Rows.Count > 0)
|
||||
List<string> SystemIds = new List<string>();
|
||||
var devices = Funs.DB.PreRun_SysDevice.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PreRunLevel == 3).ToList();
|
||||
if (devices.Count > 0)
|
||||
{
|
||||
foreach (DataRow row in tb.Rows)
|
||||
SystemIds = devices.ConvertAll(x => x.PreRunId);
|
||||
}
|
||||
string allStr = $"select b.WorkPackId,b.WorkPackName,COUNT(a.SystemId) as WorkPackNum from TestRun_SubSysWorkPackage as a inner join TestRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where a.SystemId in ('{string.Join("','", SystemIds)}') group by b.WorkPackId,b.WorkPackName";
|
||||
var dt = SQLHelper.GetDataTableRunText(allStr);
|
||||
var data = new List<TwoDto>();
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
string inspectStr = $"select a.WorkPackId,b.WorkPackName,b.Sort,SUM(case ISNULL(a.InspectIsClose, 0) when 1 then 1 else 0 end) as CloseNum,SUM(case ISNULL(a.InspectIsClose, 0) when 0 then 1 else 0 end) as NoCloseNum,COUNT(1) as AllNum from TestRun_SubInspectTerm as a inner join TestRun_WorkPackage as b on a.WorkPackId = b.WorkPackId where 1=1 and a.ProjectId = '{this.CurrUser.LoginProjectId}' group by a.WorkPackId,b.WorkPackName,b.Sort order by b.Sort asc";
|
||||
var inspectDt = SQLHelper.GetDataTableRunText(inspectStr);
|
||||
var inspectlist = DataTableToList<WorkPackageInspectDto>(inspectDt);
|
||||
int progressNum = 0;
|
||||
int completeNum = 0;
|
||||
int allNum = 0;
|
||||
var testlist = DataTableToList<TestRunScheduleDto>(dt);
|
||||
foreach (var item in testlist)
|
||||
{
|
||||
float allNum = float.Parse(row["AllNum"].ToString());
|
||||
float completeNum = float.Parse(row["CompleteNum"].ToString());
|
||||
var rate = completeNum > 0 ? (float)Math.Round((completeNum / allNum) * 100, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
if (rate > 100) rate = 100;
|
||||
if (inspectlist.Count(x => x.WorkPackId == item.WorkPackId) > 0)
|
||||
{
|
||||
var itemInspect = inspectlist.FirstOrDefault(x => x.WorkPackId == item.WorkPackId);
|
||||
allNum = itemInspect.AllNum;
|
||||
progressNum = itemInspect.NoCloseNum;
|
||||
completeNum = itemInspect.CloseNum;
|
||||
}
|
||||
var rate = completeNum > 0 ? (float)Math.Round((float)completeNum / (float)allNum, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
result.Add(new TwoDto()
|
||||
{
|
||||
Name = row["WorkPackName"].ToString(),
|
||||
Name = item.WorkPackName,
|
||||
Rate = rate
|
||||
});
|
||||
}
|
||||
@@ -140,11 +223,204 @@ namespace FineUIPro.Web
|
||||
twoDataStr = JsonConvert.SerializeObject(result);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 三查四定
|
||||
/// </summary>
|
||||
public void FourDecision()
|
||||
{
|
||||
var result = new List<ThreeDto>();
|
||||
var list = Funs.DB.Run_ScheduleSetUp.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.States == 3).OrderBy(o => o.LevelName).ToList();
|
||||
if (list.Count > 0)
|
||||
{
|
||||
foreach (var item in list)
|
||||
{
|
||||
var rate = item.CompleteNum > 0 ? (float)Math.Round((float)item.CompleteNum / (float)item.AllNum * 100, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
if (rate > 100) rate = 100;
|
||||
result.Add(new ThreeDto()
|
||||
{
|
||||
Name = item.LevelName,
|
||||
Rate = rate
|
||||
});
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
var fourlist = new List<FourDecisionScheduleBridDto>();
|
||||
string allStr = $"select Level,COUNT(1) as AllNum,SUM(case ISNULL(a.DecisionIsClose,0) when 0 then 1 else 0 end) as NoCloseNum,SUM(case ISNULL(a.DecisionIsClose,0) when 1 then 1 else 0 end) as CloseNum from PreRun_SubThreeChecksFourDecision as a where a.ProjectId='{this.CurrUser.LoginProjectId}' group by a.Level order by a.Level asc";
|
||||
var dt = SQLHelper.GetDataTableRunText(allStr);
|
||||
if (dt.Rows.Count > 0)
|
||||
{
|
||||
fourlist = DataTableToList<FourDecisionScheduleBridDto>(dt);
|
||||
foreach (var item in fourlist)
|
||||
{
|
||||
float rate = item.CloseNum > 0 ? (float)Math.Round((float)item.CloseNum / (float)item.AllNum * 100, 2, MidpointRounding.AwayFromZero) : 0;
|
||||
result.Add(new ThreeDto()
|
||||
{
|
||||
Name = item.Level,
|
||||
Rate = rate
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
fourDecisionStr = JsonConvert.SerializeObject(result);
|
||||
}
|
||||
|
||||
#region 实体类
|
||||
|
||||
/// <summary>
|
||||
/// 图2
|
||||
/// </summary>
|
||||
public class TwoDto
|
||||
{
|
||||
public float Rate { get; set; }
|
||||
public string Name { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 图3
|
||||
/// </summary>
|
||||
public class ThreeDto
|
||||
{
|
||||
public string Name { get; set; }
|
||||
public float Rate { get; set; }
|
||||
}
|
||||
|
||||
public class WorkPackageInspectDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作包主键
|
||||
/// </summary>
|
||||
public string WorkPackId { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表数量
|
||||
/// </summary>
|
||||
public int AllNum { get; set; }
|
||||
/// <summary>
|
||||
/// 未关闭任务单数量
|
||||
/// </summary>
|
||||
public int NoCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 已关闭任务单数量
|
||||
/// </summary>
|
||||
public int CloseNum { get; set; }
|
||||
}
|
||||
|
||||
public class Run_ScheduleSetUpDto : Run_ScheduleSetUp
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
}
|
||||
|
||||
public class TestRunScheduleDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 工作包主键
|
||||
/// </summary>
|
||||
public string WorkPackId { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包名称
|
||||
/// </summary>
|
||||
public string WorkPackName { get; set; }
|
||||
/// <summary>
|
||||
/// 装置名称
|
||||
/// </summary>
|
||||
public string InstallationName { get; set; }
|
||||
/// <summary>
|
||||
/// 工序名称
|
||||
/// </summary>
|
||||
public string ProcessesName { get; set; }
|
||||
/// <summary>
|
||||
/// 系统名称
|
||||
/// </summary>
|
||||
public string SystemName { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包数量
|
||||
/// </summary>
|
||||
public int WorkPackNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包未关闭数量
|
||||
/// </summary>
|
||||
public int WorkPackNoCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 工作包已关闭数量
|
||||
/// </summary>
|
||||
public int WorkPackCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表数量
|
||||
/// </summary>
|
||||
public int InspectNum { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表未关闭数量
|
||||
/// </summary>
|
||||
public int InspectNoCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 检查表已关闭数量
|
||||
/// </summary>
|
||||
public int InspectCloseNum { get; set; }
|
||||
}
|
||||
|
||||
public class FourDecisionScheduleBridDto
|
||||
{
|
||||
/// <summary>
|
||||
/// 级别
|
||||
/// </summary>
|
||||
public string Level { get; set; }
|
||||
/// <summary>
|
||||
/// 尾项数量
|
||||
/// </summary>
|
||||
public int AllNum { get; set; }
|
||||
/// <summary>
|
||||
/// 未关闭尾项数量
|
||||
/// </summary>
|
||||
public int NoCloseNum { get; set; }
|
||||
/// <summary>
|
||||
/// 已关闭尾项数量
|
||||
/// </summary>
|
||||
public int CloseNum { get; set; }
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region 转换
|
||||
|
||||
/// <summary>
|
||||
/// DataTable转换List
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public List<T> DataTableToList<T>(DataTable table)
|
||||
{
|
||||
List<T> list = new List<T>();
|
||||
T t = default(T);
|
||||
PropertyInfo[] propertypes = null;
|
||||
string tempName = string.Empty;
|
||||
foreach (DataRow row in table.Rows)
|
||||
{
|
||||
t = Activator.CreateInstance<T>();
|
||||
propertypes = t.GetType().GetProperties();
|
||||
foreach (PropertyInfo pro in propertypes)
|
||||
{
|
||||
tempName = pro.Name;
|
||||
if (table.Columns.Contains(tempName))
|
||||
{
|
||||
object value = row[tempName];
|
||||
if (!value.ToString().Equals(""))
|
||||
{
|
||||
pro.SetValue(t, value, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
list.Add(t);
|
||||
}
|
||||
return list.Count == 0 ? new List<T>() : list;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user