|
|
|
@ -2809,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);
|
|
|
|
|
|
|
|
|
@ -2843,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);
|
|
|
|
@ -2992,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;
|
|
|
|
@ -3047,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))
|
|
|
|
@ -3079,7 +3082,7 @@ namespace DS.WMS.Core.Op.Method
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
result.succ = true;
|
|
|
|
|
succ = true;
|
|
|
|
|
|
|
|
|
|
var group = data.Keys.Where(x =>
|
|
|
|
|
!existsNoList.Contains(x.SlotBookingNo)
|
|
|
|
@ -3120,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
|
|
|
|
|
|
|
|
|
|