This commit is contained in:
2024-05-23 09:35:43 +08:00
parent df39b88c09
commit 6c7c257fd2
8 changed files with 255 additions and 32 deletions
@@ -30,8 +30,13 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
(CASE WHEN IsWelderFirst=1 THEN '是' ELSE '否' END) AS IsWelderFirst,
JLAudit,GLGSAudit,QTAudit,IsPointAudit
FROM dbo.View_Batch_PointBatchItem
WHERE PointState IS NOT NULL";
WHERE PointState IS NOT NULL AND TrustBatchItemId IS NULL";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(this.txtPipeCode.Text))
{
strSql += " AND PipelineCode LIKE @PipelineCode";
listStr.Add(new SqlParameter("@PipelineCode", "%" + this.txtPipeCode.Text.Trim() + "%"));
}
if (!string.IsNullOrEmpty(this.txtPointStartDate.Text))
{
strSql += " AND PointDate >= @PointStartDate";
@@ -200,5 +205,148 @@ namespace FineUIPro.Web.WeldingProcess.TrustManage
return;
}
}
/// <summary>
/// 手动生成委托单
/// </summary>
/// <param name="sender"></param>
/// <param name="e"></param>
protected void btnHandGenerate_Click(object sender, EventArgs e)
{
if (CommonService.GetAllButtonPowerList(this.CurrUser.LoginProjectId, this.CurrUser.UserId, Const.HJGL_PointManageMenuId, Const.BtnHandGenerate))
{
List<string> selectRow = new List<string>();
foreach (string pitem in Grid1.SelectedRowIDArray)
{
selectRow.Add(pitem);
}
if (selectRow.Count() > 0)
{
List<string> weldMot = new List<string>();
List<string> grooveType = new List<string>();
List<bool> IsFist = new List<bool>();
List<string> pointBatchIds = new List<string>();
string error = string.Empty;
foreach (string pointItemId in selectRow)
{
var pointItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(pointItemId);
var jot = BLL.Pipeline_WeldJointService.GetWeldJointByWeldJointId(pointItem.WeldJointId);
weldMot.Add(jot.WeldingMethodId);
grooveType.Add(jot.GrooveTypeId);
IsFist.Add(pointItem.IsWelderFirst == true ? true : false);
pointBatchIds.Add(pointItem.PointBatchId);
}
if (pointBatchIds.Distinct().Count() > 1)
{
error = "勾选的焊口不在一个批次中,";
}
if (weldMot.Distinct().Count() > 1)
{
error = "勾选的焊口焊接方法不一至,";
}
if (grooveType.Distinct().Count() > 1)
{
error = error + "勾选的焊口坡口类型不一至,";
}
if (IsFist.Distinct().Count() > 1)
{
error = error + "勾选的焊口是否首三不一至,";
}
if (error == string.Empty)
{
var point = BLL.Batch_PointBatchService.GetPointBatchById(pointBatchIds[0]);
var iso = BLL.Pipeline_PipelineService.GetPipelineByPipelineId(point.PipelineId);
var project = BLL.Base_ProjectService.GetProjectByProjectId(point.ProjectId);
var unit = BLL.Base_UnitService.GetUnit(point.UnitId);
var ndt = BLL.Base_DetectionTypeService.GetDetectionTypeByDetectionTypeId(point.DetectionTypeId);
var work = BLL.Project_WorkAreaService.GetProject_WorkAreaByWorkAreaId(iso.WorkAreaId);
Model.Batch_BatchTrust newBatchTrust = new Model.Batch_BatchTrust();
string perfix = string.Empty;
//perfix = unit.UnitCode + "-" + ins.InstallationCode + "-GD-" + ndt.DetectionTypeCode + "-";
perfix = ndt.DetectionTypeCode + "-" + unit.UnitCode + "-" + work.WorkAreaCode + "-PI" + "-";
newBatchTrust.TrustBatchCode = BLL.SQLHelper.RunProcNewId("SpGetNewCode", "dbo.Batch_BatchTrust", "TrustBatchCode", project.ProjectId, perfix);
string trustBatchId = SQLHelper.GetNewID(typeof(Model.Batch_BatchTrust));
newBatchTrust.TrustBatchId = trustBatchId;
newBatchTrust.TrustDate = DateTime.Now;
newBatchTrust.ProjectId = point.ProjectId;
newBatchTrust.UnitId = point.UnitId;
newBatchTrust.InstallationId = point.InstallationId;
newBatchTrust.WorkAreaId = iso.WorkAreaId;
newBatchTrust.WeldingMethodId = weldMot[0];
newBatchTrust.GrooveTypeId = grooveType[0];
newBatchTrust.IsWelderFirst = IsFist[0];
newBatchTrust.DetectionTypeId = point.DetectionTypeId;
newBatchTrust.PipelineId = point.PipelineId;
BLL.Batch_BatchTrustService.AddBatchTrust(newBatchTrust); // 新增委托单
// 生成委托明细,并回写点口明细信息
string toPointBatch = string.Empty;
foreach (string pointItemId in selectRow)
{
var pointItem = BLL.Batch_PointBatchItemService.GetPointBatchItemByPointBatchItemId(pointItemId);
if (BLL.Batch_PointBatchService.GetIsGenerateTrust(pointItem.PointBatchItemId)) ////生成委托单的条件判断
{
if (!toPointBatch.Contains(pointItem.PointBatchId))
{
toPointBatch = toPointBatch + pointItem.PointBatchId + ",";
}
Model.Batch_BatchTrustItem trustItem = new Model.Batch_BatchTrustItem
{
TrustBatchItemId = SQLHelper.GetNewID(typeof(Model.Batch_BatchTrustItem)),
TrustBatchId = trustBatchId,
PointBatchItemId = pointItem.PointBatchItemId,
WeldJointId = pointItem.WeldJointId,
//FilmNum = fileNum,
CreateDate = DateTime.Now
};
Batch_BatchTrustItemService.AddBatchTrustItem(trustItem);
}
//Model.Batch_PointBatchItem pointBatchItem = Funs.DB.Batch_PointBatchItem.FirstOrDefault(e => e.PointBatchItemId == item.PointBatchItemId);
pointItem.IsBuildTrust = true;
Funs.DB.SubmitChanges();
}
// 回写委托批对应点口信息
if (!string.IsNullOrEmpty(toPointBatch))
{
toPointBatch = toPointBatch.Substring(0, toPointBatch.Length - 1);
var updateTrut = BLL.Batch_BatchTrustService.GetBatchTrustById(trustBatchId);
if (updateTrut != null)
{
updateTrut.TopointBatch = toPointBatch;
BLL.Batch_BatchTrustService.UpdateBatchTrust(updateTrut);
}
}
Alert.ShowInTop("委托单已生成!", MessageBoxIcon.Success);
}
else
{
Alert.ShowInTop(error + "不能组成一个委托单!", MessageBoxIcon.Warning);
}
}
else
{
Alert.ShowInTop("请勾选要生成委托单的焊口!", MessageBoxIcon.Warning);
}
}
else
{
ShowNotify(Resources.Lan.NoPrivilegePrompt, MessageBoxIcon.Warning);
return;
}
}
}
}