feat(hjgl):增加焊接日报审核流程
This commit is contained in:
@@ -293,6 +293,408 @@ namespace BLL
|
||||
db.SubmitChanges();
|
||||
}
|
||||
}
|
||||
|
||||
#region 焊接日报待审核
|
||||
/// <summary>
|
||||
/// 移动端按焊口保存焊接日报待审核明细
|
||||
/// </summary>
|
||||
/// <param name="weldJointId">焊口ID</param>
|
||||
/// <param name="personId">提交焊工ID</param>
|
||||
/// <param name="time">焊接日期</param>
|
||||
/// <param name="weldingLocationId">焊接位置ID</param>
|
||||
/// <param name="welderType">焊工类型 0 全部 1 打底 2 盖面</param>
|
||||
/// <returns>错误信息</returns>
|
||||
public static string SaveWeldingDailyTempDetailByMobile(string weldJointId, string personId, string time, string weldingLocationId, int welderType)
|
||||
{
|
||||
string res = string.Empty;
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
try
|
||||
{
|
||||
DateTime weldingDate;
|
||||
if (!DateTime.TryParse(time, out weldingDate))
|
||||
{
|
||||
return "焊接日期不正确";
|
||||
}
|
||||
weldingDate = weldingDate.Date;
|
||||
|
||||
var person = db.Person_Persons.FirstOrDefault(x => x.PersonId == personId);
|
||||
if (person == null)
|
||||
{
|
||||
return "人员不存在";
|
||||
}
|
||||
|
||||
var joint = db.View_HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == weldJointId);
|
||||
string err = CheckWeldingDailyTempJoint(db, joint, weldingLocationId);
|
||||
if (!string.IsNullOrEmpty(err))
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
var weldTask = db.HJGL_WeldTask.FirstOrDefault(x => x.WeldJointId == joint.WeldJointId);
|
||||
var weldJoint = db.HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == joint.WeldJointId);
|
||||
var pending = GetPendingTempDetail(db, weldJointId, weldingDate);
|
||||
|
||||
string coverWelderId = pending != null ? pending.CoverWelderId : weldJoint.CoverWelderId;
|
||||
string backingWelderId = pending != null ? pending.BackingWelderId : weldJoint.BackingWelderId;
|
||||
if (welderType == 0)
|
||||
{
|
||||
coverWelderId = personId;
|
||||
backingWelderId = personId;
|
||||
}
|
||||
else if (welderType == 1)
|
||||
{
|
||||
backingWelderId = personId;
|
||||
}
|
||||
else if (welderType == 2)
|
||||
{
|
||||
coverWelderId = personId;
|
||||
}
|
||||
else
|
||||
{
|
||||
return "焊工类型不正确";
|
||||
}
|
||||
|
||||
SaveWeldingDailyTempDetail(db, joint, weldTask, weldingDate, personId, coverWelderId, backingWelderId,
|
||||
joint.JointAttribute, weldingLocationId, joint.ProjectId, null, null, joint.WeldingMode);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APICommonService.SaveSysAPILog("erro", ex.ToString(), "-1");
|
||||
res = ex.Message;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Web端保存焊接日报待审核明细
|
||||
/// </summary>
|
||||
/// <param name="weldJointId">焊口ID</param>
|
||||
/// <param name="submitPersonId">提交人ID</param>
|
||||
/// <param name="weldingDate">焊接日期</param>
|
||||
/// <param name="coverWelderId">盖面焊工ID</param>
|
||||
/// <param name="backingWelderId">打底焊工ID</param>
|
||||
/// <param name="jointAttribute">焊口属性</param>
|
||||
/// <param name="weldingLocationId">焊接位置ID</param>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="unitId">单位ID</param>
|
||||
/// <param name="unitWorkId">单位工程ID</param>
|
||||
/// <param name="weldingMode">焊接模式</param>
|
||||
/// <returns>错误信息</returns>
|
||||
public static string SaveWeldingDailyTempDetailByWeb(string weldJointId, string submitPersonId, DateTime weldingDate, string coverWelderId,
|
||||
string backingWelderId, string jointAttribute, string weldingLocationId, string projectId, string unitId, string unitWorkId, string weldingMode)
|
||||
{
|
||||
string res = string.Empty;
|
||||
using (Model.SGGLDB db = new Model.SGGLDB(Funs.ConnString))
|
||||
{
|
||||
try
|
||||
{
|
||||
weldingDate = weldingDate.Date;
|
||||
weldingLocationId = NormalizeNullValue(weldingLocationId);
|
||||
unitId = NormalizeNullValue(unitId);
|
||||
unitWorkId = NormalizeNullValue(unitWorkId);
|
||||
|
||||
if (string.IsNullOrEmpty(weldJointId))
|
||||
{
|
||||
return "焊口不能为空";
|
||||
}
|
||||
if (string.IsNullOrEmpty(coverWelderId) || string.IsNullOrEmpty(backingWelderId))
|
||||
{
|
||||
return "未选择完整焊工";
|
||||
}
|
||||
|
||||
var joint = db.View_HJGL_WeldJoint.FirstOrDefault(x => x.WeldJointId == weldJointId);
|
||||
string err = CheckWeldingDailyTempJoint(db, joint, weldingLocationId);
|
||||
if (!string.IsNullOrEmpty(err))
|
||||
{
|
||||
return err;
|
||||
}
|
||||
|
||||
var coverWelder = db.SitePerson_Person.FirstOrDefault(x => x.ProjectId == projectId && x.PersonId == coverWelderId);
|
||||
if (coverWelder == null)
|
||||
{
|
||||
return "盖面焊工不存在";
|
||||
}
|
||||
var backingWelder = db.SitePerson_Person.FirstOrDefault(x => x.ProjectId == projectId && x.PersonId == backingWelderId);
|
||||
if (backingWelder == null)
|
||||
{
|
||||
return "打底焊工不存在";
|
||||
}
|
||||
|
||||
var weldTask = db.HJGL_WeldTask.FirstOrDefault(x => x.WeldJointId == weldJointId);
|
||||
SaveWeldingDailyTempDetail(db, joint, weldTask, weldingDate, submitPersonId, coverWelderId, backingWelderId,
|
||||
jointAttribute, weldingLocationId, projectId, unitId, unitWorkId, weldingMode);
|
||||
db.SubmitChanges();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
APICommonService.SaveSysAPILog("erro", ex.ToString(), "-1");
|
||||
res = ex.Message;
|
||||
}
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 审核通过焊接日报待审核明细
|
||||
/// </summary>
|
||||
/// <param name="tempDetailIds">待审核明细ID集合</param>
|
||||
/// <param name="auditMan">审核人</param>
|
||||
/// <returns>错误信息</returns>
|
||||
public static string AuditWeldingDailyTempDetails(string[] tempDetailIds, string auditMan)
|
||||
{
|
||||
string errlog = string.Empty;
|
||||
if (tempDetailIds == null || tempDetailIds.Length == 0)
|
||||
{
|
||||
return "请选择要审核的记录";
|
||||
}
|
||||
|
||||
foreach (string tempDetailId in tempDetailIds.Where(x => !string.IsNullOrEmpty(x)).Distinct())
|
||||
{
|
||||
var tempDetail = Funs.DB.HJGL_WeldingDailyTempDetail.FirstOrDefault(x => x.TempDetailId == tempDetailId);
|
||||
if (tempDetail == null)
|
||||
{
|
||||
errlog += "待审核记录不存在;";
|
||||
continue;
|
||||
}
|
||||
if (tempDetail.AuditState != 0)
|
||||
{
|
||||
errlog += "焊口待审核记录已审核;";
|
||||
continue;
|
||||
}
|
||||
if (string.IsNullOrEmpty(tempDetail.CoverWelderId) || string.IsNullOrEmpty(tempDetail.BackingWelderId))
|
||||
{
|
||||
errlog += "焊口待审核记录未选择完整焊工;";
|
||||
continue;
|
||||
}
|
||||
|
||||
var weldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(tempDetail.WeldJointId);
|
||||
if (weldJoint == null)
|
||||
{
|
||||
errlog += "焊口不存在;";
|
||||
continue;
|
||||
}
|
||||
if (!string.IsNullOrEmpty(weldJoint.WeldingDailyId))
|
||||
{
|
||||
errlog += "焊口【" + weldJoint.WeldJointCode + "】已生成焊接日报;";
|
||||
continue;
|
||||
}
|
||||
|
||||
var batchC = BLL.Project_SysSetService.GetSysSetBySetId("5", tempDetail.ProjectId);
|
||||
if (batchC == null)
|
||||
{
|
||||
errlog += "请设置项目的组批条件;";
|
||||
continue;
|
||||
}
|
||||
|
||||
var weldingDaily = GetOrCreateWeldingDailyByTempDetail(tempDetail);
|
||||
string itemErr = InsertWeldingDailyItem(tempDetail.WeldJointId, tempDetail.CoverWelderId, tempDetail.BackingWelderId,
|
||||
tempDetail.JointAttribute, weldingDaily.WeldingDate, batchC.SetValue, true, weldingDaily.WeldingDailyId,
|
||||
tempDetail.ProjectId, tempDetail.WeldingLocationId);
|
||||
if (!string.IsNullOrEmpty(itemErr))
|
||||
{
|
||||
errlog += itemErr;
|
||||
continue;
|
||||
}
|
||||
|
||||
BLL.HJGL_PipelineComponentjointService.UpdateStateByWeldJointId(tempDetail.WeldJointId, (DateTime)weldingDaily.WeldingDate);//更改预制口实际时间和状态
|
||||
PipelineService.UpdataDateByWeldJointId(tempDetail.WeldJointId);//更改安装口时间和状态
|
||||
tempDetail.AuditState = 1;
|
||||
tempDetail.AuditMan = auditMan;
|
||||
tempDetail.AuditDate = DateTime.Now;
|
||||
Funs.DB.SubmitChanges();
|
||||
}
|
||||
|
||||
return errlog;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 删除未审核的焊接日报待审核明细
|
||||
/// </summary>
|
||||
/// <param name="tempDetailIds">待审核明细ID集合</param>
|
||||
/// <returns>错误信息</returns>
|
||||
public static string DeleteWeldingDailyTempDetails(string[] tempDetailIds)
|
||||
{
|
||||
if (tempDetailIds == null || tempDetailIds.Length == 0)
|
||||
{
|
||||
return "请选择要删除的记录";
|
||||
}
|
||||
|
||||
string errlog = string.Empty;
|
||||
foreach (string tempDetailId in tempDetailIds.Where(x => !string.IsNullOrEmpty(x)).Distinct())
|
||||
{
|
||||
var tempDetail = Funs.DB.HJGL_WeldingDailyTempDetail.FirstOrDefault(x => x.TempDetailId == tempDetailId);
|
||||
if (tempDetail == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if (tempDetail.AuditState != 0)
|
||||
{
|
||||
errlog += "已审核记录不能删除;";
|
||||
continue;
|
||||
}
|
||||
Funs.DB.HJGL_WeldingDailyTempDetail.DeleteOnSubmit(tempDetail);
|
||||
}
|
||||
Funs.DB.SubmitChanges();
|
||||
return errlog;
|
||||
}
|
||||
|
||||
private static string CheckWeldingDailyTempJoint(Model.SGGLDB db, Model.View_HJGL_WeldJoint joint, string weldingLocationId)
|
||||
{
|
||||
if (joint == null)
|
||||
{
|
||||
return "焊口不存在";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(joint.WeldingDailyId))
|
||||
{
|
||||
return "焊口【" + joint.WeldJointCode + "】已生成焊接日报,不能提交待审核";
|
||||
}
|
||||
if (!string.IsNullOrEmpty(weldingLocationId))
|
||||
{
|
||||
var weldingLocationModel = db.Base_WeldingLocation.FirstOrDefault(x => x.WeldingLocationId == weldingLocationId);
|
||||
if (weldingLocationModel == null)
|
||||
{
|
||||
return "焊口位置不存在";
|
||||
}
|
||||
}
|
||||
return string.Empty;
|
||||
}
|
||||
|
||||
private static Model.HJGL_WeldingDailyTempDetail GetPendingTempDetail(Model.SGGLDB db, string weldJointId, DateTime weldingDate)
|
||||
{
|
||||
return db.HJGL_WeldingDailyTempDetail.FirstOrDefault(x => x.WeldJointId == weldJointId
|
||||
&& x.WeldingDate >= weldingDate.Date
|
||||
&& x.WeldingDate < weldingDate.Date.AddDays(1)
|
||||
&& x.AuditState == 0);
|
||||
}
|
||||
|
||||
private static void SaveWeldingDailyTempDetail(Model.SGGLDB db, Model.View_HJGL_WeldJoint joint, Model.HJGL_WeldTask weldTask,
|
||||
DateTime weldingDate, string submitPersonId, string coverWelderId, string backingWelderId, string jointAttribute,
|
||||
string weldingLocationId, string projectId, string unitId, string unitWorkId, string weldingMode)
|
||||
{
|
||||
var pending = GetPendingTempDetail(db, joint.WeldJointId, weldingDate);
|
||||
if (pending == null)
|
||||
{
|
||||
pending = new Model.HJGL_WeldingDailyTempDetail
|
||||
{
|
||||
TempDetailId = Guid.NewGuid().ToString(),
|
||||
WeldJointId = joint.WeldJointId,
|
||||
WeldingDate = weldingDate.Date,
|
||||
AuditState = 0,
|
||||
SubmitDate = DateTime.Now
|
||||
};
|
||||
db.HJGL_WeldingDailyTempDetail.InsertOnSubmit(pending);
|
||||
}
|
||||
|
||||
pending.ProjectId = !string.IsNullOrEmpty(projectId) ? projectId : joint.ProjectId;
|
||||
pending.UnitId = !string.IsNullOrEmpty(unitId) ? unitId : (weldTask != null && !string.IsNullOrEmpty(weldTask.UnitId) ? weldTask.UnitId : joint.UnitId);
|
||||
pending.UnitWorkId = !string.IsNullOrEmpty(unitWorkId) ? unitWorkId : joint.UnitWorkId;
|
||||
pending.CoverWelderId = coverWelderId;
|
||||
pending.BackingWelderId = backingWelderId;
|
||||
pending.JointAttribute = !string.IsNullOrEmpty(jointAttribute) ? jointAttribute : joint.JointAttribute;
|
||||
pending.WeldingLocationId = !string.IsNullOrEmpty(weldingLocationId) ? weldingLocationId : joint.WeldingLocationId;
|
||||
pending.WeldingMode = !string.IsNullOrEmpty(weldingMode) ? weldingMode : joint.WeldingMode;
|
||||
pending.SubmitPersonId = submitPersonId;
|
||||
pending.SubmitDate = DateTime.Now;
|
||||
}
|
||||
|
||||
private static Model.HJGL_WeldingDaily GetOrCreateWeldingDailyByTempDetail(Model.HJGL_WeldingDailyTempDetail tempDetail)
|
||||
{
|
||||
var weldingDaily = Funs.DB.HJGL_WeldingDaily.FirstOrDefault(x => x.UnitWorkId == tempDetail.UnitWorkId
|
||||
&& x.WeldingDate >= tempDetail.WeldingDate.Date
|
||||
&& x.WeldingDate < tempDetail.WeldingDate.Date.AddDays(1));
|
||||
if (weldingDaily != null)
|
||||
{
|
||||
return weldingDaily;
|
||||
}
|
||||
|
||||
var submitPerson = Funs.DB.Person_Persons.FirstOrDefault(x => x.PersonId == tempDetail.SubmitPersonId);
|
||||
string personName = submitPerson != null ? submitPerson.PersonName : string.Empty;
|
||||
string perfix = string.Format("{0:yyyyMMdd}", tempDetail.WeldingDate) + "-" + personName + "-";
|
||||
weldingDaily = new Model.HJGL_WeldingDaily
|
||||
{
|
||||
WeldingDailyId = Guid.NewGuid().ToString(),
|
||||
WeldingDailyCode = BLL.SQLHelper.RunProcNewId("SpGetThreeNumber", "dbo.HJGL_WeldingDaily", "WeldingDailyCode", tempDetail.ProjectId, perfix),
|
||||
WeldingDate = tempDetail.WeldingDate.Date,
|
||||
ProjectId = tempDetail.ProjectId,
|
||||
UnitWorkId = tempDetail.UnitWorkId,
|
||||
UnitId = tempDetail.UnitId,
|
||||
Tabler = tempDetail.SubmitPersonId,
|
||||
TableDate = tempDetail.WeldingDate.Date,
|
||||
Remark = "焊接日报待审核通过"
|
||||
};
|
||||
BLL.WeldingDailyService.AddWeldingDaily(weldingDaily);
|
||||
return weldingDaily;
|
||||
}
|
||||
|
||||
private static string NormalizeNullValue(string value)
|
||||
{
|
||||
return value == Const._Null ? null : value;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 日报明细插入(更新焊口信息),组批等
|
||||
/// </summary>
|
||||
/// <param name="weldJointId">焊口ID</param>
|
||||
/// <param name="coverWelderId">盖面焊工ID</param>
|
||||
/// <param name="backingWelderId">打底焊工ID</param>
|
||||
/// <param name="jointAttribute">焊口属性</param>
|
||||
/// <param name="weldingDate">焊接日期</param>
|
||||
/// <param name="batchCondition">组批条件</param>
|
||||
/// <param name="isSave">是否保存</param>
|
||||
/// <param name="weldingDailyId">日报ID</param>
|
||||
/// <param name="projectId">项目ID</param>
|
||||
/// <param name="weldingLocationId">焊接位置ID</param>
|
||||
/// <returns>错误信息</returns>
|
||||
private static string InsertWeldingDailyItem(string weldJointId, string coverWelderId, string backingWelderId, string jointAttribute, DateTime? weldingDate, string batchCondition, bool isSave, string weldingDailyId, string projectId, string weldingLocationId)
|
||||
{
|
||||
string errlog = string.Empty;
|
||||
var newWeldJoint = BLL.WeldJointService.GetWeldJointByWeldJointId(weldJointId);
|
||||
if (newWeldJoint == null)
|
||||
{
|
||||
return "焊口不存在;";
|
||||
}
|
||||
|
||||
var pipeline = BLL.PipelineService.GetPipelineByPipelineId(newWeldJoint.PipelineId);
|
||||
var weldingDaily = BLL.WeldingDailyService.GetPipeline_WeldingDailyByWeldingDailyId(weldingDailyId);
|
||||
if (pipeline == null || weldingDaily == null)
|
||||
{
|
||||
return "焊口关联管线或日报不存在;";
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(coverWelderId) && !string.IsNullOrEmpty(backingWelderId))
|
||||
{
|
||||
if (isSave)
|
||||
{
|
||||
newWeldJoint.WeldingDailyId = weldingDailyId;
|
||||
newWeldJoint.WeldingDailyCode = weldingDaily.WeldingDailyCode;
|
||||
newWeldJoint.CoverWelderId = coverWelderId;
|
||||
newWeldJoint.BackingWelderId = backingWelderId;
|
||||
newWeldJoint.CoverWelderTeamGroupId = SitePerson_PersonService.GetSitePersonByProjectIdPersonId(pipeline.ProjectId, coverWelderId).TeamGroupId;
|
||||
newWeldJoint.BackingWelderTeamGroupId = SitePerson_PersonService.GetSitePersonByProjectIdPersonId(pipeline.ProjectId, backingWelderId).TeamGroupId;
|
||||
if (!string.IsNullOrEmpty(weldingLocationId))
|
||||
{
|
||||
newWeldJoint.WeldingLocationId = weldingLocationId;
|
||||
}
|
||||
newWeldJoint.JointAttribute = jointAttribute;
|
||||
BLL.WeldJointService.UpdateWeldJoint(newWeldJoint);
|
||||
|
||||
// 更新焊口号 修改固定焊口号后 +G
|
||||
BLL.WeldJointService.UpdateWeldJointAddG(newWeldJoint.WeldJointId, newWeldJoint.JointAttribute, Const.BtnAdd);
|
||||
errlog = PointBatchService.AddBatchByWeldJointId(weldJointId, weldingDate, batchCondition);//自动组批
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
errlog = "焊口" + "【" + newWeldJoint.WeldJointCode + "】" + "未选择焊工";
|
||||
}
|
||||
|
||||
return errlog;
|
||||
}
|
||||
#endregion
|
||||
|
||||
/// <summary>
|
||||
/// 日报明细删除
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user