|
|
|
@ -17,6 +17,7 @@ using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Text.RegularExpressions;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace Myshipping.Application
|
|
|
|
@ -168,11 +169,7 @@ namespace Myshipping.Application
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var shipList = _taskRollingNominationShipInfoRepository.AsQueryable()
|
|
|
|
|
.Where(a => a.NOM_ID == rollModel.PK_ID && a.GROUP_INDX == 1 && !a.IsDeleted).ToList();
|
|
|
|
|
|
|
|
|
|
if(shipList.Count == 0)
|
|
|
|
|
shipList = _taskRollingNominationShipInfoRepository.AsQueryable()
|
|
|
|
|
.Where(a => a.NOM_ID == rollModel.PK_ID && a.GROUP_INDX == 0 && !a.IsDeleted).ToList();
|
|
|
|
|
.Where(a => a.NOM_ID == rollModel.PK_ID && a.IsDeleted == false).ToList();
|
|
|
|
|
|
|
|
|
|
var fromEntity = shipList.Where(a =>
|
|
|
|
|
a.SHIP_TYPE.Equals("From", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
@ -180,12 +177,34 @@ namespace Myshipping.Application
|
|
|
|
|
if (fromEntity.Count > 0)
|
|
|
|
|
model.From = fromEntity.Select(p=>p.Adapt<TaskRollingNominationShipDto>()).ToList();
|
|
|
|
|
|
|
|
|
|
var toEntity = shipList.Where(a =>
|
|
|
|
|
a.SHIP_TYPE.Equals("To", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
var toEntity = shipList.Where(a => Regex.IsMatch(a.SHIP_TYPE,"To(\\s+[0-9]+)?"
|
|
|
|
|
, RegexOptions.IgnoreCase)).ToList();
|
|
|
|
|
|
|
|
|
|
if (toEntity.Count > 0)
|
|
|
|
|
model.To = toEntity.Select(p => p.Adapt<TaskRollingNominationShipDto>()).ToList();
|
|
|
|
|
|
|
|
|
|
//这里为了前端原船和换船做了根据PORT对应
|
|
|
|
|
model.FromToList = model.From.GroupJoin(model.To, l => l.Port?.Trim(), r => r.Port?.Trim(), (l, r) =>
|
|
|
|
|
{
|
|
|
|
|
TaskRollingNominationShipFromToDto dto = new TaskRollingNominationShipFromToDto();
|
|
|
|
|
|
|
|
|
|
dto.FromShip = l;
|
|
|
|
|
|
|
|
|
|
var currArg = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (currArg.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
dto.ToShipList = currArg.Select((p, idx) =>
|
|
|
|
|
{
|
|
|
|
|
if (Regex.IsMatch(p.ShipType, "[0-9]+"))
|
|
|
|
|
return new { SortNo = int.Parse(Regex.Match(p.ShipType, "[0-9]+").Value), Obj = p };
|
|
|
|
|
|
|
|
|
|
return new { SortNo = idx + 1, Obj = p };
|
|
|
|
|
}).OrderBy(p => p.SortNo).Select(p => p.Obj).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return dto;
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
var withDispatchList = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.LeftJoin<TaskRollingNominationDispatchInfo>((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID)
|
|
|
|
@ -193,20 +212,6 @@ namespace Myshipping.Application
|
|
|
|
|
&& (string.IsNullOrWhiteSpace(dispatch.PK_ID) || (!string.IsNullOrWhiteSpace(dispatch.PK_ID) && dispatch.IsDeleted == false)))
|
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
|
|
|
|
|
if (withDispatchList.Any(p => p.Detail != null))
|
|
|
|
|
{
|
|
|
|
|
var detailList =
|
|
|
|
|
withDispatchList.Where(p => p.Detail != null)
|
|
|
|
|
.Select(p => p.Detail).ToList();
|
|
|
|
|
|
|
|
|
|
var portList = detailList.Where(p => !string.IsNullOrWhiteSpace(p.PLACEOF_RECEIPT))
|
|
|
|
|
.Select(p => p.PLACEOF_RECEIPT?.Trim()).Distinct().ToList();
|
|
|
|
|
|
|
|
|
|
model.From = model.From.Where(p=> portList.Any(p2=>p2.Equals(p.Port?.Trim()))).ToList();
|
|
|
|
|
|
|
|
|
|
model.To = model.To.Where(p => portList.Any(p2 => p2.Equals(p.Port?.Trim()))).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<Tuple<string,int>> tuples = new List<Tuple<string,int>>();
|
|
|
|
|
|
|
|
|
|
if (withDispatchList.Any(a =>
|
|
|
|
|