From bb8986c98de7a9b9ac607faacbdf567f0511c597 Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Mon, 27 Feb 2023 15:49:58 +0800 Subject: [PATCH 1/4] mark --- .../src/main/resources/mapper/SysDeptDao.xml | 9 ++++----- .../main/resources/mapper/SysDictDataDao.xml | 2 +- .../main/resources/mapper/SysDictTypeDao.xml | 2 +- .../src/main/resources/mapper/SysMenuDao.xml | 6 +++--- .../src/main/resources/mapper/SysParamsDao.xml | 5 ++--- .../resources/mapper/SysRoleDataScopeDao.xml | 4 +--- .../main/resources/mapper/SysRoleMenuDao.xml | 5 ++--- .../main/resources/mapper/SysRoleUserDao.xml | 4 +--- .../src/main/resources/mapper/SysUserDao.xml | 11 +++++------ .../src/main/resources/application-dev.yml | 18 +++++++++--------- .../java/com/cnbm/dispatch/KukaJoinThread.java | 12 ++++++------ 11 files changed, 35 insertions(+), 43 deletions(-) diff --git a/ym-admin/src/main/resources/mapper/SysDeptDao.xml b/ym-admin/src/main/resources/mapper/SysDeptDao.xml index 5101128..a558f10 100644 --- a/ym-admin/src/main/resources/mapper/SysDeptDao.xml +++ b/ym-admin/src/main/resources/mapper/SysDeptDao.xml @@ -6,9 +6,8 @@ select t1.*,(select t2.name from sys_dept t2 where t2.id=t1.pid)parentName from sys_dept t1 - where t1.id = #{value} AND t1.valid = 1 + where t1.id = #{value} \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysDictDataDao.xml b/ym-admin/src/main/resources/mapper/SysDictDataDao.xml index 8c88067..fa2f89f 100644 --- a/ym-admin/src/main/resources/mapper/SysDictDataDao.xml +++ b/ym-admin/src/main/resources/mapper/SysDictDataDao.xml @@ -4,7 +4,7 @@ \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml b/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml index e2863a1..0698e4e 100644 --- a/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml +++ b/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml @@ -4,7 +4,7 @@ \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysMenuDao.xml b/ym-admin/src/main/resources/mapper/SysMenuDao.xml index a831e30..078d5a4 100644 --- a/ym-admin/src/main/resources/mapper/SysMenuDao.xml +++ b/ym-admin/src/main/resources/mapper/SysMenuDao.xml @@ -5,7 +5,7 @@ select t3.permissions from sys_role_user t1 left join sys_role_menu t2 on t1.role_id = t2.role_id - left join sys_menu t3 on t2.menu_id = t3.id + left join sys_menu t3 on t2.menu_id = t3.id where t1.user_id = #{userId} AND t1.valid = 1 order by t3.sort asc @@ -43,5 +43,5 @@ - + \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysParamsDao.xml b/ym-admin/src/main/resources/mapper/SysParamsDao.xml index 3bbf120..3ada3b6 100644 --- a/ym-admin/src/main/resources/mapper/SysParamsDao.xml +++ b/ym-admin/src/main/resources/mapper/SysParamsDao.xml @@ -5,7 +5,7 @@ @@ -14,11 +14,10 @@ #{id} - AND valid = 1 - update sys_params set param_value = #{paramValue} where param_code = #{paramCode} AND valid = 1 + update sys_params set param_value = #{paramValue} where param_code = #{paramCode} \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml b/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml index 60c96d4..e01c48a 100644 --- a/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml +++ b/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml @@ -4,13 +4,12 @@ @@ -18,7 +17,6 @@ #{roleId} - AND valid = 1 \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml b/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml index 8ceb0f2..aa4261a 100644 --- a/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml +++ b/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml @@ -4,7 +4,7 @@ @@ -12,10 +12,9 @@ #{roleId} - AND valid = 1 - delete from sys_role_menu where menu_id = #{value} AND valid = 1 + delete from sys_role_menu where menu_id = #{value} \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml b/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml index 0380ae0..1ece0b5 100644 --- a/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml +++ b/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml @@ -8,7 +8,6 @@ #{roleId} - AND valid = 1 @@ -16,11 +15,10 @@ #{userId} - AND valid = 1 \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysUserDao.xml b/ym-admin/src/main/resources/mapper/SysUserDao.xml index 399968f..c305412 100644 --- a/ym-admin/src/main/resources/mapper/SysUserDao.xml +++ b/ym-admin/src/main/resources/mapper/SysUserDao.xml @@ -5,7 +5,7 @@ select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName from sys_user t1 - where t1.id = #{value} AND t1.valid = 1 + where t1.id = #{value} - update sys_user set password = #{newPassword} where id = #{id} AND valid = 1 + update sys_user set password = #{newPassword} where id = #{id} \ No newline at end of file diff --git a/ym-gateway/src/main/resources/application-dev.yml b/ym-gateway/src/main/resources/application-dev.yml index d85aabd..3bbe591 100644 --- a/ym-gateway/src/main/resources/application-dev.yml +++ b/ym-gateway/src/main/resources/application-dev.yml @@ -61,14 +61,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-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java index 41c714d..bf0016a 100644 --- a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java +++ b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java @@ -150,12 +150,12 @@ public class KukaJoinThread implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { - kukaStep1.scheduleAtFixedRate(new Runnable() { - @Override - public void run() { - logger.info("================= 现在开始执行 过程一 任务 =================="); - } - },1,1, TimeUnit.SECONDS); +// kukaStep1.scheduleAtFixedRate(new Runnable() { +// @Override +// public void run() { +// logger.info("================= 现在开始执行 过程一 任务 =================="); +// } +// },1,1, TimeUnit.SECONDS); From 14745366be9d5ab84dca983d55aefde4f11be0a7 Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Wed, 1 Mar 2023 12:05:06 +0800 Subject: [PATCH 2/4] commit for pull --- ym-admin/src/main/resources/mapper/SysDeptDao.xml | 9 +++++---- ym-admin/src/main/resources/mapper/SysDictDataDao.xml | 2 +- ym-admin/src/main/resources/mapper/SysDictTypeDao.xml | 2 +- ym-admin/src/main/resources/mapper/SysMenuDao.xml | 6 +++--- ym-admin/src/main/resources/mapper/SysParamsDao.xml | 5 +++-- .../src/main/resources/mapper/SysRoleDataScopeDao.xml | 4 +++- ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml | 5 +++-- ym-admin/src/main/resources/mapper/SysRoleUserDao.xml | 4 +++- ym-admin/src/main/resources/mapper/SysUserDao.xml | 11 ++++++----- 9 files changed, 28 insertions(+), 20 deletions(-) diff --git a/ym-admin/src/main/resources/mapper/SysDeptDao.xml b/ym-admin/src/main/resources/mapper/SysDeptDao.xml index a558f10..5101128 100644 --- a/ym-admin/src/main/resources/mapper/SysDeptDao.xml +++ b/ym-admin/src/main/resources/mapper/SysDeptDao.xml @@ -6,8 +6,9 @@ select t1.*,(select t2.name from sys_dept t2 where t2.id=t1.pid)parentName from sys_dept t1 - where t1.id = #{value} + where t1.id = #{value} AND t1.valid = 1 \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysDictDataDao.xml b/ym-admin/src/main/resources/mapper/SysDictDataDao.xml index fa2f89f..8c88067 100644 --- a/ym-admin/src/main/resources/mapper/SysDictDataDao.xml +++ b/ym-admin/src/main/resources/mapper/SysDictDataDao.xml @@ -4,7 +4,7 @@ \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml b/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml index 0698e4e..e2863a1 100644 --- a/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml +++ b/ym-admin/src/main/resources/mapper/SysDictTypeDao.xml @@ -4,7 +4,7 @@ \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysMenuDao.xml b/ym-admin/src/main/resources/mapper/SysMenuDao.xml index 078d5a4..a831e30 100644 --- a/ym-admin/src/main/resources/mapper/SysMenuDao.xml +++ b/ym-admin/src/main/resources/mapper/SysMenuDao.xml @@ -5,7 +5,7 @@ select t3.permissions from sys_role_user t1 left join sys_role_menu t2 on t1.role_id = t2.role_id - left join sys_menu t3 on t2.menu_id = t3.id + left join sys_menu t3 on t2.menu_id = t3.id where t1.user_id = #{userId} AND t1.valid = 1 order by t3.sort asc @@ -43,5 +43,5 @@ - + \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysParamsDao.xml b/ym-admin/src/main/resources/mapper/SysParamsDao.xml index 3ada3b6..3bbf120 100644 --- a/ym-admin/src/main/resources/mapper/SysParamsDao.xml +++ b/ym-admin/src/main/resources/mapper/SysParamsDao.xml @@ -5,7 +5,7 @@ @@ -14,10 +14,11 @@ #{id} + AND valid = 1 - update sys_params set param_value = #{paramValue} where param_code = #{paramCode} + update sys_params set param_value = #{paramValue} where param_code = #{paramCode} AND valid = 1 \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml b/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml index e01c48a..60c96d4 100644 --- a/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml +++ b/ym-admin/src/main/resources/mapper/SysRoleDataScopeDao.xml @@ -4,12 +4,13 @@ @@ -17,6 +18,7 @@ #{roleId} + AND valid = 1 \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml b/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml index aa4261a..8ceb0f2 100644 --- a/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml +++ b/ym-admin/src/main/resources/mapper/SysRoleMenuDao.xml @@ -4,7 +4,7 @@ @@ -12,9 +12,10 @@ #{roleId} + AND valid = 1 - delete from sys_role_menu where menu_id = #{value} + delete from sys_role_menu where menu_id = #{value} AND valid = 1 \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml b/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml index 1ece0b5..0380ae0 100644 --- a/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml +++ b/ym-admin/src/main/resources/mapper/SysRoleUserDao.xml @@ -8,6 +8,7 @@ #{roleId} + AND valid = 1 @@ -15,10 +16,11 @@ #{userId} + AND valid = 1 \ No newline at end of file diff --git a/ym-admin/src/main/resources/mapper/SysUserDao.xml b/ym-admin/src/main/resources/mapper/SysUserDao.xml index c305412..399968f 100644 --- a/ym-admin/src/main/resources/mapper/SysUserDao.xml +++ b/ym-admin/src/main/resources/mapper/SysUserDao.xml @@ -5,7 +5,7 @@ select t1.*, (select t2.name from sys_dept t2 where t2.id=t1.dept_id) deptName from sys_user t1 - where t1.id = #{value} + where t1.id = #{value} AND t1.valid = 1 - update sys_user set password = #{newPassword} where id = #{id} + update sys_user set password = #{newPassword} where id = #{id} AND valid = 1 \ No newline at end of file From ce721696fab2d10f441845e41efcf5308fd8603d Mon Sep 17 00:00:00 2001 From: thomas Date: Wed, 1 Mar 2023 14:06:46 +0800 Subject: [PATCH 3/4] =?UTF-8?q?feat:=20:rocket:=20=E6=B7=BB=E5=8A=A0?= =?UTF-8?q?=E9=83=A8=E7=BD=B2master=E5=88=86=E6=94=AF=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .drone.yml | 8 ++++---- Dockerfile | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/.drone.yml b/.drone.yml index 3dca087..97992e1 100644 --- a/.drone.yml +++ b/.drone.yml @@ -11,16 +11,16 @@ steps: - name: dockerconfig path: /root/.docker commands: - - docker build -t harbor.picaiba.com/kszny/mes-api:1.0.0-india ./ && docker push harbor.picaiba.com/kszny/mes-api:1.0.0-india + - docker build -t harbor.picaiba.com/kszny/mes-api:1.0.0-cigs4 ./ && docker push harbor.picaiba.com/kszny/mes-api:1.0.0-cigs4 - name: deploy image: harbor.picaiba.com/tools/kubectl commands: - echo "172.27.0.20 lb.kubesphere.local" >> /etc/hosts - sleep 1 - - kubectl scale --replicas=0 deployment/mes-api -n mes-india + - kubectl scale --replicas=0 deployment/mes-api -n mes-cigs4 - sleep 3 - - kubectl scale --replicas=1 deployment/mes-api -n mes-india + - kubectl scale --replicas=1 deployment/mes-api -n mes-cigs4 depends_on: - build @@ -34,6 +34,6 @@ volumes: trigger: branch: - - porject/yd-monitor + - master event: - push diff --git a/Dockerfile b/Dockerfile index b764535..db5986e 100644 --- a/Dockerfile +++ b/Dockerfile @@ -49,7 +49,7 @@ ENV TZ="Asia/Shanghai" RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && echo $TZ > /etc/timezone # 定义一些环境变量,方便环境变量传参 ENV JVM_OPTS="" -ENV JAVA_OPTS="-Dspring.profiles.active=dev" +ENV JAVA_OPTS="" # 指定暴露的端口,起到说明的作用,不指定也会暴露对应端口 EXPOSE 8080 # 启动 jar 的命令 From 550a2f796b1841a1cd11af657cd6316fa607e8b6 Mon Sep 17 00:00:00 2001 From: caixiang <939387484@qq.com> Date: Wed, 1 Mar 2023 17:06:24 +0800 Subject: [PATCH 4/4] commit --- .../com/cnbm/dispatch/KukaJoinThread.java | 376 +++++++++--------- .../packing/controller/TestController.java | 77 ++++ .../cnbm/s7/s7connector/enmuc/S7Client.java | 4 +- 3 files changed, 266 insertions(+), 191 deletions(-) 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 bf0016a..b9f45e9 100644 --- a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java +++ b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java @@ -7,6 +7,10 @@ import com.cnbm.dispatch.enums.kuka.step2.Step2Mes2PlcVar; 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.entity.WoPackagingBox; +import com.cnbm.packing.entity.WoPackagingBoxSubstrate; +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; @@ -18,6 +22,8 @@ import org.springframework.boot.ApplicationRunner; import org.springframework.core.annotation.Order; import org.springframework.stereotype.Component; +import java.time.LocalDateTime; +import java.util.Arrays; import java.util.Date; import java.util.concurrent.Executors; import java.util.concurrent.ScheduledExecutorService; @@ -150,199 +156,191 @@ public class KukaJoinThread implements ApplicationRunner { @Override public void run(ApplicationArguments args) throws Exception { -// kukaStep1.scheduleAtFixedRate(new Runnable() { -// @Override -// public void run() { + kukaStep1.scheduleAtFixedRate(new Runnable() { + @Override + public void run() { + //调度开始 +// logger.info(""); // logger.info("================= 现在开始执行 过程一 任务 =================="); -// } -// },1,1, TimeUnit.SECONDS); + 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); + //二. 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()); -// kukaStep1.scheduleAtFixedRate(new Runnable() { -// @Override -// public void run() { -// //调度开始 -//// logger.info(""); -//// logger.info("================= 现在开始执行 过程一 任务 =================="); -// 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); -// logger.info("采集到 基板ID: "+subId+", 线边号:"+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()); -// -// -// -// //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); -// -// -// kukaStep2.scheduleAtFixedRate(new Runnable() { -// @Override -// public void run() { -// //调度开始 -// -// 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); -// logger.info("获取到基板列表:"+ Arrays.toString(subIdList)); -// -// //二. MES 业务 -// //=============== MES 业务 开始 ================= -// //1.MES 生成BoxId -// if(subIdList.length<=0){ -// logger.info("失败"+" --- "+"从plc里面获取到的基板列表 为空"); -// } -// WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIdList[0]); -// String boxId = getBoxId(bySubId.getSapMaterial()); -// logger.info("mes 生成的boxId :"+ boxId); -// //2. 依次update 基板表,把boxId 赋予这些基板 -// for(int i=0;i().ok(service.getExtendArgFromCamline(subId.toString()).toString()); } + private void write(S7Client s7Client, Step1Mes2PlcVar var, Object newValue) { + if(var.getType().equals(PlcVar.STRING_Array)){ + String[] s = (String[])newValue; + String[] ss = (String[])newValue; + if(s.length > var.getLength() ){ + ss = new String[var.getLength()]; + for(int i=0;i< var.getLength();i++){ + ss[i] = s[i]; + } + } + s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); + }else { + s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); + } + } + private void write(S7Client s7Client, Step2Mes2PlcVar var, Object newValue) { + if(var.getType().equals(PlcVar.STRING_Array)){ + String[] s = (String[])newValue; + String[] ss = (String[])newValue; + if(s.length > var.getLength() ){ + ss = new String[var.getLength()]; + for(int i=0;i< var.getLength();i++){ + ss[i] = s[i]; + } + } + s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); + }else { + s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); + } + } + + private void write(S7Client s7Client, Step3Mes2PlcVar var, Object newValue) { + if(var.getType().equals(PlcVar.STRING_Array)){ + String[] s = (String[])newValue; + String[] ss = (String[])newValue; + if(s.length > var.getLength() ){ + ss = new String[var.getLength()]; + for(int i=0;i< var.getLength();i++){ + ss[i] = s[i]; + } + } + s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); + }else { + s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); + } + } + } 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 e2b60ac..6c32fd8 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 @@ -178,7 +178,7 @@ public enum S7Client { ); return type.toObject(read); } - }catch (Exception e) { + }catch (Throwable e) { throw new S7CheckResultException("read errMsg : "+e.getMessage()); } @@ -293,7 +293,7 @@ public enum S7Client { ); } return null; - }catch (Exception e) { + }catch (Throwable e) { throw new S7CheckResultException("write errMsg : "+e.getMessage()); } },