131 lines
4.8 KiB
C#
Executable File
131 lines
4.8 KiB
C#
Executable File
using System;
|
|
using System.Collections;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Opsoft.Data;
|
|
using Opsoft.NetCore.O3App.Domain;
|
|
using Opsoft.NetCore.O3App.Domain.Interface;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.WMS.IRepositories;
|
|
using Opsoft.NetCore.O3App.Domain.UnitOfWork.WMS.Model;
|
|
using Opsoft.NetCore.O3App.Shared;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Threading.Tasks;
|
|
using Exception = System.Exception;
|
|
|
|
namespace Opsoft.NetCore.O3App.Repositories.WMS
|
|
{
|
|
[MapTo(typeof(IPickMtrlRepository), ServiceLifetime.Transient)]
|
|
public class PickMtrlRepository : RepositoryBase<BaseEntity>, IPickMtrlRepository
|
|
{
|
|
public async Task<List<BarcodeCheckInfo>> GetBarcodeCheckInfoAsync(string barcode)
|
|
{
|
|
try
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
var sqlStr = $@"SELECT * FROM T_BD_BARCODERS
|
|
WHERE FBARCODE ='{barcode}'";
|
|
return await dbContext.Database.SqlQueryAsync<BarcodeCheckInfo>(sqlStr);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public async Task<List<SOURCEBILLINFO>> GetSourceBillDataAsync(string sqlStr)
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
return await dbContext.Database.SqlQueryAsync<SOURCEBILLINFO>(sqlStr);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public async Task<string> CreateBillNo(string strJson, int billType)
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
switch (billType)
|
|
{
|
|
case 1:
|
|
return
|
|
CreateBilllNO(dbContext, strJson, "PRD_PICKMTRL", "T_PRD_PICKMTRL", "FBILLNO", null, null);
|
|
case 2:
|
|
return
|
|
CreateBilllNO(dbContext, strJson, "PRD_RETURNMTRL", "T_PRD_RETURNMTRL", "FBILLNO", null, null);
|
|
}
|
|
|
|
return "";
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public async Task<Hashtable> GetSystemParameters(string key)
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
return dbContext.PBValue(key);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public decimal GetQty2(string materialId, string unitFrom, string unitTo, decimal qty)
|
|
{
|
|
using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
return GetMaterQty2(dbContext, materialId, unitFrom, unitTo, qty);
|
|
}
|
|
|
|
public async Task<int> ExecuteTransactionAsync(List<string> sqlStrList)
|
|
{
|
|
await using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
var count = 0;
|
|
await dbContext.Database.BeginTransactionAsync().ConfigureAwait(false);
|
|
foreach (var sql in sqlStrList)
|
|
{
|
|
count += await dbContext.Database.SqlNonQueryAsync(sql);
|
|
}
|
|
await dbContext.Database.CommitTransactionAsync().ConfigureAwait(false);
|
|
return count;
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
await dbContext.Database.RollbackTransactionAsync().ConfigureAwait(false);
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
|
|
public string GetUpdateInventoryQtySqlStr(
|
|
string orgID,
|
|
List<BarCodeMsg<BD_BARCODERS2>> inputMaterialList,
|
|
bool isPlus,
|
|
ref List<string> exeSqlStrList)
|
|
{
|
|
using APPServerContext dbContext = new APPServerContext(LoginInfo.DBAias, LoginInfo.UserID);
|
|
try
|
|
{
|
|
//操作库存
|
|
return APPWmsCommonFunc.CalculateInventory(dbContext, orgID, inputMaterialList, isPlus, ref exeSqlStrList);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
throw new O3AppException(e.Message);
|
|
}
|
|
}
|
|
}
|
|
}
|