修改服务项目保存、获取详情

optimize
jianghaiqing 1 year ago
parent cba96f6bdc
commit a9a0d7d6bb

@ -87,6 +87,16 @@ namespace Myshipping.Application.Entity
/// <summary>
/// 最后活动名称
/// </summary>
public int LST_ACT_NAME { get; set; }
public string LST_ACT_NAME { get; set; }
/// <summary>
/// 是否已产生 1-已产生 0-未产生
/// </summary>
public int IS_YIELD { get; set; }
/// <summary>
/// 项目发生时间
/// </summary>
public Nullable<DateTime> ACT_DATE { get; set; }
}
}

@ -2225,13 +2225,14 @@ namespace Myshipping.Application
}
#endregion
#region 获取服务项目列表
/// <summary>
/// 获取服务项目列表
/// </summary>
/// <param name="model">查询服务项目和状态详情</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> GetServiceProjectList(QueryServiceProjectWithStatus model)
[HttpPost("/BookingValueAdded/GetServiceProjectList")]
public async Task<TaskManageOrderResultDto> GetServiceProjectList([FromBody] QueryServiceProjectWithStatus model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
@ -2239,7 +2240,19 @@ namespace Myshipping.Application
try
{
var bookingOrder = _bookingOrderRepository.AsQueryable().Filter(null, true)
.First(a => a.Id == model.BookingId);
if (bookingOrder == null)
throw Oops.Oh($"订舱信息获取失败,订舱信息不存在或已作废");
QueryServiceProjectWithStatus queryInfo = new QueryServiceProjectWithStatus {
BookingId = model.BookingId,
QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_PROJECT,
TenantId = bookingOrder.TenantId.Value
};
result = await _serviceWorkFlowManageService.GetEnableProjectList(queryInfo);
}
catch(Exception ex)
{
@ -2249,6 +2262,7 @@ namespace Myshipping.Application
return result;
}
#endregion
/// <summary>

@ -25,5 +25,10 @@ namespace Myshipping.Application
/// 服务项目代码组
/// </summary>
public string[] ProjectCodes { get; set; }
/// <summary>
/// 租户ID
/// </summary>
public long TenantId { get; set; }
}
}

@ -49,13 +49,23 @@ namespace Myshipping.Application
/// <summary>
/// 发布日期
/// </summary>
public DateTime ReleaseDate { get; set; }
public Nullable<DateTime> ReleaseDate { get; set; }
/// <summary>
/// 状态代码列表(方便检索)
/// </summary>
public string[] StatusSKUCodeArgs { get; set; }
/// <summary>
/// 是否已完成
/// </summary>
public bool IsYield { get; set; }
/// <summary>
/// 完成时间
/// </summary>
public Nullable<DateTime> ActDate { get; set; }
/// <summary>
/// 状态列表
/// </summary>

@ -16,6 +16,11 @@ namespace Myshipping.Application
/// </summary>
public string PKId { get; set; }
/// <summary>
/// 服务项目主键
/// </summary>
public string ServiceProjectId { get; set; }
/// <summary>
/// 服务项目代码
/// </summary>
@ -26,6 +31,16 @@ namespace Myshipping.Application
/// </summary>
public string ServiceProjectName { get; set; }
/// <summary>
/// 是否已产生 1-已产生 0-未产生
/// </summary>
public int IsYield { get; set; }
/// <summary>
/// 项目发生时间
/// </summary>
public Nullable<DateTime> ActDate { get; set; }
/// <summary>
/// 状态列表
/// </summary>

@ -129,5 +129,8 @@ namespace Myshipping.Application
/// <param name="isAvoidCache">是否不从缓存取值</param>
/// <returns>返回回执</returns>
Task<List<ServiceProjectWithStatusDto>> GetEnableProjectWithStatusList(string tenantId, bool isAvoidCache = false);
}
}

@ -64,5 +64,11 @@ namespace Myshipping.Application
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> ValidateCancelProject(TrackingMessageInfo info);
/// <summary>
/// 检索已选中并且可用的服务项目列表
/// </summary>
/// <param name="model">查询服务项目和状态详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetEnableProjectList(QueryServiceProjectWithStatus model);
}
}

@ -2014,5 +2014,7 @@ namespace Myshipping.Application
return statusList;
}
#endregion
}
}

@ -131,6 +131,8 @@ namespace Myshipping.Application
throw Oops.Oh($"报文Main的业务主键不能为空", typeof(InvalidOperationException));
}
var statusList = _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(info.Main.OperTenantId.ToString()).GetAwaiter().GetResult();
var projectList = _cache.Get<List<ServiceProjectBaseDto>>($"{CONST_CACHE_ENABLE_PROJECT}_{info.Main.OperTenantId}");
if (info.Main.PushType == TrackingPushTypeEnum.Project)
@ -142,12 +144,83 @@ namespace Myshipping.Application
throw Oops.Oh($"推送类型是【服务项目】,服务项目列表不能为空", typeof(InvalidOperationException));
}
//提取
//提取所有已经有run记录的
var runBaseList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true)
.Where(a => a.BUSI_ID == info.Main.BusiId && a.BUSI_SYSTEM_CODE.Equals(info.Main.BusiSystemCode)
&& !a.IsDeleted && a.TenantId == info.Main.OperTenantId).ToList();
}
var needProjectArg = info.Main.ProjectList.Select(a=>a.ServiceProjectCode).ToArray();
var needProjectList = statusList.Where(a => needProjectArg.Contains(a.ProjectCode)).ToList();
var tskList = needProjectList.GroupJoin(runBaseList, l => l.WFPKId,
r => r.SERVICE_WF_ID,
(l, r) =>
{
var currList = r.ToList();
if (currList.Count == 0)
{
//标识当前服务项目写入运行主表
return new { OperType = "Insert", Info = l, Run = new ServiceWorkFlowRunInfo() };
}
return new { OperType = "Update", Info = l, Run = currList.FirstOrDefault() };
}).ToList();
DateTime nowDate = DateTime.Now;
tskList.ForEach(async tsk => {
if(tsk.OperType == "Insert")
{
ServiceWorkFlowRunInfo serviceWorkFlowRunInfo = new ServiceWorkFlowRunInfo
{
PK_ID = IDGen.NextID().ToString(),
SERVICE_WF_ID = tsk.Info.WFPKId,
BUSI_SYSTEM_CODE = info.Main.BusiSystemCode.ToUpper(),
BUSI_ID = info.Main.BusiId.ToUpper(),
MBL_NO = info.Main?.MBlNo.ToUpper(),
VESSEL_VOYNO = info.Main?.VesselVoyno.ToUpper(),
ORDER_NO = info.Main?.OrderNo,
STATUS = TaskStatusEnum.Create.ToString(),
RELEASE_VERSION = tsk.Info.ReleaseVersion,
ACTIVITIES_NUM = 0,
CreatedTime = nowDate,
UpdatedTime = nowDate,
CreatedUserId = long.Parse(info.Main.OperUserId),
CreatedUserName = info.Main.OperUserName,
TenantId = info.Main.OperTenantId,
TenantName = info.Main.OperTenantName,
SERVICE_PROJECT_CODE = tsk.Info.ProjectCode,
SERVICE_PROJECT_NAME = tsk.Info.ProjectName,
SERVICE_PROJECT_ID = tsk.Info.ProjectPKId,
IS_YIELD = 1,
ACT_DATE = nowDate,
};
await _serviceWorkFlowRunInfoRepository.InsertAsync(serviceWorkFlowRunInfo);
}
else if(tsk.OperType == "Update")
{
var runInfo = _serviceWorkFlowRunInfoRepository.AsQueryable()
.First(a => a.PK_ID == tsk.Run.PK_ID);
runInfo.IS_YIELD = 1;
runInfo.ACT_DATE = nowDate;
await _serviceWorkFlowRunInfoRepository.AsUpdateable(runInfo).UpdateColumns(it => new
{
it.ACT_DATE,
it.IS_YIELD,
}).ExecuteCommandAsync();
}
});
result.succ = true;
result.msg = "推送成功";
return result;
}
//校验状态代码是否一致,不一致直接返回错误不允许推送
var statusArg = info.Main.StatusList.Select(a => a?.StatusCode.ToUpper())
@ -432,62 +505,84 @@ namespace Myshipping.Application
try
{
result.succ = true;
result.ext = InnerGetRunListBySigleBusiness(info);
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"单票单服务项目查询失败,原因:{ex.Message}";
}
return result;
}
#endregion
var runList = _serviceWorkFlowRunInfoRepository.AsQueryable().Filter(null, true)
.LeftJoin<ServiceWorkFlowRunActivitiesInfo>((m, s) => m.PK_ID == s.RUN_ID)
.LeftJoin<ServiceWorkFlowProjectRelation>((m, s, rela) =>
m.SERVICE_WF_ID == rela.SERVICE_WORKFLOW_ID && m.RELEASE_VERSION == rela.WF_VERSION)
.LeftJoin<ServiceProjectBaseInfo>((m, s, rela, p) =>
rela.SERVICE_PROJECT_ID == p.PK_ID)
.Where((m, s, rela, p)
=> m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && m.BUSI_ID == info.Main.BusiId &&
info.Main.ServiceProjectCodeList.Contains(p.SERVICE_PROJECT_CODE))
.Select((m, s) => new { Run = m, Sub = s }).ToList();
var resultList = runList.GroupBy(a=>a.Run.PK_ID)
.Select(a => {
var currList = a.ToList();
var runInfo = currList.FirstOrDefault().Run;
var showModel = new ServiceWorkFlowRunDto();
showModel.PKId = runInfo.PK_ID;
showModel.ServiceProjectCode = runInfo.SERVICE_PROJECT_CODE;
showModel.ServiceProjectName = runInfo.SERVICE_PROJECT_NAME;
showModel.ActivitiesList = currList.Where(t => t.Sub.IS_SUB == 0)
.Select(t =>
#region 获取单票业务相关的服务项目运行列表
/// <summary>
/// 获取单票业务相关的服务项目运行列表
/// </summary>
/// <param name="info">查询服务流程详情</param>
/// <returns>返回查询列表</returns>
private List<ServiceWorkFlowRunDto> InnerGetRunListBySigleBusiness(TrackingQueryMessageInfo info)
{
var runList = _serviceWorkFlowRunInfoRepository.AsQueryable()
.Filter(null, true)
.LeftJoin<ServiceWorkFlowRunActivitiesInfo>((m, s) => m.PK_ID == s.RUN_ID)
.LeftJoin<ServiceWorkFlowProjectRelation>((m, s, rela) =>
m.SERVICE_WF_ID == rela.SERVICE_WORKFLOW_ID && m.RELEASE_VERSION == rela.WF_VERSION)
.LeftJoin<ServiceProjectBaseInfo>((m, s, rela, p) =>
rela.SERVICE_PROJECT_ID == p.PK_ID)
.Where((m, s, rela, p)
=> m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && m.BUSI_ID == info.Main.BusiId &&
(info.Main.ServiceProjectCodeList == null || info.Main.ServiceProjectCodeList.Contains(p.SERVICE_PROJECT_CODE)))
.Select((m, s) => new { Run = m, Sub = s }).ToList();
var resultList = runList.GroupBy(a => a.Run.PK_ID)
.Select(a => {
var currList = a.ToList();
var runInfo = currList.FirstOrDefault().Run;
var showModel = new ServiceWorkFlowRunDto();
showModel.PKId = runInfo.PK_ID;
showModel.ServiceProjectId = runInfo.SERVICE_PROJECT_ID;
showModel.ServiceProjectCode = runInfo.SERVICE_PROJECT_CODE;
showModel.ServiceProjectName = runInfo.SERVICE_PROJECT_NAME;
showModel.IsYield = runInfo.IS_YIELD;
showModel.ActDate = runInfo.ACT_DATE;
showModel.ActivitiesList = currList.Where(t => t.Sub.IS_SUB == 0)
.Select(t =>
{
var runModel = new ServiceWorkFlowActivitiesRunDto
{
var runModel = new ServiceWorkFlowActivitiesRunDto
{
PKId = t.Sub.PK_ID,
ActDate = t.Sub.ACT_DATE,
ActId = t.Sub.ACT_ID,
ExecSortNo = t.Sub.EXEC_SORT_NO,
ActVal = t.Sub.ACT_VAL,
IsStart = t.Sub.IS_START,
IsEnd = t.Sub.IS_END,
IsYield = t.Sub.IS_YIELD,
RunId = t.Sub.RUN_ID,
ShowName = t.Sub.SHOW_NAME,
SourceType = t.Sub.SOURCE_TYPE,
StatusSKUCode = t.Sub.STATUS_SKU_CODE,
StatusSKUId = t.Sub.STATUS_SKU_ID
};
PKId = t.Sub.PK_ID,
ActDate = t.Sub.ACT_DATE,
ActId = t.Sub.ACT_ID,
ExecSortNo = t.Sub.EXEC_SORT_NO,
ActVal = t.Sub.ACT_VAL,
IsStart = t.Sub.IS_START,
IsEnd = t.Sub.IS_END,
IsYield = t.Sub.IS_YIELD,
RunId = t.Sub.RUN_ID,
ShowName = t.Sub.SHOW_NAME,
SourceType = t.Sub.SOURCE_TYPE,
StatusSKUCode = t.Sub.STATUS_SKU_CODE,
StatusSKUId = t.Sub.STATUS_SKU_ID
};
return runModel;
}).ToList();
return runModel;
}).ToList();
var subList =
currList.Where(t => t.Sub.IS_SUB == 1)
.Select(t => t.Sub).ToList();
var subList =
currList.Where(t => t.Sub.IS_SUB == 1)
.Select(t => t.Sub).ToList();
showModel.ActivitiesList = showModel.ActivitiesList.GroupJoin(subList,
l => l.PKId, r => r.PARENT_ID,
(l, r) =>
showModel.ActivitiesList = showModel.ActivitiesList.GroupJoin(subList,
l => l.PKId, r => r.PARENT_ID,
(l, r) =>
{
var currList = r.ToList();
@ -513,25 +608,16 @@ namespace Myshipping.Application
};
return subModel;
}).OrderBy(x=>x.ExecSortNo).ToList();
}).OrderBy(x => x.ExecSortNo).ToList();
}
return l;
}).OrderBy(t => t.ExecSortNo).ToList();
return showModel;
}).ToList();
result.succ = true;
result.ext = resultList;
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"单票单服务项目查询失败,原因:{ex.Message}";
}
return showModel;
}).ToList();
return result;
return resultList;
}
#endregion
@ -558,7 +644,6 @@ namespace Myshipping.Application
=> m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && m.BUSI_ID == info.Main.BusiId)
.Select((m, s) => new { Run = m, Sub = s }).ToList();
var resultList = runList.GroupBy(a => a.Run.PK_ID)
.Select(a => {
var currList = a.ToList();
@ -1120,6 +1205,79 @@ namespace Myshipping.Application
return result;
}
#endregion
#region 检索已选中并且可用的服务项目列表
/// <summary>
/// 检索已选中并且可用的服务项目列表
/// </summary>
/// <param name="model">查询服务项目和状态详情</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> GetEnableProjectList(QueryServiceProjectWithStatus model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
//先获取可用的服务项目
var projectList = await _serviceWorkFlowBaseService.GetEnableProjectList(model.TenantId.ToString());
TrackingQueryMessageInfo messageInfo = new TrackingQueryMessageInfo {
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 TrackingMessageQueryMainInfo {
BusiId = model.BookingId.ToString(),
BusiSystemCode = "BOOKING_ORDER",
TenantId = model.TenantId.ToString(),
}
};
//在获取运行表已有的记录
var runList = InnerGetRunListBySigleBusiness(messageInfo);
var resultList = projectList.GroupJoin(runList, l => l.PKId, r => r.ServiceProjectId, (l, r) => {
var currList = r.ToList();
var runInfo = currList.FirstOrDefault();
var dto = new ServiceProjectWithStatusDto
{
ProjectPKId = l.PKId,
ProjectCode = l.ServiceProjectCode,
ProjectName = l.ServiceProjectName,
SortNo = l.SortNo
};
if(runInfo != null)
{
dto.IsYield = runInfo.IsYield == 1 ? true : false;
dto.ActDate = runInfo.ActDate;
}
return dto;
}).ToList();
result.succ = true;
result.ext = resultList;
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"检索已选中并且可用的服务项目列表失败,原因:{ex.Message}";
}
return result;
}
#endregion
}
}

Loading…
Cancel
Save