diff --git a/README.md b/README.md index 185a4bd..3ce7b96 100644 --- a/README.md +++ b/README.md @@ -26,4 +26,11 @@ - Maven3.0+ - MySQL8.0 - redis6.0+ -
\ No newline at end of file +
+ + +**切换到现场环境** +- gateway 下的 application.yml 改redis地址 改成10.0.1.249那个 +- gateway 下的 application-dev.yml 选用 “MySQL-local” 和 “camline系统 - local” 这两个 +- packaging 下的 KukaJoinThread 要把 三个启动线程放开(kukaStep1.scheduleAtFixedRate、kukaStep2.scheduleAtFixedRate、kukaStep3.scheduleAtFixedRate) +
\ No newline at end of file diff --git a/pom.xml b/pom.xml index ff07845..66fe715 100644 --- a/pom.xml +++ b/pom.xml @@ -38,7 +38,10 @@ 4.13.2 4.2.2 1.2.9 - 3.5.1 + + + 3.5.3 + 4.0 11.2.0.3 3.12.0 diff --git a/ym-gateway/src/main/resources/logback.xml b/ym-gateway/src/main/resources/logback.xml index 9107c9c..73a96a9 100644 --- a/ym-gateway/src/main/resources/logback.xml +++ b/ym-gateway/src/main/resources/logback.xml @@ -15,6 +15,7 @@ + @@ -193,6 +194,206 @@ DENY + + + + ${logging.eventlog}/line2/event1/kuka-event1-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line2/kuka-event1-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + ${logging.eventlog}/line2/event2/kuka-event2-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line2/kuka-event2-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + ${logging.eventlog}/line2/event3/kuka-event3-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line2/kuka-event3-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + + + + ${logging.eventlog}/line1/event1/kuka-event1-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line1/kuka-event1-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + ${logging.eventlog}/line1/event2/kuka-event2-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line1/kuka-event2-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + ${logging.eventlog}/line1/event3/kuka-event3-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line1/kuka-event3-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + + + + ${logging.eventlog}/line1/event4/kuka-ngEvent-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line1/kuka-ngEvent-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + + + ${logging.eventlog}/line2/event4/kuka-ngEvent-log-info.log + + + %d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n + UTF-8 + + + + ${logging.eventlog}/line2/kuka-ngEvent-log-info-%d{yyyy-MM-dd}.%i.log + + 100MB + + 999 + 200GB + + + + info + ACCEPT + DENY + + + @@ -405,7 +606,41 @@ - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java b/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java deleted file mode 100644 index d498bf1..0000000 --- a/ym-packing/src/main/java/com/cnbm/dispatch/KukaJoinThread.java +++ /dev/null @@ -1,539 +0,0 @@ -//package com.cnbm.dispatch; -// -//import cn.hutool.core.date.DateUtil; -//import com.cnbm.dispatch.enums.kuka.step1.Step1Mes2PlcVar; -//import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar; -//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.dto.CamlineSubIdDTO; -//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; -//import io.swagger.models.auth.In; -//import org.slf4j.Logger; -//import org.slf4j.LoggerFactory; -//import org.springframework.beans.factory.annotation.Autowired; -//import org.springframework.boot.ApplicationArguments; -//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; -//import java.util.concurrent.Executors; -//import java.util.concurrent.ScheduledExecutorService; -//import java.util.concurrent.TimeUnit; -// -///** -// * @Desc: "" -// * @Author: caixiang -// * @DATE: 2022/12/23 12:33 -// */ -//@Component -//@Order(value = 1) -//public class KukaJoinThread implements ApplicationRunner { -// private static final Logger logger = LoggerFactory.getLogger(KukaJoinThread.class); -// -// @Autowired -// DynamicDataSourceService service; -// @Autowired -// WoPowerLevelServiceBiz levelServiceBiz; -// -// @Autowired -// WoCompensationPowerServiceBiz compensationPowerServiceBiz; -// -// @Autowired -// WoPackagingBoxSubstrateServiceBiz substrateServiceBiz; -// -// @Autowired -// WoPackagingBoxServiceBiz boxServiceBiz; -// -// public KukaJoinThread(){ -// this.kukaStep1 = Executors.newScheduledThreadPool(1); -// this.kukaStep2 = Executors.newScheduledThreadPool(1); -// this.kukaStep3 = Executors.newScheduledThreadPool(1); -// } -// -// private ScheduledExecutorService kukaStep1; -// private ScheduledExecutorService kukaStep2; -// private ScheduledExecutorService kukaStep3; -// -// -// -// -// /** -// * return -// * 成功: 返回相应的object对象 -// * 失败: 返回null -// * */ -// private Object read(S7Client s7Client,Step1Plc2MesVar var) { -// try { -// return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); -// }catch (Exception e){ -// logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); -// e.printStackTrace(); -// return null; -// } -// } -// 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { -// try { -// return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); -// }catch (Exception e){ -// logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); -// e.printStackTrace(); -// return null; -// } -// } -// 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { -// try { -// return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); -// }catch (Exception e){ -// logger.error("host:"+s7Client.getHost()+" ; read 操作出现问题: "+e.getMessage()); -// e.printStackTrace(); -// return null; -// } -// } -// 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); -// } -// } -// -// -// public String getBoxId(String sapMaterial){ -// Integer todayBoxNum = service.getTodayBoxNum()+1; -// String nowTime = DateUtil.format(new Date(), "yyMMdd"); -// -// todayBoxNum+=500; -// String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); -// 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){ -// return str.substring(0,17); -// } -// -// public static void main(String[] args) { -// 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); -// } -// -// //return true 出现混档了,return false 没有出现混档 -// private boolean isMixLevel(String[] subIds,Integer size){ -// String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); -// String errMsg = "以下基板ID出现混档:"; -// boolean res = false; -// for(int i=0;i 1 代表数组 ;; 注意 length这个参数 是实际plc中 数组的长度,和read操作相关 + //如果是String 类型不用填length 只需要填string类型的起始位置就行了,我会自己去取数据长度(也就是说这里的length并不是string 的长度)。 + private Integer length; + + //这个字段只是给 字符串变量 和 字符串数组 用, 这个字段是plc中设置的最大String长度 + private Integer strSize; + + Step4Mes2PlcVar(String name, PlcVar type, Integer length, DaveArea area, Integer areaNumber, Integer byteOffset, Integer bitOffset){ + this.name = name; + this.type = type; + this.length = length; + this.area = area; + this.areaNumber = areaNumber; + this.byteOffset = byteOffset; + this.bitOffset = bitOffset; + this.strSize = 0; + } + Step4Mes2PlcVar(String name, PlcVar type, Integer length, DaveArea area, Integer areaNumber, Integer byteOffset, Integer bitOffset, Integer strSize){ + this.name = name; + this.type = type; + this.length = length; + this.area = area; + this.areaNumber = areaNumber; + this.byteOffset = byteOffset; + this.bitOffset = bitOffset; + this.strSize = strSize; + } + + public Integer getStrSize() { + return strSize; + } + + public void setStrSize(Integer strSize) { + this.strSize = strSize; + } + + public String getName() { + return name; + } + + public DaveArea getArea() { + return area; + } + + public Integer getAreaNumber() { + return areaNumber; + } + + public Integer getBitOffset() { + return bitOffset; + } + + public Integer getByteOffset() { + return byteOffset; + } + + public PlcVar getType() { + return type; + } + + public Integer getLength() { + return length; + } +} diff --git a/ym-packing/src/main/java/com/cnbm/dispatch/enums/kuka/step4/Step4Plc2MesVar.java b/ym-packing/src/main/java/com/cnbm/dispatch/enums/kuka/step4/Step4Plc2MesVar.java new file mode 100644 index 0000000..1f3b518 --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/dispatch/enums/kuka/step4/Step4Plc2MesVar.java @@ -0,0 +1,87 @@ +package com.cnbm.dispatch.enums.kuka.step4; + +import com.cnbm.s7.s7connector.api.DaveArea; +import com.cnbm.s7.s7connector.type.PlcVar; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2023/2/21 19:35 + */ +public enum Step4Plc2MesVar { + + SubArrivedToMes("SubArrivedToMes", PlcVar.BOOL,1, DaveArea.DB,2001,0,0), + SubIdToMes("SubIdToMes",PlcVar.STRING,1,DaveArea.DB,2001,2,0,20), + + ; + + private String name; + private DaveArea area; + private Integer areaNumber; + private Integer byteOffset; + private Integer bitOffset; + private PlcVar type; + //length = 1代表 非数组;;; length > 1 代表数组 ;; 注意 length这个参数 是实际plc中 数组的长度,和read操作相关 + //如果是String 类型不用填length 只需要填string类型的起始位置就行了,我会自己去取数据长度(也就是说这里的length并不是string 的长度)。 + private Integer length; + + //这个字段只是给 字符串变量 和 字符串数组 用, 这个字段是plc中设置的最大String长度 + private Integer strSize; + + Step4Plc2MesVar(String name, PlcVar type, Integer length, DaveArea area, Integer areaNumber, Integer byteOffset, Integer bitOffset){ + this.name = name; + this.type = type; + this.length = length; + this.area = area; + this.areaNumber = areaNumber; + this.byteOffset = byteOffset; + this.bitOffset = bitOffset; + this.strSize = 0; + } + Step4Plc2MesVar(String name, PlcVar type, Integer length, DaveArea area, Integer areaNumber, Integer byteOffset, Integer bitOffset, Integer strSize){ + this.name = name; + this.type = type; + this.length = length; + this.area = area; + this.areaNumber = areaNumber; + this.byteOffset = byteOffset; + this.bitOffset = bitOffset; + this.strSize = strSize; + } + + public Integer getStrSize() { + return strSize; + } + + public void setStrSize(Integer strSize) { + this.strSize = strSize; + } + + public String getName() { + return name; + } + + public DaveArea getArea() { + return area; + } + + public Integer getAreaNumber() { + return areaNumber; + } + + public Integer getBitOffset() { + return bitOffset; + } + + public Integer getByteOffset() { + return byteOffset; + } + + public PlcVar getType() { + return type; + } + + public Integer getLength() { + return length; + } +} diff --git a/ym-packing/src/main/java/com/cnbm/dispatch/line1/KukaEvent1ThreadLine1.java b/ym-packing/src/main/java/com/cnbm/dispatch/line1/KukaEvent1ThreadLine1.java new file mode 100644 index 0000000..dda7ec0 --- /dev/null +++ b/ym-packing/src/main/java/com/cnbm/dispatch/line1/KukaEvent1ThreadLine1.java @@ -0,0 +1,416 @@ +package com.cnbm.dispatch.line1; + +import cn.hutool.core.date.DateUtil; +import com.cnbm.dispatch.enums.kuka.step1.Step1Mes2PlcVar; +import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar; +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.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; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +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.Date; +import java.util.concurrent.Executors; +import java.util.concurrent.ScheduledExecutorService; +import java.util.concurrent.TimeUnit; + +/** + * @Desc: "" + * @Author: caixiang + * @DATE: 2022/12/23 12:33 + */ +@Component +@Order(value = 1) +public class KukaEvent1ThreadLine1 implements ApplicationRunner { + private static final Logger logger = LoggerFactory.getLogger("EVENT1Line1"); + + @Autowired + DynamicDataSourceService service; + @Autowired + WoPowerLevelServiceBiz levelServiceBiz; + + @Autowired + WoCompensationPowerServiceBiz compensationPowerServiceBiz; + + @Autowired + WoPackagingBoxSubstrateServiceBiz substrateServiceBiz; + + @Autowired + WoPackagingBoxServiceBiz boxServiceBiz; + + public KukaEvent1ThreadLine1(){ + this.kukaStep1 = Executors.newScheduledThreadPool(1); + } + + private ScheduledExecutorService kukaStep1; + + + + + /** + * return + * 成功: 返回相应的object对象 + * 失败: 返回null + * */ + private Object read(S7Client s7Client,Step1Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + + public String getErrorBoxId(String sapMaterial){ + + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + 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); + } + + //return true 出现混档了,return false 没有出现混档 + private boolean isMixLevel(String[] subIds,Integer size){ + String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); + String errMsg = "以下基板ID出现混档:"; + boolean res = false; + for(int i=0;i 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + Format f1 = new DecimalFormat("000"); + System.out.println(f1.format(todayBoxNum)); + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + + + + public String getErrorBoxId(String sapMaterial){ + Integer todayErrBoxNum = service.getTodayErrBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError+"01"+todayErrBoxNum; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayErrBoxNum:"+todayErrBoxNum); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + Integer a = 102; + Integer b = 1; + Format f1 = new DecimalFormat("000"); + System.out.println(f1.format(a)); + System.out.println(f1.format(b)); + } + public String formateString(Integer a){ + Format f1 = new DecimalFormat("000"); + return f1.format(a); + } + + //return true 出现混档了,return false 没有出现混档 +// private boolean isMixLevel(String[] subIds,Integer size){ +// WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIds[0]); +// String correctLevel = null; +// String powerLevel = null; +// //如果 我们数据库没有 去camline 数据库里面取 -- 开始 +// if(bySubId == null){ +// logger.info("BOXID生成Event-------检查是否混箱时,发现数据库中 无subId:"+ subIds[0]+"现在从camline 系统获取这个基板相关信息"); +// //todo +// CamlineSubIdDTO subIdByCamline = service.getSubIdByCamline(subIds[0]); +// logger.info("BOXID生成Event-------检查是否混箱时,发现数据库中 无subId:"+ subIds[0]+"现在从camline 系统获取这个基板相关信息是:"+subIdByCamline); +// +// correctLevel = subIdByCamline.getPowerLevel(); +// powerLevel = subIdByCamline.getSapMaterial(); +// }else { +// correctLevel = bySubId.getPowerLevel(); +// powerLevel = bySubId.getSapMaterial(); +// } +// String errMsg = "以下基板ID出现混档:"; +// boolean res = false; +// for(int i=0;i 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + + public String getErrorBoxId(String sapMaterial){ + + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + 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); + } + + //return true 出现混档了,return false 没有出现混档 + private boolean isMixLevel(String[] subIds,Integer size){ + String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); + String errMsg = "以下基板ID出现混档:"; + boolean res = false; + for(int i=0;i 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + + public String getErrorBoxId(String sapMaterial){ + + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + 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); + } + + //return true 出现混档了,return false 没有出现混档 + private boolean isMixLevel(String[] subIds,Integer size){ + String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); + String errMsg = "以下基板ID出现混档:"; + boolean res = false; + for(int i=0;i 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + + public String getErrorBoxId(String sapMaterial){ + + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + 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); + } + + //return true 出现混档了,return false 没有出现混档 + private boolean isMixLevel(String[] subIds,Integer size){ + String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); + String errMsg = "以下基板ID出现混档:"; + boolean res = false; + for(int i=0;i 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + +// public String getErrorBoxId(String sapMaterial){ +// +// String nowTime = DateUtil.format(new Date(), "yyMMdd"); +// String mixBoxError = "001"; +// String res = "444"+sapMaterial+nowTime+mixBoxError +"02"; +// logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime); +// +// return res; +// } + + public String getErrorBoxId(String sapMaterial){ + Integer todayErrBoxNum = service.getTodayErrBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError+"02"+todayErrBoxNum; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayErrBoxNum:"+todayErrBoxNum); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + 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); + } + + //return true 出现混档了,return false 没有出现混档 +// private boolean isMixLevel(String[] subIds,Integer size){ +// String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); +// String errMsg = "以下基板ID出现混档:"; +// boolean res = false; +// for(int i=0;i 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + + public String getErrorBoxId(String sapMaterial){ + + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + 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); + } + + //return true 出现混档了,return false 没有出现混档 + private boolean isMixLevel(String[] subIds,Integer size){ + String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); + String errMsg = "以下基板ID出现混档:"; + boolean res = false; + for(int i=0;i 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 Object read(S7Client s7Client, Step2Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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 Object read(S7Client s7Client, Step3Plc2MesVar var) { + try { + return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); + }catch (Throwable e){ + logger.info("host:"+s7Client.getHost()+" ; read 操作出现问题: {}",e.getMessage(),e); + return null; + } + } + 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); + } + } + + + public String getBoxId(String sapMaterial){ + Integer todayBoxNum = service.getTodayBoxNum()+1; + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + + todayBoxNum+=500; + logger.info("BOXID生成Event-------现在生成boxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime+",todayBoxNum:"+formateString(todayBoxNum)); + String res = "301"+sapMaterial+nowTime+formateString(todayBoxNum); + return res; + } + + + public String getErrorBoxId(String sapMaterial){ + + String nowTime = DateUtil.format(new Date(), "yyMMdd"); + String mixBoxError = "001"; + String res = "444"+sapMaterial+nowTime+mixBoxError; + logger.info("BOXID生成Event-------现在生成errBoxId ,sapMaterial: "+sapMaterial+",nowTime:"+nowTime); + + return res; + } + + public String removeKG(String str){ + return str.substring(0,17); + } + + public static void main(String[] args) { + 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); + } + + //return true 出现混档了,return false 没有出现混档 + private boolean isMixLevel(String[] subIds,Integer size){ + String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); + String errMsg = "以下基板ID出现混档:"; + boolean res = false; + for(int i=0;i>().ok(page); } + @GetMapping("{id}") @ApiOperation("信息") @PreAuthorize("@ex.hasAuthority('packing:printModel:info')") 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 b09fea2..835a033 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 @@ -2,7 +2,6 @@ package com.cnbm.packing.controller; import cn.hutool.core.date.DateUtil; import com.baomidou.mybatisplus.core.metadata.IPage; -import com.cnbm.admin.annotation.LogOperation; import com.cnbm.dispatch.enums.kuka.step1.Step1Mes2PlcVar; import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar; import com.cnbm.dispatch.enums.kuka.step2.Step2Mes2PlcVar; @@ -11,16 +10,13 @@ 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.dto.PowerReportDTO; import com.cnbm.packing.dto.WoCompensationPowerDTO; import com.cnbm.packing.entity.WoPackagingBoxSubstrate; import com.cnbm.packing.mapper.WoPackagingBoxSubstrateMapper; -import com.cnbm.packing.param.PowerReportQueryParam; import com.cnbm.packing.param.SubIdQueryParam; import com.cnbm.packing.service.DynamicDataSourceService; import com.cnbm.packing.service.WoPackagingBoxServiceBiz; import com.cnbm.packing.service.WoPackagingBoxSubstrateServiceBiz; -import com.cnbm.packing.vo.PowerReportVo; import com.cnbm.packing.vo.SubIdPageVo; import com.cnbm.s7.entity.R; import com.cnbm.s7.s7connector.enmuc.S7Client; @@ -130,7 +126,7 @@ public class TestController { } @PostMapping("/forString") public R forString() throws UnsupportedEncodingException, ParseException { - String[] s = (String[])read(S7Client.S7_KUKA,Step2Plc2MesVar.SubIdList); + String[] s = (String[])read(S7Client.S7_DDJ1,Step2Plc2MesVar.SubIdList); System.out.println(Step2Plc2MesVar.SubIdList.getName()+" : "+Arrays.toString(s)); return R.ok(); } @@ -241,30 +237,61 @@ public class TestController { @PostMapping("/testReadAll") public R testReadAll() throws UnsupportedEncodingException, ParseException { for(Step1Plc2MesVar actual:Step1Plc2MesVar.values()){ - logger.info(read(S7Client.S7_KUKA,actual).toString()); - System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString()); + logger.info(read(S7Client.S7_DDJ1,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString()); } for(Step1Mes2PlcVar actual:Step1Mes2PlcVar.values()){ - logger.info(read(S7Client.S7_KUKA,actual).toString()); - System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString()); + logger.info(read(S7Client.S7_DDJ1,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString()); } for(Step2Plc2MesVar actual:Step2Plc2MesVar.values()){ - logger.info(read(S7Client.S7_KUKA,actual).toString()); - System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString()); + logger.info(read(S7Client.S7_DDJ1,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString()); } for(Step2Mes2PlcVar actual:Step2Mes2PlcVar.values()){ - logger.info(read(S7Client.S7_KUKA,actual).toString()); - System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString()); + logger.info(read(S7Client.S7_DDJ1,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString()); } for(Step3Plc2MesVar actual:Step3Plc2MesVar.values()){ - logger.info(read(S7Client.S7_KUKA,actual).toString()); - System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString()); + logger.info(read(S7Client.S7_DDJ1,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString()); } for(Step3Mes2PlcVar actual:Step3Mes2PlcVar.values()){ - logger.info(read(S7Client.S7_KUKA,actual).toString()); - System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString()); + logger.info(read(S7Client.S7_DDJ1,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString()); + } + return R.ok(); + } + + @PostMapping("/testReadAll2") + public R testReadAll2() throws UnsupportedEncodingException, ParseException { + for(Step1Plc2MesVar actual:Step1Plc2MesVar.values()){ + logger.info(read(S7Client.S7_DDJ2,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ2,actual).toString()); + } + for(Step1Mes2PlcVar actual:Step1Mes2PlcVar.values()){ + logger.info(read(S7Client.S7_DDJ2,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ2,actual).toString()); + } + + for(Step2Plc2MesVar actual:Step2Plc2MesVar.values()){ + logger.info(read(S7Client.S7_DDJ2,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ2,actual).toString()); + } + for(Step2Mes2PlcVar actual:Step2Mes2PlcVar.values()){ + logger.info(read(S7Client.S7_DDJ2,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ2,actual).toString()); + } + + for(Step3Plc2MesVar actual:Step3Plc2MesVar.values()){ + logger.info(read(S7Client.S7_DDJ2,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ2,actual).toString()); + } + for(Step3Mes2PlcVar actual:Step3Mes2PlcVar.values()){ + logger.info(read(S7Client.S7_DDJ2,actual).toString()); + System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ2,actual).toString()); } return R.ok(); } @@ -280,32 +307,32 @@ public class TestController { BigDecimal isc = new BigDecimal(3.799); BigDecimal vmpp = new BigDecimal(46.799); BigDecimal impp = new BigDecimal(3.0799); - write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Pnom,new Integer(1)); + write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Pnom,new Integer(1)); System.out.println(Step1Mes2PlcVar.dLable_Pnom.getName()+" : "+1); - write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Voc,voc); + write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Voc,voc); System.out.println(Step1Mes2PlcVar.dLable_Voc.getName()+" : "+voc.toPlainString()); - write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Isc,isc); + write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Isc,isc); System.out.println(Step1Mes2PlcVar.dLable_Isc.getName()+" : "+isc.toPlainString()); - write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Vmpp,vmpp); + write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Vmpp,vmpp); System.out.println(Step1Mes2PlcVar.dLable_Vmpp.getName()+" : "+vmpp.toPlainString()); - write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Impp,impp); + write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Impp,impp); System.out.println(Step1Mes2PlcVar.dLable_Impp.getName()+" : "+impp.toPlainString()); - write(S7Client.S7_KUKA,Step2Mes2PlcVar.BoxId,"12345678901111111111"); + write(S7Client.S7_DDJ1,Step2Mes2PlcVar.BoxId,"12345678901111111111"); System.out.println(Step2Mes2PlcVar.BoxId.getName()+" : "+"12345678901111111111"); - write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,true); + write(S7Client.S7_DDJ1,Step1Mes2PlcVar.SubArrivedFinish,true); System.out.println(Step1Mes2PlcVar.SubArrivedFinish.getName()+" : "+"true"); - write(S7Client.S7_KUKA,Step2Mes2PlcVar.ShelfIsFullFinish,false); + write(S7Client.S7_DDJ1,Step2Mes2PlcVar.ShelfIsFullFinish,false); System.out.println(Step2Mes2PlcVar.ShelfIsFullFinish.getName()+" : "+"false"); - write(S7Client.S7_KUKA,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,true); + write(S7Client.S7_DDJ1,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,true); System.out.println(Step3Mes2PlcVar.ShelfIsFullArrivedFinish.getName()+" : "+"true"); diff --git a/ym-packing/src/main/java/com/cnbm/packing/controller/WoPowerLevelController.java b/ym-packing/src/main/java/com/cnbm/packing/controller/WoPowerLevelController.java index bed78dd..cb66219 100644 --- a/ym-packing/src/main/java/com/cnbm/packing/controller/WoPowerLevelController.java +++ b/ym-packing/src/main/java/com/cnbm/packing/controller/WoPowerLevelController.java @@ -52,7 +52,6 @@ public class WoPowerLevelController { @PreAuthorize("@ex.hasAuthority('packing:woPowerLevel:page')") public Result> page(@ApiIgnore @RequestParam Map params){ PageData page = woPowerLevelService.page(params); - return new Result>().ok(page); } @@ -61,7 +60,6 @@ public class WoPowerLevelController { @PreAuthorize("@ex.hasAuthority('packing:woPowerLevel:info')") public Result get(@PathVariable("id") Long id){ WoPowerLevelDTO data = woPowerLevelService.get(id); - return new Result().ok(data); } 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 af7fe1a..cdfd004 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 @@ -28,6 +28,7 @@ public interface CamlineMapper { CamlineExtendArgDTO getExtendArgFromCamline(@Param("subId") String subId); Integer getTodayBoxNum(); + Integer getTodayErrBoxNum(); CamlineSubIdDTO getSubIdByCamline(@Param("subId") String subId); 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 79749a4..b101f4d 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 @@ -31,6 +31,10 @@ public class DynamicDataSourceService { return mapper.getTodayBoxNum(); } + public Integer getTodayErrBoxNum(){ + return mapper.getTodayErrBoxNum(); + } + @DataSource("camline") @Transactional public float getPMPPBySubId(String subId){ diff --git a/ym-packing/src/main/resources/mapper/CamlineMapper.xml b/ym-packing/src/main/resources/mapper/CamlineMapper.xml index b5e8303..0af79b1 100644 --- a/ym-packing/src/main/resources/mapper/CamlineMapper.xml +++ b/ym-packing/src/main/resources/mapper/CamlineMapper.xml @@ -195,5 +195,17 @@ twpb.model = 2 + + + + \ No newline at end of file diff --git a/ym-packing/src/main/resources/mapper/WoCompensationPowerMapper.xml b/ym-packing/src/main/resources/mapper/WoCompensationPowerMapper.xml index eb841ff..13641d8 100644 --- a/ym-packing/src/main/resources/mapper/WoCompensationPowerMapper.xml +++ b/ym-packing/src/main/resources/mapper/WoCompensationPowerMapper.xml @@ -6,7 +6,7 @@ - + @@ -43,7 +43,7 @@ and twcp.actl_pmpp_high ]]> #{param.pmpp} and twcp.actl_pmpp_low #{param.pmpp} - + limit 1 diff --git a/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml b/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml index 6974982..78dd952 100644 --- a/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml +++ b/ym-packing/src/main/resources/mapper/WoPowerLevelMapper.xml @@ -40,6 +40,7 @@ and twpl.pmpp_high ]]> #{param.pmpp} and twpl.pmpp_low #{param.pmpp} + limit 1 diff --git a/ym-s7/pom.xml b/ym-s7/pom.xml index 6145cba..dd7cc87 100644 --- a/ym-s7/pom.xml +++ b/ym-s7/pom.xml @@ -36,5 +36,6 @@ + \ No newline at end of file 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 468a855..0623712 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,8 +27,15 @@ 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,2), - //1500 机架-0 插槽-1 + + //1线 + //S7_DDJ1("10.10.3.152",0,1,2), + S7_DDJ1("10.10.3.154",0,1,2), + //2线 + S7_DDJ2("10.10.3.158",0,1,2), + + +//1500 机架-0 插槽-1 //后续 在这里扩展 多PLC应用。 ; private String host; diff --git a/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7ParamErrorCode.java b/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7ParamErrorCode.java index 5271f2c..240a70d 100644 --- a/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7ParamErrorCode.java +++ b/ym-s7/src/main/java/com/cnbm/s7/s7connector/enmuc/S7ParamErrorCode.java @@ -27,6 +27,7 @@ import java.util.Map; */ public enum S7ParamErrorCode { + ERROR_0x0000((short) 0x0000, "No error"), ERROR_0x0110((short) 0x0110, "Invalid block number"), ERROR_0x0111((short) 0x0111, "Invalid request length"), diff --git a/ym-s7/src/main/java/com/cnbm/s7/s7connector/exception/S7CheckResultException.java b/ym-s7/src/main/java/com/cnbm/s7/s7connector/exception/S7CheckResultException.java index e7ca0de..1c79fc1 100644 --- a/ym-s7/src/main/java/com/cnbm/s7/s7connector/exception/S7CheckResultException.java +++ b/ym-s7/src/main/java/com/cnbm/s7/s7connector/exception/S7CheckResultException.java @@ -15,6 +15,8 @@ limitations under the License. */ package com.cnbm.s7.s7connector.exception; +import io.swagger.models.auth.In; + /** * The Class S7Exception is an exception related to S7 Communication */ @@ -23,6 +25,17 @@ public final class S7CheckResultException extends RuntimeException { /** The Constant serialVersionUID. */ private static final long serialVersionUID = -4761415733559374116L; + public static void main(String[] args) { + + try { + String str = null; + + str.substring(0,17); + }catch (Throwable e){ + e.printStackTrace(); + System.out.println("标签打印Event--- 出现异常 :"+e.toString()); + } + } /** * Instantiates a new s7 exception. */