2023-07-11 16:32:16 +08:00
|
|
|
|
using Microsoft.SqlServer.Dts.Runtime;
|
|
|
|
|
using Model;
|
|
|
|
|
using NPOI.SS.Formula.Functions;
|
|
|
|
|
using System;
|
2022-03-15 17:36:38 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using System.Security.Cryptography;
|
2022-03-15 17:36:38 +08:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace BLL
|
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
public static class APINDETrustService
|
|
|
|
|
{
|
|
|
|
|
#region 选择单位工程、探伤类型、探伤比例、点口批号获取需要进行点口的批
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择单位工程、探伤类型、探伤比例、点口批号获取还未点口的批
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitWorkId"></param>
|
|
|
|
|
/// <param name="detectionTypeId"></param>
|
|
|
|
|
/// <param name="detectionRateId"></param>
|
|
|
|
|
/// <param name="pointBatchCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> getAutoPointBatchCode(string unitWorkId, string detectionTypeId, string detectionRateId, string pointBatchCode)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var dataList = from x in db.HJGL_Batch_PointBatch
|
|
|
|
|
where x.UnitWorkId == unitWorkId && x.EndDate == null
|
|
|
|
|
select x;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(detectionTypeId))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.DetectionTypeId == detectionTypeId);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(detectionRateId))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.DetectionRateId == detectionRateId);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(pointBatchCode))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.PointBatchCode.Contains(pointBatchCode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var getDataLists = (from x in dataList
|
|
|
|
|
orderby x.PointBatchCode
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
PointBatchId = x.PointBatchId,
|
|
|
|
|
PointBatchCode = x.PointBatchCode,
|
|
|
|
|
}).ToList();
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据单位工程、点口批号、批开始时间获取需要调整的批(已点口但还未进行委托的批列表)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据单位工程、点口批号、批开始时间获取需要调整的批(已点口但还未进行委托的批列表)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitWorkId"></param>
|
|
|
|
|
/// <param name="pointBatchCode"></param>
|
|
|
|
|
/// <param name="startDate"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> getPointBatchCode(string unitWorkId, string detectionTypeId, string detectionRateId, string pointBatchCode)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var dataList = from x in db.HJGL_Batch_PointBatch
|
|
|
|
|
join y in db.HJGL_Batch_PointBatchItem on x.PointBatchId equals y.PointBatchId
|
|
|
|
|
where x.UnitWorkId == unitWorkId && y.IsBuildTrust == null && x.EndDate.HasValue
|
|
|
|
|
select x;
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(detectionTypeId))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.DetectionTypeId == detectionTypeId);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(detectionRateId))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.DetectionRateId == detectionRateId);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(pointBatchCode))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.PointBatchCode.Contains(pointBatchCode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var getDataLists = (from x in dataList
|
|
|
|
|
orderby x.PointBatchCode
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
PointBatchId = x.PointBatchId,
|
|
|
|
|
PointBatchCode = x.PointBatchCode,
|
|
|
|
|
}).Distinct().ToList();
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据点口批ID获取批明细(自动点口呈现)
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据点口批ID获取批明细(自动点口呈现)
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pointBatchCode"></param>
|
|
|
|
|
/// <param name="startDate"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> getPointBatchDetail(string pointBatchId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getDataLists = (from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
where x.PointBatchId == pointBatchId
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
WeldJointId = x.WeldJointId,
|
|
|
|
|
WeldJointCode = y.WeldJointCode,
|
|
|
|
|
PipelineCode = y.PipelineCode,
|
|
|
|
|
JointArea = y.JointArea,
|
|
|
|
|
AttachUrl = y.AttachUrl
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据点口批ID获取已点口还未审批的焊口
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据点口批ID获取已点口还未审批的焊口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pointBatchCode"></param>
|
|
|
|
|
/// <param name="startDate"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> getPointWeldJoint(string pointBatchId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getDataLists = (from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
where x.IsBuildTrust == null && x.PointBatchId == pointBatchId && x.PointState == "1"
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
WeldJointId = x.WeldJointId,
|
|
|
|
|
WeldJointCode = y.WeldJointCode,
|
|
|
|
|
PipelineCode = y.PipelineCode,
|
|
|
|
|
JointArea = y.JointArea,
|
|
|
|
|
AttachUrl = y.AttachUrl
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据点口批ID和焊口ID获取待调整焊口
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据点口批ID和焊口ID获取待调整焊口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pointBatchCode"></param>
|
|
|
|
|
/// <param name="startDate"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> getPointWeldJoint(string pointBatchId, string weldJointId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var jot = db.HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == weldJointId);
|
|
|
|
|
|
|
|
|
|
var getDataLists = (from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
where x.PointBatchId == pointBatchId && x.PointState == null
|
|
|
|
|
&& y.JointAttribute == jot.JointAttribute
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
WeldJointId = x.WeldJointId,
|
|
|
|
|
WeldJointCode = y.WeldJointCode,
|
|
|
|
|
PipelineCode = y.PipelineCode,
|
|
|
|
|
JointArea = y.JointArea,
|
|
|
|
|
AttachUrl = y.AttachUrl
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 对所选批次进行自动点口
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 对所选批次进行自动点口
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pointBatchId"></param>
|
|
|
|
|
public static void AutoPointSave(string pointBatchId)
|
|
|
|
|
{
|
|
|
|
|
AutoPoint(pointBatchId);
|
|
|
|
|
}
|
|
|
|
|
public static void AutoPoint(string pointBatchId)
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
int pointNum = 0;
|
|
|
|
|
int pointNumG = 0;
|
|
|
|
|
int pointNumA = 0;
|
|
|
|
|
|
|
|
|
|
var batch = db.HJGL_Batch_PointBatch.FirstOrDefault(e => e.PointBatchId == pointBatchId);
|
|
|
|
|
var batchItemNum = db.HJGL_Batch_PointBatchItem.Where(e => e.PointBatchId == pointBatchId).ToList();
|
|
|
|
|
|
|
|
|
|
if (batch.DetectionRateId != null && batchItemNum.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
var rate = db.Base_DetectionRate.FirstOrDefault(e => e.DetectionRateId == batch.DetectionRateId);
|
|
|
|
|
// 批里要检测的数量
|
|
|
|
|
pointNum = Convert.ToInt32(Math.Ceiling((batchItemNum.Count() * Convert.ToDouble(rate.DetectionRateValue)) * 0.01));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var weldG = from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
where y.JointAttribute == "固定口" && x.PointBatchId == pointBatchId
|
|
|
|
|
select x;
|
|
|
|
|
var weldA = from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
where y.JointAttribute == "活动口" && x.PointBatchId == pointBatchId
|
|
|
|
|
select x;
|
|
|
|
|
if (weldG.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
// 固定口检测数量
|
|
|
|
|
pointNumG = Convert.ToInt32(Math.Ceiling(weldG.Count() * 0.4));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 活动口要检测的数量
|
|
|
|
|
pointNumA = pointNum - pointNumG;
|
|
|
|
|
|
|
|
|
|
if (pointNumG > 0)
|
|
|
|
|
{
|
|
|
|
|
int[] r = Funs.GetRandomNum(pointNumG, 1, weldG.Count());
|
|
|
|
|
int i = 0;
|
|
|
|
|
foreach (var p in weldG)
|
|
|
|
|
{
|
|
|
|
|
i++;
|
|
|
|
|
if (r.Contains(i))
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_Batch_PointBatchItem newBatchDetail = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == p.PointBatchItemId);
|
|
|
|
|
if (newBatchDetail != null)
|
|
|
|
|
{
|
|
|
|
|
newBatchDetail.PointState = "1";
|
|
|
|
|
newBatchDetail.PointDate = System.DateTime.Now;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
if (pointNumA > 0)
|
|
|
|
|
{
|
|
|
|
|
int[] r = Funs.GetRandomNum(pointNumA, 1, weldA.Count());
|
|
|
|
|
int j = 0;
|
|
|
|
|
foreach (var p in weldA)
|
|
|
|
|
{
|
|
|
|
|
j++;
|
|
|
|
|
if (r.Contains(j))
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
Model.HJGL_Batch_PointBatchItem newBatchDetail = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == p.PointBatchItemId);
|
|
|
|
|
if (newBatchDetail != null)
|
|
|
|
|
{
|
|
|
|
|
newBatchDetail.PointState = "1";
|
|
|
|
|
newBatchDetail.PointDate = System.DateTime.Now;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Model.HJGL_Batch_PointBatch newBatch = db.HJGL_Batch_PointBatch.FirstOrDefault(e => e.PointBatchId == pointBatchId);
|
|
|
|
|
if (newBatch != null)
|
|
|
|
|
{
|
|
|
|
|
newBatch.EndDate = DateTime.Now;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 点口调整
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 点口调整
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="oldJointId">原来点的焊口</param>
|
|
|
|
|
/// <param name="newJointId">调为新的焊口</param>
|
|
|
|
|
public static void RePointSave(string oldJointId, string newJointId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var oldPoint = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.WeldJointId == oldJointId);
|
|
|
|
|
if (oldPoint != null)
|
|
|
|
|
{
|
|
|
|
|
oldPoint.PointDate = null;
|
|
|
|
|
oldPoint.PointState = null;
|
|
|
|
|
oldPoint.IsAudit = null;
|
|
|
|
|
oldPoint.IsPipelineFirst = null;
|
|
|
|
|
oldPoint.IsWelderFirst = null;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
var newPoint = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.WeldJointId == newJointId);
|
|
|
|
|
if (newPoint != null)
|
|
|
|
|
{
|
|
|
|
|
newPoint.PointState = "1";
|
|
|
|
|
newPoint.PointDate = DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据单位工程获取所有已点的焊口列表
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据单位工程获取所有已点的焊口列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitWorkId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> GetPointWeldJointList(string unitWorkId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getDataLists = (from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
join z in db.HJGL_Batch_PointBatch on x.PointBatchId equals z.PointBatchId
|
|
|
|
|
where x.IsBuildTrust == null && z.UnitWorkId == unitWorkId
|
|
|
|
|
&& x.PointState == "1"
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
WeldJointId = x.WeldJointId,
|
|
|
|
|
PointBatchCode = z.PointBatchCode,
|
|
|
|
|
WeldJointCode = y.WeldJointCode,
|
|
|
|
|
PipelineCode = y.PipelineCode,
|
|
|
|
|
AttachUrl = y.AttachUrl
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 根据单位工程获取所有已点的焊口生成委托单
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据单位工程获取所有已点的焊口生成委托单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitWorkId"></param>
|
|
|
|
|
public static void GenerateTrust(string unitWorkId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getViewGenerateTrustLists = (from x in db.View_GenerateTrust where x.UnitWorkId == unitWorkId select x).ToList();
|
|
|
|
|
|
|
|
|
|
foreach (var trust in getViewGenerateTrustLists)
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust();
|
|
|
|
|
var project = db.Base_Project.FirstOrDefault(e => e.ProjectId == trust.ProjectId) ;
|
|
|
|
|
var unit = db.Base_Unit.FirstOrDefault(x => x.UnitId == trust.UnitId) ;
|
|
|
|
|
var unitWork = db.WBS_UnitWork.FirstOrDefault(e => e.UnitWorkId.ToString() == trust.UnitWorkId) ;
|
|
|
|
|
var ndt = db.Base_DetectionType.FirstOrDefault(e => e.DetectionTypeId == trust.DetectionTypeId) ;
|
|
|
|
|
var rate = db.Base_DetectionRate.FirstOrDefault(e => e.DetectionRateId == trust.DetectionRateId) ;
|
|
|
|
|
|
|
|
|
|
string perfix = string.Empty;
|
|
|
|
|
perfix = unit.UnitCode + "-" + ndt.DetectionTypeCode + "-" + rate.DetectionRateValue.ToString() + "%-";
|
|
|
|
|
newBatchTrust.TrustBatchCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode5ByProjectId", "dbo.HJGL_Batch_BatchTrust", "TrustBatchCode", project.ProjectId, perfix);
|
|
|
|
|
|
|
|
|
|
string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust));
|
|
|
|
|
newBatchTrust.TrustBatchId = trustBatchId;
|
|
|
|
|
|
|
|
|
|
newBatchTrust.TrustDate = DateTime.Now;
|
|
|
|
|
newBatchTrust.ProjectId = trust.ProjectId;
|
|
|
|
|
newBatchTrust.UnitId = trust.UnitId;
|
|
|
|
|
newBatchTrust.UnitWorkId = trust.UnitWorkId;
|
|
|
|
|
newBatchTrust.DetectionTypeId = trust.DetectionTypeId;
|
|
|
|
|
newBatchTrust.NDEUuit = unitWork.NDEUnit;
|
|
|
|
|
newBatchTrust.IsAudit = true;
|
|
|
|
|
db.HJGL_Batch_BatchTrust.InsertOnSubmit(newBatchTrust);
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
// 生成委托条件对比
|
|
|
|
|
var generateTrustItem = from x in db.View_GenerateTrustItem
|
|
|
|
|
where x.ProjectId == trust.ProjectId
|
|
|
|
|
&& x.UnitWorkId == trust.UnitWorkId && x.UnitId == trust.UnitId
|
|
|
|
|
&& x.DetectionTypeId == trust.DetectionTypeId
|
|
|
|
|
&& x.DetectionRateId == trust.DetectionRateId
|
|
|
|
|
select x;
|
|
|
|
|
|
|
|
|
|
List<string> toPointBatchList = generateTrustItem.Select(x => x.PointBatchId).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
// 生成委托明细,并回写点口明细信息
|
|
|
|
|
foreach (var item in generateTrustItem)
|
|
|
|
|
{
|
|
|
|
|
if (BLL.Batch_BatchTrustItemService.GetIsGenerateTrust(item.PointBatchItemId)) ////生成委托单的条件判断
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
Model.HJGL_Batch_BatchTrustItem trustItem = new Model.HJGL_Batch_BatchTrustItem
|
|
|
|
|
{
|
|
|
|
|
TrustBatchItemId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrustItem)),
|
|
|
|
|
TrustBatchId = trustBatchId,
|
|
|
|
|
PointBatchItemId = item.PointBatchItemId,
|
|
|
|
|
WeldJointId = item.WeldJointId,
|
|
|
|
|
CreateDate = DateTime.Now
|
|
|
|
|
};
|
|
|
|
|
db.HJGL_Batch_BatchTrustItem.InsertOnSubmit(trustItem);
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Model.HJGL_Batch_PointBatchItem pointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == item.PointBatchItemId);
|
|
|
|
|
|
|
|
|
|
pointBatchItem.IsBuildTrust = true;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 回写委托批对应点口信息
|
|
|
|
|
if (toPointBatchList.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
string toPointBatch = String.Join(",", toPointBatchList);
|
|
|
|
|
|
|
|
|
|
var updateTrut = db.HJGL_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
|
|
|
|
|
if (updateTrut != null)
|
|
|
|
|
{
|
|
|
|
|
updateTrut.TopointBatch = toPointBatch;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////委托单/////////////////////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#region 选择单位工程、探伤类型、探伤比例、委托单号等获取委托单
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择单位工程、探伤类型、探伤比例、委托单号等获取委托单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitWorkId"></param>
|
|
|
|
|
/// <param name="detectionTypeId"></param>
|
|
|
|
|
/// <param name="detectionRateId"></param>
|
|
|
|
|
/// <param name="isAudit"></param>
|
|
|
|
|
/// <param name="pointBatchCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> getBatchTrustCode(string unitWorkId, string detectionTypeId, string detectionRateId, bool? isAudit, string trustBatchCode)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var dataList = from x in db.HJGL_Batch_BatchTrust
|
|
|
|
|
where x.UnitWorkId == unitWorkId
|
|
|
|
|
select x;
|
2022-03-15 17:36:38 +08:00
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(detectionTypeId))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.DetectionTypeId == detectionTypeId);
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(detectionRateId))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.DetectionRateId == detectionRateId);
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
if (isAudit == true)
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.IsAudit == true);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.IsAudit == null || e.IsAudit == false);
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(trustBatchCode))
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
dataList = dataList.Where(e => e.TrustBatchCode.Contains(trustBatchCode));
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
var getDataLists = (from x in dataList
|
|
|
|
|
orderby x.TrustBatchCode
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = x.TrustBatchId,
|
|
|
|
|
BaseInfoCode = x.TrustBatchCode,
|
|
|
|
|
}).ToList();
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 选择委托单ID获取委托单明细信息
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择委托单ID获取委托单明细信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="trustBatchId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> GetBatchTrustDetail(string trustBatchId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getDataLists = (from x in db.HJGL_Batch_BatchTrustItem
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
where x.TrustBatchId == trustBatchId
|
|
|
|
|
orderby y.WeldJointCode
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
WeldJointCode = y.WeldJointCode,
|
|
|
|
|
PipelineCode = y.PipelineCode,
|
|
|
|
|
JointArea = y.JointArea,
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 对所选委托单进行审核
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 对所选委托单进行审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="trustBatchId"></param>
|
|
|
|
|
public static void BatchTrustAudit(string trustBatchId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_Batch_BatchTrust newBatchTrust = db.HJGL_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
|
|
|
|
|
if (newBatchTrust != null)
|
|
|
|
|
{
|
|
|
|
|
newBatchTrust.IsAudit = true;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
///////////////////////////////////////无损检测单////////////////////////////////////////////
|
|
|
|
|
#region 无损检测单
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 选择单位工程、探伤类型、检测单号获取检测单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitWorkId"></param>
|
|
|
|
|
/// <param name="detectionTypeId"></param>
|
|
|
|
|
/// <param name="ndeCode"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> getBatchNdeCode(string unitWorkId, string detectionTypeId, string ndeCode)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var dataList = from x in db.HJGL_Batch_NDE
|
|
|
|
|
join y in db.HJGL_Batch_BatchTrust on x.TrustBatchId equals y.TrustBatchId
|
|
|
|
|
where x.UnitWorkId == unitWorkId
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = x.NDEID,
|
|
|
|
|
BaseInfoCode = x.NDECode,
|
|
|
|
|
BaseInfoName = y.DetectionTypeId
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(detectionTypeId))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.BaseInfoName == detectionTypeId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(ndeCode))
|
|
|
|
|
{
|
|
|
|
|
dataList = dataList.Where(e => e.BaseInfoCode.Contains(ndeCode));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var getDataLists = (from x in dataList
|
|
|
|
|
orderby x.BaseInfoCode
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = x.BaseInfoId,
|
|
|
|
|
BaseInfoCode = x.BaseInfoCode,
|
|
|
|
|
}).ToList();
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据检测单ID获取检测单明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="ndeId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> GetBatchNDEDetail(string ndeId)
|
|
|
|
|
{
|
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getDataLists = (from x in db.HJGL_Batch_NDEItem
|
|
|
|
|
join y in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals y.TrustBatchItemId
|
|
|
|
|
join z in db.HJGL_WeldJoint on y.WeldJointId equals z.WeldJointId
|
|
|
|
|
where x.NDEID == ndeId
|
|
|
|
|
orderby z.WeldJointCode
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
WeldJointCode = z.WeldJointCode,
|
|
|
|
|
PipelineCode = z.PipelineCode,
|
|
|
|
|
JointArea = z.JointArea,
|
|
|
|
|
CheckResult = x.CheckResult == "1" ? "合格" : "不合格"
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////返修/扩透/////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#region 返修/扩透
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取返修单列表
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="unitWorkId"></param>
|
|
|
|
|
/// <param name="isAudit"></param>
|
|
|
|
|
/// <param name="repairRecordId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> GetRepairRecord(string unitWorkId, bool isAudit, string repairRecordCode)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var repair = (from x in db.HJGL_RepairRecord
|
|
|
|
|
where x.UnitWorkId == unitWorkId
|
|
|
|
|
orderby x.RepairRecordCode descending
|
|
|
|
|
select x).ToList();
|
|
|
|
|
if (isAudit)
|
|
|
|
|
{
|
|
|
|
|
repair = (from x in repair where x.AuditDate.HasValue select x).ToList();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
repair = (from x in repair where !x.AuditDate.HasValue select x).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (!string.IsNullOrEmpty(repairRecordCode))
|
|
|
|
|
{
|
|
|
|
|
repair = (from x in repair where x.RepairRecordCode.Contains(repairRecordCode) select x).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var getDataLists = (from x in repair
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = x.RepairRecordId,
|
|
|
|
|
BaseInfoCode = x.RepairRecordCode
|
|
|
|
|
}).ToList();
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取返修单信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="repairRecordId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static Model.WeldJointItem GetRepairInfoByRepairRecordId(string repairRecordId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getDataLists = (from x in db.HJGL_RepairRecord
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
join z in db.SitePerson_Person on y.BackingWelderId equals z.PersonId
|
|
|
|
|
where x.RepairRecordId == repairRecordId
|
|
|
|
|
select new Model.WeldJointItem
|
|
|
|
|
{
|
|
|
|
|
PipelineCode = y.PipelineCode,
|
|
|
|
|
WeldJointCode = y.WeldJointCode,
|
|
|
|
|
BackingWelderCode = z.WelderCode,
|
|
|
|
|
BackingWelderId = y.BackingWelderId
|
|
|
|
|
}).FirstOrDefault();
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 根据条件获取可选取扩透口的批明细
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="repairRecordId"></param>
|
|
|
|
|
/// <param name="welder">同焊工</param>
|
|
|
|
|
/// <param name="pipeLine">同管线</param>
|
|
|
|
|
/// <param name="daily">同一天</param>
|
|
|
|
|
/// <param name="repairBefore">返修前所焊</param>
|
|
|
|
|
/// <param name="mat">同材质</param>
|
|
|
|
|
/// <param name="spec">同规格</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.NDETrustItem> GetRepairExpDetail(string repairRecordId, bool welder, bool pipeLine, bool daily, bool repairBefore, bool mat, bool spec)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var record = db.HJGL_RepairRecord.FirstOrDefault(e => e.RepairRecordId == repairRecordId);
|
|
|
|
|
var jot = db.View_HJGL_WeldJoint.FirstOrDefault(e => e.WeldJointId == record.WeldJointId);
|
|
|
|
|
var day = db.HJGL_WeldingDaily.FirstOrDefault(e => e.WeldingDailyId == jot.WeldingDailyId);
|
|
|
|
|
|
|
|
|
|
var repairExp = from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join z in db.HJGL_Batch_PointBatch on x.PointBatchId equals z.PointBatchId
|
|
|
|
|
join y in db.HJGL_WeldJoint on x.WeldJointId equals y.WeldJointId
|
|
|
|
|
join d in db.HJGL_WeldingDaily on y.WeldingDailyId equals d.WeldingDailyId
|
|
|
|
|
where z.DetectionTypeId == record.DetectionTypeId
|
|
|
|
|
&& !x.PointDate.HasValue || (x.PointDate.HasValue && x.RepairRecordId == repairRecordId)
|
|
|
|
|
select new
|
|
|
|
|
{
|
|
|
|
|
x.PointBatchItemId,
|
|
|
|
|
x.PointState,
|
|
|
|
|
y.WeldJointCode,
|
|
|
|
|
y.PipelineId,
|
|
|
|
|
y.PipelineCode,
|
|
|
|
|
y.JointArea,
|
|
|
|
|
y.BackingWelderId,
|
|
|
|
|
y.Material1Id,
|
|
|
|
|
y.Specification,
|
|
|
|
|
d.WeldingDate
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
if (welder)
|
|
|
|
|
{
|
|
|
|
|
repairExp = repairExp.Where(x => x.BackingWelderId == jot.BackingWelderId);
|
|
|
|
|
}
|
|
|
|
|
if (pipeLine)
|
|
|
|
|
{
|
|
|
|
|
repairExp = repairExp.Where(x => x.PipelineId == jot.PipelineId);
|
|
|
|
|
}
|
|
|
|
|
if (daily)
|
|
|
|
|
{
|
|
|
|
|
repairExp = repairExp.Where(x => x.WeldingDate == day.WeldingDate);
|
|
|
|
|
}
|
|
|
|
|
if (repairBefore)
|
|
|
|
|
{
|
|
|
|
|
repairExp = repairExp.Where(x => x.WeldingDate <= day.WeldingDate);
|
|
|
|
|
}
|
|
|
|
|
if (mat)
|
|
|
|
|
{
|
|
|
|
|
repairExp = repairExp.Where(x => x.Material1Id == jot.Material1Id);
|
|
|
|
|
}
|
|
|
|
|
if (spec)
|
|
|
|
|
{
|
|
|
|
|
repairExp = repairExp.Where(x => x.Specification == jot.Specification);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var getDataLists = (from x in repairExp
|
|
|
|
|
select new Model.NDETrustItem
|
|
|
|
|
{
|
|
|
|
|
PointBatchItemId = x.PointBatchItemId,
|
|
|
|
|
PointState = x.PointState,
|
|
|
|
|
WeldJointCode = x.WeldJointCode,
|
|
|
|
|
PipelineCode = x.PipelineCode,
|
|
|
|
|
JointArea = x.JointArea
|
|
|
|
|
}).ToList();
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 保存返修/扩透口信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="repairRecordId">返修ID</param>
|
|
|
|
|
/// <param name="expandId">扩透口ID(多个用“,”号隔开)</param>
|
|
|
|
|
/// <param name="repairWelder">返修焊工</param>
|
|
|
|
|
/// <param name="repairDate">返修日期</param>
|
|
|
|
|
/// <param name="isCut">是否切除</param>
|
|
|
|
|
public static void GetRepairExpSaveInfo(string repairRecordId, string expandId, string repairWelder, string repairDate, bool isCut)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_RepairRecord repairRecord = db.HJGL_RepairRecord.FirstOrDefault(e => e.RepairRecordId == repairRecordId);
|
|
|
|
|
// 更新返修记录
|
|
|
|
|
var repair = db.HJGL_RepairRecord.FirstOrDefault(x => x.RepairRecordId == repairRecordId);
|
|
|
|
|
if (repair != null)
|
|
|
|
|
{
|
|
|
|
|
repair.RepairWelder = repairWelder;
|
|
|
|
|
repair.RepairDate = Convert.ToDateTime(repairDate);
|
|
|
|
|
if (isCut)
|
|
|
|
|
{
|
|
|
|
|
repair.IsCut = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 更新返修口
|
|
|
|
|
var batchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.WeldJointId == repairRecord.WeldJointId);
|
|
|
|
|
if (batchItem != null)
|
|
|
|
|
{
|
|
|
|
|
batchItem.RepairDate = Convert.ToDateTime(repairDate);
|
|
|
|
|
if (isCut)
|
|
|
|
|
{
|
|
|
|
|
batchItem.CutDate = DateTime.Now.Date;
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
db.SubmitChanges();
|
2023-07-11 16:32:16 +08:00
|
|
|
|
|
|
|
|
|
var exp = db.HJGL_Batch_PointBatchItem.Where( x=>x.RepairRecordId == repairRecordId).ToList();
|
|
|
|
|
if (exp != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (Model.HJGL_Batch_PointBatchItem item in exp)
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_Batch_PointBatchItem newPointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.PointBatchItemId == item.PointBatchItemId);
|
|
|
|
|
newPointBatchItem.PointState = null;
|
|
|
|
|
newPointBatchItem.PointDate = null;
|
|
|
|
|
newPointBatchItem.RepairRecordId = null;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 更新扩透口
|
|
|
|
|
string[] checkedRow = expandId.Split(',');
|
|
|
|
|
if (checkedRow.Count() > 0)
|
|
|
|
|
{
|
|
|
|
|
foreach (string item in checkedRow)
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_Batch_PointBatchItem newPointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.PointBatchItemId == item);
|
|
|
|
|
if (newPointBatchItem != null)
|
|
|
|
|
{
|
|
|
|
|
newPointBatchItem.PointState = "2";
|
|
|
|
|
newPointBatchItem.PointDate = DateTime.Now;
|
|
|
|
|
newPointBatchItem.RepairRecordId = repairRecordId;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 返修单审核
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 返修单审核
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="repairRecordId"></param>
|
|
|
|
|
public static void RepairAudit(string repairRecordId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
// 更新返修记录
|
|
|
|
|
var repair = db.HJGL_RepairRecord.FirstOrDefault(x => x.RepairRecordId == repairRecordId);
|
|
|
|
|
if (!repair.AuditDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
repair.AuditDate = DateTime.Now;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 生成返修委托单
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 生成返修委托单
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="repairRecordId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GenerateRepairTrust(string repairRecordId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
string submitStr = string.Empty;
|
|
|
|
|
Model.HJGL_RepairRecord repairRecord = db.HJGL_RepairRecord.FirstOrDefault(e => e.RepairRecordId == repairRecordId);
|
|
|
|
|
var trustItem = from x in db.HJGL_Batch_BatchTrustItem where x.RepairRecordId == repairRecordId select x;
|
|
|
|
|
if (trustItem.Count() == 0)
|
|
|
|
|
{
|
|
|
|
|
if (!string.IsNullOrEmpty(repairRecordId) && repairRecord.AuditDate.HasValue)
|
|
|
|
|
{
|
|
|
|
|
// 返修委托
|
|
|
|
|
Model.HJGL_Batch_BatchTrust newRepairTrust = new Model.HJGL_Batch_BatchTrust();
|
|
|
|
|
string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust));
|
|
|
|
|
newRepairTrust.TrustBatchId = trustBatchId;
|
|
|
|
|
newRepairTrust.TrustBatchCode = repairRecord.RepairRecordCode;
|
|
|
|
|
newRepairTrust.TrustDate = DateTime.Now;
|
|
|
|
|
newRepairTrust.ProjectId = repairRecord.ProjectId;
|
|
|
|
|
newRepairTrust.UnitId = repairRecord.UnitId;
|
|
|
|
|
newRepairTrust.UnitWorkId = repairRecord.UnitWorkId;
|
|
|
|
|
newRepairTrust.DetectionTypeId = repairRecord.DetectionTypeId;
|
|
|
|
|
newRepairTrust.IsAudit = true;
|
|
|
|
|
db.HJGL_Batch_BatchTrust.InsertOnSubmit(newRepairTrust);
|
|
|
|
|
db.SubmitChanges(); ; // 新增返修委托单
|
|
|
|
|
|
|
|
|
|
Model.HJGL_Batch_BatchTrustItem newRepairTrustItem = new Model.HJGL_Batch_BatchTrustItem();
|
|
|
|
|
newRepairTrustItem.TrustBatchItemId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrustItem));
|
|
|
|
|
newRepairTrustItem.TrustBatchId = trustBatchId;
|
|
|
|
|
newRepairTrustItem.RepairRecordId = repairRecordId;
|
|
|
|
|
newRepairTrustItem.WeldJointId = repairRecord.WeldJointId;
|
|
|
|
|
newRepairTrustItem.CreateDate = DateTime.Now;
|
|
|
|
|
Batch_BatchTrustItemService.AddBatchTrustItemForApi(newRepairTrustItem);
|
|
|
|
|
|
|
|
|
|
// 扩透委托
|
|
|
|
|
var exp = db.HJGL_Batch_PointBatchItem .Where(x=> x.RepairRecordId == repairRecordId).ToList();
|
|
|
|
|
if (exp != null)
|
|
|
|
|
{
|
|
|
|
|
foreach (var q in exp)
|
|
|
|
|
{
|
|
|
|
|
Model.HJGL_Batch_BatchTrustItem newExportTrustItem = new Model.HJGL_Batch_BatchTrustItem();
|
|
|
|
|
newExportTrustItem.TrustBatchItemId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrustItem));
|
|
|
|
|
newExportTrustItem.TrustBatchId = trustBatchId;
|
|
|
|
|
newExportTrustItem.PointBatchItemId = q.PointBatchItemId;
|
|
|
|
|
newExportTrustItem.WeldJointId = q.WeldJointId;
|
|
|
|
|
newExportTrustItem.CreateDate = DateTime.Now;
|
|
|
|
|
Batch_BatchTrustItemService.AddBatchTrustItemForApi(newExportTrustItem);
|
|
|
|
|
|
|
|
|
|
Model.HJGL_Batch_PointBatchItem pointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(x => x.PointBatchItemId == q.PointBatchItemId);
|
|
|
|
|
pointBatchItem.IsBuildTrust = true;
|
|
|
|
|
db.SubmitChanges();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
submitStr = "成功生成委托单!";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
submitStr = "选中返修单并确认已审核!";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
submitStr = "已生成委托单!";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return submitStr;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region 获取扩透口的随机数
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 获取扩透口的随机数
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="num"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string RandomExport(int num)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
string strNum = string.Empty;
|
|
|
|
|
if (num > 0 && num <= 2)
|
|
|
|
|
{
|
|
|
|
|
if (num == 1)
|
|
|
|
|
{
|
|
|
|
|
strNum = "0";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
strNum = "0,1";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
int[] r = Funs.GetRandomNum(2, 0, num - 1);
|
|
|
|
|
strNum = r[0].ToString() + "," + r[1].ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strNum;
|
|
|
|
|
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
//////////////////////////////////////////// NDE预警//////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
#region NDE预警
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 无损检测不合格焊口信息
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> GetNdeCheckNoPassWarn(string projectId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var onecheckNoPass = (from x in db.HJGL_Batch_NDEItem
|
|
|
|
|
join y in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals y.TrustBatchItemId
|
|
|
|
|
join w in db.HJGL_WeldJoint on y.WeldJointId equals w.WeldJointId
|
|
|
|
|
join z in db.HJGL_Batch_NDE on x.NDEID equals z.NDEID
|
|
|
|
|
where y.RepairRecordId == null && x.CheckResult == "2"
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = y.WeldJointId,
|
|
|
|
|
BaseInfoCode = "检测单:" + z.NDECode,
|
|
|
|
|
BaseInfoName = "不合格焊口:" + w.WeldJointCode
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
var repairPass = (from x in db.HJGL_Batch_NDEItem
|
|
|
|
|
join y in db.HJGL_Batch_BatchTrustItem on x.TrustBatchItemId equals y.TrustBatchItemId
|
|
|
|
|
join w in db.HJGL_WeldJoint on y.WeldJointId equals w.WeldJointId
|
|
|
|
|
join z in db.HJGL_Batch_NDE on x.NDEID equals z.NDEID
|
|
|
|
|
where y.RepairRecordId != null && x.CheckResult == "1"
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = y.WeldJointId,
|
|
|
|
|
BaseInfoCode = "检测单:" + z.NDECode,
|
|
|
|
|
BaseInfoName = "不合格焊口:" + w.WeldJointCode
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
List<Model.BaseInfoItem> getDataLists = new List<Model.BaseInfoItem>();
|
|
|
|
|
foreach (var q in onecheckNoPass)
|
|
|
|
|
{
|
|
|
|
|
if (!repairPass.Contains(q))
|
|
|
|
|
{
|
|
|
|
|
getDataLists.Add(q);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 未委托焊口预警
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> GetNoTrustJointWarn(string projectId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var point = (from x in db.HJGL_Batch_PointBatchItem
|
|
|
|
|
join y in db.HJGL_Batch_PointBatch on x.PointBatchId equals y.PointBatchId
|
|
|
|
|
join z in db.HJGL_WeldJoint on x.WeldJointId equals z.WeldJointId
|
|
|
|
|
join t in db.HJGL_Batch_BatchTrustItem on x.PointBatchItemId equals t.PointBatchItemId
|
|
|
|
|
where y.ProjectId == projectId && t.TrustBatchItemId == null
|
|
|
|
|
orderby y.PointBatchCode, z.WeldJointCode
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = x.WeldJointId,
|
|
|
|
|
BaseInfoCode = "批号:" + y.PointBatchCode,
|
|
|
|
|
BaseInfoName = "未委托焊口:" + z.WeldJointCode,
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
var repair = (from x in db.HJGL_RepairRecord
|
|
|
|
|
join z in db.HJGL_WeldJoint on x.WeldJointId equals z.WeldJointId
|
|
|
|
|
join t in db.HJGL_Batch_BatchTrustItem on x.RepairRecordId equals t.RepairRecordId
|
|
|
|
|
where x.ProjectId == projectId && t.TrustBatchItemId == null
|
|
|
|
|
orderby x.RepairRecordCode, z.WeldJointCode
|
2022-03-15 17:36:38 +08:00
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
BaseInfoId = x.WeldJointId,
|
|
|
|
|
BaseInfoCode = "返修单号:" + x.RepairRecordCode,
|
|
|
|
|
BaseInfoName = "未委托焊口:" + z.WeldJointCode,
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}).ToList();
|
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
return point.Concat(repair).ToList<Model.BaseInfoItem>();
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 未检测焊口预警
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectId"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<Model.BaseInfoItem> GetNoCheckJointWarn(string projectId)
|
2022-03-15 17:36:38 +08:00
|
|
|
|
{
|
2023-07-11 16:32:16 +08:00
|
|
|
|
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
|
|
|
|
{
|
|
|
|
|
var getDataLists = (from x in db.HJGL_Batch_BatchTrustItem
|
|
|
|
|
join y in db.HJGL_Batch_BatchTrust on x.TrustBatchId equals y.TrustBatchId
|
|
|
|
|
join z in db.HJGL_WeldJoint on x.WeldJointId equals z.WeldJointId
|
|
|
|
|
join n in db.HJGL_Batch_NDEItem on x.TrustBatchItemId equals n.TrustBatchItemId
|
|
|
|
|
where y.ProjectId == projectId && n.NDEItemID == null
|
|
|
|
|
orderby y.TrustBatchCode, z.WeldJointCode
|
|
|
|
|
select new Model.BaseInfoItem
|
|
|
|
|
{
|
|
|
|
|
BaseInfoId = x.WeldJointId,
|
|
|
|
|
BaseInfoCode = "委托单号:" + y.TrustBatchCode,
|
|
|
|
|
BaseInfoName = "焊口:" + z.WeldJointCode,
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
return getDataLists;
|
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
#endregion
|
2022-03-15 17:36:38 +08:00
|
|
|
|
|
2023-07-11 16:32:16 +08:00
|
|
|
|
}
|
2022-03-15 17:36:38 +08:00
|
|
|
|
}
|