425 lines
26 KiB
C#
425 lines
26 KiB
C#
using APT.BaseData.Domain.Entities;
|
|
using APT.BaseData.Domain.Entities.FM;
|
|
using APT.BaseData.Domain.IServices.FM;
|
|
using APT.BaseData.Services.Services.FM;
|
|
using APT.Infrastructure.Core;
|
|
using APT.MS.Domain.Entities.FO;
|
|
using APT.MS.Domain.Enums;
|
|
using APT.Utility;
|
|
using Google.Protobuf.Collections;
|
|
using InfluxData.Net.InfluxDb.Models.Responses;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
|
|
namespace APT.FO.WebApi.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 领导带班下井记录
|
|
/// </summary>
|
|
[Route("api/FO/FOLeaderWellRecord")]
|
|
public partial class LeaderWellRecordController : AuthorizeApiController<T_FO_LEADER_WELL_RECORD>
|
|
{
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|
public LeaderWellRecordController(IFMNotificationTaskService notificationTaskService)
|
|
{
|
|
NotificationTaskService = notificationTaskService;
|
|
}
|
|
[HttpPost, Route("GetEdit")]
|
|
public JsonActionResult<T_FO_LEADER_WELL_RECORD> GetEdit([FromBody] KeywordFilter filter)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
var id = filter.FilterGroup.Rules.FirstOrDefault(t => t.Field == "ID").Value.ToString();
|
|
if (string.IsNullOrEmpty(id))
|
|
this.ThrowError("060010");
|
|
var entity = this.GetEntity<T_FO_LEADER_WELL_RECORD>(id, "Nav_ApplyUser", "Nav_Company", "Nav_ApplyDepartment", "Nav_ProductionUnit", "Nav_Class", "Nav_Users.Nav_User",
|
|
"Nav_Files.Nav_ImgFile.Nav_File");
|
|
if (entity != null)
|
|
{
|
|
var details = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL>(t => t.LEADER_WELL_RECORD_ID == entity.ID, new BaseFilter(entity.ORG_ID), "Nav_DetailFiles.Nav_ImgFile.Nav_File", "Nav_User", "Nav_PreUser", "Nav_AfterUser", "Nav_DetailAreas.Nav_Area").ToList();
|
|
entity.Nav_Details = details.OrderByDescending(t => t.START_DATE).ToList();
|
|
}
|
|
return entity;
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 新增修改
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdate")]
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_FO_LEADER_WELL_RECORD entity)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
var loginUserId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|
var departmentId = APT.Infrastructure.Api.AppContext.CurrentSession.DepartmentID;
|
|
entity.APPLY_USER_ID = loginUserId;
|
|
entity.APPLY_DEPARTMENT_ID = departmentId;
|
|
if (entity.JOB_START_DATE == null)
|
|
{
|
|
throw new Exception("值班开始时间不能为空");
|
|
}
|
|
if (entity.JOB_END_DATE == null)
|
|
{
|
|
throw new Exception("值班结束时间不能为空");
|
|
}
|
|
var userIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_USER>(t => t.LEADER_WELL_RECORD_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
|
var fileIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_FILE>(t => t.LEADER_WELL_RECORD_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
|
var detailIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL>(t => t.LEADER_WELL_RECORD_ID == entity.ID, new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
|
var detailFileIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_FILE>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID), new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
|
var detailAreaIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_AREA>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID), new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
|
var detailPreUserIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID), new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
|
var detailAfterUserIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID), new BaseFilter(entity.ORG_ID)).Select(m => m.ID).ToList();
|
|
var userList = new List<T_FO_LEADER_WELL_RECORD_USER>();
|
|
var fileList = new List<T_FO_LEADER_WELL_RECORD_FILE>();
|
|
var detailList = new List<T_FO_LEADER_WELL_RECORD_DETAIL>();
|
|
var detailFileList = new List<T_FO_LEADER_WELL_RECORD_DETAIL_FILE>();
|
|
var detailAreaList = new List<T_FO_LEADER_WELL_RECORD_DETAIL_AREA>();
|
|
var detailPreUserList = new List<T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER>();
|
|
var detailAfterUserList = new List<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>();
|
|
var users = entity.Nav_Users;
|
|
if (users != null && users.Any())
|
|
{
|
|
users = users.Where(t => !t.IS_DELETED).ToList();
|
|
}
|
|
else
|
|
{
|
|
users = new List<T_FO_LEADER_WELL_RECORD_USER>();
|
|
var currUserRecord = new T_FO_LEADER_WELL_RECORD_USER()
|
|
{
|
|
LEADER_WELL_RECORD_ID = entity.ID,
|
|
USER_ID = (Guid)loginUserId,
|
|
ORG_ID = entity.ORG_ID,
|
|
DEAL_STATUS = 0
|
|
};
|
|
users.Add(currUserRecord);
|
|
}
|
|
entity.Nav_Users = null;
|
|
if (users != null && users.Any())
|
|
{
|
|
foreach (var item in users)
|
|
{
|
|
item.ORG_ID = entity.ORG_ID;
|
|
item.LEADER_WELL_RECORD_ID = entity.ID;
|
|
item.Nav_User = null;
|
|
if (item.USER_ID == loginUserId)
|
|
{
|
|
item.DEAL_STATUS = MS.Domain.Enums.FOUserShiftStatusEnum.已处理;
|
|
}
|
|
userList.Add(item);
|
|
}
|
|
}
|
|
var details = entity.Nav_Details;
|
|
if (details != null && details.Any())
|
|
{
|
|
details = details.Where(t => !t.IS_DELETED).ToList();
|
|
}
|
|
entity.Nav_Details = null;
|
|
if (details != null && details.Any())
|
|
{
|
|
foreach (var item in details)
|
|
{
|
|
if (item.Nav_DetailFiles != null && item.Nav_DetailFiles.Any())
|
|
{
|
|
foreach (var item2 in item.Nav_DetailFiles)
|
|
{
|
|
item2.ORG_ID = entity.ORG_ID;
|
|
item2.LEADER_WELL_RECORD_DETAIL_ID = item.ID;
|
|
item2.Nav_ImgFile = null;
|
|
detailFileList.Add(item2);
|
|
}
|
|
}
|
|
if (item.Nav_DetailAreas != null && item.Nav_DetailAreas.Any())
|
|
{
|
|
foreach (var item2 in item.Nav_DetailAreas)
|
|
{
|
|
item2.ORG_ID = entity.ORG_ID;
|
|
item2.LEADER_WELL_RECORD_DETAIL_ID = item.ID;
|
|
item2.Nav_Area = null;
|
|
detailAreaList.Add(item2);
|
|
}
|
|
}
|
|
if (item.Nav_PreUsers != null && item.Nav_PreUsers.Any())
|
|
{
|
|
foreach (var item2 in item.Nav_PreUsers)
|
|
{
|
|
item2.ORG_ID = entity.ORG_ID;
|
|
item2.LEADER_WELL_RECORD_DETAIL_ID = item.ID;
|
|
item2.Nav_PreUser = null;
|
|
if (item2.PRE_USER_ID == loginUserId)
|
|
{
|
|
item2.PRE_USER_DEAL_STATUS = MS.Domain.Enums.FOUserShiftStatusEnum.已处理;
|
|
}
|
|
detailPreUserList.Add(item2);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
foreach(var user in users)
|
|
{
|
|
T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER currUserRecord = new T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER();
|
|
currUserRecord.ORG_ID = entity.ORG_ID;
|
|
currUserRecord.LEADER_WELL_RECORD_DETAIL_ID = item.ID;
|
|
currUserRecord.PRE_USER_ID = user.USER_ID;
|
|
currUserRecord.PRE_USER_DEAL_STATUS = user.DEAL_STATUS;
|
|
currUserRecord.Nav_PreUser = null;
|
|
if (currUserRecord.PRE_USER_ID == loginUserId)
|
|
{
|
|
currUserRecord.PRE_USER_DEAL_STATUS = MS.Domain.Enums.FOUserShiftStatusEnum.已处理;
|
|
}
|
|
detailPreUserList.Add(currUserRecord);
|
|
}
|
|
}
|
|
if (item.Nav_AfterUsers != null && item.Nav_AfterUsers.Any())
|
|
{
|
|
foreach (var item2 in item.Nav_AfterUsers)
|
|
{
|
|
item2.ORG_ID = entity.ORG_ID;
|
|
item2.LEADER_WELL_RECORD_DETAIL_ID = item.ID;
|
|
item2.Nav_AfterUser = null;
|
|
if (item2.AFTER_USER_ID == loginUserId)
|
|
{
|
|
item2.AFTER_USER_DEAL_STATUS = MS.Domain.Enums.FOUserShiftStatusEnum.已处理;
|
|
}
|
|
detailAfterUserList.Add(item2);
|
|
}
|
|
}
|
|
item.ORG_ID = entity.ORG_ID;
|
|
item.LEADER_WELL_RECORD_ID = entity.ID;
|
|
item.Nav_DetailFiles = null;
|
|
if (item.USER_ID == loginUserId)
|
|
{
|
|
item.USER_DEAL_STATUS = MS.Domain.Enums.FOUserShiftStatusEnum.已处理;
|
|
}
|
|
detailList.Add(item);
|
|
}
|
|
}
|
|
var files = entity.Nav_Files;
|
|
if (files != null && files.Any())
|
|
{
|
|
files = files.Where(t => !t.IS_DELETED).ToList();
|
|
}
|
|
entity.Nav_Files = null;
|
|
if (files != null && files.Any())
|
|
{
|
|
foreach (var item in files)
|
|
{
|
|
item.ORG_ID = entity.ORG_ID;
|
|
item.LEADER_WELL_RECORD_ID = entity.ID;
|
|
item.Nav_ImgFile = null;
|
|
fileList.Add(item);
|
|
}
|
|
}
|
|
entity.STATUS = FOStatusEnum.Draft;
|
|
var sendNotices = new List<T_FM_NOTIFICATION_TASK>();
|
|
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
|
{
|
|
var allUsers = this.GetEntities<T_FM_USER>(t => t.ENABLE_STATUS == 0 && !t.CODE.Contains("admin"), new BaseFilter(entity.ORG_ID));
|
|
var sendUserIds = detailPreUserList.Where(t => t.PRE_USER_ID != loginUserId && t.PRE_USER_ID != null).Select(m => (Guid)m.PRE_USER_ID).Distinct().ToList();
|
|
if (sendUserIds != null && sendUserIds.Any())
|
|
{
|
|
//当班人员不等于自己的,触发签字确认单
|
|
var sendUserNames = allUsers.Where(t => sendUserIds.Contains(t.ID)).Select(m => m.NAME).ToList();
|
|
sendNotices = NotificationTaskService.InsertUserNoticeTaskModels("领导带班下井记录-交班人签字确认", entity.ID, entity.ORG_ID, sendUserIds, sendUserNames, DateTime.Now, entity.JOB_END_DATE.Value, 1, "FO037_SHOWPRINT");
|
|
entity.STATUS = FOStatusEnum.PreSign;
|
|
}
|
|
else
|
|
{
|
|
//触发给现场责任人签字确认
|
|
var detailUserIds = details.Where(t => t.USER_ID != loginUserId && t.USER_ID != null).Select(m => (Guid)m.USER_ID).Distinct().ToList();
|
|
if (detailUserIds != null && detailUserIds.Any())
|
|
{
|
|
var sendUserNames = allUsers.Where(t => detailUserIds.Contains(t.ID)).Select(m => m.NAME).ToList();
|
|
sendNotices = NotificationTaskService.InsertUserNoticeTaskModels("领导带班下井记录-现场责任人签字确认", entity.ID, entity.ORG_ID, detailUserIds, sendUserNames, DateTime.Now, entity.JOB_END_DATE.Value, 1, "FO037_SHOWPRINT");
|
|
entity.STATUS = FOStatusEnum.Sign;
|
|
}
|
|
else
|
|
{
|
|
var afterUserIds = detailAfterUserList.Where(t => t.AFTER_USER_ID != loginUserId && t.AFTER_USER_ID != null).Select(m => (Guid)m.AFTER_USER_ID).Distinct().ToList();
|
|
if (afterUserIds != null && afterUserIds.Any())
|
|
{
|
|
//触发给接班人签字确认
|
|
var sendUserNames = allUsers.Where(t => afterUserIds.Contains(t.ID)).Select(m => m.NAME).ToList();
|
|
sendNotices = NotificationTaskService.InsertUserNoticeTaskModels("领导带班下井记录-接班人签字确认", entity.ID, entity.ORG_ID, afterUserIds, sendUserNames, DateTime.Now, entity.JOB_END_DATE.Value, 1, "FO037_SHOWPRINT");
|
|
entity.STATUS = FOStatusEnum.SignAccept;
|
|
}
|
|
}
|
|
}
|
|
|
|
}
|
|
this.UnifiedCommit(() =>
|
|
{
|
|
if (detailPreUserIds != null && detailPreUserIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER>(detailPreUserIds);
|
|
if (detailAfterUserIds != null && detailAfterUserIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>(detailAfterUserIds);
|
|
if (detailFileIds != null && detailFileIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_FO_LEADER_WELL_RECORD_DETAIL_FILE>(detailFileIds);
|
|
if (detailAreaIds != null && detailAreaIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_FO_LEADER_WELL_RECORD_DETAIL_AREA>(detailAreaIds);
|
|
if (detailIds != null && detailIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_FO_LEADER_WELL_RECORD_DETAIL>(detailIds);
|
|
if (fileIds != null && fileIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_FO_LEADER_WELL_RECORD_FILE>(fileIds);
|
|
if (userIds != null && userIds.Any())
|
|
this.BantchDeleteEntityNoCommit<T_FO_LEADER_WELL_RECORD_USER>(userIds);
|
|
if (entity != null)
|
|
UpdateEntityNoCommit(entity);
|
|
if (detailList != null && detailList.Any())
|
|
this.BantchSaveEntityNoCommit(detailList);
|
|
if (detailFileList != null && detailFileList.Any())
|
|
this.BantchSaveEntityNoCommit(detailFileList);
|
|
if (detailAreaList != null && detailAreaList.Any())
|
|
this.BantchSaveEntityNoCommit(detailAreaList);
|
|
if (detailPreUserList != null && detailPreUserList.Any())
|
|
this.BantchSaveEntityNoCommit(detailPreUserList);
|
|
if (detailAfterUserList != null && detailAfterUserList.Any())
|
|
this.BantchSaveEntityNoCommit(detailAfterUserList);
|
|
if (userList != null && userList.Any())
|
|
this.BantchSaveEntityNoCommit(userList);
|
|
if (fileList != null && fileList.Any())
|
|
this.BantchSaveEntityNoCommit(fileList);
|
|
if (sendNotices != null && sendNotices.Any())
|
|
this.BantchSaveEntityNoCommit(sendNotices);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 签到同意
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("PersonalAgree")]
|
|
public JsonActionResult<bool> PersonalAgree([FromBody] T_FO_LEADER_WELL_RECORD entity)
|
|
{
|
|
return SafeExecute<bool>(() =>
|
|
{
|
|
var orgId = APT.Infrastructure.Api.AppContext.CurrentSession.OrgId;
|
|
var userID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|
if (entity.TaskID != Guid.Empty)
|
|
{
|
|
var currTask = GetEntity<T_FM_NOTIFICATION_TASK>(t => t.ID == entity.TaskID);
|
|
if (currTask != null)
|
|
{
|
|
userID = currTask.USER_ID;
|
|
}
|
|
}
|
|
var allUsers = this.GetEntities<T_FM_USER>(t => t.ENABLE_STATUS == 0 && !t.CODE.Contains("admin"), new BaseFilter(orgId));
|
|
var sendNotices = new List<T_FM_NOTIFICATION_TASK>();
|
|
var detailUsers = new List<T_FO_LEADER_WELL_RECORD_DETAIL>();
|
|
var preUsers = new List<T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER>();
|
|
var afterUsers = new List<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>();
|
|
var record = this.GetEntity<T_FO_LEADER_WELL_RECORD>(entity.ID);
|
|
if (record.STATUS == FOStatusEnum.PreSign)
|
|
{
|
|
var details = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL>(t => t.LEADER_WELL_RECORD_ID == record.ID, new BaseFilter(orgId));
|
|
var detailIds = details.Select(m => m.ID).ToList();
|
|
preUsers = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID) && t.PRE_USER_ID == userID, new BaseFilter(orgId)).ToList();
|
|
if (preUsers != null && preUsers.Any())
|
|
{
|
|
preUsers.ForEach(t => t.PRE_USER_DEAL_STATUS = FOUserShiftStatusEnum.已处理);
|
|
}
|
|
var todoCount = this.GetCount<T_FO_LEADER_WELL_RECORD_DETAIL_PREUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID) && t.PRE_USER_ID != userID && t.PRE_USER_DEAL_STATUS == 0 && t.PRE_USER_ID != null, new BaseFilter(orgId));
|
|
if (todoCount == 0)
|
|
{
|
|
//触发给现场责任人签字确认
|
|
var detailUserIds = details.Where(t => t.USER_ID != userID && t.USER_ID != null).Select(m => (Guid)m.USER_ID).Distinct().ToList();
|
|
if (detailUserIds != null && detailUserIds.Any())
|
|
{
|
|
var sendUserNames = allUsers.Where(t => detailUserIds.Contains(t.ID)).Select(m => m.NAME).ToList();
|
|
sendNotices = NotificationTaskService.InsertUserNoticeTaskModels("领导带班下井记录-现场责任人签字确认", entity.ID, record.ORG_ID, detailUserIds, sendUserNames, DateTime.Now, record.JOB_END_DATE.Value, 1, "FO037_SHOWPRINT");
|
|
record.STATUS = FOStatusEnum.Sign;
|
|
}
|
|
else
|
|
{
|
|
var afterUserIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID) && t.AFTER_USER_ID != userID && t.AFTER_USER_ID != null, new BaseFilter(orgId)).Select(m => (Guid)m.AFTER_USER_ID).Distinct().ToList();
|
|
if (afterUserIds != null && afterUserIds.Any())
|
|
{
|
|
//触发给接班人签字确认
|
|
var sendUserNames = allUsers.Where(t => afterUserIds.Contains(t.ID)).Select(m => m.NAME).ToList();
|
|
sendNotices = NotificationTaskService.InsertUserNoticeTaskModels("领导带班下井记录-接班人签字确认", entity.ID, record.ORG_ID, afterUserIds, sendUserNames, DateTime.Now, record.JOB_END_DATE.Value, 1, "FO037_SHOWPRINT");
|
|
record.STATUS = FOStatusEnum.SignAccept;
|
|
}
|
|
else
|
|
{
|
|
record.STATUS = FOStatusEnum.Archived;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
else if (record.STATUS == FOStatusEnum.Sign)
|
|
{
|
|
var details = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL>(t => t.LEADER_WELL_RECORD_ID == record.ID, new BaseFilter(orgId));
|
|
detailUsers = details.Where(t => t.USER_ID == userID).ToList();
|
|
if (detailUsers != null && detailUsers.Any())
|
|
{
|
|
detailUsers.ForEach(t => t.USER_DEAL_STATUS = FOUserShiftStatusEnum.已处理);
|
|
}
|
|
var todoCount = this.GetCount<T_FO_LEADER_WELL_RECORD_DETAIL>(t => t.LEADER_WELL_RECORD_ID == record.ID && t.USER_ID != userID && t.USER_DEAL_STATUS == 0 && t.USER_ID != null, new BaseFilter(orgId));
|
|
if (todoCount == 0)
|
|
{
|
|
var detailIds = details.Select(m => m.ID).ToList();
|
|
var afterUserIds = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID) && t.AFTER_USER_ID != userID && t.AFTER_USER_ID != null, new BaseFilter(orgId)).Select(m => (Guid)m.AFTER_USER_ID).Distinct().ToList();
|
|
if (afterUserIds != null && afterUserIds.Any())
|
|
{
|
|
//触发给接班人签字确认
|
|
var sendUserNames = allUsers.Where(t => afterUserIds.Contains(t.ID)).Select(m => m.NAME).ToList();
|
|
sendNotices = NotificationTaskService.InsertUserNoticeTaskModels("领导带班下井记录-接班人签字确认", entity.ID, record.ORG_ID, afterUserIds, sendUserNames, DateTime.Now, record.JOB_END_DATE.Value, 1, "FO037_SHOWPRINT");
|
|
record.STATUS = FOStatusEnum.SignAccept;
|
|
}
|
|
else
|
|
{
|
|
record.STATUS = FOStatusEnum.Archived;
|
|
}
|
|
}
|
|
}
|
|
else if (record.STATUS == FOStatusEnum.SignAccept)
|
|
{
|
|
var details = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL>(t => t.LEADER_WELL_RECORD_ID == record.ID, new BaseFilter(orgId));
|
|
var detailIds = details.Select(m => m.ID).ToList();
|
|
afterUsers = this.GetEntities<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID) && t.AFTER_USER_ID == userID, new BaseFilter(orgId)).ToList();
|
|
if (afterUsers != null && afterUsers.Any())
|
|
{
|
|
afterUsers.ForEach(t => t.AFTER_USER_DEAL_STATUS = FOUserShiftStatusEnum.已处理);
|
|
}
|
|
var todoCount = this.GetCount<T_FO_LEADER_WELL_RECORD_DETAIL_AFTERUSER>(t => detailIds.Contains(t.LEADER_WELL_RECORD_DETAIL_ID) && t.AFTER_USER_ID != userID && t.AFTER_USER_DEAL_STATUS == 0 && t.AFTER_USER_ID != null, new BaseFilter(orgId));
|
|
if (todoCount == 0)
|
|
{
|
|
record.STATUS = FOStatusEnum.Archived;
|
|
}
|
|
}
|
|
else
|
|
{
|
|
record.STATUS = FOStatusEnum.Archived;
|
|
}
|
|
T_FM_NOTIFICATION_TASK task = null;
|
|
if (entity.TaskID != Guid.Empty)
|
|
{
|
|
task = NotificationTaskService.GetTaskFinishModel(entity.TaskID);
|
|
task.SOURCE_FORMCODE = "FO037_SHOWPRINT";
|
|
}
|
|
this.UnifiedCommit(() =>
|
|
{
|
|
if (record != null)
|
|
UpdateEntityNoCommit(record);
|
|
if (preUsers != null && preUsers.Any())
|
|
this.BantchSaveEntityNoCommit(preUsers);
|
|
if (detailUsers != null && detailUsers.Any())
|
|
this.BantchSaveEntityNoCommit(detailUsers);
|
|
if (afterUsers != null && afterUsers.Any())
|
|
this.BantchSaveEntityNoCommit(afterUsers);
|
|
if (sendNotices != null && sendNotices.Any())
|
|
this.BantchSaveEntityNoCommit(sendNotices);
|
|
if (task != null)
|
|
this.UpdateEntityNoCommit(task);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
}
|
|
}
|