refactor(hjgl): 整理历史资源并完善焊接查询

归档数据库版本脚本并清理历史地图资源,补充焊口查询和焊接任务相关逻辑,降低项目资源维护成本并完善焊接业务查询。
This commit is contained in:
2026-09-22 14:22:04 +08:00
parent dc19b6d6b6
commit 2105a7c6d6
1321 changed files with 3432 additions and 47368 deletions
@@ -24,8 +24,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
private const string WeldingRodConsumablesType = "2";
private const string WeldingWireConsumablesType = "1";
private const string ManualWeldingMode = "手动";
private const string CoverMaterialClassFe1 = "Fe-1";
private const string CoverMaterialClassFe3 = "Fe-3";
public string WarehouseId
{
@@ -1019,7 +1017,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
/// 清除 Grid2 当前选中管线中已反写到管线材料表的材料主编码。
/// </summary>
/// <param name="sender">事件源。</param>
/// <param name="e">事件参数。</param>
/// <param name="e">事件参数。</param>WeldTask
protected void btnClearMaterialCode_Click(object sender, EventArgs e)
{
if (Grid2.SelectedRowIDArray == null || !Grid2.SelectedRowIDArray.Any())
@@ -1046,7 +1044,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
int count = BLL.PipelineMatService.ClearMaterialCodeByPipeLineMatIds(pipeLineMatIds);
ShowNotify("已清除材料主编码" + count.ToString() + "条!", MessageBoxIcon.Success);
ShowNotify("已清除材料主编码" + count.ToString() + "条,已生成任务单的焊口已跳过!", MessageBoxIcon.Success);
RefreshMatchResult();
if (Grid2.SelectedRowIDArray.Any())
{
@@ -1154,7 +1152,7 @@ namespace FineUIPro.Web.HJGL.WeldingManage
NewTask.PipeLineSortIndex = matchPipeline.FirstOrDefault(x => x.Value == weldJoint.PipelineId).Key;
NewTask.WeldingRod = weldJoint.WeldingRod;
NewTask.WeldingWire = weldJoint.WeldingWire;
PopulateAlternativeConsumables(NewTask, weldJoint, weldingRods, weldingWires);
BLL.WeldTaskService.PopulateAlternativeConsumables(NewTask, weldJoint, weldingRods, weldingWires);
}
NewTask.JointAttribute = weldJoint.JointAttribute;
@@ -1183,48 +1181,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
return matchPipeline;
}
/// <summary>
/// 根据母材类别计算任务单可替代的焊条和焊丝。
/// </summary>
private void PopulateAlternativeConsumables(
Model.HJGL_WeldTask task,
Model.HJGL_WeldJoint weldJoint,
IEnumerable<Model.Base_Consumables> weldingRods,
IEnumerable<Model.Base_Consumables> weldingWires)
{
// 获取可替代焊材时沿用原有母材类别和焊材钢号判断规则。
var material = BLL.Base_MaterialService.GetMaterialByMaterialId(weldJoint.Material1Id);
string materialClass = material.MaterialClass;
var selectedRod = weldingRods.FirstOrDefault(x => x.ConsumablesId == weldJoint.WeldingRod);
var selectedWire = weldingWires.FirstOrDefault(x => x.ConsumablesId == weldJoint.WeldingWire);
task.CanWeldingRodName = GetAlternativeConsumableNames(materialClass, selectedRod, weldingRods);
task.CanWeldingWireName = GetAlternativeConsumableNames(materialClass, selectedWire, weldingWires);
}
/// <summary>
/// 返回与当前焊材钢号兼容的候选名称,保持原有逗号分隔格式。
/// </summary>
private string GetAlternativeConsumableNames(
string materialClass,
Model.Base_Consumables selectedConsumable,
IEnumerable<Model.Base_Consumables> candidateConsumables)
{
if (selectedConsumable == null)
{
return null;
}
bool useCoverClass = materialClass == CoverMaterialClassFe1 || materialClass == CoverMaterialClassFe3;
var names = candidateConsumables
.Where(item => useCoverClass
? IsCoverClass(selectedConsumable.SteelType, item.SteelType)
: selectedConsumable.SteelType == item.SteelType)
.Select(item => item.ConsumablesName)
.ToList();
return names.Any() ? string.Join(",", names) : null;
}
/// <summary>
/// 按任务单实际生成规则过滤可生成任务单的焊口视图数据。
/// </summary>
@@ -1307,26 +1263,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
return new HashSet<string>(GetTaskableWeldJointRows(weldJointIds).Select(x => x.WeldJointId));
}
/// <summary>
/// 判断焊材钢号类别是否能覆盖母材类别。
/// </summary>
/// <param name="wpsClass">焊材钢号类别。</param>
/// <param name="matClass">母材类别。</param>
/// <returns>能覆盖返回 true,否则返回 false。</returns>
private bool IsCoverClass(string wpsClass, string matClass)
{
if (wpsClass.Length <= 2 || matClass.Length <= 2)
{
return false;
}
string wpsPre = wpsClass.Substring(0, wpsClass.Length - 2);
string matPre = matClass.Substring(0, matClass.Length - 2);
int wpsSn = Funs.GetNewInt(wpsClass.Substring(wpsClass.Length - 1, 1)) ?? 0;
int matSn = Funs.GetNewInt(matClass.Substring(matClass.Length - 1, 1)) ?? 0;
return wpsPre == matPre && matSn >= wpsSn;
}
#endregion 按钮事件
}
}
@@ -10,6 +10,11 @@
<link href="../../res/css/viewer.min.css" rel="stylesheet" />
<script src="../../res/js/viewer.min.js" type="text/javascript"></script>
<style type="text/css">
.img {
cursor: zoom-in;
object-fit: cover;
}
.imgPreview {
display: none;
top: 0;
@@ -389,9 +394,6 @@
<f:MenuButton ID="btnMenuOut" OnClick="btnOut_Click" Icon="FolderUp" EnableAjax="false" DisableControlBeforePostBack="false"
runat="server" Text="导出">
</f:MenuButton>
<f:MenuButton ID="btnMenuWeldingLogOut" OnClick="btnWeldingLogOut_Click" Icon="FolderUp" EnableAjax="false" DisableControlBeforePostBack="false"
runat="server" Text="导出(焊接日志)">
</f:MenuButton>
<f:MenuButton ID="btnMenuDelete" OnClick="btnMenuDelete_Click" EnablePostBack="true"
Icon="Delete" ConfirmText="删除选中行?" ConfirmTarget="Top"
runat="server" Text="删除">
@@ -419,36 +421,30 @@
function reloadGrid() {
__doPostBack(null, 'reloadGrid');
}
var imgIDs = ['<%=Grid1.ClientID %>', '<%=GridPending.ClientID %>'];
function showImg() {
$.each(imgIDs, function (_, imgID) {
var $wrap = $("#" + imgID);
$wrap.find('img').off('click.weldreport').on('click.weldreport', function () {
var src = $(this).attr('src');
if (!src || src.indexOf("/res/icon") != -1) {
var gridImageSelector = '#<%= Grid1.ClientID %> img.img, #<%= GridPending.ClientID %> img.img';
F.ready(function () {
$(document).off('click.weldreport', gridImageSelector)
.on('click.weldreport', gridImageSelector, function () {
var imageUrl = $(this).attr('src');
if (!imageUrl) {
return;
}
var div = document.createElement('div');
div.style.display = 'none';
div.innerHTML = '<img src="' + src + '">'; // 创建一个包含图片的 div 元素
document.body.appendChild(div); // 将 div 元素添加到页面中
var viewer = new Viewer(div.firstChild); // 创建 Viewer 实例并传入图片元素
viewer.show(); // 显示图片预览
var container = document.createElement('div');
var image = document.createElement('img');
container.style.display = 'none';
image.src = imageUrl;
container.appendChild(image);
document.body.appendChild(container);
// 在 Viewer 关闭后移除添加的 div 元素
var viewer = new Viewer(image);
viewer.show();
viewer.on('hidden', function () {
document.body.removeChild(div);
document.body.removeChild(container);
});
});
});
$('.imgPreview').on('click', function () {
// $('.imgPreview').hide()
});
}
F.ready(function () {
showImg();
})
});
</script>
</body>
</html>
@@ -1,7 +1,5 @@
using BLL;
using MiniExcelLibs;
using NPOI.SS.UserModel;
using NPOI.XSSF.UserModel;
using System;
using System.Collections.Generic;
using System.Data;
@@ -392,10 +390,10 @@ namespace FineUIPro.Web.HJGL.WeldingManage
string htmlStr = "<table runat='server' cellpadding='5' cellspacing='5' style=\"width: 100%\">";
foreach (string item in photoUrl.ToString().Split(new[] { "," }, StringSplitOptions.RemoveEmptyEntries))
{
string imageUrl = "../../" + item.Replace('\\', '/');
string imageUrl = "../../" + item.Trim().Replace('\\', '/');
// 日报表格图片只用于本页放大预览,不包跳转链接,避免点击时打开新标签页。
htmlStr += "<tr><td style=\"width: 60%\" align=\"left\"><img class='img' width='100' height='100' src='"
+ HttpUtility.HtmlAttributeEncode(imageUrl) + "'></img></td></tr>";
+ HttpUtility.HtmlAttributeEncode(imageUrl) + "' alt='焊接日报照片' /></td></tr>";
}
htmlStr += "</table>";
return htmlStr;
@@ -730,135 +728,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
}
}
/// <summary>
/// 导出俄文焊接日志。
/// </summary>
protected void btnWeldingLogOut_Click(object sender, EventArgs e)
{
if (tvControlItem.SelectedNode == null
|| (tvControlItem.SelectedNode.CommandName != "UnitWork"
&& tvControlItem.SelectedNode.CommandName != "WeldingDaily"))
{
Alert.ShowInTop("请选择单位工程或焊接日报!", MessageBoxIcon.Warning);
return;
}
string unitWorkId = null;
string weldingDailyId = null;
string fileName;
if (tvControlItem.SelectedNode.CommandName == "WeldingDaily")
{
weldingDailyId = tvControlItem.SelectedNodeID;
var daily = BLL.WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(weldingDailyId);
if (daily == null || daily.ProjectId != this.CurrUser.LoginProjectId)
{
Alert.ShowInTop("所选焊接日报不存在!", MessageBoxIcon.Warning);
return;
}
var unitWork = UnitWorkService.getUnitWorkByUnitWorkId(daily.UnitWorkId);
fileName = "焊接日志-" + (unitWork == null ? string.Empty : unitWork.UnitWorkName + "-")
+ daily.WeldingDailyCode + ".xlsx";
}
else
{
unitWorkId = tvControlItem.SelectedNodeID;
var unitWork = BLL.UnitWorkService.getUnitWorkByUnitWorkId(unitWorkId);
if (unitWork == null || unitWork.ProjectId != this.CurrUser.LoginProjectId)
{
Alert.ShowInTop("所选单位工程不存在!", MessageBoxIcon.Warning);
return;
}
fileName = "焊接日志-" + unitWork.UnitWorkName + "-" + txtMonth.Text.Trim() + ".xlsx";
}
DataTable data = BLL.WeldingDailyService.GetWeldingLogExportData(
this.CurrUser.LoginProjectId, unitWorkId, weldingDailyId, txtMonth.Text.Trim());
if (data.Rows.Count == 0)
{
Alert.ShowInTop("无数据,无法导出!", MessageBoxIcon.Warning);
return;
}
byte[] fileBytes;
var workbook = new XSSFWorkbook();
using (var stream = new MemoryStream())
{
ISheet sheet = workbook.CreateSheet("Сварочный журнал");
ICellStyle headerStyle = workbook.CreateCellStyle();
headerStyle.Alignment = HorizontalAlignment.Center;
headerStyle.VerticalAlignment = VerticalAlignment.Center;
headerStyle.WrapText = true;
headerStyle.BorderTop = BorderStyle.Thin;
headerStyle.BorderRight = BorderStyle.Thin;
headerStyle.BorderBottom = BorderStyle.Thin;
headerStyle.BorderLeft = BorderStyle.Thin;
IFont headerFont = workbook.CreateFont();
headerFont.IsBold = true;
headerFont.FontHeightInPoints = 10;
headerStyle.SetFont(headerFont);
ICellStyle dataStyle = workbook.CreateCellStyle();
dataStyle.Alignment = HorizontalAlignment.Center;
dataStyle.VerticalAlignment = VerticalAlignment.Center;
dataStyle.WrapText = true;
dataStyle.BorderTop = BorderStyle.Thin;
dataStyle.BorderRight = BorderStyle.Thin;
dataStyle.BorderBottom = BorderStyle.Thin;
dataStyle.BorderLeft = BorderStyle.Thin;
IRow headerRow = sheet.CreateRow(0);
headerRow.HeightInPoints = 90;
for (int columnIndex = 0; columnIndex < data.Columns.Count; columnIndex++)
{
ICell cell = headerRow.CreateCell(columnIndex);
cell.SetCellValue(data.Columns[columnIndex].ColumnName);
cell.CellStyle = headerStyle;
}
for (int rowIndex = 0; rowIndex < data.Rows.Count; rowIndex++)
{
IRow row = sheet.CreateRow(rowIndex + 1);
row.HeightInPoints = 30;
for (int columnIndex = 0; columnIndex < data.Columns.Count; columnIndex++)
{
ICell cell = row.CreateCell(columnIndex);
object value = data.Rows[rowIndex][columnIndex];
if (columnIndex == 0 && value != DBNull.Value)
{
cell.SetCellValue(Convert.ToDouble(value));
}
else
{
cell.SetCellValue(value == DBNull.Value ? string.Empty : value.ToString());
}
cell.CellStyle = dataStyle;
}
}
int[] columnWidths = { 6, 45, 25, 35, 25, 25, 16, 45, 24, 18, 26, 24, 24, 28, 35, 45, 35 };
for (int i = 0; i < columnWidths.Length; i++)
{
sheet.SetColumnWidth(i, columnWidths[i] * 256);
}
sheet.CreateFreezePane(0, 1);
sheet.FitToPage = true;
sheet.PrintSetup.Landscape = true;
sheet.PrintSetup.FitWidth = 1;
workbook.Write(stream);
fileBytes = stream.ToArray();
}
HttpResponse response = HttpContext.Current.Response;
response.Clear();
response.ContentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
response.AddHeader("Content-Disposition", "attachment;filename="
+ HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
response.AddHeader("Content-Length", fileBytes.Length.ToString());
response.BinaryWrite(fileBytes);
response.Flush();
HttpContext.Current.ApplicationInstance.CompleteRequest();
}
protected void btnMenuDeleteDetail_Click(object sender, EventArgs e)
{
if (!string.IsNullOrEmpty(Grid1.SelectedRowID))
@@ -469,16 +469,6 @@ namespace FineUIPro.Web.HJGL.WeldingManage
/// </remarks>
protected global::FineUIPro.MenuButton btnMenuOut;
/// <summary>
/// btnMenuWeldingLogOut 控件。
/// </summary>
/// <remarks>
/// 自动生成的字段。
/// 若要进行修改,请将字段声明从设计器文件移到代码隐藏文件。
/// </remarks>
protected global::FineUIPro.MenuButton btnMenuWeldingLogOut;
/// <summary>
/// btnMenuDelete 控件。
/// </summary>
/// <remarks>
@@ -1645,22 +1645,34 @@ namespace FineUIPro.Web.HJGL.WeldingManage
var taskWeldJointIds = weldTaskList.Where(x => !string.IsNullOrEmpty(x.WeldJointId))
.Select(x => x.WeldJointId).Distinct().ToList();
var pipelineList = Funs.DB.HJGL_Pipeline.Where(x => pipelines.Contains(x.PipelineId)).ToList();
var weldJointFlowingSections = Funs.DB.HJGL_WeldJoint
.Where(x => taskWeldJointIds.Contains(x.WeldJointId))
.Select(x => new { x.WeldJointId, x.FlowingSection })
.ToDictionary(x => x.WeldJointId, x => x.FlowingSection);
var materialIds = pipelineList.Where(x => !string.IsNullOrEmpty(x.MaterialId))
.Select(x => x.MaterialId).Distinct().ToList();
var pipelineMaterials = Funs.DB.Base_Material.Where(x => materialIds.Contains(x.MaterialId))
.ToDictionary(x => x.MaterialId, x => x.MaterialCode);
var paintIds = pipelineList.Where(x => !string.IsNullOrEmpty(x.PaintId))
.Select(x => x.PaintId).Distinct().ToList();
var paintCodes = Funs.DB.Tw_PaintCodeDict.Where(x => paintIds.Contains(x.Id))
.ToDictionary(x => x.Id, x => x.PaintCode);
var printMaterials = (from x in Funs.DB.HJGL_PipeLineMat
join y in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode
join y in Funs.DB.HJGL_MaterialCodeLib on x.MaterialCode equals y.MaterialCode into materialGroup
from y in materialGroup.DefaultIfEmpty()
where pipelines.Contains(x.PipelineId)
&& taskWeldJointIds.Contains(x.WeldJointId)
&& x.PrefabricatedComponents != null
select new
{
x.PipelineId,
x.WeldJointId,
x.MaterialCode,
x.Number,
y.Code,
y.HeatNo,
y.BatchNo,
y.MaterialMade,
y.MaterialSpec
Code = y == null ? null : y.Code,
HeatNo = y == null ? null : y.HeatNo,
BatchNo = y == null ? null : y.BatchNo,
MaterialMade = y == null ? null : y.MaterialMade,
MaterialSpec = y == null ? null : y.MaterialSpec
}).ToList();
foreach (var task in weldTaskList)
{
@@ -1673,17 +1685,41 @@ namespace FineUIPro.Web.HJGL.WeldingManage
foreach (var material in taskMaterials)
{
var pipeline = pipelineList.FirstOrDefault(x => x.PipelineId == task.PipelineId);
string flowingSection;
weldJointFlowingSections.TryGetValue(task.WeldJointId ?? string.Empty, out flowingSection);
if (string.IsNullOrEmpty(flowingSection))
{
flowingSection = pipeline?.FlowingSection ?? string.Empty;
}
string pipelineMaterial = string.Empty;
if (pipeline != null && !string.IsNullOrEmpty(pipeline.MaterialId))
{
pipelineMaterials.TryGetValue(pipeline.MaterialId, out pipelineMaterial);
}
string paintCode = string.Empty;
if (pipeline != null && !string.IsNullOrEmpty(pipeline.PaintId))
{
paintCodes.TryGetValue(pipeline.PaintId, out paintCode);
}
string materialMade = material?.MaterialMade;
if (string.IsNullOrEmpty(materialMade))
{
materialMade = !string.IsNullOrEmpty(pipelineMaterial)
? pipelineMaterial
: task.MaterialCode ?? string.Empty;
}
DataRow dr = dataTable.NewRow();
dr["PipelineCode"] = task.PipelineCode;
dr["FlowingSection"] = pipelineList.FirstOrDefault(x => x.PipelineId == task.PipelineId)?.FlowingSection ?? string.Empty;
dr["FlowingSection"] = flowingSection;
dr["WeldJointCode"] = !string.IsNullOrEmpty(task.PipelineCode) ? task.WeldJointCode.Replace(task.PipelineCode + "/", "") : task.WeldJointCode;
dr["MaterialCode"] = material?.Code ?? material?.MaterialCode ?? string.Empty;
dr["BatchNo"] = material == null ? string.Empty : string.Join("/", new[] { material.HeatNo, material.BatchNo }.Where(x => !string.IsNullOrEmpty(x)));
dr["NeedNum"] = material?.Number != null ? material.Number.Value.ToString("0.##") : string.Empty;
dr["MaterialMade"] = material?.MaterialMade ?? string.Empty;
dr["MaterialMade"] = materialMade;
dr["MaterialSpec"] = material?.MaterialSpec ?? string.Empty;
// 当前焊接任务单取数链路未维护油漆号,先输出空列,避免模板字段缺失。
dr["PaintCode"] = string.Empty;
dr["PaintCode"] = paintCode ?? string.Empty;
dr["WeldingSize"] = task.Size.HasValue ? task.Size.Value.ToString("0.##") : string.Empty;
dr["Remark"] = string.Empty;
dataTable.Rows.Add(dr);