|
|
|
@ -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,32 +177,40 @@ 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();
|
|
|
|
|
|
|
|
|
|
var withDispatchList = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.LeftJoin<TaskRollingNominationDispatchInfo>((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID)
|
|
|
|
|
.Where((detail, dispatch) => detail.NOM_ID == rollModel.PK_ID && detail.IsDeleted == false
|
|
|
|
|
&& (string.IsNullOrWhiteSpace(dispatch.PK_ID) || (!string.IsNullOrWhiteSpace(dispatch.PK_ID) && dispatch.IsDeleted == false)))
|
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
dto.FromShip = l;
|
|
|
|
|
|
|
|
|
|
if (withDispatchList.Any(p => p.Detail != null))
|
|
|
|
|
var currArg = r.ToList();
|
|
|
|
|
|
|
|
|
|
if (currArg.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
dto.ToShipList = currArg.Select((p, idx) =>
|
|
|
|
|
{
|
|
|
|
|
var detailList =
|
|
|
|
|
withDispatchList.Where(p => p.Detail != null)
|
|
|
|
|
.Select(p => p.Detail).ToList();
|
|
|
|
|
if (Regex.IsMatch(p.ShipType, "[0-9]+"))
|
|
|
|
|
return new { SortNo = int.Parse(Regex.Match(p.ShipType, "[0-9]+").Value), Obj = p };
|
|
|
|
|
|
|
|
|
|
var portList = detailList.Where(p => !string.IsNullOrWhiteSpace(p.PLACEOF_RECEIPT))
|
|
|
|
|
.Select(p => p.PLACEOF_RECEIPT?.Trim()).Distinct().ToList();
|
|
|
|
|
return new { SortNo = idx + 1, Obj = p };
|
|
|
|
|
}).OrderBy(p => p.SortNo).Select(p => p.Obj).ToList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
model.From = model.From.Where(p=> portList.Any(p2=>p2.Equals(p.Port?.Trim()))).ToList();
|
|
|
|
|
return dto;
|
|
|
|
|
}).ToList();
|
|
|
|
|
|
|
|
|
|
model.To = model.To.Where(p => portList.Any(p2 => p2.Equals(p.Port?.Trim()))).ToList();
|
|
|
|
|
}
|
|
|
|
|
var withDispatchList = _taskRollingNominationDetailInfoRepository.AsQueryable().Filter(null, true)
|
|
|
|
|
.LeftJoin<TaskRollingNominationDispatchInfo>((detail, dispatch) => detail.PK_ID == dispatch.DETAIL_ID)
|
|
|
|
|
.Where((detail, dispatch) => detail.NOM_ID == rollModel.PK_ID && detail.IsDeleted == false
|
|
|
|
|
&& (string.IsNullOrWhiteSpace(dispatch.PK_ID) || (!string.IsNullOrWhiteSpace(dispatch.PK_ID) && dispatch.IsDeleted == false)))
|
|
|
|
|
.Select((detail, dispatch) => new { Detail = detail, Dispatch = dispatch }).ToList();
|
|
|
|
|
|
|
|
|
|
List<Tuple<string,int>> tuples = new List<Tuple<string,int>>();
|
|
|
|
|
|
|
|
|
|