|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
|