diff --git a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs index de958b51..b0cec0a9 100644 --- a/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs +++ b/Myshipping.Application/Entity/TrackingSystem/ServiceWorkFlowBaseInfo.cs @@ -1,12 +1,63 @@ -using System; +using Furion.DistributedIDGenerator; +using Myshipping.Application.Entity.TrackingSystem; +using SqlSugar; +using System; using System.Collections.Generic; +using System.ComponentModel; using System.Linq; using System.Text; using System.Threading.Tasks; namespace Myshipping.Application.Entity { - internal class ServiceWorkFlowBaseInfo + /// + /// 服务流程主表 + /// + [SugarTable("service_workflow_base")] + [Description("服务流程主表")] + public class ServiceWorkFlowBaseInfo : TrackingSystemDbEntity { + public ServiceWorkFlowBaseInfo() + { + PK_ID = IDGen.NextID().ToString(); + + CreatedTime = DateTime.Now; + + } + + /// + /// 服务流程代码 + /// + public string SERVICE_WORKFLOW_CODE { get; set; } + + /// + /// 服务流程名称 + /// + public string SERVICE_PROJECT_NAME { get; set; } + + /// + /// 服务流程说明 + /// + public string SERVICE_WORKFLOW_NOTE { get; set; } + + /// + /// 发布版本 + /// + public string RELEASE_VERSION { get; set; } + + /// + /// 是否启用 1-启用 0-未启用 + /// + public int IS_ENABLE { get; set; } = 0; + + /// + /// 所属租户ID + /// + public string BELONG_TENANT_ID { get; set; } + + /// + /// 所属租户名称 + /// + public string BELONG_TENANT_NAME { get; set; } } } diff --git a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs index 87fe7d20..755c7d77 100644 --- a/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs +++ b/Myshipping.Application/Service/BookingTruck/BookingTruckService.cs @@ -1815,21 +1815,26 @@ namespace Myshipping.Application bookingTruckSyncDto.OperType = "Delete"; var bookingOrder = _bookingOrderRepository.AsQueryable() - .First(a => a.Id == bookingTruckInfo.BookingId); + .First(a => a.Id == bookingTruckInfo.BookingId.Value); if (bookingOrder != null) { _logger.LogInformation("判断回写需要更新去掉订舱的车队 id={id} truckid={truckid} truck={truck}", - bookingTruckInfo.BookingId, bookingOrder.TRUCKERID, bookingOrder.TRUCKER); + bookingTruckInfo.BookingId.Value, bookingOrder.TRUCKERID, bookingOrder.TRUCKER); bookingOrder.TRUCKERID = null; bookingOrder.TRUCKER = null; + bookingOrder.VERSION = IDGen.NextID().ToString().Replace("-", ""); - await _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new + _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new { it.TRUCKERID, it.TRUCKER - }).ExecuteCommandAsync(); + }).ExecuteCommand(); + + var syncDongshengRlt = await _bookingOrderService.SendBookingOrder(new long[] { bookingTruckInfo.BookingId.Value }); + + _logger.LogInformation($"推送订舱同步东胜完毕,id={bookingTruckInfo.BookingId.Value} rlt={JSON.Serialize(syncDongshengRlt)}"); _logger.LogInformation("判断回写需要更新去掉订舱的车队,更新完成"); } @@ -1842,20 +1847,25 @@ namespace Myshipping.Application if (!string.IsNullOrWhiteSpace(info.TruckCode)) { var bookingOrder = _bookingOrderRepository.AsQueryable() - .First(a => a.Id == bookingTruckInfo.BookingId); + .First(a => a.Id == bookingTruckInfo.BookingId.Value); - if (bookingOrder != null && string.IsNullOrWhiteSpace(bookingOrder.TRUCKERID)) + if (bookingOrder != null) { - _logger.LogInformation("判断回写需要更新订舱的车队 id={id} truck={truck}", bookingTruckInfo.BookingId, info.TruckName); + _logger.LogInformation("判断回写需要更新订舱的车队 id={id} truck={truck}", bookingTruckInfo.BookingId.Value, info.TruckName); bookingOrder.TRUCKERID = info.TruckCode; bookingOrder.TRUCKER = info.TruckName; + bookingOrder.VERSION = IDGen.NextID().ToString().Replace("-", ""); - await _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new + _bookingOrderRepository.AsUpdateable(bookingOrder).UpdateColumns(it => new { it.TRUCKERID, it.TRUCKER - }).ExecuteCommandAsync(); + }).ExecuteCommand(); + + var syncDongshengRlt = await _bookingOrderService.SendBookingOrder(new long[] { bookingTruckInfo.BookingId.Value }); + + _logger.LogInformation($"推送订舱同步东胜完毕,id={bookingTruckInfo.BookingId.Value} rlt={JSON.Serialize(syncDongshengRlt)}"); _logger.LogInformation("判断回写需要更新订舱的车队,更新完成"); } diff --git a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs index 2b789bc2..0cb3be25 100644 --- a/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs +++ b/Myshipping.Application/Service/TrackingSystem/Dtos/ServiceWorkFlowBaseDto.cs @@ -9,7 +9,26 @@ namespace Myshipping.Application /// /// 服务流程 /// - internal class ServiceWorkFlowBaseDto + public class ServiceWorkFlowBaseDto { + /// + /// 主键 + /// + public string PKId { get; set; } + + /// + /// 服务流程代码 + /// + public string ServiceWorkflowCode { get; set; } + + /// + /// 服务流程名称 + /// + public string ServiceWorkflowName { get; set; } + + /// + /// 服务流程说明 + /// + public string ServiceWorkflowNote { get; set; } } } diff --git a/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs new file mode 100644 index 00000000..7c56f2da --- /dev/null +++ b/Myshipping.Application/Service/TrackingSystem/ServiceWorkFlowBaseService.cs @@ -0,0 +1,246 @@ +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) + { + + } + + }*/ +}