This commit is contained in:
2026-08-12 20:18:47 +08:00
parent e418b60fdb
commit 0ba761bc7a
12 changed files with 1135 additions and 167 deletions
@@ -1026,63 +1026,144 @@ namespace FineUIPro.Web.HJGL.PointTrust
}
#endregion
#region
/// <summary>
/// 生成
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnGenerate_Click(object sender, EventArgs e)
{
//if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PointBatchMenuId, Const.BtnGenerate))
//{
// var getViewGenerateTrustLists = (from x in Funs.DB.View_GenerateTrust where x.ProjectId == this.CurrUser.LoginProjectId select x).ToList();
// if (getViewGenerateTrustLists.Count() > 0)
// {
// var getUnit = BLL.Base_UnitService.GetUnit(this.CurrUser.UnitId);
// if (getUnit == null || getUnit.UnitTypeId == "1" || getUnit.UnitTypeId == "2" || getUnit.UnitTypeId == "3")
// {
// GenerateTrust(getViewGenerateTrustLists);
// }
// else
// {
// var getUnitViewGenerateTrustLists = getViewGenerateTrustLists.Where(x => x.UnitId == this.CurrUser.UnitId);
// if (getUnitViewGenerateTrustLists.Count() > 0)
// {
// // 当前单位未委托批
// GenerateTrust(getUnitViewGenerateTrustLists.ToList());
// }
// else
// {
// Alert.ShowInTop("所属单位点口已全部生成委托单!", MessageBoxIcon.Warning);
// }
// }
// BLL.Sys_LogService.AddLog(BLL.Const.System_6, this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PointBatchMenuId, Const.BtnGenerate, null);
// this.InitTreeMenu();//加载树
// this.BindGrid();
// }
// else
// {
// Alert.ShowInTop("已全部生成委托单!", MessageBoxIcon.Warning);
// }
//}
//else
//{
// ShowNotify("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
// return;
//}
}
#region
/// <summary>
/// 生成委托单
/// </summary>
/// <param name="unitId"></param>
//private void GenerateTrust(List<Model.View_GenerateTrust> GenerateTrustLists)
//{
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnGeneratingOrder_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.PersonId, Const.HJGL_PointBatchMenuId, Const.BtnPointAudit))
{
string batchId = this.tvControlItem.SelectedNodeID;
if (!string.IsNullOrEmpty(batchId))
{
var batch = BLL.PointBatchService.GetPointBatchById(batchId);
var detail = BLL.PointBatchDetailService.GetBatchDetailByBatchId(batchId);
foreach (var d in detail)
{
for (int i = 0; i < this.Grid1.Rows.Count; i++)
{
System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[i].FindControl("cblNDT"));
System.Web.UI.WebControls.HiddenField hdBatchDetailId = (System.Web.UI.WebControls.HiddenField)(this.Grid1.Rows[i].FindControl("hdBatchDetailId"));
if (d.PointBatchItemId == hdBatchDetailId.Value)
{
string ndtId = string.Empty;
foreach (System.Web.UI.WebControls.ListItem item in cblNDT.Items)
{
if (item.Selected)
{
ndtId += item.Value + ",";
}
}
if (!string.IsNullOrEmpty(ndtId))
{
ndtId = ndtId.Substring(0, ndtId.LastIndexOf(","));
d.NDT = ndtId;
BLL.PointBatchDetailService.UpdatePointBatchDetail(d);
}
}
}
}
if (batch.EndDate.HasValue && detail.Where(d => d.NDT != null).Count() > 0)
{
var detectionTypes = from x in Funs.DB.Base_DetectionType select x;
var type1 = detectionTypes.FirstOrDefault(x => x.DetectionTypeId == batch.DetectionTypeId);
string typeStr1 = string.Empty;
if (type1 != null)
{
typeStr1 = type1.DetectionTypeCode;
}
var trust = from x in Funs.DB.HJGL_Batch_BatchTrust where x.PointBatchId == batchId select x;
if (trust.Count() == 0)
{
detail = detail.Where(d => d.NDT != null).ToList();
foreach (var d in detail)
{
string[] ndts = d.NDT.Split(','); // 可能有多种探伤类型
foreach (string n in ndts)
{
var trustNdt = from x in Funs.DB.HJGL_Batch_BatchTrust where x.PointBatchId == batchId && x.DetectionTypeId == n select x;
if (trustNdt.Count() == 0)
{
Model.HJGL_Batch_BatchTrust newBatchTrust = new Model.HJGL_Batch_BatchTrust();
var project = BLL.ProjectService.GetProjectByProjectId(batch.ProjectId);
var unit = BLL.UnitService.GetUnitByUnitId(batch.UnitId);
var area = BLL.UnitWorkService.getUnitWorkByUnitWorkId(batch.UnitWorkId);
var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(batch.DetectionTypeId);
var rate = BLL.Base_DetectionRateService.GetDetectionRateByDetectionRateId(batch.DetectionRateId);
//}
#endregion
string perfix = string.Empty;
var type2 = detectionTypes.FirstOrDefault(x => x.DetectionTypeId == n);
string typeStr2 = string.Empty;
if (type2 != null)
{
typeStr2 = type2.DetectionTypeCode;
}
newBatchTrust.TrustBatchCode = BLL.Batch_BatchTrustService.BuildTrustBatchCode(batch.PointBatchCode, DateTime.Now, typeStr1, typeStr2);
string trustBatchId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrust));
newBatchTrust.TrustBatchId = trustBatchId;
newBatchTrust.TrustDate = DateTime.Now;
newBatchTrust.ProjectId = batch.ProjectId;
newBatchTrust.PointBatchId = batch.PointBatchId;
newBatchTrust.UnitId = batch.UnitId;
newBatchTrust.UnitWorkId = batch.UnitWorkId;
newBatchTrust.DetectionTypeId = n;
newBatchTrust.DetectionRateId = batch.DetectionRateId;
var NDEUnit = Funs.DB.Project_ProjectUnit.FirstOrDefault(x => x.ProjectId == this.CurrUser.LoginProjectId && x.UnitType == BLL.Const.ProjectUnitType_5);
if (NDEUnit != null)
{
newBatchTrust.NDEUnit = NDEUnit.UnitId;
}
newBatchTrust.PointBatchId = this.PointBatchId;
BLL.Batch_BatchTrustService.AddBatchTrust(newBatchTrust); // 新增委托单
// 增加明细
Model.HJGL_Batch_BatchTrustItem item = new Model.HJGL_Batch_BatchTrustItem();
item.TrustBatchItemId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrustItem));
item.TrustBatchId = trustBatchId;
item.PointBatchItemId = d.PointBatchItemId;
item.WeldJointId = d.WeldJointId;
item.CreateDate = DateTime.Now;
BLL.Batch_BatchTrustItemService.AddBatchTrustItem(item);
}
else
{
Model.HJGL_Batch_BatchTrustItem item = new Model.HJGL_Batch_BatchTrustItem();
item.TrustBatchItemId = SQLHelper.GetNewID(typeof(Model.HJGL_Batch_BatchTrustItem));
item.TrustBatchId = trustNdt.First().TrustBatchId;
item.PointBatchItemId = d.PointBatchItemId;
item.WeldJointId = d.WeldJointId;
item.CreateDate = DateTime.Now;
BLL.Batch_BatchTrustItemService.AddBatchTrustItem(item);
}
}
}
BLL.LogService.AddSys_Log(this.CurrUser, this.PointBatchId, this.PointBatchId, BLL.Const.HJGL_PointBatchMenuId, "生成委托单");
ShowNotify("成功生成委托单!", MessageBoxIcon.Success);
}
else
{
ShowNotify("已生成委托单!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify("批未关闭或批里没有点口!", MessageBoxIcon.Warning);
}
}
}
else
{
Alert.ShowInTop("您没有这个权限,请与管理员联系!", MessageBoxIcon.Warning);
return;
}
}
#endregion
#region
@@ -1195,5 +1276,45 @@ namespace FineUIPro.Web.HJGL.PointTrust
string detectionType = this.tvControlItem.SelectedNode.ParentNode.ParentNode.NodeID.Split('|')[0];
PageContext.RegisterStartupScript(Window1.GetShowReference(String.Format("PointWeldJointView.aspx?unitWorkId={0}&rateId={1}&detectionType={2}", unitWorkId, rateId, detectionType, "新增 - ")));
}
#region Grid绑定事件
/// <summary>
/// Grid1绑定事件
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void Grid1_RowDataBound(object sender, GridRowEventArgs e)
{
var batch = Funs.DB.View_HJGL_Batch_PointBatch.FirstOrDefault(x => x.PointBatchId == this.tvControlItem.SelectedNodeID);
if (batch != null)
{
string[] strs = batch.DetectionTypeCode.Split('/');
System.Web.UI.WebControls.CheckBoxList cblNDT = (System.Web.UI.WebControls.CheckBoxList)(this.Grid1.Rows[e.RowIndex].FindControl("cblNDT"));
cblNDT.DataTextField = "DetectionTypeCode";
cblNDT.DataValueField = "DetectionTypeId";
cblNDT.DataSource = BLL.Base_DetectionTypeService.GetDetectionTypeListByDetectionTypeType2(strs);
cblNDT.DataBind();
var batchDetail = BLL.PointBatchDetailService.GetBatchDetailById(hdBatchDetailId.Value);
if (batchDetail != null)
{
if (!string.IsNullOrEmpty(batchDetail.NDT))
{
List<string> ndtIds = batchDetail.NDT.Split(',').ToList();
foreach (var ndtId in ndtIds)
{
for (int i = 0; i < cblNDT.Items.Count; i++)
{
if (cblNDT.Items[i].Value == ndtId)
{
cblNDT.Items[i].Selected = true;
}
}
}
}
}
}
}
#endregion
}
}