mahao 10 months ago
parent
commit
6df2e1c08c
  1. 14
      src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs
  2. 143
      src/WmsWebApi.Application/StockMove/StockMoveService.cs

14
src/WmsWebApi.Application/ProductRecieve/ProductRecieveService.cs

@ -16,6 +16,7 @@ using WmsWebApi.Domain;
using WmsWebApi.EntityFrameworkCore; using WmsWebApi.EntityFrameworkCore;
using WmsWebApi.Jsons; using WmsWebApi.Jsons;
using WmsWebApi.Repositories; using WmsWebApi.Repositories;
using WmsWebApi.StockMove;
using WmsWebApi.Wms; using WmsWebApi.Wms;
using WmsWebApi.WMS; using WmsWebApi.WMS;
using WmsWebApi.WMS.IRepository; using WmsWebApi.WMS.IRepository;
@ -156,6 +157,9 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
_billList.Add(tbBill); _billList.Add(tbBill);
#endregion #endregion
var agvStoreLocation = await _taStoreLocationRepository.FirstOrDefaultAsync(p => p.LocCode == _configuration.GetConnectionString("AgvInLoc"));
string toErpLoc = agvStoreLocation?.ErpLocCode;
foreach (var item in _PRDto.items) foreach (var item in _PRDto.items)
{ {
//判断物料信息 //判断物料信息
@ -276,20 +280,20 @@ public class ProductRecieveService : ApplicationService, IProductRecieveService
FromLoc = "", FromLoc = "",
ToLoc = tbRecieve.ToLocCode, ToLoc = tbRecieve.ToLocCode,
FromErpLoc = "", FromErpLoc = "",
ToErpLoc = "", ToErpLoc = toErpLoc,
Qty = item.Qty, Qty = item.Qty,
State = 0, State = 0,
CreateOper = "AGV", CreateOper = "AGV",
CreateTime = DateTime.Now, CreateTime = DateTime.Now,
PutTime = DateTime.Now, PutTime = DateTime.Now,
CustId = "", CustId = "",
VendId = "", VendId = tbBill.AccountDate?.ToString("yyyyMMdd"),
PoUnit = "", PoUnit = item.Unit,
LocUnit = "", LocUnit = item.Unit,
ValidDate = DateTime.Now, ValidDate = DateTime.Now,
ErpBillNum = tbBill.BillNum, ErpBillNum = tbBill.BillNum,
ErpLineNum = 0, ErpLineNum = 0,
EqptCode = "", EqptCode = item.ShiftName,
EqptType = "B", EqptType = "B",
VendBatch = item.Batch, VendBatch = item.Batch,
SourceBillNum = tbBill.SourceBillNum, SourceBillNum = tbBill.SourceBillNum,

143
src/WmsWebApi.Application/StockMove/StockMoveService.cs

@ -114,7 +114,12 @@ public class StockMoveService : ApplicationService, IStockMoveService
result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message; result.MESSAGE = "Json格式不正确,详细信息:" + ex.Message;
return result; return result;
} }
if (_SSDto.BillType != "902" && _SSDto.BillType != "903")
{
result.TYPE = 'E';
result.MESSAGE = "非法请求";
return result;
}
WmsWebApiStockMoveDTO apiSSdto = new WmsWebApiStockMoveDTO() WmsWebApiStockMoveDTO apiSSdto = new WmsWebApiStockMoveDTO()
{ {
AccountDate = _SSDto.AccountDate, AccountDate = _SSDto.AccountDate,
@ -166,6 +171,29 @@ public class StockMoveService : ApplicationService, IStockMoveService
#endregion #endregion
var agvloc = _configuration.GetConnectionString("AgvInLoc"); var agvloc = _configuration.GetConnectionString("AgvInLoc");
var wmsloc = _configuration.GetConnectionString("AgvOutLoc"); var wmsloc = _configuration.GetConnectionString("AgvOutLoc");
var agvStoreLocation = await _taStoreLocationRepository.FirstOrDefaultAsync(p => p.LocCode == agvloc);
var wmsStoreLocation = await _taStoreLocationRepository.FirstOrDefaultAsync(p => p.LocCode == wmsloc);
string fromErpLoc = string.Empty;
string toErpLoc = string.Empty;
switch (_SSDto.BillType)
{
case "902":
//WMS-AGV
fromErpLoc = wmsStoreLocation?.ErpLocCode;
toErpLoc = agvStoreLocation?.ErpLocCode;
break;
case "903":
//AGV-WMS
fromErpLoc = agvStoreLocation?.ErpLocCode;
toErpLoc = wmsStoreLocation?.ErpLocCode;
break;
default:
break;
}
foreach (var item in _SSDto.items) foreach (var item in _SSDto.items)
{ {
//判断物料信息 //判断物料信息
@ -230,12 +258,12 @@ public class StockMoveService : ApplicationService, IStockMoveService
BarCode = _barcode, BarCode = _barcode,
PartCode = item.PartCode, PartCode = item.PartCode,
Batch = item.Batch, Batch = item.Batch,
EqptCode = "", EqptCode = item.ShiftName,
//LocCode = part.DefaultReceiveLocCode, //LocCode = part.DefaultReceiveLocCode,
AreaCode = partLoc.AreaCode,//"FG", AreaCode = partLoc.AreaCode,//"FG",
Qty = item.Qty, Qty = item.Qty,
UpdateQty = item.Qty, UpdateQty = item.Qty,
VendId = "", VendId = tbBill.AccountDate?.ToString("yyyyMMdd"),
ProduceDate = DateTime.Now, ProduceDate = DateTime.Now,
OverdueDate = (DateTime.Now).AddDays(part.ValidityDays), OverdueDate = (DateTime.Now).AddDays(part.ValidityDays),
ReceiveDate = DateTime.Now, ReceiveDate = DateTime.Now,
@ -244,14 +272,17 @@ public class StockMoveService : ApplicationService, IStockMoveService
State = EnumStockState., State = EnumStockState.,
Amount = 0, Amount = 0,
VinState = 0, VinState = 0,
}; };
TS_STOCK_DETAIL tsStockIn = JsonConvert.DeserializeObject<TS_STOCK_DETAIL>(JsonConvert.SerializeObject(tsStock));
var stockagv = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode var stockagv = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode
&& p.LocCode == agvloc && p.LocCode == agvloc
&& p.State == EnumStockState.); && p.State == EnumStockState.);
var stockwms = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode var stockwms = await _tsStockDetailRepository.FirstOrDefaultAsync(p => p.BarCode == _barcode
&& p.LocCode == wmsloc && p.LocCode == wmsloc
&& p.State == EnumStockState.); && p.State == EnumStockState.);
if (_SSDto.BillType == "902")//AGV库位增加库存,WMS库位减少库存 if (_SSDto.BillType == "902")//AGV库位增加库存,WMS库位减少库存
{ {
#region 出库 #region 出库
@ -264,6 +295,8 @@ public class StockMoveService : ApplicationService, IStockMoveService
} }
else if (stockwms.Qty - item.Qty == 0) else if (stockwms.Qty - item.Qty == 0)
{ {
tsStock.Qty = 0 - tsStock.Qty;
tsStock.UpdateQty = tsStock.Qty;
_stockDelList.Add(tsStock); _stockDelList.Add(tsStock);
} }
else else
@ -274,14 +307,16 @@ public class StockMoveService : ApplicationService, IStockMoveService
} }
#endregion #endregion
#region 入库 #region 入库
tsStock.LocCode = agvloc; tsStockIn.LocCode = agvloc;
tsStockIn.Qty = -tsStock.Qty;
tsStockIn.UpdateQty = -tsStock.UpdateQty;
if (stockagv == null) if (stockagv == null)
{ {
_stockList.Add(tsStock); _stockList.Add(tsStockIn);
} }
else else
{ {
_stockUpdateList.Add(tsStock); _stockUpdateList.Add(tsStockIn);
} }
#endregion #endregion
} }
@ -297,6 +332,8 @@ public class StockMoveService : ApplicationService, IStockMoveService
} }
else if (stockagv.Qty - item.Qty == 0) else if (stockagv.Qty - item.Qty == 0)
{ {
tsStock.Qty = 0 - tsStock.Qty;
tsStock.UpdateQty = tsStock.Qty;
_stockDelList.Add(tsStock); _stockDelList.Add(tsStock);
} }
else else
@ -307,14 +344,16 @@ public class StockMoveService : ApplicationService, IStockMoveService
} }
#endregion #endregion
#region 入库 #region 入库
tsStock.LocCode = wmsloc; tsStockIn.LocCode = wmsloc;
tsStockIn.Qty = -tsStock.Qty;
tsStockIn.UpdateQty = -tsStock.UpdateQty;
if (stockwms == null) if (stockwms == null)
{ {
_stockList.Add(tsStock); _stockList.Add(tsStockIn);
} }
else else
{ {
_stockUpdateList.Add(tsStock); _stockUpdateList.Add(tsStockIn);
} }
#endregion #endregion
} }
@ -400,41 +439,41 @@ public class StockMoveService : ApplicationService, IStockMoveService
} }
#endregion #endregion
//插入TS_UNI_API ////插入TS_UNI_API
listTSUNIAPI.Add(new TS_UNI_API() //listTSUNIAPI.Add(new TS_UNI_API()
{ //{
InterfaceType = "BackFlush", // InterfaceType = "BackFlush",
TableName = "xxwms_bk_mstr", // TableName = "xxwms_bk_mstr",
BillType = 201, // BillType = 302,
SubBillType = tbBill.SubBillType, // SubBillType = tbBill.SubBillType,
BillNum = tbBill.BillNum, // BillNum = tbBill.BillNum,
PartCode = item.PartCode, // PartCode = item.PartCode,
Batch = item.Batch, // Batch = item.Batch,
FromLoc = tbStockMove.FromLocCode, // FromLoc = tbStockMove.FromLocCode,
ToLoc = tbStockMove.ToLocCode, // ToLoc = tbStockMove.ToLocCode,
FromErpLoc = "", // FromErpLoc = fromErpLoc,
ToErpLoc = "", // ToErpLoc = toErpLoc,
Qty = item.Qty, // Qty = item.Qty,
State = 0, // State = 0,
CreateOper = "AGV", // CreateOper = "AGV",
CreateTime = DateTime.Now, // CreateTime = DateTime.Now,
PutTime = DateTime.Now, // PutTime = DateTime.Now,
CustId = "", // CustId = "",
VendId = "", // VendId = tbBill.AccountDate?.ToString("yyyyMMdd"),
PoUnit = "", // PoUnit = item.Unit,
LocUnit = "", // LocUnit = item.Unit,
ValidDate = DateTime.Now, // ValidDate = DateTime.Now,
ErpBillNum = tbBill.BillNum, // ErpBillNum = tbBill.BillNum,
ErpLineNum = 0, // ErpLineNum = 0,
EqptCode = "", // EqptCode = item.ShiftName,
EqptType = "B", // EqptType = "B",
VendBatch = item.Batch, // VendBatch = item.Batch,
SourceBillNum = tbBill.SourceBillNum, // SourceBillNum = tbBill.SourceBillNum,
ProcessId = 0, // ProcessId = 0,
GoodQty = item.Qty, // GoodQty = item.Qty,
ScrapQty = 0, // ScrapQty = 0,
InvalidQty = 0 // InvalidQty = 0
}); //});
} }
if (!bErr) if (!bErr)
{ {
@ -449,10 +488,10 @@ public class StockMoveService : ApplicationService, IStockMoveService
await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList); await _tmPgWmsUpdate.UpdateTsStock(_stockUpdateList);
if (_stockDelList != null && _stockDelList.Count() > 0) if (_stockDelList != null && _stockDelList.Count() > 0)
await _tmPgWmsUpdate.DeleteTsStock(_stockDelList); await _tmPgWmsUpdate.DeleteTsStock(_stockDelList);
if (listTSUNIAPI != null && listTSUNIAPI.Count() > 0) //if (listTSUNIAPI != null && listTSUNIAPI.Count() > 0)
{ //{
await _tSUNIAPIRepository.InsertManyAsync(listTSUNIAPI); // await _tSUNIAPIRepository.InsertManyAsync(listTSUNIAPI);
} //}
await _tlTransactionRepository.AddAsync(_transList); await _tlTransactionRepository.AddAsync(_transList);
} }
await CurrentUnitOfWork.SaveChangesAsync(); await CurrentUnitOfWork.SaveChangesAsync();
@ -471,9 +510,9 @@ public class StockMoveService : ApplicationService, IStockMoveService
throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex); throw new Exception($"接口异常,请稍后重试:{ex.GetBaseException().Message}", ex);
} }
finally finally
{ {
if (IsRequestRetry == false) if (IsRequestRetry == false)
{ {
Logger.LogInformation(apiSSdto.JSON); Logger.LogInformation(apiSSdto.JSON);
@ -481,7 +520,7 @@ public class StockMoveService : ApplicationService, IStockMoveService
{ {
result.TYPE = 'E'; result.TYPE = 'E';
} }
else else
{ {
result.MESSAGE = "成功"; result.MESSAGE = "成功";
} }

Loading…
Cancel
Save