optimize
wet 2 years ago
parent 4ecaedac98
commit 90503c42a5

@ -111,6 +111,8 @@ namespace Myshipping.Application
private readonly SqlSugarRepository<BookingGoodsStatus> _goodsStatus;
private readonly SqlSugarRepository<BookingGoodsStatusConfig> _goodsStatusConfig;
private readonly SqlSugarRepository<DjyCustomer> _djycustomer;
private readonly SqlSugarRepository<BookingTemplate> _bookingTemplate;
private readonly SqlSugarRepository<ParaGoodsInfo> _paraGoodsInfoRepository;
private readonly IHttpContextAccessor _httpContextAccessor;
private readonly IBookingGoodsStatusConfigService _GoodsConfig;
const string CONST_MAPPING_MODULE = "BOOK_OR_CLOSING";
@ -121,12 +123,12 @@ namespace Myshipping.Application
SqlSugarRepository<BookingLog> bookinglog, SqlSugarRepository<BookingLogDetail> bookinglogdetail, SqlSugarRepository<BookingRemark> bookingremark,
SqlSugarRepository<BookingFile> bookingfile, SqlSugarRepository<DjyUserConfig> repUserConfig, SqlSugarRepository<BookingPrintTemplate> repPrint,
SqlSugarRepository<SysDictData> dicdata, SqlSugarRepository<BookingStatusLog> statuslog, SqlSugarRepository<BookingStatusLogDetail> statuslogdetail,
ILogger<BookingOrderService> logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, ISysDataUserMenu right,
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser,
ILogger<BookingOrderService> logger, ISysCacheService cache, IDjyWebsiteAccountConfigService webAccountConfig, ISysDataUserMenu right, SqlSugarRepository<ParaGoodsInfo> paraGoodsInfoRepository,
SqlSugarRepository<BookingPrintTemplate> repPrintTemplate, SqlSugarRepository<BookingLetteryard> repLetterYard, SqlSugarRepository<SysUser> repUser, SqlSugarRepository<BookingTemplate> bookingTemplate,
SqlSugarRepository<BookingOrderUrl> repOrderUrl, SqlSugarRepository<BookingOrderContact> repOrderContact, SqlSugarRepository<BookingSampleBill> repSampleBill, SqlSugarRepository<DjyCustomer> djycustomer,
SqlSugarRepository<BookingExcelTemplate> excelrep, SqlSugarRepository<DjyUserMailAccount> repUserMail, SqlSugarRepository<BookingGoodsStatus> goodsStatus, SqlSugarRepository<BookingGoodsStatusConfig> goodsStatusConfig,
SqlSugarRepository<SysTenant> repTenant, SqlSugarRepository<BookingStatus> repBookingStatus, SqlSugarRepository<BookingEDIExt> bookingEDIExt, SqlSugarRepository<BookingServiceItem> serviceItem,
IHttpContextAccessor httpContextAccessor,IBookingGoodsStatusConfigService GoodsConfig)
IHttpContextAccessor httpContextAccessor, IBookingGoodsStatusConfigService GoodsConfig)
{
this._logger = logger;
this._rep = rep;
@ -157,7 +159,9 @@ namespace Myshipping.Application
this._serviceItem = serviceItem;
this._goodsStatus = goodsStatus;
this._goodsStatusConfig = goodsStatusConfig;
this._bookingTemplate = bookingTemplate;
this._djycustomer = djycustomer;
this._paraGoodsInfoRepository = paraGoodsInfoRepository;
_httpContextAccessor = httpContextAccessor;
_GoodsConfig = GoodsConfig;
}
@ -180,6 +184,8 @@ namespace Myshipping.Application
var ftoday = DateTime.Now.AddDays(-15);
var etoday = DateTime.Now.AddDays(15);
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
#region
var entities = await _rep.AsQueryable()
.WhereIF(input.firstFlag, x => x.ETD <= etoday && x.ETD >= ftoday || x.ETD == null)
.WhereIF(string.IsNullOrWhiteSpace(input.HBLNO), x => x.ParentId == 0 || x.ParentId == null)
@ -329,22 +335,47 @@ namespace Myshipping.Application
.OrderBy(PageInputOrder.OrderBuilder(input.SortField, input.DescSort))
.ToPagedListAsync(input.PageNo, input.PageSize);
#endregion
var list = entities.Adapt<SqlSugarPagedList<PageBookingOrder>>();
var status = await _repBookingStatus.AsQueryable().ToListAsync();
var remark = await _bookingremark.AsQueryable().ToListAsync();
var itgoodsStatus = _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new
{
bookingid = goods.bookingId,
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = goods.FinishTime,
ExtData = goods.ExtData,
Remark = goods.Remark,
CreatedUserId = config.CreatedUserId,
Sort = config.Sort
}).ToList();
var itconfigs = _goodsStatusConfig.AsQueryable().Select(config => new
{
bookingid = "",
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = "",
ExtData = "",
Remark = "",
CreatedUserId = config.CreatedUserId,
Sort = config.Sort
}).ToList();
foreach (var item in list.Items)
{
var sta = status.Where(x => x.BookingId == item.Id).ToList();
var sta = _repBookingStatus.AsQueryable().Filter(null, true).Where(x => x.BookingId == item.Id).ToList();
if (sta != null)
{
item.bookstatus = sta;
}
var st = remark.Where(x => x.PId == item.Id).ToList();
var st = _bookingremark.AsQueryable().Filter(null, true).Where(x => x.PId == item.Id).ToList();
if (st != null)
{
item.bookremark = st;
@ -357,6 +388,37 @@ namespace Myshipping.Application
{
item.ETA = Convert.ToDateTime(item.ETA).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.GoodsStatusList = itgoods.Union<GoodsStatusList>(itconfig).OrderBy(x=>x.Sort).ToList();
}
return list;
@ -766,11 +828,6 @@ namespace Myshipping.Application
}
/// <summary>
/// 更新订舱
/// </summary>
@ -1260,7 +1317,7 @@ namespace Myshipping.Application
/// <returns></returns>
[SqlSugarUnitOfWork]
[HttpPost("/BookingOrder/SaveGoodsStatus")]
public async Task SaveGoodsStatus(GoodsStatusDtoList input)
public async Task<dynamic> SaveGoodsStatus(GoodsStatusDtoList input)
{
if (input.BookingId == null || input.BookingId == 0)
{
@ -1278,6 +1335,53 @@ namespace Myshipping.Application
await _goodsStatus.InsertAsync(entity);
}
var userid = _rep.Where(x => x.Id == input.BookingId).Select(x => x.CreatedUserId).First();
if (userid != null)
{
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == input.BookingId).
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = goods.FinishTime,
FinishUser = goods.FinishUser,
FinishUserId = goods.FinishUserId,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Remark,
Sort = config.Sort
}).ToListAsync();
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
FinishTime = null,
FinishUser = null,
FinishUserId = null,
IsPublic = false,
ExtData = null,
Remark = null,
Sort = config.Sort
}).ToList();
foreach (var item in list)
{
config.RemoveAll(x => x.ConfigId == item.ConfigId);
}
return list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).ToList();
}
return null;
}
/// <summary>
@ -1292,8 +1396,8 @@ namespace Myshipping.Application
if (userid != null)
{
var list= await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
( goods,config) => config.Id == goods.ConfigId).Where((goods,config ) => config.CreatedUserId == userid&& goods.bookingId==bookingId).
var list = await _goodsStatus.AsQueryable().LeftJoin(_goodsStatusConfig.AsQueryable(),
(goods, config) => config.Id == goods.ConfigId).Where((goods, config) => config.CreatedUserId == userid && goods.bookingId == bookingId).
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new GoodsStatusQuery
{
@ -1305,11 +1409,12 @@ namespace Myshipping.Application
FinishUserId = goods.FinishUserId,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Remark
Remark = goods.Remark,
Sort = config.Sort
}).ToListAsync();
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery
{
ConfigId = config.Id,
@ -1320,16 +1425,17 @@ namespace Myshipping.Application
FinishUserId = null,
IsPublic = false,
ExtData = null,
Remark = null
Remark = null,
Sort = config.Sort
}).ToList();
foreach (var item in list)
{
config.RemoveAll(x => x.ConfigId==item.ConfigId);
config.RemoveAll(x => x.ConfigId == item.ConfigId);
}
return list.Union<dynamic>(config);
return list.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).ToList();
}
return null;
@ -4993,6 +5099,7 @@ namespace Myshipping.Application
OrderBy((goods, config) => config.Sort).
Select((goods, config) => new GoodsStatusQuery
{
ConfigId = config.Id,
SystemCode = config.SystemCode,
StatusName = config.StatusName,
@ -5001,8 +5108,8 @@ namespace Myshipping.Application
FinishUserId = goods.FinishUserId,
IsPublic = goods.IsPublic,
ExtData = goods.ExtData,
Remark = goods.Remark
Remark = goods.Remark,
Sort = config.Sort
}).ToListAsync();
var config = _goodsStatusConfig.AsQueryable().Where(config => config.CreatedUserId == userid).ToList().Select(config => new GoodsStatusQuery
@ -5016,7 +5123,8 @@ namespace Myshipping.Application
FinishUserId = null,
IsPublic = false,
ExtData = null,
Remark = null
Remark = null,
Sort = config.Sort
}).ToList();
foreach (var item in GoodsStatus)
@ -5027,7 +5135,7 @@ namespace Myshipping.Application
allData.GoodsStatus= GoodsStatus.Union<GoodsStatusQuery>(config).ToList();
allData.GoodsStatus = GoodsStatus.Union<GoodsStatusQuery>(config).OrderBy(x => x.Sort).ToList();
}
@ -5043,28 +5151,55 @@ namespace Myshipping.Application
///获取下拉前10条接口
/// </summary>
/// <returns></returns>
[HttpGet("/BookingOrder/GetAllSelectData")]
public async Task<dynamic> GetAllSelectData()
{
////报关行
var BGH= _djycustomer.Where(x => x.PropString == "customs_broker").Take(10).ToList();
var BGH = _djycustomer.Where(x => x.PropString == "customs_broker").Take(10).ToList();
//车队
var CD = _djycustomer.Where(x => x.PropString == "fleet").Take(10).ToList();
//国外代理
var GWDL = _djycustomer.Where(x => x.PropString == "out_agent").Take(10).ToList();
//仓库
var CK = _djycustomer.Where(x => x.PropString == "warehouse").Take(10).ToList();
var Portload = _cache.GetAllCodePortLoad().Result.Take(10).ToList();
return null;
}
var Port = _cache.GetAllCodePort().Result.Take(10).ToList();
var Template = _bookingTemplate.AsQueryable().Take(10).ToList();
var Customer = _djycustomer.AsQueryable().Filter(null, true).Where(x => x.TenantId == UserManager.TENANT_ID).Take(10).ToList();
var Forwarder = _cache.GetAllCodeForwarder().Result.Take(10).ToList();
var Contractno = _paraGoodsInfoRepository.AsQueryable().OrderBy("GOODS_CODE asc").Take(50).ToList().Select(t => t.Adapt<ParaGoodsShowDto>()).ToList();
var superAdmin = UserManager.IsSuperAdmin;
var User = _repUser.AsQueryable().InnerJoin<SysEmp>((u, e) => u.Id == e.Id)
.InnerJoin<SysOrg>((u, e, o) => e.OrgId == o.Id)
.InnerJoin<SysTenant>((u, e, o, t) => u.TenantId == t.Id)
.Where((u, e, o) => u.AdminType == AdminType.None)
.Select<UserOutput>("u.*,t.Name As TenantName ").ToDataFilter("u", "Id", FilterType.User).Take(10).ToList();
dynamic obj = new
{
BGH = BGH,
CD = CD,
GWDL = GWDL,
CK = CK,
Portload = Portload,
Port = Port,
Template = Template,
Customer = Customer,
Contractno = Contractno,
User = User
};
return obj;
}
}
}

@ -95,5 +95,49 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 排序
/// </summary>
public long? Sort { get; set; }
}
public class GoodsStatusList
{
public long? ConfigId { get; set; }
/// <summary>
/// 状态名称
/// </summary>
public string StatusName { get; set; }
/// <summary>
/// 系统编码
/// </summary>
public string SystemCode { get; set; }
/// <summary>
/// 完成时间
/// </summary>
public DateTime? FinishTime { get; set; }
/// <summary>
/// 附加数据
/// </summary>
public string ExtData { get; set; }
/// <summary>
/// 备注
/// </summary>
public string Remark { get; set; }
/// <summary>
/// 排序
/// </summary>
public long? Sort { get; set; }
}
}

@ -817,5 +817,7 @@ namespace Myshipping.Application.Service.BookingOrder.Dto
public List<BookingStatus> bookstatus { get; set; }
public List<BookingRemark> bookremark { get; set; }
public List<GoodsStatusList> GoodsStatusList { get; set; }
}
}

@ -1019,6 +1019,7 @@ namespace Myshipping.Application
entity.CARRIERID = _cache.GetAllCodeCarrier().Result.Where(x => x.CnName == entity.CARRIER).Select(x => x.Code).FirstOrDefault();
}
entity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
entity.CreatedUserId = user.Result.Id;
entity.CreatedUserName = user.Result.Name.ToString();
entity.CreatedTime = DateTime.Now;
@ -1147,6 +1148,7 @@ namespace Myshipping.Application
fdentity.CARRIER = entity.CARRIER;
fdentity.CARRIERID = _cache.GetAllCodeCarrier().Result.Where(x => x.CnName == entity.CARRIER).Select(x => x.Code).FirstOrDefault();
}
fdentity.BOOKINGNO = Yitter.IdGenerator.YitIdHelper.NextId().ToString();
fdentity.MBLNO = entity.MBLNO;
fdentity.CreatedUserId = user.Result.Id;
fdentity.CreatedUserName = user.Result.Name;
@ -1289,6 +1291,7 @@ namespace Myshipping.Application
}
await _rep.AsUpdateable(entity).IgnoreColumns(it => new
{
it.BOOKINGNO,
it.ParentId,
it.TenantId,
it.CreatedTime,
@ -1484,6 +1487,7 @@ namespace Myshipping.Application
}
await _rep.AsUpdateable(fdentity).IgnoreColumns(it => new
{
it.BOOKINGNO,
it.ParentId,
it.TenantId,
it.CreatedTime,

@ -194,7 +194,7 @@ namespace Myshipping.Core.Service
[HttpGet("/DjyCustomer/Suggest")]
public async Task<dynamic> Suggest(string keyword, string type)
{
List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
//List<long> userlist = await DataFilterExtensions.GetDataScopeIdList();
var entities = await _rep.AsQueryable().Filter(null, true)
.Where(x => x.TenantId == UserManager.TENANT_ID)
.WhereIF(!string.IsNullOrWhiteSpace(type), u => u.PropString.Contains(type))

@ -274,6 +274,61 @@ public static class JsonUtil
// return "PONO存在中文字符";
//}
if (sourceVal.ToString().Length>9 && propName.ToUpper() == "VESSELID") {
return "船舶呼号超长";
}
if (sourceVal.ToString().Length > 5&& propName.ToUpper() == "PLACERECEIPTID")
{
return "收货地代码超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PLACERECEIPTID")
{
return "收货地代码超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PORTLOADID")
{
return "起运港代码超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PORTDISCHARGEID")
{
return "卸货港代码超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "PLACEDELIVERYID")
{
return "交货地代码超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "DESTINATIONID")
{
return "目的地代码超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "NOBILL")
{
return "提单份数超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "ISSUEPLACEID")
{
return "签单地点代码超长";
}
if (sourceVal.ToString().Length > 1 && propName.ToUpper() == "CARGOID")
{
return "货物标识超长";
}
if (sourceVal.ToString().Length > 5 && propName.ToUpper() == "TRANSPORTID")
{
return "中转港代码超长";
}
}
}

Loading…
Cancel
Save