|
|
|
@ -109,6 +109,13 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
//船公司基础映射模块
|
|
|
|
|
const string CONST_MAPPING_CARRIER_MODULE = "CarrierBaseMapping";
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* 是否启用委托单位权限显示控制
|
|
|
|
|
开启此参数后,在部分接口查询数据时会根据当前登陆人的权限范围来决定返回哪些委托单位,
|
|
|
|
|
如委托单位管理台账查询接口、委托单位下拉查询接口、舱位管理台账查询接口、舱位管理详情查询接口等
|
|
|
|
|
*/
|
|
|
|
|
const string IS_ENABLE_CUSTOMER_AUTHORITY = "IS_ENABLE_CUSTOMER_AUTHORITY";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public BookingSlotService(IServiceProvider serviceProvider)
|
|
|
|
|
{
|
|
|
|
@ -2802,28 +2809,32 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="file">导入舱位文件</param>
|
|
|
|
|
/// <returns>返回回执</returns>
|
|
|
|
|
public async Task<TaskManageOrderResultDto> ImportSlotFromFile(IFormFile file)
|
|
|
|
|
public async Task<DataResult<List<object>>> ImportSlotFromFile(IFormFile file)
|
|
|
|
|
{
|
|
|
|
|
TaskManageOrderResultDto result = new TaskManageOrderResultDto();
|
|
|
|
|
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
|
|
|
|
|
bool succ = false;
|
|
|
|
|
List<object> list = new List<object>();
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
result.succ = false;
|
|
|
|
|
|
|
|
|
|
if (file == null)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "附件不能为空";
|
|
|
|
|
return result;
|
|
|
|
|
//附件不能为空
|
|
|
|
|
return DataResult<List<object>>.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotImportFileNull)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
FileInfo fileInfo = new FileInfo(file.FileName);
|
|
|
|
|
if (fileInfo.Extension != ".xlsx")
|
|
|
|
|
{
|
|
|
|
|
result.msg = "请上传指定模板文件";
|
|
|
|
|
return result;
|
|
|
|
|
//请上传指定模板文件
|
|
|
|
|
return DataResult<List<object>>.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotImportFileTypeError)));
|
|
|
|
|
}
|
|
|
|
|
var tempDic = string.Empty;// Path.Combine(App.WebHostEnvironment.WebRootPath, App.GetOptions<TempFileOptions>().Path, DateTime.Now.Ticks.ToString());
|
|
|
|
|
|
|
|
|
|
string fileRoot = AppSetting.app(new string[] { "FileSettings", "BasePath" });
|
|
|
|
|
string relativePath = AppSetting.app(new string[] { "FileSettings", "RelativePath" });
|
|
|
|
|
|
|
|
|
|
var tempDic = Path.Combine(fileRoot, relativePath, DateTime.Now.Ticks.ToString());
|
|
|
|
|
Directory.CreateDirectory(tempDic);
|
|
|
|
|
var filePath = Path.Combine(tempDic, file.FileName);
|
|
|
|
|
|
|
|
|
@ -2836,15 +2847,15 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
var sheet = readbook.GetSheet("导入");
|
|
|
|
|
if (sheet == null)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "内容为空";
|
|
|
|
|
return result;
|
|
|
|
|
//内容为空
|
|
|
|
|
return DataResult<List<object>>.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotImportExcelEmpty)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var rowCount = sheet.LastRowNum;
|
|
|
|
|
if (rowCount <= 1)
|
|
|
|
|
{
|
|
|
|
|
result.msg = "内容为空";
|
|
|
|
|
return result;
|
|
|
|
|
//内容为空
|
|
|
|
|
return DataResult<List<object>>.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotImportExcelEmpty)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Dictionary<BookingSlotBase, List<BookingSlotCtn>> data = new(rowCount);
|
|
|
|
@ -2985,7 +2996,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 特殊处理
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(slot.CarrierCode)) slot.Carrier = cacheMappCarrier.FirstOrDefault(x => x.CarrierName == slot.CarrierCode)?.CarrierName;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(slot.CarrierCode)) slot.Carrier = cacheMappCarrier.FirstOrDefault(x => x.MapCode == slot.CarrierCode)?.MapName;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(slot.PortLoadCode)) slot.PortLoad = cachePort.FirstOrDefault(x => x.EdiCode == slot.PortLoadCode)?.PortName;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(slot.PortDischargeCode)) slot.PortDischarge = cachePort.FirstOrDefault(x => x.EdiCode == slot.PortDischargeCode)?.PortName;
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(slot.LaneName)) slot.LaneCode = cacheLane.FirstOrDefault(x => x.LaneName == slot.LaneName)?.LaneEnName;
|
|
|
|
@ -3040,8 +3051,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
.Select(x => x.SlotBookingNo)
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
|
|
|
|
|
List<object> list = new List<object>();
|
|
|
|
|
result.ext = list;
|
|
|
|
|
|
|
|
|
|
foreach (var item in data)
|
|
|
|
|
{
|
|
|
|
|
if (existsNoList.Contains(item.Key.SlotBookingNo))
|
|
|
|
@ -3072,7 +3082,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
succ = true;
|
|
|
|
|
|
|
|
|
|
var group = data.Keys.Where(x =>
|
|
|
|
|
!existsNoList.Contains(x.SlotBookingNo)
|
|
|
|
@ -3113,11 +3123,15 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
{
|
|
|
|
|
Logger.Log(NLog.LogLevel.Error, $"导入舱位异常,原因:{ex.Message}");
|
|
|
|
|
|
|
|
|
|
result.succ = false;
|
|
|
|
|
result.msg = $"导入舱位异常,原因:{ex.Message}";
|
|
|
|
|
return DataResult<List<object>>.Failed(string.Format(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotImportException)), ex.Message));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
if(succ)
|
|
|
|
|
{
|
|
|
|
|
return DataResult<List<object>>.Success(list);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return DataResult<List<object>>.Failed(MultiLanguageConst.GetDescription(nameof(MultiLanguageConst.BookingSlotImportFail)));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
@ -3470,14 +3484,176 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
|
|
|
|
|
//序列化查询条件
|
|
|
|
|
var whereList = db.ConfigQuery.Context.Utilities.JsonToConditionalModels(querySearch.QueryCondition);
|
|
|
|
|
|
|
|
|
|
List<string> ctnCodeArr = new List<string>();
|
|
|
|
|
List<long> labelIdArray = new List<long>();
|
|
|
|
|
|
|
|
|
|
if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("ctnStat", StringComparison.OrdinalIgnoreCase)))
|
|
|
|
|
{
|
|
|
|
|
var codList = whereList.Where(t => ((ConditionalModel)t).FieldName.Equals("ctnStat", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
|
|
|
|
|
ctnCodeArr = codList.Select(t => ((ConditionalModel)t).FieldValue).ToList();
|
|
|
|
|
|
|
|
|
|
codList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
whereList.Remove(t);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (whereList.Any(t => ((ConditionalModel)t).FieldName.Equals("labelIdArray", StringComparison.OrdinalIgnoreCase)))
|
|
|
|
|
{
|
|
|
|
|
var codList = whereList.Where(t => ((ConditionalModel)t).FieldName.Equals("labelIdArray", StringComparison.OrdinalIgnoreCase)).ToList();
|
|
|
|
|
|
|
|
|
|
labelIdArray = codList.Select(t => long.Parse(((ConditionalModel)t).FieldValue)).ToList();
|
|
|
|
|
|
|
|
|
|
codList.ForEach(t =>
|
|
|
|
|
{
|
|
|
|
|
whereList.Remove(t);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var result = tenantDb.Queryable<BookingSlotBase>()
|
|
|
|
|
.InnerJoin<BookingSlotCtn>((a, b) => a.Id == b.SlotId)
|
|
|
|
|
.Select<BookingSlotBaseDto>()
|
|
|
|
|
.Where(whereList);
|
|
|
|
|
//.ToQueryPageAsync(request.PageCondition);
|
|
|
|
|
var list = result.ToList();
|
|
|
|
|
.LeftJoin<BookingSlotCtn>((a, b) => a.Id == b.SlotId)
|
|
|
|
|
.Where(whereList)
|
|
|
|
|
.WhereIF(ctnCodeArr != null && ctnCodeArr.Count > 0, (a, b) => b != null
|
|
|
|
|
&& !string.IsNullOrWhiteSpace(b.CtnCode)
|
|
|
|
|
&& ctnCodeArr.Contains(b.CtnCode) && b.Deleted == false)
|
|
|
|
|
.WhereIF(labelIdArray != null && labelIdArray.Count > 0,
|
|
|
|
|
a => SqlFunc.Subqueryable<BookingLabelAllocation>()
|
|
|
|
|
.Where(x => x.BusinessId == a.Id && labelIdArray.Contains(x.LabelId))
|
|
|
|
|
.Any())
|
|
|
|
|
.Select<BookingSlotBaseDto>();
|
|
|
|
|
|
|
|
|
|
var data = await result.ToQueryPageAsync(querySearch.PageCondition);
|
|
|
|
|
|
|
|
|
|
var slotIds = data.Data.Select(x => x.Id);
|
|
|
|
|
if (slotIds.Any())
|
|
|
|
|
{
|
|
|
|
|
// 查询舱位绑定的销售信息,赋值到舱位对象中
|
|
|
|
|
List<BookingSlotSaleInfoDto> allocationInfoList = await tenantDb.Queryable<BookingSlotAllocation>()
|
|
|
|
|
.Where(x => slotIds.Contains(x.BookingSlotId))
|
|
|
|
|
.Select(x => new BookingSlotSaleInfoDto
|
|
|
|
|
{
|
|
|
|
|
Id = x.Id,
|
|
|
|
|
BookingId = x.BookingId,
|
|
|
|
|
BookingSlotId = x.BookingSlotId,
|
|
|
|
|
CustomerId = x.CustomerId,
|
|
|
|
|
CustomerName = x.CustomerName,
|
|
|
|
|
CustServiceId = x.CustServiceId,
|
|
|
|
|
CustService = x.CustService,
|
|
|
|
|
SaleId = x.SaleId,
|
|
|
|
|
Sale = x.Sale,
|
|
|
|
|
OpId = x.OpId,
|
|
|
|
|
Op = x.Op,
|
|
|
|
|
DocId = x.DocId,
|
|
|
|
|
Doc = x.Doc,
|
|
|
|
|
Business = x.Business,
|
|
|
|
|
BusinessId = x.BusinessId,
|
|
|
|
|
SaleTime = x.SaleTime,
|
|
|
|
|
Shipper = x.Shipper,
|
|
|
|
|
GoodsName = x.GoodsName,
|
|
|
|
|
SellingPrice = x.SellingPrice,
|
|
|
|
|
CreateBy = x.CreateBy
|
|
|
|
|
}).ToListAsync();
|
|
|
|
|
|
|
|
|
|
if (allocationInfoList.Any())
|
|
|
|
|
{
|
|
|
|
|
var paramConfig = _configService.GetConfig(IS_ENABLE_CUSTOMER_AUTHORITY, long.Parse(user.TenantId), false).GetAwaiter().GetResult()?.Data?.Value;
|
|
|
|
|
|
|
|
|
|
// 判断是否启用了委托单位查看控制权限
|
|
|
|
|
bool isEnableCustomerAuthority = false;
|
|
|
|
|
|
|
|
|
|
if(paramConfig.Equals("ENABLE",StringComparison.OrdinalIgnoreCase))
|
|
|
|
|
{
|
|
|
|
|
isEnableCustomerAuthority = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
List<long> userList = null;
|
|
|
|
|
List<string> userListStr = null;
|
|
|
|
|
//if (isEnableCustomerAuthority)
|
|
|
|
|
//{
|
|
|
|
|
// userList = await _sysDataUserMenuService.GetDataScopeList(MenuConst.MenuDjyCustomer);
|
|
|
|
|
// if (userList == null || userList.Count == 0)
|
|
|
|
|
// {
|
|
|
|
|
// isEnableCustomerAuthority = false;
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// userListStr = userList.Select(x => x.ToString()).ToList();
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
var saleInfoGroup = allocationInfoList.GroupBy(x => x.BookingSlotId);
|
|
|
|
|
foreach (var item in saleInfoGroup)
|
|
|
|
|
{
|
|
|
|
|
if (isEnableCustomerAuthority)
|
|
|
|
|
{
|
|
|
|
|
// 遍历销售信息,如果销售信息中的“销售、操作、单证、客服、创建人”中不在当前登陆人的权限范围,则隐藏客户信息
|
|
|
|
|
foreach (BookingSlotSaleInfoDto saleInfoItem in item)
|
|
|
|
|
{
|
|
|
|
|
if (!userList.Contains(saleInfoItem.CreateBy)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.OpId)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.DocId)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.SaleId)
|
|
|
|
|
&& !userListStr.Contains(saleInfoItem.CustServiceId))
|
|
|
|
|
{
|
|
|
|
|
saleInfoItem.CustomerId = 0;
|
|
|
|
|
saleInfoItem.CustomerName = "--";
|
|
|
|
|
saleInfoItem.OpId = "";
|
|
|
|
|
saleInfoItem.Op = "--";
|
|
|
|
|
saleInfoItem.DocId = "";
|
|
|
|
|
saleInfoItem.Doc = "--";
|
|
|
|
|
saleInfoItem.SaleId = "";
|
|
|
|
|
saleInfoItem.Sale = "--";
|
|
|
|
|
saleInfoItem.Shipper = "--";
|
|
|
|
|
saleInfoItem.GoodsName = "--";
|
|
|
|
|
saleInfoItem.CustServiceId = "";
|
|
|
|
|
saleInfoItem.CustService = "--";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
var slot = data.Data.FirstOrDefault(x => x.Id == item.Key);
|
|
|
|
|
if (slot != null)
|
|
|
|
|
{
|
|
|
|
|
slot.BookingSlotSaleInfoList = item.ToList();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查询舱位绑定的标签信息,赋值到舱位对象中
|
|
|
|
|
var labelCacheList = await _bookingLabelService.List(1);
|
|
|
|
|
var labelAllocationList = await tenantDb.Queryable<BookingLabelAllocation>()
|
|
|
|
|
.Where(x => slotIds.Contains(x.BusinessId))
|
|
|
|
|
.ToListAsync();
|
|
|
|
|
if (labelAllocationList.Any())
|
|
|
|
|
{
|
|
|
|
|
var labelInfoGroup = labelAllocationList.GroupBy(x => x.BusinessId);
|
|
|
|
|
foreach (var item in labelInfoGroup)
|
|
|
|
|
{
|
|
|
|
|
var slot = data.Data.FirstOrDefault(x => x.Id == item.Key);
|
|
|
|
|
if (slot != null)
|
|
|
|
|
{
|
|
|
|
|
slot.LabelList = item.Select(x =>
|
|
|
|
|
{
|
|
|
|
|
var labelCache = labelCacheList.Data.FirstOrDefault(l => l.Id == x.LabelId);
|
|
|
|
|
if (labelCache != null)
|
|
|
|
|
{
|
|
|
|
|
return new BookingLabelBaseDto
|
|
|
|
|
{
|
|
|
|
|
Id = x.LabelId,
|
|
|
|
|
Name = labelCache.Name,
|
|
|
|
|
Color = labelCache.Color,
|
|
|
|
|
Scope = labelCache.Scope
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}).ToList();
|
|
|
|
|
slot.LabelList.RemoveAll(x => x == null);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|