试压管理修改。增加试压看板,和试压包打印绑值
This commit is contained in:
@@ -42,6 +42,8 @@ namespace BLL
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
PackagingManageItem packagingManageItem = new PackagingManageItem();
|
||||
List<PackagingPrepipeItem> packagingPrepipeItem = new List<PackagingPrepipeItem>();
|
||||
|
||||
var q = (from x in db.HJGL_PackagingManage
|
||||
join n in db.Base_Project on x.ProjectId equals n.ProjectId
|
||||
join m in db.Person_Persons on x.ReceiveMan equals m.PersonId into tt
|
||||
@@ -62,20 +64,24 @@ namespace BLL
|
||||
TrainNumber = x.TrainNumber,
|
||||
}).FirstOrDefault();
|
||||
var tb_packing = (from x in db.HJGL_PackagingManage where x.PackagingManageId==packagingManageId select x ).FirstOrDefault() ;
|
||||
var PipelineComponentIdList = tb_packing.PipelineComponentId.Split(',');
|
||||
var packagingPrepipeItem = (from x in db.HJGL_Pipeline_Component
|
||||
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
|
||||
join z in db.WBS_UnitWork on y.UnitWorkId equals z.UnitWorkId
|
||||
where PipelineComponentIdList.Contains(x.PipelineComponentId)
|
||||
select new PackagingPrepipeItem
|
||||
{
|
||||
PipelineComponentId = x.PipelineComponentId,
|
||||
PipelineComponentCode = x.PipelineComponentCode,
|
||||
PreUnit = "1/个",
|
||||
UnitWorkName = z.UnitWorkName,
|
||||
PlanStartDate = string.Format("{0:g}", y.PlanStartDate),
|
||||
var PipelineComponentIdList = tb_packing?.PipelineComponentId?.Split(',');
|
||||
if (PipelineComponentIdList != null && PipelineComponentIdList.Count() > 0)
|
||||
{
|
||||
packagingPrepipeItem = (from x in db.HJGL_Pipeline_Component
|
||||
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
|
||||
join z in db.WBS_UnitWork on y.UnitWorkId equals z.UnitWorkId
|
||||
where PipelineComponentIdList.Contains(x.PipelineComponentId)
|
||||
select new PackagingPrepipeItem
|
||||
{
|
||||
PipelineComponentId = x.PipelineComponentId,
|
||||
PipelineComponentCode = x.PipelineComponentCode,
|
||||
PreUnit = "1/个",
|
||||
UnitWorkName = z.UnitWorkName,
|
||||
PlanStartDate = string.Format("{0:g}", y.PlanStartDate),
|
||||
|
||||
}).ToList();
|
||||
}).ToList();
|
||||
}
|
||||
|
||||
bool isPower = Person_PersonsService.IsGeneralUnitByPersonId(personId, projectId);
|
||||
if (!isPower)
|
||||
{
|
||||
|
||||
@@ -8,8 +8,17 @@ using System.Web.UI.WebControls;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class TestPackageEditService
|
||||
public partial class TestPackageEditService
|
||||
{
|
||||
public enum State : int
|
||||
{
|
||||
未确认 = 0,
|
||||
已确认 = 1,
|
||||
待整改 = 2,
|
||||
已整改 = 3,
|
||||
已完成 = 4,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据试压Id获取用于试压信息
|
||||
/// </summary>
|
||||
@@ -428,7 +437,11 @@ namespace BLL
|
||||
var q = Funs.DB.PTP_TestPackage.Where(e => e.UnitWorkId == unitworkId).ToList();
|
||||
return q;
|
||||
}
|
||||
|
||||
public static List<Model.PTP_TestPackage> GetTestPackageByProjectId(string projectid)
|
||||
{
|
||||
var q = Funs.DB.PTP_TestPackage.Where(e => e.ProjectId == projectid).ToList();
|
||||
return q;
|
||||
}
|
||||
|
||||
public static void DeletePipelineListByUnitWorkId(string unitworkId)
|
||||
{
|
||||
@@ -480,5 +493,196 @@ namespace BLL
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 计算试压包页面 ShowGridItem 需要的统计信息。
|
||||
/// - 根据项目系统设置(SetId = "5")判断是否按管线组批(包含 "6")
|
||||
/// - 若按管线组批:按 PTP_PipelineList 对应的每条管线计算统计(等价于页面分行判断),返回 Count1..Count4
|
||||
/// - 若不按管线组批:按页面原逻辑汇总整包的统计并返回(含 lab12.Label)
|
||||
/// 注意:方法只返回统计结果与标志,具体 UI 行样式仍由页面根据数据及返回结果决定。
|
||||
/// </summary>
|
||||
public static TestPackageAnalyzeOutput getTestPackageAnalyze(string PTP_ID, string projectId)
|
||||
{
|
||||
// 返回结果对象,包含统计信息
|
||||
var result = new TestPackageAnalyzeOutput();
|
||||
Model.SGGLDB db = Funs.DB;
|
||||
var testPackage = db.PTP_TestPackage.FirstOrDefault(p => p.PTP_ID == PTP_ID);
|
||||
if (testPackage == null) return null; // 无效试压包,直接返回空结果
|
||||
result.PTP_ID= PTP_ID;
|
||||
result.TestPackageNo = testPackage.TestPackageNo;
|
||||
result.UnitWorkName = BLL.UnitWorkService.GetUnitWorkALLName(testPackage.UnitWorkId);
|
||||
//判断当前试压包的状态
|
||||
result.StateStr = State.未确认.ToString();
|
||||
|
||||
if (testPackage.AduditDate.HasValue)
|
||||
{
|
||||
result.StateStr=State.已确认.ToString();
|
||||
}
|
||||
var PtpItemEndCheckList=(from x in db.PTP_ItemEndCheckList where x.PTP_ID==PTP_ID select x).FirstOrDefault();
|
||||
if (PtpItemEndCheckList != null )
|
||||
{
|
||||
if (PtpItemEndCheckList.State == Const.TestPackage_Complete)
|
||||
{
|
||||
result.StateStr = State.已整改.ToString();
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
result.StateStr = State.待整改.ToString();
|
||||
|
||||
}
|
||||
}
|
||||
if (testPackage.FinishDate.HasValue)
|
||||
{
|
||||
result.StateStr = State.已完成.ToString();
|
||||
|
||||
}
|
||||
// 当前试压包下所有管线ID集合
|
||||
var pipelineIds = (from p in db.PTP_PipelineList where p.PTP_ID == PTP_ID select p.PipelineId).ToList();
|
||||
result.TotalPipelines = pipelineIds.Count;
|
||||
if (result.TotalPipelines == 0)
|
||||
return result;
|
||||
|
||||
// 当前试压包下的焊口总数
|
||||
result.TotalWeldJoints = db.HJGL_WeldJoint.Count(w => pipelineIds.Contains(w.PipelineId));
|
||||
// 当前试压包下已焊接的焊口数
|
||||
result.CompletedWeldJoints = db.HJGL_WeldJoint.Count(w => pipelineIds.Contains(w.PipelineId) && w.WeldingDailyId != null);
|
||||
// 当前试压包下已检测的焊口数(去重)
|
||||
result.DetectedWeldJoints = (from x in db.HJGL_Batch_NDEItem
|
||||
join t in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals t.TrustBatchItemId
|
||||
join j in db.HJGL_WeldJoint on t.WeldJointId equals j.WeldJointId
|
||||
where pipelineIds.Contains(j.PipelineId)
|
||||
select t.WeldJointId).Distinct().Count();
|
||||
if (result.TotalWeldJoints > 0)
|
||||
{
|
||||
// 焊口完成百分比
|
||||
result.WeldCompletionPercent = Math.Round((decimal)result.CompletedWeldJoints / result.TotalWeldJoints * 100, 2);
|
||||
// 检测完成百分比
|
||||
result.DetectionCompletionPercent = Math.Round((decimal)result.DetectedWeldJoints / result.TotalWeldJoints * 100, 2);
|
||||
}
|
||||
|
||||
// 全通过管线计数
|
||||
int passCount = 0;
|
||||
// 系统设置,判断是否按管线组批
|
||||
var batch = BLL.Project_SysSetService.GetSysSetBySetId("5", projectId);
|
||||
if (batch != null && batch.SetValue != null && batch.SetValue.Contains("6"))
|
||||
{
|
||||
// 按管线组批,逐管线判断是否全通过
|
||||
var pipelineList = (from p in db.PTP_PipelineList
|
||||
join iso in db.HJGL_Pipeline on p.PipelineId equals iso.PipelineId
|
||||
where p.PTP_ID == PTP_ID
|
||||
select new { p.PipelineId, Iso = iso }).ToList();
|
||||
foreach (var item in pipelineList)
|
||||
{
|
||||
// 当前管线总焊口数
|
||||
int total = db.HJGL_WeldJoint.Count(w => w.PipelineId == item.PipelineId);
|
||||
// 当前管线已焊接焊口数
|
||||
int finished = db.HJGL_WeldJoint.Count(w => w.PipelineId == item.PipelineId && w.WeldingDailyId != null);
|
||||
// 当前管线应检测比例
|
||||
int? rateValue = null;
|
||||
if (!string.IsNullOrEmpty(item.Iso.DetectionRateId))
|
||||
{
|
||||
var rate = db.Base_DetectionRate.FirstOrDefault(r => r.DetectionRateId == item.Iso.DetectionRateId);
|
||||
if (rate != null) rateValue = rate.DetectionRateValue;
|
||||
}
|
||||
// 当前管线已检测焊口数
|
||||
int detected = (from x in db.HJGL_Batch_NDEItem
|
||||
join t in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals t.TrustBatchItemId
|
||||
join j in db.HJGL_WeldJoint on t.WeldJointId equals j.WeldJointId
|
||||
where j.PipelineId == item.PipelineId
|
||||
select t.WeldJointId).Distinct().Count();
|
||||
// 检测比例
|
||||
decimal ratio = (total > 0) ? (decimal)detected / total * 100 : 0M;
|
||||
// 检查返修焊口的最新检测是否全部合格
|
||||
bool allNDEItemOK = true;
|
||||
var lastRepair = (from x in db.HJGL_RepairRecord
|
||||
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
||||
where x.ProjectId == projectId && y.PipelineId == item.PipelineId
|
||||
orderby x.NoticeDate descending
|
||||
select x).FirstOrDefault();
|
||||
if (lastRepair != null)
|
||||
{
|
||||
// 返修批次
|
||||
var batchTrustItem = db.HJGL_Batch_BatchTrustItem.FirstOrDefault(b => b.RepairRecordId == lastRepair.RepairRecordId);
|
||||
if (batchTrustItem != null)
|
||||
{
|
||||
// 返修检测单
|
||||
var lastNDE = db.HJGL_Batch_NDE.FirstOrDefault(n => n.TrustBatchId == batchTrustItem.TrustBatchId);
|
||||
if (lastNDE != null)
|
||||
{
|
||||
// 检测单下所有检测项
|
||||
var lastNDEItems = db.HJGL_Batch_NDEItem.Where(ni => ni.NDEID == lastNDE.NDEID);
|
||||
if (lastNDEItems.Any())
|
||||
{
|
||||
foreach (var ni in lastNDEItems)
|
||||
{
|
||||
// 检查是否有未全部合格的项
|
||||
if (ni.TotalFilm != null && ni.PassFilm != null && ni.TotalFilm != ni.PassFilm)
|
||||
{
|
||||
allNDEItemOK = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else allNDEItemOK = false;
|
||||
}
|
||||
else allNDEItemOK = false;
|
||||
}
|
||||
else allNDEItemOK = false;
|
||||
}
|
||||
// 满足所有条件才算全通过
|
||||
if (!(total > finished) && !(rateValue.HasValue && rateValue.Value > ratio) && allNDEItemOK)
|
||||
passCount++;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// 整包判断
|
||||
var pipelineItem = db.PTP_PipelineList.FirstOrDefault(x => x.PTP_ID == PTP_ID);
|
||||
if (pipelineItem == null) return result;
|
||||
var pipeline = db.HJGL_Pipeline.FirstOrDefault(x => x.PipelineId == pipelineItem.PipelineId);
|
||||
if (pipeline == null) return result;
|
||||
// 整包所有焊口
|
||||
var totalJoint = from x in db.HJGL_WeldJoint
|
||||
join y in db.HJGL_Pipeline on x.PipelineId equals y.PipelineId
|
||||
join z in db.PTP_PipelineList on y.PipelineId equals z.PipelineId
|
||||
where z.PTP_ID == PTP_ID
|
||||
&& y.DetectionRateId == pipeline.DetectionRateId
|
||||
&& y.DetectionType.Contains(pipeline.DetectionType)
|
||||
select x;
|
||||
int totalJointNum = totalJoint.Count(); // 整包总焊口数
|
||||
int totalWeldingJointNum = totalJoint.Count(x => x.WeldingDailyId != null); // 整包已焊口数
|
||||
int notCloseBatch = (from x in db.HJGL_Batch_PointBatch
|
||||
join y in db.PTP_PipelineList on x.PipelineId equals y.PipelineId
|
||||
where y.PTP_ID == PTP_ID
|
||||
&& x.DetectionRateId == pipeline.DetectionRateId
|
||||
&& x.DetectionTypeId == pipeline.DetectionType && x.EndDate == null
|
||||
select x).Count(); // 未关闭批次数
|
||||
int allPointJointNum = (from x in db.HJGL_Batch_PointBatchItem
|
||||
join y in db.HJGL_Batch_PointBatch on x.PointBatchId equals y.PointBatchId
|
||||
join j in db.HJGL_WeldJoint on x.WeldJointId equals j.WeldJointId
|
||||
join p in db.PTP_PipelineList on j.PipelineId equals p.PipelineId
|
||||
where p.PTP_ID == PTP_ID
|
||||
&& y.DetectionRateId == pipeline.DetectionRateId
|
||||
&& y.DetectionTypeId == pipeline.DetectionType && x.PointState != null
|
||||
select x).Count(); // 所有检测点数
|
||||
int allOKCheckNum = (from x in db.HJGL_Batch_NDEItem
|
||||
join y in db.HJGL_Batch_NDE on x.NDEID equals y.NDEID
|
||||
join t in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals t.TrustBatchItemId
|
||||
join z in db.HJGL_Batch_BatchTrust on t.TrustBatchId equals z.TrustBatchId
|
||||
join j in db.HJGL_WeldJoint on t.WeldJointId equals j.WeldJointId
|
||||
join p in db.PTP_PipelineList on j.PipelineId equals p.PipelineId
|
||||
where p.PTP_ID == PTP_ID
|
||||
&& z.DetectionRateId == pipeline.DetectionRateId
|
||||
&& x.DetectionTypeId == pipeline.DetectionType && x.CheckResult == "1"
|
||||
select x).Count(); // 所有合格检测点数
|
||||
// 满足所有条件才算全通过
|
||||
if (!(totalJointNum > totalWeldingJointNum) && !(notCloseBatch > 0) && !(allPointJointNum > allOKCheckNum))
|
||||
passCount = result.TotalPipelines;
|
||||
}
|
||||
// 计算是否具备试压条件:全通过数量 == 管线数量且管线数>0
|
||||
result.CanPressureTest = (result.TotalPipelines > 0 && passCount == result.TotalPipelines);
|
||||
return result;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -670,7 +670,7 @@ namespace BLL
|
||||
}
|
||||
return name;
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 获取主项及设计专业名称
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user