feat(clgl)条码打印修改
This commit is contained in:
@@ -406,6 +406,179 @@ namespace FineUIPro.Web.HJGL.InfoQuery
|
||||
|
||||
// return sb.ToString();
|
||||
// }
|
||||
|
||||
/// <summary>
|
||||
/// 管道数据表导出按钮
|
||||
/// </summary>
|
||||
protected void btnPipelineDataOut_Click(object sender, EventArgs e)
|
||||
{
|
||||
var pipelines = GetCurrentPipelineList();
|
||||
if (pipelines.Count == 0)
|
||||
{
|
||||
ShowNotify("没有可导出的管线数据!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string templatePath = Funs.RootPath + @"File\Excel\DataOut\管道数据表导出模板.xlsx";
|
||||
if (!File.Exists(templatePath))
|
||||
{
|
||||
ShowNotify("导出模板不存在!", MessageBoxIcon.Warning);
|
||||
return;
|
||||
}
|
||||
|
||||
string tempPath = Funs.RootPath + @"File\Excel\Temp\管道数据表.xlsx";
|
||||
tempPath = tempPath.Replace(".xlsx", string.Format("{0:yyyy-MM-dd-HH-mm-ss}", DateTime.Now) + ".xlsx");
|
||||
Directory.CreateDirectory(Path.GetDirectoryName(tempPath));
|
||||
|
||||
var pipelineIds = pipelines.Select(x => x.PipelineId).Where(x => !string.IsNullOrEmpty(x)).ToList();
|
||||
var hotPipelineIds = Funs.DB.HJGL_WeldJoint
|
||||
.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PipelineId != null && pipelineIds.Contains(x.PipelineId) && x.IsHotProess == true)
|
||||
.Select(x => x.PipelineId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var hotPipelineIdSet = new HashSet<string>(hotPipelineIds);
|
||||
|
||||
var pipelineData = pipelines.Select((x, index) => new
|
||||
{
|
||||
No = index + 1,
|
||||
PipelineCode = SafeText(x.PipelineCode),
|
||||
PipingClassCode = SafeText(x.PipingClassCode),
|
||||
MediumName = SafeText(x.MediumName),
|
||||
PressurePipingClassCode = SafeText(x.PressurePipingClassCode),
|
||||
DesignPress = SafeText(x.DesignPress),
|
||||
DesignTemperature = SafeText(x.DesignTemperature),
|
||||
OperatePressure = "/",
|
||||
OperateTemperature = "/",
|
||||
PWHT = hotPipelineIdSet.Contains(x.PipelineId) ? "PWHT" : "/",
|
||||
DetectionRateCode = SafeText(x.DetectionRateCode),
|
||||
InsulationType = "/",
|
||||
Tracing = "/",
|
||||
TestType = "/",
|
||||
TestMethod = SafeText(x.TestMediumCode),
|
||||
TestPressure = SafeText(x.TestPressure)
|
||||
}).ToList();
|
||||
|
||||
var weldJoints = Funs.DB.View_HJGL_WeldJoint
|
||||
.Where(x => x.ProjectId == this.CurrUser.LoginProjectId && x.PipelineId != null && pipelineIds.Contains(x.PipelineId))
|
||||
.OrderBy(x => x.PipelineCode)
|
||||
.ThenBy(x => x.WeldJointCode)
|
||||
.ToList();
|
||||
var weldJointIds = weldJoints.Select(x => x.WeldJointId).Where(x => !string.IsNullOrEmpty(x)).ToList();
|
||||
var pointJointIds = Funs.DB.HJGL_Batch_PointBatchItem
|
||||
.Where(x => x.WeldJointId != null && weldJointIds.Contains(x.WeldJointId) && x.PointState != null)
|
||||
.Select(x => x.WeldJointId)
|
||||
.Distinct()
|
||||
.ToList();
|
||||
var pointJointIdSet = new HashSet<string>(pointJointIds);
|
||||
|
||||
var weldJointData = weldJoints.Select((x, index) => new
|
||||
{
|
||||
No = index + 1,
|
||||
SingleNumber = SafeText(x.SingleNumber),
|
||||
WeldJointCode = SafeText(x.WeldJointCode),
|
||||
Dia = x.Dia,
|
||||
Thickness = x.Thickness,
|
||||
MaterialCode = SafeText(x.MaterialCode),
|
||||
WeldingDate = SafeText(x.WeldingDate),
|
||||
WelderName = JoinTexts(x.BackingWelderName, x.CoverWelderName),
|
||||
CertificateNo = "/",
|
||||
WelderCode = JoinTexts(x.BackingWelderCode, x.CoverWelderCode),
|
||||
WelderExamDate = "/",
|
||||
TestJointDate = "/",
|
||||
RootWeldingData = FormatWeldingData(x.WeldingMethodCode, x.WeldingRodCode, x.WeldingWireCode),
|
||||
RemainingWeldingData = FormatWeldingData(x.WeldingMethodCode, x.WeldingRodCode, x.WeldingWireCode),
|
||||
// P列和V列按“管线需要热处理”判断,不按单个焊口判断。
|
||||
PWHT = hotPipelineIdSet.Contains(x.PipelineId) ? "PWHT" : "/",
|
||||
HotProcessAccept = hotPipelineIdSet.Contains(x.PipelineId) ? "ACC." : "/",
|
||||
// AB列按点口记录判断;AC列按管道等级1级判断,否则保持模板要求的“/”。
|
||||
PointAccept = IsPointed(x.IsPoint, x.WeldJointId, pointJointIdSet) ? "ACC." : "/",
|
||||
PipingClassAccept = IsFirstLevelPipingClass(x.PipingClassCode) ? "ACC." : "/"
|
||||
}).ToList();
|
||||
|
||||
var value = new Dictionary<string, object>
|
||||
{
|
||||
["PipelineData"] = pipelineData,
|
||||
["WeldJointData"] = weldJointData
|
||||
};
|
||||
|
||||
MiniExcel.SaveAsByTemplate(tempPath, templatePath, value);
|
||||
DownTempFile(tempPath, "管道数据表.xlsx");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按当前页面筛选条件重新获取导出管线,避免使用跨用户共享的静态缓存。
|
||||
/// </summary>
|
||||
private List<Model.View_HJGL_Pipeline> GetCurrentPipelineList()
|
||||
{
|
||||
Model.View_HJGL_Pipeline model = new Model.View_HJGL_Pipeline();
|
||||
model.ProjectId = this.CurrUser.LoginProjectId;
|
||||
model.UnitWorkId = this.tvControlItem.SelectedNodeID;
|
||||
model.PipelineCode = this.txtPipelineCode.Text.Trim();
|
||||
model.IsFinished = null;
|
||||
if (drpIsFinish.SelectedValue == "1")
|
||||
{
|
||||
model.IsFinished = true;
|
||||
}
|
||||
if (drpIsFinish.SelectedValue == "0")
|
||||
{
|
||||
model.IsFinished = false;
|
||||
}
|
||||
return BLL.PipelineService.GetView_HJGL_Pipelines(model);
|
||||
}
|
||||
|
||||
private void DownTempFile(string path, string fileName)
|
||||
{
|
||||
FileInfo info = new FileInfo(path);
|
||||
long fileSize = info.Length;
|
||||
System.Web.HttpContext.Current.Response.Clear();
|
||||
System.Web.HttpContext.Current.Response.ContentType = "application/x-zip-compressed";
|
||||
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(fileName, System.Text.Encoding.UTF8));
|
||||
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", fileSize.ToString());
|
||||
System.Web.HttpContext.Current.Response.TransmitFile(path, 0, fileSize);
|
||||
System.Web.HttpContext.Current.Response.Flush();
|
||||
System.Web.HttpContext.Current.Response.Close();
|
||||
File.Delete(path);
|
||||
}
|
||||
|
||||
private static string SafeText(object value)
|
||||
{
|
||||
if (value == null)
|
||||
{
|
||||
return "/";
|
||||
}
|
||||
string text = value.ToString();
|
||||
return string.IsNullOrWhiteSpace(text) ? "/" : text.Trim();
|
||||
}
|
||||
|
||||
private static string JoinTexts(params string[] values)
|
||||
{
|
||||
var texts = values
|
||||
.Where(x => !string.IsNullOrWhiteSpace(x))
|
||||
.Select(x => x.Trim())
|
||||
.Distinct()
|
||||
.ToList();
|
||||
return texts.Count == 0 ? "/" : string.Join("/", texts);
|
||||
}
|
||||
|
||||
private static string FormatWeldingData(params string[] values)
|
||||
{
|
||||
return JoinTexts(values);
|
||||
}
|
||||
|
||||
private static bool IsPointed(string isPoint, string weldJointId, HashSet<string> pointJointIdSet)
|
||||
{
|
||||
return pointJointIdSet.Contains(weldJointId) || isPoint == "1" || isPoint == "是" || isPoint == "True";
|
||||
}
|
||||
|
||||
private static bool IsFirstLevelPipingClass(string pipingClassCode)
|
||||
{
|
||||
if (string.IsNullOrWhiteSpace(pipingClassCode))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
string code = pipingClassCode.Trim();
|
||||
return code == "1" || code == "1级" || code == "一级" || code == "Ⅰ级" || code == "Ⅰ";
|
||||
}
|
||||
#endregion
|
||||
|
||||
protected string ConvertDetectionType(object detectionType)
|
||||
@@ -572,4 +745,4 @@ namespace FineUIPro.Web.HJGL.InfoQuery
|
||||
//ctlAuditFlow.BindData();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user