303 lines
13 KiB
C#
303 lines
13 KiB
C#
|
|
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.AE;
|
|||
|
|
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;
|
|||
|
|
|
|||
|
|
namespace APT.SC.WebApi.Controllers.Api.AE
|
|||
|
|
{
|
|||
|
|
[Route("api/AE/AEAccidentEventReport")]
|
|||
|
|
public class AEAccidentEventReportController : AuthorizeApiController<T_AE_ACCIDENT_EVENT_REPORT>
|
|||
|
|
{
|
|||
|
|
IFMFlowPermitService MFlowPermitService { get; set; }
|
|||
|
|
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
|||
|
|
IAEAccidentEventReportService AccidentEventReportService { get; set; }
|
|||
|
|
public AEAccidentEventReportController(IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService, IAEAccidentEventReportService accidentEventReportService)
|
|||
|
|
{
|
|||
|
|
MFlowPermitService = mFlowPermitService;
|
|||
|
|
ApproveCallBackService = approveCallBackService;
|
|||
|
|
AccidentEventReportService = accidentEventReportService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事故事件上报 修改
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("FullUpdate")]
|
|||
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_AE_ACCIDENT_EVENT_REPORT entity)
|
|||
|
|
{
|
|||
|
|
return SafeExecute<bool>(() =>
|
|||
|
|
{
|
|||
|
|
if (entity.STATUS != PFStandardStatus.Draft && entity.STATUS != PFStandardStatus.Approving)
|
|||
|
|
{
|
|||
|
|
throw new Exception("获取操作方式有误!");
|
|||
|
|
}
|
|||
|
|
var loginID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|||
|
|
if (entity.CREATE_TIME.HasValue && entity.CREATE_TIME < DateTime.Now && entity.USER_ID.Value != loginID.Value)
|
|||
|
|
{
|
|||
|
|
throw new Exception("此上报单不是您添加的,操作失败!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
var files = entity.Nav_Files;//附件
|
|||
|
|
entity.Nav_Files = null;
|
|||
|
|
|
|||
|
|
var ListAccidentListKind = entity.Nav_ListAccidentListKind;
|
|||
|
|
entity.Nav_ListAccidentListKind = null;
|
|||
|
|
|
|||
|
|
if (ListAccidentListKind != null && ListAccidentListKind.Count > 0)
|
|||
|
|
{
|
|||
|
|
foreach (var item in ListAccidentListKind)
|
|||
|
|
{
|
|||
|
|
item.Nav_AccidentKind = null;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
if (entity.STATUS == PFStandardStatus.Draft)
|
|||
|
|
{
|
|||
|
|
this.UnifiedCommit(() =>
|
|||
|
|
{
|
|||
|
|
if (entity != null)
|
|||
|
|
UpdateEntityNoCommit(entity); //事故事件上报
|
|||
|
|
if (ListAccidentListKind != null && ListAccidentListKind.Any())//事故种类
|
|||
|
|
BantchSaveEntityNoCommit(ListAccidentListKind);
|
|||
|
|
if (files != null && files.Any())//事故现场
|
|||
|
|
BantchSaveEntityNoCommit(files);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
if (string.IsNullOrEmpty(entity.NAME))
|
|||
|
|
{
|
|||
|
|
throw new Exception("请输入事故名称!");
|
|||
|
|
}
|
|||
|
|
if (entity.TIME == null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择事故时间!");
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(entity.ACCIDENT_PLACE))
|
|||
|
|
{
|
|||
|
|
throw new Exception("请输入事故地点!");
|
|||
|
|
}
|
|||
|
|
if (ListAccidentListKind == null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择事故种类!");
|
|||
|
|
}
|
|||
|
|
if (entity.ACCIDENT_TYPE_ID == null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择事故类型!");
|
|||
|
|
}
|
|||
|
|
if (!entity.ACCIDENT_LEVEL.HasValue)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择事故等级!");
|
|||
|
|
}
|
|||
|
|
if (entity.DEPARTMENT_ID == null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择事故部门!");
|
|||
|
|
}
|
|||
|
|
if (entity.USER_ID == null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择发起人!");
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(entity.ACCIDENT_REASON))
|
|||
|
|
{
|
|||
|
|
throw new Exception("请输入事故起因!");
|
|||
|
|
}
|
|||
|
|
if (!entity.ECONOMIC_LOSSES.HasValue)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请输入直接经济损失(元)!");
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(entity.IMPACT_SCOPE))
|
|||
|
|
{
|
|||
|
|
throw new Exception("请输入波及范围!");
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(entity.TAKE_MEASURES))
|
|||
|
|
{
|
|||
|
|
throw new Exception("请输入已采取措施!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//审批
|
|||
|
|
entity.APPROVE_ID = Guid.NewGuid();
|
|||
|
|
string param = AccidentEventReportService.GetApproveParm(entity);
|
|||
|
|
//string.Empty;
|
|||
|
|
//switch (entity.ACCIDENT_LEVEL)
|
|||
|
|
//{
|
|||
|
|
// case AEAccidentLevel.Jumbo:
|
|||
|
|
// case AEAccidentLevel.Major:
|
|||
|
|
// case AEAccidentLevel.Larger:
|
|||
|
|
// case AEAccidentLevel.General:
|
|||
|
|
// case AEAccidentLevel.SeriouslyInjured:
|
|||
|
|
// param = "1_2_3_4_5";
|
|||
|
|
// break;
|
|||
|
|
|
|||
|
|
// case AEAccidentLevel.MinorJuries:
|
|||
|
|
// param = "6";
|
|||
|
|
// break;
|
|||
|
|
// case AEAccidentLevel.Aminor:
|
|||
|
|
// param = "7";
|
|||
|
|
// break;
|
|||
|
|
// case AEAccidentLevel.Risk:
|
|||
|
|
// if (entity.ECONOMIC_LOSSES.HasValue && entity.ECONOMIC_LOSSES.Value >= 5000)
|
|||
|
|
// {
|
|||
|
|
// param = "8>=5000";
|
|||
|
|
// }
|
|||
|
|
// else
|
|||
|
|
// {
|
|||
|
|
// param = "8<5000";
|
|||
|
|
// }
|
|||
|
|
// break;
|
|||
|
|
// default:
|
|||
|
|
// break;
|
|||
|
|
//}
|
|||
|
|
Guid userID = Guid.Empty;
|
|||
|
|
//事故部门 负责人
|
|||
|
|
var dep = GetEntity<T_FM_DEPARTMENT>(entity.DEPARTMENT_ID.Value);
|
|||
|
|
if (dep.USER_ID != null && dep.USER_ID != Guid.Empty)
|
|||
|
|
{
|
|||
|
|
userID = dep.USER_ID.Value;
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
var user = GetEntity<T_FM_USER>(e => e.DEPARTMENT_ID == entity.DEPARTMENT_ID);
|
|||
|
|
if (user == null)
|
|||
|
|
{
|
|||
|
|
throw new Exception("未找到该事故部门成员!");
|
|||
|
|
}
|
|||
|
|
userID = user.ID;
|
|||
|
|
}
|
|||
|
|
MFlowPermitService.InsertApprove("", "AE006", param, entity.ID, "AE006_SHOWPRINT", entity.TaskID, true, () =>
|
|||
|
|
{
|
|||
|
|
if (entity != null)
|
|||
|
|
UpdateEntityNoCommit(entity); //事故事件上报
|
|||
|
|
if (ListAccidentListKind != null && ListAccidentListKind.Any())//事故种类
|
|||
|
|
BantchSaveEntityNoCommit(ListAccidentListKind);
|
|||
|
|
if (files != null && files.Any())//事故现场
|
|||
|
|
BantchSaveEntityNoCommit(files);
|
|||
|
|
}, entity.APPROVE_ID, userID, null, null, null, null, null);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
return true;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 会议通知发布审批回调
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpGet, Route("EventBack")]
|
|||
|
|
public JsonActionResult<bool> RecordBack(string id)
|
|||
|
|
{
|
|||
|
|
return SafeExecute<bool>(() =>
|
|||
|
|
{
|
|||
|
|
return ApproveCallBackService.CallBack("AE/AEAccidentEventReport/EventBack", id);
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 获得单条实体数据(添加限制结束时间)
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="filter">过滤实体</param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("LibGet")]
|
|||
|
|
public JsonActionResult<LibView> LibGet([FromBody] KeywordFilter filter)
|
|||
|
|
{
|
|||
|
|
return SafeExecute(() =>
|
|||
|
|
{
|
|||
|
|
Guid ID = Guid.Empty;
|
|||
|
|
if (filter.FilterGroup.Rules.Count > 0)
|
|||
|
|
{
|
|||
|
|
foreach (var item in filter.FilterGroup.Rules)
|
|||
|
|
{
|
|||
|
|
if (item.Field == "ID")
|
|||
|
|
{
|
|||
|
|
ID = new Guid(item.Value.ToString());
|
|||
|
|
break;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
if (ID == Guid.Empty)
|
|||
|
|
{
|
|||
|
|
return null;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//事故事件上报
|
|||
|
|
var Report = GetEntity<T_AE_ACCIDENT_EVENT_REPORT>(e => e.ID == ID, new string[] { "Nav_AccidentType", "Nav_Department", "Nav_User", "Nav_ListAccidentListKind.Nav_AccidentKind" });
|
|||
|
|
|
|||
|
|
//事故事件调查结果
|
|||
|
|
T_AE_ACCIDENT_EVENT_SURVEY_RESULT SurveyResult = GetEntity<T_AE_ACCIDENT_EVENT_SURVEY_RESULT>(e => e.REPORT_ID == ID && e.STATUS == PFStandardStatus.Archived, new string[] { "Nav_ListSurveyDamageObject.Nav_DamageObject", "Nav_FilesSurvey.Nav_ImgFile", "Nav_FilesP.Nav_ImgFile" });
|
|||
|
|
if (SurveyResult != null)
|
|||
|
|
{
|
|||
|
|
//事故事件原因
|
|||
|
|
SurveyResult.Nav_ListReason = GetEntities<T_AE_ACCIDENT_EVENT_SURVEY_REASON>(e => e.RESULT_ID == SurveyResult.ID, null, new string[] { "Nav_ListReasonType.Nav_ReasonType" }).ToList();
|
|||
|
|
|
|||
|
|
//调查取证资料
|
|||
|
|
SurveyResult.Nav_ListForensics = GetEntities<T_AE_ACCIDENT_EVENT_SURVEY_FORENSICS>(e => e.RESULT_ID == SurveyResult.ID, null, new string[] { "Nav_FilesSurvey.Nav_ImgFile" }).ToList();
|
|||
|
|
|
|||
|
|
//人员伤亡信息
|
|||
|
|
SurveyResult.Nav_ListCasualties = GetEntities<T_AE_ACCIDENT_EVENT_SURVEY_CASUALTIES>(e => e.RESULT_ID == SurveyResult.ID, null, new string[] { "Nav_User" }).ToList();
|
|||
|
|
if (SurveyResult.Nav_ListCasualties != null && SurveyResult.Nav_ListCasualties.Any())
|
|||
|
|
{
|
|||
|
|
//工伤理赔信息
|
|||
|
|
var listClaimRecord = GetEntities<T_TI_INSURANCE_CLAIM_RECORD>(e => e.ACCIDENT_ID == ID && e.STATUS == PFStandardStatus.Archived, null, new string[] { "Nav_Files.Nav_ImgFile" });
|
|||
|
|
if (listClaimRecord != null && listClaimRecord.Any())
|
|||
|
|
{
|
|||
|
|
foreach (var item in SurveyResult.Nav_ListCasualties)
|
|||
|
|
{
|
|||
|
|
var claimRecord = listClaimRecord.FirstOrDefault(e => e.USER_ID == item.USER_ID);
|
|||
|
|
if (claimRecord != null)
|
|||
|
|
{
|
|||
|
|
item.Nav_ClaimRecord = claimRecord;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
//设备设施损失信息
|
|||
|
|
SurveyResult.Nav_ListEquipmentLoss = GetEntities<T_AE_ACCIDENT_EVENT_SURVEY_EQUIPMENT_LOSS>(e => e.RESULT_ID == SurveyResult.ID, null, new string[] { "Nav_Equipment", "Nav_Facilities", "Nav_User" }).ToList();
|
|||
|
|
|
|||
|
|
//事故事件处罚
|
|||
|
|
SurveyResult.Nav_ListAdmPunishment = GetEntities<T_AE_ACCIDENT_EVENT_SURVEY_ADM_PUNISHMENT>(e => e.RESULT_ID == SurveyResult.ID, null, new string[] { "Nav_Department", "Nav_User" }).ToList();
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
LibView result = new LibView();
|
|||
|
|
result.Report = Report;//事故事件上报
|
|||
|
|
result.Result = SurveyResult;//事故事件调查结果
|
|||
|
|
return result;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事故事件库明细查看
|
|||
|
|
/// </summary>
|
|||
|
|
public class LibView
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事故事件上报
|
|||
|
|
/// </summary>
|
|||
|
|
public T_AE_ACCIDENT_EVENT_REPORT Report { get; set; }
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 事故事件调查结果
|
|||
|
|
/// </summary>
|
|||
|
|
public T_AE_ACCIDENT_EVENT_SURVEY_RESULT Result { get; set; }
|
|||
|
|
|
|||
|
|
///// <summary>
|
|||
|
|
///// 工伤保险理赔信息记录
|
|||
|
|
///// </summary>
|
|||
|
|
//public ICollection<T_TI_INSURANCE_CLAIM_RECORD> ListClaimRecord { get; set; }
|
|||
|
|
}
|
|||
|
|
}
|