using Furion.DependencyInjection;
using Furion.DynamicApiController;
using Furion.FriendlyException;
using Furion.JsonSerialization;
using Mapster;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using Myshipping.Application.Entity;
using Myshipping.Core;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/*
///
/// 服务流程
///
[ApiDescriptionSettings("Application", Name = "ServiceWorkFlowBase", Order = 10)]
public class ServiceWorkFlowBaseService : IServiceWorkFlowBaseService, IDynamicApiController, ITransient
{
private readonly SqlSugarRepository _serviceWorkFlowBaseRepository;
private readonly SqlSugarRepository _serviceWorkFlowActivitiesInfoRepository;
private readonly ILogger _logger;
public ServiceWorkFlowBaseService(SqlSugarRepository serviceWorkFlowBaseRepository,
ILogger logger,
SqlSugarRepository serviceWorkFlowActivitiesInfoRepository)
{
_serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository;
_serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository;
}
///
/// 保存
///
/// 服务流程详情
/// 返回回执
[HttpPost("/ServiceWorkFlowBase/Save")]
public async Task Save([FromBody] ServiceWorkFlowBaseDto info)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
var id = await InnerSave(info);
result.succ = true;
result.msg = "保存成功";
result.ext = id;
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"保存服务项目异常,原因:{ex.Message}";
}
return result;
}
#region 保存内部方法
///
/// 保存内部方法
///
/// 服务项目详情
/// 是否启用
/// 返回派车Id
[SqlSugarUnitOfWork]
private async Task InnerSave(StatusSkuBaseDto info, bool isSetEnable = false)
{
StatusSkuBaseInfo entity = info.Adapt();
if (isSetEnable)
{
entity.IS_ENABLE = 1;
}
if (entity == null)
throw Oops.Oh($"服务项目不能为空", typeof(InvalidOperationException));
_logger.LogInformation($"服务项目保存 JSON={JSON.Serialize(entity)} user={UserManager.UserId}");
if (string.IsNullOrWhiteSpace(entity.PK_ID))
{
_statusSkuBaseInfoRepository.Insert(entity);
}
else
{
var model = InnerGetInfo(entity.PK_ID);
_logger.LogInformation($"更新状态前,获取原始记录 JSON={JSON.Serialize(model)}");
if (!entity.STATUS_SKU_CODE.Equals(model.STATUS_SKU_CODE, StringComparison.OrdinalIgnoreCase))
{
ValidateServiceProject(entity, true);
}
entity.UpdatedTime = DateTime.Now;
entity.UpdatedUserId = UserManager.UserId;
entity.UpdatedUserName = UserManager.Name;
await _statusSkuBaseInfoRepository.AsUpdateable(entity).IgnoreColumns(it => new
{
it.TenantId,
it.TenantName,
it.CreatedTime,
it.CreatedUserId,
it.CreatedUserName,
it.IsDeleted,
}).ExecuteCommandAsync();
}
return entity.PK_ID;
}
#endregion
#region 单票查询
///
/// 单票查询
///
/// 状态主键
private StatusSkuBaseInfo InnerGetInfo(string pkId)
{
if (string.IsNullOrWhiteSpace(pkId))
{
throw Oops.Oh($"状态主键不能为空", typeof(InvalidOperationException));
}
var model = _statusSkuBaseInfoRepository.AsQueryable().First(a => a.PK_ID == pkId);
if (model == null)
throw Oops.Oh($"状态获取失败,状态信息不存在或已作废", typeof(InvalidOperationException));
return model;
}
#endregion
///
/// 保存并启用
///
/// 服务流程详情
/// 返回回执
public async Task SaveAndEnable(ServiceWorkFlowBaseDto info)
{
}
///
/// 启用
///
/// 服务流程主键
/// 返回回执
public async Task SetEnable(string pkId)
{
}
///
/// 取消启用
///
/// 服务流程主键
/// 返回回执
public async Task SetUnEnable(string pkId)
{
}
///
/// 删除
///
/// 服务流程主键
/// 返回回执
public async Task Delete(string pkId)
{
}
///
/// 复制
///
/// 服务流程主键
/// 返回回执
public async Task Copy(string pkId)
{
}
///
/// 获取服务流程详情
///
/// 服务流程主键
/// 返回回执
public async Task GetInfo(string pkId)
{
}
///
/// 检索服务流程列表
///
/// 检索值
/// 最大返回行数(默认15)
/// 返回回执
public async Task QueryList(string queryItem, int topNum = 15)
{
}
///
/// 服务流程台账查询
///
/// 服务流程台账查询请求
/// 返回结果
public async Task> GetPageAsync(QueryServiceWorkFlowBaseDto QuerySearch)
{
}
///
/// 发布服务流程
///
/// 服务流程主键
/// 返回回执
public async Task PublishRelease(string pkId)
{
}
///
/// 获取展示服务流程时间轴列表
///
/// 服务流程主键
/// 返回回执
public async Task GetShowTimeLine(string pkId)
{
}
}*/
}