optimize
jianghaiqing 1 year ago
parent c89b85ae2a
commit d5563f5554

@ -0,0 +1,33 @@
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
{
[SugarTable("booking_auto_yard_import")]
[Description("场站数据自动引入状态")]
public class BookingYardDataAuto
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(IsIdentity = true, ColumnDescription = "Id主键", IsPrimaryKey = true)] //通过特性设置主键和自增列
public long Id { get; set; }
/// <summary>
/// 状态:引入成功、比对失败
/// </summary>
public string Status { get; set; }
/// <summary>
/// 比对结果内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreatedTime { get; set; }
}
}

@ -0,0 +1,44 @@
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
{
/// <summary>
///
/// </summary>
[SugarTable("booking_auto_yard_import")]
[Description("场站自动引入信息")]
public class Booking_AutoYardImport
{
/// <summary>
/// 主键
/// </summary>
[SugarColumn(ColumnDescription = "Id主键", IsPrimaryKey = true)] //通过特性设置主键和自增列
public long Id { get; set; }
/// <summary>
/// 状态:引入成功、比对失败
/// </summary>
public string Status { get; set; }
/// <summary>
/// 比对结果内容
/// </summary>
public string Content { get; set; }
/// <summary>
/// 创建时间
/// </summary>
public DateTime? CreatedTime { get; set; }
/// <summary>
/// 场站数据JSON
/// </summary>
public string YardJson { get; set; }
/// <summary>
/// 比对数据时填写的箱信息JSON
/// </summary>
public string CtnJson { get; set; }
}
}

@ -12,15 +12,15 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public enum TrackingSourceTypeEnum public enum TrackingSourceTypeEnum
{ {
/// <summary>
/// 自动
/// </summary>
[Description("自动")]
AUTO,
/// <summary> /// <summary>
/// 人工 /// 人工
/// </summary> /// </summary>
[Description("人工")] [Description("人工")]
MANUAL, MANUAL,
/// <summary>
/// 自动
/// </summary>
[Description("自动")]
AUTO
} }
} }

@ -2276,7 +2276,7 @@ namespace Myshipping.Application
OpertType = TrackingOperTypeEnum.MANUAL, OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(), OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name, OperUserName = UserManager.Name,
SourceType = TrackingSourceTypeEnum.MANUAL, SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{ {
StatusCode = a.StatusCode, StatusCode = a.StatusCode,
@ -2368,7 +2368,7 @@ namespace Myshipping.Application
OpertType = TrackingOperTypeEnum.MANUAL, OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(), OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name, OperUserName = UserManager.Name,
SourceType = TrackingSourceTypeEnum.MANUAL, SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{ {
StatusCode = a.StatusCode, StatusCode = a.StatusCode,

@ -32,6 +32,11 @@ namespace Myshipping.Application
/// </summary> /// </summary>
public long BookingId { get; set; } public long BookingId { get; set; }
/// <summary>
/// 来源类型
/// </summary>
public TrackingSourceTypeEnum SourceType { get; set; } = TrackingSourceTypeEnum.MANUAL;
/// <summary> /// <summary>
/// 服务项目状态明细 /// 服务项目状态明细
/// </summary> /// </summary>

@ -0,0 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
/// <summary>
/// Ocr上传后返回
/// </summary>
public class OcrUploadOutputDto
{
/// <summary>
/// OCR返回文件名后面调用OCR获取内容时使用
/// </summary>
public string OcrFileName { get; set; }
/// <summary>
/// 上传附件的文件名
/// </summary>
public string UploadFileName { get; set; }
}
}

@ -37,14 +37,18 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository; private readonly SqlSugarRepository<BookingCtn> _bookingOrderContaRepository;
//private readonly SqlSugarRepository<SysUser> _userRepository; //private readonly SqlSugarRepository<SysUser> _userRepository;
private readonly IBookingValueAddedService _bookingValueAddedService;
public TaskShippingOrderCompareService(ISysCacheService cache, ILogger<TaskShippingOrderCompareService> logger, public TaskShippingOrderCompareService(ISysCacheService cache, ILogger<TaskShippingOrderCompareService> logger,
SqlSugarRepository<BookingOrder> bookingOrderRepository, SqlSugarRepository<BookingCtn> bookingOrderContaRepository) SqlSugarRepository<BookingOrder> bookingOrderRepository, SqlSugarRepository<BookingCtn> bookingOrderContaRepository,
IBookingValueAddedService bookingValueAddedService)
{ {
_cache = cache; _cache = cache;
_logger = logger; _logger = logger;
_bookingOrderRepository = bookingOrderRepository; _bookingOrderRepository = bookingOrderRepository;
_bookingOrderContaRepository = bookingOrderContaRepository; _bookingOrderContaRepository = bookingOrderContaRepository;
_bookingValueAddedService = bookingValueAddedService;
} }
/// <summary> /// <summary>
/// 执行下货纸比对 /// 执行下货纸比对
@ -153,6 +157,21 @@ namespace Myshipping.Application
{ {
orderInfo.LstShipOrderCompareRlt = "NO_DIFF"; orderInfo.LstShipOrderCompareRlt = "NO_DIFF";
orderInfo.LstShipOrderCompareRltName = "正常"; orderInfo.LstShipOrderCompareRltName = "正常";
//推送状态JHQ
if (App.Configuration["ServiceStatusOpenAuto"] == "1")
{
//比对成功后触发下货纸比对状态
var saveStatusRlt = await _bookingValueAddedService.SaveServiceStatus(new ModifyServiceProjectStatusDto
{
BookingId = long.Parse(bookingId),
SourceType = TrackingSourceTypeEnum.AUTO,
StatusCodes = new List<ModifyServiceProjectStatusDetailDto> {
new ModifyServiceProjectStatusDetailDto { StatusCode = "XHZBDCHG" } }
});
_logger.LogInformation("批次={no} 异步推送下货纸比对状态完成,结果={rlt}", batchNo, JSON.Serialize(saveStatusRlt));
}
} }
} }
else else

@ -130,7 +130,18 @@ namespace Myshipping.Application
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<List<ServiceProjectWithStatusDto>> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false); Task<List<ServiceProjectWithStatusDto>> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false);
/// <summary>
/// 获取可用的服务项目字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableProjectDictTreeList(bool isAvoidCache = false);
/// <summary>
/// 获取可用的服务状态字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableStatusDictTreeList(bool isAvoidCache = false);
} }
} }

@ -77,5 +77,19 @@ namespace Myshipping.Application
/// <param name="model">查询服务项目和状态详情</param> /// <param name="model">查询服务项目和状态详情</param>
/// <returns>返回回执</returns> /// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetEnableStatusListByBusiness(QueryServiceProjectWithStatus model); Task<TaskManageOrderResultDto> GetEnableStatusListByBusiness(QueryServiceProjectWithStatus model);
/// <summary>
/// 保存服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> SaveServiceStatus(ModifyServiceProjectStatusDto model);
/// <summary>
/// 取消服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> CancelServiceStatus(ModifyServiceProjectStatusDto model);
} }
} }

@ -3,6 +3,7 @@ using Furion.DistributedIDGenerator;
using Furion.DynamicApiController; using Furion.DynamicApiController;
using Furion.FriendlyException; using Furion.FriendlyException;
using Furion.JsonSerialization; using Furion.JsonSerialization;
using Furion.Localization;
using Mapster; using Mapster;
using Microsoft.AspNetCore.Mvc; using Microsoft.AspNetCore.Mvc;
using Microsoft.CodeAnalysis.CSharp.Syntax; using Microsoft.CodeAnalysis.CSharp.Syntax;
@ -12,7 +13,9 @@ using Myshipping.Application.Entity;
using Myshipping.Application.Helper; using Myshipping.Application.Helper;
using Myshipping.Core; using Myshipping.Core;
using Myshipping.Core.Entity; using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using MySqlX.XDevAPI.Common; using MySqlX.XDevAPI.Common;
using Npoi.Mapper;
using NPOI.SS.Formula.Functions; using NPOI.SS.Formula.Functions;
using NPOI.SS.Formula.PTG; using NPOI.SS.Formula.PTG;
using NPOI.Util; using NPOI.Util;
@ -2015,6 +2018,86 @@ namespace Myshipping.Application
} }
#endregion #endregion
#region 获取可用的服务项目字典列表
/// <summary>
/// 获取可用的服务项目字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
[HttpGet("/ServiceWorkFlowBase/GetEnableProjectDictTreeList")]
public async Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableProjectDictTreeList([FromQuery] bool isAvoidCache = false)
{
List<Myshipping.Core.Service.DictTreeOutput> resultList = new List<Core.Service.DictTreeOutput>();
var list = await GetEnableProjectList(UserManager.TENANT_ID.ToString(), isAvoidCache);
if(list.Count > 0)
{
resultList.Add(new Core.Service.DictTreeOutput
{
Code = "booking_service_item",
Name = "订舱服务项目",
Children = list.OrderBy(a => a.SortNo).Select(a => new DictTreeOutput {
Code = a.ServiceProjectCode,
Name = a.ServiceProjectName
}).ToList()
});
}
return resultList;
}
#endregion
#region 获取可用的服务状态字典列表
/// <summary>
/// 获取可用的服务状态字典列表
/// </summary>
/// <param name="isAvoidCache">是否重新加载缓存</param>
/// <returns></returns>
[HttpGet("/ServiceWorkFlowBase/GetEnableStatusDictTreeList")]
public async Task<List<Myshipping.Core.Service.DictTreeOutput>> GetEnableStatusDictTreeList([FromQuery] bool isAvoidCache = false)
{
List<Myshipping.Core.Service.DictTreeOutput> resultList = new List<Core.Service.DictTreeOutput>();
var list = await GetEnableProjectWithStatusList(UserManager.TENANT_ID.ToString(), isAvoidCache);
if (list.Count > 0)
{
resultList.Add(new Core.Service.DictTreeOutput
{
Code = "booking_goods_status",
Name = "订舱货物状态",
Children = list.OrderBy(a => a.SortNo).SelectMany(a => {
var rltList = new List<DictTreeOutput>();
a.StatusList.ForEach(b =>
{
rltList.Add(new DictTreeOutput
{
Code = b.StatusSKUCode,
Name = b.StatusSKUName,
Remark = b.BackgroundColor
});
if (b.SubStatusList != null && b.SubStatusList.Count > 0)
{
rltList.AddRange(b.SubStatusList.Select(c => new DictTreeOutput
{
Code = c.StatusSKUCode,
Name = c.StatusSKUName,
Remark = c.BackgroundColor
}).ToList());
}
});
return rltList;
}).ToList()
});
}
return resultList;
}
#endregion
} }
} }

@ -50,6 +50,7 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<ServiceWorkFlowRunLogInfo> _serviceWorkFlowRunLogInfoRepository; private readonly SqlSugarRepository<ServiceWorkFlowRunLogInfo> _serviceWorkFlowRunLogInfoRepository;
private readonly ICache _cache; private readonly ICache _cache;
private readonly CacheOptions _cacheOptions; private readonly CacheOptions _cacheOptions;
private readonly SqlSugarRepository<BookingOrder> _bookingOrderRepository;
private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService; private readonly IServiceWorkFlowBaseService _serviceWorkFlowBaseService;
@ -71,7 +72,8 @@ namespace Myshipping.Application
IServiceWorkFlowBaseService serviceWorkFlowBaseService, SqlSugarRepository<SysUser> sysUserRepository, IServiceWorkFlowBaseService serviceWorkFlowBaseService, SqlSugarRepository<SysUser> sysUserRepository,
SqlSugarRepository<ServiceProjectBaseInfo> serviceProjectBaseInfoRepository, SqlSugarRepository<ServiceProjectBaseInfo> serviceProjectBaseInfoRepository,
SqlSugarRepository<ServiceWorkFlowRunLogInfo> serviceWorkFlowRunLogInfoRepository, SqlSugarRepository<ServiceWorkFlowRunLogInfo> serviceWorkFlowRunLogInfoRepository,
IOptions<CacheOptions> cacheOptions, Func<string, ISingleton, object> resolveNamed) IOptions<CacheOptions> cacheOptions, Func<string, ISingleton, object> resolveNamed,
SqlSugarRepository<BookingOrder> bookingOrderRepository)
{ {
_serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository; _serviceWorkFlowBaseRepository = serviceWorkFlowBaseRepository;
_serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository; _serviceWorkFlowActivitiesInfoRepository = serviceWorkFlowActivitiesInfoRepository;
@ -88,6 +90,7 @@ namespace Myshipping.Application
_sysUserRepository = sysUserRepository; _sysUserRepository = sysUserRepository;
_serviceProjectBaseInfoRepository = serviceProjectBaseInfoRepository; _serviceProjectBaseInfoRepository = serviceProjectBaseInfoRepository;
_serviceWorkFlowRunLogInfoRepository = serviceWorkFlowRunLogInfoRepository; _serviceWorkFlowRunLogInfoRepository = serviceWorkFlowRunLogInfoRepository;
_bookingOrderRepository = bookingOrderRepository;
_cacheOptions = cacheOptions.Value; _cacheOptions = cacheOptions.Value;
_cache = resolveNamed(_cacheOptions.CacheType.ToString(), default) as ICache; _cache = resolveNamed(_cacheOptions.CacheType.ToString(), default) as ICache;
@ -1949,5 +1952,187 @@ namespace Myshipping.Application
} }
#endregion #endregion
/// <summary>
/// 保存服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> SaveServiceStatus(ModifyServiceProjectStatusDto model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString();
try
{
var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == model.BookingId);
if (bookingOrder == null)
throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废");
_logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model));
TrackingMessageInfo msgInfo = new TrackingMessageInfo
{
Head = new TrackingMessageHeadInfo
{
GID = IDGen.NextID().ToString(),
MessageType = "PROJECT",
ReceiverId = "ServiceProjectStatus",
ReceiverName = "服务项目和状态",
SenderId = "BookingOrder",
SenderName = "海运订舱",
RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Version = "2.0",
RequestAction = "AddOrModify",
},
Main = new TrackingMessageMainInfo
{
BusiId = model.BookingId.ToString(),
BusiSystemCode = "BOOKING_ORDER",
MBlNo = bookingOrder.MBLNO,
VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}",
OrderNo = bookingOrder.BSNO,
PushType = TrackingPushTypeEnum.Status,
OperTenantId = bookingOrder.TenantId.Value,
OperTenantName = bookingOrder.TenantName,
OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name,
SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{
StatusCode = a.StatusCode,
StatusDate = a.SetActDate,
StatusVal = a.SetActVal,
Remark = a.ActRemark
}).ToList()
}
};
DateTime bDate = DateTime.Now;
_logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo));
var rlt = await PushStatus(msgInfo);
DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败")
, JSON.Serialize(rlt));
if (!rlt.succ)
{
result = rlt;
}
else
{
result.succ = true;
result.msg = "推送成功";
}
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"服务项目状态推送失败,原因:{ex.Message}";
}
return result;
}
/// <summary>
/// 取消服务状态
/// </summary>
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> CancelServiceStatus(ModifyServiceProjectStatusDto model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
string batchNo = IDGen.NextID().ToString();
try
{
var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == model.BookingId);
if (bookingOrder == null)
throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废");
_logger.LogInformation("批次={no} 请求保存服务项目 modifyjson={msg}", batchNo, JSON.Serialize(model));
TrackingMessageInfo msgInfo = new TrackingMessageInfo
{
Head = new TrackingMessageHeadInfo
{
GID = IDGen.NextID().ToString(),
MessageType = "PROJECT",
ReceiverId = "ServiceProjectStatus",
ReceiverName = "服务项目和状态",
SenderId = "BookingOrder",
SenderName = "海运订舱",
RequestDate = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"),
Version = "2.0",
RequestAction = "AddOrModify",
},
Main = new TrackingMessageMainInfo
{
BusiId = model.BookingId.ToString(),
BusiSystemCode = "BOOKING_ORDER",
MBlNo = bookingOrder.MBLNO,
VesselVoyno = $"{bookingOrder.VESSEL}/{bookingOrder.VOYNO}",
OrderNo = bookingOrder.BSNO,
PushType = TrackingPushTypeEnum.Status,
OperTenantId = bookingOrder.TenantId.Value,
OperTenantName = bookingOrder.TenantName,
OpertType = TrackingOperTypeEnum.MANUAL,
OperUserId = UserManager.UserId.ToString(),
OperUserName = UserManager.Name,
SourceType = model.SourceType,
StatusList = model.StatusCodes.Select(a => new TrackingMessageMainStatusInfo
{
StatusCode = a.StatusCode,
StatusDate = a.SetActDate,
StatusVal = a.SetActVal,
Remark = a.ActRemark
}).ToList()
}
};
DateTime bDate = DateTime.Now;
_logger.LogInformation("批次={no} 推送保存服务项目 msg={msg}", batchNo, JSON.Serialize(msgInfo));
var rlt = await CancelStatus(msgInfo);
DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation("批次={no} 请求完成,耗时:{timeDiff}ms. 结果{msg} result={rlt}", batchNo, timeDiff, (rlt.succ ? "成功" : "失败")
, JSON.Serialize(rlt));
if (!rlt.succ)
{
result = rlt;
}
else
{
result.succ = true;
result.msg = "推送成功";
}
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"服务项目状态推送失败,原因:{ex.Message}";
}
return result;
}
} }
} }

Loading…
Cancel
Save