From 6d88aacee0bab921649093cf1de86b8c2d5e699c Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Fri, 3 Mar 2023 14:33:18 +0800 Subject: [PATCH 1/3] commit --- .../src/main/resources/application-dev.yml | 24 +- ym-gateway/src/main/resources/application.yml | 7 +- ym-gateway/src/main/resources/logback.xml | 8 +- .../com/cnbm/dispatch/KukaJoinThread.java | 362 ++++++++++-------- .../enums/kuka/step2/Step2Plc2MesVar.java | 4 +- .../packing/controller/TestController.java | 45 ++- .../com/cnbm/packing/dto/CamlineSubIdDTO.java | 30 ++ .../cnbm/packing/mapper/CamlineMapper.java | 3 + .../mapper/WoPackagingBoxSubstrateMapper.java | 5 +- .../service/DynamicDataSourceService.java | 7 + .../WoPackagingBoxSubstrateServiceBiz.java | 4 +- .../WoCompensationPowerServiceBizImpl.java | 7 +- ...WoPackagingBoxSubstrateServiceBizImpl.java | 4 +- .../main/resources/mapper/CamlineMapper.xml | 19 + .../mapper/WoCompensationPowerMapper.xml | 2 +- .../mapper/WoPackagingBoxSubstrateMapper.xml | 7 +- .../resources/mapper/WoPowerLevelMapper.xml | 2 +- .../cnbm/s7/s7connector/enmuc/S7Client.java | 2 +- 18 files changed, 355 insertions(+), 187 deletions(-) create mode 100644 ym-packing/src/main/java/com/cnbm/packing/dto/CamlineSubIdDTO.java diff --git a/ym-gateway/src/main/resources/application-dev.yml b/ym-gateway/src/main/resources/application-dev.yml index 3bbe591..229e619 100644 --- a/ym-gateway/src/main/resources/application-dev.yml +++ b/ym-gateway/src/main/resources/application-dev.yml @@ -1,7 +1,11 @@ spring: datasource: - #MySQL driver-class-name: com.mysql.cj.jdbc.Driver + #MySQL + #url: jdbc:mysql://10.0.1.249:3306/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + #username: cigs4 + #password: 1qazxsw2 + 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 @@ -61,14 +65,14 @@ dynamic: # 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 - password: 1qaz@WSX3edc$RFV -# # camline: # driver-class-name: com.mysql.cj.jdbc.Driver -# url: jdbc:mysql://10.0.1.23:3306/synapse?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true -# username: offline_data -# password: tpvmfab4 \ No newline at end of file +# 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: + driver-class-name: com.mysql.cj.jdbc.Driver + url: jdbc:mysql://10.0.1.23:3306/synapse?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: offline_data + password: tpvmfab4 \ No newline at end of file diff --git a/ym-gateway/src/main/resources/application.yml b/ym-gateway/src/main/resources/application.yml index 4bd8c39..bf10db0 100644 --- a/ym-gateway/src/main/resources/application.yml +++ b/ym-gateway/src/main/resources/application.yml @@ -33,9 +33,10 @@ spring: enabled: true redis: database: 6 - host: 192.168.0.135 - port: 6380 - password: '@WSXcde3' # 密码(默认为空) + host: 10.0.1.249 + #host: 127.0.0.1 + port: 6379 + password: '' # 密码(默认为空) timeout: 6000ms # 连接超时时长(毫秒) jedis: pool: diff --git a/ym-gateway/src/main/resources/logback.xml b/ym-gateway/src/main/resources/logback.xml index 5265425..15c84a5 100644 --- a/ym-gateway/src/main/resources/logback.xml +++ b/ym-gateway/src/main/resources/logback.xml @@ -16,7 +16,7 @@ - + @@ -392,6 +392,12 @@ + + + + + + diff --git a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java index b9f45e9..7311a61 100644 --- a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java +++ b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java @@ -8,6 +8,7 @@ import com.cnbm.dispatch.enums.kuka.step2.Step2Plc2MesVar; import com.cnbm.dispatch.enums.kuka.step3.Step3Mes2PlcVar; import com.cnbm.dispatch.enums.kuka.step3.Step3Plc2MesVar; import com.cnbm.packing.dto.CamlineExtendArgDTO; +import com.cnbm.packing.dto.CamlineSubIdDTO; import com.cnbm.packing.entity.WoPackagingBox; import com.cnbm.packing.entity.WoPackagingBoxSubstrate; import com.cnbm.packing.entity.WoPowerLevel; @@ -153,96 +154,113 @@ public class KukaJoinThread implements ApplicationRunner { return res; } + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + String str = "30110012302210707 "; + String substring = str.substring(0,17); + System.out.println(substring); + } + @Override public void run(ApplicationArguments args) throws Exception { kukaStep1.scheduleAtFixedRate(new Runnable() { @Override public void run() { - //调度开始 + try { + + //调度开始 // logger.info(""); // logger.info("================= 现在开始执行 过程一 任务 =================="); - Integer subArrived = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, true); - if(subArrived != 1){ - logger.info("失败"+" --- "+" MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败"); + Integer subArrived = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, true); + if(subArrived != 1){ + logger.info("失败"+" --- "+" MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败"); + } + + //一. 从plc 中获取 subId 和 lineNum + String subId = (String) read(S7Client.S7_KUKA,Step1Plc2MesVar.SubIdToMes); + Integer lineNum = (Integer) read(S7Client.S7_KUKA,Step1Plc2MesVar.LineNum); + //把基板ID字符串的空格去掉,因为plc中设置的20位,但实际基板ID就是17位,因为带空格去数据库查询 有问题的。 + subId = removeKG(subId); + + //二. MES 业务 + //=============== MES 业务 开始 ================= + //1. 从comline数据库中获取 实际pmpp + float pmppBySubId = service.getPMPPBySubId(subId); + //2. 匹配和计算补偿功率 + float actualPMPP = compensationPowerServiceBiz.calculCompensationPMPP(pmppBySubId,lineNum); + //3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka + WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(actualPMPP, lineNum); + 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()); + logger.info("采集到 基板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()); + + + + //4. 把基板录到数据库 + WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate(); + woPackagingBoxSubstrate.setLineBody(lineNum); + woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass()); + woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum()); + woPackagingBoxSubstrate.setWoSubstrateId(subId); + + //5. 从camline那里获取可变字段 + CamlineExtendArgDTO extendArgFromCamline = service.getExtendArgFromCamline(subId); + woPackagingBoxSubstrate.setLastUpdateTime(extendArgFromCamline.getLastUpdateTime()); + woPackagingBoxSubstrate.setPmpp(actualPMPP); + woPackagingBoxSubstrate.setOrderName(extendArgFromCamline.getOrderName()); + woPackagingBoxSubstrate.setBinclassFl1(extendArgFromCamline.getBinclassFl1()); + woPackagingBoxSubstrate.setBinclassFl2(extendArgFromCamline.getBinclassFl2()); + woPackagingBoxSubstrate.setEtaFl1(extendArgFromCamline.getEtaFl1()); + woPackagingBoxSubstrate.setEtaFl2(extendArgFromCamline.getEtaFl2()); + woPackagingBoxSubstrate.setFfFl1(extendArgFromCamline.getFfFl1()); + woPackagingBoxSubstrate.setFfFl2(extendArgFromCamline.getFfFl2()); + woPackagingBoxSubstrate.setImppFl1(extendArgFromCamline.getImppFl1()); + woPackagingBoxSubstrate.setImppFl2(extendArgFromCamline.getImppFl2()); + woPackagingBoxSubstrate.setInsolflashcontrolFl1(extendArgFromCamline.getInsolflashcontrolFl1()); + woPackagingBoxSubstrate.setInsolflashcontrolFl2(extendArgFromCamline.getInsolflashcontrolFl2()); + woPackagingBoxSubstrate.setInsolmppFl1(extendArgFromCamline.getInsolmppFl1()); + woPackagingBoxSubstrate.setInsolmppFl2(extendArgFromCamline.getInsolmppFl2()); + woPackagingBoxSubstrate.setInsolvocFl1(extendArgFromCamline.getInsolvocFl1()); + woPackagingBoxSubstrate.setInsolvocFl2(extendArgFromCamline.getInsolvocFl2()); + woPackagingBoxSubstrate.setInsolFl1(extendArgFromCamline.getInsolFl1()); + woPackagingBoxSubstrate.setInsolFl2(extendArgFromCamline.getInsolFl2()); + woPackagingBoxSubstrate.setIscFl1(extendArgFromCamline.getIscFl1()); + woPackagingBoxSubstrate.setIscFl2(extendArgFromCamline.getIscFl2()); + woPackagingBoxSubstrate.setMeasTimeFl1(extendArgFromCamline.getMeasTimeFl1()); + woPackagingBoxSubstrate.setMeasTimeFl2(extendArgFromCamline.getMeasTimeFl2()); + woPackagingBoxSubstrate.setPmppFl1(extendArgFromCamline.getPmppFl1()); + woPackagingBoxSubstrate.setPmppFl2(extendArgFromCamline.getPmppFl2()); + woPackagingBoxSubstrate.setTcellFl1(extendArgFromCamline.getTcellFl1()); + woPackagingBoxSubstrate.setTcellFl2(extendArgFromCamline.getTcellFl2()); + woPackagingBoxSubstrate.setTmonicellFl1(extendArgFromCamline.getTmonicellFl1()); + woPackagingBoxSubstrate.setTmonicellFl2(extendArgFromCamline.getTmonicellFl2()); + woPackagingBoxSubstrate.setUmppFl1(extendArgFromCamline.getUmppFl1()); + woPackagingBoxSubstrate.setUmppFl2(extendArgFromCamline.getUmppFl2()); + woPackagingBoxSubstrate.setUocFl1(extendArgFromCamline.getUocFl1()); + woPackagingBoxSubstrate.setUocFl1(extendArgFromCamline.getUocFl2()); + + 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("失败"+" --- "+"MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败"); + } + write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,false); + }catch (Throwable e){ + logger.info("Event1 :"+e.getMessage()); } - - //一. 从plc 中获取 subId 和 lineNum - String subId = (String) read(S7Client.S7_KUKA,Step1Plc2MesVar.SubIdToMes); - Integer lineNum = (Integer) read(S7Client.S7_KUKA,Step1Plc2MesVar.LineNum); - - - //二. MES 业务 - //=============== MES 业务 开始 ================= - //1. 从comline数据库中获取 实际pmpp - float pmppBySubId = service.getPMPPBySubId(subId); - //2. 匹配和计算补偿功率 - float actualPMPP = compensationPowerServiceBiz.calculCompensationPMPP(pmppBySubId,lineNum); - //3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka - WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(actualPMPP, lineNum); - 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()); - logger.info("采集到 基板ID: "+subId+", 线边号:"+lineNum+",dLable_Pnom: "+argByPMPP.getPowerClass() +",dLable_Voc: "+argByPMPP.getLableVoc()+",dLable_Isc: "+argByPMPP.getLableIsc()+",dLable_Vmpp: "+argByPMPP.getLableVmpp()+",dLable_Impp: "+argByPMPP.getLableImpp()); - - - //4. 把基板录到数据库 - WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate(); - woPackagingBoxSubstrate.setLineBody(lineNum); - woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass()); - woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum()); - woPackagingBoxSubstrate.setWoSubstrateId(subId); - - //5. 从camline那里获取可变字段 - CamlineExtendArgDTO extendArgFromCamline = service.getExtendArgFromCamline(subId); - woPackagingBoxSubstrate.setLastUpdateTime(extendArgFromCamline.getLastUpdateTime()); - woPackagingBoxSubstrate.setPmpp(actualPMPP); - woPackagingBoxSubstrate.setOrderName(extendArgFromCamline.getOrderName()); - woPackagingBoxSubstrate.setBinclassFl1(extendArgFromCamline.getBinclassFl1()); - woPackagingBoxSubstrate.setBinclassFl2(extendArgFromCamline.getBinclassFl2()); - woPackagingBoxSubstrate.setEtaFl1(extendArgFromCamline.getEtaFl1()); - woPackagingBoxSubstrate.setEtaFl2(extendArgFromCamline.getEtaFl2()); - woPackagingBoxSubstrate.setFfFl1(extendArgFromCamline.getFfFl1()); - woPackagingBoxSubstrate.setFfFl2(extendArgFromCamline.getFfFl2()); - woPackagingBoxSubstrate.setImppFl1(extendArgFromCamline.getImppFl1()); - woPackagingBoxSubstrate.setImppFl2(extendArgFromCamline.getImppFl2()); - woPackagingBoxSubstrate.setInsolflashcontrolFl1(extendArgFromCamline.getInsolflashcontrolFl1()); - woPackagingBoxSubstrate.setInsolflashcontrolFl2(extendArgFromCamline.getInsolflashcontrolFl2()); - woPackagingBoxSubstrate.setInsolmppFl1(extendArgFromCamline.getInsolmppFl1()); - woPackagingBoxSubstrate.setInsolmppFl2(extendArgFromCamline.getInsolmppFl2()); - woPackagingBoxSubstrate.setInsolvocFl1(extendArgFromCamline.getInsolvocFl1()); - woPackagingBoxSubstrate.setInsolvocFl2(extendArgFromCamline.getInsolvocFl2()); - woPackagingBoxSubstrate.setInsolFl1(extendArgFromCamline.getInsolFl1()); - woPackagingBoxSubstrate.setInsolFl2(extendArgFromCamline.getInsolFl2()); - woPackagingBoxSubstrate.setIscFl1(extendArgFromCamline.getIscFl1()); - woPackagingBoxSubstrate.setIscFl2(extendArgFromCamline.getIscFl2()); - woPackagingBoxSubstrate.setMeasTimeFl1(extendArgFromCamline.getMeasTimeFl1()); - woPackagingBoxSubstrate.setMeasTimeFl2(extendArgFromCamline.getMeasTimeFl2()); - woPackagingBoxSubstrate.setPmppFl1(extendArgFromCamline.getPmppFl1()); - woPackagingBoxSubstrate.setPmppFl2(extendArgFromCamline.getPmppFl2()); - woPackagingBoxSubstrate.setTcellFl1(extendArgFromCamline.getTcellFl1()); - woPackagingBoxSubstrate.setTcellFl2(extendArgFromCamline.getTcellFl2()); - woPackagingBoxSubstrate.setTmonicellFl1(extendArgFromCamline.getTmonicellFl1()); - woPackagingBoxSubstrate.setTmonicellFl2(extendArgFromCamline.getTmonicellFl2()); - woPackagingBoxSubstrate.setUmppFl1(extendArgFromCamline.getUmppFl1()); - woPackagingBoxSubstrate.setUmppFl2(extendArgFromCamline.getUmppFl2()); - woPackagingBoxSubstrate.setUocFl1(extendArgFromCamline.getUocFl1()); - woPackagingBoxSubstrate.setUocFl1(extendArgFromCamline.getUocFl2()); - - 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("失败"+" --- "+"MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败"); - } - write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,false); } },1,1, TimeUnit.SECONDS); @@ -250,59 +268,81 @@ public class KukaJoinThread implements ApplicationRunner { kukaStep2.scheduleAtFixedRate(new Runnable() { @Override public void run() { - //调度开始 + try { - Integer shelfIsFull = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, true); - if(shelfIsFull != 1){ - logger.info("失败"+" --- "+"MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败"); + //调度开始 + + 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 listSize = (Integer)read(S7Client.S7_KUKA,Step2Plc2MesVar.PackageNumberSet); + + //二. MES 业务 + //=============== MES 业务 开始 ================= + //1.MES 生成BoxId + if(subIdList.length<=0){ + logger.info("失败"+" --- "+"从plc里面获取到的基板列表 为空"); + throw new Exception("kuka机械手 取到了空箱"); + } + //真实的基板ID 就是17位的,plc读取过来,有空格,要把后面3位空格去掉就行了。 + for(int i=0;i { WoPackagingBoxSubstrate getOneByWoSubstrateId(@Param("woSubstrateId") String woSubstrateId); - int updatePackagingBoxIdByWoSubstrateId(@Param("packagingBoxId") String packagingBoxId, @Param("woSubstrateId") String woSubstrateId); -} \ No newline at end of file + + int updatePackagingBoxIdAndSlotByWoSubstrateId(@Param("packagingBoxId") String packagingBoxId, @Param("slot") Integer slot, @Param("woSubstrateId") String woSubstrateId); +} 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 5af32ad..7d62c31 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 @@ -2,6 +2,7 @@ package com.cnbm.packing.service; import com.cnbm.dynamic.datasource.annotation.DataSource; import com.cnbm.packing.dto.CamlineExtendArgDTO; +import com.cnbm.packing.dto.CamlineSubIdDTO; import com.cnbm.packing.dto.WoPowerLevelDTO; import com.cnbm.packing.mapper.CamlineMapper; @@ -41,6 +42,12 @@ public class DynamicDataSourceService { return mapper.getOrderNameBySubId(subId); } + @DataSource("camline") + @Transactional + public CamlineSubIdDTO getSubIdByCamline(String subId){ + return mapper.getSubIdByCamline(subId); + } + @DataSource("camline") @Transactional public CamlineExtendArgDTO getExtendArgFromCamline(String subId){ 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 ad4a4ed..a09c92b 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 @@ -35,5 +35,7 @@ public interface WoPackagingBoxSubstrateServiceBiz extends CrudService + + + + + @@ -118,6 +123,20 @@ LIMIT 1 + + + diff --git a/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml b/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml index d84f1e0..3494363 100644 --- a/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml +++ b/ym-packing/src/main/resources/mapper/WoPackagingBoxSubstrateMapper.xml @@ -72,9 +72,12 @@ WO_SUBSTRATE_ID = #{woSubstrateId,jdbcType=VARCHAR} limit 1 - + + + update t_wo_packaging_box_substrate - set PACKAGING_BOX_ID = #{packagingBoxId,jdbcType=VARCHAR} + set PACKAGING_BOX_ID = #{packagingBoxId,jdbcType=VARCHAR}, + SLOT = #{slot,jdbcType=NUMERIC} where WO_SUBSTRATE_ID = #{woSubstrateId,jdbcType=VARCHAR} diff --git a/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml b/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml index 15beb02..6974982 100644 --- a/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml +++ b/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml @@ -38,7 +38,7 @@ and twpl.line_body = #{param.lineBody} - and twpl.pmpp_high = ]]> #{param.pmpp} and twpl.pmpp_low #{param.pmpp} + and twpl.pmpp_high ]]> #{param.pmpp} and twpl.pmpp_low #{param.pmpp} diff --git a/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7Client.java b/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7Client.java index 6c32fd8..468a855 100644 --- a/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7Client.java +++ b/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7Client.java @@ -27,7 +27,7 @@ public enum S7Client { // S7_1200("192.168.0.52",0,1,1,PlcVarActual.HeartBeatFor1200), // S7_15001("192.168.0.51",0,1,1), // S7_1500("192.168.0.51",0,1,1), - S7_KUKA("10.10.3.158",0,1,1), + S7_KUKA("10.10.3.158",0,1,2), //1500 机架-0 插槽-1 //后续 在这里扩展 多PLC应用。 ; From 9ccc971a3861002347d642fa0bacb9d12f95f6ec Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Sat, 4 Mar 2023 13:57:07 +0800 Subject: [PATCH 2/3] mark --- .../src/main/resources/application-dev.yml | 12 +- .../com/cnbm/dispatch/KukaJoinThread.java | 21 +++- .../packing/controller/TestController.java | 18 +++ .../packing/dto/CamlineSubIdForImportDTO.java | 28 +++++ .../cnbm/packing/mapper/CamlineMapper.java | 3 + .../service/DynamicDataSourceService.java | 7 ++ .../main/resources/mapper/CamlineMapper.xml | 107 ++++++++++++++++-- 7 files changed, 178 insertions(+), 18 deletions(-) create mode 100644 ym-packing/src/main/java/com/cnbm/packing/dto/CamlineSubIdForImportDTO.java diff --git a/ym-gateway/src/main/resources/application-dev.yml b/ym-gateway/src/main/resources/application-dev.yml index 229e619..780bf3e 100644 --- a/ym-gateway/src/main/resources/application-dev.yml +++ b/ym-gateway/src/main/resources/application-dev.yml @@ -2,13 +2,13 @@ spring: datasource: driver-class-name: com.mysql.cj.jdbc.Driver #MySQL - #url: jdbc:mysql://10.0.1.249:3306/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true - #username: cigs4 - #password: 1qazxsw2 + url: jdbc:mysql://10.0.1.249:3306/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true + username: cigs4 + password: 1qazxsw2 - 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 +# 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 # #Oracle # driver-class-name: oracle.jdbc.OracleDriver # url: jdbc:oracle:thin:@192.168.10.10:1521:xe diff --git a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java index 7311a61..c14eb5a 100644 --- a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java +++ b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java @@ -15,6 +15,7 @@ import com.cnbm.packing.entity.WoPowerLevel; import com.cnbm.packing.service.*; import com.cnbm.s7.s7connector.enmuc.S7Client; import com.cnbm.s7.s7connector.type.PlcVar; +import io.swagger.models.auth.In; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +24,8 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; +import java.text.DecimalFormat; +import java.text.Format; import java.time.LocalDateTime; import java.util.Arrays; import java.util.Date; @@ -66,6 +69,7 @@ public class KukaJoinThread implements ApplicationRunner { + /** * return * 成功: 返回相应的object对象 @@ -150,7 +154,9 @@ 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; + + todayBoxNum+=500; + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); return res; } @@ -159,9 +165,13 @@ public class KukaJoinThread implements ApplicationRunner { } public static void main(String[] args) { - String str = "30110012302210707 "; - String substring = str.substring(0,17); - System.out.println(substring); + Integer a = 102; + Format f1 = new DecimalFormat("000"); + System.out.println(f1.format(a)); + } + public String formateString(Integer a){ + Format f1 = new DecimalFormat("000"); + return f1.format(a); } @Override @@ -209,6 +219,8 @@ public class KukaJoinThread implements ApplicationRunner { woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass()); woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum()); woPackagingBoxSubstrate.setWoSubstrateId(subId); + woPackagingBoxSubstrate.setActualPmpp(pmppBySubId); + woPackagingBoxSubstrate.setCreateTime(LocalDateTime.now()); //5. 从camline那里获取可变字段 CamlineExtendArgDTO extendArgFromCamline = service.getExtendArgFromCamline(subId); @@ -271,7 +283,6 @@ public class KukaJoinThread implements ApplicationRunner { try { //调度开始 - Integer shelfIsFull = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, true); if(shelfIsFull != 1){ logger.info("失败"+" --- "+"MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败"); diff --git a/ym-packing/src/main/java/com/cnbm/packing/controller/TestController.java b/ym-packing/src/main/java/com/cnbm/packing/controller/TestController.java index 68bfab4..00b119d 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/controller/TestController.java +++ b/ym-packing/src/main/java/com/cnbm/packing/controller/TestController.java @@ -7,6 +7,7 @@ import com.cnbm.dispatch.enums.kuka.step2.Step2Plc2MesVar; import com.cnbm.dispatch.enums.kuka.step3.Step3Mes2PlcVar; import com.cnbm.dispatch.enums.kuka.step3.Step3Plc2MesVar; import com.cnbm.packing.dto.CamlineSubIdDTO; +import com.cnbm.packing.dto.CamlineSubIdForImportDTO; import com.cnbm.packing.entity.WoPackagingBoxSubstrate; import com.cnbm.packing.service.DynamicDataSourceService; import com.cnbm.packing.service.WoPackagingBoxSubstrateServiceBiz; @@ -27,6 +28,7 @@ import java.io.UnsupportedEncodingException; import java.math.BigDecimal; import java.text.ParseException; import java.util.Arrays; +import java.util.List; import java.util.Map; @@ -107,6 +109,21 @@ public class TestController { System.out.println(Step2Plc2MesVar.SubIdList.getName()+" : "+Arrays.toString(s)); return R.ok(); } + @PostMapping("/forImport") + public R forImport() throws UnsupportedEncodingException, ParseException { + List alllCamlineSubForImp = service.getAlllCamlineSubForImp(); + for(CamlineSubIdForImportDTO cam:alllCamlineSubForImp){ + WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate(); + woPackagingBoxSubstrate.setWoSubstrateId(cam.getSubId()); + woPackagingBoxSubstrate.setLineBody(2); + woPackagingBoxSubstrate.setPowerLevel(cam.getPowerLevel()); + woPackagingBoxSubstrate.setOrderName(cam.getOrderName()); + woPackagingBoxSubstrate.setSapMaterial(cam.getSapMaterial()); + substrateServiceBiz.insert(woPackagingBoxSubstrate); + } + return R.ok(); + } + @PostMapping("/testReadAll") public R testReadAll() throws UnsupportedEncodingException, ParseException { for(Step1Plc2MesVar actual:Step1Plc2MesVar.values()){ @@ -205,6 +222,7 @@ public class TestController { } + @PostMapping("getPMPPBySubId") @ApiImplicitParams({ @ApiImplicitParam(name = "subId", value = "基板ID", paramType = "query", required = true, dataTypeClass=Integer.class) , diff --git a/ym-packing/src/main/java/com/cnbm/packing/dto/CamlineSubIdForImportDTO.java b/ym-packing/src/main/java/com/cnbm/packing/dto/CamlineSubIdForImportDTO.java new file mode 100644 index 0000000..b85b4af --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/packing/dto/CamlineSubIdForImportDTO.java @@ -0,0 +1,28 @@ +package com.cnbm.packing.dto; + +import io.swagger.annotations.ApiModel; +import lombok.Data; + +import java.io.Serializable; + + +/** + * 打印标签模板表 + * + * @author codeGenerator + * @since 2023-02-20 + */ +@Data +@ApiModel(value = "camline 查询对象") +public class CamlineSubIdForImportDTO implements Serializable { + + private static final long serialVersionUID = 1L; + + private String subId; + private String powerLevel; + + private String sapMaterial; + + private String orderName; + +} \ No newline at end of file diff --git a/ym-packing/src/main/java/com/cnbm/packing/mapper/CamlineMapper.java b/ym-packing/src/main/java/com/cnbm/packing/mapper/CamlineMapper.java index f5a00c8..5daa7dd 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/mapper/CamlineMapper.java +++ b/ym-packing/src/main/java/com/cnbm/packing/mapper/CamlineMapper.java @@ -2,6 +2,7 @@ package com.cnbm.packing.mapper; import com.cnbm.packing.dto.CamlineExtendArgDTO; import com.cnbm.packing.dto.CamlineSubIdDTO; +import com.cnbm.packing.dto.CamlineSubIdForImportDTO; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -29,4 +30,6 @@ public interface CamlineMapper { Integer getTodayBoxNum(); CamlineSubIdDTO getSubIdByCamline(@Param("subId") String subId); + + List getSubIdByCamlineForImpoet(); } \ 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 7d62c31..2117e3a 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 @@ -3,6 +3,7 @@ package com.cnbm.packing.service; import com.cnbm.dynamic.datasource.annotation.DataSource; import com.cnbm.packing.dto.CamlineExtendArgDTO; import com.cnbm.packing.dto.CamlineSubIdDTO; +import com.cnbm.packing.dto.CamlineSubIdForImportDTO; import com.cnbm.packing.dto.WoPowerLevelDTO; import com.cnbm.packing.mapper.CamlineMapper; @@ -54,4 +55,10 @@ public class DynamicDataSourceService { return mapper.getExtendArgFromCamline(subId); } + @DataSource("camline") + @Transactional + public List getAlllCamlineSubForImp(){ + return mapper.getSubIdByCamlineForImpoet(); + } + } diff --git a/ym-packing/src/main/resources/mapper/CamlineMapper.xml b/ym-packing/src/main/resources/mapper/CamlineMapper.xml index 93e5311..e139c79 100644 --- a/ym-packing/src/main/resources/mapper/CamlineMapper.xml +++ b/ym-packing/src/main/resources/mapper/CamlineMapper.xml @@ -11,6 +11,12 @@ + + + + + + @@ -58,16 +64,15 @@ @@ -137,6 +142,94 @@ and tu.name = #{subId} + + select * from t_wo_packaging_box_substrate @@ -81,5 +88,35 @@ where WO_SUBSTRATE_ID = #{woSubstrateId,jdbcType=VARCHAR} + + + +