@ -152,7 +152,7 @@ public class KukaJoinThread implements ApplicationRunner {
public String getBoxId ( String sapMaterial ) {
public String getBoxId ( String sapMaterial ) {
Integer todayBoxNum = service . getTodayBoxNum ( ) ;
Integer todayBoxNum = service . getTodayBoxNum ( ) + 1 ;
String nowTime = DateUtil . format ( new Date ( ) , " yyMMdd " ) ;
String nowTime = DateUtil . format ( new Date ( ) , " yyMMdd " ) ;
todayBoxNum + = 500 ;
todayBoxNum + = 500 ;
@ -160,6 +160,15 @@ public class KukaJoinThread implements ApplicationRunner {
return res ;
return res ;
}
}
public String getErrorBoxId ( String sapMaterial ) {
String nowTime = DateUtil . format ( new Date ( ) , " yyMMdd " ) ;
String mixBoxError = " 001 " ;
String res = " Err " + sapMaterial + nowTime + mixBoxError ;
return res ;
}
public String removeKG ( String str ) {
public String removeKG ( String str ) {
return str . substring ( 0 , 17 ) ;
return str . substring ( 0 , 17 ) ;
}
}
@ -174,240 +183,270 @@ public class KukaJoinThread implements ApplicationRunner {
return f1 . format ( a ) ;
return f1 . format ( a ) ;
}
}
/ / return true 出现混档了 , return false 没有出现混档
private boolean isMixLevel ( String [ ] subIds ) {
String correctLevel = substrateServiceBiz . getBySubId ( subIds [ 0 ] ) . getPowerLevel ( ) ;
String errMsg = " 以下基板ID出现混档: " ;
boolean res = false ;
for ( int i = 1 ; i < subIds . length ; i + + ) {
String powerLevel = substrateServiceBiz . getBySubId ( subIds [ i ] ) . getPowerLevel ( ) ;
if ( ! powerLevel . equals ( correctLevel ) ) {
errMsg + = " 基板ID: " + subIds [ i ] + " 档位: " + powerLevel + " , " ;
res = true ;
}
}
if ( res ) {
logger . error ( errMsg ) ;
}
return res ;
}
@Override
@Override
public void run ( ApplicationArguments args ) throws Exception {
public void run ( ApplicationArguments args ) throws Exception {
/ / kukaStep1 . scheduleAtFixedRate ( new Runnable ( ) {
kukaStep1 . scheduleAtFixedRate ( new Runnable ( ) {
/ / @Override
@Override
/ / public void run ( ) {
public void run ( ) {
/ / try {
try {
/ /
/ / / / 调度开始
/ / 调度开始
/ / / / logger . info ( " " ) ;
/ / logger . info ( " " ) ;
/ / / / logger . info ( " ================= 现在开始执行 过程一 任务 ================== " ) ;
/ / logger . info ( " ================= 现在开始执行 过程一 任务 ================== " ) ;
/ / Integer subArrived = waitingForTarget ( Step1Plc2MesVar . SubArrivedToMes , true ) ;
Integer subArrived = waitingForTarget ( Step1Plc2MesVar . SubArrivedToMes , true ) ;
/ / if ( subArrived ! = 1 ) {
if ( subArrived ! = 1 ) {
/ / logger . info ( " 标签打印Event--- 失败 " + " --- " + " MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败 " ) ;
logger . info ( " 标签打印Event--- 失败 " + " --- " + " MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败 " ) ;
/ / }
}
/ /
/ / / / 一 . 从plc 中获取 subId 和 lineNum
/ / 一 . 从plc 中获取 subId 和 lineNum
/ / String subId = ( String ) read ( S7Client . S7_KUKA , Step1Plc2MesVar . SubIdToMes ) ;
String subId = ( String ) read ( S7Client . S7_KUKA , Step1Plc2MesVar . SubIdToMes ) ;
/ / Integer lineNum = ( Integer ) read ( S7Client . S7_KUKA , Step1Plc2MesVar . LineNum ) ;
Integer lineNum = ( Integer ) read ( S7Client . S7_KUKA , Step1Plc2MesVar . LineNum ) ;
/ / / / 把基板ID字符串的空格去掉 , 因为plc中设置的20位 , 但实际基板ID就是17位 , 因为带空格去数据库查询 有问题的 。
/ / 把基板ID字符串的空格去掉 , 因为plc中设置的20位 , 但实际基板ID就是17位 , 因为带空格去数据库查询 有问题的 。
/ / subId = removeKG ( subId ) ;
subId = removeKG ( subId ) ;
/ /
/ / / / 二 . MES 业务
/ / 二 . MES 业务
/ / / / = = = = = = = = = = = = = = = MES 业务 开始 = = = = = = = = = = = = = = = = =
/ / = = = = = = = = = = = = = = = MES 业务 开始 = = = = = = = = = = = = = = = = =
/ / / / 1 . 从comline数据库中获取 实际pmpp
/ / 1 . 从comline数据库中获取 实际pmpp
/ / float pmppBySubId = service . getPMPPBySubId ( subId ) ;
float pmppActual = service . getPMPPBySubId ( subId ) ;
/ / / / 2 . 匹配和计算补偿功率
/ / 2 . 匹配和计算补偿功率
/ / float actualPMPP = compensationPowerServiceBiz . calculCompensationPMPP ( pmppBySubId , lineNum ) ;
float pmppCompensation = compensationPowerServiceBiz . calculCompensationPMPP ( pmppActual , lineNum ) ;
/ / / / 3 . 依据补偿功率 , 获取工艺参数 , 并且把这些工艺参数传给kuka
/ / 3 . 依据补偿功率 , 获取工艺参数 , 并且把这些工艺参数传给kuka
/ / WoPowerLevel argByPMPP = levelServiceBiz . getArgByPMPP ( actualPMPP , lineNum ) ;
WoPowerLevel argByPMPP = levelServiceBiz . getArgByPMPP ( pmppCompensation , lineNum ) ;
/ / write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Pnom , Integer . valueOf ( argByPMPP . getPowerClass ( ) ) ) ;
write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Pnom , Integer . valueOf ( argByPMPP . getPowerClass ( ) ) ) ;
/ / write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Voc , argByPMPP . getLableVoc ( ) ) ;
write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Voc , argByPMPP . getLableVoc ( ) ) ;
/ / write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Isc , argByPMPP . getLableIsc ( ) ) ;
write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Isc , argByPMPP . getLableIsc ( ) ) ;
/ / write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Vmpp , argByPMPP . getLableVmpp ( ) ) ;
write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Vmpp , argByPMPP . getLableVmpp ( ) ) ;
/ / write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Impp , argByPMPP . getLableImpp ( ) ) ;
write ( S7Client . S7_KUKA , Step1Mes2PlcVar . dLable_Impp , argByPMPP . getLableImpp ( ) ) ;
/ / logger . info ( " 标签打印Event--- 采集到 基板ID: " + subId + " , 线边号: " + lineNum + " , 从camline 获取到实际pmpp" + pmppBySubId + " ,计算后 补偿功率: " + actualPMPP + " ,dLable_Pnom: " + argByPMPP . getPowerClass ( ) + " ,dLable_Voc: " + argByPMPP . getLableVoc ( ) + " ,dLable_Isc: " + argByPMPP . getLableIsc ( ) + " ,dLable_Vmpp: " + argByPMPP . getLableVmpp ( ) + " ,dLable_Impp: " + argByPMPP . getLableImpp ( ) ) ;
logger . info ( " 标签打印Event--- 采集到 基板ID: " + subId + " , 线边号: " + lineNum + " , 从camline 获取到实际pmpp" + pmppActual + " ,计算后 补偿功率: " + pmppCompensation + " ,dLable_Pnom: " + argByPMPP . getPowerClass ( ) + " ,dLable_Voc: " + argByPMPP . getLableVoc ( ) + " ,dLable_Isc: " + argByPMPP . getLableIsc ( ) + " ,dLable_Vmpp: " + argByPMPP . getLableVmpp ( ) + " ,dLable_Impp: " + argByPMPP . getLableImpp ( ) ) ;
/ /
/ /
/ /
/ / / / 4 . 把基板录到数据库
/ / 4 . 把基板录到数据库
/ / WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate ( ) ;
WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate ( ) ;
/ / woPackagingBoxSubstrate . setLineBody ( lineNum ) ;
woPackagingBoxSubstrate . setLineBody ( lineNum ) ;
/ / woPackagingBoxSubstrate . setPowerLevel ( argByPMPP . getPowerClass ( ) ) ;
woPackagingBoxSubstrate . setPowerLevel ( argByPMPP . getPowerClass ( ) ) ;
/ / woPackagingBoxSubstrate . setSapMaterial ( argByPMPP . getSapMaterialNum ( ) ) ;
woPackagingBoxSubstrate . setSapMaterial ( argByPMPP . getSapMaterialNum ( ) ) ;
/ / woPackagingBoxSubstrate . setWoSubstrateId ( subId ) ;
woPackagingBoxSubstrate . setWoSubstrateId ( subId ) ;
/ / woPackagingBoxSubstrate . setActualPmpp ( pmppBySubId ) ;
woPackagingBoxSubstrate . setActualPmpp ( pmppActual ) ;
/ / woPackagingBoxSubstrate . setCreateTime ( LocalDateTime . now ( ) ) ;
woPackagingBoxSubstrate . setCreateTime ( LocalDateTime . now ( ) ) ;
/ /
woPackagingBoxSubstrate . setPmpp ( pmppCompensation ) ;
/ /
/ / / / 5 . 从camline那里获取可变字段
/ / CamlineExtendArgDTO extendArgFromCamline = service . getExtendArgFromCamline ( subId ) ;
/ / 5 . 从camline那里获取可变字段
/ / logger . info ( " 标签打印Event--- 基板ID: " + subId + " , 从camline获取PID16~PID22 的实测数据 成功, 数据内容: " + extendArgFromCamline . toString ( ) ) ;
CamlineExtendArgDTO extendArgFromCamline = service . getExtendArgFromCamline ( subId ) ;
/ / woPackagingBoxSubstrate . setLastUpdateTime ( extendArgFromCamline . getLastUpdateTime ( ) ) ;
logger . info ( " 标签打印Event--- 基板ID: " + subId + " , 从camline获取PID16~PID22 的实测数据 成功, 数据内容: " + extendArgFromCamline . toString ( ) ) ;
/ / woPackagingBoxSubstrate . setPmpp ( actualPMPP ) ;
woPackagingBoxSubstrate . setLastUpdateTime ( extendArgFromCamline . getLastUpdateTime ( ) ) ;
/ / woPackagingBoxSubstrate . setOrderName ( extendArgFromCamline . getOrderName ( ) ) ;
/ / woPackagingBoxSubstrate . setBinclassFl1 ( extendArgFromCamline . getBinclassFl1 ( ) ) ;
woPackagingBoxSubstrate . setOrderName ( extendArgFromCamline . getOrderName ( ) ) ;
/ / woPackagingBoxSubstrate . setBinclassFl2 ( extendArgFromCamline . getBinclassFl2 ( ) ) ;
woPackagingBoxSubstrate . setBinclassFl1 ( extendArgFromCamline . getBinclassFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setEtaFl1 ( extendArgFromCamline . getEtaFl1 ( ) ) ;
woPackagingBoxSubstrate . setBinclassFl2 ( extendArgFromCamline . getBinclassFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setEtaFl2 ( extendArgFromCamline . getEtaFl2 ( ) ) ;
woPackagingBoxSubstrate . setEtaFl1 ( extendArgFromCamline . getEtaFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setFfFl1 ( extendArgFromCamline . getFfFl1 ( ) ) ;
woPackagingBoxSubstrate . setEtaFl2 ( extendArgFromCamline . getEtaFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setFfFl2 ( extendArgFromCamline . getFfFl2 ( ) ) ;
woPackagingBoxSubstrate . setFfFl1 ( extendArgFromCamline . getFfFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setImppFl1 ( extendArgFromCamline . getImppFl1 ( ) ) ;
woPackagingBoxSubstrate . setFfFl2 ( extendArgFromCamline . getFfFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setImppFl2 ( extendArgFromCamline . getImppFl2 ( ) ) ;
woPackagingBoxSubstrate . setImppFl1 ( extendArgFromCamline . getImppFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolflashcontrolFl1 ( extendArgFromCamline . getInsolflashcontrolFl1 ( ) ) ;
woPackagingBoxSubstrate . setImppFl2 ( extendArgFromCamline . getImppFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolflashcontrolFl2 ( extendArgFromCamline . getInsolflashcontrolFl2 ( ) ) ;
woPackagingBoxSubstrate . setInsolflashcontrolFl1 ( extendArgFromCamline . getInsolflashcontrolFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolmppFl1 ( extendArgFromCamline . getInsolmppFl1 ( ) ) ;
woPackagingBoxSubstrate . setInsolflashcontrolFl2 ( extendArgFromCamline . getInsolflashcontrolFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolmppFl2 ( extendArgFromCamline . getInsolmppFl2 ( ) ) ;
woPackagingBoxSubstrate . setInsolmppFl1 ( extendArgFromCamline . getInsolmppFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolvocFl1 ( extendArgFromCamline . getInsolvocFl1 ( ) ) ;
woPackagingBoxSubstrate . setInsolmppFl2 ( extendArgFromCamline . getInsolmppFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolvocFl2 ( extendArgFromCamline . getInsolvocFl2 ( ) ) ;
woPackagingBoxSubstrate . setInsolvocFl1 ( extendArgFromCamline . getInsolvocFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolFl1 ( extendArgFromCamline . getInsolFl1 ( ) ) ;
woPackagingBoxSubstrate . setInsolvocFl2 ( extendArgFromCamline . getInsolvocFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setInsolFl2 ( extendArgFromCamline . getInsolFl2 ( ) ) ;
woPackagingBoxSubstrate . setInsolFl1 ( extendArgFromCamline . getInsolFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setIscFl1 ( extendArgFromCamline . getIscFl1 ( ) ) ;
woPackagingBoxSubstrate . setInsolFl2 ( extendArgFromCamline . getInsolFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setIscFl2 ( extendArgFromCamline . getIscFl2 ( ) ) ;
woPackagingBoxSubstrate . setIscFl1 ( extendArgFromCamline . getIscFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setMeasTimeFl1 ( extendArgFromCamline . getMeasTimeFl1 ( ) ) ;
woPackagingBoxSubstrate . setIscFl2 ( extendArgFromCamline . getIscFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setMeasTimeFl2 ( extendArgFromCamline . getMeasTimeFl2 ( ) ) ;
woPackagingBoxSubstrate . setMeasTimeFl1 ( extendArgFromCamline . getMeasTimeFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setPmppFl1 ( extendArgFromCamline . getPmppFl1 ( ) ) ;
woPackagingBoxSubstrate . setMeasTimeFl2 ( extendArgFromCamline . getMeasTimeFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setPmppFl2 ( extendArgFromCamline . getPmppFl2 ( ) ) ;
woPackagingBoxSubstrate . setPmppFl1 ( extendArgFromCamline . getPmppFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setTcellFl1 ( extendArgFromCamline . getTcellFl1 ( ) ) ;
woPackagingBoxSubstrate . setPmppFl2 ( extendArgFromCamline . getPmppFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setTcellFl2 ( extendArgFromCamline . getTcellFl2 ( ) ) ;
woPackagingBoxSubstrate . setTcellFl1 ( extendArgFromCamline . getTcellFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setTmonicellFl1 ( extendArgFromCamline . getTmonicellFl1 ( ) ) ;
woPackagingBoxSubstrate . setTcellFl2 ( extendArgFromCamline . getTcellFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setTmonicellFl2 ( extendArgFromCamline . getTmonicellFl2 ( ) ) ;
woPackagingBoxSubstrate . setTmonicellFl1 ( extendArgFromCamline . getTmonicellFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setUmppFl1 ( extendArgFromCamline . getUmppFl1 ( ) ) ;
woPackagingBoxSubstrate . setTmonicellFl2 ( extendArgFromCamline . getTmonicellFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setUmppFl2 ( extendArgFromCamline . getUmppFl2 ( ) ) ;
woPackagingBoxSubstrate . setUmppFl1 ( extendArgFromCamline . getUmppFl1 ( ) ) ;
/ / woPackagingBoxSubstrate . setUocFl1 ( extendArgFromCamline . getUocFl1 ( ) ) ;
woPackagingBoxSubstrate . setUmppFl2 ( extendArgFromCamline . getUmppFl2 ( ) ) ;
/ / woPackagingBoxSubstrate . setUocFl1 ( extendArgFromCamline . getUocFl2 ( ) ) ;
woPackagingBoxSubstrate . setUocFl1 ( extendArgFromCamline . getUocFl1 ( ) ) ;
/ /
woPackagingBoxSubstrate . setUocFl1 ( extendArgFromCamline . getUocFl2 ( ) ) ;
/ / substrateServiceBiz . insert ( woPackagingBoxSubstrate ) ;
/ / logger . info ( " 标签打印Event--- 基板ID: " + subId + " , 录入数据库成功 " ) ;
substrateServiceBiz . insert ( woPackagingBoxSubstrate ) ;
/ / / / = = = = = = = = = = = = = = = MES 业务 结束 = = = = = = = = = = = = = = = = =
logger . info ( " 标签打印Event--- 基板ID: " + subId + " , 录入数据库成功 " ) ;
/ /
/ / = = = = = = = = = = = = = = = MES 业务 结束 = = = = = = = = = = = = = = = = =
/ / / / 三 . 当MES完成任务后 , 把MesToPlc . SubArrivedFinish变量置为true , 告诉plc , 我操作完成了
/ / write ( S7Client . S7_KUKA , Step1Mes2PlcVar . SubArrivedFinish , true ) ;
/ / 三 . 当MES完成任务后 , 把MesToPlc . SubArrivedFinish变量置为true , 告诉plc , 我操作完成了
/ / logger . info ( " 标签打印Event--- 基板ID: " + subId + " , SubArrivedFinish, 置为true 成功 " ) ;
write ( S7Client . S7_KUKA , Step1Mes2PlcVar . SubArrivedFinish , true ) ;
/ / / / 四 . mes 监控 到PlcToMes . SubArrived = = false , 就把MesToPlc . SubArrivedFinish置为false
logger . info ( " 标签打印Event--- 基板ID: " + subId + " , SubArrivedFinish, 置为true 成功 " ) ;
/ / Integer subArrived2 = waitingForTarget ( Step1Plc2MesVar . SubArrivedToMes , false ) ;
/ / 四 . mes 监控 到PlcToMes . SubArrived = = false , 就把MesToPlc . SubArrivedFinish置为false
/ / if ( subArrived2 ! = 1 ) {
Integer subArrived2 = waitingForTarget ( Step1Plc2MesVar . SubArrivedToMes , false ) ;
/ / logger . info ( " 标签打印Event--- 失败 " + " --- " + " MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败 " ) ;
if ( subArrived2 ! = 1 ) {
/ / }
logger . info ( " 标签打印Event--- 失败 " + " --- " + " MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败 " ) ;
/ /
}
/ / write ( S7Client . S7_KUKA , Step1Mes2PlcVar . SubArrivedFinish , false ) ;
/ / logger . info ( " 标签打印Event--- 基板ID: " + subId + " , SubArrivedFinish, 置为 false 成功, Event1 成功结束 " ) ;
write ( S7Client . S7_KUKA , Step1Mes2PlcVar . SubArrivedFinish , false ) ;
/ /
logger . info ( " 标签打印Event--- 基板ID: " + subId + " , SubArrivedFinish, 置为 false 成功, Event1 成功结束 " ) ;
/ / } catch ( Throwable e ) {
/ / logger . info ( " 标签打印Event--- : " + e . getMessage ( ) ) ;
} catch ( Throwable e ) {
/ / }
logger . info ( " 标签打印Event--- : " + e . getMessage ( ) ) ;
/ / }
}
/ / } , 1 , 1 , TimeUnit . SECONDS ) ;
}
/ /
} , 1 , 1 , TimeUnit . SECONDS ) ;
/ /
/ / kukaStep2 . scheduleAtFixedRate ( new Runnable ( ) {
kukaStep2 . scheduleAtFixedRate ( new Runnable ( ) {
/ / @Override
@Override
/ / public void run ( ) {
public void run ( ) {
/ / try {
try {
/ /
/ / / / 调度开始
/ / 调度开始
/ / Integer shelfIsFull = waitingForTarget ( Step2Plc2MesVar . ShelfIsFull , true ) ;
Integer shelfIsFull = waitingForTarget ( Step2Plc2MesVar . ShelfIsFull , true ) ;
/ / if ( shelfIsFull ! = 1 ) {
if ( shelfIsFull ! = 1 ) {
/ / logger . info ( " BOXID生成Event-------失败 " + " --- " + " MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败 " ) ;
logger . info ( " BOXID生成Event-------失败 " + " --- " + " MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败 " ) ;
/ / }
}
/ /
/ / / / 一 . 从plc 中获取 subIdList 和 lineNum
/ / 一 . 从plc 中获取 subIdList 和 lineNum
/ / String [ ] subIdList = ( String [ ] ) read ( S7Client . S7_KUKA , Step2Plc2MesVar . SubIdList ) ;
String [ ] subIdList = ( String [ ] ) read ( S7Client . S7_KUKA , Step2Plc2MesVar . SubIdList ) ;
/ / Integer listSize = ( Integer ) read ( S7Client . S7_KUKA , Step2Plc2MesVar . PackageNumberSet ) ;
Integer listSize = ( Integer ) read ( S7Client . S7_KUKA , Step2Plc2MesVar . PackageNumberSet ) ;
/ /
/ / / / 二 . MES 业务
/ / 二 . MES 业务
/ / / / = = = = = = = = = = = = = = = MES 业务 开始 = = = = = = = = = = = = = = = = =
/ / = = = = = = = = = = = = = = = MES 业务 开始 = = = = = = = = = = = = = = = = =
/ / / / 1 . MES 生成BoxId
/ / 1 . MES 生成BoxId
/ / if ( subIdList . length < = 0 ) {
if ( subIdList . length < = 0 ) {
/ / logger . info ( " BOXID生成Event-------失败 " + " --- " + " 从plc里面获取到的基板列表 为空 " ) ;
logger . info ( " BOXID生成Event-------失败 " + " --- " + " 从plc里面获取到的基板列表 为空 " ) ;
/ / throw new Exception ( " BOXID生成Event-------kuka机械手 取到了空箱 " ) ;
throw new Exception ( " BOXID生成Event-------kuka机械手 取到了空箱 " ) ;
/ / }
}
/ / / / 真实的基板ID 就是17位的 , plc读取过来 , 有空格 , 要把后面3位空格去掉就行了 。
/ / 真实的基板ID 就是17位的 , plc读取过来 , 有空格 , 要把后面3位空格去掉就行了 。
/ / for ( int i = 0 ; i < subIdList . length ; i + + ) {
for ( int i = 0 ; i < subIdList . length ; i + + ) {
/ / subIdList [ i ] = removeKG ( subIdList [ i ] ) ;
subIdList [ i ] = removeKG ( subIdList [ i ] ) ;
/ / }
}
/ / logger . info ( " BOXID生成Event-------获取到基板列表: " + Arrays . toString ( subIdList ) + " ,基板数量: " + listSize ) ;
logger . info ( " BOXID生成Event-------获取到基板列表: " + Arrays . toString ( subIdList ) + " ,基板数量: " + listSize ) ;
/ /
/ / WoPackagingBoxSubstrate bySubId = substrateServiceBiz . getBySubId ( subIdList [ 0 ] ) ;
WoPackagingBoxSubstrate bySubId = substrateServiceBiz . getBySubId ( subIdList [ 0 ] ) ;
/ / / / 如果我们系统中找不到这块基板那么就去camline里面找
/ / 如果我们系统中找不到这块基板那么就去camline里面找
/ / if ( bySubId = = null ) {
if ( bySubId = = null ) {
/ / / / todo
/ / todo
/ / CamlineSubIdDTO subIdByCamline = service . getSubIdByCamline ( subIdList [ 0 ] ) ;
CamlineSubIdDTO subIdByCamline = service . getSubIdByCamline ( subIdList [ 0 ] ) ;
/ / bySubId = new WoPackagingBoxSubstrate ( ) ;
bySubId = new WoPackagingBoxSubstrate ( ) ;
/ / bySubId . setPowerLevel ( subIdByCamline . getPowerLevel ( ) ) ;
bySubId . setPowerLevel ( subIdByCamline . getPowerLevel ( ) ) ;
/ / bySubId . setSapMaterial ( subIdByCamline . getSapMaterial ( ) ) ;
bySubId . setSapMaterial ( subIdByCamline . getSapMaterial ( ) ) ;
/ / bySubId . setLineBody ( 2 ) ;
bySubId . setLineBody ( 2 ) ;
/ / }
}
/ /
/ /
/ / 校验是否存在混档位情况
/ / String boxId = getBoxId ( bySubId . getSapMaterial ( ) ) ;
String boxId = " " ;
/ / logger . info ( " BOXID生成Event-------mes 生成的boxId : " + boxId ) ;
if ( isMixLevel ( subIdList ) ) {
/ / / / 2 . 依次update 基板表 , 把boxId 赋予这些基板
/ / 出现混档
/ / for ( int i = 0 ; i < listSize ; i + + ) {
boxId = getBoxId ( bySubId . getSapMaterial ( ) ) ;
/ / substrateServiceBiz . updatePackagingBoxIdAndSlotByWoSubstrateId ( boxId , ( i + 1 ) , subIdList [ i ] ) ;
} else {
/ / }
/ / 正常情况
/ / / / 3 . 去camline数据库 查询此基板ID 对应的订单
boxId = getErrorBoxId ( bySubId . getSapMaterial ( ) ) ;
/ / String orderNameBySubId = service . getOrderNameBySubId ( subIdList [ 0 ] ) ;
}
/ / / / 4 . box信息录入到box表
/ / WoPackagingBox woPackagingBox = new WoPackagingBox ( ) ;
/ / woPackagingBox . setBoxNo ( boxId ) ;
/ / woPackagingBox . setPackagingTime ( LocalDateTime . now ( ) ) ;
/ / woPackagingBox . setPowerLevel ( bySubId . getPowerLevel ( ) ) ;
logger . info ( " BOXID生成Event-------mes 生成的boxId : " + boxId ) ;
/ / woPackagingBox . setLineBody ( bySubId . getLineBody ( ) ) ;
/ / 2 . 依次update 基板表 , 把boxId 赋予这些基板
/ / woPackagingBox . setSapMaterial ( bySubId . getSapMaterial ( ) ) ;
for ( int i = 0 ; i < listSize ; i + + ) {
/ / woPackagingBox . setOrderNum ( orderNameBySubId ) ;
substrateServiceBiz . updatePackagingBoxIdAndSlotByWoSubstrateId ( boxId , ( i + 1 ) , subIdList [ i ] ) ;
/ / / / 1 - 手动模式 , 2 - 自动模式
}
/ / woPackagingBox . setModel ( 2 ) ;
/ / 3 . 去camline数据库 查询此基板ID 对应的订单
/ / woPackagingBox . setCreateTime ( LocalDateTime . now ( ) ) ;
String orderNameBySubId = service . getOrderNameBySubId ( subIdList [ 0 ] ) ;
/ / boxServiceBiz . insert ( woPackagingBox ) ;
/ / 4 . box信息录入到box表
/ / logger . info ( " BOXID生成Event-------boxId : " + boxId + " 写入数据库成功 " ) ;
WoPackagingBox woPackagingBox = new WoPackagingBox ( ) ;
/ / / / = = = = = = = = = = = = = = = MES 业务 结束 = = = = = = = = = = = = = = = = =
woPackagingBox . setBoxNo ( boxId ) ;
/ /
woPackagingBox . setSubstrateQuantity ( listSize ) ;
/ / / / 三 . 把生成的BoxId 告诉kuka
woPackagingBox . setPackagingTime ( LocalDateTime . now ( ) ) ;
/ / write ( S7Client . S7_KUKA , Step2Mes2PlcVar . BoxId , boxId ) ;
woPackagingBox . setPowerLevel ( bySubId . getPowerLevel ( ) ) ;
/ / logger . info ( " BOXID生成Event-------boxId : " + boxId + " 传给PLC 成功 " ) ;
woPackagingBox . setLineBody ( bySubId . getLineBody ( ) ) ;
/ /
woPackagingBox . setSapMaterial ( bySubId . getSapMaterial ( ) ) ;
/ / / / 四 . 当MES完成任务后 , 把MesToPlc . ShelfIsFullFinish变量置为true , 告诉plc , 我操作完成了
woPackagingBox . setOrderNum ( orderNameBySubId ) ;
/ / write ( S7Client . S7_KUKA , Step2Mes2PlcVar . ShelfIsFullFinish , true ) ;
/ / 1 - 手动模式 , 2 - 自动模式
/ / logger . info ( " BOXID生成Event-------boxId : " + boxId + " ShelfIsFullFinish 置为true 成功 " ) ;
woPackagingBox . setModel ( 2 ) ;
/ / / / 四 . mes 监控 到PlcToMes . SubArrived = = false , 就把MesToPlc . SubArrivedFinish置为false
woPackagingBox . setCreateTime ( LocalDateTime . now ( ) ) ;
/ / Integer subArrived2 = waitingForTarget ( Step2Plc2MesVar . ShelfIsFull , false ) ;
boxServiceBiz . insert ( woPackagingBox ) ;
/ / if ( subArrived2 ! = 1 ) {
logger . info ( " BOXID生成Event-------boxId : " + boxId + " 写入数据库成功 " ) ;
/ / logger . info ( " BOXID生成Event-------失败 " + " --- " + " 步骤1. MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败 " ) ;
/ / = = = = = = = = = = = = = = = MES 业务 结束 = = = = = = = = = = = = = = = = =
/ / }
/ / write ( S7Client . S7_KUKA , Step2Mes2PlcVar . ShelfIsFullFinish , false ) ;
/ / 三 . 把生成的BoxId 告诉kuka
/ / logger . info ( " BOXID生成Event-------boxId : " + boxId + " ShelfIsFullFinish 置为false 成功,Event2 成功结束 " ) ;
write ( S7Client . S7_KUKA , Step2Mes2PlcVar . BoxId , boxId ) ;
/ / } catch ( Throwable e ) {
logger . info ( " BOXID生成Event-------boxId : " + boxId + " 传给PLC 成功 " ) ;
/ / logger . info ( " BOXID生成Event------- : " + e . getMessage ( ) ) ;
/ / }
/ / 四 . 当MES完成任务后 , 把MesToPlc . ShelfIsFullFinish变量置为true , 告诉plc , 我操作完成了
/ / }
write ( S7Client . S7_KUKA , Step2Mes2PlcVar . ShelfIsFullFinish , true ) ;
/ / } , 1 , 1 , TimeUnit . SECONDS ) ;
logger . info ( " BOXID生成Event-------boxId : " + boxId + " ShelfIsFullFinish 置为true 成功 " ) ;
/ /
/ / 四 . mes 监控 到PlcToMes . SubArrived = = false , 就把MesToPlc . SubArrivedFinish置为false
/ /
Integer subArrived2 = waitingForTarget ( Step2Plc2MesVar . ShelfIsFull , false ) ;
/ / kukaStep3 . scheduleAtFixedRate ( new Runnable ( ) {
if ( subArrived2 ! = 1 ) {
/ / @Override
logger . info ( " BOXID生成Event-------失败 " + " --- " + " 步骤1. MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败 " ) ;
/ / public void run ( ) {
}
/ / try {
write ( S7Client . S7_KUKA , Step2Mes2PlcVar . ShelfIsFullFinish , false ) ;
/ /
logger . info ( " BOXID生成Event-------boxId : " + boxId + " ShelfIsFullFinish 置为false 成功,Event2 成功结束 " ) ;
/ / / / 调度开始
} catch ( Throwable e ) {
/ / Integer shelfIsFull = waitingForTarget ( Step3Plc2MesVar . ShelfIsFullArrived , true ) ;
logger . info ( " BOXID生成Event------- : " + e . getMessage ( ) ) ;
/ / if ( shelfIsFull ! = 1 ) {
}
/ / logger . info ( " 装箱单打印Event------失败 " + " --- " + " MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败 " ) ;
}
/ / }
} , 1 , 1 , TimeUnit . SECONDS ) ;
/ /
/ / / / 一 . 从plc 中获取 subIdList 和 lineNum
kukaStep3 . scheduleAtFixedRate ( new Runnable ( ) {
/ / String boxId = ( String ) read ( S7Client . S7_KUKA , Step3Plc2MesVar . BoxId ) ;
@Override
/ / Integer lineNum = ( Integer ) read ( S7Client . S7_KUKA , Step3Plc2MesVar . LineNum ) ;
public void run ( ) {
/ / logger . info ( " 装箱单打印Event------到达站台的boxId : " + boxId ) ;
try {
/ /
/ / / / 二 . MES 业务
/ / 调度开始
/ / / / = = = = = = = = = = = = = = = MES 业务 开始 = = = = = = = = = = = = = = = = =
Integer shelfIsFull = waitingForTarget ( Step3Plc2MesVar . ShelfIsFullArrived , true ) ;
/ / / / 1 . box信息录入到box表
if ( shelfIsFull ! = 1 ) {
/ / boxServiceBiz . updateIsArrivedByBoxNo ( 1 , boxId ) ;
logger . info ( " 装箱单打印Event------失败 " + " --- " + " MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败 " ) ;
/ / logger . info ( " 装箱单打印Event------boxId : " + boxId + " 更新数据库成功 " ) ;
}
/ / / / = = = = = = = = = = = = = = = MES 业务 结束 = = = = = = = = = = = = = = = = =
/ /
/ / 一 . 从plc 中获取 subIdList 和 lineNum
/ /
String boxId = ( String ) read ( S7Client . S7_KUKA , Step3Plc2MesVar . BoxId ) ;
/ / / / 四 . 当MES完成任务后 , 把MesToPlc . ShelfIsFullArrivedFinish变量置为true , 告诉plc , 我操作完成了
Integer lineNum = ( Integer ) read ( S7Client . S7_KUKA , Step3Plc2MesVar . LineNum ) ;
/ / write ( S7Client . S7_KUKA , Step3Mes2PlcVar . ShelfIsFullArrivedFinish , true ) ;
logger . info ( " 装箱单打印Event------到达站台的boxId : " + boxId ) ;
/ / logger . info ( " 装箱单打印Event------boxId : " + boxId + " , ShelfIsFullArrivedFinish置为true 成功" ) ;
/ / / / 四 . mes 监控 到PlcToMes . SubArrived = = false , 就把MesToPlc . SubArrivedFinish置为false
/ / 二 . MES 业务
/ / Integer subArrived2 = waitingForTarget ( Step3Plc2MesVar . ShelfIsFullArrived , false ) ;
/ / = = = = = = = = = = = = = = = MES 业务 开始 = = = = = = = = = = = = = = = = =
/ / if ( subArrived2 ! = 1 ) {
/ / 1 . box信息录入到box表
/ / logger . info ( " 装箱单打印Event------失败 " + " --- " + " 步骤1. MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败 " ) ;
boxServiceBiz . updateIsArrivedByBoxNo ( 1 , boxId ) ;
/ / }
logger . info ( " 装箱单打印Event------boxId : " + boxId + " 更新数据库成功 " ) ;
/ / logger . info ( " 装箱单打印Event------boxId : " + boxId + " , 监听到subArrived=false 成功" ) ;
/ / = = = = = = = = = = = = = = = MES 业务 结束 = = = = = = = = = = = = = = = = =
/ / write ( S7Client . S7_KUKA , Step3Mes2PlcVar . ShelfIsFullArrivedFinish , false ) ;
/ / logger . info ( " 装箱单打印Event------boxId : " + boxId + " , Even3 成功" ) ;
/ / } catch ( Throwable e ) {
/ / 四 . 当MES完成任务后 , 把MesToPlc . ShelfIsFullArrivedFinish变量置为true , 告诉plc , 我操作完成了
/ / logger . info ( " 装箱单打印Event------ " + e . getMessage ( ) ) ;
write ( S7Client . S7_KUKA , Step3Mes2PlcVar . ShelfIsFullArrivedFinish , true ) ;
/ / }
logger . info ( " 装箱单打印Event------boxId : " + boxId + " , ShelfIsFullArrivedFinish置为true 成功" ) ;
/ /
/ / 四 . mes 监控 到PlcToMes . SubArrived = = false , 就把MesToPlc . SubArrivedFinish置为false
/ / }
Integer subArrived2 = waitingForTarget ( Step3Plc2MesVar . ShelfIsFullArrived , false ) ;
/ / } , 1 , 1 , TimeUnit . SECONDS ) ;
if ( subArrived2 ! = 1 ) {
logger . info ( " 装箱单打印Event------失败 " + " --- " + " 步骤1. MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败 " ) ;
}
logger . info ( " 装箱单打印Event------boxId : " + boxId + " , 监听到subArrived=false 成功" ) ;
write ( S7Client . S7_KUKA , Step3Mes2PlcVar . ShelfIsFullArrivedFinish , false ) ;
logger . info ( " 装箱单打印Event------boxId : " + boxId + " , Even3 成功" ) ;
} catch ( Throwable e ) {
logger . info ( " 装箱单打印Event------ " + e . getMessage ( ) ) ;
}
}
} , 1 , 1 , TimeUnit . SECONDS ) ;
}
}