20221008 001 焊接分析修改和焊接修复
This commit is contained in:
@@ -0,0 +1,166 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Security.Cryptography;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class HJGL_WeldingReportService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据类型获取总达因数(0总达因,1预制口总达因,2安装口总达因)
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="type">0总达因,1预制口总达因,2安装口总达因</param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetSumSize(string projectId,int type)
|
||||
{
|
||||
decimal result = 0;
|
||||
|
||||
var getWelds = Funs.DB.HJGL_WeldJoint.Where(x => x.ProjectId == projectId);
|
||||
if (getWelds.Count() > 0)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case 0:
|
||||
result = getWelds.Sum(x => x.Size ?? 0); //项目总达因数
|
||||
break;
|
||||
case 1:
|
||||
if (getWelds.Where(x => x.JointAttribute == "预制口").Count() > 0)
|
||||
{
|
||||
result = getWelds.Where(x => x.JointAttribute == "预制口").Sum(x => x.Size ?? 0);
|
||||
}
|
||||
break;
|
||||
case 2:
|
||||
if (getWelds.Where(x => x.JointAttribute == "安装口").Count() > 0)
|
||||
{
|
||||
result = getWelds.Where(x => x.JointAttribute == "安装口").Sum(x => x.Size ?? 0);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 工厂预制完成率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetGCRate_finished(string projectId)
|
||||
{
|
||||
decimal result = 0;
|
||||
var getWelds = Funs.DB.HJGL_WeldJoint.Where(x => x.ProjectId == projectId);
|
||||
if (getWelds.Count() > 0)
|
||||
{
|
||||
|
||||
var getWeldsOk = getWelds.Where(x => x.WeldingDailyId != null);
|
||||
if (getWeldsOk.Count() > 0)
|
||||
{
|
||||
var GCModel = getWeldsOk.Where(x => x.JointAttribute == "预制口");
|
||||
if (GCModel.Count() > 0)
|
||||
{
|
||||
result = GCModel.Sum(x => x.Size ?? 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 工厂预制未完成率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetGCRate_unfinished(string projectId)
|
||||
{
|
||||
decimal result = 0;
|
||||
result = GetSumSize(projectId, 1) - GetGCRate_finished(projectId);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 现场安装完成率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetXCRate_finished(string projectId)
|
||||
{
|
||||
decimal result = 0;
|
||||
var getWelds = Funs.DB.HJGL_WeldJoint.Where(x => x.ProjectId == projectId);
|
||||
if (getWelds.Count() > 0)
|
||||
{
|
||||
|
||||
var getWeldsOk = getWelds.Where(x => x.WeldingDailyId != null);
|
||||
if (getWeldsOk.Count() > 0)
|
||||
{
|
||||
var GCModel = getWeldsOk.Where(x => x.JointAttribute == "安装口");
|
||||
if (GCModel.Count() > 0)
|
||||
{
|
||||
result = GCModel.Sum(x => x.Size ?? 0);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 现场安装未完成率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetXCRate_unfinished(string projectId)
|
||||
{
|
||||
decimal result = 0;
|
||||
result = GetSumSize(projectId, 2) - GetXCRate_finished(projectId);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 管道完成预制率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetPipeRate_finished(string projectId)
|
||||
{
|
||||
decimal result = 0;
|
||||
result = GetGCRate_finished(projectId);
|
||||
return result;
|
||||
}
|
||||
/// <summary>
|
||||
/// 管道未完成预制率
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <returns></returns>
|
||||
public static decimal GetPipeRate_unfinished(string projectId)
|
||||
{
|
||||
decimal result = 0;
|
||||
result = GetSumSize(projectId, 0) - GetPipeRate_finished(projectId);
|
||||
return result;
|
||||
}
|
||||
public static decimal GetWelderEfficacy(string projectId)
|
||||
{
|
||||
decimal result = 0;
|
||||
var db = Funs.DB;
|
||||
var q = (from x in db.HJGL_WeldJoint
|
||||
join y in db.HJGL_WeldingDaily on x.WeldingDailyId equals y.WeldingDailyId
|
||||
where x.ProjectId ==projectId
|
||||
group x by x.ProjectId into g
|
||||
select new
|
||||
{
|
||||
TotalDin = g.Sum(x => x.Size),
|
||||
worktime = g.Select(x=>x.WeldingDailyId).Distinct().Count(),
|
||||
}) ;
|
||||
foreach (var item in q)
|
||||
{
|
||||
result = decimal.Divide((decimal)item.TotalDin, item.worktime) ;
|
||||
|
||||
}
|
||||
|
||||
return decimal.Truncate(result);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user