113 lines
5.1 KiB
C#
113 lines
5.1 KiB
C#
|
|
|
|||
|
|
using APT.BaseData.Domain.Entities;
|
|||
|
|
using APT.BaseData.Domain.Enums.PF;
|
|||
|
|
using APT.BaseData.Domain.IServices.FM;
|
|||
|
|
using APT.BaseData.Domain.IServices;
|
|||
|
|
using APT.Infrastructure.Core;
|
|||
|
|
using APT.MS.Domain.Entities.DM;
|
|||
|
|
using APT.Utility;
|
|||
|
|
using Microsoft.AspNetCore.Mvc;
|
|||
|
|
using System;
|
|||
|
|
using System.Linq;
|
|||
|
|
using NPOI.SS.Formula.Functions;
|
|||
|
|
using APT.BaseData.Domain.Entities.FM;
|
|||
|
|
|
|||
|
|
namespace APT.SC.WebApi.Controllers.Api.DM
|
|||
|
|
{
|
|||
|
|
[Route("api/DM/DMDeviceRepair")]
|
|||
|
|
public class DeviceRepairController : AuthorizeApiController<T_DM_DEVICE_REPAIR>
|
|||
|
|
{
|
|||
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|||
|
|
public DeviceRepairController(IFMNotificationTaskService notificationTaskService)
|
|||
|
|
{
|
|||
|
|
NotificationTaskService = notificationTaskService;
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 更新
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="id"></param>
|
|||
|
|
/// <returns></returns>
|
|||
|
|
[HttpPost, Route("FullUpdate")]
|
|||
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_DM_DEVICE_REPAIR entity)
|
|||
|
|
{
|
|||
|
|
return SafeExecute<bool>(() =>
|
|||
|
|
{
|
|||
|
|
var files = entity.Nav_Files;
|
|||
|
|
entity.Nav_Files = null;
|
|||
|
|
if (entity.CODE == null)
|
|||
|
|
{
|
|||
|
|
entity.CODE = DateTime.Now.ToString("yyyyMMddHHmmss");
|
|||
|
|
}
|
|||
|
|
if (entity.USER_ID == null || entity.USER_ID == Guid.Empty)
|
|||
|
|
{
|
|||
|
|
entity.USER_ID = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|||
|
|
}
|
|||
|
|
if (entity.REPAIR_TIME == DateTime.Parse("0001-01-01 00:00:00"))
|
|||
|
|
{
|
|||
|
|
entity.REPAIR_TIME = DateTime.Now;
|
|||
|
|
}
|
|||
|
|
if(entity.STATUS== PFStandardStatus.Archived)
|
|||
|
|
{
|
|||
|
|
throw new Exception("已归档不能编辑");
|
|||
|
|
}
|
|||
|
|
T_FM_NOTIFICATION_TASK sendNotice = null;
|
|||
|
|
T_FM_NOTIFICATION_TASK finishNotice = null;
|
|||
|
|
T_DM_DEVICE_OVERHAUL overhaul= null;
|
|||
|
|
|
|||
|
|
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
|||
|
|
{
|
|||
|
|
if (entity.STATUS == PFStandardStatus.Draft)
|
|||
|
|
{
|
|||
|
|
entity.STATUS = PFStandardStatus.Sign;
|
|||
|
|
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("设备设施故障报修-" + entity.MACHINE_NAME, entity.ID, entity.ORG_ID, (Guid)entity.REPAIR_CHARGE_USER_ID, GetEntity<T_FM_USER>(entity.REPAIR_CHARGE_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "DM020");
|
|||
|
|
}
|
|||
|
|
else if (entity.STATUS == PFStandardStatus.Sign)
|
|||
|
|
{
|
|||
|
|
entity.STATUS = PFStandardStatus.Archived;
|
|||
|
|
finishNotice = NotificationTaskService.FOGetTaskFinishModel(entity.TaskID,entity.ID, "DM020_SHOWPRINT");
|
|||
|
|
overhaul=new T_DM_DEVICE_OVERHAUL
|
|||
|
|
{
|
|||
|
|
ID= Guid.NewGuid(),
|
|||
|
|
OVERHAUL_TIME=DateTime.Now,
|
|||
|
|
CODE= DateTime.Now.ToString("yyyyMMddHHmmss"),
|
|||
|
|
USER_ID=entity.REPAIR_USER_ID,
|
|||
|
|
DEVICE_BASE_ID=entity.DEVICE_BASE_ID,
|
|||
|
|
MACHINE_NAME=entity.MACHINE_NAME,
|
|||
|
|
SPEC= entity.SPEC,
|
|||
|
|
MACHINE_CODE=entity.MACHINE_CODE,
|
|||
|
|
POSITION= entity.POSITION,
|
|||
|
|
MALFUCTION=entity.DESCRPTION,
|
|||
|
|
REPAIR_ID=entity.ID,
|
|||
|
|
ORG_ID=entity.ORG_ID,
|
|||
|
|
IS_HELP=entity.IS_HELP,
|
|||
|
|
};
|
|||
|
|
if (entity.IS_HELP == true)
|
|||
|
|
{
|
|||
|
|
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("设备设施检修记录-"+entity.MACHINE_NAME, overhaul.ID, entity.ORG_ID, (Guid)entity.REPAIR_CHARGE_USER_ID, GetEntity<T_FM_USER>(entity.REPAIR_CHARGE_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "DM022");
|
|||
|
|
}
|
|||
|
|
else
|
|||
|
|
{
|
|||
|
|
sendNotice = NotificationTaskService.InsertUserNoticeTaskModel("设备设施检修记录-" + entity.MACHINE_NAME, overhaul.ID, entity.ORG_ID, (Guid)entity.REPAIR_USER_ID, GetEntity<T_FM_USER>(entity.REPAIR_USER_ID.Value).NAME, DateTime.Now, DateTime.Now.AddDays(1), 0, "DM022");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
UnifiedCommit(() =>
|
|||
|
|
{
|
|||
|
|
UpdateEntityNoCommit(entity);
|
|||
|
|
if (files != null && files.Any())
|
|||
|
|
BantchSaveEntityNoCommit(files);
|
|||
|
|
if (sendNotice != null)
|
|||
|
|
AddEntityNoCommit(sendNotice);
|
|||
|
|
if (finishNotice != null)
|
|||
|
|
UpdateEntityNoCommit(finishNotice);
|
|||
|
|
if (overhaul != null)
|
|||
|
|
AddEntityNoCommit(overhaul);
|
|||
|
|
});
|
|||
|
|
return true;
|
|||
|
|
});
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
}
|
|||
|
|
}
|