1.去掉编译条件
2.重写业务导入功能
This commit is contained in:
@@ -39,7 +39,7 @@ namespace Tnb.WarehouseMgr
|
||||
private readonly IRunService _runService;
|
||||
private readonly IVisualDevService _visualDevService;
|
||||
private readonly IUserManager _userManager;
|
||||
public WmsCarryLedgerService(ISqlSugarRepository<WmsCarryH> repository, IRunService runService, IVisualDevService visualDevService,IUserManager userManager)
|
||||
public WmsCarryLedgerService(ISqlSugarRepository<WmsCarryH> repository, IRunService runService, IVisualDevService visualDevService, IUserManager userManager)
|
||||
{
|
||||
_db = repository.AsSugarClient();
|
||||
_runService = runService;
|
||||
@@ -58,42 +58,36 @@ namespace Tnb.WarehouseMgr
|
||||
int row = 0;
|
||||
try
|
||||
{
|
||||
//例1 获取所有表
|
||||
|
||||
List<Dictionary<string, object>> dics = await ImportExcelToMemory(file);
|
||||
List<WmsCarryH> carrys = new List<WmsCarryH>();
|
||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
|
||||
List<string> locCodes = new();
|
||||
List<string> cCodes = new();
|
||||
WmsCarryH carryH = new WmsCarryH();
|
||||
if (carryStdDic?.Count > 0)
|
||||
|
||||
string carryStdId = string.Empty;
|
||||
foreach (var d in dics)
|
||||
{
|
||||
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;
|
||||
locCodes.Add(d["location_code"]?.ToString() ?? string.Empty);
|
||||
carryH = d.Adapt<WmsCarryH>();
|
||||
carrys.Add(carryH);
|
||||
}
|
||||
if (!locCodes.IsNullOrEmpty())
|
||||
{
|
||||
var locs = await _db.Queryable<BasLocation>().Where(it => locCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
||||
foreach (var loc in locCodes)
|
||||
{
|
||||
var c = carrys.Find(x => x.location_code == loc);
|
||||
if (c != null)
|
||||
c.location_id = locs[loc].ToString();
|
||||
}
|
||||
}
|
||||
var cCode = d["carrystd_id"].ToString() ?? string.Empty;
|
||||
if (cCode == string.Empty) throw new AppFriendlyException($"第{dics.IndexOf(d) + 1}行数据有误", 500);
|
||||
locCodes.Add(d["location_code"]?.ToString() ?? string.Empty);
|
||||
cCodes.Add(cCode);
|
||||
carryH = d.Adapt<WmsCarryH>();
|
||||
carrys.Add(carryH);
|
||||
}
|
||||
if (!locCodes.IsNullOrEmpty())
|
||||
{
|
||||
var carryStdDic = await _db.Queryable<WmsCarrystd>().Where(it=>cCodes.Contains(it.carrystd_code)).ToDictionaryAsync(x => x.carrystd_code, x => x.id);
|
||||
var locs = await _db.Queryable<BasLocation>().Where(it => locCodes.Contains(it.location_code)).ToDictionaryAsync(x => x.location_code, x => x.id);
|
||||
carrys.ForEach(x =>
|
||||
{
|
||||
x.id = SnowflakeIdHelper.NextId();
|
||||
x.org_id = _userManager.User.OrganizeId;
|
||||
x.status = 1;
|
||||
x.is_lock = 0;
|
||||
x.carrystd_id = carryStdDic[x.carrystd_id].ToString()!;
|
||||
x.carry_status = ((int)EnumCarryStatus.空闲).ToString();
|
||||
x.location_id = locs[x.location_code].ToString();
|
||||
x.out_status = ((int)EnumOutStatus.正常).ToString();
|
||||
x.is_check = 1;
|
||||
x.create_id = _userManager.UserId;
|
||||
|
||||
Reference in New Issue
Block a user