Compare commits
17 Commits
cbc3983714
...
558e106f17
Author | SHA1 | Date | |
---|---|---|---|
558e106f17 | |||
259970a317 | |||
|
df116253ff | ||
|
11b41b18f1 | ||
|
4e10024bc8 | ||
|
22115af70c | ||
|
1704b2c37b | ||
|
9f78bbe8c3 | ||
|
72aae5c439 | ||
|
d70f19adcd | ||
|
d366d7d922 | ||
|
cabed052a1 | ||
|
18c1c6cc15 | ||
|
0e95d8c1d2 | ||
b0e88370b1 | |||
|
3ff7d7c178 | ||
|
e82bc1161c |
@ -27,3 +27,10 @@
|
|||||||
- MySQL8.0
|
- MySQL8.0
|
||||||
- redis6.0+
|
- redis6.0+
|
||||||
<br>
|
<br>
|
||||||
|
|
||||||
|
|
||||||
|
**切换到现场环境**
|
||||||
|
- gateway 下的 application.yml 改redis地址 改成10.0.1.249那个
|
||||||
|
- gateway 下的 application-dev.yml 选用 “MySQL-local” 和 “camline系统 - local” 这两个
|
||||||
|
- packaging 下的 KukaJoinThread 要把 三个启动线程放开(kukaStep1.scheduleAtFixedRate、kukaStep2.scheduleAtFixedRate、kukaStep3.scheduleAtFixedRate)
|
||||||
|
<br>
|
5
pom.xml
5
pom.xml
@ -38,7 +38,10 @@
|
|||||||
<junit.version>4.13.2</junit.version>
|
<junit.version>4.13.2</junit.version>
|
||||||
<jedis.version>4.2.2</jedis.version>
|
<jedis.version>4.2.2</jedis.version>
|
||||||
<druid.version>1.2.9</druid.version>
|
<druid.version>1.2.9</druid.version>
|
||||||
<mybatisplus.version>3.5.1</mybatisplus.version>
|
|
||||||
|
<!-- <mybatisplus.version>3.5.1</mybatisplus.version>-->
|
||||||
|
<mybatisplus.version>3.5.3</mybatisplus.version>
|
||||||
|
|
||||||
<sqlserver.version>4.0</sqlserver.version>
|
<sqlserver.version>4.0</sqlserver.version>
|
||||||
<oracle.version>11.2.0.3</oracle.version>
|
<oracle.version>11.2.0.3</oracle.version>
|
||||||
<commons.lang.version>3.12.0</commons.lang.version>
|
<commons.lang.version>3.12.0</commons.lang.version>
|
||||||
|
@ -75,7 +75,11 @@ public class SecurityConfig extends WebSecurityConfigurerAdapter {
|
|||||||
"/test/**",
|
"/test/**",
|
||||||
"/**/expert",
|
"/**/expert",
|
||||||
"/captcha",
|
"/captcha",
|
||||||
"druid/**").anonymous()
|
"druid/**",
|
||||||
|
"/packing/woPackagingBox/page",
|
||||||
|
"/packing/printModel/page"
|
||||||
|
|
||||||
|
).anonymous()
|
||||||
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
// .antMatchers("/testCors").hasAuthority("system:dept:list222")
|
||||||
// 除上面外的所有请求全部需要鉴权认证
|
// 除上面外的所有请求全部需要鉴权认证
|
||||||
.anyRequest()
|
.anyRequest()
|
||||||
|
@ -2,7 +2,7 @@ spring:
|
|||||||
datasource:
|
datasource:
|
||||||
#MySQL
|
#MySQL
|
||||||
driver-class-name: com.mysql.cj.jdbc.Driver
|
driver-class-name: com.mysql.cj.jdbc.Driver
|
||||||
url: jdbc:mysql://mysql.picaiba.com:30307/ym_pass?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true
|
||||||
username: root
|
username: root
|
||||||
password: 1qaz@WSX3edc$RFV
|
password: 1qaz@WSX3edc$RFV
|
||||||
# #Oracle
|
# #Oracle
|
||||||
|
@ -15,6 +15,7 @@
|
|||||||
<!-- <property name="logging.eqlog" value="C:/qgs_logger/s7" />-->
|
<!-- <property name="logging.eqlog" value="C:/qgs_logger/s7" />-->
|
||||||
|
|
||||||
<property name="logging.eqlog" value="/var/log/logger/EQCommunicationLog" />
|
<property name="logging.eqlog" value="/var/log/logger/EQCommunicationLog" />
|
||||||
|
<property name="logging.eventlog" value="/var/log/logger/EventLog" />
|
||||||
<property name="logging.packing" value="/var/log/logger/Packing" />
|
<property name="logging.packing" value="/var/log/logger/Packing" />
|
||||||
<property name="logging.pathwork" value="/var/log/logger/Working" />
|
<property name="logging.pathwork" value="/var/log/logger/Working" />
|
||||||
|
|
||||||
@ -193,6 +194,206 @@
|
|||||||
<onMismatch>DENY</onMismatch>
|
<onMismatch>DENY</onMismatch>
|
||||||
</filter>
|
</filter>
|
||||||
</appender>
|
</appender>
|
||||||
|
<!-- 2线 开始 -->
|
||||||
|
<appender name="EVENT1_APPENDER_LINE2" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line2/event1/kuka-event1-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line2/kuka-event1-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<appender name="EVENT2_APPENDER_LINE2" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line2/event2/kuka-event2-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line2/kuka-event2-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<appender name="EVENT3_APPENDER_LINE2" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line2/event3/kuka-event3-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line2/kuka-event3-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<!-- 2线 结束 -->
|
||||||
|
|
||||||
|
<!-- 1线 开始 -->
|
||||||
|
<appender name="EVENT1_APPENDER_LINE1" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line1/event1/kuka-event1-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line1/kuka-event1-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<appender name="EVENT2_APPENDER_LINE1" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line1/event2/kuka-event2-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line1/kuka-event2-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<appender name="EVENT3_APPENDER_LINE1" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line1/event3/kuka-event3-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line1/kuka-event3-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<!-- 1线 结束 -->
|
||||||
|
|
||||||
|
<!-- event4 开始 -->
|
||||||
|
<appender name="EVENT4_APPENDER_LINE1" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line1/event4/kuka-ngEvent-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line1/kuka-ngEvent-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<appender name="EVENT4_APPENDER_LINE2" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
|
<!-- 正在记录的日志文档的路径及文档名 -->
|
||||||
|
<file>${logging.eventlog}/line2/event4/kuka-ngEvent-log-info.log</file>
|
||||||
|
<!--日志文档输出格式-->
|
||||||
|
<encoder>
|
||||||
|
<pattern>%d{yyyy-MM-dd HH:mm:ss.SSS} [%thread] %-5level %logger{50} - %msg%n</pattern>
|
||||||
|
<charset>UTF-8</charset>
|
||||||
|
</encoder>
|
||||||
|
<rollingPolicy class="ch.qos.logback.core.rolling.SizeAndTimeBasedRollingPolicy">
|
||||||
|
<!-- rollover daily -->
|
||||||
|
<fileNamePattern>${logging.eventlog}/line2/kuka-ngEvent-log-info-%d{yyyy-MM-dd}.%i.log</fileNamePattern>
|
||||||
|
<!-- each file should be at most 100MB, keep 60 days worth of history, but at most 20GB -->
|
||||||
|
<maxFileSize>100MB</maxFileSize>
|
||||||
|
|
||||||
|
<maxHistory>999</maxHistory>
|
||||||
|
<totalSizeCap>200GB</totalSizeCap>
|
||||||
|
</rollingPolicy>
|
||||||
|
<!-- 此日志文档只记录info级别的 -->
|
||||||
|
<filter class="ch.qos.logback.classic.filter.LevelFilter">
|
||||||
|
<level>info</level>
|
||||||
|
<onMatch>ACCEPT</onMatch>
|
||||||
|
<onMismatch>DENY</onMismatch>
|
||||||
|
</filter>
|
||||||
|
</appender>
|
||||||
|
<!-- event4 结束 -->
|
||||||
|
|
||||||
<!-- 2.3 level为 WARN 日志,时间滚动输出 -->
|
<!-- 2.3 level为 WARN 日志,时间滚动输出 -->
|
||||||
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
<appender name="WARN_FILE" class="ch.qos.logback.core.rolling.RollingFileAppender">
|
||||||
@ -405,7 +606,41 @@
|
|||||||
<appender-ref ref="EQ_COMM_LOG_ERROR_FILE" />
|
<appender-ref ref="EQ_COMM_LOG_ERROR_FILE" />
|
||||||
</logger>
|
</logger>
|
||||||
|
|
||||||
<logger name="com.cnbm.packing" additivity="false">
|
<!-- LINE2 开始 -->
|
||||||
|
<logger name="EVENT1Line2" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT1_APPENDER_LINE2" />
|
||||||
|
</logger>
|
||||||
|
<logger name="EVENT2Line2" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT2_APPENDER_LINE2" />
|
||||||
|
</logger>
|
||||||
|
<logger name="EVENT3Line2" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT3_APPENDER_LINE2" />
|
||||||
|
</logger>
|
||||||
|
<!-- LINE2 结束 -->
|
||||||
|
|
||||||
|
<!-- LINE4NG 开始 -->
|
||||||
|
<logger name="EVENT4NGLine1" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT4_APPENDER_LINE1" />
|
||||||
|
</logger>
|
||||||
|
<logger name="EVENT4NGLine2" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT4_APPENDER_LINE2" />
|
||||||
|
</logger>
|
||||||
|
<!-- LINE4NG 结束 -->
|
||||||
|
|
||||||
|
<!-- LINE1 开始 -->
|
||||||
|
<logger name="EVENT1Line1" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT1_APPENDER_LINE1" />
|
||||||
|
</logger>
|
||||||
|
<logger name="EVENT2Line1" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT2_APPENDER_LINE1" />
|
||||||
|
</logger>
|
||||||
|
<logger name="EVENT3Line1" level="INFO" additivity="false">
|
||||||
|
<appender-ref ref="EVENT3_APPENDER_LINE1" />
|
||||||
|
</logger>
|
||||||
|
<!-- LINE1 结束 -->
|
||||||
|
|
||||||
|
|
||||||
|
<logger name="com.cnbm.packing" additivity="false">
|
||||||
<appender-ref ref="PACKING_LOG_DEBUG_FILE" />
|
<appender-ref ref="PACKING_LOG_DEBUG_FILE" />
|
||||||
<appender-ref ref="PACKING_LOG_INFO_FILE" />
|
<appender-ref ref="PACKING_LOG_INFO_FILE" />
|
||||||
<appender-ref ref="PACKING_LOG_WARN_FILE" />
|
<appender-ref ref="PACKING_LOG_WARN_FILE" />
|
||||||
|
@ -19,7 +19,7 @@ public class CodeGenerator {
|
|||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void test(){
|
public void test(){
|
||||||
mybatisPlusGenerator(new String[]{"t_wo_power_level"});
|
mybatisPlusGenerator(new String[]{"t_working_time"});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void mybatisPlusGenerator(String[] include){
|
public static void mybatisPlusGenerator(String[] include){
|
||||||
|
@ -0,0 +1,116 @@
|
|||||||
|
package com.cnbm.generator.code.controller;
|
||||||
|
|
||||||
|
import com.cnbm.admin.annotation.LogOperation;
|
||||||
|
import com.cnbm.common.constant.Constant;
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.utils.ExcelUtils;
|
||||||
|
import com.cnbm.common.utils.Result;
|
||||||
|
import com.cnbm.common.validator.AssertUtils;
|
||||||
|
import com.cnbm.common.validator.ValidatorUtils;
|
||||||
|
import com.cnbm.common.validator.group.AddGroup;
|
||||||
|
import com.cnbm.common.validator.group.DefaultGroup;
|
||||||
|
import com.cnbm.common.validator.group.UpdateGroup;
|
||||||
|
import com.cnbm.generator.code.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.generator.code.excel.WorkingTimeExcel;
|
||||||
|
import com.cnbm.generator.code.service.WorkingTimeServiceBiz;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表 前端控制器
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-20
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/code/workingTime")
|
||||||
|
@Api(tags="班次时间段 表")
|
||||||
|
public class WorkingTimeController {
|
||||||
|
@Autowired
|
||||||
|
private WorkingTimeServiceBiz workingTimeService;
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@ApiOperation("分页")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
|
||||||
|
})
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:workingTime:page')")
|
||||||
|
public Result<PageData<WorkingTimeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
|
PageData<WorkingTimeDTO> page = workingTimeService.page(params);
|
||||||
|
|
||||||
|
return new Result<PageData<WorkingTimeDTO>>().ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@ApiOperation("信息")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:workingTime:info')")
|
||||||
|
public Result<WorkingTimeDTO> get(@PathVariable("id") Long id){
|
||||||
|
WorkingTimeDTO data = workingTimeService.get(id);
|
||||||
|
|
||||||
|
return new Result<WorkingTimeDTO>().ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("保存")
|
||||||
|
@LogOperation("保存")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:workingTime:save')")
|
||||||
|
public Result<Long> save(@RequestBody WorkingTimeDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
|
workingTimeService.save(dto);
|
||||||
|
|
||||||
|
return new Result<Long>().ok(dto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@ApiOperation("修改")
|
||||||
|
@LogOperation("修改")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:workingTime:update')")
|
||||||
|
public Result<Long> update(@RequestBody WorkingTimeDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
|
workingTimeService.update(dto);
|
||||||
|
|
||||||
|
return new Result<Long>().ok(dto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@ApiOperation("删除")
|
||||||
|
@LogOperation("删除")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:workingTime:delete')")
|
||||||
|
public Result delete(@RequestBody Long[] ids){
|
||||||
|
//效验数据
|
||||||
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
|
|
||||||
|
workingTimeService.delete(ids);
|
||||||
|
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("export")
|
||||||
|
@ApiOperation("导出")
|
||||||
|
@LogOperation("导出")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('code:workingTime:export')")
|
||||||
|
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||||
|
List<WorkingTimeDTO> list = workingTimeService.list(params);
|
||||||
|
|
||||||
|
ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,65 @@
|
|||||||
|
package com.cnbm.generator.code.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "班次时间段 表DTO对象")
|
||||||
|
public class WorkingTimeDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "班次名 ,A/B/C...")
|
||||||
|
private String orderName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "班次开始时间, 0点 - 24点")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "班次结束时间, 0点 - 24点")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "删除标志,是否有效:1 可用 0不可用")
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private Long creatorId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建人姓名")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新人")
|
||||||
|
private Long updaterId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新人姓名")
|
||||||
|
private String updaterName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,93 @@
|
|||||||
|
package com.cnbm.generator.code.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 班次时间段 表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("t_working_time")
|
||||||
|
@ApiModel(value = "WorkingTime对象", description = "班次时间段 表")
|
||||||
|
public class WorkingTime implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("班次名 ,A/B/C...")
|
||||||
|
private String orderName;
|
||||||
|
|
||||||
|
@ApiModelProperty("班次开始时间, 0点 - 24点")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("班次结束时间, 0点 - 24点")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志,是否有效:1 可用 0不可用")
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建人")
|
||||||
|
private Long creatorId;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建人姓名")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新人")
|
||||||
|
private Long updaterId;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新人姓名")
|
||||||
|
private String updaterName;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String ID = "id";
|
||||||
|
|
||||||
|
public static final String ORDER_NAME = "order_name";
|
||||||
|
|
||||||
|
public static final String BEGIN_TIME = "begin_time";
|
||||||
|
|
||||||
|
public static final String END_TIME = "end_time";
|
||||||
|
|
||||||
|
public static final String REMARK = "remark";
|
||||||
|
|
||||||
|
public static final String VALID = "valid";
|
||||||
|
|
||||||
|
public static final String CREATOR_ID = "creator_id";
|
||||||
|
|
||||||
|
public static final String CREATOR_NAME = "creator_name";
|
||||||
|
|
||||||
|
public static final String CREATE_TIME = "create_time";
|
||||||
|
|
||||||
|
public static final String UPDATER_ID = "updater_id";
|
||||||
|
|
||||||
|
public static final String UPDATER_NAME = "updater_name";
|
||||||
|
|
||||||
|
public static final String UPDATE_TIME = "update_time";
|
||||||
|
|
||||||
|
public static final String VERSION = "version";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,46 @@
|
|||||||
|
package com.cnbm.generator.code.excel;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.math.BigDecimal;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-20
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WorkingTimeExcel {
|
||||||
|
@Excel(name = "ID")
|
||||||
|
private Long id;
|
||||||
|
@Excel(name = "班次名 ,A/B/C...")
|
||||||
|
private String orderName;
|
||||||
|
@Excel(name = "班次开始时间, 0点 - 24点")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
@Excel(name = "班次结束时间, 0点 - 24点")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
@Excel(name = "备注")
|
||||||
|
private String remark;
|
||||||
|
@Excel(name = "删除标志,是否有效:1 可用 0不可用")
|
||||||
|
private Integer valid;
|
||||||
|
@Excel(name = "创建人")
|
||||||
|
private Long creatorId;
|
||||||
|
@Excel(name = "创建人姓名")
|
||||||
|
private String creatorName;
|
||||||
|
@Excel(name = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
@Excel(name = "更新人")
|
||||||
|
private Long updaterId;
|
||||||
|
@Excel(name = "更新人姓名")
|
||||||
|
private String updaterName;
|
||||||
|
@Excel(name = "更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
@Excel(name = "版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,16 @@
|
|||||||
|
package com.cnbm.generator.code.mapper;
|
||||||
|
|
||||||
|
import com.cnbm.common.dao.BaseDao;
|
||||||
|
import com.cnbm.generator.code.entity.WorkingTime;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-20
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface WorkingTimeMapper extends BaseDao<WorkingTime> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,20 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cnbm.generator.code.mapper.WorkingTimeMapper">
|
||||||
|
<resultMap type="com.cnbm.generator.code.entity.WorkingTime" id="WorkingTimeMap">
|
||||||
|
<id column="id" property="id" />
|
||||||
|
<id column="order_name" property="orderName" />
|
||||||
|
<id column="begin_time" property="beginTime" />
|
||||||
|
<id column="end_time" property="endTime" />
|
||||||
|
<id column="remark" property="remark" />
|
||||||
|
<id column="valid" property="valid" />
|
||||||
|
<id column="creator_id" property="creatorId" />
|
||||||
|
<id column="creator_name" property="creatorName" />
|
||||||
|
<id column="create_time" property="createTime" />
|
||||||
|
<id column="updater_id" property="updaterId" />
|
||||||
|
<id column="updater_name" property="updaterName" />
|
||||||
|
<id column="update_time" property="updateTime" />
|
||||||
|
<id column="version" property="version" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
</mapper>
|
@ -0,0 +1,7 @@
|
|||||||
|
-- 菜单初始SQL
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date)VALUES (1737360876993064962, 1067246875800000035, '班次时间段 表', 'code/workingTime', NULL, 0, 'icon-desktop', 0, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064963, 1737360876993064962, '查看', NULL, 'code:workingTime:page,code:workingTime:info', 1, NULL, 0, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064964, 1737360876993064962, '新增', NULL, 'code:workingTime:save', 1, NULL, 1, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064965, 1737360876993064962, '修改', NULL, 'code:workingTime:update', 1, NULL, 2, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064966, 1737360876993064962, '删除', NULL, 'code:workingTime:delete', 1, NULL, 3, 1067246875800000001, now(), 1067246875800000001, now());
|
||||||
|
INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1737360876993064967, 1737360876993064962, '导出', NULL, 'code:workingTime:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now());
|
@ -0,0 +1,15 @@
|
|||||||
|
package com.cnbm.generator.code.service;
|
||||||
|
|
||||||
|
import com.cnbm.common.service.CrudService;
|
||||||
|
import com.cnbm.generator.code.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.generator.code.entity.WorkingTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-20
|
||||||
|
*/
|
||||||
|
public interface WorkingTimeServiceBiz extends CrudService<WorkingTime, WorkingTimeDTO> {
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.cnbm.generator.code.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.cnbm.common.service.impl.CrudServiceImpl;
|
||||||
|
import com.cnbm.generator.code.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.generator.code.mapper.WorkingTimeMapper;
|
||||||
|
import com.cnbm.generator.code.entity.WorkingTime;
|
||||||
|
import com.cnbm.generator.code.service.WorkingTimeServiceBiz;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-20
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper, WorkingTime, WorkingTimeDTO> implements WorkingTimeServiceBiz {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper<WorkingTime> getWrapper(Map<String, Object> params){
|
||||||
|
String id = (String)params.get("id");
|
||||||
|
|
||||||
|
QueryWrapper<WorkingTime> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -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<size;i++){
|
|
||||||
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
|
||||||
|
|
||||||
if(!powerLevel.equals(correctLevel)){
|
|
||||||
errMsg+="基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
|
||||||
res = true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if(res){
|
|
||||||
logger.error(errMsg);
|
|
||||||
}
|
|
||||||
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
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("标签打印Event--- 失败"+" --- "+" 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 pmppActual = service.getPMPPBySubId(subId);
|
|
||||||
// //2. 匹配和计算补偿功率
|
|
||||||
// float pmppCompensation = compensationPowerServiceBiz.calculCompensationPMPP(pmppActual,lineNum);
|
|
||||||
// //3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka
|
|
||||||
// WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(pmppCompensation, 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("标签打印Event--- 采集到 基板ID: "+subId+", 线边号:"+lineNum+",从camline 获取到实际pmpp"+pmppActual+",计算后 补偿功率:"+pmppCompensation+",dLable_Pnom: "+argByPMPP.getPowerClass() +",dLable_Voc: "+argByPMPP.getLableVoc()+",dLable_Isc: "+argByPMPP.getLableIsc()+",dLable_Vmpp: "+argByPMPP.getLableVmpp()+",dLable_Impp: "+argByPMPP.getLableImpp());
|
|
||||||
//
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //4. 把基板录到数据库
|
|
||||||
// WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate();
|
|
||||||
// woPackagingBoxSubstrate.setLineBody(lineNum);
|
|
||||||
// woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass());
|
|
||||||
// woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum());
|
|
||||||
// woPackagingBoxSubstrate.setWoSubstrateId(subId);
|
|
||||||
// woPackagingBoxSubstrate.setActualPmpp(pmppActual);
|
|
||||||
// woPackagingBoxSubstrate.setCreateTime(LocalDateTime.now());
|
|
||||||
// woPackagingBoxSubstrate.setPmpp(pmppCompensation);
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //5. 从camline那里获取可变字段
|
|
||||||
// CamlineExtendArgDTO extendArgFromCamline = service.getExtendArgFromCamline(subId);
|
|
||||||
// logger.info("标签打印Event--- 基板ID: "+subId+", 从camline获取PID16~PID22 的实测数据 成功, 数据内容:"+extendArgFromCamline.toString());
|
|
||||||
// woPackagingBoxSubstrate.setLastUpdateTime(extendArgFromCamline.getLastUpdateTime());
|
|
||||||
//
|
|
||||||
// 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);
|
|
||||||
// logger.info("标签打印Event--- 基板ID: "+subId+", 录入数据库成功");
|
|
||||||
// //=============== MES 业务 结束 =================
|
|
||||||
//
|
|
||||||
// //三. 当MES完成任务后,把MesToPlc.SubArrivedFinish变量置为true,告诉plc,我操作完成了
|
|
||||||
// write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,true);
|
|
||||||
// logger.info("标签打印Event--- 基板ID: "+subId+", SubArrivedFinish,置为true 成功");
|
|
||||||
// //四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
|
||||||
// Integer subArrived2 = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, false);
|
|
||||||
// if(subArrived2 != 1){
|
|
||||||
// logger.info("标签打印Event--- 失败"+" --- "+"MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,false);
|
|
||||||
// logger.info("标签打印Event--- 基板ID: "+subId+", SubArrivedFinish,置为 false 成功, Event1 成功结束");
|
|
||||||
//
|
|
||||||
// }catch (Throwable e){
|
|
||||||
// e.printStackTrace();
|
|
||||||
// logger.info("标签打印Event--- 出现异常 :"+e.toString());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },1,1, TimeUnit.SECONDS);
|
|
||||||
//
|
|
||||||
// kukaStep2.scheduleAtFixedRate(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// //调度开始
|
|
||||||
// Integer shelfIsFull = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, true);
|
|
||||||
// if(shelfIsFull != 1){
|
|
||||||
// logger.info("BOXID生成Event-------失败"+" --- "+"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)-1;
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //二. MES 业务
|
|
||||||
// //=============== MES 业务 开始 =================
|
|
||||||
// //1.MES 生成BoxId
|
|
||||||
// if(subIdList.length<=0){
|
|
||||||
// logger.info("BOXID生成Event-------失败"+" --- "+"从plc里面获取到的基板列表 为空");
|
|
||||||
// throw new Exception("BOXID生成Event-------kuka机械手 取到了空箱");
|
|
||||||
// }
|
|
||||||
// //真实的基板ID 就是17位的,plc读取过来,有空格,要把后面3位空格去掉就行了。
|
|
||||||
// for(int i=0;i<subIdList.length;i++){
|
|
||||||
// subIdList[i] = removeKG(subIdList[i]);
|
|
||||||
// }
|
|
||||||
// logger.info("BOXID生成Event-------获取到基板列表:"+ Arrays.toString(subIdList)+",基板数量:"+listSize);
|
|
||||||
//
|
|
||||||
// WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIdList[0]);
|
|
||||||
// logger.info("bySubId"+ bySubId.toString());
|
|
||||||
// //如果我们系统中找不到这块基板那么就去camline里面找
|
|
||||||
// if(bySubId == null){
|
|
||||||
//
|
|
||||||
// //todo
|
|
||||||
// CamlineSubIdDTO subIdByCamline = service.getSubIdByCamline(subIdList[0]);
|
|
||||||
// bySubId = new WoPackagingBoxSubstrate();
|
|
||||||
// bySubId.setPowerLevel(subIdByCamline.getPowerLevel());
|
|
||||||
// bySubId.setSapMaterial(subIdByCamline.getSapMaterial());
|
|
||||||
// bySubId.setLineBody(2);
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //校验是否存在混档位情况
|
|
||||||
// String boxId = "";
|
|
||||||
// if(isMixLevel(subIdList,listSize)){
|
|
||||||
// //出现混档
|
|
||||||
// boxId = getErrorBoxId(bySubId.getSapMaterial());
|
|
||||||
// }else {
|
|
||||||
// //正常情况
|
|
||||||
// boxId = getBoxId(bySubId.getSapMaterial());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// logger.info("BOXID生成Event-------mes 生成的boxId :"+ boxId);
|
|
||||||
// //2. 依次update 基板表,把boxId 赋予这些基板
|
|
||||||
// for(int i=0;i<listSize;i++){
|
|
||||||
// substrateServiceBiz.updatePackagingBoxIdAndSlotByWoSubstrateId(boxId,(i+1),subIdList[i]);
|
|
||||||
// }
|
|
||||||
// //3.去camline数据库 查询此基板ID 对应的订单
|
|
||||||
// String orderNameBySubId = service.getOrderNameBySubId(subIdList[0]);
|
|
||||||
// //4. box信息录入到box表
|
|
||||||
// WoPackagingBox woPackagingBox = new WoPackagingBox();
|
|
||||||
// woPackagingBox.setBoxNo(boxId);
|
|
||||||
// woPackagingBox.setSubstrateQuantity(listSize);
|
|
||||||
// woPackagingBox.setPackagingTime(LocalDateTime.now());
|
|
||||||
// woPackagingBox.setPowerLevel(bySubId.getPowerLevel());
|
|
||||||
// woPackagingBox.setLineBody(bySubId.getLineBody());
|
|
||||||
// woPackagingBox.setSapMaterial(bySubId.getSapMaterial());
|
|
||||||
// woPackagingBox.setOrderNum(orderNameBySubId);
|
|
||||||
// //1-手动模式,2-自动模式
|
|
||||||
// woPackagingBox.setModel(2);
|
|
||||||
// woPackagingBox.setCreateTime(LocalDateTime.now());
|
|
||||||
// woPackagingBox.setPackagingTime(LocalDateTime.now());
|
|
||||||
// boxServiceBiz.insert(woPackagingBox);
|
|
||||||
// logger.info("BOXID生成Event-------boxId :"+ boxId+"写入数据库成功");
|
|
||||||
// //=============== MES 业务 结束 =================
|
|
||||||
//
|
|
||||||
// //三. 把生成的BoxId 告诉kuka
|
|
||||||
// write(S7Client.S7_KUKA,Step2Mes2PlcVar.BoxId,boxId);
|
|
||||||
// logger.info("BOXID生成Event-------boxId :"+ boxId+"传给PLC 成功");
|
|
||||||
//
|
|
||||||
// //四. 当MES完成任务后,把MesToPlc.ShelfIsFullFinish变量置为true,告诉plc,我操作完成了
|
|
||||||
// write(S7Client.S7_KUKA,Step2Mes2PlcVar.ShelfIsFullFinish,true);
|
|
||||||
// logger.info("BOXID生成Event-------boxId :"+ boxId+"ShelfIsFullFinish 置为true 成功");
|
|
||||||
// //四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
|
||||||
// Integer subArrived2 = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, false);
|
|
||||||
// if(subArrived2 != 1){
|
|
||||||
// logger.info("BOXID生成Event-------失败"+" --- "+"步骤1. MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
|
||||||
// }
|
|
||||||
// write(S7Client.S7_KUKA,Step2Mes2PlcVar.ShelfIsFullFinish,false);
|
|
||||||
// logger.info("BOXID生成Event-------boxId :"+ boxId+"ShelfIsFullFinish 置为false 成功,Event2 成功结束");
|
|
||||||
// }catch (Throwable e){
|
|
||||||
// e.printStackTrace();
|
|
||||||
// logger.info("BOXID生成Event------- 出现异常:" + e.toString());
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// },1,1, TimeUnit.SECONDS);
|
|
||||||
//
|
|
||||||
// kukaStep3.scheduleAtFixedRate(new Runnable() {
|
|
||||||
// @Override
|
|
||||||
// public void run() {
|
|
||||||
// try {
|
|
||||||
//
|
|
||||||
// //调度开始
|
|
||||||
// Integer shelfIsFull = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, true);
|
|
||||||
// if(shelfIsFull != 1){
|
|
||||||
// logger.info("装箱单打印Event------失败"+" --- "+"MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败");
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// //一. 从plc 中获取 subIdList 和 lineNum
|
|
||||||
// String boxId = (String)read(S7Client.S7_KUKA,Step3Plc2MesVar.BoxId);
|
|
||||||
// Integer lineNum = (Integer) read(S7Client.S7_KUKA,Step3Plc2MesVar.LineNum);
|
|
||||||
// logger.info("装箱单打印Event------到达站台的boxId :"+boxId);
|
|
||||||
//
|
|
||||||
// //二. MES 业务
|
|
||||||
// //=============== MES 业务 开始 =================
|
|
||||||
// //1. box信息录入到box表
|
|
||||||
// boxServiceBiz.updateIsArrivedByBoxNo(1,boxId);
|
|
||||||
// logger.info("装箱单打印Event------boxId :"+boxId+"更新数据库成功");
|
|
||||||
// //=============== MES 业务 结束 =================
|
|
||||||
//
|
|
||||||
//
|
|
||||||
// //四. 当MES完成任务后,把MesToPlc.ShelfIsFullArrivedFinish变量置为true,告诉plc,我操作完成了
|
|
||||||
// write(S7Client.S7_KUKA,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,true);
|
|
||||||
// logger.info("装箱单打印Event------boxId :"+boxId+", ShelfIsFullArrivedFinish置为true 成功");
|
|
||||||
// //四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
|
||||||
// Integer subArrived2 = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, false);
|
|
||||||
// if(subArrived2 != 1){
|
|
||||||
// logger.info("装箱单打印Event------失败"+" --- "+"步骤1. MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败");
|
|
||||||
// }
|
|
||||||
// logger.info("装箱单打印Event------boxId :"+boxId+", 监听到subArrived=false 成功");
|
|
||||||
// write(S7Client.S7_KUKA,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,false);
|
|
||||||
// logger.info("装箱单打印Event------boxId :"+boxId+", Even3 成功");
|
|
||||||
// }catch (Throwable e){
|
|
||||||
// e.printStackTrace();
|
|
||||||
// logger.info("装箱单打印Event 出现异常------"+e.toString());
|
|
||||||
// }
|
|
||||||
//
|
|
||||||
// }
|
|
||||||
// },1,1, TimeUnit.SECONDS);
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* arg:
|
|
||||||
* Step1Plc2MesVar 参数类型
|
|
||||||
* targetValue 目的值
|
|
||||||
* return:
|
|
||||||
* 2 s7 访问异常;
|
|
||||||
* 1 成功;
|
|
||||||
* */
|
|
||||||
private Integer waitingForTarget(Step1Plc2MesVar var, Boolean targetValue) {
|
|
||||||
Integer res = 0;
|
|
||||||
while (true){
|
|
||||||
try {
|
|
||||||
Boolean now = (Boolean) read(S7Client.S7_KUKA,var);
|
|
||||||
if(targetValue.equals(now)){
|
|
||||||
res = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(200);
|
|
||||||
}catch (Exception e){
|
|
||||||
logger.info("S7 数据采集 异常。");
|
|
||||||
res = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* arg:
|
|
||||||
* Step2Plc2MesVar 参数类型
|
|
||||||
* targetValue 目的值
|
|
||||||
* return:
|
|
||||||
* 2 s7 访问异常;
|
|
||||||
* 1 成功;
|
|
||||||
* */
|
|
||||||
private Integer waitingForTarget(Step2Plc2MesVar var, Boolean targetValue) {
|
|
||||||
Integer res = 0;
|
|
||||||
while (true){
|
|
||||||
try {
|
|
||||||
Boolean now = (Boolean) read(S7Client.S7_KUKA,var);
|
|
||||||
if(targetValue.equals(now)){
|
|
||||||
res = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(200);
|
|
||||||
}catch (Exception e){
|
|
||||||
logger.info("S7 数据采集 异常。");
|
|
||||||
res = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
*
|
|
||||||
* arg:
|
|
||||||
* Step3Plc2MesVar 参数类型
|
|
||||||
* targetValue 目的值
|
|
||||||
* return:
|
|
||||||
* 2 s7 访问异常;
|
|
||||||
* 1 成功;
|
|
||||||
* */
|
|
||||||
private Integer waitingForTarget(Step3Plc2MesVar var, Boolean targetValue) {
|
|
||||||
Integer res = 0;
|
|
||||||
while (true){
|
|
||||||
try {
|
|
||||||
Boolean now = (Boolean) read(S7Client.S7_KUKA,var);
|
|
||||||
if(targetValue.equals(now)){
|
|
||||||
res = 1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
Thread.sleep(200);
|
|
||||||
}catch (Exception e){
|
|
||||||
logger.info("S7 数据采集 异常。");
|
|
||||||
res = 2;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return res;
|
|
||||||
}
|
|
||||||
}
|
|
@ -16,9 +16,6 @@ public enum Step1Mes2PlcVar {
|
|||||||
dLable_Isc("dLable_Isc", PlcVar.REAL,1, DaveArea.DB,2000,36,0),
|
dLable_Isc("dLable_Isc", PlcVar.REAL,1, DaveArea.DB,2000,36,0),
|
||||||
dLable_Vmpp("dLable_Vmpp", PlcVar.REAL,1, DaveArea.DB,2000,40,0),
|
dLable_Vmpp("dLable_Vmpp", PlcVar.REAL,1, DaveArea.DB,2000,40,0),
|
||||||
dLable_Impp("dLable_Vmpp", PlcVar.REAL,1, DaveArea.DB,2000,44,0),
|
dLable_Impp("dLable_Vmpp", PlcVar.REAL,1, DaveArea.DB,2000,44,0),
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -14,7 +14,6 @@ public enum Step1Plc2MesVar {
|
|||||||
SubIdToMes("SubIdToMes",PlcVar.STRING,1,DaveArea.DB,2000,2,0,20),
|
SubIdToMes("SubIdToMes",PlcVar.STRING,1,DaveArea.DB,2000,2,0,20),
|
||||||
LineNum("LineNum", PlcVar.UINT,1, DaveArea.DB,2000,24,0),
|
LineNum("LineNum", PlcVar.UINT,1, DaveArea.DB,2000,24,0),
|
||||||
|
|
||||||
|
|
||||||
;
|
;
|
||||||
|
|
||||||
private String name;
|
private String name;
|
||||||
|
@ -0,0 +1,90 @@
|
|||||||
|
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 Step4Mes2PlcVar {
|
||||||
|
SubArrivedFinish("SubArrivedFinish", PlcVar.BOOL,1, DaveArea.DB,2001,24,0),
|
||||||
|
|
||||||
|
dLable_Pnom("dLable_Pnom", PlcVar.DINT,1, DaveArea.DB,2001,26,0),
|
||||||
|
dLable_Voc("dLable_Voc", PlcVar.REAL,1, DaveArea.DB,2001,30,0),
|
||||||
|
dLable_Isc("dLable_Isc", PlcVar.REAL,1, DaveArea.DB,2001,34,0),
|
||||||
|
dLable_Vmpp("dLable_Vmpp", PlcVar.REAL,1, DaveArea.DB,2001,38,0),
|
||||||
|
dLable_Impp("dLable_Vmpp", PlcVar.REAL,1, DaveArea.DB,2001,42,0),
|
||||||
|
;
|
||||||
|
|
||||||
|
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;
|
||||||
|
|
||||||
|
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;
|
||||||
|
}
|
||||||
|
}
|
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -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<size;i++){
|
||||||
|
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
|
||||||
|
kukaStep1.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer subArrived = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程一 任务( 开始 ) ===================================");
|
||||||
|
if(subArrived != 1){
|
||||||
|
logger.info("标签打印Event--- 失败"+" --- "+" MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
} else if (subArrived == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
logger.info("标签打印Event --- 成功 ---- MES监听到 SubArrivedToMes==true");
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subId 和 lineNum
|
||||||
|
String subId = (String) read(S7Client.S7_DDJ1,Step1Plc2MesVar.SubIdToMes);
|
||||||
|
Integer lineNum = (Integer) read(S7Client.S7_DDJ1,Step1Plc2MesVar.LineNum);
|
||||||
|
//把基板ID字符串的空格去掉,因为plc中设置的20位,但实际基板ID就是17位,因为带空格去数据库查询 有问题的。
|
||||||
|
if(subId == null || lineNum == null){
|
||||||
|
logger.info("标签打印Event--- 失败"+" --- "+" MES采集到null值,subId:"+subId+",lineNum:"+lineNum);
|
||||||
|
}
|
||||||
|
subId = removeKG(subId);
|
||||||
|
logger.info("标签打印Event --- 成功 ---- MES 从plu中 read 到基板id:"+subId);
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
logger.info("================= 现在开始执行 过程一 任务 ( MES 业务 ) ( 开始 ) ==================");
|
||||||
|
//1. 从comline数据库中获取 实际pmpp
|
||||||
|
float pmppActual = service.getPMPPBySubId(subId);
|
||||||
|
//2. 匹配和计算补偿功率
|
||||||
|
float pmppCompensation = compensationPowerServiceBiz.calculCompensationPMPP(pmppActual,lineNum);
|
||||||
|
//3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka
|
||||||
|
WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(pmppCompensation, lineNum);
|
||||||
|
write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Pnom,Integer.valueOf(argByPMPP.getPowerClass()));
|
||||||
|
write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Voc,argByPMPP.getLableVoc());
|
||||||
|
write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Isc,argByPMPP.getLableIsc());
|
||||||
|
write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Vmpp,argByPMPP.getLableVmpp());
|
||||||
|
write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Impp,argByPMPP.getLableImpp());
|
||||||
|
logger.info("标签打印Event--- 采集到 基板ID: "+subId+", 线边号:"+lineNum+",从camline 获取到实际pmpp"+pmppActual+",计算后 补偿功率:"+pmppCompensation+",dLable_Pnom: "+argByPMPP.getPowerClass() +",dLable_Voc: "+argByPMPP.getLableVoc()+",dLable_Isc: "+argByPMPP.getLableIsc()+",dLable_Vmpp: "+argByPMPP.getLableVmpp()+",dLable_Impp: "+argByPMPP.getLableImpp());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//4. 把基板录到数据库
|
||||||
|
WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate();
|
||||||
|
woPackagingBoxSubstrate.setLineBody(lineNum);
|
||||||
|
woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass());
|
||||||
|
woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum());
|
||||||
|
woPackagingBoxSubstrate.setWoSubstrateId(subId);
|
||||||
|
woPackagingBoxSubstrate.setActualPmpp(pmppActual);
|
||||||
|
woPackagingBoxSubstrate.setCreateTime(LocalDateTime.now());
|
||||||
|
//计算后的补偿功率
|
||||||
|
woPackagingBoxSubstrate.setPmpp(pmppCompensation);
|
||||||
|
|
||||||
|
|
||||||
|
//5. 从camline那里获取可变字段
|
||||||
|
CamlineExtendArgDTO extendArgFromCamline = service.getExtendArgFromCamline(subId);
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", 从camline获取PID16~PID22 的实测数据 成功, 数据内容:"+extendArgFromCamline.toString());
|
||||||
|
woPackagingBoxSubstrate.setLastUpdateTime(extendArgFromCamline.getLastUpdateTime());
|
||||||
|
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);
|
||||||
|
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", 录入数据库成功");
|
||||||
|
logger.info("================= 现在开始执行 过程一 任务 ( MES 业务 ) ( 结束 ) ==================");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
//三. 当MES完成任务后,把MesToPlc.SubArrivedFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ1,Step1Mes2PlcVar.SubArrivedFinish,true);
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", SubArrivedFinish,置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("标签打印Event--- 失败"+" --- "+"MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
}else if (subArrived2 == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
write(S7Client.S7_DDJ1,Step1Mes2PlcVar.SubArrivedFinish,false);
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", SubArrivedFinish,置为 false 成功");
|
||||||
|
logger.info("================================== 现在开始执行 过程一 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("标签打印Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step1Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step1Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step2Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step2Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step3Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step3Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,490 @@
|
|||||||
|
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.CamlineSubIdDTO;
|
||||||
|
import com.cnbm.packing.entity.WoPackagingBox;
|
||||||
|
import com.cnbm.packing.entity.WoPackagingBoxSubstrate;
|
||||||
|
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.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 KukaEvent2ThreadLine1 implements ApplicationRunner {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("EVENT2Line1");
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DynamicDataSourceService service;
|
||||||
|
@Autowired
|
||||||
|
WoPowerLevelServiceBiz levelServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoCompensationPowerServiceBiz compensationPowerServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||||
|
|
||||||
|
public KukaEvent2ThreadLine1(){
|
||||||
|
|
||||||
|
this.kukaStep2 = Executors.newScheduledThreadPool(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ScheduledExecutorService kukaStep2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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;
|
||||||
|
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<size;i++){
|
||||||
|
//
|
||||||
|
// if(!powerLevel.equals(correctLevel)){
|
||||||
|
// errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
// res = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(res){
|
||||||
|
// logger.error(errMsg);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return res;
|
||||||
|
// }
|
||||||
|
private CamlineSubIdDTO getFromCamline(String subId){
|
||||||
|
return service.getSubIdByCamline(subId);
|
||||||
|
}
|
||||||
|
private boolean isMixLevel(String[] subIds,Integer size){
|
||||||
|
WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIds[0]);
|
||||||
|
String correctLevel = 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();
|
||||||
|
}else {
|
||||||
|
correctLevel = bySubId.getPowerLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String errMsg = "以下基板ID出现混档:";
|
||||||
|
boolean res = false;
|
||||||
|
for(int i=0;i<size;i++){
|
||||||
|
WoPackagingBoxSubstrate innerSub = substrateServiceBiz.getBySubId(subIds[i]);
|
||||||
|
String powerLevel = null;
|
||||||
|
if(innerSub==null){
|
||||||
|
powerLevel = getFromCamline(subIds[i]).getPowerLevel();
|
||||||
|
}else {
|
||||||
|
powerLevel = innerSub.getPowerLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
kukaStep2.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer shelfIsFull = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程二 任务( 开始 ) ===================================");
|
||||||
|
if(shelfIsFull != 1){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败");
|
||||||
|
}else if(shelfIsFull == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subIdList 和 lineNum
|
||||||
|
String[] subIdList = (String[])read(S7Client.S7_DDJ1,Step2Plc2MesVar.SubIdList);
|
||||||
|
Integer listSize = (Integer)read(S7Client.S7_DDJ1,Step2Plc2MesVar.PackageNumberSet)-1;
|
||||||
|
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
//1.MES 生成BoxId
|
||||||
|
if(subIdList.length<=0){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"从plc里面获取到的基板列表 为空");
|
||||||
|
throw new Exception("BOXID生成Event失败-------kuka机械手 取到了空箱");
|
||||||
|
}
|
||||||
|
if(listSize == null){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"从plc里面获取到的listSize 为null");
|
||||||
|
throw new Exception("BOXID生成Event失败-------listSize 为null");
|
||||||
|
}
|
||||||
|
|
||||||
|
//真实的基板ID 就是17位的,plc读取过来,有空格,要把后面3位空格去掉就行了。
|
||||||
|
for(int i=0;i<subIdList.length;i++){
|
||||||
|
subIdList[i] = removeKG(subIdList[i]);
|
||||||
|
}
|
||||||
|
logger.info("BOXID生成Event-------获取到基板列表:"+ Arrays.toString(subIdList)+",基板数量:"+listSize);
|
||||||
|
|
||||||
|
WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIdList[0]);
|
||||||
|
logger.info("BOXID生成Event-------依据subId"+subIdList[0]+"去qgs数据库 查询数据,数据内容:"+bySubId);
|
||||||
|
|
||||||
|
|
||||||
|
//如果我们系统中找不到这块基板那么就去camline里面找
|
||||||
|
// if(bySubId == null){
|
||||||
|
// logger.info("BOXID生成Event-------数据库中 无subId:"+ subIdList[0]+"现在从camline 系统获取这个基板相关信息");
|
||||||
|
// //todo
|
||||||
|
// CamlineSubIdDTO subIdByCamline = service.getSubIdByCamline(subIdList[0]);
|
||||||
|
// logger.info("BOXID生成Event-------camline 中关于此基板信息:"+ subIdByCamline);
|
||||||
|
//
|
||||||
|
// bySubId = new WoPackagingBoxSubstrate();
|
||||||
|
// bySubId.setPowerLevel(subIdByCamline.getPowerLevel());
|
||||||
|
// bySubId.setSapMaterial(subIdByCamline.getSapMaterial());
|
||||||
|
// bySubId.setLineBody(1);
|
||||||
|
// }
|
||||||
|
if(bySubId == null){
|
||||||
|
logger.info("BOXID生成Event-------数据库中 无subId:"+ subIdList[0]);
|
||||||
|
throw new Exception("BOXID生成Event-------数据库中 无subId:"+ subIdList[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//校验是否存在混档位情况 -- 开始
|
||||||
|
String boxId = "";
|
||||||
|
if(isMixLevel(subIdList,listSize)){
|
||||||
|
//出现混档
|
||||||
|
logger.info("BOXID生成Event-------subIdList :"+Arrays.asList(subIdList)+"出现混档");
|
||||||
|
boxId = getErrorBoxId(bySubId.getSapMaterial());
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//正常情况
|
||||||
|
logger.info("BOXID生成Event-------subIdList :"+Arrays.asList(subIdList)+"没有出现混档");
|
||||||
|
boxId = getBoxId(bySubId.getSapMaterial());
|
||||||
|
}
|
||||||
|
logger.info("BOXID生成Event-------subIdList :"+Arrays.asList(subIdList)+"isMixLevel 校验结束");
|
||||||
|
//校验是否存在混档位情况 -- 结束
|
||||||
|
|
||||||
|
|
||||||
|
logger.info("BOXID生成Event-------mes 生成的boxId :"+ boxId);
|
||||||
|
//2. 依次update 基板表,把boxId 赋予这些基板
|
||||||
|
for(int i=0;i<listSize;i++){
|
||||||
|
substrateServiceBiz.updatePackagingBoxIdAndSlotByWoSubstrateId(boxId,(i+1),subIdList[i]);
|
||||||
|
}
|
||||||
|
//3.去camline数据库 查询此基板ID 对应的订单
|
||||||
|
String orderNameBySubId = service.getOrderNameBySubId(subIdList[0]);
|
||||||
|
//4. box信息录入到box表
|
||||||
|
WoPackagingBox woPackagingBox = new WoPackagingBox();
|
||||||
|
woPackagingBox.setBoxNo(boxId);
|
||||||
|
woPackagingBox.setSubstrateQuantity(listSize);
|
||||||
|
woPackagingBox.setPackagingTime(LocalDateTime.now());
|
||||||
|
woPackagingBox.setPowerLevel(bySubId.getPowerLevel());
|
||||||
|
woPackagingBox.setLineBody(bySubId.getLineBody());
|
||||||
|
woPackagingBox.setSapMaterial(bySubId.getSapMaterial());
|
||||||
|
woPackagingBox.setOrderNum(orderNameBySubId);
|
||||||
|
//1-手动模式,2-自动模式
|
||||||
|
woPackagingBox.setModel(2);
|
||||||
|
woPackagingBox.setCreateTime(LocalDateTime.now());
|
||||||
|
woPackagingBox.setPackagingTime(LocalDateTime.now());
|
||||||
|
boxServiceBiz.insert(woPackagingBox);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"写入数据库成功");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
//三. 把生成的BoxId 告诉kuka
|
||||||
|
write(S7Client.S7_DDJ1,Step2Mes2PlcVar.BoxId,boxId);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"传给PLC 成功");
|
||||||
|
|
||||||
|
//四. 当MES完成任务后,把MesToPlc.ShelfIsFullFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ1,Step2Mes2PlcVar.ShelfIsFullFinish,true);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"ShelfIsFullFinish 置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"步骤1. MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
}else if(subArrived2 == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
write(S7Client.S7_DDJ1,Step2Mes2PlcVar.ShelfIsFullFinish,false);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"ShelfIsFullFinish 置为false 成功,Event2 成功结束");
|
||||||
|
logger.info("================================== 现在开始执行 过程二 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
|
||||||
|
}catch (Throwable e){
|
||||||
|
// logger.info("BOXID生成Event------- 出现异常:" + e.toString());
|
||||||
|
logger.info("BOXID生成Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step1Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step1Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step2Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step2Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step3Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step3Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,354 @@
|
|||||||
|
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.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.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 KukaEvent3ThreadLine1 implements ApplicationRunner {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("EVENT3Line1");
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DynamicDataSourceService service;
|
||||||
|
@Autowired
|
||||||
|
WoPowerLevelServiceBiz levelServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoCompensationPowerServiceBiz compensationPowerServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||||
|
|
||||||
|
public KukaEvent3ThreadLine1(){
|
||||||
|
this.kukaStep3 = Executors.newScheduledThreadPool(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 (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<size;i++){
|
||||||
|
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
|
||||||
|
kukaStep3.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer shelfIsFull = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程三 任务( 开始 ) ===================================");
|
||||||
|
if(shelfIsFull != 1){
|
||||||
|
logger.info("装箱单打印Event------失败"+" --- "+"MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败");
|
||||||
|
}else if(shelfIsFull == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subIdList 和 lineNum
|
||||||
|
String boxId = (String)read(S7Client.S7_DDJ1,Step3Plc2MesVar.BoxId);
|
||||||
|
Integer lineNum = (Integer) read(S7Client.S7_DDJ1,Step3Plc2MesVar.LineNum);
|
||||||
|
if(boxId == null){
|
||||||
|
logger.info("装箱单打印Event-------失败"+" --- "+"从plc里面获取到的boxId 为null");
|
||||||
|
throw new Exception("装箱单打印Event-------boxId 为null");
|
||||||
|
}
|
||||||
|
logger.info("装箱单打印Event------到达站台的boxId :"+boxId);
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
//1. box信息录入到box表
|
||||||
|
boxServiceBiz.updateIsArrivedByBoxNo(1,boxId);
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+"更新数据库成功");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
|
||||||
|
//四. 当MES完成任务后,把MesToPlc.ShelfIsFullArrivedFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ1,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,true);
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+", ShelfIsFullArrivedFinish置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("装箱单打印Event------失败"+" --- "+"步骤1. MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败");
|
||||||
|
}else if(subArrived2 == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+", 监听到subArrived=false 成功");
|
||||||
|
write(S7Client.S7_DDJ1,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,false);
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+", Even3 成功");
|
||||||
|
|
||||||
|
logger.info("================================== 现在开始执行 过程三 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
}catch (Throwable e){
|
||||||
|
// e.printStackTrace();
|
||||||
|
// logger.info("装箱单打印Event 出现异常------"+e.toString());
|
||||||
|
logger.info("装箱单打印Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step1Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step1Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step2Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step2Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step3Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step3Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,306 @@
|
|||||||
|
package com.cnbm.dispatch.line1;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
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.dispatch.enums.kuka.step4.Step4Mes2PlcVar;
|
||||||
|
import com.cnbm.dispatch.enums.kuka.step4.Step4Plc2MesVar;
|
||||||
|
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.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 KukaEvent4ThreadLine1 implements ApplicationRunner {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("EVENT4NGLine1");
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DynamicDataSourceService service;
|
||||||
|
@Autowired
|
||||||
|
WoPowerLevelServiceBiz levelServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoCompensationPowerServiceBiz compensationPowerServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||||
|
|
||||||
|
public KukaEvent4ThreadLine1(){
|
||||||
|
this.kukaStep1 = Executors.newScheduledThreadPool(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScheduledExecutorService kukaStep1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return
|
||||||
|
* 成功: 返回相应的object对象
|
||||||
|
* 失败: 返回null
|
||||||
|
* */
|
||||||
|
private Object read(S7Client s7Client, Step4Plc2MesVar 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, Step4Mes2PlcVar 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<size;i++){
|
||||||
|
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
|
||||||
|
kukaStep1.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer subArrived = waitingForTarget(Step4Plc2MesVar.SubArrivedToMes, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程四 任务( 开始 ) ===================================");
|
||||||
|
if(subArrived != 1){
|
||||||
|
logger.info("NG口基板Event--- 失败"+" --- "+" MES监听 Step4Plc2MesVar.SubArrivedToMes 是否 等于 true 失败");
|
||||||
|
} else if (subArrived == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
logger.info("NG口基板Event --- 成功 ---- MES监听到 Step4Plc2MesVar.SubArrivedToMes==true");
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subId
|
||||||
|
String subId = (String) read(S7Client.S7_DDJ1,Step4Plc2MesVar.SubIdToMes);
|
||||||
|
Integer lineNum = 1;
|
||||||
|
//把基板ID字符串的空格去掉,因为plc中设置的20位,但实际基板ID就是17位,因为带空格去数据库查询 有问题的。
|
||||||
|
if(subId == null ){
|
||||||
|
logger.info("NG口基板Event--- 失败"+" --- "+" MES采集到null值,subId:"+subId);
|
||||||
|
}
|
||||||
|
subId = removeKG(subId);
|
||||||
|
logger.info("NG口基板Event --- 成功 ---- MES 从plu中 read 到基板id:"+subId);
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
logger.info("================= 现在开始执行 过程四 任务 ( MES 业务 ) ( 开始 ) ==================");
|
||||||
|
//1. 从comline数据库中获取 实际pmpp
|
||||||
|
float pmppActual = service.getPMPPBySubId(subId);
|
||||||
|
//2. 匹配和计算补偿功率
|
||||||
|
float pmppCompensation = compensationPowerServiceBiz.calculCompensationPMPP(pmppActual,lineNum);
|
||||||
|
//3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka
|
||||||
|
WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(pmppCompensation, lineNum);
|
||||||
|
write(S7Client.S7_DDJ1,Step4Mes2PlcVar.dLable_Pnom,Integer.valueOf(argByPMPP.getPowerClass()));
|
||||||
|
write(S7Client.S7_DDJ1,Step4Mes2PlcVar.dLable_Voc,argByPMPP.getLableVoc());
|
||||||
|
write(S7Client.S7_DDJ1,Step4Mes2PlcVar.dLable_Isc,argByPMPP.getLableIsc());
|
||||||
|
write(S7Client.S7_DDJ1,Step4Mes2PlcVar.dLable_Vmpp,argByPMPP.getLableVmpp());
|
||||||
|
write(S7Client.S7_DDJ1,Step4Mes2PlcVar.dLable_Impp,argByPMPP.getLableImpp());
|
||||||
|
logger.info("NG口基板Event--- 采集到 基板ID: "+subId+", 线边号:"+lineNum+",从camline 获取到实际pmpp"+pmppActual+",计算后 补偿功率:"+pmppCompensation+",dLable_Pnom: "+argByPMPP.getPowerClass() +",dLable_Voc: "+argByPMPP.getLableVoc()+",dLable_Isc: "+argByPMPP.getLableIsc()+",dLable_Vmpp: "+argByPMPP.getLableVmpp()+",dLable_Impp: "+argByPMPP.getLableImpp());
|
||||||
|
|
||||||
|
logger.info("================= 现在开始执行 过程四 任务 ( MES 业务 - 数据已经传给PLC ) ( 结束 ) ==================");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
//三. 当MES完成任务后,把MesToPlc.SubArrivedFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ1,Step4Mes2PlcVar.SubArrivedFinish,true);
|
||||||
|
logger.info("NG口基板Event--- 基板ID: "+subId+", SubArrivedFinish,置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step4Plc2MesVar.SubArrivedToMes, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("NG口基板Event--- 失败"+" --- "+"MES监听 Step4Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
}else if (subArrived2 == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
write(S7Client.S7_DDJ1,Step4Mes2PlcVar.SubArrivedFinish,false);
|
||||||
|
logger.info("NG口基板Event--- 基板ID: "+subId+", SubArrivedFinish,置为 false 成功");
|
||||||
|
logger.info("================================== 现在开始执行 过程四 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("NG口基板Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step4Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step4Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ1,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,418 @@
|
|||||||
|
package com.cnbm.dispatch.line2;
|
||||||
|
|
||||||
|
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 KukaEvent1ThreadLine2 implements ApplicationRunner {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("EVENT1Line2");
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DynamicDataSourceService service;
|
||||||
|
@Autowired
|
||||||
|
WoPowerLevelServiceBiz levelServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoCompensationPowerServiceBiz compensationPowerServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||||
|
|
||||||
|
public KukaEvent1ThreadLine2(){
|
||||||
|
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<size;i++){
|
||||||
|
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
|
||||||
|
kukaStep1.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer subArrived = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程一 任务( 开始 ) ===================================");
|
||||||
|
if(subArrived != 1){
|
||||||
|
logger.info("标签打印Event--- 失败"+" --- "+" MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
} else if (subArrived == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
logger.info("标签打印Event --- 成功 ---- MES监听到 SubArrivedToMes==true");
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subId 和 lineNum
|
||||||
|
String subId = (String) read(S7Client.S7_DDJ2,Step1Plc2MesVar.SubIdToMes);
|
||||||
|
Integer lineNum = (Integer) read(S7Client.S7_DDJ2,Step1Plc2MesVar.LineNum);
|
||||||
|
//把基板ID字符串的空格去掉,因为plc中设置的20位,但实际基板ID就是17位,因为带空格去数据库查询 有问题的。
|
||||||
|
if(subId == null || lineNum == null){
|
||||||
|
logger.info("标签打印Event--- 失败"+" --- "+" MES采集到null值,subId:"+subId+",lineNum:"+lineNum);
|
||||||
|
}
|
||||||
|
subId = removeKG(subId);
|
||||||
|
logger.info("标签打印Event --- 成功 ---- MES 从plu中 read 到基板id:"+subId);
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
logger.info("================= 现在开始执行 过程一 任务 ( MES 业务 ) ( 开始 ) ==================");
|
||||||
|
//1. 从comline数据库中获取 实际pmpp
|
||||||
|
float pmppActual = service.getPMPPBySubId(subId);
|
||||||
|
//2. 匹配和计算补偿功率
|
||||||
|
float pmppCompensation = compensationPowerServiceBiz.calculCompensationPMPP(pmppActual,lineNum);
|
||||||
|
//3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka
|
||||||
|
WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(pmppCompensation, lineNum);
|
||||||
|
write(S7Client.S7_DDJ2,Step1Mes2PlcVar.dLable_Pnom,Integer.valueOf(argByPMPP.getPowerClass()));
|
||||||
|
write(S7Client.S7_DDJ2,Step1Mes2PlcVar.dLable_Voc,argByPMPP.getLableVoc());
|
||||||
|
write(S7Client.S7_DDJ2,Step1Mes2PlcVar.dLable_Isc,argByPMPP.getLableIsc());
|
||||||
|
write(S7Client.S7_DDJ2,Step1Mes2PlcVar.dLable_Vmpp,argByPMPP.getLableVmpp());
|
||||||
|
write(S7Client.S7_DDJ2,Step1Mes2PlcVar.dLable_Impp,argByPMPP.getLableImpp());
|
||||||
|
logger.info("标签打印Event--- 采集到 基板ID: "+subId+", 线边号:"+lineNum+",从camline 获取到实际pmpp"+pmppActual+",计算后 补偿功率:"+pmppCompensation+",dLable_Pnom: "+argByPMPP.getPowerClass() +",dLable_Voc: "+argByPMPP.getLableVoc()+",dLable_Isc: "+argByPMPP.getLableIsc()+",dLable_Vmpp: "+argByPMPP.getLableVmpp()+",dLable_Impp: "+argByPMPP.getLableImpp());
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
//4. 把基板录到数据库
|
||||||
|
WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate();
|
||||||
|
woPackagingBoxSubstrate.setLineBody(lineNum);
|
||||||
|
woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass());
|
||||||
|
woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum());
|
||||||
|
woPackagingBoxSubstrate.setWoSubstrateId(subId);
|
||||||
|
woPackagingBoxSubstrate.setActualPmpp(pmppActual);
|
||||||
|
woPackagingBoxSubstrate.setCreateTime(LocalDateTime.now());
|
||||||
|
//计算后的补偿功率
|
||||||
|
woPackagingBoxSubstrate.setPmpp(pmppCompensation);
|
||||||
|
|
||||||
|
|
||||||
|
//5. 从camline那里获取可变字段
|
||||||
|
CamlineExtendArgDTO extendArgFromCamline = service.getExtendArgFromCamline(subId);
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", 从camline获取PID16~PID22 的实测数据 成功, 数据内容:"+extendArgFromCamline.toString());
|
||||||
|
woPackagingBoxSubstrate.setLastUpdateTime(extendArgFromCamline.getLastUpdateTime());
|
||||||
|
|
||||||
|
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);
|
||||||
|
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", 录入数据库成功");
|
||||||
|
logger.info("================= 现在开始执行 过程一 任务 ( MES 业务 ) ( 结束 ) ==================");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
//三. 当MES完成任务后,把MesToPlc.SubArrivedFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ2,Step1Mes2PlcVar.SubArrivedFinish,true);
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", SubArrivedFinish,置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("标签打印Event--- 失败"+" --- "+"MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
}else if (subArrived2 == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
write(S7Client.S7_DDJ2,Step1Mes2PlcVar.SubArrivedFinish,false);
|
||||||
|
logger.info("标签打印Event--- 基板ID: "+subId+", SubArrivedFinish,置为 false 成功");
|
||||||
|
logger.info("================================== 现在开始执行 过程一 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("标签打印Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step1Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step1Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step2Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step2Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step3Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step3Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,481 @@
|
|||||||
|
package com.cnbm.dispatch.line2;
|
||||||
|
|
||||||
|
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.CamlineSubIdDTO;
|
||||||
|
import com.cnbm.packing.entity.WoPackagingBox;
|
||||||
|
import com.cnbm.packing.entity.WoPackagingBoxSubstrate;
|
||||||
|
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.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 KukaEvent2ThreadLine2 implements ApplicationRunner {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("EVENT2Line2");
|
||||||
|
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DynamicDataSourceService service;
|
||||||
|
@Autowired
|
||||||
|
WoPowerLevelServiceBiz levelServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoCompensationPowerServiceBiz compensationPowerServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||||
|
|
||||||
|
public KukaEvent2ThreadLine2(){
|
||||||
|
|
||||||
|
this.kukaStep2 = Executors.newScheduledThreadPool(1);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private ScheduledExecutorService kukaStep2;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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 +"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<size;i++){
|
||||||
|
// String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||||
|
//
|
||||||
|
// if(!powerLevel.equals(correctLevel)){
|
||||||
|
// errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
// res = true;
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// if(res){
|
||||||
|
// logger.error(errMsg);
|
||||||
|
// }
|
||||||
|
//
|
||||||
|
// return res;
|
||||||
|
// }
|
||||||
|
|
||||||
|
|
||||||
|
private CamlineSubIdDTO getFromCamline(String subId){
|
||||||
|
return service.getSubIdByCamline(subId);
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean isMixLevel(String[] subIds,Integer size){
|
||||||
|
WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIds[0]);
|
||||||
|
String correctLevel = 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();
|
||||||
|
}else {
|
||||||
|
correctLevel = bySubId.getPowerLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
String errMsg = "以下基板ID出现混档:";
|
||||||
|
boolean res = false;
|
||||||
|
for(int i=0;i<size;i++){
|
||||||
|
WoPackagingBoxSubstrate innerSub = substrateServiceBiz.getBySubId(subIds[i]);
|
||||||
|
String powerLevel = null;
|
||||||
|
if(innerSub==null){
|
||||||
|
powerLevel = getFromCamline(subIds[i]).getPowerLevel();
|
||||||
|
}else {
|
||||||
|
powerLevel = innerSub.getPowerLevel();
|
||||||
|
}
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
kukaStep2.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer shelfIsFull = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程二 任务( 开始 ) ===================================");
|
||||||
|
if(shelfIsFull != 1){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败");
|
||||||
|
}else if(shelfIsFull == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subIdList 和 lineNum
|
||||||
|
String[] subIdList = (String[])read(S7Client.S7_DDJ2,Step2Plc2MesVar.SubIdList);
|
||||||
|
Integer listSize = (Integer)read(S7Client.S7_DDJ2,Step2Plc2MesVar.PackageNumberSet)-1;
|
||||||
|
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
//1.MES 生成BoxId
|
||||||
|
if(subIdList.length<=0){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"从plc里面获取到的基板列表 为空");
|
||||||
|
throw new Exception("BOXID生成Event失败-------kuka机械手 取到了空箱");
|
||||||
|
}
|
||||||
|
if(listSize == null){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"从plc里面获取到的listSize 为null");
|
||||||
|
throw new Exception("BOXID生成Event失败-------listSize 为null");
|
||||||
|
}
|
||||||
|
|
||||||
|
//真实的基板ID 就是17位的,plc读取过来,有空格,要把后面3位空格去掉就行了。
|
||||||
|
for(int i=0;i<subIdList.length;i++){
|
||||||
|
subIdList[i] = removeKG(subIdList[i]);
|
||||||
|
}
|
||||||
|
logger.info("BOXID生成Event-------获取到基板列表:"+ Arrays.toString(subIdList)+",基板数量:"+listSize);
|
||||||
|
|
||||||
|
WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIdList[0]);
|
||||||
|
logger.info("BOXID生成Event-------依据subId"+subIdList[0]+"去qgs数据库 查询数据,数据内容:"+bySubId);
|
||||||
|
|
||||||
|
|
||||||
|
//如果我们系统中找不到这块基板那么就去camline里面找
|
||||||
|
// if(bySubId == null){
|
||||||
|
// logger.info("BOXID生成Event-------数据库中 无subId:"+ subIdList[0]+"现在从camline 系统获取这个基板相关信息");
|
||||||
|
// //todo
|
||||||
|
// CamlineSubIdDTO subIdByCamline = service.getSubIdByCamline(subIdList[0]);
|
||||||
|
// bySubId = new WoPackagingBoxSubstrate();
|
||||||
|
// bySubId.setPowerLevel(subIdByCamline.getPowerLevel());
|
||||||
|
// bySubId.setSapMaterial(subIdByCamline.getSapMaterial());
|
||||||
|
// bySubId.setLineBody(2);
|
||||||
|
// }
|
||||||
|
if(bySubId == null){
|
||||||
|
logger.info("BOXID生成Event-------数据库中 无subId:"+ subIdList[0]);
|
||||||
|
throw new Exception("BOXID生成Event-------数据库中 无subId:"+ subIdList[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//校验是否存在混档位情况
|
||||||
|
String boxId = "";
|
||||||
|
if(isMixLevel(subIdList,listSize)){
|
||||||
|
//出现混档
|
||||||
|
logger.info("BOXID生成Event-------subIdList :"+Arrays.asList(subIdList)+"出现混档");
|
||||||
|
boxId = getErrorBoxId(bySubId.getSapMaterial());
|
||||||
|
|
||||||
|
}else {
|
||||||
|
//正常情况
|
||||||
|
logger.info("BOXID生成Event-------subIdList :"+Arrays.asList(subIdList)+"没有出现混档");
|
||||||
|
boxId = getBoxId(bySubId.getSapMaterial());
|
||||||
|
}
|
||||||
|
logger.info("BOXID生成Event-------subIdList :"+Arrays.asList(subIdList)+"isMixLevel 校验结束");
|
||||||
|
|
||||||
|
logger.info("BOXID生成Event-------mes 生成的boxId :"+ boxId);
|
||||||
|
//2. 依次update 基板表,把boxId 赋予这些基板
|
||||||
|
for(int i=0;i<listSize;i++){
|
||||||
|
substrateServiceBiz.updatePackagingBoxIdAndSlotByWoSubstrateId(boxId,(i+1),subIdList[i]);
|
||||||
|
}
|
||||||
|
//3.去camline数据库 查询此基板ID 对应的订单
|
||||||
|
String orderNameBySubId = service.getOrderNameBySubId(subIdList[0]);
|
||||||
|
//4. box信息录入到box表
|
||||||
|
WoPackagingBox woPackagingBox = new WoPackagingBox();
|
||||||
|
woPackagingBox.setBoxNo(boxId);
|
||||||
|
woPackagingBox.setSubstrateQuantity(listSize);
|
||||||
|
woPackagingBox.setPackagingTime(LocalDateTime.now());
|
||||||
|
woPackagingBox.setPowerLevel(bySubId.getPowerLevel());
|
||||||
|
woPackagingBox.setLineBody(bySubId.getLineBody());
|
||||||
|
woPackagingBox.setSapMaterial(bySubId.getSapMaterial());
|
||||||
|
woPackagingBox.setOrderNum(orderNameBySubId);
|
||||||
|
//1-手动模式,2-自动模式
|
||||||
|
woPackagingBox.setModel(2);
|
||||||
|
woPackagingBox.setCreateTime(LocalDateTime.now());
|
||||||
|
woPackagingBox.setPackagingTime(LocalDateTime.now());
|
||||||
|
boxServiceBiz.insert(woPackagingBox);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"写入数据库成功");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
//三. 把生成的BoxId 告诉kuka
|
||||||
|
write(S7Client.S7_DDJ2,Step2Mes2PlcVar.BoxId,boxId);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"传给PLC 成功");
|
||||||
|
|
||||||
|
//四. 当MES完成任务后,把MesToPlc.ShelfIsFullFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ2,Step2Mes2PlcVar.ShelfIsFullFinish,true);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"ShelfIsFullFinish 置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("BOXID生成Event-------失败"+" --- "+"步骤1. MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
}else if(subArrived2 == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
write(S7Client.S7_DDJ2,Step2Mes2PlcVar.ShelfIsFullFinish,false);
|
||||||
|
logger.info("BOXID生成Event-------boxId :"+ boxId+"ShelfIsFullFinish 置为false 成功,Event2 成功结束");
|
||||||
|
logger.info("================================== 现在开始执行 过程二 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
|
||||||
|
}catch (Throwable e){
|
||||||
|
// logger.info("BOXID生成Event------- 出现异常:" + e.toString());
|
||||||
|
logger.info("BOXID生成Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step1Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step1Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step2Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step2Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step3Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step3Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,354 @@
|
|||||||
|
package com.cnbm.dispatch.line2;
|
||||||
|
|
||||||
|
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.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.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 KukaEvent3ThreadLine2 implements ApplicationRunner {
|
||||||
|
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("EVENT3Line2");
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DynamicDataSourceService service;
|
||||||
|
@Autowired
|
||||||
|
WoPowerLevelServiceBiz levelServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoCompensationPowerServiceBiz compensationPowerServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||||
|
|
||||||
|
public KukaEvent3ThreadLine2(){
|
||||||
|
this.kukaStep3 = Executors.newScheduledThreadPool(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
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 (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<size;i++){
|
||||||
|
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
|
||||||
|
kukaStep3.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer shelfIsFull = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程三 任务( 开始 ) ===================================");
|
||||||
|
if(shelfIsFull != 1){
|
||||||
|
logger.info("装箱单打印Event------失败"+" --- "+"MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败");
|
||||||
|
}else if(shelfIsFull == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subIdList 和 lineNum
|
||||||
|
String boxId = (String)read(S7Client.S7_DDJ2,Step3Plc2MesVar.BoxId);
|
||||||
|
Integer lineNum = (Integer) read(S7Client.S7_DDJ2,Step3Plc2MesVar.LineNum);
|
||||||
|
if(boxId == null){
|
||||||
|
logger.info("装箱单打印Event-------失败"+" --- "+"从plc里面获取到的boxId 为null");
|
||||||
|
throw new Exception("装箱单打印Event-------boxId 为null");
|
||||||
|
}
|
||||||
|
logger.info("装箱单打印Event------到达站台的boxId :"+boxId);
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
//1. box信息录入到box表
|
||||||
|
boxServiceBiz.updateIsArrivedByBoxNo(1,boxId);
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+"更新数据库成功");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
|
||||||
|
//四. 当MES完成任务后,把MesToPlc.ShelfIsFullArrivedFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ2,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,true);
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+", ShelfIsFullArrivedFinish置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("装箱单打印Event------失败"+" --- "+"步骤1. MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败");
|
||||||
|
}else if(subArrived2 == 2){
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+", 监听到subArrived=false 成功");
|
||||||
|
write(S7Client.S7_DDJ2,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,false);
|
||||||
|
logger.info("装箱单打印Event------boxId :"+boxId+", Even3 成功");
|
||||||
|
|
||||||
|
logger.info("================================== 现在开始执行 过程三 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
}catch (Throwable e){
|
||||||
|
// e.printStackTrace();
|
||||||
|
// logger.info("装箱单打印Event 出现异常------"+e.toString());
|
||||||
|
logger.info("装箱单打印Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step1Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step1Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step2Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step2Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step3Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step3Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,306 @@
|
|||||||
|
package com.cnbm.dispatch.line2;
|
||||||
|
|
||||||
|
import cn.hutool.core.date.DateUtil;
|
||||||
|
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.dispatch.enums.kuka.step4.Step4Mes2PlcVar;
|
||||||
|
import com.cnbm.dispatch.enums.kuka.step4.Step4Plc2MesVar;
|
||||||
|
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.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 KukaEvent4ThreadLine2 implements ApplicationRunner {
|
||||||
|
private static final Logger logger = LoggerFactory.getLogger("EVENT4NGLine2");
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
DynamicDataSourceService service;
|
||||||
|
@Autowired
|
||||||
|
WoPowerLevelServiceBiz levelServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoCompensationPowerServiceBiz compensationPowerServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxSubstrateServiceBiz substrateServiceBiz;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
WoPackagingBoxServiceBiz boxServiceBiz;
|
||||||
|
|
||||||
|
public KukaEvent4ThreadLine2(){
|
||||||
|
this.kukaStep1 = Executors.newScheduledThreadPool(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
private ScheduledExecutorService kukaStep1;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return
|
||||||
|
* 成功: 返回相应的object对象
|
||||||
|
* 失败: 返回null
|
||||||
|
* */
|
||||||
|
private Object read(S7Client s7Client, Step4Plc2MesVar 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, Step4Mes2PlcVar 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<size;i++){
|
||||||
|
String powerLevel = substrateServiceBiz.getBySubId(subIds[i]).getPowerLevel();
|
||||||
|
|
||||||
|
if(!powerLevel.equals(correctLevel)){
|
||||||
|
errMsg += "基板ID:"+subIds[i]+" 档位:"+powerLevel+", ";
|
||||||
|
res = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(res){
|
||||||
|
logger.error(errMsg);
|
||||||
|
}
|
||||||
|
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run(ApplicationArguments args) throws Exception {
|
||||||
|
|
||||||
|
kukaStep1.scheduleAtFixedRate(new Runnable() {
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
try {
|
||||||
|
|
||||||
|
//调度开始
|
||||||
|
Integer subArrived = waitingForTarget(Step4Plc2MesVar.SubArrivedToMes, true);
|
||||||
|
logger.info("");
|
||||||
|
logger.info("================================== 现在开始执行 过程四 任务( 开始 ) ===================================");
|
||||||
|
if(subArrived != 1){
|
||||||
|
logger.info("NG口基板Event--- 失败"+" --- "+" MES监听 Step4Plc2MesVar.SubArrivedToMes 是否 等于 true 失败");
|
||||||
|
} else if (subArrived == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
logger.info("NG口基板Event --- 成功 ---- MES监听到 Step4Plc2MesVar.SubArrivedToMes==true");
|
||||||
|
|
||||||
|
//一. 从plc 中获取 subId
|
||||||
|
String subId = (String) read(S7Client.S7_DDJ2,Step4Plc2MesVar.SubIdToMes);
|
||||||
|
Integer lineNum = 1;
|
||||||
|
//把基板ID字符串的空格去掉,因为plc中设置的20位,但实际基板ID就是17位,因为带空格去数据库查询 有问题的。
|
||||||
|
if(subId == null ){
|
||||||
|
logger.info("NG口基板Event--- 失败"+" --- "+" MES采集到null值,subId:"+subId);
|
||||||
|
}
|
||||||
|
subId = removeKG(subId);
|
||||||
|
logger.info("NG口基板Event --- 成功 ---- MES 从plu中 read 到基板id:"+subId);
|
||||||
|
|
||||||
|
//二. MES 业务
|
||||||
|
//=============== MES 业务 开始 =================
|
||||||
|
logger.info("================= 现在开始执行 过程四 任务 ( MES 业务 ) ( 开始 ) ==================");
|
||||||
|
//1. 从comline数据库中获取 实际pmpp
|
||||||
|
float pmppActual = service.getPMPPBySubId(subId);
|
||||||
|
//2. 匹配和计算补偿功率
|
||||||
|
float pmppCompensation = compensationPowerServiceBiz.calculCompensationPMPP(pmppActual,lineNum);
|
||||||
|
//3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka
|
||||||
|
WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(pmppCompensation, lineNum);
|
||||||
|
write(S7Client.S7_DDJ2,Step4Mes2PlcVar.dLable_Pnom,Integer.valueOf(argByPMPP.getPowerClass()));
|
||||||
|
write(S7Client.S7_DDJ2,Step4Mes2PlcVar.dLable_Voc,argByPMPP.getLableVoc());
|
||||||
|
write(S7Client.S7_DDJ2,Step4Mes2PlcVar.dLable_Isc,argByPMPP.getLableIsc());
|
||||||
|
write(S7Client.S7_DDJ2,Step4Mes2PlcVar.dLable_Vmpp,argByPMPP.getLableVmpp());
|
||||||
|
write(S7Client.S7_DDJ2,Step4Mes2PlcVar.dLable_Impp,argByPMPP.getLableImpp());
|
||||||
|
logger.info("NG口基板Event--- 采集到 基板ID: "+subId+", 线边号:"+lineNum+",从camline 获取到实际pmpp"+pmppActual+",计算后 补偿功率:"+pmppCompensation+",dLable_Pnom: "+argByPMPP.getPowerClass() +",dLable_Voc: "+argByPMPP.getLableVoc()+",dLable_Isc: "+argByPMPP.getLableIsc()+",dLable_Vmpp: "+argByPMPP.getLableVmpp()+",dLable_Impp: "+argByPMPP.getLableImpp());
|
||||||
|
|
||||||
|
logger.info("================= 现在开始执行 过程四 任务 ( MES 业务 - 数据已经传给PLC ) ( 结束 ) ==================");
|
||||||
|
//=============== MES 业务 结束 =================
|
||||||
|
|
||||||
|
//三. 当MES完成任务后,把MesToPlc.SubArrivedFinish变量置为true,告诉plc,我操作完成了
|
||||||
|
write(S7Client.S7_DDJ2,Step4Mes2PlcVar.SubArrivedFinish,true);
|
||||||
|
logger.info("NG口基板Event--- 基板ID: "+subId+", SubArrivedFinish,置为true 成功");
|
||||||
|
//四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false
|
||||||
|
Integer subArrived2 = waitingForTarget(Step4Plc2MesVar.SubArrivedToMes, false);
|
||||||
|
if(subArrived2 != 1){
|
||||||
|
logger.info("NG口基板Event--- 失败"+" --- "+"MES监听 Step4Plc2MesVar.SubArrivedToMes 是否 等于 1 失败");
|
||||||
|
}else if (subArrived2 == 2) {
|
||||||
|
throw new Exception("MES 监听值出现异常。");
|
||||||
|
}
|
||||||
|
|
||||||
|
write(S7Client.S7_DDJ2,Step4Mes2PlcVar.SubArrivedFinish,false);
|
||||||
|
logger.info("NG口基板Event--- 基板ID: "+subId+", SubArrivedFinish,置为 false 成功");
|
||||||
|
logger.info("================================== 现在开始执行 过程四 任务( 结束 ) ===================================");
|
||||||
|
logger.info("");
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("NG口基板Event--- 出现异常 : {}",e.getMessage(),e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},1,1, TimeUnit.SECONDS);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* arg:
|
||||||
|
* Step4Plc2MesVar 参数类型
|
||||||
|
* targetValue 目的值
|
||||||
|
* return:
|
||||||
|
* 2 s7 访问异常;
|
||||||
|
* 1 成功;
|
||||||
|
* */
|
||||||
|
private Integer waitingForTarget(Step4Plc2MesVar var, Boolean targetValue) {
|
||||||
|
Integer res = 0;
|
||||||
|
while (true){
|
||||||
|
try {
|
||||||
|
|
||||||
|
Boolean now = (Boolean) read(S7Client.S7_DDJ2,var);
|
||||||
|
//注意:即使now为null ,这里也不会抛出异常,这里很容易产生 空轮询。
|
||||||
|
if(now == null){
|
||||||
|
throw new Exception("");
|
||||||
|
}
|
||||||
|
if(targetValue.equals(now)){
|
||||||
|
res = 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
Thread.sleep(200);
|
||||||
|
}catch (Throwable e){
|
||||||
|
logger.info("S7 数据采集 异常. 监听 变量 :"+var.getName()+" 为目标值:"+targetValue+"失败");
|
||||||
|
res = 2;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -23,6 +23,7 @@ import org.springframework.web.bind.annotation.*;
|
|||||||
import springfox.documentation.annotations.ApiIgnore;
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
import javax.servlet.http.HttpServletResponse;
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@ -52,13 +53,13 @@ public class PrintModelController {
|
|||||||
@ApiImplicitParam(name = "lineBody", value = "线体,1=F ; 2=S", paramType = "query", dataTypeClass = Integer.class),
|
@ApiImplicitParam(name = "lineBody", value = "线体,1=F ; 2=S", paramType = "query", dataTypeClass = Integer.class),
|
||||||
@ApiImplicitParam(name = "isEnable", value = "启用状态:0 、停用,1、启用", paramType = "query", dataTypeClass = Integer.class)
|
@ApiImplicitParam(name = "isEnable", value = "启用状态:0 、停用,1、启用", paramType = "query", dataTypeClass = Integer.class)
|
||||||
})
|
})
|
||||||
@PreAuthorize("@ex.hasAuthority('packing:printModel:page')")
|
//@PreAuthorize("@ex.hasAuthority('packing:printModel:page')")
|
||||||
public Result<PageData<PrintModelDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
public Result<PageData<PrintModelDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
PageData<PrintModelDTO> page = printModelService.page(params);
|
PageData<PrintModelDTO> page = printModelService.page(params);
|
||||||
|
|
||||||
return new Result<PageData<PrintModelDTO>>().ok(page);
|
return new Result<PageData<PrintModelDTO>>().ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@GetMapping("{id}")
|
@GetMapping("{id}")
|
||||||
@ApiOperation("信息")
|
@ApiOperation("信息")
|
||||||
@PreAuthorize("@ex.hasAuthority('packing:printModel:info')")
|
@PreAuthorize("@ex.hasAuthority('packing:printModel:info')")
|
||||||
@ -128,4 +129,11 @@ public class PrintModelController {
|
|||||||
return new Result<String>().ok(code);
|
return new Result<String>().ok(code);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("getByLineBody/{lineBody}")
|
||||||
|
@ApiOperation("依据line_body 查询,is_enable==1 && type==2 limit 1的数据")
|
||||||
|
public Result<PrintModelDTO> getByLineBody(@PathVariable("lineBody") Integer lineBody){
|
||||||
|
PrintModelDTO dto = printModelService.getByLineBody(lineBody);
|
||||||
|
return new Result<PrintModelDTO>().ok(dto);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -2,7 +2,6 @@ package com.cnbm.packing.controller;
|
|||||||
|
|
||||||
import cn.hutool.core.date.DateUtil;
|
import cn.hutool.core.date.DateUtil;
|
||||||
import com.baomidou.mybatisplus.core.metadata.IPage;
|
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.Step1Mes2PlcVar;
|
||||||
import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar;
|
import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar;
|
||||||
import com.cnbm.dispatch.enums.kuka.step2.Step2Mes2PlcVar;
|
import com.cnbm.dispatch.enums.kuka.step2.Step2Mes2PlcVar;
|
||||||
@ -11,15 +10,13 @@ import com.cnbm.dispatch.enums.kuka.step3.Step3Mes2PlcVar;
|
|||||||
import com.cnbm.dispatch.enums.kuka.step3.Step3Plc2MesVar;
|
import com.cnbm.dispatch.enums.kuka.step3.Step3Plc2MesVar;
|
||||||
import com.cnbm.packing.dto.CamlineSubIdDTO;
|
import com.cnbm.packing.dto.CamlineSubIdDTO;
|
||||||
import com.cnbm.packing.dto.CamlineSubIdForImportDTO;
|
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.entity.WoPackagingBoxSubstrate;
|
||||||
import com.cnbm.packing.mapper.WoPackagingBoxSubstrateMapper;
|
import com.cnbm.packing.mapper.WoPackagingBoxSubstrateMapper;
|
||||||
import com.cnbm.packing.param.PowerReportQueryParam;
|
|
||||||
import com.cnbm.packing.param.SubIdQueryParam;
|
import com.cnbm.packing.param.SubIdQueryParam;
|
||||||
import com.cnbm.packing.service.DynamicDataSourceService;
|
import com.cnbm.packing.service.DynamicDataSourceService;
|
||||||
import com.cnbm.packing.service.WoPackagingBoxServiceBiz;
|
import com.cnbm.packing.service.WoPackagingBoxServiceBiz;
|
||||||
import com.cnbm.packing.service.WoPackagingBoxSubstrateServiceBiz;
|
import com.cnbm.packing.service.WoPackagingBoxSubstrateServiceBiz;
|
||||||
import com.cnbm.packing.vo.PowerReportVo;
|
|
||||||
import com.cnbm.packing.vo.SubIdPageVo;
|
import com.cnbm.packing.vo.SubIdPageVo;
|
||||||
import com.cnbm.s7.entity.R;
|
import com.cnbm.s7.entity.R;
|
||||||
import com.cnbm.s7.s7connector.enmuc.S7Client;
|
import com.cnbm.s7.s7connector.enmuc.S7Client;
|
||||||
@ -129,7 +126,7 @@ public class TestController {
|
|||||||
}
|
}
|
||||||
@PostMapping("/forString")
|
@PostMapping("/forString")
|
||||||
public R forString() throws UnsupportedEncodingException, ParseException {
|
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));
|
System.out.println(Step2Plc2MesVar.SubIdList.getName()+" : "+Arrays.toString(s));
|
||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -144,8 +141,8 @@ public class TestController {
|
|||||||
|
|
||||||
|
|
||||||
@PostMapping("/forImport")
|
@PostMapping("/forImport")
|
||||||
public R forImport() throws UnsupportedEncodingException, ParseException {
|
public R forImport(@RequestBody WoCompensationPowerDTO dto) throws UnsupportedEncodingException, ParseException {
|
||||||
List<CamlineSubIdForImportDTO> alllCamlineSubForImp = service.getAlllCamlineSubForImp();
|
List<CamlineSubIdForImportDTO> alllCamlineSubForImp = service.getAlllCamlineSubForImp(dto.getRemark().split(","));
|
||||||
for(CamlineSubIdForImportDTO cam:alllCamlineSubForImp){
|
for(CamlineSubIdForImportDTO cam:alllCamlineSubForImp){
|
||||||
WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate();
|
WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate();
|
||||||
woPackagingBoxSubstrate.setWoSubstrateId(cam.getSubId());
|
woPackagingBoxSubstrate.setWoSubstrateId(cam.getSubId());
|
||||||
@ -158,6 +155,15 @@ public class TestController {
|
|||||||
return R.ok();
|
return R.ok();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// @PostMapping("/forImportTest")
|
||||||
|
// public R forImportTest(@RequestBody WoCompensationPowerDTO dto){
|
||||||
|
// System.out.println(dto.getRemark());
|
||||||
|
//
|
||||||
|
// List<CamlineSubIdForImportDTO> alllCamlineSubForImp = service.getAlllCamlineSubForImp(dto.getRemark().split(","));
|
||||||
|
//
|
||||||
|
// return R.ok().put("data",alllCamlineSubForImp);
|
||||||
|
// }
|
||||||
|
|
||||||
@PostMapping("/forTestMix")
|
@PostMapping("/forTestMix")
|
||||||
public R forTestMix() throws UnsupportedEncodingException, ParseException {
|
public R forTestMix() throws UnsupportedEncodingException, ParseException {
|
||||||
String[] s = new String[20];
|
String[] s = new String[20];
|
||||||
@ -231,30 +237,61 @@ public class TestController {
|
|||||||
@PostMapping("/testReadAll")
|
@PostMapping("/testReadAll")
|
||||||
public R testReadAll() throws UnsupportedEncodingException, ParseException {
|
public R testReadAll() throws UnsupportedEncodingException, ParseException {
|
||||||
for(Step1Plc2MesVar actual:Step1Plc2MesVar.values()){
|
for(Step1Plc2MesVar actual:Step1Plc2MesVar.values()){
|
||||||
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
logger.info(read(S7Client.S7_DDJ1,actual).toString());
|
||||||
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString());
|
||||||
}
|
}
|
||||||
for(Step1Mes2PlcVar actual:Step1Mes2PlcVar.values()){
|
for(Step1Mes2PlcVar actual:Step1Mes2PlcVar.values()){
|
||||||
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
logger.info(read(S7Client.S7_DDJ1,actual).toString());
|
||||||
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Step2Plc2MesVar actual:Step2Plc2MesVar.values()){
|
for(Step2Plc2MesVar actual:Step2Plc2MesVar.values()){
|
||||||
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
logger.info(read(S7Client.S7_DDJ1,actual).toString());
|
||||||
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString());
|
||||||
}
|
}
|
||||||
for(Step2Mes2PlcVar actual:Step2Mes2PlcVar.values()){
|
for(Step2Mes2PlcVar actual:Step2Mes2PlcVar.values()){
|
||||||
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
logger.info(read(S7Client.S7_DDJ1,actual).toString());
|
||||||
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
for(Step3Plc2MesVar actual:Step3Plc2MesVar.values()){
|
for(Step3Plc2MesVar actual:Step3Plc2MesVar.values()){
|
||||||
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
logger.info(read(S7Client.S7_DDJ1,actual).toString());
|
||||||
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
|
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_DDJ1,actual).toString());
|
||||||
}
|
}
|
||||||
for(Step3Mes2PlcVar actual:Step3Mes2PlcVar.values()){
|
for(Step3Mes2PlcVar actual:Step3Mes2PlcVar.values()){
|
||||||
logger.info(read(S7Client.S7_KUKA,actual).toString());
|
logger.info(read(S7Client.S7_DDJ1,actual).toString());
|
||||||
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,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();
|
return R.ok();
|
||||||
}
|
}
|
||||||
@ -270,32 +307,32 @@ public class TestController {
|
|||||||
BigDecimal isc = new BigDecimal(3.799);
|
BigDecimal isc = new BigDecimal(3.799);
|
||||||
BigDecimal vmpp = new BigDecimal(46.799);
|
BigDecimal vmpp = new BigDecimal(46.799);
|
||||||
BigDecimal impp = new BigDecimal(3.0799);
|
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);
|
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());
|
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());
|
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());
|
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());
|
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");
|
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");
|
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");
|
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");
|
System.out.println(Step3Mes2PlcVar.ShelfIsFullArrivedFinish.getName()+" : "+"true");
|
||||||
|
|
||||||
|
|
||||||
|
@ -63,7 +63,6 @@ public class WoPackagingBoxController {
|
|||||||
// @ApiImplicitParam(name = "printStatus", value = "打印状态:0、未打印,1、已打印", paramType = "query", dataTypeClass = Integer.class),
|
// @ApiImplicitParam(name = "printStatus", value = "打印状态:0、未打印,1、已打印", paramType = "query", dataTypeClass = Integer.class),
|
||||||
@ApiImplicitParam(name = "model", value = "模式,1-手动模式;2-自动模式", paramType = "query", dataTypeClass = Integer.class)
|
@ApiImplicitParam(name = "model", value = "模式,1-手动模式;2-自动模式", paramType = "query", dataTypeClass = Integer.class)
|
||||||
})
|
})
|
||||||
@PreAuthorize("@ex.hasAuthority('packing:woPackagingBox:page')")
|
|
||||||
public Result<PageData<WoPackagingBoxDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
public Result<PageData<WoPackagingBoxDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
PageData<WoPackagingBoxDTO> page = woPackagingBoxService.page(params);
|
PageData<WoPackagingBoxDTO> page = woPackagingBoxService.page(params);
|
||||||
|
|
||||||
|
@ -52,7 +52,6 @@ public class WoPowerLevelController {
|
|||||||
@PreAuthorize("@ex.hasAuthority('packing:woPowerLevel:page')")
|
@PreAuthorize("@ex.hasAuthority('packing:woPowerLevel:page')")
|
||||||
public Result<PageData<WoPowerLevelDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
public Result<PageData<WoPowerLevelDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
PageData<WoPowerLevelDTO> page = woPowerLevelService.page(params);
|
PageData<WoPowerLevelDTO> page = woPowerLevelService.page(params);
|
||||||
|
|
||||||
return new Result<PageData<WoPowerLevelDTO>>().ok(page);
|
return new Result<PageData<WoPowerLevelDTO>>().ok(page);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -61,7 +60,6 @@ public class WoPowerLevelController {
|
|||||||
@PreAuthorize("@ex.hasAuthority('packing:woPowerLevel:info')")
|
@PreAuthorize("@ex.hasAuthority('packing:woPowerLevel:info')")
|
||||||
public Result<WoPowerLevelDTO> get(@PathVariable("id") Long id){
|
public Result<WoPowerLevelDTO> get(@PathVariable("id") Long id){
|
||||||
WoPowerLevelDTO data = woPowerLevelService.get(id);
|
WoPowerLevelDTO data = woPowerLevelService.get(id);
|
||||||
|
|
||||||
return new Result<WoPowerLevelDTO>().ok(data);
|
return new Result<WoPowerLevelDTO>().ok(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -0,0 +1,125 @@
|
|||||||
|
package com.cnbm.packing.controller;
|
||||||
|
|
||||||
|
import com.cnbm.admin.annotation.LogOperation;
|
||||||
|
import com.cnbm.common.constant.Constant;
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.utils.ExcelUtils;
|
||||||
|
import com.cnbm.common.utils.Result;
|
||||||
|
import com.cnbm.common.validator.AssertUtils;
|
||||||
|
import com.cnbm.common.validator.ValidatorUtils;
|
||||||
|
import com.cnbm.common.validator.group.AddGroup;
|
||||||
|
import com.cnbm.common.validator.group.DefaultGroup;
|
||||||
|
import com.cnbm.common.validator.group.UpdateGroup;
|
||||||
|
import com.cnbm.packing.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.packing.excel.WorkingTimeExcel;
|
||||||
|
import com.cnbm.packing.service.WorkingTimeServiceBiz;
|
||||||
|
import io.swagger.annotations.Api;
|
||||||
|
import io.swagger.annotations.ApiImplicitParam;
|
||||||
|
import io.swagger.annotations.ApiImplicitParams;
|
||||||
|
import io.swagger.annotations.ApiOperation;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
|
import org.springframework.web.bind.annotation.*;
|
||||||
|
import springfox.documentation.annotations.ApiIgnore;
|
||||||
|
|
||||||
|
import javax.servlet.http.HttpServletResponse;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表 前端控制器
|
||||||
|
*
|
||||||
|
* @author packingGenerator
|
||||||
|
* @since 2023-12-19
|
||||||
|
*/
|
||||||
|
@RestController
|
||||||
|
@RequestMapping("/packing/workingTime")
|
||||||
|
@Api(tags="班次时间段 表")
|
||||||
|
public class WorkingTimeController {
|
||||||
|
@Autowired
|
||||||
|
private WorkingTimeServiceBiz workingTimeService;
|
||||||
|
|
||||||
|
@GetMapping("page")
|
||||||
|
@ApiOperation("分页")
|
||||||
|
@ApiImplicitParams({
|
||||||
|
@ApiImplicitParam(name = Constant.PAGE, value = "当前页码,从1开始", paramType = "query", required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.LIMIT, value = "每页显示记录数", paramType = "query",required = true, dataTypeClass=Integer.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER_FIELD, value = "排序字段", paramType = "query", dataTypeClass=String.class) ,
|
||||||
|
@ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class)
|
||||||
|
})
|
||||||
|
@PreAuthorize("@ex.hasAuthority('packing:workingTime:page')")
|
||||||
|
public Result<PageData<WorkingTimeDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){
|
||||||
|
PageData<WorkingTimeDTO> page = workingTimeService.page(params);
|
||||||
|
|
||||||
|
return new Result<PageData<WorkingTimeDTO>>().ok(page);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("{id}")
|
||||||
|
@ApiOperation("信息")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('packing:workingTime:info')")
|
||||||
|
public Result<WorkingTimeDTO> get(@PathVariable("id") Long id){
|
||||||
|
WorkingTimeDTO data = workingTimeService.get(id);
|
||||||
|
|
||||||
|
return new Result<WorkingTimeDTO>().ok(data);
|
||||||
|
}
|
||||||
|
|
||||||
|
@PostMapping
|
||||||
|
@ApiOperation("保存")
|
||||||
|
@LogOperation("保存")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('packing:workingTime:save')")
|
||||||
|
public Result<Long> save(@RequestBody WorkingTimeDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, AddGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
|
workingTimeService.save(dto);
|
||||||
|
|
||||||
|
return new Result<Long>().ok(dto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@PutMapping
|
||||||
|
@ApiOperation("修改")
|
||||||
|
@LogOperation("修改")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('packing:workingTime:update')")
|
||||||
|
public Result<Long> update(@RequestBody WorkingTimeDTO dto){
|
||||||
|
//效验数据
|
||||||
|
ValidatorUtils.validateEntity(dto, UpdateGroup.class, DefaultGroup.class);
|
||||||
|
|
||||||
|
workingTimeService.update(dto);
|
||||||
|
|
||||||
|
return new Result<Long>().ok(dto.getId());
|
||||||
|
}
|
||||||
|
|
||||||
|
@DeleteMapping
|
||||||
|
@ApiOperation("删除")
|
||||||
|
@LogOperation("删除")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('packing:workingTime:delete')")
|
||||||
|
public Result delete(@RequestBody Long[] ids){
|
||||||
|
//效验数据
|
||||||
|
AssertUtils.isArrayEmpty(ids, "id");
|
||||||
|
|
||||||
|
workingTimeService.delete(ids);
|
||||||
|
|
||||||
|
return new Result();
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("export")
|
||||||
|
@ApiOperation("导出")
|
||||||
|
@LogOperation("导出")
|
||||||
|
@PreAuthorize("@ex.hasAuthority('packing:workingTime:export')")
|
||||||
|
public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception {
|
||||||
|
List<WorkingTimeDTO> list = workingTimeService.list(params);
|
||||||
|
|
||||||
|
ExcelUtils.exportExcelToTarget(response, null, list, WorkingTimeExcel.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@GetMapping("getOrderName")
|
||||||
|
@ApiOperation("查询时间匹配的班次名称")
|
||||||
|
public Result<String> getOrderName(@RequestBody LocalDateTime time){
|
||||||
|
String orderName = workingTimeService.getOrderName(time);
|
||||||
|
|
||||||
|
return new Result<String>().ok(orderName);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -80,4 +80,10 @@ public class PrintModelDTO implements Serializable {
|
|||||||
@ApiModelProperty(value = "是否启用,0 停用;1 启用")
|
@ApiModelProperty(value = "是否启用,0 停用;1 启用")
|
||||||
private Integer isEnable;
|
private Integer isEnable;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "场景,前端传字符串过来,目前固定这几个:DZ BIPV")
|
||||||
|
private String scenes;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "产品等级,目前固定这几个 : A1 A2 A3 A4 NK")
|
||||||
|
private String productGrade;
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,63 @@
|
|||||||
|
package com.cnbm.packing.dto;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@ApiModel(value = "班次时间段 表DTO对象")
|
||||||
|
public class WorkingTimeDTO implements Serializable {
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "班次名 ,A/B/C...")
|
||||||
|
private String orderName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "班次开始时间, 0点 - 24点")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "班次结束时间, 0点 - 24点")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "删除标志,是否有效:1 可用 0不可用")
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建人")
|
||||||
|
private Long creatorId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建人姓名")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新人")
|
||||||
|
private Long updaterId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新人姓名")
|
||||||
|
private String updaterName;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
}
|
@ -81,6 +81,12 @@ public class PrintModel implements Serializable {
|
|||||||
@ApiModelProperty("是否启用,0 停用;1 启用")
|
@ApiModelProperty("是否启用,0 停用;1 启用")
|
||||||
private Integer isEnable;
|
private Integer isEnable;
|
||||||
|
|
||||||
|
@ApiModelProperty("场景,前端传字符串过来,目前固定这几个:DZ BIPV")
|
||||||
|
private String scenes;
|
||||||
|
|
||||||
|
@ApiModelProperty("产品等级,目前固定这几个 : A1 A2 A3 A4 NK")
|
||||||
|
private String productGrade;
|
||||||
|
|
||||||
|
|
||||||
public static final String ID = "ID";
|
public static final String ID = "ID";
|
||||||
|
|
||||||
@ -120,4 +126,8 @@ public class PrintModel implements Serializable {
|
|||||||
|
|
||||||
public static final String IS_ENABLE = "is_enable";
|
public static final String IS_ENABLE = "is_enable";
|
||||||
|
|
||||||
|
public static final String SCENES = "scenes";
|
||||||
|
|
||||||
|
public static final String PRODUCT_GRADE = "product_grade";
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,94 @@
|
|||||||
|
package com.cnbm.packing.entity;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableLogic;
|
||||||
|
import com.baomidou.mybatisplus.annotation.TableName;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.io.Serializable;
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* 班次时间段 表
|
||||||
|
* </p>
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
@TableName("t_working_time")
|
||||||
|
@ApiModel(value = "WorkingTime对象", description = "班次时间段 表")
|
||||||
|
public class WorkingTime implements Serializable {
|
||||||
|
|
||||||
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
|
@ApiModelProperty("ID")
|
||||||
|
private Long id;
|
||||||
|
|
||||||
|
@ApiModelProperty("班次名 ,A/B/C...")
|
||||||
|
private String orderName;
|
||||||
|
|
||||||
|
@ApiModelProperty("班次开始时间, 0点 - 24点")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("班次结束时间, 0点 - 24点")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("备注")
|
||||||
|
private String remark;
|
||||||
|
|
||||||
|
@ApiModelProperty("删除标志,是否有效:1 可用 0不可用")
|
||||||
|
@TableLogic
|
||||||
|
private Integer valid;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建人")
|
||||||
|
private Long creatorId;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建人姓名")
|
||||||
|
private String creatorName;
|
||||||
|
|
||||||
|
@ApiModelProperty("创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新人")
|
||||||
|
private Long updaterId;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新人姓名")
|
||||||
|
private String updaterName;
|
||||||
|
|
||||||
|
@ApiModelProperty("更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty("版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
|
||||||
|
public static final String ID = "id";
|
||||||
|
|
||||||
|
public static final String ORDER_NAME = "order_name";
|
||||||
|
|
||||||
|
public static final String BEGIN_TIME = "begin_time";
|
||||||
|
|
||||||
|
public static final String END_TIME = "end_time";
|
||||||
|
|
||||||
|
public static final String REMARK = "remark";
|
||||||
|
|
||||||
|
public static final String VALID = "valid";
|
||||||
|
|
||||||
|
public static final String CREATOR_ID = "creator_id";
|
||||||
|
|
||||||
|
public static final String CREATOR_NAME = "creator_name";
|
||||||
|
|
||||||
|
public static final String CREATE_TIME = "create_time";
|
||||||
|
|
||||||
|
public static final String UPDATER_ID = "updater_id";
|
||||||
|
|
||||||
|
public static final String UPDATER_NAME = "updater_name";
|
||||||
|
|
||||||
|
public static final String UPDATE_TIME = "update_time";
|
||||||
|
|
||||||
|
public static final String VERSION = "version";
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,43 @@
|
|||||||
|
package com.cnbm.packing.excel;
|
||||||
|
|
||||||
|
import cn.afterturn.easypoi.excel.annotation.Excel;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-19
|
||||||
|
*/
|
||||||
|
@Data
|
||||||
|
public class WorkingTimeExcel {
|
||||||
|
@Excel(name = "ID")
|
||||||
|
private Long id;
|
||||||
|
@Excel(name = "班次名 ,A/B/C...")
|
||||||
|
private String orderName;
|
||||||
|
@Excel(name = "班次开始时间, 0点 - 24点")
|
||||||
|
private LocalDateTime beginTime;
|
||||||
|
@Excel(name = "班次结束时间, 0点 - 24点")
|
||||||
|
private LocalDateTime endTime;
|
||||||
|
@Excel(name = "备注")
|
||||||
|
private String remark;
|
||||||
|
@Excel(name = "删除标志,是否有效:1 可用 0不可用")
|
||||||
|
private Integer valid;
|
||||||
|
@Excel(name = "创建人")
|
||||||
|
private Long creatorId;
|
||||||
|
@Excel(name = "创建人姓名")
|
||||||
|
private String creatorName;
|
||||||
|
@Excel(name = "创建时间")
|
||||||
|
private LocalDateTime createTime;
|
||||||
|
@Excel(name = "更新人")
|
||||||
|
private Long updaterId;
|
||||||
|
@Excel(name = "更新人姓名")
|
||||||
|
private String updaterName;
|
||||||
|
@Excel(name = "更新时间")
|
||||||
|
private LocalDateTime updateTime;
|
||||||
|
@Excel(name = "版本号")
|
||||||
|
private Integer version;
|
||||||
|
|
||||||
|
}
|
@ -28,8 +28,9 @@ public interface CamlineMapper {
|
|||||||
CamlineExtendArgDTO getExtendArgFromCamline(@Param("subId") String subId);
|
CamlineExtendArgDTO getExtendArgFromCamline(@Param("subId") String subId);
|
||||||
|
|
||||||
Integer getTodayBoxNum();
|
Integer getTodayBoxNum();
|
||||||
|
Integer getTodayErrBoxNum();
|
||||||
|
|
||||||
CamlineSubIdDTO getSubIdByCamline(@Param("subId") String subId);
|
CamlineSubIdDTO getSubIdByCamline(@Param("subId") String subId);
|
||||||
|
|
||||||
List<CamlineSubIdForImportDTO> getSubIdByCamlineForImpoet();
|
List<CamlineSubIdForImportDTO> getSubIdByCamlineForImpoet(@Param("subIds") String[] subIds);
|
||||||
}
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package com.cnbm.packing.mapper;
|
||||||
|
|
||||||
|
import com.cnbm.common.dao.BaseDao;
|
||||||
|
import com.cnbm.packing.dto.WoPowerLevelDTO;
|
||||||
|
import com.cnbm.packing.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.packing.entity.WorkingTime;
|
||||||
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 打印标签模板表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-02-15
|
||||||
|
*/
|
||||||
|
@Mapper
|
||||||
|
public interface WorkingTimeMapper extends BaseDao<WorkingTime> {
|
||||||
|
|
||||||
|
List<WorkingTimeDTO> list();
|
||||||
|
|
||||||
|
}
|
@ -31,6 +31,10 @@ public class DynamicDataSourceService {
|
|||||||
return mapper.getTodayBoxNum();
|
return mapper.getTodayBoxNum();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Integer getTodayErrBoxNum(){
|
||||||
|
return mapper.getTodayErrBoxNum();
|
||||||
|
}
|
||||||
|
|
||||||
@DataSource("camline")
|
@DataSource("camline")
|
||||||
@Transactional
|
@Transactional
|
||||||
public float getPMPPBySubId(String subId){
|
public float getPMPPBySubId(String subId){
|
||||||
@ -57,8 +61,8 @@ public class DynamicDataSourceService {
|
|||||||
|
|
||||||
@DataSource("camline")
|
@DataSource("camline")
|
||||||
@Transactional
|
@Transactional
|
||||||
public List<CamlineSubIdForImportDTO> getAlllCamlineSubForImp(){
|
public List<CamlineSubIdForImportDTO> getAlllCamlineSubForImp(String[] subIds){
|
||||||
return mapper.getSubIdByCamlineForImpoet();
|
return mapper.getSubIdByCamlineForImpoet(subIds);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -30,4 +30,6 @@ public interface PrintModelServiceBiz extends CrudService<PrintModel, PrintModel
|
|||||||
List<PrintModelDTO> list();
|
List<PrintModelDTO> list();
|
||||||
|
|
||||||
String getCode();
|
String getCode();
|
||||||
|
|
||||||
|
PrintModelDTO getByLineBody(Integer lineBody);
|
||||||
}
|
}
|
@ -0,0 +1,34 @@
|
|||||||
|
package com.cnbm.packing.service;
|
||||||
|
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.service.CrudService;
|
||||||
|
import com.cnbm.packing.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.packing.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.packing.entity.WorkingTime;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-19
|
||||||
|
*/
|
||||||
|
public interface WorkingTimeServiceBiz extends CrudService<WorkingTime, WorkingTimeDTO> {
|
||||||
|
|
||||||
|
PageData<WorkingTimeDTO> page (Map<String, Object> params);
|
||||||
|
|
||||||
|
WorkingTimeDTO get(Long id);
|
||||||
|
|
||||||
|
void save(WorkingTimeDTO dto);
|
||||||
|
|
||||||
|
void update(WorkingTimeDTO dto);
|
||||||
|
|
||||||
|
void delete(Long[] ids);
|
||||||
|
|
||||||
|
List<WorkingTimeDTO> list();
|
||||||
|
|
||||||
|
String getOrderName(LocalDateTime time);
|
||||||
|
}
|
@ -107,5 +107,18 @@ public class PrintModelServiceBizImpl extends CrudServiceImpl<PrintModelMapper,
|
|||||||
return CodeGeneratorHelper.getPrintModelCode();
|
return CodeGeneratorHelper.getPrintModelCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PrintModelDTO getByLineBody(Integer lineBody){
|
||||||
|
QueryWrapper<PrintModel> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq(ObjectUtils.isNotNull(lineBody), PrintModel.LINE_BODY, lineBody);
|
||||||
|
wrapper.eq(PrintModel.IS_ENABLE,1);
|
||||||
|
wrapper.eq(PrintModel.TYPE,2);
|
||||||
|
List<PrintModel> list = mapper.selectList(wrapper);
|
||||||
|
PrintModel entity = new PrintModel();
|
||||||
|
if(list.size()>0){
|
||||||
|
entity = list.get(0);
|
||||||
|
}
|
||||||
|
return ConvertUtils.sourceToTarget(entity, PrintModelDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
@ -0,0 +1,122 @@
|
|||||||
|
package com.cnbm.packing.service.impl;
|
||||||
|
|
||||||
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||||
|
import com.baomidou.mybatisplus.core.metadata.IPage;
|
||||||
|
import com.cnbm.admin.utils.BaseSupportUtils;
|
||||||
|
import com.cnbm.common.page.PageData;
|
||||||
|
import com.cnbm.common.service.impl.CrudServiceImpl;
|
||||||
|
|
||||||
|
import com.cnbm.common.utils.ConvertUtils;
|
||||||
|
import com.cnbm.packing.dto.WorkingTimeDTO;
|
||||||
|
import com.cnbm.packing.entity.WorkingTime;
|
||||||
|
import com.cnbm.packing.mapper.WorkingTimeMapper;
|
||||||
|
import com.cnbm.packing.service.WorkingTimeServiceBiz;
|
||||||
|
import org.apache.commons.lang3.ObjectUtils;
|
||||||
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
|
import java.time.LocalDateTime;
|
||||||
|
import java.time.LocalTime;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 班次时间段 表
|
||||||
|
*
|
||||||
|
* @author codeGenerator
|
||||||
|
* @since 2023-12-19
|
||||||
|
*/
|
||||||
|
@Service
|
||||||
|
public class WorkingTimeServiceBizImpl extends CrudServiceImpl<WorkingTimeMapper, WorkingTime, WorkingTimeDTO> implements WorkingTimeServiceBiz {
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private WorkingTimeMapper mapper;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public QueryWrapper<WorkingTime> getWrapper(Map<String, Object> params){
|
||||||
|
String id = (String)params.get("id");
|
||||||
|
|
||||||
|
QueryWrapper<WorkingTime> wrapper = new QueryWrapper<>();
|
||||||
|
wrapper.eq(StringUtils.isNotBlank(id), "id", id);
|
||||||
|
|
||||||
|
return wrapper;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageData<WorkingTimeDTO> page (Map<String, Object> params){
|
||||||
|
IPage<WorkingTime> page = baseDao.selectPage(
|
||||||
|
getPage(params, WorkingTime.CREATE_TIME, false),
|
||||||
|
getWrapper(params)
|
||||||
|
);
|
||||||
|
return getPageData(page, WorkingTimeDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public WorkingTimeDTO get(Long id) {
|
||||||
|
WorkingTime entity = baseDao.selectById(id);
|
||||||
|
return ConvertUtils.sourceToTarget(entity, WorkingTimeDTO.class);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void save(WorkingTimeDTO dto) {
|
||||||
|
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
|
||||||
|
BaseSupportUtils.setCommonField(entity);
|
||||||
|
insert(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void update(WorkingTimeDTO dto) {
|
||||||
|
WorkingTime entity = ConvertUtils.sourceToTarget(dto, WorkingTime.class);
|
||||||
|
BaseSupportUtils.setUpdateCommonField(entity);
|
||||||
|
updateById(entity);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public void delete(Long[] ids) {
|
||||||
|
//删除
|
||||||
|
deleteBatchIds(Arrays.asList(ids));
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
@Transactional(rollbackFor = Exception.class)
|
||||||
|
public List<WorkingTimeDTO> list() {
|
||||||
|
List<WorkingTimeDTO> list = mapper.list();
|
||||||
|
return list;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getOrderName(LocalDateTime time) {
|
||||||
|
|
||||||
|
LocalTime localTime = time.toLocalTime();
|
||||||
|
List<WorkingTimeDTO> resultList = new ArrayList<>();
|
||||||
|
List<WorkingTimeDTO> listAll = mapper.list();
|
||||||
|
for(WorkingTimeDTO dto : listAll){
|
||||||
|
LocalTime beginTime = dto.getBeginTime().toLocalTime();
|
||||||
|
LocalTime endTime = dto.getEndTime().toLocalTime();
|
||||||
|
if(beginTime.isBefore(endTime)) {
|
||||||
|
if (localTime.isBefore(endTime) && localTime.isAfter(beginTime)) {
|
||||||
|
resultList.add(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if(localTime.isAfter(endTime)||localTime.isBefore(beginTime)){
|
||||||
|
resultList.add(dto);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String orderName = null;
|
||||||
|
if(resultList.size()>0){
|
||||||
|
orderName = resultList.get(0).getOrderName();
|
||||||
|
}
|
||||||
|
return orderName;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
@ -153,66 +153,25 @@
|
|||||||
LEFT JOIN e_tracking_unit tu ON flc.mainid = tu.id
|
LEFT JOIN e_tracking_unit tu ON flc.mainid = tu.id
|
||||||
LEFT JOIN er_order eo ON tu.ORDER_ID = eo.ID
|
LEFT JOIN er_order eo ON tu.ORDER_ID = eo.ID
|
||||||
WHERE
|
WHERE
|
||||||
tu.NAME IN (
|
tu.NAME IN
|
||||||
'30110012303050629',
|
<foreach collection="subIds" item="subId" index="index" open="(" close=")" separator=",">
|
||||||
'30110012302272118',
|
#{subId}
|
||||||
'30110012303050331',
|
</foreach>
|
||||||
'30110012303050321',
|
|
||||||
'30110012303030164',
|
|
||||||
'30110012303023000',
|
|
||||||
'30110012303011203',
|
|
||||||
'30110012303012089',
|
|
||||||
'30110012303011487',
|
|
||||||
'30110012302271154',
|
|
||||||
'30110012302283324',
|
|
||||||
'30110012303030787',
|
|
||||||
'30110012303050373',
|
|
||||||
'30110012303022841',
|
|
||||||
'30110012303021008',
|
|
||||||
'30110012303030325',
|
|
||||||
'30110012302283810',
|
|
||||||
'30110012303011490',
|
|
||||||
'30110012303022163',
|
|
||||||
'30110012303012695',
|
|
||||||
'30110012303010372',
|
|
||||||
'30110012303020247',
|
|
||||||
'30110012303022801',
|
|
||||||
'30110012303022407',
|
|
||||||
'30110012303012915',
|
|
||||||
'30110012303022996',
|
|
||||||
'30110012303022721',
|
|
||||||
'30110012303040003',
|
|
||||||
'30110012303023102',
|
|
||||||
'30110012302281213',
|
|
||||||
'30110012303022204',
|
|
||||||
'30110012302281212',
|
|
||||||
'30110012303022970',
|
|
||||||
'30110012303022415',
|
|
||||||
'30110012303050341',
|
|
||||||
'30110012303022434',
|
|
||||||
'30110012302271569',
|
|
||||||
'30110012303030505',
|
|
||||||
'30110012303021276',
|
|
||||||
'30110012302280295',
|
|
||||||
'30110012303022166',
|
|
||||||
'30110012303022299',
|
|
||||||
'30110012303020988',
|
|
||||||
'30110012302271160',
|
|
||||||
'30110012302281215',
|
|
||||||
'30110012303050537',
|
|
||||||
'30110012302272052',
|
|
||||||
'30110012303011213',
|
|
||||||
'30110012303030488',
|
|
||||||
'30110012303021614',
|
|
||||||
'30110012303012878',
|
|
||||||
'30110012302242962',
|
|
||||||
'30110012303030608',
|
|
||||||
'30110012303012697',
|
|
||||||
'30110012303020737'
|
|
||||||
)
|
|
||||||
and flc.PMPP != 0
|
and flc.PMPP != 0
|
||||||
GROUP BY tu.`NAME`
|
GROUP BY tu.`NAME`
|
||||||
</select>
|
</select>
|
||||||
|
<!-- <select id="getSubIdByCamlineForImpoet" resultMap="ResultMapCamIm">-->
|
||||||
|
<!-- SELECT-->
|
||||||
|
<!-- sub.WO_SUBSTRATE_ID as sub_id-->
|
||||||
|
<!-- FROM-->
|
||||||
|
<!-- t_wo_packaging_box_substrate sub-->
|
||||||
|
|
||||||
|
<!-- WHERE-->
|
||||||
|
<!-- sub.WO_SUBSTRATE_ID IN-->
|
||||||
|
<!-- <foreach collection="subIds" item="subId" index="index" open="(" close=")" separator=",">-->
|
||||||
|
<!-- #{subId}-->
|
||||||
|
<!-- </foreach>-->
|
||||||
|
<!-- </select>-->
|
||||||
|
|
||||||
<select id="getOrderNameBySubId" resultType="string">
|
<select id="getOrderNameBySubId" resultType="string">
|
||||||
SELECT
|
SELECT
|
||||||
@ -236,5 +195,17 @@
|
|||||||
twpb.model = 2
|
twpb.model = 2
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
|
<select id="getTodayErrBoxNum" resultType="java.lang.Integer">
|
||||||
|
select count(1)
|
||||||
|
from t_wo_packaging_box twpb
|
||||||
|
where
|
||||||
|
twpb.CREATE_TIME BETWEEN DATE_FORMAT(NOW(),'%Y-%m-%d 00:00:00') AND DATE_FORMAT(NOW(),'%Y-%m-%d 23:59:59')
|
||||||
|
and
|
||||||
|
twpb.model = 2
|
||||||
|
and twpb.BOX_NO like '444%'
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
@ -22,6 +22,8 @@
|
|||||||
<id column="CONTENT" property="content" />
|
<id column="CONTENT" property="content" />
|
||||||
<id column="line_body" property="lineBody" />
|
<id column="line_body" property="lineBody" />
|
||||||
<id column="is_enable" property="isEnable" />
|
<id column="is_enable" property="isEnable" />
|
||||||
|
<id column="scenes" property="scenes" />
|
||||||
|
<id column="product_grade" property="productGrade" />
|
||||||
</resultMap>
|
</resultMap>
|
||||||
|
|
||||||
<select id="list" resultType="com.cnbm.packing.dto.PrintModelDTO">
|
<select id="list" resultType="com.cnbm.packing.dto.PrintModelDTO">
|
||||||
|
@ -6,7 +6,7 @@
|
|||||||
<id column="actl_pmpp_low" property="actlPmppLow" />
|
<id column="actl_pmpp_low" property="actlPmppLow" />
|
||||||
<id column="actl_pmpp_high" property="actlPmppHigh" />
|
<id column="actl_pmpp_high" property="actlPmppHigh" />
|
||||||
<id column="formula" property="formula" />
|
<id column="formula" property="formula" />
|
||||||
<id column="line_body" property="lineBody" />
|
<id column="line_body" prope】/rty="lineBody" />
|
||||||
<id column="coefficient_a" property="coefficientA" />
|
<id column="coefficient_a" property="coefficientA" />
|
||||||
<id column="coefficient_b" property="coefficientB" />
|
<id column="coefficient_b" property="coefficientB" />
|
||||||
<id column="remark" property="remark" />
|
<id column="remark" property="remark" />
|
||||||
@ -43,7 +43,7 @@
|
|||||||
<if test="param.pmpp != null">
|
<if test="param.pmpp != null">
|
||||||
and twcp.actl_pmpp_high <![CDATA[ > ]]> #{param.pmpp} and twcp.actl_pmpp_low <![CDATA[ <= ]]> #{param.pmpp}
|
and twcp.actl_pmpp_high <![CDATA[ > ]]> #{param.pmpp} and twcp.actl_pmpp_low <![CDATA[ <= ]]> #{param.pmpp}
|
||||||
</if>
|
</if>
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
<if test="param.pmpp != null">
|
<if test="param.pmpp != null">
|
||||||
and twpl.pmpp_high <![CDATA[ > ]]> #{param.pmpp} and twpl.pmpp_low <![CDATA[ <= ]]> #{param.pmpp}
|
and twpl.pmpp_high <![CDATA[ > ]]> #{param.pmpp} and twpl.pmpp_low <![CDATA[ <= ]]> #{param.pmpp}
|
||||||
</if>
|
</if>
|
||||||
|
limit 1
|
||||||
</select>
|
</select>
|
||||||
|
|
||||||
</mapper>
|
</mapper>
|
||||||
|
25
ym-packing/src/main/resources/mapper/WorkingTimeMapper.xml
Normal file
25
ym-packing/src/main/resources/mapper/WorkingTimeMapper.xml
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
<mapper namespace="com.cnbm.packing.mapper.WorkingTimeMapper">
|
||||||
|
<resultMap type="com.cnbm.packing.entity.WorkingTime" id="WorkingTimeMap">
|
||||||
|
<id column="id" property="id" />
|
||||||
|
<id column="order_name" property="orderName" />
|
||||||
|
<id column="begin_time" property="beginTime" />
|
||||||
|
<id column="end_time" property="endTime" />
|
||||||
|
<id column="remark" property="remark" />
|
||||||
|
<id column="valid" property="valid" />
|
||||||
|
<id column="creator_id" property="creatorId" />
|
||||||
|
<id column="creator_name" property="creatorName" />
|
||||||
|
<id column="create_time" property="createTime" />
|
||||||
|
<id column="updater_id" property="updaterId" />
|
||||||
|
<id column="updater_name" property="updaterName" />
|
||||||
|
<id column="update_time" property="updateTime" />
|
||||||
|
<id column="version" property="version" />
|
||||||
|
</resultMap>
|
||||||
|
|
||||||
|
<select id="list" resultType="com.cnbm.packing.dto.WorkingTimeDTO">
|
||||||
|
select * from t_working_time
|
||||||
|
order by id asc
|
||||||
|
</select>
|
||||||
|
|
||||||
|
</mapper>
|
@ -36,5 +36,6 @@
|
|||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- retry 结束 -->
|
<!-- retry 结束 -->
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
@ -27,8 +27,15 @@ public enum S7Client {
|
|||||||
// S7_1200("192.168.0.52",0,1,1,PlcVarActual.HeartBeatFor1200),
|
// S7_1200("192.168.0.52",0,1,1,PlcVarActual.HeartBeatFor1200),
|
||||||
// S7_15001("192.168.0.51",0,1,1),
|
// S7_15001("192.168.0.51",0,1,1),
|
||||||
// S7_1500("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应用。
|
//后续 在这里扩展 多PLC应用。
|
||||||
;
|
;
|
||||||
private String host;
|
private String host;
|
||||||
|
@ -27,6 +27,7 @@ import java.util.Map;
|
|||||||
*/
|
*/
|
||||||
public enum S7ParamErrorCode {
|
public enum S7ParamErrorCode {
|
||||||
|
|
||||||
|
|
||||||
ERROR_0x0000((short) 0x0000, "No error"),
|
ERROR_0x0000((short) 0x0000, "No error"),
|
||||||
ERROR_0x0110((short) 0x0110, "Invalid block number"),
|
ERROR_0x0110((short) 0x0110, "Invalid block number"),
|
||||||
ERROR_0x0111((short) 0x0111, "Invalid request length"),
|
ERROR_0x0111((short) 0x0111, "Invalid request length"),
|
||||||
|
@ -15,6 +15,8 @@ limitations under the License.
|
|||||||
*/
|
*/
|
||||||
package com.cnbm.s7.s7connector.exception;
|
package com.cnbm.s7.s7connector.exception;
|
||||||
|
|
||||||
|
import io.swagger.models.auth.In;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class S7Exception is an exception related to S7 Communication
|
* The Class S7Exception is an exception related to S7 Communication
|
||||||
*/
|
*/
|
||||||
@ -23,6 +25,17 @@ public final class S7CheckResultException extends RuntimeException {
|
|||||||
/** The Constant serialVersionUID. */
|
/** The Constant serialVersionUID. */
|
||||||
private static final long serialVersionUID = -4761415733559374116L;
|
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.
|
* Instantiates a new s7 exception.
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user