1
This commit is contained in:
@@ -169,6 +169,10 @@ public class ModuleConsts
|
||||
/// </summary>
|
||||
public const string MODULE_WMSWAREHOUSEDEFINITION_ID = "25905106252053";
|
||||
/// <summary>
|
||||
/// 模块标识-仓库定义
|
||||
/// </summary>
|
||||
public const string MODULE_LOCATIONDEFINITION_ID = "26103854387237";
|
||||
/// <summary>
|
||||
/// 模块标识-路段管理
|
||||
/// </summary>
|
||||
public const string MODULE_WMSROAD_ID = "26100621140773";
|
||||
|
||||
@@ -43,7 +43,7 @@ namespace Tnb.WarehouseMgr
|
||||
|
||||
ICellStyle style = workbook.CreateCellStyle();
|
||||
IFont font = workbook.CreateFont();
|
||||
font.Color = IndexedColors.Black.Index; // 将字体颜色设置为红色
|
||||
font.Color = IndexedColors.Black.Index; // 将字体颜色设置为黑色
|
||||
style.SetFont(font);
|
||||
var nameRow = sheet?.GetRow(0);
|
||||
if (nameRow != null)
|
||||
|
||||
82
WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs
Normal file
82
WarehouseMgr/Tnb.WarehouseMgr/LocationDefinitionService.cs
Normal file
@@ -0,0 +1,82 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
using JNPF.Common.Core.Manager;
|
||||
using JNPF.Common.Security;
|
||||
using JNPF.FriendlyException;
|
||||
using JNPF.VisualDev;
|
||||
using Mapster;
|
||||
using Microsoft.AspNetCore.Http;
|
||||
using SqlSugar;
|
||||
using Tnb.BasicData.Entities;
|
||||
using Tnb.WarehouseMgr.Entities.Enums;
|
||||
using Tnb.WarehouseMgr.Entities;
|
||||
using JNPF.Common.Extension;
|
||||
using JNPF.Logging;
|
||||
using System.Reflection.Emit;
|
||||
|
||||
namespace Tnb.WarehouseMgr
|
||||
{
|
||||
[OverideVisualDev(ModuleConsts.MODULE_LOCATIONDEFINITION_ID)]
|
||||
public class LocationDefinitionService : ExcelDataImportManager
|
||||
{
|
||||
private readonly ISqlSugarClient _db;
|
||||
private readonly IUserManager _userManager;
|
||||
public LocationDefinitionService(ISqlSugarRepository<BasLocation> repository, IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_userManager = userManager;
|
||||
OverideFuncs.ImportAsync = DataImport;
|
||||
}
|
||||
|
||||
private async Task<dynamic> DataImport(IFormFile file)
|
||||
{
|
||||
int row = 0;
|
||||
try
|
||||
{
|
||||
//例1 获取所有表
|
||||
|
||||
List<Dictionary<string, object>> dics = await ImportExcelToMemory(file);
|
||||
List<BasLocation> locs = new List<BasLocation>();
|
||||
BasLocation loc = new BasLocation();
|
||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
if (carryStdDic?.Count > 0)
|
||||
{
|
||||
string carryStdId = string.Empty;
|
||||
foreach (var d in dics)
|
||||
{
|
||||
var stdCodeKey = d["carrystd_id"].ToString();
|
||||
carryStdId = carryStdDic.ContainsKey(stdCodeKey) ? carryStdDic[stdCodeKey]?.ToString() ?? "" : "";
|
||||
d["carrystd_id"] = carryStdId;
|
||||
loc = d.Adapt<BasLocation>();
|
||||
locs.Add(loc);
|
||||
}
|
||||
}
|
||||
locs.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.is_lock = 0;
|
||||
x.create_id = _userManager.UserId;
|
||||
x.create_time = DateTime.Now;
|
||||
x.modify_id = null;
|
||||
x.modify_time = null;
|
||||
x.is_mix = 1;
|
||||
});
|
||||
|
||||
await _db.Ado.BeginTranAsync();
|
||||
row = await _db.Insertable(locs).ExecuteCommandAsync();
|
||||
await _db.Ado.CommitTranAsync();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
await _db.Ado.RollbackTranAsync();
|
||||
Log.Error("导入失败", ex);
|
||||
throw Oops.Bah("导入失败");
|
||||
}
|
||||
return row > 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -72,7 +72,6 @@ namespace Tnb.WarehouseMgr
|
||||
{
|
||||
var stdCodeKey = d["carrystd_id"].ToString();
|
||||
carryStdId = carryStdDic.ContainsKey(stdCodeKey) ? carryStdDic[stdCodeKey]?.ToString() ?? "" : "";
|
||||
d.Add("carrystd_code", stdCodeKey??"");
|
||||
d["carrystd_id"] = carryStdId;
|
||||
locCodes.Add(d["location_code"]?.ToString() ?? string.Empty);
|
||||
carryH = d.Adapt<WmsCarryH>();
|
||||
@@ -86,7 +85,6 @@ namespace Tnb.WarehouseMgr
|
||||
var c = carrys.Find(x => x.location_code == loc);
|
||||
if (c != null)
|
||||
c.location_id = locs[loc].ToString();
|
||||
|
||||
}
|
||||
}
|
||||
carrys.ForEach(x =>
|
||||
|
||||
Reference in New Issue
Block a user