162 lines
7.5 KiB
C#
162 lines
7.5 KiB
C#
|
|
using APT.BaseData.Domain.Entities;
|
|||
|
|
using APT.BaseData.Domain.Entities.FM;
|
|||
|
|
using APT.BaseData.Domain.Enums.PF;
|
|||
|
|
using APT.BaseData.Domain.IServices;
|
|||
|
|
using APT.BaseData.Domain.IServices.AE;
|
|||
|
|
using APT.BaseData.Domain.IServices.FM;
|
|||
|
|
using APT.Infrastructure.Core;
|
|||
|
|
using APT.MS.Domain.Entities.OH;
|
|||
|
|
using APT.MS.Domain.Entities.TI;
|
|||
|
|
using APT.MS.Domain.Enums;
|
|||
|
|
using APT.Utility;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Linq.Expressions;
|
|||
|
|
|
|||
|
|
namespace APT.SC.WebApi.Controllers.Api.OH
|
|||
|
|
{
|
|||
|
|
[Route("api/OH/OHHazardMonitorResultSum")]
|
|||
|
|
public class OHHazardMonitorResultSumController : AuthorizeApiController<T_OH_HAZARD_MONITOR_RESULT_SUM>
|
|||
|
|
{
|
|||
|
|
IFMFlowPermitService MFlowPermitService { get; set; }
|
|||
|
|
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
|||
|
|
IAEAccidentEventReportService AccidentEventReportService { get; set; }
|
|||
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|||
|
|
IFMUserService UserService { get; set; }
|
|||
|
|
public OHHazardMonitorResultSumController(IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService, IAEAccidentEventReportService accidentEventReportService, IFMNotificationTaskService notificationTaskService, IFMUserService userService)
|
|||
|
|
{
|
|||
|
|
MFlowPermitService = mFlowPermitService;
|
|||
|
|
ApproveCallBackService = approveCallBackService;
|
|||
|
|
AccidentEventReportService = accidentEventReportService;
|
|||
|
|
NotificationTaskService = notificationTaskService;
|
|||
|
|
UserService = userService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获得单条实体数据
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="filter">过滤实体</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("GetSumEdit")]
|
|||
|
|
public JsonActionResult<T_OH_HAZARD_MONITOR_RESULT_SUM> GetSumEdit([FromBody] KeywordFilter filter)
|
|||
|
|
{
|
|||
|
|
return SafeExecute(() =>
|
|||
|
|
{
|
|||
|
|
var sum = GetEntity<T_OH_HAZARD_MONITOR_RESULT_SUM>(null, filter, null);
|
|||
|
|
Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value;
|
|||
|
|
bool isLimit = false;
|
|||
|
|
if (sum != null && sum.Nav_ListMonitorResult != null && sum.Nav_ListMonitorResult.Any())
|
|||
|
|
{
|
|||
|
|
if (sum.STATUS != PFStandardStatus.Archived)
|
|||
|
|
{
|
|||
|
|
foreach (var item in sum.Nav_ListMonitorResult)
|
|||
|
|
{
|
|||
|
|
if (LoginID == item.User_ID)
|
|||
|
|
{
|
|||
|
|
isLimit = true;
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (isLimit)
|
|||
|
|
{
|
|||
|
|
sum.EDITTYPE = 0;
|
|||
|
|
//填单人 只能看到自己的
|
|||
|
|
sum.Nav_ListMonitorResult = sum.Nav_ListMonitorResult.Where(e => e.User_ID == LoginID).ToList();
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sum.EDITTYPE = 1;
|
|||
|
|
sum.Nav_ListMonitorResult = sum.Nav_ListMonitorResult.OrderBy(e => e.User_ID).ToList();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return sum;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 体检周期表 修改
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("FullUpdate")]
|
|||
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_OH_HAZARD_MONITOR_RESULT_SUM entity)
|
|||
|
|
{
|
|||
|
|
return SafeExecute<bool>(() =>
|
|||
|
|
{
|
|||
|
|
//判断 是不是 安环部负责人 如果不是 状态修改到 子表 子表 中 如果除了登陆者大家都提交了 发送待办给 安环部负责人
|
|||
|
|
Guid LoginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID.Value;
|
|||
|
|
var UserLogin = GetEntity<T_FM_USER>(e => e.ID == LoginID, "Nav_ApproveRole");
|
|||
|
|
|
|||
|
|
var ListMonitorResult = entity.Nav_ListMonitorResult;
|
|||
|
|
entity.Nav_ListMonitorResult = null;
|
|||
|
|
if (ListMonitorResult == null || !ListMonitorResult.Any())
|
|||
|
|
{
|
|||
|
|
throw new Exception("获取检测结果统计详情失败!");
|
|||
|
|
}
|
|||
|
|
//记录人、安环部负责人 结束操作
|
|||
|
|
T_FM_NOTIFICATION_TASK taskEnd = null;
|
|||
|
|
//给安环部负责人发送待办
|
|||
|
|
T_FM_NOTIFICATION_TASK taskSendToSafe = null;
|
|||
|
|
if (UserLogin.APPROVE_ROLE_ID.HasValue && UserLogin.Nav_ApproveRole.NAME.Contains("安环部负责人"))
|
|||
|
|
{
|
|||
|
|
//安环部负责人 保存并发送 后 直接 结束待办
|
|||
|
|
if (entity.STATUS == PFStandardStatus.Sign)
|
|||
|
|
{
|
|||
|
|
taskEnd = NotificationTaskService.GetEntityTask(entity.TaskID, "OH028_SHOWPRINT");
|
|||
|
|
entity.STATUS = PFStandardStatus.Archived;//安环负责人 归档
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
bool isSend = false;
|
|||
|
|
if (entity.STATUS == PFStandardStatus.Sign)
|
|||
|
|
{
|
|||
|
|
var listDetailID = ListMonitorResult.Select(e => e.ID);
|
|||
|
|
var listCheck = GetEntities<T_OH_HAZARD_MONITOR_RESULT>(e => e.SUM_ID == entity.ID && !listDetailID.Contains(e.ID) && e.STATUS == PFStandardStatus.Draft, null, null);
|
|||
|
|
if (listCheck == null || !listCheck.Any())
|
|||
|
|
isSend = true; //最后一个填写 给安环部负责人发送 信息
|
|||
|
|
|
|||
|
|
//状态修改
|
|||
|
|
entity.STATUS = PFStandardStatus.Draft;
|
|||
|
|
foreach (var item in ListMonitorResult)
|
|||
|
|
{
|
|||
|
|
item.STATUS = PFStandardStatus.Sign;
|
|||
|
|
}
|
|||
|
|
if (entity.TaskID != Guid.Empty)
|
|||
|
|
taskEnd = NotificationTaskService.GetEntityTask(entity.TaskID, "OH028_SHOWPRINT");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (isSend)
|
|||
|
|
{
|
|||
|
|
//给安环部负责人发送信息
|
|||
|
|
var listUserT = GetEntities<T_FM_USER>(e => !e.IS_DELETED && e.Nav_ApproveRole.NAME.Contains("安环部负责人"), null, new string[] { "Nav_ApproveRole" });
|
|||
|
|
if (listUserT == null || !listUserT.Any())
|
|||
|
|
{
|
|||
|
|
throw new Exception("获取安环部负责人失败!");
|
|||
|
|
}
|
|||
|
|
var listUser = listUserT.ToList();
|
|||
|
|
taskSendToSafe = NotificationTaskService.InsertUserNoticeTaskModel("监测结果统计与分析汇总", entity.ID, entity.ORG_ID, listUser[0].ID, listUser[0].NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "OH028");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.UnifiedCommit(() =>
|
|||
|
|
{
|
|||
|
|
if (entity != null)
|
|||
|
|
UpdateEntityNoCommit(entity);
|
|||
|
|
if (ListMonitorResult != null && ListMonitorResult.Any())
|
|||
|
|
BantchSaveEntityNoCommit(ListMonitorResult);
|
|||
|
|
if (taskEnd != null)
|
|||
|
|
UpdateEntityNoCommit(taskEnd);
|
|||
|
|
if (taskSendToSafe != null)
|
|||
|
|
UpdateEntityNoCommit(taskSendToSafe);
|
|||
|
|
});
|
|||
|
|
return true;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|