1
This commit is contained in:
@@ -0,0 +1,150 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 无损委托明细
|
||||
/// </summary>
|
||||
public static class Batch_BatchTrustItemService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据主键获取无损委托明细
|
||||
/// </summary>
|
||||
/// <param name="batchTrustItemId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.HJGL_Batch_BatchTrustItem GetBatchTrustItemById(string trustBatchItemId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
return db.HJGL_Batch_BatchTrustItem.FirstOrDefault(e => e.TrustBatchItemId == trustBatchItemId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据无损委托Id获取相关明细信息
|
||||
/// </summary>
|
||||
/// <param name="hardTrustId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.HJGL_Batch_BatchTrustItem> GetBatchTrustItemByTrustBatchId(string trustBatchId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
return (from x in db.HJGL_Batch_BatchTrustItem where x.TrustBatchId == trustBatchId select x).ToList();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加无损委托明细
|
||||
/// </summary>
|
||||
/// <param name="batchTrustItem"></param>
|
||||
public static void AddBatchTrustItem(Model.HJGL_Batch_BatchTrustItem batchTrustItem)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrustItem newTrustBatchItem = new Model.HJGL_Batch_BatchTrustItem
|
||||
{
|
||||
TrustBatchItemId = batchTrustItem.TrustBatchItemId,
|
||||
TrustBatchId = batchTrustItem.TrustBatchId,
|
||||
PointBatchItemId = batchTrustItem.PointBatchItemId,
|
||||
RepairRecordId = batchTrustItem.RepairRecordId,
|
||||
WeldJointId = batchTrustItem.WeldJointId,
|
||||
CreateDate = batchTrustItem.CreateDate,
|
||||
RepairNum = batchTrustItem.RepairNum,
|
||||
};
|
||||
db.HJGL_Batch_BatchTrustItem.InsertOnSubmit(newTrustBatchItem);
|
||||
db.SubmitChanges();
|
||||
UpdateTrustNum(batchTrustItem.TrustBatchItemId, 1);
|
||||
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改无损委托
|
||||
/// </summary>
|
||||
/// <param name="batchTrustItem"></param>
|
||||
public static void UpdateBatchTrustItem(Model.HJGL_Batch_BatchTrustItem batchTrustItem)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrustItem newBatchTrustItem = db.HJGL_Batch_BatchTrustItem.FirstOrDefault(e => e.TrustBatchItemId == batchTrustItem.TrustBatchItemId);
|
||||
if (newBatchTrustItem != null)
|
||||
{
|
||||
newBatchTrustItem.PointBatchItemId = batchTrustItem.PointBatchItemId;
|
||||
newBatchTrustItem.WeldJointId = batchTrustItem.WeldJointId;
|
||||
newBatchTrustItem.CreateDate = batchTrustItem.CreateDate;
|
||||
newBatchTrustItem.RepairNum = batchTrustItem.RepairNum;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据无损委托Id获取相关明细视图信息
|
||||
/// </summary>
|
||||
/// <param name="projectId"></param>
|
||||
/// <param name="hardTrustId"></param>
|
||||
/// <returns></returns>
|
||||
public static List<Model.View_Batch_BatchTrustItem> GetViewBatchTrustItem(string trustBatchId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
return (from x in db.View_Batch_BatchTrustItem where x.TrustBatchId == trustBatchId select x).ToList();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 根据Id删除明细信息
|
||||
/// </summary>
|
||||
/// <param name="checkItemId"></param>
|
||||
public static void DeleteTrustItemByTrustBatchItemId(string trustBatchItemId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrustItem trustItem = db.HJGL_Batch_BatchTrustItem.FirstOrDefault(e => e.TrustBatchItemId == trustBatchItemId);
|
||||
if (trustItem != null)
|
||||
{
|
||||
UpdateTrustNum(trustBatchItemId, -1);
|
||||
db.HJGL_Batch_BatchTrustItem.DeleteOnSubmit(trustItem);
|
||||
db.SubmitChanges();
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 更新委托次数
|
||||
/// </summary>
|
||||
/// <param name="trustBatchItemId">委托批明细ID</param>
|
||||
/// <param name="num"></param>
|
||||
public static void UpdateTrustNum(string trustBatchItemId, int num)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
var trustBatchItem = db.HJGL_Batch_BatchTrustItem.FirstOrDefault(x => x.TrustBatchItemId == trustBatchItemId);
|
||||
if (trustBatchItem != null)
|
||||
{
|
||||
trustBatchItem.TrustNum = trustBatchItem.TrustNum ?? 0 + num;
|
||||
if (trustBatchItem.TrustNum < 0)
|
||||
{
|
||||
trustBatchItem.TrustNum = 0;
|
||||
}
|
||||
}
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
#region 是否满足生成委托条件
|
||||
/// <summary>
|
||||
/// 是否满足生成委托条件
|
||||
/// </summary>
|
||||
/// <returns></returns>
|
||||
public static bool GetIsGenerateTrust(string pointBatchItemId)
|
||||
{
|
||||
bool isShow = true;
|
||||
var trustBatchItem = Funs.DB.HJGL_Batch_BatchTrustItem.FirstOrDefault(x => x.PointBatchItemId == pointBatchItemId);
|
||||
if (trustBatchItem != null)
|
||||
{
|
||||
var checkItem = Funs.DB.HJGL_Batch_NDEItem.FirstOrDefault(x => x.TrustBatchItemId == trustBatchItem.TrustBatchItemId && x.CheckResult == "1");
|
||||
if (checkItem != null)
|
||||
{
|
||||
isShow = false;
|
||||
}
|
||||
}
|
||||
|
||||
return isShow;
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,177 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
/// <summary>
|
||||
/// 无损委托
|
||||
/// </summary>
|
||||
public static class Batch_BatchTrustService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据主键获取无损委托
|
||||
/// </summary>
|
||||
/// <param name="batchTrustID"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.HJGL_Batch_BatchTrust GetBatchTrustById(string trustBatchId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
return db.HJGL_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键获取无损委托视图
|
||||
/// </summary>
|
||||
/// <param name="batchTrustID"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.View_Batch_BatchTrust GetBatchTrustViewById(string trustBatchId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
return db.View_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
|
||||
}
|
||||
|
||||
#region 更新委托单 检测状态
|
||||
/// <summary>
|
||||
/// 更新委托单 检测状态
|
||||
/// </summary>
|
||||
/// <param name="pointBatchId"></param>
|
||||
/// <param name="isTrust"></param>
|
||||
public static void UpdatTrustBatchtState(string trustBatchId, bool? isCheck)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrust update = db.HJGL_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
|
||||
if (update != null)
|
||||
{
|
||||
update.IsCheck = isCheck;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 添加无损委托
|
||||
/// </summary>
|
||||
/// <param name="batchTrust"></param>
|
||||
public static void AddBatchTrust(Model.HJGL_Batch_BatchTrust batchTrust)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust
|
||||
{
|
||||
TrustBatchId = batchTrust.TrustBatchId,
|
||||
TrustBatchCode = batchTrust.TrustBatchCode,
|
||||
TrustDate = batchTrust.TrustDate,
|
||||
ProjectId = batchTrust.ProjectId,
|
||||
UnitId = batchTrust.UnitId,
|
||||
UnitWorkId = batchTrust.UnitWorkId,
|
||||
DetectionRateId = batchTrust.DetectionRateId,
|
||||
NDEUuit=batchTrust.NDEUuit,
|
||||
TrustType = batchTrust.TrustType,
|
||||
DetectionTypeId = batchTrust.DetectionTypeId,
|
||||
IsCheck = batchTrust.IsCheck,
|
||||
TopointBatch = batchTrust.TopointBatch,
|
||||
IsAudit = true
|
||||
};
|
||||
|
||||
db.HJGL_Batch_BatchTrust.InsertOnSubmit(newBatchTrust);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 修改无损委托
|
||||
/// </summary>
|
||||
/// <param name="batchTrust"></param>
|
||||
public static void UpdateBatchTrust(Model.HJGL_Batch_BatchTrust batchTrust)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrust newBatchTrust = db.HJGL_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == batchTrust.TrustBatchId);
|
||||
if (newBatchTrust != null)
|
||||
{
|
||||
newBatchTrust.TrustBatchCode = batchTrust.TrustBatchCode;
|
||||
newBatchTrust.TrustDate = batchTrust.TrustDate;
|
||||
newBatchTrust.ProjectId = batchTrust.ProjectId;
|
||||
newBatchTrust.UnitId = batchTrust.UnitId;
|
||||
newBatchTrust.UnitWorkId = batchTrust.UnitWorkId;
|
||||
newBatchTrust.DetectionRateId = batchTrust.DetectionRateId;
|
||||
newBatchTrust.NDEUuit = batchTrust.NDEUuit;
|
||||
newBatchTrust.TrustType = batchTrust.TrustType;
|
||||
newBatchTrust.DetectionTypeId = batchTrust.DetectionTypeId;
|
||||
newBatchTrust.IsCheck = batchTrust.IsCheck;
|
||||
newBatchTrust.TopointBatch = batchTrust.TopointBatch;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateBatchTrustAudit(string batchTrustId, bool isAudit)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrust newBatchTrust = db.HJGL_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == batchTrustId);
|
||||
if (newBatchTrust != null)
|
||||
{
|
||||
newBatchTrust.IsAudit = isAudit;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除无损委托
|
||||
/// </summary>
|
||||
/// <param name="batchTrustID"></param>
|
||||
public static void DeleteBatchTrustById(string trustBatchId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_BatchTrust batchTrust = db.HJGL_Batch_BatchTrust.FirstOrDefault(e => e.TrustBatchId == trustBatchId);
|
||||
if (batchTrust != null)
|
||||
{
|
||||
db.HJGL_Batch_BatchTrust.DeleteOnSubmit(batchTrust);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 无损委托委托单编号是否存在
|
||||
/// </summary>
|
||||
/// <param name="pointNo"></param>
|
||||
/// <param name="pointId"></param>
|
||||
/// <returns></returns>
|
||||
public static bool IsExistTrustCode(string trustBatchCode, string trustBatchId, string projectId)
|
||||
{
|
||||
var q = Funs.DB.HJGL_Batch_BatchTrust.FirstOrDefault(x => x.TrustBatchCode == trustBatchCode && x.ProjectId == projectId && x.TrustBatchId != trustBatchId);
|
||||
if (q != null)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
#region 委托单下拉项
|
||||
/// <summary>
|
||||
/// 委托单下拉项
|
||||
/// </summary>
|
||||
/// <param name="dropName">下拉框名称</param>
|
||||
/// <param name="isShowPlease">是否显示请选择</param>
|
||||
/// <param name="ComponentsType">耗材类型</param>
|
||||
public static void InitTrustBatchDropDownList(FineUIPro.DropDownList dropName, bool isShowPlease, string unitId, string detectionTypeId, string pipelineCode, string itemText)
|
||||
{
|
||||
dropName.DataValueField = "TrustBatchId";
|
||||
dropName.DataTextField = "TrustBatchCode";
|
||||
|
||||
var q = from x in Funs.DB.View_Batch_BatchTrust
|
||||
where x.UnitId == unitId && x.DetectionTypeId == detectionTypeId
|
||||
&& x.CheckTrustBatchId == null
|
||||
select x; // 管线TODO
|
||||
|
||||
dropName.DataSource = q;
|
||||
dropName.DataBind();
|
||||
if (isShowPlease)
|
||||
{
|
||||
Funs.FineUIPleaseSelect(dropName, itemText);
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,260 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class PointBatchDetailService
|
||||
{
|
||||
/// <summary>
|
||||
/// 根据批明细ID获取批明细信息
|
||||
/// </summary>
|
||||
/// <param name="batchId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.HJGL_Batch_PointBatchItem GetBatchDetailById(string batchDetailId)
|
||||
{
|
||||
return Funs.DB.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == batchDetailId);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据批焊口ID获取批明细信息
|
||||
/// </summary>
|
||||
/// <param name="jotId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.HJGL_Batch_PointBatchItem GetBatchDetailByJotId(string jotId)
|
||||
{
|
||||
return Funs.DB.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.WeldJointId == jotId);
|
||||
}
|
||||
|
||||
public static List<Model.HJGL_Batch_PointBatchItem> GetBatchDetailByBatchId(string batchId)
|
||||
{
|
||||
return Funs.DB.HJGL_Batch_PointBatchItem.Where(e => e.PointBatchId == batchId).ToList();
|
||||
}
|
||||
|
||||
public static List<Model.HJGL_Batch_PointBatchItem> GetGBatchDetailByBatchId(string batchId)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
return (from x in db.HJGL_Batch_PointBatchItem
|
||||
join y in db.HJGL_WeldJoint
|
||||
on x.WeldJointId equals y.WeldJointId
|
||||
where y.WeldJointCode.Contains("G") && x.PointBatchId == batchId
|
||||
select x).ToList();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改
|
||||
/// </summary>
|
||||
/// <param name="batchDetail"></param>
|
||||
public static void UpdatePointBatchDetail(Model.HJGL_Batch_PointBatchItem batchDetail)
|
||||
{
|
||||
Model.HJGL_Batch_PointBatchItem newBatchDetail = Funs.DB.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == batchDetail.PointBatchItemId);
|
||||
if (newBatchDetail != null)
|
||||
{
|
||||
newBatchDetail.PointBatchId = batchDetail.PointBatchId;
|
||||
newBatchDetail.WeldJointId = batchDetail.WeldJointId;
|
||||
newBatchDetail.PointState = batchDetail.PointState;
|
||||
newBatchDetail.PointDate = batchDetail.PointDate;
|
||||
newBatchDetail.PointDate = batchDetail.PointDate;
|
||||
newBatchDetail.RepairDate = batchDetail.RepairDate;
|
||||
newBatchDetail.CutDate = batchDetail.CutDate;
|
||||
newBatchDetail.CreatDate = batchDetail.CreatDate;
|
||||
newBatchDetail.IsBuildTrust = batchDetail.IsBuildTrust;
|
||||
newBatchDetail.IsWelderFirst = batchDetail.IsWelderFirst;
|
||||
newBatchDetail.IsPipelineFirst = batchDetail.IsPipelineFirst;
|
||||
newBatchDetail.Remark = batchDetail.Remark;
|
||||
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdatePointBatchDetail(string pointBatchItemId, string pointState, DateTime? pointDate)
|
||||
{
|
||||
Model.HJGL_Batch_PointBatchItem newBatchDetail = Funs.DB.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId);
|
||||
if (newBatchDetail != null)
|
||||
{
|
||||
newBatchDetail.PointState = pointState;
|
||||
newBatchDetail.PointDate = pointDate;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
#region 点口审核
|
||||
/// <summary>
|
||||
/// 点口审核
|
||||
/// </summary>
|
||||
/// <param name="pointBatchItemId"></param>
|
||||
/// <param name="isAudit"></param>
|
||||
public static void PointAudit(string pointBatchItemId, bool isAudit)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_PointBatchItem newPointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId);
|
||||
if (newPointBatchItem != null)
|
||||
{
|
||||
newPointBatchItem.IsAudit = isAudit;
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
||||
#region 首件制
|
||||
/// <summary>
|
||||
/// 焊工首两件
|
||||
/// </summary>
|
||||
/// <param name="pointBatchItemId"></param>
|
||||
/// <param name="welderFirst"></param>
|
||||
public static void UpdateWelderFirst(string pointBatchItemId, bool? welderFirst)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_PointBatchItem newPointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId);
|
||||
newPointBatchItem.IsWelderFirst = welderFirst;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 管线首件
|
||||
/// </summary>
|
||||
/// <param name="pointBatchItemId"></param>
|
||||
/// <param name="pipelineFirst"></param>
|
||||
public static void UpdatePipelineFirst(string pointBatchItemId, bool? pipelineFirst)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_PointBatchItem newPointBatchItem = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == pointBatchItemId);
|
||||
newPointBatchItem.IsPipelineFirst = pipelineFirst;
|
||||
|
||||
db.SubmitChanges();
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 根据批焊口ID删除批明细信息
|
||||
/// </summary>
|
||||
/// <param name="checkId"></param>
|
||||
public static void DeleteBatchDetail(string jotId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_PointBatchItem batch = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.WeldJointId == jotId);
|
||||
if (batch != null)
|
||||
{
|
||||
db.HJGL_Batch_PointBatchItem.DeleteOnSubmit(batch);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 增加
|
||||
/// </summary>
|
||||
/// <param name="batchDetail"></param>
|
||||
public static void AddBatchDetail(Model.HJGL_Batch_PointBatchItem batchDetail)
|
||||
{
|
||||
Model.HJGL_Batch_PointBatchItem newBatchDetail = new Model.HJGL_Batch_PointBatchItem();
|
||||
newBatchDetail.PointBatchItemId = batchDetail.PointBatchItemId;
|
||||
newBatchDetail.PointBatchId = batchDetail.PointBatchId;
|
||||
newBatchDetail.WeldJointId = batchDetail.WeldJointId;
|
||||
newBatchDetail.PointState = batchDetail.PointState;
|
||||
newBatchDetail.PointDate = batchDetail.PointDate;
|
||||
newBatchDetail.PointDate = batchDetail.PointDate;
|
||||
newBatchDetail.RepairDate = batchDetail.RepairDate;
|
||||
newBatchDetail.CutDate = batchDetail.CutDate;
|
||||
newBatchDetail.CreatDate = batchDetail.CreatDate;
|
||||
newBatchDetail.IsBuildTrust = batchDetail.IsBuildTrust;
|
||||
newBatchDetail.IsWelderFirst = batchDetail.IsWelderFirst;
|
||||
newBatchDetail.IsPipelineFirst = batchDetail.IsPipelineFirst;
|
||||
newBatchDetail.Remark = batchDetail.Remark;
|
||||
Funs.DB.HJGL_Batch_PointBatchItem.InsertOnSubmit(newBatchDetail);
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 根据主键删除明细
|
||||
/// </summary>
|
||||
/// <param name="batchDetailId"></param>
|
||||
public static void DeleteBatchDetailById(string batchDetailId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_PointBatchItem batch = db.HJGL_Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == batchDetailId);
|
||||
if (batch != null)
|
||||
{
|
||||
db.HJGL_Batch_PointBatchItem.DeleteOnSubmit(batch);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
/// <summary>
|
||||
/// 检验批自动点口算法
|
||||
/// </summary>
|
||||
/// <param name="pointBatchId"></param>
|
||||
public static void AutoPoint(string pointBatchId)
|
||||
{
|
||||
using (Model.SUBQHSEDB db = new Model.SUBQHSEDB(Funs.ConnString))
|
||||
{
|
||||
int pointNum = 0;
|
||||
int pointNumG = 0;
|
||||
int pointNumA = 0;
|
||||
|
||||
var batch = PointBatchService.GetPointBatchById(pointBatchId);
|
||||
var batchItemNum = PointBatchDetailService.GetBatchDetailByBatchId(pointBatchId);
|
||||
|
||||
if (batch.DetectionRateId != null && batchItemNum.Count() > 0)
|
||||
{
|
||||
var rate = Base_DetectionRateService.GetDetectionRateByDetectionRateId(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))
|
||||
{
|
||||
PointBatchDetailService.UpdatePointBatchDetail(p.PointBatchItemId, "1", System.DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (pointNumA > 0)
|
||||
{
|
||||
int[] r = Funs.GetRandomNum(pointNumA, 1, weldA.Count());
|
||||
int j = 0;
|
||||
foreach (var p in weldA)
|
||||
{
|
||||
j++;
|
||||
if (r.Contains(j))
|
||||
{
|
||||
PointBatchDetailService.UpdatePointBatchDetail(p.PointBatchItemId, "1", System.DateTime.Now);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
PointBatchService.UpdateBatchIsClosed(pointBatchId, DateTime.Now);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,77 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Collections;
|
||||
|
||||
namespace BLL
|
||||
{
|
||||
public class PointBatchService
|
||||
{
|
||||
/// <summary>
|
||||
///
|
||||
/// </summary>
|
||||
/// <param name="batchId"></param>
|
||||
/// <returns></returns>
|
||||
public static Model.HJGL_Batch_PointBatch GetPointBatchById(string pointBatchId)
|
||||
{
|
||||
return Funs.DB.HJGL_Batch_PointBatch.FirstOrDefault(e => e.PointBatchId == pointBatchId);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 修改批主表批关闭状态
|
||||
/// </summary>
|
||||
/// <param name="batch"></param>
|
||||
public static void UpdateBatchIsClosed(string PointBatchId, DateTime endDate)
|
||||
{
|
||||
Model.HJGL_Batch_PointBatch newBatch = Funs.DB.HJGL_Batch_PointBatch.FirstOrDefault(e => e.PointBatchId == PointBatchId);
|
||||
if (newBatch != null)
|
||||
{
|
||||
newBatch.EndDate = endDate;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 添加
|
||||
/// </summary>
|
||||
/// <param name="check"></param>
|
||||
public static void AddPointBatch(Model.HJGL_Batch_PointBatch batch)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_PointBatch newBatch = new Model.HJGL_Batch_PointBatch();
|
||||
newBatch.PointBatchId = batch.PointBatchId;
|
||||
newBatch.PointBatchCode = batch.PointBatchCode;
|
||||
newBatch.BatchCondition = batch.BatchCondition;
|
||||
newBatch.ProjectId = batch.ProjectId;
|
||||
newBatch.UnitWorkId = batch.UnitWorkId;
|
||||
newBatch.UnitId = batch.UnitId;
|
||||
newBatch.DetectionTypeId = batch.DetectionTypeId;
|
||||
|
||||
newBatch.DetectionRateId = batch.DetectionRateId;
|
||||
newBatch.PipingClassId = batch.PipingClassId;
|
||||
newBatch.PipelineId = batch.PipelineId;
|
||||
newBatch.WelderId = batch.WelderId;
|
||||
newBatch.StartDate = batch.StartDate;
|
||||
|
||||
db.HJGL_Batch_PointBatch.InsertOnSubmit(newBatch);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 删除
|
||||
/// </summary>
|
||||
/// <param name="checkId"></param>
|
||||
public static void DeleteBatch(string batchId)
|
||||
{
|
||||
Model.SUBQHSEDB db = Funs.DB;
|
||||
Model.HJGL_Batch_PointBatch batch = db.HJGL_Batch_PointBatch.FirstOrDefault(e => e.PointBatchId == batchId);
|
||||
|
||||
db.HJGL_Batch_PointBatch.DeleteOnSubmit(batch);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user