#EQD-6425 国联民生-衍生品系统移动审批(提交OA流程) - 审批节点支持配置“关联OA移动审批” - 创建OA流程并记录请求、requestId、状态及异常备注 - 支持OA轮询同步审批通过、退回和归档状态 - 本地通过、拒绝、撤回时同步强制归档未结束OA流程 - 增加审批列表OA备注展示及本地Mock联调接口 - 新增OA审批记录表和数据库升级脚本 - OA移动审批使用独立查询地址及isnextflow配置,不影响交易确认书OA
111 lines
4.1 KiB
C#
111 lines
4.1 KiB
C#
using System.Collections.Concurrent;
|
|
using System.Text.Json;
|
|
using YLErp.Helpers;
|
|
|
|
namespace YLErp.Web.WebAPI.Controllers
|
|
{
|
|
/// <summary>
|
|
/// 仅供本地开发验证收益互换移动审批调用链的 OA 模拟接口。
|
|
/// </summary>
|
|
[ApiController]
|
|
[Route("api/mock/tradeApprovalOa")]
|
|
public class TradeApprovalOaMockController : ControllerBase
|
|
{
|
|
private static readonly ConcurrentDictionary<string, MockOaFlow> Flows = new();
|
|
private static readonly JsonSerializerOptions JsonOptions = new()
|
|
{
|
|
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
|
};
|
|
|
|
[HttpPost("createOaFlow")]
|
|
public IActionResult CreateOaFlow([FromBody] JsonElement payload)
|
|
{
|
|
if (!IsEnabled()) return NotFound();
|
|
|
|
var requestId = "mock-" + Guid.NewGuid().ToString("N");
|
|
Flows[requestId] = new MockOaFlow { RequestId = requestId };
|
|
return Json(new { code = 0, data = new { msg = string.Empty, requestid = requestId }, status = "SUCCESS" });
|
|
}
|
|
|
|
[HttpGet("getRequestData")]
|
|
public IActionResult GetRequestData([FromQuery] string requestId)
|
|
{
|
|
if (!IsEnabled()) return NotFound();
|
|
|
|
if (!Flows.TryGetValue(requestId ?? string.Empty, out var flow))
|
|
return Json(new { code = 0, data = Array.Empty<object>(), status = "SUCCESS" });
|
|
|
|
return Json(new
|
|
{
|
|
code = 0,
|
|
data = new[] { new { requestId = flow.RequestId, flowStatusType = flow.FlowStatusType, status = flow.Status } },
|
|
status = "SUCCESS"
|
|
});
|
|
}
|
|
|
|
[HttpPost("forceEndOaFlow")]
|
|
public IActionResult ForceEndOaFlow([FromQuery] string requestId)
|
|
{
|
|
if (!IsEnabled()) return NotFound();
|
|
|
|
if (requestId != null && Flows.TryGetValue(requestId, out var flow))
|
|
{
|
|
flow.FlowStatusType = "3";
|
|
flow.Status = "归档";
|
|
flow.IsEnded = true;
|
|
}
|
|
|
|
return Json(new { code = 0, data = new { resultcode = "0" }, status = "SUCCESS" });
|
|
}
|
|
|
|
[HttpPost("setStatus")]
|
|
public IActionResult SetStatus([FromQuery] string requestId, [FromQuery] string flowStatusType, [FromQuery] string status = null)
|
|
{
|
|
if (!IsEnabled()) return NotFound();
|
|
if (flowStatusType != "0" && flowStatusType != "1" && flowStatusType != "2" && flowStatusType != "3")
|
|
return BadRequest(new { code = 1, msg = "flowStatusType 只能为 0、1 或 2" });
|
|
if (!Flows.TryGetValue(requestId ?? string.Empty, out var flow))
|
|
return NotFound(new { code = 1, msg = "未找到 requestId" });
|
|
if (flow.IsEnded)
|
|
return BadRequest(new { code = 1, msg = "OA 流程已归档" });
|
|
|
|
flow.FlowStatusType = flowStatusType;
|
|
if (!string.IsNullOrWhiteSpace(status))
|
|
flow.Status = status;
|
|
return Json(new { code = 0, data = new { requestId, flowStatusType, status = flow.Status }, status = "SUCCESS" });
|
|
}
|
|
|
|
[HttpGet("flows")]
|
|
public IActionResult GetFlows()
|
|
{
|
|
if (!IsEnabled()) return NotFound();
|
|
|
|
return Json(new
|
|
{
|
|
code = 0,
|
|
data = Flows.Values.Select(x => new { requestId = x.RequestId, flowStatusType = x.FlowStatusType, status = x.Status, isEnded = x.IsEnded }),
|
|
status = "SUCCESS"
|
|
});
|
|
}
|
|
|
|
private static bool IsEnabled()
|
|
{
|
|
return bool.TryParse(AppManager.GetConfiguration()["TradeApprovalOaMock:Enabled"], out var enabled) && enabled;
|
|
}
|
|
|
|
private JsonResult Json(object value)
|
|
{
|
|
return new JsonResult(value, JsonOptions);
|
|
}
|
|
|
|
private sealed class MockOaFlow
|
|
{
|
|
public string RequestId { get; set; }
|
|
public string FlowStatusType { get; set; } = "0";
|
|
public string Status { get; set; } = "创建";
|
|
public bool IsEnded { get; set; }
|
|
}
|
|
|
|
}
|
|
}
|