|
@ -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(); |
|
|