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