feat(hjgl)焊前准备,日报管理增加附件
This commit is contained in:
@@ -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