feat(hjgl): 支持按焊口匹配和回写管线材料

管线材料导入需要关联到具体焊口,并允许按材料编码匹配库存后回写
材料主编码。新增 HJGL_PipeLineMat 的焊口和材料编码字段,材料匹配、
任务生成和出库关系同步按焊口维度处理,避免仅按组件匹配导致材料
范围不准确。
This commit is contained in:
2026-06-11 10:39:58 +08:00
parent c48972cc60
commit 201443e437
15 changed files with 488 additions and 206 deletions
@@ -0,0 +1,3 @@
ALTER table HJGL_PipeLineMat add WeldJointId nvarchar(50);
ALTER table HJGL_PipeLineMat add MaterialCode2 nvarchar(50);
ALTER table Tw_InOutPlanDetail_Relation add WeldJointId nvarchar(50);
+88 -33
View File
@@ -94,14 +94,14 @@ namespace BLL
/// <param name="warehouseCode"></param>
/// <param name="projectId"></param>
/// <returns></returns>
public static List<Tw_PipeMatMatchOutput> GetMatMatchOutput(List<Tw_PipeMatMatchOutput> requiredMaterials, string warehouseCode, string projectId)
public static List<Tw_PipeMatMatchOutput> GetMatMatchOutput(List<Tw_PipeMatMatchOutput> requiredMaterials, string warehouseCode, string projectId, bool matchByMaterialCodeLibCode = false)
{
Tw_MaterialStockOutput twMaterialStockOutput = new Tw_MaterialStockOutput
{
WarehouseCode = warehouseCode,
ProjectId = projectId
};
var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStockOutput).ToList();//获取库存列表
var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStockOutput).ToList();//获取库存列表
// 预扣除出库申请单中状态为待审核/已审核的材料数量
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
@@ -133,7 +133,14 @@ var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStoc
foreach (var material in requiredMaterials)
{
material.Id = Guid.NewGuid().ToString();
var thisMaterialStockNum = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode)?.StockNum ?? 0;
var stock = matchByMaterialCodeLibCode
? stockList
.Where(x => x.Code == material.MaterialCode && (x.StockNum ?? 0) > 0)
.OrderByDescending(x => (x.StockNum ?? 0) >= (material.NeedNum ?? 0))
.ThenBy(x => x.PipeLineMatCode)
.FirstOrDefault()
: stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode);
var thisMaterialStockNum = stock?.StockNum ?? 0;
if (thisMaterialStockNum >= material.NeedNum)
{
material.MatchNum = material.NeedNum;
@@ -147,8 +154,8 @@ var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStoc
material.MatchRateString = Math.Round((decimal)(material.MatchRate ?? 0) * 100, 2).ToString() + "%";
}
material.MatchMaterialCode = stock?.PipeLineMatCode;
//修改stockList对应的库存数量
var stock = stockList.FirstOrDefault(x => x.PipeLineMatCode == material.MaterialCode);
if (stock != null)
{
stock.StockNum -= material.MatchNum;
@@ -246,56 +253,104 @@ var stockList = TwMaterialstockService.GetTw_MaterialStockByModle(twMaterialStoc
/// <param name="pipelineIds"></param>
/// <param name="warehouseCode"></param>
/// <returns></returns>
public static List<Tw_PipeMatMatchOutput> GetPipeMatMatch(string projectId, List<string> pipelineIds, string warehouseCode, Dictionary<string, List<string>> priorityComponents = null)
public static List<Tw_PipeMatMatchOutput> GetPipeMatMatch(string projectId, List<string> pipelineIds, string warehouseCode, Dictionary<string, List<string>> priorityWeldJoints = null)
{
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
{
var results = new List<Tw_PipeMatMatchOutput>();
// 获取所需材料列表
var requiredMaterials = (from x in db.HJGL_PipeLineMat
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
var pipeLineMats = (from x in db.HJGL_PipeLineMat
join z in db.HJGL_Pipeline on x.PipelineId equals z.PipelineId
join m in db.WBS_UnitWork on z.UnitWorkId equals m.UnitWorkId
where z.ProjectId == projectId && pipelineIds.Contains(z.PipelineId) && x.PrefabricatedComponents != "" //x.PrefabricatedComponents!="" 用于筛选非散件材料
select new Tw_PipeMatMatchOutput
{
Id = Guid.NewGuid().ToString(),
PipelineId = x.PipelineId,
PipelineCode = z.PipelineCode,
UnitWorkId = z.UnitWorkId,
UnitWorkName = m.UnitWorkName,
PrefabricatedComponents = x.PrefabricatedComponents,
MaterialCode = x.MaterialCode,
Code = y.Code,
HeatNo = y.HeatNo,
BatchNo = y.BatchNo,
MaterialName = y.MaterialName,
MaterialSpec = y.MaterialSpec,
MaterialUnit = y.MaterialUnit,
MaterialDef = y.MaterialDef,
NeedNum = x.Number,
}
).ToList();
join w in db.HJGL_WeldJoint on x.WeldJointId equals w.WeldJointId into weldJoin
from w in weldJoin.DefaultIfEmpty()
where z.ProjectId == projectId && pipelineIds.Contains(z.PipelineId) && x.PrefabricatedComponents != "" //x.PrefabricatedComponents!="" 用于筛选非散件材料
select new
{
PipeLineMat = x,
PipelineCode = z.PipelineCode,
UnitWorkId = z.UnitWorkId,
UnitWorkName = m.UnitWorkName,
WeldJointCode = w == null ? null : w.WeldJointCode
}).ToList();
var materialCodes = pipeLineMats
.Where(x => !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode))
.Select(x => x.PipeLineMat.MaterialCode)
.Distinct()
.ToList();
var materialCode2s = pipeLineMats
.Where(x => !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2))
.Select(x => x.PipeLineMat.MaterialCode2)
.Distinct()
.ToList();
var libByMaterialCode = db.HJGL_MaterialCodeLib
.Where(x => materialCodes.Contains(x.MaterialCode))
.ToList()
.GroupBy(x => x.MaterialCode)
.ToDictionary(x => x.Key, x => x.First());
var libByCode = db.HJGL_MaterialCodeLib
.Where(x => materialCode2s.Contains(x.Code))
.ToList()
.GroupBy(x => x.Code)
.ToDictionary(x => x.Key, x => x.First());
var requiredMaterials = pipeLineMats.Select(x =>
{
HJGL_MaterialCodeLib lib = null;
if (!string.IsNullOrEmpty(x.PipeLineMat.MaterialCode) && libByMaterialCode.ContainsKey(x.PipeLineMat.MaterialCode))
{
lib = libByMaterialCode[x.PipeLineMat.MaterialCode];
}
else if (!string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) && libByCode.ContainsKey(x.PipeLineMat.MaterialCode2))
{
lib = libByCode[x.PipeLineMat.MaterialCode2];
}
string code = !string.IsNullOrEmpty(x.PipeLineMat.MaterialCode2) ? x.PipeLineMat.MaterialCode2 : lib?.Code;
return new Tw_PipeMatMatchOutput
{
Id = Guid.NewGuid().ToString(),
PipeLineMatId = x.PipeLineMat.PipeLineMatId,
PipelineId = x.PipeLineMat.PipelineId,
PipelineCode = x.PipelineCode,
UnitWorkId = x.UnitWorkId,
UnitWorkName = x.UnitWorkName,
PrefabricatedComponents = x.PipeLineMat.PrefabricatedComponents,
WeldJointId = x.PipeLineMat.WeldJointId,
WeldJointCode = x.WeldJointCode,
MaterialCode = code,
MatchMaterialCode = x.PipeLineMat.MaterialCode,
Code = code,
HeatNo = lib?.HeatNo,
BatchNo = lib?.BatchNo,
MaterialName = lib?.MaterialName,
MaterialSpec = lib?.MaterialSpec,
MaterialUnit = lib?.MaterialUnit,
MaterialDef = lib?.MaterialDef,
NeedNum = x.PipeLineMat.Number,
};
}).ToList();
var newRequiredMaterials = new List<Tw_PipeMatMatchOutput>();
foreach (string id in pipelineIds)
{
var pipelineMaterials = requiredMaterials.Where(x => x.PipelineId == id).ToList();
if (priorityComponents != null && priorityComponents.ContainsKey(id) && priorityComponents[id] != null && priorityComponents[id].Any())
if (priorityWeldJoints != null && priorityWeldJoints.ContainsKey(id) && priorityWeldJoints[id] != null && priorityWeldJoints[id].Any())
{
var components = priorityComponents[id];
var weldJointIds = priorityWeldJoints[id];
newRequiredMaterials.AddRange(pipelineMaterials
.Where(x => components.Contains(x.PrefabricatedComponents))
.OrderBy(x => components.IndexOf(x.PrefabricatedComponents)));
.Where(x => weldJointIds.Contains(x.WeldJointId))
.OrderBy(x => weldJointIds.IndexOf(x.WeldJointId)));
newRequiredMaterials.AddRange(pipelineMaterials
.Where(x => !components.Contains(x.PrefabricatedComponents)));
.Where(x => !weldJointIds.Contains(x.WeldJointId)));
}
else
{
newRequiredMaterials.AddRange(pipelineMaterials);
}
}
results = GetMatMatchOutput(newRequiredMaterials, warehouseCode, projectId);
results = GetMatMatchOutput(newRequiredMaterials, warehouseCode, projectId, true);
return results;
}
}
@@ -102,6 +102,7 @@ namespace BLL
MaterialCode = newtable.MaterialCode,
PrefabricatedComponents = newtable.PrefabricatedComponents,
Number = newtable.Number,
WeldJointId = newtable.WeldJointId,
};
Funs.DB.Tw_InOutPlanDetail_Relation.InsertOnSubmit(table);
Funs.DB.SubmitChanges();
@@ -133,6 +134,7 @@ namespace BLL
table.MaterialCode = newtable.MaterialCode;
table.PrefabricatedComponents = newtable.PrefabricatedComponents;
table.Number = newtable.Number;
table.WeldJointId = newtable.WeldJointId;
Funs.DB.SubmitChanges();
}
@@ -158,56 +160,6 @@ namespace BLL
}
}
public static void InsertByPipeLineMat(string inOutPlanMasterId, List<Model.Tw_PipeLineMat> tw_PipeLineMats)
{
var master = TwInOutplanmasterService.GetById(inOutPlanMasterId);
if (master == null)
{
return;
}
var outMateriaList = from x in tw_PipeLineMats
group x by new { x.MaterialCode, x.MaterialUnit }
into g
select new
{
g.Key.MaterialCode,
planNum = g.Sum(x => x.Number) ?? 0,
MaterialName = g.Key.MaterialUnit,
};
switch (master.Category)
{
case (int)TwConst.Category.:
outMateriaList.Where(x => x.MaterialName.Contains("米"));//管段
break;
case (int)TwConst.Category.:
outMateriaList.Where(x => x.MaterialName.Contains("个"));//管件
break;
}
foreach (var item in outMateriaList)
{
Model.Tw_InOutPlanDetail detail = new Model.Tw_InOutPlanDetail
{
Id = Guid.NewGuid().ToString(),
InOutPlanMasterId = inOutPlanMasterId,
MaterialCode = item.MaterialCode,
PlanNum = item.planNum,
};
TwInOutplandetailService.Add(detail);
}
var twinoutplandetailRelationList = tw_PipeLineMats.Select(x => new Tw_InOutPlanDetail_Relation
{
PipelineId = x.PipelineId,
MaterialCode = x.MaterialCode,
Number = x.Number,
PrefabricatedComponents = x.PrefabricatedComponents,
}).ToList();
TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, inOutPlanMasterId);
}
public static IEnumerable GetPrintListByOutputMasterIds(List<string> outputMasterIds)
{
var q = from x in Funs.DB.Tw_InOutPlanDetail_Relation
+9 -21
View File
@@ -992,36 +992,22 @@ namespace BLL
.Select(e => e.WeldJointId)
.Distinct()
.ToList();
var taskComponents = (from relation in db.HJGL_Pipeline_ComponentJoint
join component in db.HJGL_Pipeline_Component on relation.PipelineComponentId equals component.PipelineComponentId into componentJoin
from componentItem in componentJoin.DefaultIfEmpty()
join weldJointItem in db.HJGL_WeldJoint on relation.WeldJointId equals weldJointItem.WeldJointId
where taskWeldJointIds.Contains(relation.WeldJointId)
&& weldJointItem.PipelineId != null
&& (relation.PipelineComponentCode != null || (componentItem != null && componentItem.PipelineComponentCode != null))
select new
{
PipelineId = weldJointItem.PipelineId,
PipelineComponentCode = componentItem != null && componentItem.PipelineComponentCode != null ? componentItem.PipelineComponentCode : relation.PipelineComponentCode
}).Distinct().ToList();
//领料出库需要排除散件材料
var allMaterDatial = (from x in db.HJGL_PipeLineMat
join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
where pipelineList.Contains(x.PipelineId) && x.PrefabricatedComponents != null
where pipelineList.Contains(x.PipelineId)
&& taskWeldJointIds.Contains(x.WeldJointId)
&& x.PrefabricatedComponents != null
select new
{
x.PipelineId,
x.PrefabricatedComponents,
x.WeldJointId,
x.MaterialCode,
x.Number,
y.MaterialUnit,
}).ToList();
var componentPipelineIds = taskComponents.Select(x => x.PipelineId).Distinct().ToList();
var MaterDatial = taskComponents.Any()
? allMaterDatial.Where(mat => !componentPipelineIds.Contains(mat.PipelineId)
|| taskComponents.Any(component => component.PipelineId == mat.PipelineId
&& component.PipelineComponentCode == mat.PrefabricatedComponents)).ToList()
: allMaterDatial;
var MaterDatial = allMaterDatial;
//var outMateriaList = from x in db.HJGL_PipeLineMat
// join y in db.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
// where pipelineList.Contains(x.PipelineId)
@@ -1077,12 +1063,13 @@ namespace BLL
};
TwInOutplandetailService.Add(detail);
}
var twinoutplandetailRelationList = MaterDatial.Select(x => new Tw_InOutPlanDetail_Relation
var twinoutplandetailRelationList = MaterDatial.Where(x => x.MaterialUnit.Contains("个")).Select(x => new Tw_InOutPlanDetail_Relation
{
PipelineId = x.PipelineId,
MaterialCode = x.MaterialCode,
Number = x.Number,
PrefabricatedComponents = x.PrefabricatedComponents,
WeldJointId = x.WeldJointId,
}).ToList();
TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, table.Id);
}
@@ -1116,12 +1103,13 @@ namespace BLL
};
TwInOutplandetailService.Add(detail);
}
var twinoutplandetailRelationList = MaterDatial.Select(x => new Tw_InOutPlanDetail_Relation
var twinoutplandetailRelationList = MaterDatial.Where(x => x.MaterialUnit.Contains("米")).Select(x => new Tw_InOutPlanDetail_Relation
{
PipelineId = x.PipelineId,
MaterialCode = x.MaterialCode,
Number = x.Number,
PrefabricatedComponents = x.PrefabricatedComponents,
WeldJointId = x.WeldJointId,
}).ToList();
TwInoutplandetailRelationService.AddList(twinoutplandetailRelationList, table.Id);
}
@@ -31,6 +31,8 @@ namespace BLL
{
PipeLineMatId = pipelineMat.PipeLineMatId,
MaterialCode = pipelineMat.MaterialCode,
MaterialCode2 = pipelineMat.MaterialCode2,
WeldJointId = pipelineMat.WeldJointId,
PipelineId = pipelineMat.PipelineId,
Number = pipelineMat.Number,
PrefabricatedComponents = pipelineMat.PrefabricatedComponents,
@@ -50,12 +52,48 @@ namespace BLL
if (newPipelineMat != null)
{
newPipelineMat.MaterialCode = pipelineMat.MaterialCode;
newPipelineMat.MaterialCode2 = pipelineMat.MaterialCode2;
newPipelineMat.WeldJointId = pipelineMat.WeldJointId;
newPipelineMat.PipelineId = pipelineMat.PipelineId;
newPipelineMat.Number = pipelineMat.Number;
newPipelineMat.PrefabricatedComponents = pipelineMat.PrefabricatedComponents;
db.SubmitChanges();
}
}
/// <summary>
/// 根据材料匹配结果反写材料主编码
/// </summary>
/// <param name="matchedMaterials">匹配成功的管线材料</param>
/// <returns>反写数量</returns>
public static int UpdateMaterialCodeByMatchOutputs(IEnumerable<Model.Tw_PipeMatMatchOutput> matchedMaterials)
{
Model.SGGLDB db = Funs.DB;
int count = 0;
foreach (var item in matchedMaterials)
{
if (item == null || string.IsNullOrEmpty(item.PipeLineMatId) || string.IsNullOrEmpty(item.MatchMaterialCode))
{
continue;
}
var pipeLineMat = db.HJGL_PipeLineMat.FirstOrDefault(e => e.PipeLineMatId == item.PipeLineMatId);
if (pipeLineMat == null)
{
continue;
}
pipeLineMat.MaterialCode = item.MatchMaterialCode;
count++;
}
if (count > 0)
{
db.SubmitChanges();
}
return count;
}
/// <summary>
/// 根据unitworkid删除焊口
/// </summary>
+1 -1
View File
@@ -17208,4 +17208,4 @@
<Target Name="AfterBuild">
</Target>
-->
</Project>
</Project>
@@ -119,6 +119,10 @@
FieldType="String" HeaderText="预制组件" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="120px" ColumnID="WeldJointCode" DataField="WeldJointCode" SortField="WeldJointCode"
FieldType="String" HeaderText="焊口号" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField HeaderText="材料主编码" ColumnID="MaterialCode"
DataField="MaterialCode" SortField="MaterialCode" FieldType="String" HeaderTextAlign="Center"
TextAlign="Left" Width="150px">
@@ -178,6 +182,10 @@
<Columns>
<f:RowNumberField EnablePagingNumber="true" HeaderText="序号"
Width="60px" HeaderTextAlign="Center" TextAlign="Center" />
<f:RenderField Width="120px" ColumnID="WeldJointCode" DataField="WeldJointCode" SortField="WeldJointCode"
FieldType="String" HeaderText="焊口号" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField HeaderText="材料主编码" ColumnID="MaterialCode"
DataField="MaterialCode" SortField="MaterialCode" FieldType="String" HeaderTextAlign="Center"
TextAlign="Left" Width="150px">
@@ -235,6 +243,10 @@
<Columns>
<f:RowNumberField EnablePagingNumber="true" HeaderText="序号"
Width="60px" HeaderTextAlign="Center" TextAlign="Center" />
<f:RenderField Width="120px" ColumnID="WeldJointCode" DataField="WeldJointCode" SortField="WeldJointCode"
FieldType="String" HeaderText="焊口号" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField HeaderText="材料主编码" ColumnID="MaterialCode"
DataField="MaterialCode" SortField="MaterialCode" FieldType="String" HeaderTextAlign="Center"
TextAlign="Left" Width="150px">
@@ -195,7 +195,7 @@ namespace FineUIPro.Web.HJGL.DataImport
return (from x in Funs.DB.HJGL_Pipeline
join y in Funs.DB.PTP_PipelineList on x.PipelineId equals y.PipelineId
join z in Funs.DB.PTP_TestPackage on y.PTP_ID equals z.PTP_ID
join m in Funs.DB.HJGL_PipeLineMat.Where(e => e.MaterialCode.Contains(txtMaterialCode.Text.Trim()))
join m in Funs.DB.HJGL_PipeLineMat.Where(e => (e.MaterialCode != null && e.MaterialCode.Contains(txtMaterialCode.Text.Trim())) || (e.MaterialCode2 != null && e.MaterialCode2.Contains(txtMaterialCode.Text.Trim())))
on x.PipelineId equals m.PipelineId into temp
from m in temp.DefaultIfEmpty()
where x.ProjectId == this.CurrUser.LoginProjectId
@@ -241,7 +241,7 @@ namespace FineUIPro.Web.HJGL.DataImport
{
return (from x in Funs.DB.HJGL_Pipeline
join y in Funs.DB.PTP_PipelineList on x.PipelineId equals y.PipelineId
join m in Funs.DB.HJGL_PipeLineMat.Where(e => e.MaterialCode.Contains(txtMaterialCode.Text.Trim()))
join m in Funs.DB.HJGL_PipeLineMat.Where(e => (e.MaterialCode != null && e.MaterialCode.Contains(txtMaterialCode.Text.Trim())) || (e.MaterialCode2 != null && e.MaterialCode2.Contains(txtMaterialCode.Text.Trim())))
on x.PipelineId equals m.PipelineId into temp
from m in temp.DefaultIfEmpty()
where y.PTP_ID == ptpId
@@ -320,11 +320,18 @@ namespace FineUIPro.Web.HJGL.DataImport
/// </summary>
private void BindGrid1(string pipelineId, string unitworkid)
{
string strSql = @" SELECT pipe.PipeLineMatId, lib.MaterialCode,lib.Code,lib.HeatNo,lib.BatchNo,lib.MaterialName,lib.MaterialUnit,
lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,pipe.Number,pipe.PrefabricatedComponents
string strSql = @" SELECT pipe.PipeLineMatId, pipe.MaterialCode,ISNULL(pipe.MaterialCode2, lib.Code) AS Code,lib.HeatNo,lib.BatchNo,
ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName,
ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit,
ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec,
ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade,
ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef,
pipe.Number,pipe.PrefabricatedComponents,weld.WeldJointCode
FROM dbo.HJGL_PipeLineMat pipe
LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode
LEFT JOIN HJGL_Pipeline line ON pipe.PipelineId=line.PipelineId
OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode
LEFT JOIN dbo.HJGL_WeldJoint weld ON weld.WeldJointId = pipe.WeldJointId
WHERE line.UnitWorkId=@UnitWorkId and line.PipeArea='1' and pipe.PrefabricatedComponents !='' ";
List<SqlParameter> listStr = new List<SqlParameter>();
//if (!string.IsNullOrEmpty(txtMaterialCode.Text.Trim()))
@@ -340,7 +347,7 @@ namespace FineUIPro.Web.HJGL.DataImport
}
if (!string.IsNullOrEmpty(txtMaterialCode2.Text.Trim()))
{
strSql += " and lib.MaterialCode like @MaterialCode ";
strSql += " and (pipe.MaterialCode2 like @MaterialCode or lib.MaterialCode like @MaterialCode or lib.Code like @MaterialCode) ";
listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode2.Text.Trim() + "%"));
}
@@ -355,11 +362,18 @@ namespace FineUIPro.Web.HJGL.DataImport
}
private void BindGrid2(string pipelineId, string unitworkid)
{
string strSql = @" SELECT pipe.PipeLineMatId, lib.MaterialCode,lib.Code,lib.HeatNo,lib.BatchNo,lib.MaterialName,lib.MaterialUnit,
lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,pipe.Number
string strSql = @" SELECT pipe.PipeLineMatId, pipe.MaterialCode,ISNULL(pipe.MaterialCode2, lib.Code) AS Code,lib.HeatNo,lib.BatchNo,
ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName,
ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit,
ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec,
ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade,
ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef,
pipe.Number,weld.WeldJointCode
FROM dbo.HJGL_PipeLineMat pipe
LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode
LEFT JOIN HJGL_Pipeline line ON pipe.PipelineId=line.PipelineId
OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode
LEFT JOIN dbo.HJGL_WeldJoint weld ON weld.WeldJointId = pipe.WeldJointId
WHERE line.UnitWorkId=@UnitWorkId and line.PipeArea='2' ";
List<SqlParameter> listStr = new List<SqlParameter>();
if (!string.IsNullOrEmpty(pipelineId))
@@ -370,7 +384,7 @@ namespace FineUIPro.Web.HJGL.DataImport
}
if (!string.IsNullOrEmpty(txtMaterialCode2.Text.Trim()))
{
strSql += " and lib.MaterialCode like @MaterialCode ";
strSql += " and (pipe.MaterialCode2 like @MaterialCode or lib.MaterialCode like @MaterialCode or lib.Code like @MaterialCode) ";
listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode2.Text.Trim() + "%"));
}
@@ -386,11 +400,18 @@ namespace FineUIPro.Web.HJGL.DataImport
private void BindGrid3(string pipelineId, string unitworkid)
{
string strSql = @" SELECT pipe.PipeLineMatId, lib.MaterialCode,lib.Code,lib.HeatNo,lib.BatchNo,lib.MaterialName,lib.MaterialUnit,
lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,pipe.Number,pipe.PrefabricatedComponents
string strSql = @" SELECT pipe.PipeLineMatId, pipe.MaterialCode,ISNULL(pipe.MaterialCode2, lib.Code) AS Code,lib.HeatNo,lib.BatchNo,
ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName,
ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit,
ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec,
ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade,
ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef,
pipe.Number,pipe.PrefabricatedComponents,weld.WeldJointCode
FROM dbo.HJGL_PipeLineMat pipe
LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode
LEFT JOIN HJGL_Pipeline line ON pipe.PipelineId=line.PipelineId
OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode
LEFT JOIN dbo.HJGL_WeldJoint weld ON weld.WeldJointId = pipe.WeldJointId
WHERE line.UnitWorkId=@UnitWorkId and line.PipeArea='1' and (pipe.PrefabricatedComponents is null or pipe.PrefabricatedComponents='') ";
List<SqlParameter> listStr = new List<SqlParameter>();
//if (!string.IsNullOrEmpty(txtMaterialCode.Text.Trim()))
@@ -406,7 +427,7 @@ namespace FineUIPro.Web.HJGL.DataImport
}
if (!string.IsNullOrEmpty(txtMaterialCode2.Text.Trim()))
{
strSql += " and lib.MaterialCode like @MaterialCode ";
strSql += " and (pipe.MaterialCode2 like @MaterialCode or lib.MaterialCode like @MaterialCode or lib.Code like @MaterialCode) ";
listStr.Add(new SqlParameter("@MaterialCode", "%" + txtMaterialCode2.Text.Trim() + "%"));
}
@@ -138,7 +138,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
Model.ResponeData responeData = new Model.ResponeData();
List<string> result = new List<string>();
if (count < 6)
if (count < 5)
{
responeData.code = 0;
responeData.message = "导入Excel格式错误!Excel只有" + count.ToString().Trim() + "列";
@@ -182,43 +182,48 @@ namespace FineUIPro.Web.HJGL.WeldingManage
if (pds[i].C != null && !string.IsNullOrEmpty(pds[i].C.ToString()))
{
string materialCode = pds[i].C.ToString().Trim();
string furnaceNo = pds[i].D == null ? string.Empty : pds[i].D.ToString().Trim();
string batchNo = pds[i].E == null ? string.Empty : pds[i].E.ToString().Trim();
if (pds[i].D == null || string.IsNullOrEmpty(pds[i].D.ToString()))
if (!string.IsNullOrEmpty(item.PipelineId))
{
result.Add((i + 2) + "Line, [炉号] 不能为空</br>");
}
if (pds[i].E == null || string.IsNullOrEmpty(pds[i].E.ToString()))
{
result.Add((i + 2) + "Line, [批号] 不能为空</br>");
}
if (!string.IsNullOrEmpty(materialCode) && !string.IsNullOrEmpty(furnaceNo) && !string.IsNullOrEmpty(batchNo))
{
string fullMaterialCode = materialCode + "-" + furnaceNo + "-" + batchNo;
var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.MaterialCode == fullMaterialCode select x;
if (lib.Count() > 0)
string weldJointCode = pds[i].C.ToString().Trim();
var weldJoint = BLL.WeldJointService.GetWeldJointsByWeldJointCode(item.PipelineId, weldJointCode);
if (weldJoint != null)
{
item.MaterialCode = fullMaterialCode;
item.WeldJointId = weldJoint.WeldJointId;
}
else
{
result.Add("不存在此材料:" + fullMaterialCode);
result.Add("第" + (i + 2).ToString() + "行,当前管线不存在此焊口号-" + weldJointCode + "</br>");
}
}
}
else
{
result.Add((i + 2) + "Line, [焊口号] 不能为空</br>");
}
if (pds[i].D != null && !string.IsNullOrEmpty(pds[i].D.ToString()))
{
string materialCode = pds[i].D.ToString().Trim();
var lib = from x in Funs.DB.HJGL_MaterialCodeLib where x.Code == materialCode select x;
if (lib.Count() > 0)
{
item.MaterialCode2 = materialCode;
}
else
{
result.Add("第" + (i + 2).ToString() + "行,材料编码库不存在此材料编码-" + materialCode + "</br>");
}
}
else
{
result.Add((i + 2) + "Line, [材料编码] 不能为空</br>");
}
if (pds[i].F != null && !string.IsNullOrEmpty(pds[i].F.ToString()))
if (pds[i].E != null && !string.IsNullOrEmpty(pds[i].E.ToString()))
{
try
{
var number = Funs.GetNewDecimal(pds[i].F.ToString());
var number = Funs.GetNewDecimal(pds[i].E.ToString());
item.Number = number;
}
catch (Exception)
@@ -247,7 +252,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
// result.Add((i + 2) + "Line, [预制组件] 不能为空</br>");
}
}
var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode == item.MaterialCode && x.PrefabricatedComponents == item.PrefabricatedComponents);
var model = matList.Where(x => x.PipelineId == item.PipelineId && x.MaterialCode2 == item.MaterialCode2 && x.WeldJointId == item.WeldJointId && x.PrefabricatedComponents == item.PrefabricatedComponents);
if (model.Count() == 0)
{
matList.Add(item);
@@ -478,7 +483,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
{
foreach (var item in matList)
{
var pipeLineMat = from x in Funs.DB.HJGL_PipeLineMat where x.MaterialCode == item.MaterialCode && x.PipelineId == item.PipelineId && x.PrefabricatedComponents == item.PrefabricatedComponents select x;
var pipeLineMat = from x in Funs.DB.HJGL_PipeLineMat
where x.MaterialCode2 == item.MaterialCode2
&& x.WeldJointId == item.WeldJointId
&& x.PipelineId == item.PipelineId
&& x.PrefabricatedComponents == item.PrefabricatedComponents
select x;
if (pipeLineMat.Count() == 0 || pipeLineMat == null)
{
item.PipeLineMatId = SQLHelper.GetNewID(typeof(Model.HJGL_PipeLineMat));
@@ -486,7 +496,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
else
{
item.PipeLineMatId = pipeLineMat.First().PipeLineMatId;
var oldPipeLineMat = pipeLineMat.First();
item.PipeLineMatId = oldPipeLineMat.PipeLineMatId;
if (string.IsNullOrEmpty(item.MaterialCode))
{
item.MaterialCode = oldPipeLineMat.MaterialCode;
}
BLL.PipelineMatService.UpdatePipeLineMat(item);
}
BLL.HJGL_PipelineComponentService.SyncPipelineComponentByMatId(item.PipeLineMatId);
@@ -27,16 +27,19 @@
}
.f-grid-row.red {
background-color: red;
color: red;
font-weight: bold;
}
.f-grid-row.green {
background-color: green;
color: green;
font-weight: bold;
}
.f-grid-row.priority {
background-color: #1e88e5;
/* background-color: #1e88e5;*/
color: #fff;
font-weight: bold;
}
.f-grid-row {
@@ -143,10 +146,12 @@
<f:Toolbar ID="Toolbar3" Position="Top" runat="server" ToolbarAlign="Left">
<Items>
<f:Label ID="lbRate" runat="server" LabelWidth="100px" Hidden="true"></f:Label>
<f:Label ID="lbNote" runat="server" LabelWidth="100px" Text="绿色为匹配率100%,红色为匹配率小于100%,蓝色为手动优先组件"></f:Label>
<f:Button ID="btnPriorityComponents" Text="优先匹配选中组件" Icon="TabGo" runat="server" OnClick="btnPriorityComponents_Click">
<f:Label ID="lbNote" runat="server" LabelWidth="100px" Text="绿色为匹配率100%,红色为匹配率小于100%,蓝色为手动优先焊口"></f:Label>
<f:Button ID="btnPriorityComponents" Text="优先匹配选中焊口" Icon="TabGo" runat="server" OnClick="btnPriorityComponents_Click">
</f:Button>
<f:Button ID="btnGenTask" ToolTip="生成任务单" Icon="ApplicationViewIcons" runat="server" OnClick="btnGenTask_Click" ConfirmText="确定生成任务单吗?">
<f:Button ID="btnConfirmMaterialCode" Text="保存匹配结果" Icon="SystemSave" runat="server" OnClick="btnConfirmMaterialCode_Click" ConfirmText="确定根据当前匹配结果反写材料主编码吗?">
</f:Button>
<f:Button ID="btnGenTask" ToolTip="生成任务单" Text="生成任务单" Icon="ApplicationViewIcons" runat="server" OnClick="btnGenTask_Click" ConfirmText="确定生成任务单吗?">
</f:Button>
<f:CheckBox ID="cbSelectCom" ShowLabel="false" runat="server" Text="默认勾选匹配100%" Checked="true">
</f:CheckBox>
@@ -181,7 +186,7 @@
<Items>
<f:Grid ID="Grid1" ShowBorder="true" ShowHeader="false" Title="材料匹配明细" EnableRowClickEvent="true"
EnableCollapse="true" runat="server" BoxFlex="1" DataKeyNames="Id,PipelineId,PrefabricatedComponents" ForceFit="true"
EnableCollapse="true" runat="server" BoxFlex="1" DataKeyNames="Id,PipelineId,PrefabricatedComponents,WeldJointId" ForceFit="true"
EnableColumnLines="true" DataIDField="Id" AllowSorting="true" OnRowDataBound="Grid1_RowDataBound"
SortField="Id" SortDirection="ASC" OnSort="Grid1_Sort" EnableCheckBoxSelect="true">
<Columns>
@@ -193,10 +198,18 @@
FieldType="String" HeaderText="预制组件号" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="120px" ColumnID="WeldJointCode" DataField="WeldJointCode" SortField="WeldJointCode"
FieldType="String" HeaderText="焊口号" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="120px" ColumnID="MaterialCode" DataField="MaterialCode" SortField="MaterialCode"
FieldType="String" HeaderText="材料编码" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="150px" ColumnID="MatchMaterialCode" DataField="MatchMaterialCode" SortField="MatchMaterialCode"
FieldType="String" HeaderText="匹配主编码" HeaderTextAlign="Center"
TextAlign="Left">
</f:RenderField>
<f:RenderField Width="100px" ColumnID="MaterialName" DataField="MaterialName" SortField="MaterialName"
FieldType="String" HeaderText="材料名称" HeaderTextAlign="Center"
TextAlign="Left">
@@ -70,21 +70,21 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
}
public Dictionary<string, HashSet<string>> priorityComponents
public Dictionary<string, HashSet<string>> priorityWeldJoints
{
get
{
var value = ViewState["priorityComponents"] as Dictionary<string, HashSet<string>>;
var value = ViewState["priorityWeldJoints"] as Dictionary<string, HashSet<string>>;
if (value == null)
{
value = new Dictionary<string, HashSet<string>>();
ViewState["priorityComponents"] = value;
ViewState["priorityWeldJoints"] = value;
}
return value;
}
set
{
ViewState["priorityComponents"] = value;
ViewState["priorityWeldJoints"] = value;
}
}
@@ -104,7 +104,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
; HJGL_MaterialService.materialStockItems_FIELD = new List<Model.MaterialStockItem>();
HJGL_MaterialService.materialStockItems_SHOP = new List<Model.MaterialStockItem>();
dicSeclectPipeLine = new Dictionary<string, string>();
priorityComponents = new Dictionary<string, HashSet<string>>();
priorityWeldJoints = new Dictionary<string, HashSet<string>>();
var pipeline = (from x in Funs.DB.HJGL_Pipeline
where x.ProjectId == this.CurrUser.LoginProjectId
select x.FlowingSection).Distinct().ToList();
@@ -377,14 +377,25 @@ namespace FineUIPro.Web.HJGL.WeldingManage
#region
private void BindGrid()
{
string strSql = @"SELECT lib.MaterialCode,lib.MaterialName,lib.MaterialUnit,
lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef,sum(pipe.Number)as Number ,
string strSql = @"SELECT ISNULL(pipe.MaterialCode2, lib.Code) AS MaterialCode,
ISNULL(lib.MaterialName, libCode.MaterialName) AS MaterialName,
ISNULL(lib.MaterialUnit, libCode.MaterialUnit) AS MaterialUnit,
ISNULL(lib.MaterialSpec, libCode.MaterialSpec) AS MaterialSpec,
ISNULL(lib.MaterialMade, libCode.MaterialMade) AS MaterialMade,
ISNULL(lib.MaterialDef, libCode.MaterialDef) AS MaterialDef,
sum(pipe.Number)as Number ,
'0' as MatchNum,'否' AS CheckState
FROM dbo.HJGL_PipeLineMat pipe
LEFT JOIN dbo.HJGL_MaterialCodeLib lib ON lib.MaterialCode = pipe.MaterialCode
LEFT JOIN dbo.HJGL_Pipeline line ON line.PipelineId = pipe.PipelineId
OUTER APPLY (SELECT TOP 1 * FROM dbo.HJGL_MaterialCodeLib codeLib WHERE codeLib.ProjectId=line.ProjectId AND codeLib.Code=pipe.MaterialCode2 ORDER BY codeLib.MaterialCode) libCode
WHERE PipelineId=@PipelineId
group by lib.MaterialCode,lib.MaterialName,lib.MaterialUnit,
lib.MaterialSpec,lib.MaterialMade,lib.MaterialDef ";
group by ISNULL(pipe.MaterialCode2, lib.Code),
ISNULL(lib.MaterialName, libCode.MaterialName),
ISNULL(lib.MaterialUnit, libCode.MaterialUnit),
ISNULL(lib.MaterialSpec, libCode.MaterialSpec),
ISNULL(lib.MaterialMade, libCode.MaterialMade),
ISNULL(lib.MaterialDef, libCode.MaterialDef) ";
List<SqlParameter> listStr = new List<SqlParameter>();
listStr.Add(new SqlParameter("@PipelineId", this.tvControlItem.SelectedNodeID));
SqlParameter[] parameter = listStr.ToArray();
@@ -394,7 +405,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
Grid1.DataSource = dt;
Grid1.DataBind();
}
void BindGrid2()
void BindGrid2(IEnumerable<string> keepSelectedPipelineIds = null)
{
//var result = tw_PipeMatMatchOutputs
// .GroupBy(item => new { item.PipelineId, item.PipelineCode,item.UnitWorkName }) // 按 PipelineId 和 PipelineCode 分组
@@ -424,6 +435,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
Rate = Math.Round((decimal)output.Average(item => item.MatchRate) * 100, 2);
lbRate.Text = "匹配率:" + Rate.ToString() + "%";
}*/
var keepSelectedList = keepSelectedPipelineIds == null ? new List<string>() : keepSelectedPipelineIds.Where(x => !string.IsNullOrEmpty(x)).Distinct().ToList();
var selectList = new List<string>();
for (int i = 0; i < Grid2.Rows.Count; i++)
{
@@ -443,7 +455,12 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
if (cbSelectCom.Checked)
{
Grid2.SelectedRowIDArray = selectList.ToArray();
selectList.AddRange(keepSelectedList);
Grid2.SelectedRowIDArray = selectList.Distinct().ToArray();
}
else if (keepSelectedList.Any())
{
Grid2.SelectedRowIDArray = keepSelectedList.ToArray();
}
}
@@ -486,7 +503,9 @@ namespace FineUIPro.Web.HJGL.WeldingManage
private void BindMaterialDetail(string pipelineId)
{
var tb = tw_PipeMatMatchOutputs.Where(x => x.PipelineId == pipelineId).ToList();
var tb = GetNoTaskMaterialDetails()
.Where(x => x.PipelineId == pipelineId)
.ToList();
Grid1.DataSource = tb;
Grid1.DataBind();
@@ -499,7 +518,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
continue;
}
if (IsPriorityComponent(model.PipelineId, model.PrefabricatedComponents))
if (IsPriorityWeldJoint(model.PipelineId, model.WeldJointId))
{
Grid1.Rows[i].RowCssClass = "priority";
selectList.Add(model.Id);
@@ -513,30 +532,54 @@ namespace FineUIPro.Web.HJGL.WeldingManage
Grid1.SelectedRowIDArray = selectList.ToArray();
}
private bool IsPriorityComponent(string pipelineId, string prefabricatedComponents)
private List<Tw_PipeMatMatchOutput> GetNoTaskMaterialDetails()
{
return !string.IsNullOrEmpty(pipelineId)
&& !string.IsNullOrEmpty(prefabricatedComponents)
&& priorityComponents.ContainsKey(pipelineId)
&& priorityComponents[pipelineId].Contains(prefabricatedComponents);
var matchOutputs = tw_PipeMatMatchOutputs ?? new List<Tw_PipeMatMatchOutput>();
var weldJointIds = matchOutputs
.Where(x => !string.IsNullOrEmpty(x.WeldJointId))
.Select(x => x.WeldJointId)
.Distinct()
.ToList();
if (!weldJointIds.Any())
{
return matchOutputs;
}
var taskWeldJointIds = Funs.DB.HJGL_WeldTask
.Where(x => weldJointIds.Contains(x.WeldJointId))
.Select(x => x.WeldJointId)
.Distinct()
.ToList();
return matchOutputs
.Where(x => string.IsNullOrEmpty(x.WeldJointId) || !taskWeldJointIds.Contains(x.WeldJointId))
.ToList();
}
private Dictionary<string, List<string>> GetPriorityComponentList()
private bool IsPriorityWeldJoint(string pipelineId, string weldJointId)
{
return priorityComponents
return !string.IsNullOrEmpty(pipelineId)
&& !string.IsNullOrEmpty(weldJointId)
&& priorityWeldJoints.ContainsKey(pipelineId)
&& priorityWeldJoints[pipelineId].Contains(weldJointId);
}
private Dictionary<string, List<string>> GetPriorityWeldJointList()
{
return priorityWeldJoints
.Where(x => x.Value != null && x.Value.Any())
.ToDictionary(x => x.Key, x => x.Value.ToList());
}
private void RefreshMatchResult()
{
var keepSelectedPipelineIds = Grid2.SelectedRowIDArray == null ? new List<string>() : Grid2.SelectedRowIDArray.ToList();
tw_PipeMatMatchOutputs = TwArrivalStatisticsService.GetPipeMatMatch(
this.CurrUser.LoginProjectId,
dicSeclectPipeLine.Keys.ToList(),
drpWarehouse.SelectedValue,
GetPriorityComponentList());
GetPriorityWeldJointList());
BindGrid3();
BindGrid2();
BindGrid2(keepSelectedPipelineIds);
}
protected void Grid2_RowClick(object sender, GridRowClickEventArgs e)
@@ -692,7 +735,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
foreach (string rowId in Grid3.SelectedRowIDArray)
{
dicSeclectPipeLine.Remove(rowId);
priorityComponents.Remove(rowId);
priorityWeldJoints.Remove(rowId);
var node = tvControlItem.FindNode(rowId);
if (node != null)
{
@@ -713,38 +756,85 @@ namespace FineUIPro.Web.HJGL.WeldingManage
return;
}
var selectedComponents = new HashSet<string>();
var selectedWeldJoints = new HashSet<string>();
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
if (Grid1.DataKeys[rowIndex].Length < 3)
if (Grid1.DataKeys[rowIndex].Length < 4)
{
continue;
}
string pipelineId = Grid1.DataKeys[rowIndex][1]?.ToString();
string componentCode = Grid1.DataKeys[rowIndex][2]?.ToString();
if (pipelineId == selectedPipelineId && !string.IsNullOrEmpty(componentCode))
string weldJointId = Grid1.DataKeys[rowIndex][3]?.ToString();
if (pipelineId == selectedPipelineId && !string.IsNullOrEmpty(weldJointId))
{
selectedComponents.Add(componentCode);
selectedWeldJoints.Add(weldJointId);
}
}
if (selectedComponents.Any())
if (selectedWeldJoints.Any())
{
priorityComponents[selectedPipelineId] = selectedComponents;
priorityWeldJoints[selectedPipelineId] = selectedWeldJoints;
}
else
{
priorityComponents.Remove(selectedPipelineId);
priorityWeldJoints.Remove(selectedPipelineId);
}
var keepSelectedPipelineIds = Grid2.SelectedRowIDArray == null ? new List<string>() : Grid2.SelectedRowIDArray.ToList();
if (!keepSelectedPipelineIds.Contains(selectedPipelineId))
{
keepSelectedPipelineIds.Add(selectedPipelineId);
}
RefreshMatchResult();
Grid2.SelectedRowIDArray = keepSelectedPipelineIds.Distinct().ToArray();
BindMaterialDetail(selectedPipelineId);
}
protected void btnConfirmMaterialCode_Click(object sender, EventArgs e)
{
if (Grid2.SelectedRowIDArray == null || !Grid2.SelectedRowIDArray.Any())
{
ShowNotify("请先选择需要保存匹配结果的管线!", MessageBoxIcon.Warning);
return;
}
if (tw_PipeMatMatchOutputs == null || !tw_PipeMatMatchOutputs.Any())
{
RefreshMatchResult();
}
var selectedPipelineIds = Grid2.SelectedRowIDArray.ToList();
var matchedMaterials = tw_PipeMatMatchOutputs
.Where(x => selectedPipelineIds.Contains(x.PipelineId))
.ToList();
if (!matchedMaterials.Any())
{
ShowNotify("未找到保存的材料匹配明细!", MessageBoxIcon.Warning);
return;
}
var invalidMaterials = matchedMaterials
.Where(x => string.IsNullOrEmpty(x.MatchMaterialCode) || (x.MatchRate ?? 0) < 1)
.ToList();
/* if (invalidMaterials.Any())
{
ShowNotify("存在未100%匹配的材料,不能反写材料主编码!", MessageBoxIcon.Warning);
return;
}*/
int count = BLL.PipelineMatService.UpdateMaterialCodeByMatchOutputs(matchedMaterials);
ShowNotify("已保存材料主编码" + count.ToString() + "条!", MessageBoxIcon.Success);
RefreshMatchResult();
if (Grid2.SelectedRowIDArray.Any())
{
BindMaterialDetail(Grid2.SelectedRowIDArray.First());
}
}
protected void btnGenTask_Click(object sender, EventArgs e)
{
if (Grid2.SelectedRowIDArray.Count() > 0)
if (GetSelectedWeldJointIdsFromGrid1().Any())
{
if (SaveTask())
{
@@ -760,23 +850,30 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
else
{
ShowNotify("请先选择需要发起任单的管线", MessageBoxIcon.Warning);
ShowNotify("请先在材料匹配明细中选择需要生成任务单的焊口", MessageBoxIcon.Warning);
}
}
private bool SaveTask()
{
var selectedWeldJointIds = GetSelectedWeldJointIdsFromGrid1();
if (!selectedWeldJointIds.Any())
{
ShowNotify("请先在材料匹配明细中选择需要生成任务单的焊口!", MessageBoxIcon.Warning);
return false;
}
var weldingRods = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "2" select x;
var weldingWires = from x in Funs.DB.Base_Consumables where x.ConsumablesType == "1" select x;
var selectedWeldJointIdList = selectedWeldJointIds.ToList();
var selectRowId = (from x in Funs.DB.View_HJGL_NoWeldJointFind
where Grid2.SelectedRowIDArray.ToList().Contains(x.PipelineId) && x.WeldingDailyId == null &&
where selectedWeldJointIdList.Contains(x.WeldJointId) && x.WeldingDailyId == null &&
x.WeldTaskId == null && x.WeldingMethodCode != null
select x).ToList();
Dictionary<string, string> unitworkTaskCode = new Dictionary<string, string>();
Dictionary<string, string> unitworkSerialNumber = new Dictionary<string, string>();
Dictionary<int, string> matchPipeline = new Dictionary<int, string>();
foreach (var rowIndex in Grid2.SelectedRowIndexArray)
for (int rowIndex = 0; rowIndex < Grid2.Rows.Count; rowIndex++)
{
matchPipeline.Add(rowIndex + 1, Grid2.Rows[rowIndex].RowID);
}
@@ -784,16 +881,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
{
selectRowId = selectRowId.Where(x => x.JointAttribute == "预制口").ToList();
}
var priorityWeldJointIds = GetPriorityWeldJointIds(Grid2.SelectedRowIDArray.ToList());
if (priorityWeldJointIds.Any())
{
if (priorityWeldJointIds.Any(x => !x.Value.Any()))
{
ShowNotify("选中组件未找到关联焊口,无法按组件生成任务单!", MessageBoxIcon.Warning);
return false;
}
selectRowId = selectRowId.Where(x => !priorityWeldJointIds.ContainsKey(x.PipelineId) || priorityWeldJointIds[x.PipelineId].Contains(x.WeldJointId)).ToList();
}
if (!selectRowId.Any())
{
ShowNotify("未找到可生成任务单的焊口!", MessageBoxIcon.Warning);
@@ -909,28 +996,41 @@ namespace FineUIPro.Web.HJGL.WeldingManage
return true;
}
private HashSet<string> GetSelectedWeldJointIdsFromGrid1()
{
var selectedWeldJointIds = new HashSet<string>();
if (Grid1.SelectedRowIndexArray == null)
{
return selectedWeldJointIds;
}
foreach (int rowIndex in Grid1.SelectedRowIndexArray)
{
if (Grid1.DataKeys[rowIndex].Length < 4)
{
continue;
}
string weldJointId = Grid1.DataKeys[rowIndex][3]?.ToString();
if (!string.IsNullOrEmpty(weldJointId))
{
selectedWeldJointIds.Add(weldJointId);
}
}
return selectedWeldJointIds;
}
private Dictionary<string, HashSet<string>> GetPriorityWeldJointIds(List<string> selectedPipelineIds)
{
var result = new Dictionary<string, HashSet<string>>();
var selectedPriority = priorityComponents
var selectedPriority = priorityWeldJoints
.Where(x => selectedPipelineIds.Contains(x.Key) && x.Value != null && x.Value.Any())
.ToList();
foreach (var item in selectedPriority)
{
string pipelineId = item.Key;
var componentCodes = item.Value.ToList();
var weldJointIds = (from joint in Funs.DB.HJGL_Pipeline_ComponentJoint
join weldJoint in Funs.DB.HJGL_WeldJoint on joint.WeldJointId equals weldJoint.WeldJointId
join component in Funs.DB.HJGL_Pipeline_Component on joint.PipelineComponentId equals component.PipelineComponentId into componentJoin
from componentItem in componentJoin.DefaultIfEmpty()
where joint.WeldJointId != null
&& weldJoint.PipelineId == pipelineId
&& ((componentItem != null && componentCodes.Contains(componentItem.PipelineComponentCode))
|| componentCodes.Contains(joint.PipelineComponentCode))
select joint.WeldJointId).Distinct().ToList();
result[pipelineId] = new HashSet<string>(weldJointIds);
result[item.Key] = new HashSet<string>(item.Value);
}
return result;
@@ -266,6 +266,15 @@ namespace FineUIPro.Web.HJGL.WeldingManage
/// </remarks>
protected global::FineUIPro.Button btnPriorityComponents;
/// <summary>
/// btnConfirmMaterialCode 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.Button btnConfirmMaterialCode;
/// <summary>
/// btnGenTask 控件。
/// </summary>
+4
View File
@@ -11,12 +11,16 @@ namespace Model
public class Tw_PipeMatMatchOutput
{
public string Id { get; set; }
public string PipeLineMatId { get; set; }
public string PipelineId { get; set; }
public string PipelineCode { get; set; }
public string UnitWorkId { get; set; }
public string UnitWorkName { get; set; }
public string PrefabricatedComponents { get; set; }
public string WeldJointId { get; set; }
public string WeldJointCode { get; set; }
public string MaterialCode { get; set; }
public string MatchMaterialCode { get; set; }
public string Code { get; set; }
public string HeatNo { get; set; }
public string BatchNo { get; set; }
+72
View File
@@ -105869,6 +105869,10 @@ namespace Model
private System.Nullable<bool> _IsLooseParts;
private string _WeldJointId;
private string _MaterialCode2;
private EntityRef<HJGL_MaterialCodeLib> _HJGL_MaterialCodeLib;
private EntityRef<HJGL_Pipeline> _HJGL_Pipeline;
@@ -105889,6 +105893,10 @@ namespace Model
partial void OnPrefabricatedComponentsChanged();
partial void OnIsLoosePartsChanging(System.Nullable<bool> value);
partial void OnIsLoosePartsChanged();
partial void OnWeldJointIdChanging(string value);
partial void OnWeldJointIdChanged();
partial void OnMaterialCode2Changing(string value);
partial void OnMaterialCode2Changed();
#endregion
public HJGL_PipeLineMat()
@@ -106026,6 +106034,46 @@ namespace Model
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WeldJointId", DbType="NVarChar(50)")]
public string WeldJointId
{
get
{
return this._WeldJointId;
}
set
{
if ((this._WeldJointId != value))
{
this.OnWeldJointIdChanging(value);
this.SendPropertyChanging();
this._WeldJointId = value;
this.SendPropertyChanged("WeldJointId");
this.OnWeldJointIdChanged();
}
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_MaterialCode2", DbType="NVarChar(50)")]
public string MaterialCode2
{
get
{
return this._MaterialCode2;
}
set
{
if ((this._MaterialCode2 != value))
{
this.OnMaterialCode2Changing(value);
this.SendPropertyChanging();
this._MaterialCode2 = value;
this.SendPropertyChanged("MaterialCode2");
this.OnMaterialCode2Changed();
}
}
}
[global::System.Data.Linq.Mapping.AssociationAttribute(Name="FK_HJGL_PipeLineMat_HJGL_MaterialCodeLib", Storage="_HJGL_MaterialCodeLib", ThisKey="MaterialCode", OtherKey="MaterialCode", IsForeignKey=true)]
public HJGL_MaterialCodeLib HJGL_MaterialCodeLib
{
@@ -277039,6 +277087,8 @@ namespace Model
private System.Nullable<decimal> _Number;
private string _WeldJointId;
#region
partial void OnLoaded();
partial void OnValidate(System.Data.Linq.ChangeAction action);
@@ -277055,6 +277105,8 @@ namespace Model
partial void OnPrefabricatedComponentsChanged();
partial void OnNumberChanging(System.Nullable<decimal> value);
partial void OnNumberChanged();
partial void OnWeldJointIdChanging(string value);
partial void OnWeldJointIdChanged();
#endregion
public Tw_InOutPlanDetail_Relation()
@@ -277182,6 +277234,26 @@ namespace Model
}
}
[global::System.Data.Linq.Mapping.ColumnAttribute(Storage="_WeldJointId", DbType="NVarChar(50)")]
public string WeldJointId
{
get
{
return this._WeldJointId;
}
set
{
if ((this._WeldJointId != value))
{
this.OnWeldJointIdChanging(value);
this.SendPropertyChanging();
this._WeldJointId = value;
this.SendPropertyChanged("WeldJointId");
this.OnWeldJointIdChanged();
}
}
}
public event PropertyChangingEventHandler PropertyChanging;
public event PropertyChangedEventHandler PropertyChanged;