feat(hjgl)焊前准备,日报管理增加附件
This commit is contained in:
@@ -54,10 +54,50 @@ namespace BLL
|
||||
var weldjoint = db.View_HJGL_WeldJoint
|
||||
.Where(p => p.WeldJointId == WeldJointId)
|
||||
.FirstOrDefault();
|
||||
if (weldjoint != null)
|
||||
{
|
||||
SetWeldingDailyAttachUrl(db, weldjoint);
|
||||
}
|
||||
return weldjoint;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回填小程序日报上传的焊前、焊后附件路径
|
||||
/// </summary>
|
||||
/// <param name="db">数据库上下文</param>
|
||||
/// <param name="weldJoint">焊口详情</param>
|
||||
private static void SetWeldingDailyAttachUrl(Model.SGGLDB db, Model.View_HJGL_WeldJoint weldJoint)
|
||||
{
|
||||
var tempDetail = db.HJGL_WeldingDailyTempDetail
|
||||
.Where(x => x.WeldJointId == weldJoint.WeldJointId)
|
||||
.OrderByDescending(x => x.SubmitDate)
|
||||
.FirstOrDefault();
|
||||
if (tempDetail == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
weldJoint.PreWeldAttachUrl = GetAttachUrl(db, Const.HJGL_WeldReportMenuId, tempDetail.TempDetailId + "#Before");
|
||||
weldJoint.PostWeldAttachUrl = GetAttachUrl(db, Const.HJGL_WeldReportMenuId, tempDetail.TempDetailId + "#After");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按菜单和业务ID获取附件路径
|
||||
/// </summary>
|
||||
/// <param name="db">数据库上下文</param>
|
||||
/// <param name="menuId">菜单ID</param>
|
||||
/// <param name="toKeyId">业务ID</param>
|
||||
/// <returns>附件路径</returns>
|
||||
private static string GetAttachUrl(Model.SGGLDB db, string menuId, string toKeyId)
|
||||
{
|
||||
var attachUrl = db.AttachFile
|
||||
.Where(x => x.MenuId == menuId && x.ToKeyId == toKeyId)
|
||||
.Select(x => x.AttachUrl)
|
||||
.FirstOrDefault();
|
||||
return string.IsNullOrEmpty(attachUrl) ? attachUrl : attachUrl.Replace('\\', '/');
|
||||
}
|
||||
|
||||
|
||||
#region 获取未焊接的焊口信息
|
||||
|
||||
@@ -626,4 +666,4 @@ namespace BLL
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -41,10 +41,58 @@ namespace BLL
|
||||
Misalignment = x.Misalignment
|
||||
};
|
||||
|
||||
return query.FirstOrDefault();
|
||||
var item = query.FirstOrDefault();
|
||||
if (item != null)
|
||||
{
|
||||
SetInspectionAttachUrl(db, item);
|
||||
}
|
||||
|
||||
return item;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 回填下料、组对抽检附件路径
|
||||
/// </summary>
|
||||
/// <param name="db">数据库上下文</param>
|
||||
/// <param name="item">焊前抽检基础信息</param>
|
||||
private static void SetInspectionAttachUrl(Model.SGGLDB db, Model.PreWeldJointItem item)
|
||||
{
|
||||
var cuttingCheckId = db.HJGL_PreWeldCuttingCheck
|
||||
.Where(x => x.WeldJointId == item.WeldJointId)
|
||||
.Select(x => x.CuttingCheckId)
|
||||
.FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(cuttingCheckId))
|
||||
{
|
||||
item.CuttingAttachUrl1 = GetAttachUrl(db, Const.HJGL_PreWeldCuttingCheckMenuId, cuttingCheckId);
|
||||
}
|
||||
|
||||
var fitupCheckId = db.HJGL_PreWeldFitupCheck
|
||||
.Where(x => x.WeldJointId == item.WeldJointId)
|
||||
.Select(x => x.FitupCheckId)
|
||||
.FirstOrDefault();
|
||||
if (!string.IsNullOrEmpty(fitupCheckId))
|
||||
{
|
||||
item.FitupAttachUrl1 = GetAttachUrl(db, Const.HJGL_PreWeldFitupCheckMenuId, fitupCheckId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 按菜单和业务ID获取附件路径
|
||||
/// </summary>
|
||||
/// <param name="db">数据库上下文</param>
|
||||
/// <param name="menuId">菜单ID</param>
|
||||
/// <param name="toKeyId">业务ID</param>
|
||||
/// <returns>附件路径</returns>
|
||||
private static string GetAttachUrl(Model.SGGLDB db, string menuId, string toKeyId)
|
||||
{
|
||||
var attachUrl = db.AttachFile
|
||||
.Where(x => x.MenuId == menuId && x.ToKeyId == toKeyId)
|
||||
.Select(x => x.AttachUrl)
|
||||
.FirstOrDefault();
|
||||
return string.IsNullOrEmpty(attachUrl) ? attachUrl : attachUrl.Replace('\\', '/');
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存下料抽检,已存在同一焊口记录时更新原记录
|
||||
/// </summary>
|
||||
@@ -92,6 +140,8 @@ namespace BLL
|
||||
check.Remark = item.Remark;
|
||||
|
||||
db.SubmitChanges();
|
||||
|
||||
SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldCuttingCheckMenuId, check.CuttingCheckId);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +208,32 @@ namespace BLL
|
||||
weldJoint.Misalignment = item.Misalignment;
|
||||
|
||||
db.SubmitChanges();
|
||||
|
||||
SaveInspectionAttachUrl(item.AttachUrl1, Const.HJGL_PreWeldFitupCheckMenuId, check.FitupCheckId);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存焊前抽检附件,空附件时清理原附件。
|
||||
/// </summary>
|
||||
/// <param name="attachUrl">附件路径</param>
|
||||
/// <param name="menuId">菜单ID</param>
|
||||
/// <param name="dataId">业务数据ID</param>
|
||||
private static void SaveInspectionAttachUrl(string attachUrl, string menuId, string dataId)
|
||||
{
|
||||
// AttachUrl1 为 null 表示旧调用方未传附件参数,避免误删已有附件;空字符串表示明确清空附件。
|
||||
if (attachUrl == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(attachUrl))
|
||||
{
|
||||
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(attachUrl, 10, null), attachUrl, menuId, dataId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonService.DeleteAttachFileById(menuId, dataId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -277,6 +277,77 @@ namespace BLL
|
||||
return BLL.WeldingDailyService.SaveWeldingDailyTempDetailByMobile(WeldJointId, Personid, time, weldingLocation, welderType);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存焊接日报并维护焊前、焊后附件
|
||||
/// </summary>
|
||||
/// <param name="newItem">焊接日报及附件参数</param>
|
||||
/// <returns>错误信息</returns>
|
||||
public static string SaveWeldingDailyByWeldJointIdWithAttach(Model.WeldingDailyByWeldJointAttachItem newItem)
|
||||
{
|
||||
if (newItem == null)
|
||||
{
|
||||
return "参数不能为空";
|
||||
}
|
||||
|
||||
string res = BLL.WeldingDailyService.SaveWeldingDailyTempDetailByMobile(newItem.WeldJointId, newItem.Personid, newItem.time, newItem.weldingLocation, newItem.welderType);
|
||||
if (!string.IsNullOrEmpty(res))
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
DateTime weldingDate;
|
||||
if (!DateTime.TryParse(newItem.time, out weldingDate))
|
||||
{
|
||||
return "焊接日期不正确";
|
||||
}
|
||||
weldingDate = weldingDate.Date;
|
||||
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
var tempDetail = db.HJGL_WeldingDailyTempDetail.FirstOrDefault(x => x.WeldJointId == newItem.WeldJointId
|
||||
&& x.WeldingDate >= weldingDate
|
||||
&& x.WeldingDate < weldingDate.AddDays(1)
|
||||
&& x.AuditState == 0);
|
||||
if (tempDetail == null)
|
||||
{
|
||||
return "未找到待审核日报明细";
|
||||
}
|
||||
|
||||
SaveWeldingDailyTempAttachUrl(newItem.PreWeldAttachUrl, tempDetail.TempDetailId + "#Before");
|
||||
SaveWeldingDailyTempAttachUrl(newItem.PostWeldAttachUrl, tempDetail.TempDetailId + "#After");
|
||||
|
||||
// 明细表仅有一个附件字段,合并记录焊前、焊后附件路径,便于台账直接展示。
|
||||
var preWeldAttachUrl = APIUpLoadFileService.getFileUrl(Const.HJGL_WeldReportMenuId, tempDetail.TempDetailId + "#Before", null);
|
||||
var postWeldAttachUrl = APIUpLoadFileService.getFileUrl(Const.HJGL_WeldReportMenuId, tempDetail.TempDetailId + "#After", null);
|
||||
tempDetail.AttachUrl = string.Join(",", new[] { preWeldAttachUrl, postWeldAttachUrl }.Where(x => !string.IsNullOrEmpty(x)));
|
||||
db.SubmitChanges();
|
||||
}
|
||||
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 保存焊接日报待审核附件,null 表示不变,空字符串表示清空。
|
||||
/// </summary>
|
||||
/// <param name="attachUrl">附件路径</param>
|
||||
/// <param name="toKeyId">附件关联业务ID</param>
|
||||
private static void SaveWeldingDailyTempAttachUrl(string attachUrl, string toKeyId)
|
||||
{
|
||||
if (attachUrl == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(attachUrl))
|
||||
{
|
||||
UploadFileService.SaveAttachUrl(UploadFileService.GetSourceByAttachUrl(attachUrl, 10, null), attachUrl, Const.HJGL_WeldReportMenuId, toKeyId);
|
||||
}
|
||||
else
|
||||
{
|
||||
CommonService.DeleteAttachFileById(Const.HJGL_WeldReportMenuId, toKeyId);
|
||||
}
|
||||
}
|
||||
|
||||
#region 保存焊接日报明细
|
||||
/// <summary>
|
||||
/// 保存焊接日报明细
|
||||
|
||||
Reference in New Issue
Block a user