@ -160,12 +160,13 @@ namespace SlnMesnac.WCS.WCS
bool anyTonerPallet = HasAnyTonerInLine ( ) ;
if ( returnJudgeSignal & & busy2Flag = = 0 & & ( Amount < 3 | | anyTonerPallet ) )
{
string rfid = ReadEpcStrByRfidKey ( "2#Transplant" ) ;
if ( string . IsNullOrEmpty ( rfid ) )
int type = 0 ;
string rfid = ReadEpcStrByRfidKeyAndReturnType ( "2#Transplant" , out type ) ;
if ( type = = 0 | | type = = 2 )
{ //二次读取
rfid = ReadEpcStrByRfidKey ( "2#Transplant" ) ;
rfid = ReadEpcStrByRfidKey AndReturnType ( "2#Transplant" , out type ) ;
}
if ( ! string . IsNullOrEmpty ( rfid ) )
if ( type = = 1 ) //读到1个标签
{
int hoistFloor = workShop2Plc . readInt16ByAddress ( StaticData . GetPlcAddress ( "2#提升机当前层" ) ) ;
if ( Amount < 3 & & hoistFloor = = 1 ) //如果提升机正好在1楼
@ -186,7 +187,9 @@ namespace SlnMesnac.WCS.WCS
{
//注意: plc上旋转移栽必须锁住线体状态才可以, 2#接驳位如果有满料, 那么通知plc信号, plc在连廊不再把箱体放到旋转移栽上
//调度系统结合上面缓存链条线库存, 如果上面低于3, 那么空箱可以上来缓存线
workShop2Plc . writeInt16ByAddress ( StaticData . GetPlcAddress ( "2#缓存空箱线体状态" ) , 1 ) ;
workShop2Plc . writeInt16ByAddress ( StaticData . GetPlcAddress ( "2#线体忙碌状态" ) , 1 ) ;
workShop2Plc . writeInt16ByAddress ( "DB100.DBW40" , 1 ) ;
bool createResult = CreateDeliverTonerTask ( rfid ) ;
if ( createResult )
{
@ -232,14 +235,25 @@ namespace SlnMesnac.WCS.WCS
}
}
}
else
else if ( type = = 0 ) //读到0个标签
{
//RFID 未读到报警( 2#移栽平台处)
workShop2Plc . writeBoolByAddress ( "DB100.DBX42.1" , true ) ;
_logger . Error ( "RFID 未读取报警( 2#移栽平台处)" ) ;
workShop2Plc . writeBoolByAddress ( StaticData . GetPlcAddress ( "2#料箱运回RFID读取" ) , false ) ;
//没读到2空箱转运
// _logger.Info($"1#移栽====没读到,空箱转运");
//workShop2Plc.writeInt16ByAddress(StaticData.GetPlcAddress("2#线体忙碌状态"), 1);
//workShop2Plc.writeInt16ByAddress(StaticData.GetPlcAddress("2#移栽平台任务"), 2);
//workShop2Plc.writeBoolByAddress(StaticData.GetPlcAddress("2#料箱运回RFID读取"), false);
}
else if ( type = = 2 ) //串读
{
//RFID 串读报警( 2#移栽平台处)
workShop2Plc . writeBoolByAddress ( "DB100.DBX42.0" , true ) ;
_logger . Error ( "RFID 串读报警( 2#移栽平台处)" ) ;
workShop2Plc . writeBoolByAddress ( StaticData . GetPlcAddress ( "2#料箱运回RFID读取" ) , false ) ;
}
}
}
@ -254,13 +268,13 @@ namespace SlnMesnac.WCS.WCS
if ( returnJudgeSignal & & busy1Flag = = 0 )
{
//test
string rfid = ReadEpcStrByRfidKey ( "1#MetrologyRoom" ) ;
int type = 0 ;
string rfid = ReadEpcStrByRfidKey AndReturnType ( "1#MetrologyRoom" , out type ) ;
if ( string . IsNullOrEmpty ( rfid ) )
{
rfid = ReadEpcStrByRfidKey ( "1#MetrologyRoom" ) ;
rfid = ReadEpcStrByRfidKey AndReturnType ( "1#MetrologyRoom" , out type ) ;
}
if ( ! string . IsNullOrEmpty ( rfid ) )
if ( type = = 1 )
{
// 判断有无料, 如果没有料, wcs下发空箱旋转信号, 有料, 通知plc上提升机计量室
WmsPalletInfo ? wmsPalletInfo = sqlSugarClient . Queryable < WmsPalletInfo > ( ) . First ( it = > it . PalletInfoCode = = rfid ) ;
@ -286,14 +300,26 @@ namespace SlnMesnac.WCS.WCS
workShop2Plc . writeBoolByAddress ( StaticData . GetPlcAddress ( "2#料箱运进计量室RFID读取" ) , false ) ;
}
}
else
else if ( type = = 0 )
{
//RFID 未读到报警( 1#移栽平台处)
workShop2Plc . writeBoolByAddress ( "DB100.DBX42.3" , true ) ;
_logger . Error ( "RFID 未读取报警( 1#移栽平台处)" ) ;
workShop2Plc . writeBoolByAddress ( StaticData . GetPlcAddress ( "2#料箱运进计量室RFID读取" ) , false ) ;
//没读到,当成空箱子旋转一圈
//1#移栽平台任务( 1上提升机,2空箱转运)
// _logger.Info($"1#移栽====没读到,空箱转运");
//workShop2Plc.writeInt16ByAddress(StaticData.GetPlcAddress("1#移栽平台任务"), 2);
//workShop2Plc.writeBoolByAddress(StaticData.GetPlcAddress("2#料箱运进计量室RFID读取"), false);
}
else if ( type = = 2 ) //串读
{
//RFID 串读报警( 1#移栽平台处)
workShop2Plc . writeBoolByAddress ( "DB100.DBX42.2" , true ) ;
_logger . Error ( "RFID 串读报警( 1#移栽平台处)" ) ;
workShop2Plc . writeBoolByAddress ( StaticData . GetPlcAddress ( "2#料箱运进计量室RFID读取" ) , false ) ;
}
}
}
@ -377,24 +403,24 @@ namespace SlnMesnac.WCS.WCS
WmsBaseLocation ? startLocation = null ;
//todo:优化点:为避免送料时尽可能少的移库任务,因此在这里可以先读取下一个料包要去的机台号,提前调度这里的空箱
string nextGoMachineCode = workShop3Plc . readInt16ByAddress ( StaticData . GetPlcAddress ( "3#实时机台号" ) ) . ToString ( ) ;
bool hasAny = StaticData . WmsMachineInfos . Any ( x = > x . MachineCode = = nextGoMachineCode & & x . WorkshopId = = 3 ) ;
if ( hasAny )
{
int machineId = StaticData . WmsMachineInfos . First ( x = > x . MachineCode = = nextGoMachineCode ) . MachineId ;
if ( machineId > = 12 & & machineId < = 16 )
{
//12 - 16号机台都送往12号机台
machineId = 12 ;
}
//判断该机台有无空料箱,优先补充
string sql = $"SELECT wbl.* FROM wms_base_location wbl join wms_pallet_info wpi on wbl.container_code = wpi.pallet_info_code where wbl.container_code is not null and wbl.container_code!='' and wbl.location_status=0 and wbl.machineid ={machineId} and wpi.amount=0" ;
List < WmsBaseLocation > startLocations = sqlSugarClient . Ado . SqlQuery < WmsBaseLocation > ( sql ) . OrderByDescending ( x = > x . MachineId ) . ToList ( ) ;
if ( startLocations . Count > 0 )
{
startLocation = startLocations [ 0 ] ;
}
}
//string nextGoMachineCode = workShop3Plc.readInt16ByAddress(StaticData.GetPlcAddress("3#实时机台号")).ToString() ;
//bool hasAny = StaticData.WmsMachineInfos.Any(x => x.MachineCode == nextGoMachineCode && x.WorkshopId == 3) ;
//if (hasAny )
// {
// int machineId = StaticData.WmsMachineInfos.First(x => x.MachineCode == nextGoMachineCode).MachineId;
// if (machineId >= 12 && machineId <= 16)
// {
// //12 - 16号机台都送往12号机台
// machineId = 12;
// }
// //判断该机台有无空料箱,优先补充
// string sql = $"SELECT wbl.* FROM wms_base_location wbl join wms_pallet_info wpi on wbl.container_code = wpi.pallet_info_code where wbl.container_code is not null and wbl.container_code!='' and wbl.location_status=0 and wbl.machineid ={machineId} and wpi.amount=0";
// List<WmsBaseLocation> startLocations = sqlSugarClient.Ado.SqlQuery<WmsBaseLocation>(sql).OrderByDescending(x => x.MachineId).ToList();
// if (startLocations.Count > 0)
// {
// startLocation = startLocations[0];
// }
// }
//1-12机台, 优先12
if ( startLocation = = null )
{
@ -480,6 +506,18 @@ namespace SlnMesnac.WCS.WCS
_logger . Info ( $"机台:{machineCode}没有可用空库位,无法配送" ) ;
return ;
}
#region 二次核查确认目标库位是否有托盘
bool hasPallet = sqlSugarClient . Queryable < WmsBaseLocation > ( ) . Any ( x = > x . LocationCode = = targetLocation . LocationCode & & string . IsNullOrEmpty ( x . ContainerCode ) ) ;
if ( ! hasPallet )
{
_logger . Info ( $"库位:{targetLocation.LocationCode}有托盘暂不处理" ) ;
return ;
}
#endregion 二次核查确认目标库位是否有托盘
WcsBaseEquip startEquip = sqlSugarClient . Queryable < WcsBaseEquip > ( ) . First ( it = > it . EquipNo = = "3DeliverBigGoodsStartPoint" ) ;
WmsPalletInfo wmsPalletInfo = sqlSugarClient . Queryable < WmsPalletInfo > ( ) . First ( it = > it . PalletInfoCode = = rfid ) ;
WcsTask task = new WcsTask ( ) ;
@ -948,6 +986,19 @@ namespace SlnMesnac.WCS.WCS
return null ;
// todo推送预警 // 目标机台没有空库位,没有可移库的空箱,等待
}
#region 如果有补空箱任务,并且起点是要送料机台的库位,就不再生成移库任务
//目标机台的两个库位编号
List < string > locationCodes = AllWmsBaseLocationList . Where ( x = > x . MachineId = = machineId ) . Select ( x = > x . LocationCode ) . ToList ( ) ;
bool hasTask = sqlSugarClient . Queryable < WcsTask > ( ) . Any ( x = > x . TaskType = = StaticTaskType . SupplyEmptyPalletTask & & locationCodes . Contains ( x . CurrPointNo ) ) ;
if ( hasTask )
{
return null ;
}
#endregion 如果有补空箱任务,并且起点是要送料机台的库位,就不再生成移库任务
//需要生成从该库位到其他机台的移库任务,找寻移库终点库位
moveEndLocation = AllWmsBaseLocationList . FirstOrDefault ( x = > x . LocationId ! = moveStartLocation . LocationId & & x . LocationStatus = = 0 & & string . IsNullOrEmpty ( x . ContainerCode ) ) ;
if ( moveEndLocation = = null )