105 lines
4.2 KiB
C#
105 lines
4.2 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/OHHazardMonitorJobReport")]
|
|||
|
|
public class OHHazardMonitorJobReportController : AuthorizeApiController<T_OH_HAZARD_MONITOR_JOB_REPORT>
|
|||
|
|
{
|
|||
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|||
|
|
public OHHazardMonitorJobReportController(IFMNotificationTaskService notificationTaskService)
|
|||
|
|
{
|
|||
|
|
NotificationTaskService = notificationTaskService;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 体检周期表 修改
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="entity"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("FullUpdate")]
|
|||
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_OH_HAZARD_MONITOR_JOB_REPORT entity)
|
|||
|
|
{
|
|||
|
|
return SafeExecute<bool>(() =>
|
|||
|
|
{
|
|||
|
|
var files = entity.Nav_Files;
|
|||
|
|
entity.Nav_Files = null;
|
|||
|
|
T_FM_NOTIFICATION_TASK task = null;
|
|||
|
|
if (entity.TaskID != Guid.Empty)
|
|||
|
|
{
|
|||
|
|
task = GetEntity<T_FM_NOTIFICATION_TASK>(entity.TaskID);
|
|||
|
|
task.SOURCE_DATA_ID = entity.ID;
|
|||
|
|
}
|
|||
|
|
if (entity.STATUS == PFStandardStatus.Archived)
|
|||
|
|
{
|
|||
|
|
if (entity.YEAR == 0)
|
|||
|
|
{
|
|||
|
|
throw new Exception("请选择年度!");
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(entity.NAME))
|
|||
|
|
{
|
|||
|
|
throw new Exception("请填写文件名称!");
|
|||
|
|
}
|
|||
|
|
if (string.IsNullOrEmpty(entity.DEPARTMENTNAME_JOB))
|
|||
|
|
{
|
|||
|
|
throw new Exception("请填写监测单位!");
|
|||
|
|
}
|
|||
|
|
if (entity.BEGINTIME_MONITOR.HasValue && entity.ENDTIME_MONITOR.HasValue && entity.BEGINTIME_MONITOR.Value > entity.ENDTIME_MONITOR.Value)
|
|||
|
|
{
|
|||
|
|
throw new Exception("监测开始时间不能大于监测结束时间!");
|
|||
|
|
}
|
|||
|
|
if (files == null || !files.Any())
|
|||
|
|
{
|
|||
|
|
throw new Exception("请上传附件!");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
entity.DEPARTMENT_ID = APT.Infrastructure.Api.AppContext.DepartmentID;
|
|||
|
|
entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|||
|
|
if (task != null)
|
|||
|
|
{
|
|||
|
|
task.TASK_DT = DateTime.Now;
|
|||
|
|
task.SOURCE_FORMCODE = "OH034_SHOWPRINT";
|
|||
|
|
if (task.TASK_ENDDT >= task.TASK_DT)
|
|||
|
|
task.NOTICE_STATUS = (int)FMNoticeStatusEnum.正常已办;
|
|||
|
|
else
|
|||
|
|
task.NOTICE_STATUS = (int)FMNoticeStatusEnum.超期办理;
|
|||
|
|
}
|
|||
|
|
else if (entity.TaskID != Guid.Empty)
|
|||
|
|
{
|
|||
|
|
task = NotificationTaskService.GetEntityTask(entity.TaskID, "OH034_SHOWPRINT");
|
|||
|
|
task.SOURCE_DATA_ID = entity.ID;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
foreach (var item in files)
|
|||
|
|
{
|
|||
|
|
item.REPORT_ID = entity.ID;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
this.UnifiedCommit(() =>
|
|||
|
|
{
|
|||
|
|
if (entity != null)
|
|||
|
|
UpdateEntityNoCommit(entity);
|
|||
|
|
if (files != null && files.Any())
|
|||
|
|
BantchSaveEntityNoCommit(files);
|
|||
|
|
if (task != null)//待办
|
|||
|
|
UpdateEntityNoCommit(task);
|
|||
|
|
});
|
|||
|
|
return true;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|