using APT.BaseData.Domain.IServices.FM;
using APT.BaseData.Domain.IServices;
using APT.MS.Domain.Entities.SC.PR;
using APT.Utility;
using Microsoft.AspNetCore.Mvc;
using APT.BaseData.Domain.Entities.FM;
using APT.BaseData.Domain.Entities;
using APT.BaseData.Domain.Enums.PF;
using APT.Infrastructure.Core;
using APT.MS.Domain.Entities.HM;
using APT.MS.Domain.Enums;
using System.Collections.Generic;
using System.Linq;
using System;
using APT.BaseData.Domain.Enums;
namespace APT.SC.WebApi.Controllers.Api.PRController
{
///
/// 滑坡滚石监控处理记录表
///
[Route("api/PR/PRLandslideRollstoneMonitor")]
public partial class LandslideRollstoneMonitorController : AuthorizeApiController
{
IPFCodeRuleService CodeRuleService { get; set; }
IFMFlowPermitService MFlowPermitService { get; set; }
IPFApproveCallBackService ApproveCallBackService { get; set; }
///
/// 滑坡滚石监控处理记录表
///
///
public LandslideRollstoneMonitorController(IPFCodeRuleService codeRuleService, IFMFlowPermitService mFlowPermitService, IPFApproveCallBackService approveCallBackService)
{
CodeRuleService = codeRuleService;
MFlowPermitService = mFlowPermitService;
ApproveCallBackService = approveCallBackService;
}
///
/// 新增/编辑
///
///
///
[HttpPost, Route("FullUpdate")]
public JsonActionResult FullUpdate([FromBody] T_PR_LANDSLIDE_ROLLSTONE_MONITOR entity)
{
return SafeExecute(() =>
{
if (entity.MONITOR_STATUS == 0)
throw new Exception("请选择监测情况");
entity.STATUS = PFStandardStatus.Draft;
var loginUserId = APT.Infrastructure.Api.AppContext.CurrentSession.UserID;
entity.USER_ID = loginUserId;
//附件
var files = entity.Nav_Files;
//附件保存
if (files != null && files.Any())
{
files.ForEach(t =>
{
t.ORG_ID = entity.ORG_ID; t.LANDSLIDE_ROLLSTONE_MONITOR_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[] { ',' });
var param = entity.MONITOR_STATUS.GetDescription();
MFlowPermitService.InsertApprove(serialCode[0], "PR007", param, entity.ID, "PR007_SHOWPRINT", entity.TaskID, true, () =>
{
if (entity != null)
this.UpdateEntityNoCommit(entity);
if (files != null && files.Any())
this.BantchSaveEntityNoCommit(files);
}, null, null, null, null, null, "PR007_SHOWPRINT", null);
return true;
}
UnifiedCommit(() =>
{
if (entity != null)
this.UpdateEntityNoCommit(entity);
if (files != null && files.Any())
this.BantchSaveEntityNoCommit(files);
});
return true;
});
}
///
/// 回调函数
///
///
///
[HttpGet, Route("BackUpdate")]
public JsonActionResult BackUpdate(string id)
{
return SafeExecute(() =>
{
return ApproveCallBackService.CallBack("PR/PRLandslideRollstoneMonitor/BackUpdate", id);
});
}
}
}