diff --git a/ym-gateway/src/main/resources/application-dev.yml b/ym-gateway/src/main/resources/application-dev.yml
index 43cc06d..1b109d0 100644
--- a/ym-gateway/src/main/resources/application-dev.yml
+++ b/ym-gateway/src/main/resources/application-dev.yml
@@ -54,12 +54,14 @@ spring:
##多数据源的配置,需要引用renren-dynamic-datasource
dynamic:
datasource:
- slave1:
- driver-class-name: com.mysql.cj.jdbc.Driver
- url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
- username: root
- password: 1qaz@WSX3edc$RFV
- slave2:
+# ## 本mes系统
+# slave1:
+# driver-class-name: com.mysql.cj.jdbc.Driver
+# url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
+# username: root
+# password: 1qaz@WSX3edc$RFV
+ ## camline系统
+ camline:
driver-class-name: com.mysql.cj.jdbc.Driver
url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
username: root
diff --git a/ym-packing/pom.xml b/ym-packing/pom.xml
index b12037c..6e2fbea 100644
--- a/ym-packing/pom.xml
+++ b/ym-packing/pom.xml
@@ -43,6 +43,5 @@
1.0-SNAPSHOT
compile
->>>>>>>>> Temporary merge branch 2
\ No newline at end of file
diff --git a/ym-packing/src/main/java/com/cnbm/packing/dispatch/KukaJoinThread.java b/ym-packing/src/main/java/com/cnbm/packing/dispatch/KukaJoinThread.java
index 222a86d..c7ec919 100644
--- a/ym-packing/src/main/java/com/cnbm/packing/dispatch/KukaJoinThread.java
+++ b/ym-packing/src/main/java/com/cnbm/packing/dispatch/KukaJoinThread.java
@@ -1,5 +1,6 @@
package com.cnbm.packing.dispatch;
+import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.RandomUtil;
import com.cnbm.packing.dispatch.enums.kuka.step1.Step1Mes2PlcVar;
import com.cnbm.packing.dispatch.enums.kuka.step1.Step1Plc2MesVar;
@@ -8,12 +9,10 @@ import com.cnbm.packing.dispatch.enums.kuka.step2.Step2Plc2MesVar;
import com.cnbm.packing.dispatch.enums.kuka.step3.Step3Mes2PlcVar;
import com.cnbm.packing.dispatch.enums.kuka.step3.Step3Plc2MesVar;
import com.cnbm.packing.dto.WoPowerLevelDTO;
+import com.cnbm.packing.entity.WoPackagingBox;
import com.cnbm.packing.entity.WoPackagingBoxSubstrate;
import com.cnbm.packing.entity.WoPowerLevel;
-import com.cnbm.packing.service.DynamicDataSourceService;
-import com.cnbm.packing.service.WoCompensationPowerServiceBiz;
-import com.cnbm.packing.service.WoPackagingBoxSubstrateServiceBiz;
-import com.cnbm.packing.service.WoPowerLevelServiceBiz;
+import com.cnbm.packing.service.*;
import com.cnbm.s7.s7connector.enmuc.S7Client;
import com.cnbm.s7.s7connector.type.PlcVar;
import org.slf4j.Logger;
@@ -25,6 +24,7 @@ import org.springframework.core.annotation.Order;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
+import java.util.Date;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
@@ -50,6 +50,9 @@ public class KukaJoinThread implements ApplicationRunner {
@Autowired
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
+ @Autowired
+ WoPackagingBoxServiceBiz boxServiceBiz;
+
public KukaJoinThread(){
this.kukaStep1 = Executors.newScheduledThreadPool(1);
this.kukaStep2 = Executors.newScheduledThreadPool(1);
@@ -60,6 +63,8 @@ public class KukaJoinThread implements ApplicationRunner {
private ScheduledExecutorService kukaStep2;
private ScheduledExecutorService kukaStep3;
+
+
/**
* return
* 成功: 返回相应的object对象
@@ -141,33 +146,39 @@ public class KukaJoinThread implements ApplicationRunner {
}
+ public String getBoxId(String sapMaterial){
+ Integer todayBoxNum = service.getTodayBoxNum();
+ String nowTime = DateUtil.format(new Date(), "yyMMdd");
+ String res = "301"+sapMaterial+nowTime+todayBoxNum;
+ return res;
+ }
@Override
public void run(ApplicationArguments args) throws Exception {
kukaStep1.execute(new Runnable() {
@Override
public void run() {
- while (true){
- //read one
-// logger.info("过程一 : "+ Arrays.toString((String[])read(S7Client.S7_1500,PlcVarActual.SubIdArrays)));
-// try {
-// Thread.sleep(300);
-// } catch (InterruptedException e) {
-// throw new S7ParseDataException(e);
-// }
-// //write one
-// String[] toWrite = new String[60];
-// for(int i=0;i<60;i++){
-// toWrite[i] = RandomStringUtils.randomAlphanumeric(18);
-// }
-// try {
-// write(S7Client.S7_1500,PlcVarActual.SubIdArrays,toWrite);
-// } catch (Exception e) {
-// throw new S7ParseDataException(e);
-// }
-
-
- }
+// while (true){
+// //read one
+//// logger.info("过程一 : "+ Arrays.toString((String[])read(S7Client.S7_1500,PlcVarActual.SubIdArrays)));
+//// try {
+//// Thread.sleep(300);
+//// } catch (InterruptedException e) {
+//// throw new S7ParseDataException(e);
+//// }
+//// //write one
+//// String[] toWrite = new String[60];
+//// for(int i=0;i<60;i++){
+//// toWrite[i] = RandomStringUtils.randomAlphanumeric(18);
+//// }
+//// try {
+//// write(S7Client.S7_1500,PlcVarActual.SubIdArrays,toWrite);
+//// } catch (Exception e) {
+//// throw new S7ParseDataException(e);
+//// }
+//
+//
+// }
}
});
@@ -182,64 +193,111 @@ public class KukaJoinThread implements ApplicationRunner {
logger.info("失败"+" --- "+"步骤1. MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
}
- //1. 从plc 中获取 subId 和 lineNum
+ //一. 从plc 中获取 subId 和 lineNum
String subId = (String) read(S7Client.S7_KUKA,Step1Plc2MesVar.SubIdToMes);
Integer lineNum = (Integer) read(S7Client.S7_KUKA,Step1Plc2MesVar.LineNum);
- //2. 从comline数据库中获取 实际pmpp
+
+ //二. MES 业务
+ //=============== MES 业务 开始 =================
+ //1. 从comline数据库中获取 实际pmpp
float pmppBySubId = service.getPMPPBySubId(subId);
- //3. 匹配和计算补偿功率
+ //2. 匹配和计算补偿功率
float actualPMPP = compensationPowerServiceBiz.calculCompensationPMPP(pmppBySubId,lineNum);
- //4. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka
+ //3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka
WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(actualPMPP, lineNum);
- write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Pnom,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_Isc,argByPMPP.getLableIsc());
write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Vmpp,argByPMPP.getLableVmpp());
write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Impp,argByPMPP.getLableImpp());
+ //4. 从camline那里获取可变字段
- //5. 把基板录到数据库
+
+ //4. 把基板录到数据库
WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate();
- woPackagingBoxSubstrate.setLineBody(1);
- woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass().toString());
+ woPackagingBoxSubstrate.setLineBody(lineNum);
+ woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass());
woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum());
- woPackagingBoxSubstrate.setWoSubstrateId("sub123");
-
+ woPackagingBoxSubstrate.setWoSubstrateId(subId);
substrateServiceBiz.insert(woPackagingBoxSubstrate);
+ //=============== MES 业务 结束 =================
+ //三. 当MES完成任务后,把MesToPlc.SubArrivedFinish变量置为true,告诉plc,我操作完成了
+ write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,true);
+
+ //四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
+ Integer subArrived2 = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, false);
+ if(subArrived2 != 1){
+ logger.info("失败"+" --- "+"步骤1. MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
+ }
+ write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,false);
+ logger.info("================= 过程一 任务成功完成 ==================");
+ logger.info("");
}
},1,1, TimeUnit.SECONDS);
+
kukaStep2.scheduleAtFixedRate(new Runnable() {
@Override
public void run() {
- try {
- String s = RandomUtil.randomString(5);
- System.out.println("start + "+s+" : "+LocalDateTime.now());
- Thread.sleep(3000);
-
-
- //写业务代码
- WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(2.1111f, 1);
-
-
- WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate();
- woPackagingBoxSubstrate.setLineBody(1);
- woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass().toString());
- woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum());
- woPackagingBoxSubstrate.setWoSubstrateId("sub123");
-
- substrateServiceBiz.insert(woPackagingBoxSubstrate);
-
- System.err.println(argByPMPP.toString());
-// service.salve3Get();
- System.out.println("end "+ s +" : "+ LocalDateTime.now());
- }catch (Throwable e){
- //Error 和 Exception 都继承于Throwable ,所以当业务代码出现Error/Exception 都不会导致程序down掉
- e.printStackTrace();
+ //调度开始
+ logger.info("");
+ logger.info("================= 现在开始执行 过程二 任务 ==================");
+ Integer shelfIsFull = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, true);
+ if(shelfIsFull != 1){
+ logger.info("失败"+" --- "+"MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败");
}
+
+ //一. 从plc 中获取 subIdList 和 lineNum
+ String[] subIdList = (String[])read(S7Client.S7_KUKA,Step2Plc2MesVar.SubIdList);
+// Integer lineNum = (Integer) read(S7Client.S7_KUKA,Step2Plc2MesVar.LineNum);
+
+
+ //二. MES 业务
+ //=============== MES 业务 开始 =================
+ //1.MES 生成BoxId
+ if(subIdList.length<=0){
+ logger.info("失败"+" --- "+"从plc里面获取到的基板列表 为空");
+ }
+ WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIdList[0]);
+ String boxId = getBoxId(bySubId.getSapMaterial());
+ //2. 依次update 基板表,把boxId 赋予这些基板
+ for(int i=0;i {
List list();
+ int updateIsArrivedByBoxNo(@Param("isArrived") Integer isArrived, @Param("boxNo") String boxNo);
+
}
\ No newline at end of file
diff --git a/ym-packing/src/main/java/com/cnbm/packing/mapper/WoPackagingBoxSubstrateMapper.java b/ym-packing/src/main/java/com/cnbm/packing/mapper/WoPackagingBoxSubstrateMapper.java
index 985ed54..0403873 100644
--- a/ym-packing/src/main/java/com/cnbm/packing/mapper/WoPackagingBoxSubstrateMapper.java
+++ b/ym-packing/src/main/java/com/cnbm/packing/mapper/WoPackagingBoxSubstrateMapper.java
@@ -1,4 +1,5 @@
package com.cnbm.packing.mapper;
+import org.apache.ibatis.annotations.Param;
import com.cnbm.common.dao.BaseDao;
import com.cnbm.packing.entity.WoPackagingBoxSubstrate;
@@ -12,5 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
*/
@Mapper
public interface WoPackagingBoxSubstrateMapper extends BaseDao {
-
+ WoPackagingBoxSubstrate getOneByWoSubstrateId(@Param("woSubstrateId") String woSubstrateId);
+
+ int updatePackagingBoxIdByWoSubstrateId(@Param("packagingBoxId") String packagingBoxId, @Param("woSubstrateId") String woSubstrateId);
}
\ No newline at end of file
diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/DynamicDataSourceService.java b/ym-packing/src/main/java/com/cnbm/packing/service/DynamicDataSourceService.java
index 7215dc8..8eea8f3 100644
--- a/ym-packing/src/main/java/com/cnbm/packing/service/DynamicDataSourceService.java
+++ b/ym-packing/src/main/java/com/cnbm/packing/service/DynamicDataSourceService.java
@@ -4,6 +4,7 @@ import com.cnbm.dynamic.datasource.annotation.DataSource;
import com.cnbm.packing.dto.WoPowerLevelDTO;
import com.cnbm.packing.mapper.CamlineMapper;
+import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
@@ -23,28 +24,20 @@ public class DynamicDataSourceService {
WoPowerLevelServiceBiz powerLevelServiceBiz;
+ public Integer getTodayBoxNum(){
+ return mapper.getTodayBoxNum();
+ }
+
+ @DataSource("camline")
@Transactional
- @DataSource("slave1")
- public void salve1Get(){
- WoPowerLevelDTO woPowerLevelDTO = powerLevelServiceBiz.get(Long.valueOf(1));
- System.out.println(woPowerLevelDTO.toString());
- }
-
- public void getTodayBoxNum(){
- Integer todayBoxNum = mapper.getTodayBoxNum();
- System.out.println(todayBoxNum);
- }
-
public float getPMPPBySubId(String subId){
return mapper.getPMPPBySubId(subId);
}
-
-
- @DataSource("slave2")
+ @DataSource("camline")
@Transactional
- public void salve3Get(){
- float byid = mapper.getByid("LTWeight");
- System.out.println(byid);
+ public String getOrderNameBySubId(String subId){
+ return mapper.getOrderNameBySubId(subId);
}
+
}
diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxServiceBiz.java b/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxServiceBiz.java
index 7baca8b..62e4d3b 100644
--- a/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxServiceBiz.java
+++ b/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxServiceBiz.java
@@ -5,6 +5,7 @@ import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.WoPackagingBoxDTO;
import com.cnbm.packing.dto.WoPackagingBoxDTO;
import com.cnbm.packing.entity.WoPackagingBox;
+import org.apache.ibatis.annotations.Param;
import java.util.List;
import java.util.Map;
@@ -28,5 +29,6 @@ public interface WoPackagingBoxServiceBiz extends CrudService list();
-
+
+ int updateIsArrivedByBoxNo(Integer isArrived, String boxNo);
}
\ No newline at end of file
diff --git a/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxSubstrateServiceBiz.java b/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxSubstrateServiceBiz.java
index 4906841..3879717 100644
--- a/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxSubstrateServiceBiz.java
+++ b/ym-packing/src/main/java/com/cnbm/packing/service/WoPackagingBoxSubstrateServiceBiz.java
@@ -4,6 +4,7 @@ import com.cnbm.common.page.PageData;
import com.cnbm.common.service.CrudService;
import com.cnbm.packing.dto.WoPackagingBoxSubstrateDTO;
import com.cnbm.packing.entity.WoPackagingBoxSubstrate;
+import org.apache.ibatis.annotations.Param;
import java.util.Map;
@@ -32,5 +33,7 @@ public interface WoPackagingBoxSubstrateServiceBiz extends CrudService
SELECT
- -- tu.`NAME`,-- DMC(就是基板ID/模组ID)
- -- flr.LAST_UPDATE_TIME,
- flr.PMPP_FL2
+ flc.PMPP
FROM
- ue_flasher_data_raw flr
+ ue_flasher_data_calc flc
LEFT JOIN e_tracking_unit tu ON flc.mainid = tu.id
WHERE
- flr.PMPP != 0
+ flc.PMPP != 0
and
tu.name=#{subId} -- 查特定基板功率
ORDER BY
diff --git a/ym-packing/src/main/resources/mapper/WoPackagingBoxMapper.xml b/ym-packing/src/main/resources/mapper/WoPackagingBoxMapper.xml
index cfc88c0..03dbef4 100644
--- a/ym-packing/src/main/resources/mapper/WoPackagingBoxMapper.xml
+++ b/ym-packing/src/main/resources/mapper/WoPackagingBoxMapper.xml
@@ -37,5 +37,10 @@
select * from t_wo_packaging_box
order by id asc
+
+ update t_wo_packaging_box
+ set is_arrived = #{isArrived,jdbcType=NUMERIC}
+ where BOX_NO = #{boxNo,jdbcType=VARCHAR}
+
diff --git a/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml b/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml
index 5290639..17ba091 100644
--- a/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml
+++ b/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml
@@ -24,6 +24,20 @@
select * from t_wo_packaging_box_substrate
order by id asc
+
+
+ update t_wo_packaging_box_substrate
+ set PACKAGING_BOX_ID = #{packagingBoxId,jdbcType=VARCHAR}
+ where WO_SUBSTRATE_ID = #{woSubstrateId,jdbcType=VARCHAR}
+