wet 1 year ago
commit cdb0bca3e9

@ -2205,14 +2205,17 @@ namespace Myshipping.Application
var usrList = _repUser.AsQueryable().Filter(null, true).Where(u => u.TenantId == tenantId && !u.IsDeleted).ToList();
Dictionary<string, List<string>> dic = new Dictionary<string, List<string>>();
//遍历船名航次,查询订舱数据
//遍历船名航次,查询船期维护人
foreach (var item in dto)
{
var boUserList = _rep.AsQueryable().Filter(null, true).Where(x => x.VESSEL == item.Vessel && x.VOYNO == item.Voyno && (x.ParentId == 0 || x.ParentId == null) && !x.IsDeleted && x.TenantId == tenantId)
.Select(x => x.CreatedUserId).ToList();
if (boUserList.Count > 0)
var veUserList = _vesselinfo.AsQueryable().Filter(null, true)
.Where(v => v.TenantId == tenantId && v.Vessel == item.Vessel && v.Voyno == item.Voyno && !v.IsDeleted)
.Select(x => x.CreatedUserId)
.ToList();
if (veUserList.Count > 0)
{
var phoneList = usrList.Where(u => boUserList.Contains(u.Id) && u.Phone != "" && u.Phone != null).Select(x => x.Phone).ToList();
var phoneList = usrList.Where(u => veUserList.Contains(u.Id) && u.Phone != "" && u.Phone != null).Select(x => x.Phone).ToList();
foreach (var phone in phoneList)
{

@ -240,5 +240,9 @@ namespace Myshipping.Application
/// 集装箱列表
/// </summary>
public List<TaskBCCTNInfoDto> CtnList { get; set; }
/// <summary>
/// 顺序号
/// </summary>
public int Indx { get; set; }
}
}

@ -10,6 +10,8 @@ using Myshipping.Application.Enum;
using Myshipping.Core;
using Myshipping.Core.Service;
using NPOI.SS.Formula.Functions;
using SqlSugar;
using StackExchange.Profiling.Internal;
using System;
using System.Collections.Generic;
using System.IO;
@ -197,21 +199,88 @@ namespace Myshipping.Application
/*
1
2
3
*/
try
{
Dictionary<string, List<BookingOrder>> toDoListDict = new Dictionary<string, List<BookingOrder>>();
//获取所有待处理的BC任务
var taskList = await _taskBCInfoRepository.AsQueryable().InnerJoin<TaskBCInfo>((a,b)=>a.TASK_ID == b.PK_ID)
var taskList = await _taskBCInfoRepository.AsQueryable().InnerJoin<TaskBaseInfo>((a,b)=>a.TASK_ID == b.PK_ID)
.Where((a, b)=> !a.BOOKING_ORDER_ID.HasValue && b.STATUS == TaskStatusEnum.Create.ToString())
.Select((a,b)=>new { BC = a,TSK = b }).ToListAsync();
if (taskList.Count > 0)
{
taskList.ForEach(async tsk =>
{
var curList = await _bookingOrderRepository.AsQueryable()
.Where(a => a.VESSEL.Contains(tsk.BC.VESSEL) && a.VOYNO.Contains(tsk.BC.VOYNO) || a.MBLNO.Contains(tsk.BC.MBL_NO)
).ToListAsync();
if (curList.Count > 0)
{
toDoListDict.Add(tsk.BC.PK_ID, curList);
}
else
{
toDoListDict.Add(tsk.BC.PK_ID, new List<BookingOrder>());
}
});
}
//这里最后清洗一下对应的订舱数据,只保留一条符合的数据
if (toDoListDict.Count > 0)
{
List<Tuple<TaskBCInfoDto, BookingOrderBCTaskDto>> tupList = new List<Tuple<TaskBCInfoDto, BookingOrderBCTaskDto>>();
int num = 1;
int odNum = 1;
foreach (var kvp in toDoListDict)
{
var bcInfo = taskList.FirstOrDefault(a => a.BC.PK_ID == kvp.Key).BC.Adapt<TaskBCInfoDto>();
bcInfo.Indx = num;
if (kvp.Value.Count > 0)
{
var bookingOrder = kvp.Value.Select(a =>
{
if (a.MBLNO.Equals(bcInfo.MBLNo, StringComparison.OrdinalIgnoreCase))
{
return new { Sort = 90, OBJ = a };
}
else if (a.VESSEL.Equals(bcInfo.Vessel, StringComparison.OrdinalIgnoreCase)
&& a.VOYNO.Equals(bcInfo.VoyNo, StringComparison.OrdinalIgnoreCase))
{
return new { Sort = 80, OBJ = a };
}
return new { Sort = 1, OBJ = a };
}).OrderByDescending(a => a.Sort).FirstOrDefault().OBJ.Adapt<BookingOrderBCTaskDto>();
bookingOrder.Indx = odNum;
odNum++;
tupList.Add(new Tuple<TaskBCInfoDto, BookingOrderBCTaskDto>(
bcInfo,
bookingOrder
));
}
else
{
tupList.Add(new Tuple<TaskBCInfoDto, BookingOrderBCTaskDto>(
bcInfo,
null
));
}
num++;
}
result.ext = tupList;
}
result.succ = true;
}
catch (Exception ex)
{

Loading…
Cancel
Save