修改服务状态拉取。

修改订舱台账
optimize
jianghaiqing 1 year ago
parent 1f53972307
commit 952eae1b6b

@ -449,7 +449,19 @@ namespace Myshipping.Application
}
var bookingidlist = list.Items.Select(x => x.Id).ToList();
var itgoodsStatus = _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
if (App.Configuration["ServiceStatusOpenAuto"] == "1")
{
QueryServiceProjectWithStatusBatch batchQuery = new QueryServiceProjectWithStatusBatch {
BookingIds = bookingidlist.ToArray(),
QueryType = TrackingQueryTypeEnum.QUERY_SERVICE_ALL
};
var queryList = _serviceWorkFlowManageService.GetEnableStatusListByBusinessBatch(batchQuery)
.GetAwaiter().GetResult();
}
var itgoodsStatus =
_goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId && bookingidlist.Contains((long)goods.bookingId)).
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new
@ -464,20 +476,23 @@ namespace Myshipping.Application
CreatedUserId = config.CreatedUserId,
Sort = config.Sort
}).ToList();
var configID = itgoodsStatus.Select(x => x.ConfigId).Distinct().ToList();
var configID = itgoodsStatus.Select(x => x.ConfigId)
.Distinct().ToList();
var itconfigs = _goodsStatusConfig.AsQueryable()
.Where(x => configID.Contains(x.Id)).Select(config => new
{
bookingid = "",
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = "",
ExtData = "",
Remark = "",
CreatedUserId = config.CreatedUserId,
Sort = config.Sort
}).ToList();
var itconfigs = _goodsStatusConfig.AsQueryable().Where(x => configID.Contains(x.Id)).Select(config => new
{
bookingid = "",
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = "",
ExtData = "",
Remark = "",
CreatedUserId = config.CreatedUserId,
Sort = config.Sort
}).ToList();
if (traceTime)
{
@ -558,38 +573,41 @@ namespace Myshipping.Application
{
item.ATA = Convert.ToDateTime(item.ATA).ToString("yyyy-MM-dd");
}
var itgoods = itgoodsStatus.Where(x => x.CreatedUserId == item.CreatedUserId && x.bookingid == item.Id).OrderBy(x => x.Sort).
Select(x => new GoodsStatusList
{
ConfigId = x.ConfigId,
StatusName = x.StatusName,
SystemCode = x.SystemCode,
FinishTime = x.FinishTime,
ExtData = x.ExtData,
Remark = x.Remark,
Sort = x.Sort
}).ToList();
var itconfig = itconfigs.Where(x => x.CreatedUserId == item.CreatedUserId).OrderBy(x => x.Sort).
Select(x => new GoodsStatusList
{
ConfigId = x.ConfigId,
StatusName = x.StatusName,
SystemCode = x.SystemCode,
FinishTime = null,
ExtData = x.ExtData,
Remark = x.Remark,
Sort = x.Sort
}).ToList();
foreach (var ii in itgoods)
{
itconfig.RemoveAll(x => x.ConfigId == ii.ConfigId);
}
item.IsVGM = itgoods.Where(x => x.SystemCode == "YFVGM").FirstOrDefault() == null ? null : itgoods.Where(x => x.SystemCode == "YFVGM").Select(x => x.FinishTime).FirstOrDefault();
item.IsCanDan = itgoods.Where(x => x.SystemCode == "YFCD").FirstOrDefault() == null ? null : itgoods.Where(x => x.SystemCode == "YFCD").Select(x => x.FinishTime).FirstOrDefault();
item.IsZZFX = itgoods.Where(x => x.SystemCode == "ZZFX").FirstOrDefault() == null ? null : itgoods.Where(x => x.SystemCode == "ZZFX").Select(x => x.FinishTime).FirstOrDefault();
item.GoodsStatusList = itgoods.Union<GoodsStatusList>(itconfig).OrderBy(x => x.Sort).ToList();
var itgoods = itgoodsStatus.Where(x => x.CreatedUserId == item.CreatedUserId && x.bookingid == item.Id).OrderBy(x => x.Sort).
Select(x => new GoodsStatusList
{
ConfigId = x.ConfigId,
StatusName = x.StatusName,
SystemCode = x.SystemCode,
FinishTime = x.FinishTime,
ExtData = x.ExtData,
Remark = x.Remark,
Sort = x.Sort
}).ToList();
var itconfig = itconfigs.Where(x => x.CreatedUserId == item.CreatedUserId).OrderBy(x => x.Sort).
Select(x => new GoodsStatusList
{
ConfigId = x.ConfigId,
StatusName = x.StatusName,
SystemCode = x.SystemCode,
FinishTime = null,
ExtData = x.ExtData,
Remark = x.Remark,
Sort = x.Sort
}).ToList();
foreach (var ii in itgoods)
{
itconfig.RemoveAll(x => x.ConfigId == ii.ConfigId);
}
item.IsVGM = itgoods.Where(x => x.SystemCode == "YFVGM").FirstOrDefault() == null ? null : itgoods.Where(x => x.SystemCode == "YFVGM").Select(x => x.FinishTime).FirstOrDefault();
item.IsCanDan = itgoods.Where(x => x.SystemCode == "YFCD").FirstOrDefault() == null ? null : itgoods.Where(x => x.SystemCode == "YFCD").Select(x => x.FinishTime).FirstOrDefault();
item.IsZZFX = itgoods.Where(x => x.SystemCode == "ZZFX").FirstOrDefault() == null ? null : itgoods.Where(x => x.SystemCode == "ZZFX").Select(x => x.FinishTime).FirstOrDefault();
item.GoodsStatusList = itgoods.Union<GoodsStatusList>(itconfig).OrderBy(x => x.Sort).ToList();
//获取提箱返场状态
//var statuslog = statusloglist.Where(x => x.BookingId == item.Id).OrderByDescending(x => x.CreatedTime).ToList();
//var dto = statuslog.Adapt<List<BookingStatusLogDto>>();

@ -138,6 +138,9 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
/// </summary>
public long? Sort { get; set; }
/// <summary>
/// 是否最新记录
/// </summary>
public bool IsLast { get; set; } = false;
}
}

@ -31,4 +31,27 @@ namespace Myshipping.Application
/// </summary>
public long TenantId { get; set; }
}
public class QueryServiceProjectWithStatusBatch
{
/// <summary>
/// 订舱ID数组
/// </summary>
public long[] BookingIds { get; set; }
/// <summary>
/// 0-查服务项目 1-查服务项目下的状态
/// </summary>
public TrackingQueryTypeEnum QueryType { get; set; }
/// <summary>
/// 服务项目代码组
/// </summary>
public string[] ProjectCodes { get; set; }
/// <summary>
/// 租户ID
/// </summary>
public long TenantId { get; set; }
}
}

@ -183,5 +183,15 @@ namespace Myshipping.Application
/// 是否结束
/// </summary>
public bool IsEnd { get; set; }
/// <summary>
/// 业务系统代码
/// </summary>
public string BusiSystemCode { get; set; }
/// <summary>
/// 业务主键
/// </summary>
public string BusiId { get; set; }
}
}

@ -46,6 +46,16 @@ namespace Myshipping.Application
/// </summary>
public string WFPKId { get; set; }
/// <summary>
/// 业务系统代码
/// </summary>
public string BusiSystemCode { get; set; }
/// <summary>
/// 业务主键
/// </summary>
public string BusiId { get; set; }
/// <summary>
/// 状态列表
/// </summary>

@ -79,4 +79,65 @@ namespace Myshipping.Application
public bool IsReloadCache { get; set; } = false;
}
public class TrackingQueryBatchMessageInfo
{
/// <summary>
/// 表头
/// </summary>
public TrackingMessageHeadInfo Head { get; set; }
/// <summary>
/// 表体
/// </summary>
public TrackingMessageQueryBatchMainInfo Main { get; set; }
}
/// <summary>
/// 表体
/// </summary>
public class TrackingMessageQueryBatchMainInfo
{
/// <summary>
/// 服务项目代码
/// </summary>
public List<string> ServiceProjectCodeList { get; set; }
/// <summary>
/// 业务系统代码
/// </summary>
[Required(ErrorMessage = "必填")]
public string BusiSystemCode { get; set; }
/// <summary>
/// 业务主键
/// </summary>
public List<string> BusiIds { get; set; }
/// <summary>
/// 查询类型
/// </summary>
public TrackingQueryTypeEnum QueryType { get; set; }
/// <summary>
/// 查询服务项目代码
/// </summary>
public string[] QueryServiceProjectCode { get; set; }
/// <summary>
/// 租户ID
/// </summary>
public string TenantId { get; set; }
/// <summary>
/// 租户名称
/// </summary>
public string TenantName { get; set; }
/// <summary>
/// 强制刷新缓存
/// </summary>
public bool IsReloadCache { get; set; } = false;
}
}

@ -91,5 +91,13 @@ namespace Myshipping.Application
/// <param name="model">修改服务状态详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> CancelServiceStatus(ModifyServiceProjectStatusDto model);
/// <summary>
/// 批量检索服务项目下的状态列表
/// </summary>
/// <param name="model">批量查询服务项目和状态详情</param>
/// <returns>返回回执</returns>
Task<TaskManageOrderResultDto> GetEnableStatusListByBusinessBatch(QueryServiceProjectWithStatusBatch model);
}
}

@ -1875,8 +1875,8 @@ namespace Myshipping.Application
ActSortNo = c.ActSortNo,
ShowName = c.ShowName,
IsYield = false,
StatusSKUCode = b.StatusSKUCode,
ActRemark = b.ActRemark,
StatusSKUCode = c.StatusSKUCode,
ActRemark = c.ActRemark,
WFSortNo = l.SortNo,
CalcSortNo = (decimal)b.ActSortNo + (c.ActSortNo * 0.001m)
}).ToList());
@ -2143,5 +2143,289 @@ namespace Myshipping.Application
return result;
}
/// <summary>
/// 批量检索服务项目下的状态列表
/// </summary>
/// <param name="model">批量查询服务项目和状态详情</param>
/// <returns>返回回执</returns>
public async Task<TaskManageOrderResultDto> GetEnableStatusListByBusinessBatch(QueryServiceProjectWithStatusBatch model)
{
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
try
{
var statuList = await _serviceWorkFlowBaseService.GetEnableProjectWithStatusList(model.TenantId.ToString());
TrackingQueryBatchMessageInfo messageInfo = new TrackingQueryBatchMessageInfo
{
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 TrackingMessageQueryBatchMainInfo
{
BusiIds = model.BookingIds.Select(a=>a.ToString()).ToList(),
BusiSystemCode = "BOOKING_ORDER",
TenantId = model.TenantId.ToString(),
}
};
DateTime bDate = DateTime.Now;
//在获取运行表已有的记录
var runList = InnerGetRunListBySingleBusinessBatch(messageInfo);
DateTime eDate = DateTime.Now;
TimeSpan ts = eDate.Subtract(bDate);
var timeDiff = ts.TotalMilliseconds;
_logger.LogInformation("测试读取服务状态-读取数据库记录 耗时:{timeDiff}ms. ", timeDiff);
int lastWFSortNo = 0;
int calcNum = 1;
var resultList = statuList.Join(runList, l => l.WFPKId, r => r.WFPKId,
(l, r) => {
var runInfo = r;
var rltList = new List<ServiceProjectStatusDto>();
if (runInfo.IsYield == 1)
{
if (runInfo.ActivitiesList == null || (runInfo.ActivitiesList != null && runInfo.ActivitiesList.Count == 0))
{
l.StatusList.ForEach(b => {
rltList.Add(new ServiceProjectStatusDto
{
ActPKId = b.ActPKId,
ActSortNo = b.ActSortNo,
ShowName = b.ShowName,
IsYield = false,
StatusSKUCode = b.StatusSKUCode,
ActRemark = b.ActRemark,
WFSortNo = l.SortNo,
CalcSortNo = (decimal)b.ActSortNo,
BusiSystemCode = runInfo.BusiSystemCode,
BusiId = runInfo.BusiId,
});
if (b.SubStatusList != null && b.SubStatusList.Count > 0)
{
rltList.AddRange(b.SubStatusList.Select(c => new ServiceProjectStatusDto
{
ActPKId = c.ActPKId,
ActSortNo = c.ActSortNo,
ShowName = c.ShowName,
IsYield = false,
StatusSKUCode = b.StatusSKUCode,
ActRemark = b.ActRemark,
WFSortNo = l.SortNo,
CalcSortNo = (decimal)b.ActSortNo + (c.ActSortNo * 0.001m),
BusiSystemCode = runInfo.BusiSystemCode,
BusiId = runInfo.BusiId,
}).ToList());
}
});
}
else
{
runInfo.ActivitiesList.ForEach(b => {
rltList.Add(new ServiceProjectStatusDto
{
ActPKId = b.ActId,
ActSortNo = b.ExecSortNo,
ShowName = b.ShowName,
IsYield = b.IsYield == 1 ? true : false,
ActDate = b.ActDate,
ActVal = b.ActVal,
StatusSKUCode = b.StatusSKUCode,
ActRemark = b.ActRemark,
WFSortNo = l.SortNo,
CalcSortNo = (decimal)b.ExecSortNo,
BusiSystemCode = runInfo.BusiSystemCode,
BusiId = runInfo.BusiId,
});
if (b.SubList != null && b.SubList.Count > 0)
{
rltList.AddRange(b.SubList.Select(c => new ServiceProjectStatusDto
{
ActPKId = c.ActId,
ActSortNo = c.ExecSortNo,
ShowName = c.ShowName,
IsYield = c.IsYield == 1 ? true : false,
ActDate = c.ActDate,
ActVal = c.ActVal,
StatusSKUCode = c.StatusSKUCode,
ActRemark = c.ActRemark,
WFSortNo = l.SortNo,
CalcSortNo = (decimal)b.ExecSortNo + (c.ExecSortNo * 0.001m),
BusiSystemCode = runInfo.BusiSystemCode,
BusiId = runInfo.BusiId,
}).ToList());
}
});
}
}
if (rltList != null && rltList.Count > 0)
{
var maxSort = rltList.Max(t => t.CalcSortNo);
rltList.FirstOrDefault(t => t.CalcSortNo == maxSort).IsEnd = true;
}
return rltList;
}).SelectMany(b => b).OrderBy(b => b.WFSortNo).Select(b => {
if (lastWFSortNo == 0)
{
b.GroupName = calcNum.ToString();
lastWFSortNo = b.WFSortNo;
}
else if (b.WFSortNo == lastWFSortNo)
{
b.GroupName = calcNum.ToString();
}
else
{
++calcNum;
lastWFSortNo = b.WFSortNo;
b.GroupName = calcNum.ToString();
}
return b;
}).OrderBy(b => b.WFSortNo).ThenBy(b => b.CalcSortNo).ToList();
result.succ = true;
result.ext = resultList;
}
catch (Exception ex)
{
result.succ = false;
result.msg = $"检索服务项目下的状态列表失败,原因:{ex.Message}";
}
return result;
}
#region 获取单票业务相关的服务项目运行列表
/// <summary>
/// 获取单票业务相关的服务项目运行列表
/// </summary>
/// <param name="info">查询服务流程详情</param>
/// <returns>返回查询列表</returns>
private List<ServiceWorkFlowRunDto> InnerGetRunListBySingleBusinessBatch(TrackingQueryBatchMessageInfo 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)
.InnerJoin<ServiceProjectBaseInfo>((m, s, rela, p) =>
rela.SERVICE_PROJECT_ID == p.PK_ID)
.Where((m, s, rela, p)
=> m.BUSI_SYSTEM_CODE == info.Main.BusiSystemCode && info.Main.BusiIds.Contains(m.BUSI_ID) &&
(info.Main.ServiceProjectCodeList == null || info.Main.ServiceProjectCodeList.Contains(p.SERVICE_PROJECT_CODE)))
.Select((m, s, rela, p) =>
new { Run = m, Sub = s }).ToList();
var resultList = runList.GroupBy(a => $"{a.Run.BUSI_ID}_{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.WFPKId = runInfo.SERVICE_WF_ID;
showModel.BusiId = runInfo.BUSI_ID;
showModel.BusiSystemCode = runInfo.BUSI_SYSTEM_CODE;
showModel.ActivitiesList = currList.Where(t =>
!string.IsNullOrWhiteSpace(t.Sub.PK_ID) && t.Sub.IS_SUB == 0)
.Select(t =>
{
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,
ActRemark = t.Sub.ACT_REMARK,
};
return runModel;
}).ToList();
var subList =
currList.Where(t =>
!string.IsNullOrWhiteSpace(t.Sub.PK_ID) && 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) =>
{
var currList = r.ToList();
if (currList.Count > 0)
{
l.SubList = currList.Select(x => {
var subModel = new ServiceWorkFlowActivitiesRunSubDto
{
PKId = x.PK_ID,
ActDate = x.ACT_DATE,
ActId = x.ACT_ID,
ExecSortNo = x.EXEC_SORT_NO,
ActVal = x.ACT_VAL,
IsStart = x.IS_START,
IsEnd = x.IS_END,
IsYield = x.IS_YIELD,
RunId = x.RUN_ID,
ShowName = x.SHOW_NAME,
SourceType = x.SOURCE_TYPE,
StatusSKUCode = x.STATUS_SKU_CODE,
StatusSKUId = x.STATUS_SKU_ID,
ActRemark = x.ACT_REMARK
};
return subModel;
}).OrderBy(x => x.ExecSortNo).ToList();
}
return l;
}).OrderBy(t => t.ExecSortNo).ToList();
return showModel;
}).ToList();
return resultList;
}
#endregion
}
}

Loading…
Cancel
Save