@ -68,8 +68,11 @@ namespace Khd.Core.Wcs.Wcs
//var createRawInWareTaskThread = new Thread(CreateRawInWareTaskLogic);
//createRawInWareTaskThread.Start();
//var createFiveProductTaskThread = new Thread(CreateFiveProductTaskLogic);
//createFiveProductTaskThread.Start();
var createFiveProductInTaskThread = new Thread ( CreateFiveProductInTaskLogic ) ;
createFiveProductInTaskThread . Start ( ) ;
var createFiveProductTaskThread = new Thread ( CreateFiveProductTaskLogic ) ;
createFiveProductTaskThread . Start ( ) ;
var createRawTaskThread = new Thread ( CreateRawTaskLogic ) ;
createRawTaskThread . Start ( ) ;
@ -81,6 +84,97 @@ namespace Khd.Core.Wcs.Wcs
LogManager . Info ( "出库任务监听启动成功" ) ;
}
private void CreateFiveProductInTaskLogic ( object? obj )
{
using var scope = _host . Services . CreateScope ( ) ;
using var dbContext = scope . ServiceProvider . GetRequiredService < DefaultDbContext > ( ) ;
BaseEquip agvEquip = StaticData . BaseEquip . First ( t = > t . objid = = 28 ) ;
BaseEquip endEquip = StaticData . BaseEquip . First ( t = > t . objid = = 30 ) ;
while ( true )
{
try
{
dbContext . ChangeTracker . Entries ( ) . ToList ( ) . ForEach ( e = > e . Reload ( ) ) ;
var wmsProductInstock = dbContext . WmsProductInstock
. Where ( t = > t . productType = = "2" )
. Where ( t = > t . auditStatus = = "1" )
. Where ( t = > t . warehouseId = = 521 )
. FirstOrDefault ( ) ;
if ( wmsProductInstock ! = null & & wmsProductInstock . executeStatus = = "0" )
{
var wmsBaseLocation = dbContext . WmsBaseLocation
. Where ( t = > t . warehouseId = = 521 )
. Where ( t = > t . activeFlag = = "1" )
. Where ( t = > t . instockFlag = = "0" )
. Where ( t = > t . outstockFlag = = "0" )
. Where ( t = > t . locationStatus = = "1" )
. Where ( t = > t . containerCode = = null | | t . containerCode = = "" ) . FirstOrDefault ( ) ;
if ( wmsBaseLocation ! = null )
{
var wcsTask = new WcsTask ( )
{
objid = StaticData . SnowId . NextId ( ) ,
serialNo = SystemData . GetSerialNo ( dbContext ) ,
taskType = 34 ,
startPointId = wmsBaseLocation . locationId ,
startPointNo = wmsBaseLocation . locationCode ,
endPointId = endEquip . objid ,
endPointNo = endEquip . equipNo ,
currPointId = wmsBaseLocation . locationId ,
currPointNo = wmsBaseLocation . locationCode ,
equipmentNo = agvEquip . equipNo ,
useFlag = 1 ,
qty = 1 ,
containerNo = wmsProductInstock . palletInfoCode ,
taskStatus = 0 ,
createBy = "WCS" ,
createTime = DateTime . Now ,
floorNo = 5 ,
fromFloorNo = 5 ,
isEmpty = "0" ,
masterId = wmsProductInstock . productId ,
orderId = wmsProductInstock . productInstockId ,
materialId = wmsProductInstock . productId ,
nextPointId = agvEquip . objid ,
nextPointNo = agvEquip . equipNo ,
} ;
WmsProductInstockDetail wmsProductInstockDetail = new WmsProductInstockDetail ( )
{
erpAmount = 0 ,
productId = wmsProductInstock . productId ,
executeStatus = "1" ,
productInstockDetailId = StaticData . SnowId . NextId ( ) ,
instockAmount = 1 ,
instockBy = "WCS" ,
instockDate = DateTime . Now ,
instockWay = "2" ,
locationCode = wmsBaseLocation . locationCode ,
planAmount = 1 ,
productBarcode = wmsProductInstock . productBatch ,
productBatch = wmsProductInstock . productBatch ,
productInstockId = wmsProductInstock . productInstockId ,
} ;
WcsTaskLog wcsTaskLog = CoreMapper . Map < WcsTaskLog > ( wcsTask ) ;
wmsProductInstock . executeStatus = "1" ;
wmsBaseLocation . instockFlag = "1" ;
wmsBaseLocation . locationStatus = "4" ;
dbContext . Add ( wmsProductInstock ) ;
dbContext . Update ( wmsProductInstock ) ;
dbContext . Update ( wmsBaseLocation ) ;
dbContext . Add ( wcsTask ) ;
dbContext . Add ( wcsTaskLog ) ;
dbContext . SaveChanges ( ) ;
}
}
}
catch ( Exception ex )
{
LogManager . Error ( ex ) ;
}
Thread . Sleep ( 1000 ) ;
}
}
/// <summary>
/// 创建去翻转机的任务
/// </summary>
@ -420,51 +514,52 @@ namespace Khd.Core.Wcs.Wcs
qty = Convert . ToInt32 ( needNumber ) ;
stock . updateDate = DateTime . Now ;
}
wcsTask = new WcsTask ( )
MesBasePalletInfo ? mesBasePalletInfo = dbContext . MesBasePalletInfo . FirstOrDefault ( t = > t . palletInfoCode = = location . containerCode ) ;
if ( mesBasePalletInfo ! = null )
{
objid = StaticData . SnowId . NextId ( ) ,
orderId = item . saleOrderId ,
taskType = 38 ,
containerNo = location . containerCode ,
createBy = "WCS" ,
createTime = DateTime . Now ,
taskStatus = 0 ,
materialId = item . productId ,
currPointId = location . locationId ,
currPointNo = location . locationCode ,
startPointId = location . locationId ,
startPointNo = location . locationCode ,
nextPointId = ctuEquip . objid ,
nextPointNo = ctuEquip . equipNo ,
endPointId = lineEquip . objid ,
endPointNo = lineEquip . equipNo ,
equipmentNo = ctuEquip . equipNo ,
useFlag = 1 ,
qty = qty
} ;
location . outstockFlag = "1" ;
location . locationStatus = "6" ;
location . updateBy = "WCS" ;
location . updateTime = DateTime . Now ;
MesBaseBarcodeInfo ? mesBaseBarcodeInfo = dbContext . MesBaseBarcodeInfo . Where ( t = > t . barcodeInfo = = stock . productBatch ) . FirstOrDefault ( ) ;
if ( mesBaseBarcodeInfo ! = null )
{
WmsProductOutstockDetail wmsProductOutstockDetail = new WmsProductOutstockDetail ( )
WmsProductOutstockDetail detail = new ( )
{
productOutstockDetailId = StaticData . SnowId . NextId ( ) ,
productOutstockId = item . productOutstockId ,
productId = item . productId ,
beginTime = DateTime . Now ,
confirmAmount = 0 ,
executeStatus = "1" ,
productOutstockId = item . productOutstockId ,
locationCode = location . locationCode ,
outstockAmount = qty ,
planAmount = item . applyQty ,
executeStatus = "1" ,
beginTime = DateTime . Now ,
warehouseId = item . warehouseId ,
productBatch = mesBaseBarcodeInfo . batchCode ,
productBarcode = mesBaseBarcodeInfo . barcodeInfo
erpAmount = 0 ,
confirmAmount = 0 ,
outstockAmount = 1 ,
planAmount = 1 ,
productBatch = item . productBatch ,
productOutstockDetailId = StaticData . SnowId . NextId ( ) ,
productBarcode = mesBasePalletInfo . materialBarcode
} ;
dbContext . Add ( wmsProductOutstockDetail ) ;
wcsTask = new WcsTask ( )
{
objid = StaticData . SnowId . NextId ( ) ,
orderId = item . productOutstockId ,
taskType = 38 ,
containerNo = location . containerCode ,
createBy = "WCS" ,
createTime = DateTime . Now ,
taskStatus = 0 ,
materialId = item . productId ,
currPointId = location . locationId ,
currPointNo = location . locationCode ,
startPointId = location . locationId ,
startPointNo = location . locationCode ,
nextPointId = ctuEquip . objid ,
nextPointNo = ctuEquip . equipNo ,
endPointId = lineEquip . objid ,
endPointNo = lineEquip . equipNo ,
equipmentNo = ctuEquip . equipNo ,
useFlag = 1 ,
qty = qty
} ;
location . outstockFlag = "1" ;
location . locationStatus = "6" ;
location . updateBy = "WCS" ;
location . updateTime = DateTime . Now ;
dbContext . Add ( detail ) ;
dbContext . Update ( location ) ;
dbContext . Add ( wcsTask ) ;
dbContext . Update ( stock ) ;
@ -475,7 +570,6 @@ namespace Khd.Core.Wcs.Wcs
}
}
}
if ( item . beginTime = = null )
{
item . beginTime = DateTime . Now ;
@ -648,7 +742,12 @@ namespace Khd.Core.Wcs.Wcs
planAmount = item . outstockAmount ,
warehouseId = item . warehouseId ,
materialBarcode = mesBaseBarcodeInfo . barcodeInfo ,
instockBatch = mesBaseBarcodeInfo . batchCode
instockBatch = mesBaseBarcodeInfo . batchCode ,
stackAmount = qty ,
outstockPerson = "WCS" ,
outstockTime = DateTime . Now ,
outstockWay = "2" ,
materialProductionDate = mesBaseBarcodeInfo . productionDate
} ;
dbContext . Add ( wmsProductOutstockDetail ) ;
location . outstockFlag = "1" ;
@ -769,21 +868,47 @@ namespace Khd.Core.Wcs.Wcs
useFlag = 0 ,
qty = qty
} ;
location . outstockFlag = "1" ;
location . locationStatus = "6" ;
location . updateBy = "WCS" ;
location . updateTime = DateTime . Now ;
wcsOutstockLock . qty + = 1 ;
wcsOutstockLock . boxStatus = 1 ;
dbContext . Update ( wcsOutstockLock ) ;
dbContext . Update ( location ) ;
dbContext . Add ( wcsTask ) ;
dbContext . Update ( stock ) ;
dbContext . SaveChanges ( ) ;
CreateSuccess = true ;
if ( qty > = needNumber )
MesBaseBarcodeInfo ? mesBaseBarcodeInfo = dbContext . MesBaseBarcodeInfo . Where ( t = > t . barcodeInfo = = stock . instockBatch ) . FirstOrDefault ( ) ;
if ( mesBaseBarcodeInfo ! = null )
{
break ;
WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail ( )
{
rawOutstockDetailId = StaticData . SnowId . NextId ( ) ,
rawOutstockId = item . rawOutstockId ,
materialId = item . materialId ,
createDate = DateTime . Now ,
createBy = "WCS" ,
taskCode = wcsTask . objid . ToString ( ) ,
executeStatus = "1" ,
locationCode = location . locationCode ,
outstockAmount = qty ,
planAmount = item . outstockAmount ,
warehouseId = item . warehouseId ,
materialBarcode = mesBaseBarcodeInfo . barcodeInfo ,
instockBatch = mesBaseBarcodeInfo . batchCode ,
stackAmount = qty ,
outstockPerson = "WCS" ,
outstockTime = DateTime . Now ,
outstockWay = "2" ,
materialProductionDate = mesBaseBarcodeInfo . productionDate
} ;
dbContext . Add ( wmsProductOutstockDetail ) ;
location . outstockFlag = "1" ;
location . locationStatus = "6" ;
location . updateBy = "WCS" ;
location . updateTime = DateTime . Now ;
wcsOutstockLock . qty + = 1 ;
wcsOutstockLock . boxStatus = 1 ;
dbContext . Update ( wcsOutstockLock ) ;
dbContext . Update ( location ) ;
dbContext . Add ( wcsTask ) ;
dbContext . Update ( stock ) ;
dbContext . SaveChanges ( ) ;
CreateSuccess = true ;
if ( qty > = needNumber )
{
break ;
}
}
}
}
@ -900,49 +1025,75 @@ namespace Khd.Core.Wcs.Wcs
qty = Convert . ToInt32 ( needNumber ) ;
stock . updateDate = DateTime . Now ;
}
wcsTask = new WcsTask ( )
MesBaseBarcodeInfo ? mesBaseBarcodeInfo = dbContext . MesBaseBarcodeInfo . Where ( t = > t . barcodeInfo = = stock . instockBatch ) . FirstOrDefault ( ) ;
if ( mesBaseBarcodeInfo ! = null )
{
objid = StaticData . SnowId . NextId ( ) ,
orderId = item . rawOutstockId ,
taskType = endEquip . equipType = = 12 ? 46 : 33 , //如果是12那么就是原材料到柜体验收区,如果是13那么就是原材料到背板安装区
containerNo = location . containerCode ,
createBy = "WCS" ,
createTime = DateTime . Now ,
taskStatus = 0 ,
materialId = item . materialId ,
currPointId = location . locationId ,
currPointNo = location . locationCode ,
startPointId = location . locationId ,
startPointNo = location . locationCode ,
nextPointId = bearAgvEquip . objid ,
nextPointNo = bearAgvEquip . equipNo ,
endPointId = lineEquip . objid ,
endPointNo = lineEquip . equipNo ,
equipmentNo = bearAgvEquip . equipNo ,
useFlag = 1 ,
qty = qty
} ;
location . outstockFlag = "1" ;
location . locationStatus = "6" ;
location . updateBy = "WCS" ;
location . updateTime = DateTime . Now ;
endEquip . emptyCount = 1 ;
dbContext . Update ( endEquip ) ;
dbContext . Update ( location ) ;
dbContext . Add ( wcsTask ) ;
dbContext . Update ( stock ) ;
dbContext . SaveChanges ( ) ;
if ( qty > = needNumber )
{
break ;
wcsTask = new WcsTask ( )
{
objid = StaticData . SnowId . NextId ( ) ,
orderId = item . rawOutstockId ,
taskType = endEquip . equipType = = 12 ? 46 : 33 , //如果是12那么就是原材料到柜体验收区,如果是13那么就是原材料到背板安装区
containerNo = location . containerCode ,
createBy = "WCS" ,
createTime = DateTime . Now ,
taskStatus = 0 ,
materialId = item . materialId ,
currPointId = location . locationId ,
currPointNo = location . locationCode ,
startPointId = location . locationId ,
startPointNo = location . locationCode ,
nextPointId = bearAgvEquip . objid ,
nextPointNo = bearAgvEquip . equipNo ,
endPointId = lineEquip . objid ,
endPointNo = lineEquip . equipNo ,
equipmentNo = bearAgvEquip . equipNo ,
useFlag = 1 ,
qty = qty
} ;
WmsRawOutstockDetail wmsProductOutstockDetail = new WmsRawOutstockDetail ( )
{
rawOutstockDetailId = StaticData . SnowId . NextId ( ) ,
rawOutstockId = item . rawOutstockId ,
materialId = item . materialId ,
createDate = DateTime . Now ,
createBy = "WCS" ,
taskCode = wcsTask . objid . ToString ( ) ,
executeStatus = "1" ,
locationCode = location . locationCode ,
outstockAmount = qty ,
planAmount = item . outstockAmount ,
warehouseId = item . warehouseId ,
materialBarcode = mesBaseBarcodeInfo . barcodeInfo ,
instockBatch = mesBaseBarcodeInfo . batchCode ,
stackAmount = qty ,
outstockPerson = "WCS" ,
outstockTime = DateTime . Now ,
outstockWay = "2" ,
materialProductionDate = mesBaseBarcodeInfo . productionDate
} ;
dbContext . Add ( wmsProductOutstockDetail ) ;
location . outstockFlag = "1" ;
location . locationStatus = "6" ;
location . updateBy = "WCS" ;
location . updateTime = DateTime . Now ;
endEquip . emptyCount = 1 ;
dbContext . Update ( endEquip ) ;
dbContext . Update ( location ) ;
dbContext . Add ( wcsTask ) ;
dbContext . Update ( stock ) ;
dbContext . SaveChanges ( ) ;
if ( qty > = needNumber )
{
break ;
}
}
if ( item . beginTime = = null )
{
item . beginTime = DateTime . Now ;
}
dbContext . Update ( item ) ;
dbContext . SaveChanges ( ) ;
}
if ( item . beginTime = = null )
{
item . beginTime = DateTime . Now ;
}
dbContext . Update ( item ) ;
dbContext . SaveChanges ( ) ;
}
}
}