cjy 2 months ago
commit 4aeee28be4

@ -0,0 +1,179 @@
using DS.Module.Core;
using DS.Module.ExcelModule.Model;
using LanguageExt.ClassInstances;
using LanguageExt;
using Microsoft.AspNet.SignalR.Hubs;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.DependencyInjection;
using MiniExcelLibs;
using Newtonsoft.Json.Linq;
using SqlSugar;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using NPOI.SS.UserModel;
using OfficeOpenXml;
using System.Data;
using Spire.Xls;
namespace DS.Module.ExcelModule
{
public class EPPlusService : IEPPlusService
{
private readonly IServiceProvider _serviceProvider;
private static string GetString(object obj)
{
try
{
if (obj == null) return "";
return obj.ToString();
}
catch (Exception ex)
{
return "";
}
}
/// <summary>
///将指定的Excel的文件转换成DataTable Excel的第一个sheet
/// </summary>
/// <param name="fullFielPath">文件的绝对路径</param>
/// <returns></returns>
public DataTable WorksheetToTable(string fullFielPath, int SheetIndex = 1)
{
try
{
string[] PathNames = fullFielPath.Split(new string[] { @"/" }, StringSplitOptions.RemoveEmptyEntries);
var ExcelFileName = PathNames[PathNames.Length - 1];
if (ExcelFileName.EndsWith(".xls"))
{
var newExcelFileName = PathNames[PathNames.Length - 1].Replace(".xls", ".xlsx");
var _newFileFullname = Path.GetDirectoryName(fullFielPath) + "/" + newExcelFileName;
Workbook book = new Workbook();
book.LoadFromFile(fullFielPath);
book.SaveToFile(_newFileFullname, ExcelVersion.Version2013);
fullFielPath = _newFileFullname;
}
FileInfo existingFile = new FileInfo(fullFielPath);
ExcelPackage package = new ExcelPackage(existingFile);
ExcelWorksheet worksheet = package.Workbook.Worksheets[SheetIndex];//选定 指定页
return WorksheetToTable(worksheet);
}
catch (Exception e)
{
throw;
}
}
public DataTable WorksheetToTable_NoTitle(string fullFielPath, int SheetIndex = 1)
{
try
{
string[] PathNames = fullFielPath.Split(new string[] { @"/" }, StringSplitOptions.RemoveEmptyEntries);
var ExcelFileName = PathNames[PathNames.Length - 1];
if (ExcelFileName.EndsWith(".xls"))
{
var newExcelFileName = PathNames[PathNames.Length - 1].Replace(".xls", ".xlsx");
var _newFileFullname = Path.GetDirectoryName(fullFielPath) + "/" + newExcelFileName;
Workbook book = new Workbook();
book.LoadFromFile(fullFielPath);
book.SaveToFile(_newFileFullname, ExcelVersion.Version2013);
fullFielPath = _newFileFullname;
}
FileInfo existingFile = new FileInfo(fullFielPath);
ExcelPackage package = new ExcelPackage(existingFile);
ExcelWorksheet worksheet = package.Workbook.Worksheets[SheetIndex];//选定 指定页
return WorksheetToTable_NoTitle(worksheet);
}
catch (Exception e)
{
throw;
}
}
/// <summary>
/// 将worksheet转成datatable
/// </summary>
/// <param name="worksheet">待处理的worksheet</param>
/// <returns>返回处理后的datatable</returns>
public DataTable WorksheetToTable(ExcelWorksheet worksheet)
{
//获取worksheet的行数
int rows = worksheet.Dimension.End.Row;
//获取worksheet的列数
int cols = worksheet.Dimension.End.Column;
DataTable dt = new DataTable(worksheet.Name);
DataRow dr = null;
for (int i = 1; i <= rows; i++)
{
if (i > 1)
dr = dt.Rows.Add();
for (int j = 1; j <= cols; j++)
{
//默认将第一行设置为datatable的标题
if (i == 1)
dt.Columns.Add(GetString(worksheet.Cells[i, j].Value));
//剩下的写入datatable
else
dr[j - 1] = GetString(worksheet.Cells[i, j].Value);
}
}
return dt;
}
public DataTable WorksheetToTable_NoTitle(ExcelWorksheet worksheet)
{
//获取worksheet的行数
int rows = worksheet.Dimension.End.Row;
//获取worksheet的列数
int cols = worksheet.Dimension.End.Column;
DataTable dt = new DataTable(worksheet.Name);
DataRow dr = null;
for (int i = 1; i <= rows; i++)
{
//if (i > 1)
dr = dt.Rows.Add();
for (int j = 1; j <= cols; j++)
{
//默认将第一行设置为datatable的标题
if (i == 1)
{
dt.Columns.Add(GetString(worksheet.Cells[i, j].Value));
dr[j - 1] = GetString(worksheet.Cells[i, j].Value);
}
//剩下的写入datatable
else
{
dr[j - 1] = GetString(worksheet.Cells[i, j].Value);
}
}
}
return dt;
}
}
}

@ -56,6 +56,7 @@ namespace DS.Module.ExcelModule
return DataResult<string>.Success(path); return DataResult<string>.Success(path);
} }
public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req) public MemoryStream ExportExcelStreamByColumn(ExportByColumnReq req)
{ {
var filename = Guid.NewGuid() + ".xlsx"; var filename = Guid.NewGuid() + ".xlsx";

@ -0,0 +1,19 @@
using DS.Module.Core;
using DS.Module.ExcelModule.Model;
using Microsoft.AspNetCore.Mvc;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace DS.Module.ExcelModule
{
public interface IEPPlusService
{
public DataTable WorksheetToTable(string fullFielPath, int SheetIndex = 1);
public DataTable WorksheetToTable_NoTitle(string fullFielPath, int SheetIndex = 1);
}
}

@ -15,6 +15,7 @@
<PackageReference Include="DotNetCore.CAP" Version="8.0.0" /> <PackageReference Include="DotNetCore.CAP" Version="8.0.0" />
<PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="8.0.0" /> <PackageReference Include="DotNetCore.CAP.InMemoryStorage" Version="8.0.0" />
<PackageReference Include="Enums.NET" Version="5.0.0" /> <PackageReference Include="Enums.NET" Version="5.0.0" />
<PackageReference Include="EPPlus" Version="7.3.1" />
<PackageReference Include="fasterflect" Version="3.0.0" /> <PackageReference Include="fasterflect" Version="3.0.0" />
<PackageReference Include="GZY.Quartz.MUI" Version="2.6.0" /> <PackageReference Include="GZY.Quartz.MUI" Version="2.6.0" />
<PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" /> <PackageReference Include="Hangfire.AspNetCore" Version="1.8.14" />
@ -50,6 +51,7 @@
<PackageReference Include="SharpZipLib" Version="1.4.2" /> <PackageReference Include="SharpZipLib" Version="1.4.2" />
<PackageReference Include="Snowflake.Core" Version="2.0.0" /> <PackageReference Include="Snowflake.Core" Version="2.0.0" />
<PackageReference Include="Snowflake.Data" Version="2.2.0" /> <PackageReference Include="Snowflake.Data" Version="2.2.0" />
<PackageReference Include="Spire.XLS" Version="14.9.1" />
<PackageReference Include="SqlSugar.IOC" Version="2.0.0" /> <PackageReference Include="SqlSugar.IOC" Version="2.0.0" />
<PackageReference Include="SqlSugarCore" Version="5.1.4.167" /> <PackageReference Include="SqlSugarCore" Version="5.1.4.167" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" /> <PackageReference Include="Swashbuckle.AspNetCore" Version="6.7.0" />

@ -17,7 +17,11 @@ using DS.WMS.Core.Sys.Entity;
using Mapster; using Mapster;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json; using Newtonsoft.Json;
using NPOI.HPSF;
using SqlSugar; using SqlSugar;
using DS.Module;
using DS.Module.ExcelModule;
using DS.Module.ExcelModule.Model;
namespace DS.WMS.ContainerManagement.Info.Method; namespace DS.WMS.ContainerManagement.Info.Method;
@ -27,6 +31,7 @@ public class CM_BaseInfoService : ICM_BaseInfoService
private readonly ISqlSugarClient db; private readonly ISqlSugarClient db;
private readonly IUser user; private readonly IUser user;
private readonly ISaasDbService saasService; private readonly ISaasDbService saasService;
private readonly IEPPlusService epplusService;
/// <summary> /// <summary>
/// ///
@ -38,6 +43,7 @@ public class CM_BaseInfoService : ICM_BaseInfoService
db = _serviceProvider.GetRequiredService<ISqlSugarClient>(); db = _serviceProvider.GetRequiredService<ISqlSugarClient>();
user = _serviceProvider.GetRequiredService<IUser>(); user = _serviceProvider.GetRequiredService<IUser>();
saasService = _serviceProvider.GetRequiredService<ISaasDbService>(); saasService = _serviceProvider.GetRequiredService<ISaasDbService>();
epplusService = _serviceProvider.GetRequiredService<IEPPlusService>();
} }
/// <summary> /// <summary>
@ -264,6 +270,11 @@ public class CM_BaseInfoService : ICM_BaseInfoService
/// <returns></returns> /// <returns></returns>
public DataResult CM_DealExcel(CM_DealExcelReq req) public DataResult CM_DealExcel(CM_DealExcelReq req)
{ {
var _dt = epplusService.WorksheetToTable("excel文件地址");
return DataResult.Successed($"调用成功!{JsonConvert.SerializeObject(req)}", MultiLanguageConst.DataUpdateSuccess); return DataResult.Successed($"调用成功!{JsonConvert.SerializeObject(req)}", MultiLanguageConst.DataUpdateSuccess);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);
@ -280,6 +291,8 @@ public class CM_BaseInfoService : ICM_BaseInfoService
{ {
return DataResult.Successed($"", MultiLanguageConst.DataUpdateSuccess); return DataResult.Successed($"", MultiLanguageConst.DataUpdateSuccess);
var tenantDb = saasService.GetBizDbScopeById(user.TenantId); var tenantDb = saasService.GetBizDbScopeById(user.TenantId);

@ -45,6 +45,7 @@
<ProjectReference Include="..\DS.Module.Core\DS.Module.Core.csproj" /> <ProjectReference Include="..\DS.Module.Core\DS.Module.Core.csproj" />
<ProjectReference Include="..\DS.Module.DjyRulesEngine\DS.Module.DjyRulesEngine.csproj" /> <ProjectReference Include="..\DS.Module.DjyRulesEngine\DS.Module.DjyRulesEngine.csproj" />
<ProjectReference Include="..\DS.Module.DjyServiceStatus\DS.Module.DjyServiceStatus.csproj" /> <ProjectReference Include="..\DS.Module.DjyServiceStatus\DS.Module.DjyServiceStatus.csproj" />
<ProjectReference Include="..\DS.Module.ExcelModule\DS.Module.ExcelModule.csproj" />
<ProjectReference Include="..\DS.Module.MQ\DS.Module.MQ.csproj" /> <ProjectReference Include="..\DS.Module.MQ\DS.Module.MQ.csproj" />
<ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" /> <ProjectReference Include="..\DS.Module.Nuget\DS.Module.Nuget.csproj" />
<ProjectReference Include="..\DS.Module.PrintModule\DS.Module.PrintModule.csproj" /> <ProjectReference Include="..\DS.Module.PrintModule\DS.Module.PrintModule.csproj" />

@ -431,6 +431,11 @@ namespace DS.WMS.Core.Op.EDI
} }
} }
if (!new string[] { "ORI", "TER", "EXP" }.Contains(headData.ISSUETYPE))
{
error = error + "<br />提单号:" + headData.MBLNO + "签单方式未识别";
}
if (string.IsNullOrEmpty(headData.DESCRIPTION)) if (string.IsNullOrEmpty(headData.DESCRIPTION))
{ {
error = error + "<br />提单号:" + headData.MBLNO + " 货物描述不能为空"; error = error + "<br />提单号:" + headData.MBLNO + " 货物描述不能为空";
@ -831,15 +836,20 @@ namespace DS.WMS.Core.Op.EDI
} }
else ISSUETYPE = "EXP"; else ISSUETYPE = "EXP";
*/ */
if (bill.ISSUETYPE == "ORIGINAL") //if (bill.ISSUETYPE == "ORIGINAL")
{ //{
ISSUETYPE = "ORI"; // ISSUETYPE = "ORI";
} //}
else if (bill.ISSUETYPE == "TELEX") //else if (bill.ISSUETYPE == "TELEX")
//{
// ISSUETYPE = "TER";
//}
//else ISSUETYPE = "EXP";
if(new string[] { "ORI", "TER", "EXP" }.Contains(bill.ISSUETYPE))
{ {
ISSUETYPE = "TER"; ISSUETYPE = bill.ISSUETYPE;
} }
else ISSUETYPE = "EXP";
r.WriteLine("03:" + ISSUETYPE + ":" + bill.ISSUEPLACEID.Trim() + ":" + bill.ISSUEPLACE.Trim() + ":" + GetDateStr(bill.ISSUEDATE, "yyyyMMdd") + ":" + GetBillNum2(bill.NOBILL) + ":" + bill.PREPARDAT + ":" + bill.PAYABLEAT + "'"); r.WriteLine("03:" + ISSUETYPE + ":" + bill.ISSUEPLACEID.Trim() + ":" + bill.ISSUEPLACE.Trim() + ":" + GetDateStr(bill.ISSUEDATE, "yyyyMMdd") + ":" + GetBillNum2(bill.NOBILL) + ":" + bill.PREPARDAT + ":" + bill.PAYABLEAT + "'");
icount++; icount++;

@ -1383,12 +1383,19 @@ namespace DS.WMS.Core.Op.Method
#region 签单方式EDI #region 签单方式EDI
////签单方式EDI ////签单方式EDI
if (!string.IsNullOrWhiteSpace(order.IssueType)) if (!string.IsNullOrWhiteSpace(order.IssueTypeCode))
{ {
long issueTypeId = long.Parse(order.IssueType); //long issueTypeId = long.Parse(order.IssueType);
var codeIssue = tenantDb.Queryable<CodeIssueType>().First(t => t.EdiCode == order.IssueTypeCode);
if (codeIssue == null)
{
return DataResult<string>.Failed($"签单方式{order.IssueTypeCode}的基础代码未找到");
}
var mapInfo = tenantDb.Queryable<MappingIssueType>() var mapInfo = tenantDb.Queryable<MappingIssueType>()
.First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && t.CarrierId == order.CarrierId && t.Id == issueTypeId); .First(t => t.Module.Equals(CONST_MAPPING_MODULE, StringComparison.OrdinalIgnoreCase) && t.CarrierId == order.CarrierId && t.LinkId == codeIssue.Id);
if (mapInfo != null) if (mapInfo != null)
{ {
@ -1397,15 +1404,13 @@ namespace DS.WMS.Core.Op.Method
else else
{ {
//签单方式EDI //签单方式EDI
var codeService = tenantDb.Queryable<CodeIssueType>().First(x => x.Status == StatusEnum.Enable && x.Id == issueTypeId); if (codeIssue != null && !string.IsNullOrWhiteSpace(codeIssue.EdiCode))
if (codeService != null && !string.IsNullOrWhiteSpace(codeService.EdiCode))
{ {
primaryModel.ISSUETYPE = codeService.EdiCode; primaryModel.ISSUETYPE = codeIssue.EdiCode;
} }
else else
{ {
return DataResult<string>.Failed($"签单方式{order.Service}的基础代码未找到"); return DataResult<string>.Failed($"签单方式{order.Service}的基础代码 EdiCode 未配置");
} }
} }
} }
@ -1512,7 +1517,7 @@ namespace DS.WMS.Core.Op.Method
primaryModel.EDIATTNEMAIL = ediExtModel.EDIAttnMail; primaryModel.EDIATTNEMAIL = ediExtModel.EDIAttnMail;
if (string.IsNullOrWhiteSpace(primaryModel.EDIATTNEMAIL)) if (string.IsNullOrWhiteSpace(primaryModel.EDIATTNEMAIL) && ediRouteEnum != EDIRouteEnum.YT)
{ {
primaryModel.EDIATTNEMAIL = ftpSet.SendEmail; primaryModel.EDIATTNEMAIL = ftpSet.SendEmail;
} }

Loading…
Cancel
Save