108 lines
4.6 KiB
C#
108 lines
4.6 KiB
C#
using APT.BaseData.Domain.Entities.FM;
|
|
using APT.BaseData.Domain.Enums;
|
|
using APT.BaseData.Domain.Enums.PF;
|
|
using APT.BaseData.Domain.IServices;
|
|
using APT.BaseData.Domain.IServices.FM;
|
|
using APT.Infrastructure.Core;
|
|
using APT.MS.Domain.Entities.SC.DM;
|
|
using APT.Utility;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace APT.SC.WebApi.Controllers.Api.DMController
|
|
{
|
|
/// <summary>
|
|
/// 设备设施申领
|
|
/// </summary>
|
|
[Route("api/DM/DMDeviceApply")]
|
|
public partial class DeviceApplyController : AuthorizeApiController<T_DM_DEVICE_APPLY>
|
|
{
|
|
IPFCodeRuleService CodeRuleService { get; set; }
|
|
IFMNotificationTaskService NotificationTaskService { get; set; }
|
|
IFMFlowPermitService MFlowPermitService { get; set; }
|
|
IPFApproveCallBackService ApproveCallBackService { get; set; }
|
|
/// <summary>
|
|
/// 设备设施申领
|
|
/// </summary>
|
|
/// <param name="notificationTaskService"></param>
|
|
public DeviceApplyController(IPFCodeRuleService codeRuleService, IFMNotificationTaskService notificationTaskService, IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService)
|
|
{
|
|
CodeRuleService = codeRuleService;
|
|
NotificationTaskService = notificationTaskService;
|
|
MFlowPermitService = mFlowPermitService;
|
|
ApproveCallBackService = approveCallBackService;
|
|
}
|
|
/// <summary>
|
|
/// 新增/编辑
|
|
/// </summary>
|
|
/// <param name="entity"></param>
|
|
/// <returns></returns>
|
|
[HttpPost, Route("FullUpdate")]
|
|
public JsonActionResult<bool> FullUpdate([FromBody] T_DM_DEVICE_APPLY entity)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
entity.TIME = DateTime.Now;
|
|
entity.STATUS = PFStandardStatus.Draft;
|
|
var loginUserId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
|
|
entity.USER_ID = loginUserId;
|
|
var user = this.GetEntity<T_FM_USER>(t => t.ID == loginUserId.Value && t.ENABLE_STATUS == 0);
|
|
entity.DEPARTMENT_ID = user?.DEPARTMENT_ID;
|
|
if (string.IsNullOrEmpty(entity.CODE))
|
|
entity.CODE = DateTime.Now.Year.ToString().PadLeft(4, '0') + DateTime.Now.Month.ToString().PadLeft(2, '0') + DateTime.Now.Day.ToString().PadLeft(2, '0') + new Random().Next().ToString();
|
|
var details = entity.Nav_Details;
|
|
entity.Nav_Details = null;
|
|
if (details != null && details.Any())
|
|
{
|
|
details.ForEach(t =>
|
|
{
|
|
t.ORG_ID = entity.ORG_ID; t.DEVICE_APPLY_ID = entity.ID;
|
|
});
|
|
}
|
|
if (entity.PUBLISH != null && entity.PUBLISH.Equals("SaveAndNotify"))
|
|
{
|
|
entity.STATUS = PFStandardStatus.Approving;
|
|
//取审批流水码
|
|
var sysFilter = new SystemCodeFilter();
|
|
sysFilter.CodeType = (int)PFCodeRuleType.审批流编码;
|
|
sysFilter.Count = 1;
|
|
sysFilter.OrgId = entity.ORG_ID;
|
|
var codes = CodeRuleService.NewGenSerial(sysFilter);
|
|
var serialCode = codes.Split(new char[] { ',' });
|
|
MFlowPermitService.InsertApprove(serialCode[0], "DM014", "", entity.ID, "DM014_SHOWPRINT", entity.TaskID, true, () =>
|
|
{
|
|
if (entity != null)
|
|
this.UpdateEntityNoCommit(entity);
|
|
if (details != null && details.Any())
|
|
this.BantchSaveEntityNoCommit(details);
|
|
}, null, null, null, null, null, "DM014_SHOWPRINT", null);
|
|
return true;
|
|
}
|
|
UnifiedCommit(() =>
|
|
{
|
|
if (entity != null)
|
|
this.UpdateEntityNoCommit(entity);
|
|
if (details != null && details.Any())
|
|
this.BantchSaveEntityNoCommit(details);
|
|
});
|
|
return true;
|
|
});
|
|
}
|
|
|
|
/// <summary>
|
|
/// 回调函数
|
|
/// </summary>
|
|
/// <param name="id"></param>
|
|
/// <returns></returns>
|
|
[HttpGet, Route("BackUpdate")]
|
|
public JsonActionResult<bool> BackUpdate(string id)
|
|
{
|
|
return SafeExecute(() =>
|
|
{
|
|
return ApproveCallBackService.CallBack("DM/DMDeviceApply/BackUpdate", id);
|
|
});
|
|
}
|
|
}
|
|
}
|