Compare commits
	
		
			104 Commits
		
	
	
		
			cicd
			...
			8aea3bcd31
		
	
	| Author | SHA1 | Date | |
|---|---|---|---|
| 8aea3bcd31 | |||
| 558e106f17 | |||
| 259970a317 | |||
|  | df116253ff | ||
|  | 11b41b18f1 | ||
|  | 4e10024bc8 | ||
|  | 22115af70c | ||
|  | 1704b2c37b | ||
|  | 9f78bbe8c3 | ||
|  | 72aae5c439 | ||
|  | d70f19adcd | ||
|  | d366d7d922 | ||
|  | cabed052a1 | ||
|  | 18c1c6cc15 | ||
|  | 0e95d8c1d2 | ||
| b0e88370b1 | |||
| cbc3983714 | |||
| 0eb650ff50 | |||
|  | 3ff7d7c178 | ||
|  | e82bc1161c | ||
| 3172934f4e | |||
| 802a5474e7 | |||
| a436683e00 | |||
| 3ab40e515a | |||
| abdcb07492 | |||
|  | ce46bafa60 | ||
|  | 9bce971af0 | ||
| 045688f123 | |||
| f02aa38051 | |||
| 7694dd8242 | |||
| 64baad1a36 | |||
| b6e61961f7 | |||
| 42f4f2e741 | |||
|  | 4e02f7e03a | ||
|  | 7789d2b1ab | ||
| d62c7bf447 | |||
| 7970efd5d0 | |||
| dde937a6cd | |||
|  | 2b3c4b5f03 | ||
|  | 1258751c10 | ||
| a7ae47485c | |||
| f07fbd89a9 | |||
| 8d37c0ebf9 | |||
| 51736166a4 | |||
| dcc726ad77 | |||
|  | 6f50adc782 | ||
|  | c37f25a874 | ||
|  | 78c9cbd686 | ||
| eda15da1a9 | |||
| 02cecaed68 | |||
| ba30dfe7af | |||
|  | ee0bd67011 | ||
|  | 4d8f2bfe74 | ||
| 6b38aebb5b | |||
| 5f5a60eb29 | |||
| 1684075a9c | |||
| 4e932a09fd | |||
|  | fe10292885 | ||
|  | c284a4b394 | ||
|  | 00c907ece0 | ||
| 3b7cc67690 | |||
| 10c2414204 | |||
| 53a6f02212 | |||
|  | c588346c69 | ||
|  | 391b52b23a | ||
| c9ddb770e1 | |||
| 6fe5b71e49 | |||
| e35c2f4c45 | |||
| d8b1f7e3e4 | |||
| f3f08353ae | |||
|  | a16cd349cc | ||
|  | 867aef5f50 | ||
| 06364c973b | |||
| 7aa7e382a8 | |||
| ddc2343842 | |||
| e9e73df74d | |||
| 4fd5498f1e | |||
| 5b3f6f6f5d | |||
| cd1bfc3287 | |||
| bf0d6108a1 | |||
|  | 05684b5d2a | ||
|  | 9ccc971a38 | ||
|  | ec1e5097f7 | ||
| b80aaee82c | |||
| b7a3548a47 | |||
| 333d076f6e | |||
|  | e04a4d184e | ||
|  | 6d88aacee0 | ||
| f3b9c25a33 | |||
| 2e72fb7df8 | |||
| cf9614f857 | |||
| 8fa7a486fd | |||
| dd9cff155e | |||
| 101bc8359e | |||
| e405dcb06a | |||
| 458cedb42f | |||
| b0c884d210 | |||
| 3f38072356 | |||
| 3167ad09c4 | |||
| df44cf308f | |||
| 57b79b4f0e | |||
|  | a8d3147ac9 | ||
|  | 550a2f796b | ||
| 25d21ef884 | 
| @@ -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> | ||||||
|   | |||||||
| @@ -43,6 +43,11 @@ | |||||||
|             <artifactId>ym-common</artifactId> |             <artifactId>ym-common</artifactId> | ||||||
|             <version>1.0-SNAPSHOT</version> |             <version>1.0-SNAPSHOT</version> | ||||||
|         </dependency> |         </dependency> | ||||||
|  |         <dependency> | ||||||
|  |             <groupId>com.alibaba</groupId> | ||||||
|  |             <artifactId>fastjson</artifactId> | ||||||
|  |             <version>1.2.75</version> | ||||||
|  |         </dependency> | ||||||
|  |  | ||||||
|     </dependencies> |     </dependencies> | ||||||
|  |  | ||||||
|   | |||||||
							
								
								
									
										167
									
								
								ym-admin/src/main/java/com/cnbm/admin/base/BaseSupport.java
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										167
									
								
								ym-admin/src/main/java/com/cnbm/admin/base/BaseSupport.java
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,167 @@ | |||||||
|  | /* | ||||||
|  |  * Copyright (c) 2018. | ||||||
|  |  * http://www.ulabcare.com | ||||||
|  |  */ | ||||||
|  |  | ||||||
|  | package com.cnbm.admin.base; | ||||||
|  |  | ||||||
|  | import com.alibaba.fastjson.JSON; | ||||||
|  | import com.cnbm.admin.entity.LoginUser; | ||||||
|  | import com.cnbm.admin.enums.WhetherEnum; | ||||||
|  | import lombok.Builder; | ||||||
|  | import lombok.Data; | ||||||
|  | import org.apache.commons.lang3.StringUtils; | ||||||
|  | import org.springframework.beans.BeanUtils; | ||||||
|  | import org.springframework.stereotype.Service; | ||||||
|  | import org.springframework.web.context.request.RequestContextHolder; | ||||||
|  | import org.springframework.web.context.request.ServletRequestAttributes; | ||||||
|  |  | ||||||
|  | import javax.servlet.http.HttpServletRequest; | ||||||
|  | import javax.servlet.http.HttpServletResponse; | ||||||
|  | import javax.servlet.http.HttpSession; | ||||||
|  | import java.io.Serializable; | ||||||
|  | import java.time.LocalDateTime; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 接口支持基类 | ||||||
|  |  * | ||||||
|  |  * @author jiff | ||||||
|  |  * @date 2018/11/1 | ||||||
|  |  * @since 1.0 | ||||||
|  |  */ | ||||||
|  | @Service | ||||||
|  | public class BaseSupport { | ||||||
|  |  | ||||||
|  |     protected LoginUser getLoginUser() { | ||||||
|  |         // 后续完善拦截器再使用该方式 | ||||||
|  | //        LoginUser loginUser = loginUserHolder.get(); | ||||||
|  | //        if (loginUser != null) { | ||||||
|  | //            return loginUser; | ||||||
|  | //        } | ||||||
|  |         HttpSession session = getHttpServletRequest().getSession(false); | ||||||
|  |         LoginUser loginUser = null; | ||||||
|  |         if (session != null) { | ||||||
|  |             String loginUserJson = (String) session.getAttribute(LoginUser.HTTP_HEADER_NAME); | ||||||
|  |             if (StringUtils.isNotBlank(loginUserJson)) { | ||||||
|  |                 loginUser = JSON.parseObject(loginUserJson, LoginUser.class); | ||||||
|  |                 return loginUser; | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |         return null; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 获取当前http请求对象 | ||||||
|  |      * | ||||||
|  |      * @return | ||||||
|  |      */ | ||||||
|  |     protected HttpServletRequest getHttpServletRequest() { | ||||||
|  |         return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 获取当前http响应对象 | ||||||
|  |      * | ||||||
|  |      * @return | ||||||
|  |      */ | ||||||
|  |     protected HttpServletResponse getHttpServletResponse() { | ||||||
|  |         return ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getResponse(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 设置公共字段值,一般用于创建新记录,包含以下字段: | ||||||
|  |      * | ||||||
|  |      * <p> | ||||||
|  |      * {@link CommonField#enabled}<br> | ||||||
|  |      * {@link CommonField#valid}<br> | ||||||
|  |      * {@link CommonField#creatorId}<br> | ||||||
|  |      * {@link CommonField#creatorName}<br> | ||||||
|  |      * {@link CommonField#createTime}<br> | ||||||
|  |      * {@link CommonField#updaterId}<br> | ||||||
|  |      * {@link CommonField#updaterName}<br> | ||||||
|  |      * {@link CommonField#updateTime}<br> | ||||||
|  |      * </p> | ||||||
|  |      * | ||||||
|  |      * @param t                需要设置的对象 | ||||||
|  |      * @param ignoreProperties 忽略的字段 | ||||||
|  |      * @param <T> | ||||||
|  |      */ | ||||||
|  |     public <T extends Serializable> T setCommonField(T t, String... ignoreProperties) { | ||||||
|  |  | ||||||
|  |         CommonField commonField = CommonField.builder() | ||||||
|  |                 .enabled(WhetherEnum.YES.getValue()) | ||||||
|  |                 .valid(WhetherEnum.YES.getValue()) | ||||||
|  |                 .createTime(LocalDateTime.now()) | ||||||
|  |                 .creatorId(getLoginUser().getSysUserEntity().getId()) | ||||||
|  |                 .creatorName(getLoginUser().getUsername()) | ||||||
|  |                 .updateTime(LocalDateTime.now()) | ||||||
|  |                 .updaterId(getLoginUser().getSysUserEntity().getId()) | ||||||
|  |                 .updaterName(getLoginUser().getUsername()) | ||||||
|  |                 .build(); | ||||||
|  |         BeanUtils.copyProperties(commonField, t, ignoreProperties); | ||||||
|  |         return t; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     /** | ||||||
|  |      * 设置更新的公共字段值,一般用于更新记录,包含以下字段: | ||||||
|  |      * | ||||||
|  |      * <p> | ||||||
|  |      * {@link CommonField#updaterId}<br> | ||||||
|  |      * {@link CommonField#updaterName}<br> | ||||||
|  |      * {@link CommonField#updateTime}<br> | ||||||
|  |      * </p> | ||||||
|  |      * | ||||||
|  |      * @param t   需要设置的对象 | ||||||
|  |      * @param <T> | ||||||
|  |      */ | ||||||
|  |     public <T extends Serializable> T setUpdateCommonField(T t) { | ||||||
|  |         CommonField commonField = CommonField.builder() | ||||||
|  |                 .updaterId(getLoginUser().getSysUserEntity().getId()) | ||||||
|  |                 .updaterName(getLoginUser().getUsername()) | ||||||
|  |                 .updateTime(LocalDateTime.now()) | ||||||
|  |                 .build(); | ||||||
|  |         BeanUtils.copyProperties(commonField, t, "enabled", "valid"); | ||||||
|  |         return t; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Data | ||||||
|  |     @Builder | ||||||
|  |     private static class CommonField implements Serializable { | ||||||
|  |         /** | ||||||
|  |          * 启用状态:0 、停用,1、启用 | ||||||
|  |          */ | ||||||
|  |         private Integer enabled; | ||||||
|  |         /** | ||||||
|  |          * 删除标志,是否有效:1 可用 0不可用 | ||||||
|  |          */ | ||||||
|  |         private Integer valid; | ||||||
|  |  | ||||||
|  |         /** | ||||||
|  |          * 创建人 | ||||||
|  |          */ | ||||||
|  |         private Long creatorId; | ||||||
|  |         /** | ||||||
|  |          * 创建人 | ||||||
|  |          */ | ||||||
|  |         private String creatorName; | ||||||
|  |         /** | ||||||
|  |          * 创建时间 | ||||||
|  |          */ | ||||||
|  |         private LocalDateTime createTime; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         /** | ||||||
|  |          * 更新人 | ||||||
|  |          */ | ||||||
|  |         private Long updaterId; | ||||||
|  |         /** | ||||||
|  |          * 更新人 | ||||||
|  |          */ | ||||||
|  |         private String updaterName; | ||||||
|  |         /** | ||||||
|  |          * 更新时间 | ||||||
|  |          */ | ||||||
|  |         private LocalDateTime updateTime; | ||||||
|  |     } | ||||||
|  | } | ||||||
| @@ -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() | ||||||
|   | |||||||
| @@ -61,7 +61,7 @@ public class SysLogLoginController { | |||||||
|     public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |     public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { | ||||||
|         List<SysLogLoginDTO> list = sysLogLoginService.list(params); |         List<SysLogLoginDTO> list = sysLogLoginService.list(params); | ||||||
|  |  | ||||||
|         ExcelUtils.exportExcelToTarget(response, null, list, SysLogLoginExcel.class); |         ExcelUtils.exportExcelToTarget(response, "登入登出日志导出", list, SysLogLoginExcel.class); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -46,7 +46,6 @@ public class SysLogOperationController { | |||||||
|     }) |     }) | ||||||
|     public Result<PageData<SysLogOperationDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ |     public Result<PageData<SysLogOperationDTO>> page(@ApiIgnore @RequestParam Map<String, Object> params){ | ||||||
|         PageData<SysLogOperationDTO> page = sysLogOperationService.page(params); |         PageData<SysLogOperationDTO> page = sysLogOperationService.page(params); | ||||||
|  |  | ||||||
|         return new Result<PageData<SysLogOperationDTO>>().ok(page); |         return new Result<PageData<SysLogOperationDTO>>().ok(page); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -56,7 +55,7 @@ public class SysLogOperationController { | |||||||
|     public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |     public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { | ||||||
|         List<SysLogOperationDTO> list = sysLogOperationService.list(params); |         List<SysLogOperationDTO> list = sysLogOperationService.list(params); | ||||||
|  |  | ||||||
|         ExcelUtils.exportExcelToTarget(response, null, list, SysLogOperationExcel.class); |         ExcelUtils.exportExcelToTarget(response, "操作日志导出", list, SysLogOperationExcel.class); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -24,6 +24,8 @@ public class LoginUser implements UserDetails{ | |||||||
|  |  | ||||||
|     private static final long serialVersionUID = 1L; |     private static final long serialVersionUID = 1L; | ||||||
|  |  | ||||||
|  |     public static final String HTTP_HEADER_NAME = "loginUser"; | ||||||
|  |  | ||||||
|     private SysUserEntity sysUserEntity; |     private SysUserEntity sysUserEntity; | ||||||
|  |  | ||||||
|     private List<String> permissions; |     private List<String> permissions; | ||||||
|   | |||||||
| @@ -7,8 +7,8 @@ import java.util.Date; | |||||||
|  |  | ||||||
| @Data | @Data | ||||||
| public class SysLogLoginExcel { | public class SysLogLoginExcel { | ||||||
|     @Excel(name = "用户操作") |     @Excel(name = "用户操作", replace = {"登入_0", "登出_1"}) | ||||||
|     private String operation; |     private Integer operation; | ||||||
|     @Excel(name = "状态", replace = {"失败_0", "成功_1", "账号已锁定_1"}) |     @Excel(name = "状态", replace = {"失败_0", "成功_1", "账号已锁定_1"}) | ||||||
|     private Integer status; |     private Integer status; | ||||||
|     @Excel(name = "User-Agent") |     @Excel(name = "User-Agent") | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package com.cnbm.admin.service.impl; | package com.cnbm.admin.service.impl; | ||||||
|  |  | ||||||
|  | import com.alibaba.fastjson.JSON; | ||||||
| import com.cnbm.admin.entity.LoginUser; | import com.cnbm.admin.entity.LoginUser; | ||||||
| import com.cnbm.admin.entity.SysLogLoginEntity; | import com.cnbm.admin.entity.SysLogLoginEntity; | ||||||
| import com.cnbm.admin.enums.LoginOperationEnum; | import com.cnbm.admin.enums.LoginOperationEnum; | ||||||
| @@ -9,7 +10,6 @@ import com.cnbm.admin.service.CaptchaService; | |||||||
| import com.cnbm.admin.service.SysLogLoginService; | import com.cnbm.admin.service.SysLogLoginService; | ||||||
| import com.cnbm.admin.utils.JwtUtil; | import com.cnbm.admin.utils.JwtUtil; | ||||||
| import com.cnbm.admin.service.LoginService; | import com.cnbm.admin.service.LoginService; | ||||||
| import com.cnbm.admin.utils.ResponseResult; |  | ||||||
| import com.cnbm.common.exception.ErrorCode; | import com.cnbm.common.exception.ErrorCode; | ||||||
| import com.cnbm.common.utils.IpUtils; | import com.cnbm.common.utils.IpUtils; | ||||||
| import com.cnbm.common.utils.Result; | import com.cnbm.common.utils.Result; | ||||||
| @@ -22,8 +22,11 @@ import org.springframework.security.authentication.UsernamePasswordAuthenticatio | |||||||
| import org.springframework.security.core.Authentication; | import org.springframework.security.core.Authentication; | ||||||
| import org.springframework.security.core.context.SecurityContextHolder; | import org.springframework.security.core.context.SecurityContextHolder; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
|  | import org.springframework.web.context.request.RequestContextHolder; | ||||||
|  | import org.springframework.web.context.request.ServletRequestAttributes; | ||||||
|  |  | ||||||
| import javax.servlet.http.HttpServletRequest; | import javax.servlet.http.HttpServletRequest; | ||||||
|  | import javax.servlet.http.HttpSession; | ||||||
| import java.util.Date; | import java.util.Date; | ||||||
| import java.util.HashMap; | import java.util.HashMap; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| @@ -53,10 +56,10 @@ public class LoginServiceImpl implements LoginService { | |||||||
|     @Override |     @Override | ||||||
|     public Result login(HttpServletRequest request, LoginParam loginParam) { |     public Result login(HttpServletRequest request, LoginParam loginParam) { | ||||||
|         //验证码是否正确 |         //验证码是否正确 | ||||||
|         boolean flag = captchaService.validate(loginParam.getUuid(), loginParam.getCaptcha()); | //        boolean flag = captchaService.validate(loginParam.getUuid(), loginParam.getCaptcha()); | ||||||
|         if(!flag){ | //        if(!flag){ | ||||||
|             return new Result<>().error(ErrorCode.CAPTCHA_ERROR, "验证码错误"); | //            return new Result<>().error(ErrorCode.CAPTCHA_ERROR, "验证码错误"); | ||||||
|         } | //        } | ||||||
|         UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginParam.getUsername(),loginParam.getPassword()); |         UsernamePasswordAuthenticationToken authenticationToken = new UsernamePasswordAuthenticationToken(loginParam.getUsername(),loginParam.getPassword()); | ||||||
|         Authentication authenticate = authenticationManager.authenticate(authenticationToken); |         Authentication authenticate = authenticationManager.authenticate(authenticationToken); | ||||||
|         //登录日志 |         //登录日志 | ||||||
| @@ -81,6 +84,11 @@ public class LoginServiceImpl implements LoginService { | |||||||
|         map.put("token",jwt); |         map.put("token",jwt); | ||||||
|         //把完整的用户信息存入redis  userid作为key |         //把完整的用户信息存入redis  userid作为key | ||||||
|         redisTemplate.opsForValue().set("login:"+userid,loginUser,1, TimeUnit.DAYS); |         redisTemplate.opsForValue().set("login:"+userid,loginUser,1, TimeUnit.DAYS); | ||||||
|  |  | ||||||
|  |         //当前登录用户信息存入session中 | ||||||
|  |         HttpSession session = ((ServletRequestAttributes) RequestContextHolder.getRequestAttributes()).getRequest().getSession(); | ||||||
|  |         session.setAttribute(loginUser.HTTP_HEADER_NAME, JSON.toJSONString(loginUser)); | ||||||
|  |  | ||||||
|         //登录成功 |         //登录成功 | ||||||
|         log.setStatus(LoginStatusEnum.SUCCESS.value()); |         log.setStatus(LoginStatusEnum.SUCCESS.value()); | ||||||
|         log.setCreator(loginUser.getSysUserEntity().getId()); |         log.setCreator(loginUser.getSysUserEntity().getId()); | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import com.cnbm.admin.entity.SysRoleEntity; | |||||||
| import com.cnbm.admin.entity.SysUserEntity; | import com.cnbm.admin.entity.SysUserEntity; | ||||||
| import com.cnbm.admin.enums.SuperAdminEnum; | import com.cnbm.admin.enums.SuperAdminEnum; | ||||||
| import com.cnbm.admin.service.*; | import com.cnbm.admin.service.*; | ||||||
|  | import com.cnbm.admin.utils.BaseSupportUtils; | ||||||
| import com.cnbm.common.constant.Constant; | import com.cnbm.common.constant.Constant; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.impl.BaseServiceImpl; | import com.cnbm.common.service.impl.BaseServiceImpl; | ||||||
| @@ -20,6 +21,7 @@ import org.springframework.security.core.context.SecurityContextHolder; | |||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
|  | import java.sql.Timestamp; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| @@ -89,6 +91,8 @@ public class SysRoleServiceImpl extends BaseServiceImpl<SysRoleDao, SysRoleEntit | |||||||
|         SysRoleEntity entity = ConvertUtils.sourceToTarget(dto, SysRoleEntity.class); |         SysRoleEntity entity = ConvertUtils.sourceToTarget(dto, SysRoleEntity.class); | ||||||
|  |  | ||||||
|         //保存角色 |         //保存角色 | ||||||
|  |         Timestamp timestamp = new Timestamp(System.currentTimeMillis()); | ||||||
|  |         entity.setCreateDate(timestamp); | ||||||
|         insert(entity); |         insert(entity); | ||||||
|  |  | ||||||
|         //保存角色菜单关系 |         //保存角色菜单关系 | ||||||
|   | |||||||
| @@ -9,6 +9,7 @@ import com.cnbm.admin.enums.SuperAdminEnum; | |||||||
| import com.cnbm.admin.service.SysDeptService; | import com.cnbm.admin.service.SysDeptService; | ||||||
| import com.cnbm.admin.service.SysRoleUserService; | import com.cnbm.admin.service.SysRoleUserService; | ||||||
| import com.cnbm.admin.service.SysUserService; | import com.cnbm.admin.service.SysUserService; | ||||||
|  | import com.cnbm.admin.utils.BaseSupportUtils; | ||||||
| import com.cnbm.admin.utils.PasswordUtils; | import com.cnbm.admin.utils.PasswordUtils; | ||||||
| import com.cnbm.common.constant.Constant; | import com.cnbm.common.constant.Constant; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| @@ -21,6 +22,7 @@ import org.springframework.security.core.context.SecurityContextHolder; | |||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
|  | import java.sql.Timestamp; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
| @@ -98,6 +100,8 @@ public class SysUserServiceImpl extends BaseServiceImpl<SysUserDao, SysUserEntit | |||||||
|  |  | ||||||
|         //保存用户 |         //保存用户 | ||||||
|         entity.setSuperAdmin(SuperAdminEnum.NO.value()); |         entity.setSuperAdmin(SuperAdminEnum.NO.value()); | ||||||
|  |         Timestamp timestamp = new Timestamp(System.currentTimeMillis()); | ||||||
|  |         entity.setCreateDate(timestamp); | ||||||
|         insert(entity); |         insert(entity); | ||||||
|  |  | ||||||
|         //保存角色用户关系 |         //保存角色用户关系 | ||||||
|   | |||||||
| @@ -58,7 +58,7 @@ public abstract class BaseSupportUtils { | |||||||
|      */ |      */ | ||||||
|     public static <T extends Serializable> T setCommonField(T t, String... ignoreProperties) { |     public static <T extends Serializable> T setCommonField(T t, String... ignoreProperties) { | ||||||
|         CommonField commonField = CommonField.builder() |         CommonField commonField = CommonField.builder() | ||||||
|                 .enabled(WhetherEnum.YES.getValue()) | //                .enabled(WhetherEnum.YES.getValue()) | ||||||
|                 .valid(WhetherEnum.YES.getValue()) |                 .valid(WhetherEnum.YES.getValue()) | ||||||
|                 .createTime(LocalDateTime.now()) |                 .createTime(LocalDateTime.now()) | ||||||
|                 .creatorId(getLoginUser().getId()) |                 .creatorId(getLoginUser().getId()) | ||||||
| @@ -89,7 +89,7 @@ public abstract class BaseSupportUtils { | |||||||
|                 .updaterName(getLoginUser().getUsername()) |                 .updaterName(getLoginUser().getUsername()) | ||||||
|                 .updateTime(LocalDateTime.now()) |                 .updateTime(LocalDateTime.now()) | ||||||
|                 .build(); |                 .build(); | ||||||
|         BeanUtils.copyProperties(commonField, t, "enabled", "valid"); |         BeanUtils.copyProperties(commonField, t,  "valid"); | ||||||
|         return t; |         return t; | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -82,9 +82,11 @@ public class JwtUtil { | |||||||
|  |  | ||||||
|     public static void main(String[] args) throws Exception { |     public static void main(String[] args) throws Exception { | ||||||
| //        String jwt = createJWT("123"); | //        String jwt = createJWT("123"); | ||||||
|         Claims claims = parseJWT("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiI5OWNhNGJhMjg5ZjU0OTVjODE5YTM0N2ExZmNlZjc0YSIsInN1YiI6IjEyMyIsImlzcyI6IndoeSIsImlhdCI6MTY1NDc1OTg5NiwiZXhwIjoxNjU0NzYzNDk2fQ.CTgS6yQjfXSGPJUTu-_rqjkh_KB_F9SzPThFfnvB5yg"); |         Claims claims = parseJWT("eyJhbGciOiJIUzI1NiJ9.eyJqdGkiOiJkNTQxODQ5NjNjMWM0NzgzOTA0ZDAwZGI1ZmNkNWU3NiIsInN1YiI6IjEwNjcyNDY4NzU4MDAwMDAwMDEiLCJpc3MiOiJ3aHkiLCJpYXQiOjE2Nzg5MzE1MjAsImV4cCI6MTY3ODkzNTEyMH0.2we9FhhFU2Qvx2fvywqmA8A1qs0mbdXvr8T2CjJUz7o"); | ||||||
|         String subject = claims.getSubject(); |         String subject = claims.getSubject(); | ||||||
|         System.out.println(subject); |         System.out.println(subject); | ||||||
|  |  | ||||||
|  |         System.out.println(claims.toString()); | ||||||
| //        System.out.println(claims); | //        System.out.println(claims); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|   | |||||||
| @@ -23,7 +23,7 @@ | |||||||
| 	</select> | 	</select> | ||||||
|  |  | ||||||
| 	<select id="getIdAndPidList" resultType="com.cnbm.admin.entity.SysDeptEntity"> | 	<select id="getIdAndPidList" resultType="com.cnbm.admin.entity.SysDeptEntity"> | ||||||
| 		select t1.id, t1.pid from sys_dept t1  AND t1.valid = 1 | 		select t1.id, t1.pid from sys_dept t1 where t1.valid = 1 | ||||||
| 	</select> | 	</select> | ||||||
|  |  | ||||||
| 	<select id="getSubDeptIdList" resultType="long"> | 	<select id="getSubDeptIdList" resultType="long"> | ||||||
|   | |||||||
| @@ -1,7 +1,12 @@ | |||||||
| spring: | spring: | ||||||
|   datasource: |   datasource: | ||||||
|       #MySQL |  | ||||||
|       driver-class-name: com.mysql.cj.jdbc.Driver |       driver-class-name: com.mysql.cj.jdbc.Driver | ||||||
|  |       #MySQL-local | ||||||
|  | #      url: jdbc:mysql://10.0.1.249:3306/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true | ||||||
|  | #      username: cigs4 | ||||||
|  | #      password: 1qazxsw2 | ||||||
|  |  | ||||||
|  |       #MySQL-remote | ||||||
|       url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?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 | ||||||
| @@ -60,13 +65,14 @@ dynamic: | |||||||
| #      url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?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 | ||||||
|     ## camline系统 |     ## camline系统 - remote | ||||||
|     camline: |     camline: | ||||||
|       driver-class-name: com.mysql.cj.jdbc.Driver |       driver-class-name: com.mysql.cj.jdbc.Driver | ||||||
|       url: jdbc:mysql://mysql.picaiba.com:30307/mt_cigs4?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true |       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 | ||||||
| # | # | ||||||
|  |     #camline系统 - local | ||||||
| #    camline: | #    camline: | ||||||
| #      driver-class-name: com.mysql.cj.jdbc.Driver | #      driver-class-name: com.mysql.cj.jdbc.Driver | ||||||
| #      url: jdbc:mysql://10.0.1.23:3306/synapse?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true | #      url: jdbc:mysql://10.0.1.23:3306/synapse?useUnicode=true&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&nullCatalogMeansCurrent=true | ||||||
|   | |||||||
| @@ -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 | ||||||
|   | |||||||
| @@ -33,9 +33,11 @@ spring: | |||||||
|       enabled: true |       enabled: true | ||||||
|   redis: |   redis: | ||||||
|     database: 6 |     database: 6 | ||||||
|     host: 192.168.0.135 |     host: 127.0.0.1 | ||||||
|     port: 6380 |     #host: 10.0.1.249 | ||||||
|     password: '@WSXcde3'   # 密码(默认为空) |     #host: 192.168.0.102 | ||||||
|  |     port: 6379 | ||||||
|  |     password: ''   # 密码(默认为空) | ||||||
|     timeout: 6000ms  # 连接超时时长(毫秒) |     timeout: 6000ms  # 连接超时时长(毫秒) | ||||||
|     jedis: |     jedis: | ||||||
|       pool: |       pool: | ||||||
|   | |||||||
| @@ -14,9 +14,10 @@ | |||||||
| <!--    <property name="logging.pathmq" value="C:/qgs_logger/mq" />--> | <!--    <property name="logging.pathmq" value="C:/qgs_logger/mq" />--> | ||||||
| <!--    <property name="logging.eqlog" value="C:/qgs_logger/s7" />--> | <!--    <property name="logging.eqlog" value="C:/qgs_logger/s7" />--> | ||||||
|  |  | ||||||
|     <property name="logging.eqlog" value="/usr/local/logger/EQCommunicationLog" /> |     <property name="logging.eqlog" value="/var/log/logger/EQCommunicationLog" /> | ||||||
|     <property name="logging.packing" value="/usr/local/logger/Packing" /> |     <property name="logging.eventlog" value="/var/log/logger/EventLog" /> | ||||||
|  |     <property name="logging.packing" value="/var/log/logger/Packing" /> | ||||||
|  |     <property name="logging.pathwork" value="/var/log/logger/Working" /> | ||||||
|  |  | ||||||
|  |  | ||||||
|     <!--0. 日志格式和颜色渲染 --> |     <!--0. 日志格式和颜色渲染 --> | ||||||
| @@ -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"> | ||||||
| @@ -392,6 +593,12 @@ | |||||||
|  |  | ||||||
|     <!-- name就是包名,这个包下的 所有logger 输出就以下配置(这里的logger只会输出代码里 你指定打印的log ) --> |     <!-- name就是包名,这个包下的 所有logger 输出就以下配置(这里的logger只会输出代码里 你指定打印的log ) --> | ||||||
|  |  | ||||||
|  | <!--    <logger name="com.cnbm.pathwork" additivity="false">--> | ||||||
|  | <!--        <appender-ref ref="WORKING_DEBUG_FILE" />--> | ||||||
|  | <!--        <appender-ref ref="WORKING_INFO_FILE" />--> | ||||||
|  | <!--        <appender-ref ref="WORKING_WARN_FILE" />--> | ||||||
|  | <!--        <appender-ref ref="WORKING_ERROR_FILE" />--> | ||||||
|  | <!--    </logger>--> | ||||||
|     <logger name="com.cnbm.dispatch" additivity="false"> |     <logger name="com.cnbm.dispatch" additivity="false"> | ||||||
|         <appender-ref ref="EQ_COMM_LOG_DEBUG_FILE" /> |         <appender-ref ref="EQ_COMM_LOG_DEBUG_FILE" /> | ||||||
|         <appender-ref ref="EQ_COMM_LOG_INFO_FILE" /> |         <appender-ref ref="EQ_COMM_LOG_INFO_FILE" /> | ||||||
| @@ -399,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){ | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ import java.util.Map; | |||||||
|  * 打印标签模板表  前端控制器 |  * 打印标签模板表  前端控制器 | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-20 |  * @since  2023-03-08 | ||||||
|  */ |  */ | ||||||
| @RestController | @RestController | ||||||
| @RequestMapping("/code/printModel") | @RequestMapping("/code/printModel") | ||||||
|   | |||||||
| @@ -31,7 +31,7 @@ import java.util.Map; | |||||||
|  * 包装箱基板关联表 ( 基板表 )  前端控制器 |  * 包装箱基板关联表 ( 基板表 )  前端控制器 | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-23 |  * @since  2023-03-03 | ||||||
|  */ |  */ | ||||||
| @RestController | @RestController | ||||||
| @RequestMapping("/code/woPackagingBoxSubstrate") | @RequestMapping("/code/woPackagingBoxSubstrate") | ||||||
|   | |||||||
| @@ -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); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -14,7 +14,7 @@ import java.math.BigDecimal; | |||||||
|  * 打印标签模板表 |  * 打印标签模板表 | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-20 |  * @since  2023-03-08 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| @ApiModel(value = "打印标签模板表DTO对象") | @ApiModel(value = "打印标签模板表DTO对象") | ||||||
| @@ -77,4 +77,7 @@ public class PrintModelDTO implements Serializable { | |||||||
| 	@ApiModelProperty(value = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | 	@ApiModelProperty(value = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | ||||||
| 	private Integer lineBody; | 	private Integer lineBody; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "是否启用,0 停用;1 启用") | ||||||
|  | 	private Integer isEnable; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -14,7 +14,7 @@ import java.math.BigDecimal; | |||||||
|  * 包装箱基板关联表 ( 基板表 ) |  * 包装箱基板关联表 ( 基板表 ) | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-23 |  * @since  2023-03-03 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| @ApiModel(value = "包装箱基板关联表 ( 基板表 )DTO对象") | @ApiModel(value = "包装箱基板关联表 ( 基板表 )DTO对象") | ||||||
| @@ -74,7 +74,7 @@ public class WoPackagingBoxSubstrateDTO implements Serializable { | |||||||
| 	@ApiModelProperty(value = "") | 	@ApiModelProperty(value = "") | ||||||
| 	private LocalDateTime lastUpdateTime; | 	private LocalDateTime lastUpdateTime; | ||||||
|  |  | ||||||
| 	@ApiModelProperty(value = "补偿pmpp") | 	@ApiModelProperty(value = "补偿后的功率,pmpp") | ||||||
| 	private Float pmpp; | 	private Float pmpp; | ||||||
|  |  | ||||||
| 	@ApiModelProperty(value = "订单名") | 	@ApiModelProperty(value = "订单名") | ||||||
| @@ -170,4 +170,7 @@ public class WoPackagingBoxSubstrateDTO implements Serializable { | |||||||
| 	@ApiModelProperty(value = "") | 	@ApiModelProperty(value = "") | ||||||
| 	private Float uocFl2; | 	private Float uocFl2; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "真实PMPP") | ||||||
|  | 	private Float actualPmpp; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -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; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -14,7 +14,7 @@ import lombok.Data; | |||||||
|  * </p> |  * </p> | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since 2023-02-20 |  * @since 2023-03-08 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| @TableName("t_print_model") | @TableName("t_print_model") | ||||||
| @@ -78,6 +78,9 @@ public class PrintModel implements Serializable { | |||||||
|     @ApiModelProperty("线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") |     @ApiModelProperty("线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | ||||||
|     private Integer lineBody; |     private Integer lineBody; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("是否启用,0 停用;1 启用") | ||||||
|  |     private Integer isEnable; | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static final String ID = "ID"; |     public static final String ID = "ID"; | ||||||
|  |  | ||||||
| @@ -115,4 +118,6 @@ public class PrintModel implements Serializable { | |||||||
|  |  | ||||||
|     public static final String LINE_BODY = "line_body"; |     public static final String LINE_BODY = "line_body"; | ||||||
|  |  | ||||||
|  |     public static final String IS_ENABLE = "is_enable"; | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import lombok.Data; | |||||||
|  * </p> |  * </p> | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since 2023-02-23 |  * @since 2023-03-03 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| @TableName("t_wo_packaging_box_substrate") | @TableName("t_wo_packaging_box_substrate") | ||||||
| @@ -74,7 +74,7 @@ public class WoPackagingBoxSubstrate implements Serializable { | |||||||
|  |  | ||||||
|     private LocalDateTime lastUpdateTime; |     private LocalDateTime lastUpdateTime; | ||||||
|  |  | ||||||
|     @ApiModelProperty("补偿pmpp") |     @ApiModelProperty("补偿后的功率,pmpp") | ||||||
|     private Float pmpp; |     private Float pmpp; | ||||||
|  |  | ||||||
|     @ApiModelProperty("订单名") |     @ApiModelProperty("订单名") | ||||||
| @@ -140,6 +140,9 @@ public class WoPackagingBoxSubstrate implements Serializable { | |||||||
|  |  | ||||||
|     private Float uocFl2; |     private Float uocFl2; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("真实PMPP") | ||||||
|  |     private Float actualPmpp; | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static final String ID = "ID"; |     public static final String ID = "ID"; | ||||||
|  |  | ||||||
| @@ -239,4 +242,6 @@ public class WoPackagingBoxSubstrate implements Serializable { | |||||||
|  |  | ||||||
|     public static final String UOC_FL2 = "UOC_FL2"; |     public static final String UOC_FL2 = "UOC_FL2"; | ||||||
|  |  | ||||||
|  |     public static final String ACTUAL_PMPP = "ACTUAL_PMPP"; | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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"; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -12,7 +12,7 @@ import java.util.Date; | |||||||
|  * 打印标签模板表 |  * 打印标签模板表 | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-20 |  * @since  2023-03-08 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| public class PrintModelExcel { | public class PrintModelExcel { | ||||||
| @@ -52,5 +52,7 @@ public class PrintModelExcel { | |||||||
|     private String content; |     private String content; | ||||||
|     @Excel(name = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") |     @Excel(name = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | ||||||
|     private Integer lineBody; |     private Integer lineBody; | ||||||
|  |     @Excel(name = "是否启用,0 停用;1 启用") | ||||||
|  |     private Integer isEnable; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -12,7 +12,7 @@ import java.util.Date; | |||||||
|  * 包装箱基板关联表 ( 基板表 ) |  * 包装箱基板关联表 ( 基板表 ) | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-23 |  * @since  2023-03-03 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| public class WoPackagingBoxSubstrateExcel { | public class WoPackagingBoxSubstrateExcel { | ||||||
| @@ -50,7 +50,7 @@ public class WoPackagingBoxSubstrateExcel { | |||||||
|     private String powerLevel; |     private String powerLevel; | ||||||
|     @Excel(name = "") |     @Excel(name = "") | ||||||
|     private LocalDateTime lastUpdateTime; |     private LocalDateTime lastUpdateTime; | ||||||
|     @Excel(name = "补偿pmpp") |     @Excel(name = "补偿后的功率,pmpp") | ||||||
|     private Float pmpp; |     private Float pmpp; | ||||||
|     @Excel(name = "订单名") |     @Excel(name = "订单名") | ||||||
|     private String orderName; |     private String orderName; | ||||||
| @@ -114,5 +114,7 @@ public class WoPackagingBoxSubstrateExcel { | |||||||
|     private Float uocFl1; |     private Float uocFl1; | ||||||
|     @Excel(name = "") |     @Excel(name = "") | ||||||
|     private Float uocFl2; |     private Float uocFl2; | ||||||
|  |     @Excel(name = "真实PMPP") | ||||||
|  |     private Float actualPmpp; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -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; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Mapper; | |||||||
|  * 打印标签模板表 |  * 打印标签模板表 | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since 2023-02-20 |  * @since 2023-03-08 | ||||||
|  */ |  */ | ||||||
| @Mapper | @Mapper | ||||||
| public interface PrintModelMapper extends BaseDao<PrintModel> { | public interface PrintModelMapper extends BaseDao<PrintModel> { | ||||||
|   | |||||||
| @@ -20,6 +20,7 @@ | |||||||
|             <id column="IS_PREVIEW" property="isPreview" /> |             <id column="IS_PREVIEW" property="isPreview" /> | ||||||
|             <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" /> | ||||||
|     </resultMap> |     </resultMap> | ||||||
|  |  | ||||||
| </mapper> | </mapper> | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import org.apache.ibatis.annotations.Mapper; | |||||||
|  * 包装箱基板关联表 ( 基板表 ) |  * 包装箱基板关联表 ( 基板表 ) | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since 2023-02-23 |  * @since 2023-03-03 | ||||||
|  */ |  */ | ||||||
| @Mapper | @Mapper | ||||||
| public interface WoPackagingBoxSubstrateMapper extends BaseDao<WoPackagingBoxSubstrate> { | public interface WoPackagingBoxSubstrateMapper extends BaseDao<WoPackagingBoxSubstrate> { | ||||||
|   | |||||||
| @@ -51,6 +51,7 @@ | |||||||
|             <id column="UMPP_FL2" property="umppFl2" /> |             <id column="UMPP_FL2" property="umppFl2" /> | ||||||
|             <id column="UOC_FL1" property="uocFl1" /> |             <id column="UOC_FL1" property="uocFl1" /> | ||||||
|             <id column="UOC_FL2" property="uocFl2" /> |             <id column="UOC_FL2" property="uocFl2" /> | ||||||
|  |             <id column="ACTUAL_PMPP" property="actualPmpp" /> | ||||||
|     </resultMap> |     </resultMap> | ||||||
|  |  | ||||||
| </mapper> | </mapper> | ||||||
|   | |||||||
| @@ -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> | ||||||
| @@ -1,7 +1,7 @@ | |||||||
| -- 菜单初始SQL | -- 菜单初始SQL | ||||||
| INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date)VALUES (1627506543435272194, 1067246875800000035, '打印标签模板表', 'packing/printModel', 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 (1633305189284167681, 1067246875800000035, '打印标签模板表', 'code/printModel', 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 (1627506543435272195, 1627506543435272194, '查看', NULL, 'packing:printModel:page,packing:printModel: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 (1633305189284167682, 1633305189284167681, '查看', NULL, 'code:printModel:page,code:printModel: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 (1627506543435272196, 1627506543435272194, '新增', NULL, 'packing:printModel: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 (1633305189284167683, 1633305189284167681, '新增', NULL, 'code:printModel: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 (1627506543435272197, 1627506543435272194, '修改', NULL, 'packing:printModel: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 (1633305189284167684, 1633305189284167681, '修改', NULL, 'code:printModel: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 (1627506543435272198, 1627506543435272194, '删除', NULL, 'packing:printModel: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 (1633305189284167685, 1633305189284167681, '删除', NULL, 'code:printModel: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 (1627506543435272199, 1627506543435272194, '导出', NULL, 'packing:printModel:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now()); | INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1633305189284167686, 1633305189284167681, '导出', NULL, 'code:printModel:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now()); | ||||||
|   | |||||||
| @@ -1,7 +1,7 @@ | |||||||
| -- 菜单初始SQL | -- 菜单初始SQL | ||||||
| INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date)VALUES (1628638869145812994, 1067246875800000035, '包装箱基板关联表 ( 基板表 )', 'code/woPackagingBoxSubstrate', 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 (1631549072342364161, 1067246875800000035, '包装箱基板关联表 ( 基板表 )', 'code/woPackagingBoxSubstrate', 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 (1628638869145812995, 1628638869145812994, '查看', NULL, 'code:woPackagingBoxSubstrate:page,code:woPackagingBoxSubstrate: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 (1631549072342364162, 1631549072342364161, '查看', NULL, 'code:woPackagingBoxSubstrate:page,code:woPackagingBoxSubstrate: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 (1628638869145812996, 1628638869145812994, '新增', NULL, 'code:woPackagingBoxSubstrate: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 (1631549072342364163, 1631549072342364161, '新增', NULL, 'code:woPackagingBoxSubstrate: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 (1628638869145812997, 1628638869145812994, '修改', NULL, 'code:woPackagingBoxSubstrate: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 (1631549072342364164, 1631549072342364161, '修改', NULL, 'code:woPackagingBoxSubstrate: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 (1628638869145812998, 1628638869145812994, '删除', NULL, 'code:woPackagingBoxSubstrate: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 (1631549072342364165, 1631549072342364161, '删除', NULL, 'code:woPackagingBoxSubstrate: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 (1628638869145812999, 1628638869145812994, '导出', NULL, 'code:woPackagingBoxSubstrate:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now()); | INSERT INTO sys_menu(id, pid, name, url, permissions, type, icon, sort, creator, create_date, updater, update_date) VALUES (1631549072342364166, 1631549072342364161, '导出', NULL, 'code:woPackagingBoxSubstrate:export', 1, NULL, 4, 1067246875800000001, now(), 1067246875800000001, now()); | ||||||
|   | |||||||
| @@ -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()); | ||||||
| @@ -8,7 +8,7 @@ import com.cnbm.generator.code.entity.PrintModel; | |||||||
|  * 打印标签模板表 |  * 打印标签模板表 | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-20 |  * @since  2023-03-08 | ||||||
|  */ |  */ | ||||||
| public interface PrintModelServiceBiz extends CrudService<PrintModel, PrintModelDTO> { | public interface PrintModelServiceBiz extends CrudService<PrintModel, PrintModelDTO> { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -8,7 +8,7 @@ import com.cnbm.generator.code.entity.WoPackagingBoxSubstrate; | |||||||
|  * 包装箱基板关联表 ( 基板表 ) |  * 包装箱基板关联表 ( 基板表 ) | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since  2023-02-23 |  * @since  2023-03-03 | ||||||
|  */ |  */ | ||||||
| public interface WoPackagingBoxSubstrateServiceBiz extends CrudService<WoPackagingBoxSubstrate, WoPackagingBoxSubstrateDTO> { | public interface WoPackagingBoxSubstrateServiceBiz extends CrudService<WoPackagingBoxSubstrate, WoPackagingBoxSubstrateDTO> { | ||||||
|  |  | ||||||
|   | |||||||
| @@ -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> { | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -15,7 +15,7 @@ import java.util.Map; | |||||||
|  * 打印标签模板表 |  * 打印标签模板表 | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since 2023-02-20 |  * @since 2023-03-08 | ||||||
|  */ |  */ | ||||||
| @Service | @Service | ||||||
| public class PrintModelServiceBizImpl extends CrudServiceImpl<PrintModelMapper, PrintModel, PrintModelDTO> implements PrintModelServiceBiz { | public class PrintModelServiceBizImpl extends CrudServiceImpl<PrintModelMapper, PrintModel, PrintModelDTO> implements PrintModelServiceBiz { | ||||||
|   | |||||||
| @@ -15,7 +15,7 @@ import java.util.Map; | |||||||
|  * 包装箱基板关联表 ( 基板表 ) |  * 包装箱基板关联表 ( 基板表 ) | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since 2023-02-23 |  * @since 2023-03-03 | ||||||
|  */ |  */ | ||||||
| @Service | @Service | ||||||
| public class WoPackagingBoxSubstrateServiceBizImpl extends CrudServiceImpl<WoPackagingBoxSubstrateMapper, WoPackagingBoxSubstrate, WoPackagingBoxSubstrateDTO> implements WoPackagingBoxSubstrateServiceBiz { | public class WoPackagingBoxSubstrateServiceBizImpl extends CrudServiceImpl<WoPackagingBoxSubstrateMapper, WoPackagingBoxSubstrate, WoPackagingBoxSubstrateDTO> implements WoPackagingBoxSubstrateServiceBiz { | ||||||
|   | |||||||
| @@ -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,430 +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.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.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(); |  | ||||||
|         String nowTime = DateUtil.format(new Date(), "yyMMdd"); |  | ||||||
|         String res = "301"+sapMaterial+nowTime+todayBoxNum; |  | ||||||
|         return res; |  | ||||||
|     } |  | ||||||
|  |  | ||||||
|     @Override |  | ||||||
|     public void run(ApplicationArguments args) throws Exception { |  | ||||||
|  |  | ||||||
| //        kukaStep1.scheduleAtFixedRate(new Runnable() { |  | ||||||
| //            @Override |  | ||||||
| //            public void run() { |  | ||||||
| //                logger.info("=================  现在开始执行 过程一 任务   =================="); |  | ||||||
| //            } |  | ||||||
| //        },1,1, TimeUnit.SECONDS); |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
| //        kukaStep1.scheduleAtFixedRate(new Runnable() { |  | ||||||
| //            @Override |  | ||||||
| //            public void run() { |  | ||||||
| //                //调度开始 |  | ||||||
| ////                logger.info(""); |  | ||||||
| ////                logger.info("=================  现在开始执行 过程一 任务   =================="); |  | ||||||
| //                Integer subArrived = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, true); |  | ||||||
| //                if(subArrived != 1){ |  | ||||||
| //                    logger.info("失败"+" --- "+" MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败"); |  | ||||||
| //                } |  | ||||||
| // |  | ||||||
| //                //一. 从plc 中获取 subId 和 lineNum |  | ||||||
| //                String subId = (String) read(S7Client.S7_KUKA,Step1Plc2MesVar.SubIdToMes); |  | ||||||
| //                Integer lineNum = (Integer) read(S7Client.S7_KUKA,Step1Plc2MesVar.LineNum); |  | ||||||
| //                logger.info("采集到 基板ID: "+subId+", 线边号:"+lineNum); |  | ||||||
| // |  | ||||||
| //                //二. MES 业务 |  | ||||||
| //                //===============           MES 业务 开始         ================= |  | ||||||
| //                //1. 从comline数据库中获取 实际pmpp |  | ||||||
| //                float pmppBySubId = service.getPMPPBySubId(subId); |  | ||||||
| //                //2. 匹配和计算补偿功率 |  | ||||||
| //                float actualPMPP = compensationPowerServiceBiz.calculCompensationPMPP(pmppBySubId,lineNum); |  | ||||||
| //                //3. 依据补偿功率,获取工艺参数,并且把这些工艺参数传给kuka |  | ||||||
| //                WoPowerLevel argByPMPP = levelServiceBiz.getArgByPMPP(actualPMPP, lineNum); |  | ||||||
| //                write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Pnom,Integer.valueOf(argByPMPP.getPowerClass())); |  | ||||||
| //                write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Voc,argByPMPP.getLableVoc()); |  | ||||||
| //                write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Isc,argByPMPP.getLableIsc()); |  | ||||||
| //                write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Vmpp,argByPMPP.getLableVmpp()); |  | ||||||
| //                write(S7Client.S7_KUKA,Step1Mes2PlcVar.dLable_Impp,argByPMPP.getLableImpp()); |  | ||||||
| // |  | ||||||
| // |  | ||||||
| // |  | ||||||
| //                //4. 把基板录到数据库 |  | ||||||
| //                WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate(); |  | ||||||
| //                woPackagingBoxSubstrate.setLineBody(lineNum); |  | ||||||
| //                woPackagingBoxSubstrate.setPowerLevel(argByPMPP.getPowerClass()); |  | ||||||
| //                woPackagingBoxSubstrate.setSapMaterial(argByPMPP.getSapMaterialNum()); |  | ||||||
| //                woPackagingBoxSubstrate.setWoSubstrateId(subId); |  | ||||||
| // |  | ||||||
| //                //5. 从camline那里获取可变字段 |  | ||||||
| //                CamlineExtendArgDTO extendArgFromCamline = service.getExtendArgFromCamline(subId); |  | ||||||
| //                woPackagingBoxSubstrate.setLastUpdateTime(extendArgFromCamline.getLastUpdateTime()); |  | ||||||
| //                woPackagingBoxSubstrate.setPmpp(actualPMPP); |  | ||||||
| //                woPackagingBoxSubstrate.setOrderName(extendArgFromCamline.getOrderName()); |  | ||||||
| //                woPackagingBoxSubstrate.setBinclassFl1(extendArgFromCamline.getBinclassFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setBinclassFl2(extendArgFromCamline.getBinclassFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setEtaFl1(extendArgFromCamline.getEtaFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setEtaFl2(extendArgFromCamline.getEtaFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setFfFl1(extendArgFromCamline.getFfFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setFfFl2(extendArgFromCamline.getFfFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setImppFl1(extendArgFromCamline.getImppFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setImppFl2(extendArgFromCamline.getImppFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolflashcontrolFl1(extendArgFromCamline.getInsolflashcontrolFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolflashcontrolFl2(extendArgFromCamline.getInsolflashcontrolFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolmppFl1(extendArgFromCamline.getInsolmppFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolmppFl2(extendArgFromCamline.getInsolmppFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolvocFl1(extendArgFromCamline.getInsolvocFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolvocFl2(extendArgFromCamline.getInsolvocFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolFl1(extendArgFromCamline.getInsolFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setInsolFl2(extendArgFromCamline.getInsolFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setIscFl1(extendArgFromCamline.getIscFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setIscFl2(extendArgFromCamline.getIscFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setMeasTimeFl1(extendArgFromCamline.getMeasTimeFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setMeasTimeFl2(extendArgFromCamline.getMeasTimeFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setPmppFl1(extendArgFromCamline.getPmppFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setPmppFl2(extendArgFromCamline.getPmppFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setTcellFl1(extendArgFromCamline.getTcellFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setTcellFl2(extendArgFromCamline.getTcellFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setTmonicellFl1(extendArgFromCamline.getTmonicellFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setTmonicellFl2(extendArgFromCamline.getTmonicellFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setUmppFl1(extendArgFromCamline.getUmppFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setUmppFl2(extendArgFromCamline.getUmppFl2()); |  | ||||||
| //                woPackagingBoxSubstrate.setUocFl1(extendArgFromCamline.getUocFl1()); |  | ||||||
| //                woPackagingBoxSubstrate.setUocFl1(extendArgFromCamline.getUocFl2()); |  | ||||||
| // |  | ||||||
| //                substrateServiceBiz.insert(woPackagingBoxSubstrate); |  | ||||||
| //                //===============           MES 业务 结束         ================= |  | ||||||
| // |  | ||||||
| //                //三. 当MES完成任务后,把MesToPlc.SubArrivedFinish变量置为true,告诉plc,我操作完成了 |  | ||||||
| //                write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,true); |  | ||||||
| // |  | ||||||
| //                //四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false |  | ||||||
| //                Integer subArrived2 = waitingForTarget(Step1Plc2MesVar.SubArrivedToMes, false); |  | ||||||
| //                if(subArrived2 != 1){ |  | ||||||
| //                    logger.info("失败"+" --- "+"MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败"); |  | ||||||
| //                } |  | ||||||
| //                write(S7Client.S7_KUKA,Step1Mes2PlcVar.SubArrivedFinish,false); |  | ||||||
| //            } |  | ||||||
| //        },1,1, TimeUnit.SECONDS); |  | ||||||
| // |  | ||||||
| // |  | ||||||
| //        kukaStep2.scheduleAtFixedRate(new Runnable() { |  | ||||||
| //            @Override |  | ||||||
| //            public void run() { |  | ||||||
| //                //调度开始 |  | ||||||
| // |  | ||||||
| //                Integer shelfIsFull = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, true); |  | ||||||
| //                if(shelfIsFull != 1){ |  | ||||||
| //                    logger.info("失败"+" --- "+"MES监听 Step2Plc2MesVar.ShelfIsFull 是否 等于 1 失败"); |  | ||||||
| //                } |  | ||||||
| // |  | ||||||
| //                //一. 从plc 中获取 subIdList 和 lineNum |  | ||||||
| //                String[] subIdList = (String[])read(S7Client.S7_KUKA,Step2Plc2MesVar.SubIdList); |  | ||||||
| ////                Integer lineNum = (Integer) read(S7Client.S7_KUKA,Step2Plc2MesVar.LineNum); |  | ||||||
| //                logger.info("获取到基板列表:"+ Arrays.toString(subIdList)); |  | ||||||
| // |  | ||||||
| //                //二. MES 业务 |  | ||||||
| //                //===============           MES 业务 开始         ================= |  | ||||||
| //                //1.MES 生成BoxId |  | ||||||
| //                if(subIdList.length<=0){ |  | ||||||
| //                    logger.info("失败"+" --- "+"从plc里面获取到的基板列表 为空"); |  | ||||||
| //                } |  | ||||||
| //                WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(subIdList[0]); |  | ||||||
| //                String boxId = getBoxId(bySubId.getSapMaterial()); |  | ||||||
| //                logger.info("mes 生成的boxId :"+ boxId); |  | ||||||
| //                //2. 依次update 基板表,把boxId 赋予这些基板 |  | ||||||
| //                for(int i=0;i<subIdList.length;i++){ |  | ||||||
| //                    substrateServiceBiz.updatePackagingBoxIdByWoSubstrateId(boxId,subIdList[i]); |  | ||||||
| //                } |  | ||||||
| //                //3.去camline数据库 查询此基板ID 对应的订单 |  | ||||||
| //                String orderNameBySubId = service.getOrderNameBySubId(subIdList[0]); |  | ||||||
| //                //4. box信息录入到box表 |  | ||||||
| //                WoPackagingBox woPackagingBox = new WoPackagingBox(); |  | ||||||
| //                woPackagingBox.setBoxNo(boxId); |  | ||||||
| //                woPackagingBox.setPackagingTime(LocalDateTime.now()); |  | ||||||
| //                woPackagingBox.setPowerLevel(bySubId.getPowerLevel()); |  | ||||||
| //                woPackagingBox.setLineBody(bySubId.getLineBody()); |  | ||||||
| //                woPackagingBox.setSapMaterial(bySubId.getSapMaterial()); |  | ||||||
| //                woPackagingBox.setOrderNum(orderNameBySubId); |  | ||||||
| //                //1-手动模式,2-自动模式 |  | ||||||
| //                woPackagingBox.setModel(2); |  | ||||||
| //                boxServiceBiz.insert(woPackagingBox); |  | ||||||
| //                //===============           MES 业务 结束         ================= |  | ||||||
| // |  | ||||||
| //                //三. 把生成的BoxId 告诉kuka |  | ||||||
| //                write(S7Client.S7_KUKA,Step2Mes2PlcVar.BoxId,boxId); |  | ||||||
| // |  | ||||||
| //                //四. 当MES完成任务后,把MesToPlc.ShelfIsFullFinish变量置为true,告诉plc,我操作完成了 |  | ||||||
| //                write(S7Client.S7_KUKA,Step2Mes2PlcVar.ShelfIsFullFinish,true); |  | ||||||
| // |  | ||||||
| //                //四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false |  | ||||||
| //                Integer subArrived2 = waitingForTarget(Step2Plc2MesVar.ShelfIsFull, false); |  | ||||||
| //                if(subArrived2 != 1){ |  | ||||||
| //                    logger.info("失败"+" --- "+"步骤1.  MES监听 Step1Plc2MesVar.SubArrivedToMes 是否 等于 1 失败"); |  | ||||||
| //                } |  | ||||||
| //                write(S7Client.S7_KUKA,Step2Mes2PlcVar.ShelfIsFullFinish,false); |  | ||||||
| //            } |  | ||||||
| //        },1,1, TimeUnit.SECONDS); |  | ||||||
| // |  | ||||||
| // |  | ||||||
| //        kukaStep3.scheduleAtFixedRate(new Runnable() { |  | ||||||
| //            @Override |  | ||||||
| //            public void run() { |  | ||||||
| //                //调度开始 |  | ||||||
| //                Integer shelfIsFull = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, true); |  | ||||||
| //                if(shelfIsFull != 1){ |  | ||||||
| //                    logger.info("失败"+" --- "+"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("到达站台的boxId :"+boxId); |  | ||||||
| // |  | ||||||
| //                //二. MES 业务 |  | ||||||
| //                //===============           MES 业务 开始         ================= |  | ||||||
| //                //1. box信息录入到box表 |  | ||||||
| //                boxServiceBiz.updateIsArrivedByBoxNo(1,boxId); |  | ||||||
| //                //===============           MES 业务 结束         ================= |  | ||||||
| // |  | ||||||
| // |  | ||||||
| //                //四. 当MES完成任务后,把MesToPlc.ShelfIsFullArrivedFinish变量置为true,告诉plc,我操作完成了 |  | ||||||
| //                write(S7Client.S7_KUKA,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,true); |  | ||||||
| // |  | ||||||
| //                //四. mes 监控 到PlcToMes.SubArrived==false,就把MesToPlc.SubArrivedFinish置为false |  | ||||||
| //                Integer subArrived2 = waitingForTarget(Step3Plc2MesVar.ShelfIsFullArrived, false); |  | ||||||
| //                if(subArrived2 != 1){ |  | ||||||
| //                    logger.info("失败"+" --- "+"步骤1.  MES监听 Step3Plc2MesVar.ShelfIsFullArrived 是否 等于 1 失败"); |  | ||||||
| //                } |  | ||||||
| //                write(S7Client.S7_KUKA,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,false); |  | ||||||
| // |  | ||||||
| // |  | ||||||
| //            } |  | ||||||
| //        },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; | ||||||
|   | |||||||
| @@ -14,7 +14,9 @@ public enum Step2Plc2MesVar { | |||||||
|  |  | ||||||
|     ShelfIsFull("ShelfIsFull", PlcVar.BOOL,1, DaveArea.DB,2000,48,0), |     ShelfIsFull("ShelfIsFull", PlcVar.BOOL,1, DaveArea.DB,2000,48,0), | ||||||
|     SubIdList("SubIdList",PlcVar.STRING_Array,30,DaveArea.DB,2000,50,0,20), |     SubIdList("SubIdList",PlcVar.STRING_Array,30,DaveArea.DB,2000,50,0,20), | ||||||
|     LineNum("LineNum", PlcVar.BOOL,1, DaveArea.DB,2000,710,0), |     LineNum("LineNum", PlcVar.UINT,1, DaveArea.DB,2000,710,0), | ||||||
|  |     PackageNumberSet("PackageNumberSet", PlcVar.UINT,1, DaveArea.DB,2000,764,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; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -3,6 +3,7 @@ package com.cnbm.packing.controller; | |||||||
| import com.cnbm.admin.annotation.LogOperation; | import com.cnbm.admin.annotation.LogOperation; | ||||||
| import com.cnbm.common.constant.Constant; | import com.cnbm.common.constant.Constant; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
|  | import com.cnbm.common.utils.ConvertUtils; | ||||||
| import com.cnbm.common.utils.ExcelUtils; | import com.cnbm.common.utils.ExcelUtils; | ||||||
| import com.cnbm.common.utils.Result; | import com.cnbm.common.utils.Result; | ||||||
| import com.cnbm.common.validator.AssertUtils; | import com.cnbm.common.validator.AssertUtils; | ||||||
| @@ -11,6 +12,7 @@ import com.cnbm.common.validator.group.AddGroup; | |||||||
| import com.cnbm.common.validator.group.DefaultGroup; | import com.cnbm.common.validator.group.DefaultGroup; | ||||||
| import com.cnbm.common.validator.group.UpdateGroup; | import com.cnbm.common.validator.group.UpdateGroup; | ||||||
| import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; | import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; | ||||||
|  | import com.cnbm.packing.entity.ChangePackagingBoxHistory; | ||||||
| import com.cnbm.packing.excel.ChangePackagingBoxHistoryExcel; | import com.cnbm.packing.excel.ChangePackagingBoxHistoryExcel; | ||||||
| import com.cnbm.packing.service.ChangePackagingBoxHistoryServiceBiz; | import com.cnbm.packing.service.ChangePackagingBoxHistoryServiceBiz; | ||||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||||
| @@ -24,6 +26,7 @@ import springfox.documentation.annotations.ApiIgnore; | |||||||
|  |  | ||||||
| import javax.servlet.http.HttpServletResponse; | import javax.servlet.http.HttpServletResponse; | ||||||
| import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||||
|  | import java.time.format.DateTimeFormatter; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| @@ -110,11 +113,35 @@ public class ChangePackagingBoxHistoryController { | |||||||
|     @GetMapping("export") |     @GetMapping("export") | ||||||
|     @ApiOperation("导出") |     @ApiOperation("导出") | ||||||
|     @LogOperation("导出") |     @LogOperation("导出") | ||||||
|  |     @ApiImplicitParams({ | ||||||
|  |             @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|  |             @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|  |             @ApiImplicitParam(name = "type", value = "类型,1=加入包装箱;2=移除包装箱;3=换箱", paramType = "query", dataTypeClass=Integer.class) | ||||||
|  |     }) | ||||||
|     @PreAuthorize("@ex.hasAuthority('packing:changePackagingBoxHistory:export')") |     @PreAuthorize("@ex.hasAuthority('packing:changePackagingBoxHistory:export')") | ||||||
|     public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { |     public void export(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { | ||||||
|         List<ChangePackagingBoxHistoryDTO> list = changePackagingBoxHistoryService.list(params); |         List<ChangePackagingBoxHistory> list = changePackagingBoxHistoryService.historyList(params); | ||||||
|  |         List<ChangePackagingBoxHistoryDTO> dtoList = ConvertUtils.sourceToTarget(list, ChangePackagingBoxHistoryDTO.class); | ||||||
|         ExcelUtils.exportExcelToTarget(response, null, list, ChangePackagingBoxHistoryExcel.class); |         if(list.size()>0) { | ||||||
|  |             for(ChangePackagingBoxHistoryDTO dto:dtoList){ | ||||||
|  |                 //操作时间 转化 | ||||||
|  |                 DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||||||
|  |                 if(dto.getCreateTime()!=null){ | ||||||
|  |                     dto.setCreateTime1(df.format(dto.getCreateTime())); | ||||||
|  |                 } | ||||||
|  |                 //操作类型 1=模组加入包装箱;2=模组移出包装箱;3=模组换箱 | ||||||
|  |                 if(dto.getType()==1){ | ||||||
|  |                     dto.setType1("模组加入包装箱"); | ||||||
|  |                 } | ||||||
|  |                 if(dto.getType()==2){ | ||||||
|  |                     dto.setType1("模组移出包装箱"); | ||||||
|  |                 } | ||||||
|  |                 if(dto.getType()==3){ | ||||||
|  |                     dto.setType1("模组换箱"); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             ExcelUtils.exportExcelToTarget(response, "包装箱模组操作记录", dtoList, ChangePackagingBoxHistoryExcel.class); | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -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; | ||||||
|  |  | ||||||
| @@ -49,15 +50,16 @@ public class PrintModelController { | |||||||
|         @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class), |         @ApiImplicitParam(name = Constant.ORDER, value = "排序方式,可选值(asc、desc)", paramType = "query", dataTypeClass=String.class), | ||||||
|         @ApiImplicitParam(name = "name", value = "标签名称", paramType = "query", dataTypeClass = String.class), |         @ApiImplicitParam(name = "name", value = "标签名称", paramType = "query", dataTypeClass = String.class), | ||||||
|         @ApiImplicitParam(name = "type", value = "类型,0:模组标签,1:等级标签", paramType = "query", dataTypeClass = Integer.class), |         @ApiImplicitParam(name = "type", value = "类型,0:模组标签,1:等级标签", paramType = "query", dataTypeClass = Integer.class), | ||||||
|         @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) | ||||||
|     }) |     }) | ||||||
|     @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')") | ||||||
| @@ -127,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); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -1,26 +1,47 @@ | |||||||
| package com.cnbm.packing.controller; | package com.cnbm.packing.controller; | ||||||
|  |  | ||||||
|  | import cn.hutool.core.date.DateUtil; | ||||||
|  | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||||
| 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; | ||||||
| import com.cnbm.dispatch.enums.kuka.step2.Step2Plc2MesVar; | import com.cnbm.dispatch.enums.kuka.step2.Step2Plc2MesVar; | ||||||
| import com.cnbm.dispatch.enums.kuka.step3.Step3Mes2PlcVar; | 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.CamlineSubIdForImportDTO; | ||||||
|  | import com.cnbm.packing.dto.WoCompensationPowerDTO; | ||||||
|  | import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | ||||||
|  | import com.cnbm.packing.mapper.WoPackagingBoxSubstrateMapper; | ||||||
|  | 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.WoPackagingBoxSubstrateServiceBiz; | ||||||
|  | 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; | ||||||
|  | import com.cnbm.s7.s7connector.type.PlcVar; | ||||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||||
|  | import io.swagger.annotations.ApiOperation; | ||||||
| import org.slf4j.Logger; | import org.slf4j.Logger; | ||||||
| import org.slf4j.LoggerFactory; | import org.slf4j.LoggerFactory; | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
|  | import org.springframework.validation.annotation.Validated; | ||||||
| import org.springframework.web.bind.annotation.*; | import org.springframework.web.bind.annotation.*; | ||||||
| import com.cnbm.common.utils.Result; | import com.cnbm.common.utils.Result; | ||||||
| import springfox.documentation.annotations.ApiIgnore; | import springfox.documentation.annotations.ApiIgnore; | ||||||
|  |  | ||||||
|  | import javax.validation.groups.Default; | ||||||
| import java.io.UnsupportedEncodingException; | import java.io.UnsupportedEncodingException; | ||||||
|  | import java.math.BigDecimal; | ||||||
|  | import java.text.DecimalFormat; | ||||||
|  | import java.text.Format; | ||||||
| import java.text.ParseException; | import java.text.ParseException; | ||||||
|  | import java.util.Arrays; | ||||||
|  | import java.util.Date; | ||||||
|  | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
|  |  | ||||||
| @@ -37,6 +58,16 @@ public class TestController { | |||||||
|     private static final Logger logger = LoggerFactory.getLogger(TestController.class); |     private static final Logger logger = LoggerFactory.getLogger(TestController.class); | ||||||
|     @Autowired |     @Autowired | ||||||
|     DynamicDataSourceService service; |     DynamicDataSourceService service; | ||||||
|  |     @Autowired | ||||||
|  |     WoPackagingBoxSubstrateServiceBiz substrateServiceBiz; | ||||||
|  |  | ||||||
|  |     @Autowired | ||||||
|  |     WoPackagingBoxServiceBiz boxServiceBiz; | ||||||
|  |  | ||||||
|  |     @Autowired | ||||||
|  |     WoPackagingBoxSubstrateMapper subMapper; | ||||||
|  |  | ||||||
|  |  | ||||||
|     private Object read(S7Client s7Client,Step1Plc2MesVar var) throws UnsupportedEncodingException, ParseException { |     private Object read(S7Client s7Client,Step1Plc2MesVar var) throws UnsupportedEncodingException, ParseException { | ||||||
|         try { |         try { | ||||||
|             return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); |             return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType()); | ||||||
| @@ -93,45 +124,246 @@ public class TestController { | |||||||
|             return null; |             return null; | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |     @PostMapping("/forString") | ||||||
|  |     public R forString() throws UnsupportedEncodingException, ParseException { | ||||||
|  |         String[] s = (String[])read(S7Client.S7_DDJ1,Step2Plc2MesVar.SubIdList); | ||||||
|  |         System.out.println(Step2Plc2MesVar.SubIdList.getName()+" : "+Arrays.toString(s)); | ||||||
|  |         return R.ok(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @PostMapping("/subPageMapper") | ||||||
|  |     @ApiOperation(value = "基板表 left join box表 分页查询") | ||||||
|  |  | ||||||
|  |     public com.cnbm.packing.vo.R<IPage<SubIdPageVo>> subPageMapper(@Validated({Default.class}) @RequestBody SubIdQueryParam param) { | ||||||
|  |  | ||||||
|  |         return boxServiceBiz.subIdPage(param); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     @PostMapping("/forImport") | ||||||
|  |     public R forImport(@RequestBody WoCompensationPowerDTO dto) throws UnsupportedEncodingException, ParseException { | ||||||
|  |         List<CamlineSubIdForImportDTO> alllCamlineSubForImp = service.getAlllCamlineSubForImp(dto.getRemark().split(",")); | ||||||
|  |         for(CamlineSubIdForImportDTO cam:alllCamlineSubForImp){ | ||||||
|  |             WoPackagingBoxSubstrate woPackagingBoxSubstrate = new WoPackagingBoxSubstrate(); | ||||||
|  |             woPackagingBoxSubstrate.setWoSubstrateId(cam.getSubId()); | ||||||
|  |             woPackagingBoxSubstrate.setLineBody(2); | ||||||
|  |             woPackagingBoxSubstrate.setPowerLevel(cam.getPowerLevel()); | ||||||
|  |             woPackagingBoxSubstrate.setOrderName(cam.getOrderName()); | ||||||
|  |             woPackagingBoxSubstrate.setSapMaterial(cam.getSapMaterial()); | ||||||
|  |             substrateServiceBiz.insert(woPackagingBoxSubstrate); | ||||||
|  |         } | ||||||
|  |         return R.ok(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | //    @PostMapping("/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") | ||||||
|  |     public R forTestMix() throws UnsupportedEncodingException, ParseException { | ||||||
|  |         String[] s = new String[20]; | ||||||
|  |         s[0]= "30110012303021614"; | ||||||
|  |         s[1]= "30110012303022415"; | ||||||
|  |         s[2]= "30110012303022801"; | ||||||
|  |         s[3]= "30110012303040003"; | ||||||
|  |         s[4]= "30110012303030488"; | ||||||
|  |         s[5]= "30110012303020247"; | ||||||
|  |         s[6]= "30110012303021008"; | ||||||
|  |         s[7]= "30110012303022434"; | ||||||
|  |         s[8]= "30110012303012878"; | ||||||
|  |         s[9]= "30110012302281212"; | ||||||
|  |         s[10]= "30110012302281213"; | ||||||
|  |         s[11]= "30110012302281215"; | ||||||
|  |         s[12]= "30110012302271160"; | ||||||
|  |         s[13]= "30110012302271154"; | ||||||
|  |         s[14]= "30110012303050321"; | ||||||
|  |         s[15]= "30110012303050331"; | ||||||
|  |         s[16]= "30110012303020036"; | ||||||
|  |         s[17]= "30110012303022606"; | ||||||
|  |         s[18]= "30110012303030009"; | ||||||
|  |         s[19]= "30110012303021795"; | ||||||
|  |         System.out.println(isMixLevel(s));; | ||||||
|  |         WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId(s[0]); | ||||||
|  |         System.out.println(bySubId.getSapMaterial()); | ||||||
|  |         System.out.println(getErrorBoxId(bySubId.getSapMaterial())); | ||||||
|  |         System.out.println(getBoxId(bySubId.getSapMaterial())); | ||||||
|  |  | ||||||
|  |         return R.ok(); | ||||||
|  |     } | ||||||
|  |     public String formateString(Integer a){ | ||||||
|  |         Format f1 = new DecimalFormat("000"); | ||||||
|  |         return f1.format(a); | ||||||
|  |     } | ||||||
|  |     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; | ||||||
|  |     } | ||||||
|  |     private boolean isMixLevel(String[] subIds){ | ||||||
|  |         String correctLevel = substrateServiceBiz.getBySubId(subIds[0]).getPowerLevel(); | ||||||
|  |         String errMsg = "以下基板ID出现混档:"; | ||||||
|  |         boolean res = false; | ||||||
|  |         for(int i=1;i<subIds.length;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; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     @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(); |         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(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     public static void main(String[] args) { | ||||||
|  |         BigDecimal voc = new BigDecimal(59.799); | ||||||
|  |         System.out.println(Float.valueOf(voc.toString())); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @PostMapping("/testWrite") | ||||||
|  |     public R testWrite() { | ||||||
|  |         BigDecimal voc = new BigDecimal(59.799); | ||||||
|  |         BigDecimal isc = new BigDecimal(3.799); | ||||||
|  |         BigDecimal vmpp = new BigDecimal(46.799); | ||||||
|  |         BigDecimal impp = new BigDecimal(3.0799); | ||||||
|  |         write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Pnom,new Integer(1)); | ||||||
|  |         System.out.println(Step1Mes2PlcVar.dLable_Pnom.getName()+" : "+1); | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Voc,voc); | ||||||
|  |         System.out.println(Step1Mes2PlcVar.dLable_Voc.getName()+" : "+voc.toPlainString()); | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Isc,isc); | ||||||
|  |         System.out.println(Step1Mes2PlcVar.dLable_Isc.getName()+" : "+isc.toPlainString()); | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Vmpp,vmpp); | ||||||
|  |         System.out.println(Step1Mes2PlcVar.dLable_Vmpp.getName()+" : "+vmpp.toPlainString()); | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step1Mes2PlcVar.dLable_Impp,impp); | ||||||
|  |         System.out.println(Step1Mes2PlcVar.dLable_Impp.getName()+" : "+impp.toPlainString()); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step2Mes2PlcVar.BoxId,"12345678901111111111"); | ||||||
|  |         System.out.println(Step2Mes2PlcVar.BoxId.getName()+" : "+"12345678901111111111"); | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step1Mes2PlcVar.SubArrivedFinish,true); | ||||||
|  |         System.out.println(Step1Mes2PlcVar.SubArrivedFinish.getName()+" : "+"true"); | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step2Mes2PlcVar.ShelfIsFullFinish,false); | ||||||
|  |         System.out.println(Step2Mes2PlcVar.ShelfIsFullFinish.getName()+" : "+"false"); | ||||||
|  |  | ||||||
|  |         write(S7Client.S7_DDJ1,Step3Mes2PlcVar.ShelfIsFullArrivedFinish,true); | ||||||
|  |         System.out.println(Step3Mes2PlcVar.ShelfIsFullArrivedFinish.getName()+" : "+"true"); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         return R.ok(); | ||||||
|  |     } | ||||||
|     @PostMapping("/testlogger") |     @PostMapping("/testlogger") | ||||||
|     public R testlogger() { |     public R testlogger() { | ||||||
|         logger.info("test logger"); |         logger.info("test logger"); | ||||||
|         System.out.println("test logger"); |         System.out.println("test logger"); | ||||||
|  | //        CamlineSubIdDTO subIdByCamline = service.getSubIdByCamline("30110012302220591"); | ||||||
|  | //        CamlineSubIdDTO subIdByCamline2 = service.getSubIdByCamline("30110012302220591   "); | ||||||
|  | //        System.out.println("subIdByCamline: "+subIdByCamline.toString()); | ||||||
|  | //        System.out.println("subIdByCamline2: "+subIdByCamline2.toString()); | ||||||
|  |  | ||||||
|  | //        WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId("30110012302220591   "); | ||||||
|  | //        System.out.println("bySubId: "+bySubId.toString()); | ||||||
|  |  | ||||||
|  |         WoPackagingBoxSubstrate bySubId = substrateServiceBiz.getBySubId("30110012302210707   "); | ||||||
|  |         if(bySubId == null){ | ||||||
|  |             //todo | ||||||
|  |             CamlineSubIdDTO subIdByCamline = service.getSubIdByCamline("30110012302220591   "); | ||||||
|  |             bySubId = new WoPackagingBoxSubstrate(); | ||||||
|  |             bySubId.setPowerLevel(subIdByCamline.getPowerLevel()); | ||||||
|  |             bySubId.setSapMaterial(subIdByCamline.getSapMaterial()); | ||||||
|  |             System.out.println("bySubId2 : "+bySubId.toString()); | ||||||
|  |         } | ||||||
|         return R.ok(); |         return R.ok(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|     @PostMapping("getPMPPBySubId") |     @PostMapping("getPMPPBySubId") | ||||||
|     @ApiImplicitParams({ |     @ApiImplicitParams({ | ||||||
|             @ApiImplicitParam(name = "subId", value = "基板ID", paramType = "query", required = true, dataTypeClass=Integer.class) , |             @ApiImplicitParam(name = "subId", value = "基板ID", paramType = "query", required = true, dataTypeClass=Integer.class) , | ||||||
| @@ -159,4 +391,51 @@ public class TestController { | |||||||
|         return new Result<String>().ok(service.getExtendArgFromCamline(subId.toString()).toString()); |         return new Result<String>().ok(service.getExtendArgFromCamline(subId.toString()).toString()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     private void write(S7Client s7Client, Step1Mes2PlcVar var, Object newValue) { | ||||||
|  |         if(var.getType().equals(PlcVar.STRING_Array)){ | ||||||
|  |             String[] s = (String[])newValue; | ||||||
|  |             String[] ss = (String[])newValue; | ||||||
|  |             if(s.length > var.getLength() ){ | ||||||
|  |                 ss = new String[var.getLength()]; | ||||||
|  |                 for(int i=0;i< var.getLength();i++){ | ||||||
|  |                     ss[i] = s[i]; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); | ||||||
|  |         }else { | ||||||
|  |             s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |     private void write(S7Client s7Client, Step2Mes2PlcVar var, Object newValue) { | ||||||
|  |         if(var.getType().equals(PlcVar.STRING_Array)){ | ||||||
|  |             String[] s = (String[])newValue; | ||||||
|  |             String[] ss = (String[])newValue; | ||||||
|  |             if(s.length > var.getLength() ){ | ||||||
|  |                 ss = new String[var.getLength()]; | ||||||
|  |                 for(int i=0;i< var.getLength();i++){ | ||||||
|  |                     ss[i] = s[i]; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); | ||||||
|  |         }else { | ||||||
|  |             s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     private void write(S7Client s7Client, Step3Mes2PlcVar var, Object newValue) { | ||||||
|  |         if(var.getType().equals(PlcVar.STRING_Array)){ | ||||||
|  |             String[] s = (String[])newValue; | ||||||
|  |             String[] ss = (String[])newValue; | ||||||
|  |             if(s.length > var.getLength() ){ | ||||||
|  |                 ss = new String[var.getLength()]; | ||||||
|  |                 for(int i=0;i< var.getLength();i++){ | ||||||
|  |                     ss[i] = s[i]; | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),ss); | ||||||
|  |         }else { | ||||||
|  |             s7Client.write(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getStrSize(), var.getType(),newValue); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -1,5 +1,6 @@ | |||||||
| package com.cnbm.packing.controller; | package com.cnbm.packing.controller; | ||||||
|  |  | ||||||
|  | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||||
| import com.cnbm.admin.annotation.LogOperation; | import com.cnbm.admin.annotation.LogOperation; | ||||||
| import com.cnbm.common.constant.Constant; | import com.cnbm.common.constant.Constant; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| @@ -12,7 +13,11 @@ import com.cnbm.common.validator.group.DefaultGroup; | |||||||
| import com.cnbm.common.validator.group.UpdateGroup; | import com.cnbm.common.validator.group.UpdateGroup; | ||||||
| import com.cnbm.packing.dto.IdVo; | import com.cnbm.packing.dto.IdVo; | ||||||
| import com.cnbm.packing.dto.WoPackagingBoxDTO; | import com.cnbm.packing.dto.WoPackagingBoxDTO; | ||||||
|  | import com.cnbm.packing.entity.WoPackagingBox; | ||||||
|  | import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | ||||||
| import com.cnbm.packing.excel.WoPackagingBoxExcel; | import com.cnbm.packing.excel.WoPackagingBoxExcel; | ||||||
|  | import com.cnbm.packing.excel.WoPackagingBoxSubstrateExcel; | ||||||
|  | import com.cnbm.packing.mapper.WoPackagingBoxMapper; | ||||||
| import com.cnbm.packing.service.WoPackagingBoxServiceBiz; | import com.cnbm.packing.service.WoPackagingBoxServiceBiz; | ||||||
| import io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||||
| @@ -41,6 +46,8 @@ import java.util.Map; | |||||||
| public class WoPackagingBoxController { | public class WoPackagingBoxController { | ||||||
|     @Autowired |     @Autowired | ||||||
|     private WoPackagingBoxServiceBiz woPackagingBoxService; |     private WoPackagingBoxServiceBiz woPackagingBoxService; | ||||||
|  |     @Autowired | ||||||
|  |     private WoPackagingBoxMapper woPackagingBoxMapper; | ||||||
|  |  | ||||||
|     @GetMapping("page") |     @GetMapping("page") | ||||||
|     @ApiOperation("分页") |     @ApiOperation("分页") | ||||||
| @@ -52,11 +59,10 @@ public class WoPackagingBoxController { | |||||||
|         @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class), |         @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|         @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class), |         @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|         @ApiImplicitParam(name = "boxNo", value = "boxid", paramType = "query", dataTypeClass = String.class), |         @ApiImplicitParam(name = "boxNo", value = "boxid", paramType = "query", dataTypeClass = String.class), | ||||||
|         @ApiImplicitParam(name = "lineBody", value = "线体", paramType = "query", dataTypeClass = Integer.class), | //        @ApiImplicitParam(name = "lineBody", value = "线体", paramType = "query", dataTypeClass = Integer.class), | ||||||
|         @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); | ||||||
|  |  | ||||||
| @@ -132,4 +138,56 @@ public class WoPackagingBoxController { | |||||||
|         return new Result<WoPackagingBoxDTO>().ok(data); |         return new Result<WoPackagingBoxDTO>().ok(data); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("exportSubstrateList") | ||||||
|  |     @ApiOperation("箱单明细导出") | ||||||
|  |     @LogOperation("箱单明细导出") | ||||||
|  |     @ApiImplicitParams({ | ||||||
|  |             @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|  |             @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|  |             @ApiImplicitParam(name = "boxNo", value = "boxid", paramType = "query", dataTypeClass = String.class), | ||||||
|  | //            @ApiImplicitParam(name = "lineBody", value = "线体", 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) | ||||||
|  |     }) | ||||||
|  |     public void exportSubstrateList(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { | ||||||
|  |         List<WoPackagingBoxSubstrate> list = woPackagingBoxService.substrateList(params); | ||||||
|  |         if (list.size() > 0) { | ||||||
|  |             ExcelUtils.exportExcelToTarget(response, "箱单明细", list, WoPackagingBoxSubstrateExcel.class); | ||||||
|  |         } | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("boxList/{woSubstrateId}") | ||||||
|  |     @ApiOperation("查询模组id所在包装箱") | ||||||
|  |     public List<WoPackagingBox> boxList(@PathVariable("woSubstrateId") String woSubstrateId){ | ||||||
|  |         return woPackagingBoxService.boxList(woSubstrateId); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @PostMapping("insertSubstrateManual") | ||||||
|  |     @ApiOperation("手动新增包装箱") | ||||||
|  |     @LogOperation("手动新增包装箱") | ||||||
|  |     public Result<IdVo> insertSubstrateManual(@RequestBody WoPackagingBoxDTO dto){ | ||||||
|  |  | ||||||
|  |         //验证包装箱是否重名 | ||||||
|  |         QueryWrapper<WoPackagingBox> wrapper = new QueryWrapper<>(); | ||||||
|  |         wrapper.eq(WoPackagingBox.BOX_NO, dto.getBoxNo()); | ||||||
|  |         if(woPackagingBoxMapper.selectCount(wrapper)!= 0){ | ||||||
|  |             return new Result().error(1,"BoxID已存在,请重新输入"); | ||||||
|  |         } | ||||||
|  |         else { | ||||||
|  |             return new Result<IdVo>().ok(woPackagingBoxService.insertSubstrateManual(dto)); | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @PostMapping("editSubstrateManual") | ||||||
|  |     @ApiOperation("手动编辑包装箱") | ||||||
|  |     @LogOperation("手动编辑包装箱") | ||||||
|  |     public Result editSubstrateManual(@RequestBody WoPackagingBoxDTO dto){ | ||||||
|  |  | ||||||
|  |         woPackagingBoxService.editSubstrateManual(dto); | ||||||
|  |  | ||||||
|  |         return new Result(); | ||||||
|  |  | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -13,13 +13,19 @@ import com.cnbm.common.validator.group.AddGroup; | |||||||
| import com.cnbm.common.validator.group.DefaultGroup; | import com.cnbm.common.validator.group.DefaultGroup; | ||||||
| import com.cnbm.common.validator.group.UpdateGroup; | import com.cnbm.common.validator.group.UpdateGroup; | ||||||
| import com.cnbm.packing.dto.ChangePackingBoxDTO; | import com.cnbm.packing.dto.ChangePackingBoxDTO; | ||||||
|  | import com.cnbm.packing.dto.PowerReportDTO; | ||||||
| import com.cnbm.packing.dto.WoPackagingBoxSubstrateDTO; | import com.cnbm.packing.dto.WoPackagingBoxSubstrateDTO; | ||||||
| import com.cnbm.packing.entity.WoPackagingBox; | import com.cnbm.packing.entity.WoPackagingBox; | ||||||
| import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | ||||||
| import com.cnbm.packing.excel.WoPackagingBoxSubstrateExcel; | import com.cnbm.packing.excel.WoPackagingBoxSubstrateExcel; | ||||||
|  | import com.cnbm.packing.excel.WoPackagingBoxSubstrateManualExcel; | ||||||
| import com.cnbm.packing.mapper.WoPackagingBoxMapper; | import com.cnbm.packing.mapper.WoPackagingBoxMapper; | ||||||
| import com.cnbm.packing.mapper.WoPackagingBoxSubstrateMapper; | import com.cnbm.packing.mapper.WoPackagingBoxSubstrateMapper; | ||||||
|  | import com.cnbm.packing.param.PackingInfoQueryParam; | ||||||
|  | import com.cnbm.packing.param.PowerReportQueryParam; | ||||||
|  | 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 io.swagger.annotations.Api; | import io.swagger.annotations.Api; | ||||||
| import io.swagger.annotations.ApiImplicitParam; | import io.swagger.annotations.ApiImplicitParam; | ||||||
| import io.swagger.annotations.ApiImplicitParams; | import io.swagger.annotations.ApiImplicitParams; | ||||||
| @@ -31,8 +37,13 @@ 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.text.DecimalFormat; | ||||||
|  | import java.time.format.DateTimeFormatter; | ||||||
|  | import java.util.ArrayList; | ||||||
|  | import java.time.LocalDateTime; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  | import java.util.Objects; | ||||||
|  |  | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -48,6 +59,9 @@ public class WoPackagingBoxSubstrateController { | |||||||
|     @Autowired |     @Autowired | ||||||
|     private WoPackagingBoxSubstrateServiceBiz woPackagingBoxSubstrateService; |     private WoPackagingBoxSubstrateServiceBiz woPackagingBoxSubstrateService; | ||||||
|  |  | ||||||
|  |     @Autowired | ||||||
|  |     private WoPackagingBoxServiceBiz boxServiceBiz; | ||||||
|  |  | ||||||
|     @Autowired |     @Autowired | ||||||
|     private WoPackagingBoxSubstrateMapper woPackagingBoxSubstrateMapper; |     private WoPackagingBoxSubstrateMapper woPackagingBoxSubstrateMapper; | ||||||
|  |  | ||||||
| @@ -93,6 +107,16 @@ public class WoPackagingBoxSubstrateController { | |||||||
|         return new Result<Long>().ok(dto.getId()); |         return new Result<Long>().ok(dto.getId()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  | //    @PostMapping | ||||||
|  | //    @ApiOperation("功率报表") | ||||||
|  | //    @LogOperation("功率报表查询") | ||||||
|  | //    public Result<List<PowerReportDTO>> powerReport(@RequestBody PowerReportQueryParam queryParam){ | ||||||
|  | // | ||||||
|  | // | ||||||
|  | //        List<PowerReportDTO> powerReportDTOS = boxServiceBiz.powerReport(queryParam.getOrderName(), queryParam.getBegin(), queryParam.getEnd()); | ||||||
|  | //        return new Result<List<PowerReportDTO>>().ok(powerReportDTOS); | ||||||
|  | //    } | ||||||
|  |  | ||||||
|     @PutMapping |     @PutMapping | ||||||
|     @ApiOperation("修改") |     @ApiOperation("修改") | ||||||
|     @LogOperation("修改") |     @LogOperation("修改") | ||||||
| @@ -106,6 +130,91 @@ public class WoPackagingBoxSubstrateController { | |||||||
|         return new Result<Long>().ok(dto.getId()); |         return new Result<Long>().ok(dto.getId()); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @ApiOperation("查询模组档位统计分布图powerReportTY") | ||||||
|  |     @LogOperation("查询模组档位统计分布图powerReportTY") | ||||||
|  |     @PostMapping("/powerReportTY") | ||||||
|  |     public Result<Boolean> powerReportTY(@RequestBody PowerReportQueryParam queryParam){ | ||||||
|  |         List<PowerReportDTO> powerReportDTOS = boxServiceBiz.powerReport(queryParam); | ||||||
|  |         System.out.println(powerReportDTOS); | ||||||
|  |         return new Result<Boolean>().ok(true); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @ApiOperation("查询模组档位统计分布图") | ||||||
|  |     @LogOperation("查询模组档位统计分布图") | ||||||
|  |     @PostMapping("/powerReport") | ||||||
|  |     public Result<PowerReportVo> powerReport(@RequestBody PowerReportQueryParam queryParam){ | ||||||
|  |         List<PowerReportDTO> powerReportDTOS = boxServiceBiz.powerReport(queryParam); | ||||||
|  |         System.out.println(powerReportDTOS.toString()); | ||||||
|  |         List<PowerReportDTO> powerReportList = new ArrayList<>(); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"115",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"120",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"125",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"130",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"135",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"140",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"145",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"150",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"155",0f,"0%")); | ||||||
|  |         powerReportList.add(new PowerReportDTO(0,"160",0f,"0%")); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         for(PowerReportDTO power : powerReportList){ | ||||||
|  |             for(PowerReportDTO inner : powerReportDTOS){ | ||||||
|  |                 if(Objects.equals(power.getSubLevel(), inner.getSubLevel())){ | ||||||
|  |                     power.setProportion(inner.getProportion()); | ||||||
|  |                     power.setSubNum(inner.getSubNum()); | ||||||
|  |                     power.setSumPMPP(inner.getSumPMPP()); | ||||||
|  |                     power.setSubLevel(inner.getSubLevel()); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |         System.out.println(powerReportList.toString()); | ||||||
|  |         PowerReportVo powerReportVo = new PowerReportVo(); | ||||||
|  |         Float totalLevelPower = new Float(0); | ||||||
|  |         Float totalCompensatePower = new Float(0); | ||||||
|  |         Float diversePower = new Float(0); | ||||||
|  |         Integer totalSubNum = 0; | ||||||
|  |         for(PowerReportDTO power : powerReportList){ | ||||||
|  |             Integer subLevel = Integer.valueOf(power.getSubLevel()); | ||||||
|  |             Integer subNum = power.getSubNum(); | ||||||
|  |             if(power.getSumPMPP()==null){ | ||||||
|  |                 return new Result<PowerReportVo>().error("基板等级:"+subLevel+",基板数量:"+subNum+", 的总和为null"); | ||||||
|  |             } | ||||||
|  |             Float sumPMPP = power.getSumPMPP(); | ||||||
|  |             totalLevelPower += subLevel*subNum; | ||||||
|  |             totalCompensatePower += sumPMPP*subNum; | ||||||
|  |             totalSubNum+= subNum; | ||||||
|  |         } | ||||||
|  |         for(PowerReportDTO power : powerReportList){ | ||||||
|  |             if(power.getSubNum()==0 ||totalSubNum ==0 ){ | ||||||
|  |                 power.setProportion("0%"); | ||||||
|  |             }else { | ||||||
|  |                 Float prop = (Float.valueOf(power.getSubNum())/Float.valueOf(totalSubNum))*100; | ||||||
|  |                 DecimalFormat df = new DecimalFormat("0.00"); | ||||||
|  |                 String propS = df.format(prop)+"%"; | ||||||
|  |                 power.setProportion(propS); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |  | ||||||
|  |  | ||||||
|  |         diversePower = totalCompensatePower - totalLevelPower; | ||||||
|  |         powerReportVo.setPowerReports(powerReportList); | ||||||
|  |         powerReportVo.setDiversePower(diversePower); | ||||||
|  |         powerReportVo.setTotalCompensatePower(totalCompensatePower); | ||||||
|  |         powerReportVo.setTotalLevelPower(totalLevelPower); | ||||||
|  |  | ||||||
|  |         return new Result<PowerReportVo>().ok(powerReportVo); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @ApiOperation("查询模组档位统计分布图-获取ordername列表") | ||||||
|  |     @LogOperation("查询模组档位统计分布图-获取ordername列表") | ||||||
|  |     @PostMapping("/orderNameList") | ||||||
|  |     public Result<List<String>> orderNameList(){ | ||||||
|  |         List<String> powerReportDTOS = boxServiceBiz.orderNameList(); | ||||||
|  |         return new Result<List<String>>().ok(powerReportDTOS); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @DeleteMapping |     @DeleteMapping | ||||||
|     @ApiOperation("删除") |     @ApiOperation("删除") | ||||||
|     @LogOperation("删除") |     @LogOperation("删除") | ||||||
| @@ -144,10 +253,16 @@ public class WoPackagingBoxSubstrateController { | |||||||
|     @LogOperation("合箱") |     @LogOperation("合箱") | ||||||
|     public Result insertSubstrate(@RequestBody ChangePackingBoxDTO dto){ |     public Result insertSubstrate(@RequestBody ChangePackingBoxDTO dto){ | ||||||
|  |  | ||||||
|         String woSubstrateId = dto.getWoSubstrateId(); |         //验证包装箱是否为存在 | ||||||
|  |         String packagingBoxId = dto.getPackagingBoxId(); | ||||||
|  |         QueryWrapper<WoPackagingBox> boxQueryWrapper = new QueryWrapper<>(); | ||||||
|  |         boxQueryWrapper.eq(StringUtils.isNotBlank(packagingBoxId), WoPackagingBox.BOX_NO, packagingBoxId); | ||||||
|  |         if(woPackagingBoxMapper.selectCount(boxQueryWrapper)== 0){ | ||||||
|  |             return new Result().error(1,"该包装箱不存在,请重新输入"); | ||||||
|  |         } | ||||||
|         //验证模组是否存在 |         //验证模组是否存在 | ||||||
|         QueryWrapper<WoPackagingBoxSubstrate> substrateQueryWrapper1 = new QueryWrapper<>(); |         QueryWrapper<WoPackagingBoxSubstrate> substrateQueryWrapper1 = new QueryWrapper<>(); | ||||||
|         substrateQueryWrapper1.eq(StringUtils.isNotBlank(woSubstrateId), WoPackagingBoxSubstrate.WO_SUBSTRATE_ID, woSubstrateId); |         substrateQueryWrapper1.eq(WoPackagingBoxSubstrate.WO_SUBSTRATE_ID, dto.getWoSubstrateId()); | ||||||
|         if(woPackagingBoxSubstrateMapper.selectCount(substrateQueryWrapper1 )== 0){ |         if(woPackagingBoxSubstrateMapper.selectCount(substrateQueryWrapper1 )== 0){ | ||||||
|             return new Result().error(1,"该模组不存在,请重新输入"); |             return new Result().error(1,"该模组不存在,请重新输入"); | ||||||
|         } |         } | ||||||
| @@ -166,9 +281,6 @@ public class WoPackagingBoxSubstrateController { | |||||||
|         } |         } | ||||||
|  |  | ||||||
|         //验证该模组的线体、功率等级是否BoxID的线体、功率等级一致,一致,保存成功,数据发生更新。不一致,则显示保存失败,数据不发生更新 |         //验证该模组的线体、功率等级是否BoxID的线体、功率等级一致,一致,保存成功,数据发生更新。不一致,则显示保存失败,数据不发生更新 | ||||||
|         String packagingBoxId = dto.getPackagingBoxId(); |  | ||||||
|         QueryWrapper<WoPackagingBox> boxQueryWrapper = new QueryWrapper<>(); |  | ||||||
|         boxQueryWrapper.eq(StringUtils.isNotBlank(packagingBoxId), WoPackagingBox.BOX_NO, packagingBoxId); |  | ||||||
|         WoPackagingBox box = woPackagingBoxMapper.selectList(boxQueryWrapper).get(0); |         WoPackagingBox box = woPackagingBoxMapper.selectList(boxQueryWrapper).get(0); | ||||||
|  |  | ||||||
|         if((substrate.getLineBody()==box.getLineBody()) && (substrate.getPowerLevel().equals(box.getPowerLevel())) ) |         if((substrate.getLineBody()==box.getLineBody()) && (substrate.getPowerLevel().equals(box.getPowerLevel())) ) | ||||||
| @@ -210,11 +322,60 @@ public class WoPackagingBoxSubstrateController { | |||||||
|     @PostMapping("insertSubstrateManual") |     @PostMapping("insertSubstrateManual") | ||||||
|     @ApiOperation("手动装箱") |     @ApiOperation("手动装箱") | ||||||
|     @LogOperation("手动装箱") |     @LogOperation("手动装箱") | ||||||
|     public Result insertSubstrateManual(@RequestBody ChangePackingBoxDTO dto){ |     public Result insertSubstrateManual(@RequestBody ChangePackingBoxDTO[] dtos){ | ||||||
|  |  | ||||||
|         woPackagingBoxSubstrateService.insertSubstrateManual(dto); |         woPackagingBoxSubstrateService.insertSubstrateManual(dtos); | ||||||
|  |  | ||||||
|         return new Result(); |         return new Result(); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @PostMapping("updateSubstrateManual") | ||||||
|  |     @ApiOperation("手动装箱编辑") | ||||||
|  |     @LogOperation("手动装箱编辑") | ||||||
|  |     public Result updateSubstrateManual(@RequestBody ChangePackingBoxDTO[] dtos){ | ||||||
|  |  | ||||||
|  |         woPackagingBoxSubstrateService.updateSubstrateManual(dtos); | ||||||
|  |  | ||||||
|  |         return new Result(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @PostMapping("substrateList") | ||||||
|  |     @ApiOperation("装箱单信息查询") | ||||||
|  |     public Result<PageData<WoPackagingBoxSubstrateDTO>> substrateList(@RequestBody PackingInfoQueryParam param){ | ||||||
|  |         PageData<WoPackagingBoxSubstrateDTO> page = woPackagingBoxSubstrateService.substratePage(param); | ||||||
|  |         return new Result<PageData<WoPackagingBoxSubstrateDTO>>().ok(page); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @GetMapping("exportPackingInfo") | ||||||
|  |     @ApiOperation("装箱单信息导出") | ||||||
|  |     @LogOperation("装箱单信息导出") | ||||||
|  |     @ApiImplicitParams({ | ||||||
|  |             @ApiImplicitParam(name = "startTime", value = "开始时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|  |             @ApiImplicitParam(name = "endTime", value = "结束时间", paramType = "query", dataTypeClass = LocalDateTime.class), | ||||||
|  |             @ApiImplicitParam(name = "model", value = "模式,1-手动模式;2-自动模式", paramType = "query", dataTypeClass = Integer.class), | ||||||
|  |             @ApiImplicitParam(name = "packagingBoxId", value = "包装箱ID,BoxId", paramType = "query", dataTypeClass = String.class), | ||||||
|  |             @ApiImplicitParam(name = "woSubstrateId", value = "基板ID(关联T_SUBSTRATE表)", paramType = "query", dataTypeClass = String.class) | ||||||
|  |  | ||||||
|  |     }) | ||||||
|  |     public void exportPackingInfo(@ApiIgnore @RequestParam Map<String, Object> params, HttpServletResponse response) throws Exception { | ||||||
|  |         List<WoPackagingBoxSubstrateDTO> list = woPackagingBoxSubstrateService.substrateList(params); | ||||||
|  |         if(list.size()>0) { | ||||||
|  |             //包装箱创建时间 最近打印时间 转化 | ||||||
|  |             for(WoPackagingBoxSubstrateDTO dto:list){ | ||||||
|  |                 DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||||||
|  |                 if(dto.getBoxCreateTime()!=null){ | ||||||
|  |                     dto.setBoxCreateTime1(df.format(dto.getBoxCreateTime())); | ||||||
|  |                 } | ||||||
|  |                 if(dto.getPrintTime()!=null){ | ||||||
|  |                     dto.setPrintTime1(df.format(dto.getPrintTime())); | ||||||
|  |                 } | ||||||
|  |             } | ||||||
|  |             if(Integer.parseInt(params.get("model").toString())==1){ | ||||||
|  |                 ExcelUtils.exportExcelToTarget(response, "手动装箱单信息", list, WoPackagingBoxSubstrateManualExcel.class); | ||||||
|  |             } | ||||||
|  |             else { | ||||||
|  |                 ExcelUtils.exportExcelToTarget(response, "自动装箱单信息", list, WoPackagingBoxSubstrateExcel.class); | ||||||
|  |             } | ||||||
|  |         } | ||||||
|  |     } | ||||||
| } | } | ||||||
| @@ -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); | ||||||
|  |     } | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,30 @@ | |||||||
|  | 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-02-20 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | @ApiModel(value = "camline 查询对象") | ||||||
|  | public class CamlineSubIdDTO implements Serializable { | ||||||
|  |  | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	private String powerLevel; | ||||||
|  |  | ||||||
|  | 	private String sapMaterial; | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,28 @@ | |||||||
|  | package com.cnbm.packing.dto; | ||||||
|  |  | ||||||
|  | import io.swagger.annotations.ApiModel; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | import java.io.Serializable; | ||||||
|  |  | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 打印标签模板表 | ||||||
|  |  * | ||||||
|  |  * @author codeGenerator | ||||||
|  |  * @since  2023-02-20 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | @ApiModel(value = "camline 查询对象") | ||||||
|  | public class CamlineSubIdForImportDTO implements Serializable { | ||||||
|  |  | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  |  | ||||||
|  | 	private String subId; | ||||||
|  | 	private String powerLevel; | ||||||
|  |  | ||||||
|  | 	private String sapMaterial; | ||||||
|  |  | ||||||
|  | 	private String orderName; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -75,4 +75,10 @@ public class ChangePackagingBoxHistoryDTO implements Serializable { | |||||||
| 	@ApiModelProperty(value = "版本号") | 	@ApiModelProperty(value = "版本号") | ||||||
| 	private Integer version; | 	private Integer version; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "操作时间(转)") | ||||||
|  | 	private String createTime1; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "操作类型(转)") | ||||||
|  | 	private String type1; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -0,0 +1,48 @@ | |||||||
|  | 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-02-21 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | @ApiModel(value = "包装箱基板关联表 ( 基板表 )DTO对象") | ||||||
|  | public class PowerReportDTO implements Serializable { | ||||||
|  | 	private static final long serialVersionUID = 1L; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "subNum") | ||||||
|  | 	private Integer subNum; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "subLevel") | ||||||
|  | 	private String subLevel; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "sumPMPP") | ||||||
|  | 	private Float sumPMPP; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "占比(百分比)") | ||||||
|  | 	private String proportion; | ||||||
|  |  | ||||||
|  | 	public PowerReportDTO() { | ||||||
|  | 	} | ||||||
|  |  | ||||||
|  | 	public PowerReportDTO(Integer subNum, String subLevel, Float sumPMPP, String proportion) { | ||||||
|  | 		this.subNum = subNum; | ||||||
|  | 		this.subLevel = subLevel; | ||||||
|  | 		this.sumPMPP = sumPMPP; | ||||||
|  | 		this.proportion = proportion; | ||||||
|  | 	} | ||||||
|  | 	public PowerReportDTO(Integer subNum, String subLevel, Float sumPMPP) { | ||||||
|  | 		this.subNum = subNum; | ||||||
|  | 		this.subLevel = subLevel; | ||||||
|  | 		this.sumPMPP = sumPMPP; | ||||||
|  | 	} | ||||||
|  | } | ||||||
| @@ -77,4 +77,13 @@ public class PrintModelDTO implements Serializable { | |||||||
| 	@ApiModelProperty(value = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | 	@ApiModelProperty(value = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | ||||||
| 	private Integer lineBody; | 	private Integer lineBody; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "是否启用,0 停用;1 启用") | ||||||
|  | 	private Integer isEnable; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "场景,前端传字符串过来,目前固定这几个:DZ BIPV") | ||||||
|  | 	private String scenes; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "产品等级,目前固定这几个 : A1 A2 A3 A4 NK") | ||||||
|  | 	private String productGrade; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -74,7 +74,7 @@ public class WoPackagingBoxSubstrateDTO implements Serializable { | |||||||
| 	@ApiModelProperty(value = "") | 	@ApiModelProperty(value = "") | ||||||
| 	private LocalDateTime lastUpdateTime; | 	private LocalDateTime lastUpdateTime; | ||||||
|  |  | ||||||
| 	@ApiModelProperty(value = "补偿pmpp") | 	@ApiModelProperty(value = "补偿后的功率,pmpp") | ||||||
| 	private Float pmpp; | 	private Float pmpp; | ||||||
|  |  | ||||||
| 	@ApiModelProperty(value = "订单名") | 	@ApiModelProperty(value = "订单名") | ||||||
| @@ -170,4 +170,19 @@ public class WoPackagingBoxSubstrateDTO implements Serializable { | |||||||
| 	@ApiModelProperty(value = "") | 	@ApiModelProperty(value = "") | ||||||
| 	private Float uocFl2; | 	private Float uocFl2; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "真实PMPP") | ||||||
|  | 	private Float actualPmpp; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "包装箱创建时间") | ||||||
|  | 	private LocalDateTime boxCreateTime; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "打印时间(最近一次打印时间)") | ||||||
|  | 	private LocalDateTime printTime; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "包装箱创建时间(转)") | ||||||
|  | 	private String boxCreateTime1; | ||||||
|  |  | ||||||
|  | 	@ApiModelProperty(value = "最近打印时间(转)") | ||||||
|  | 	private String printTime1; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -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; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -78,6 +78,15 @@ public class PrintModel implements Serializable { | |||||||
|     @ApiModelProperty("线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") |     @ApiModelProperty("线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | ||||||
|     private Integer lineBody; |     private Integer lineBody; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("是否启用,0 停用;1 启用") | ||||||
|  |     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"; | ||||||
|  |  | ||||||
| @@ -115,4 +124,10 @@ public class PrintModel implements Serializable { | |||||||
|  |  | ||||||
|     public static final String LINE_BODY = "line_body"; |     public static final String LINE_BODY = "line_body"; | ||||||
|  |  | ||||||
|  |     public static final String IS_ENABLE = "is_enable"; | ||||||
|  |  | ||||||
|  |     public static final String SCENES = "scenes"; | ||||||
|  |  | ||||||
|  |     public static final String PRODUCT_GRADE = "product_grade"; | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -14,7 +14,7 @@ import lombok.Data; | |||||||
|  * </p> |  * </p> | ||||||
|  * |  * | ||||||
|  * @author codeGenerator |  * @author codeGenerator | ||||||
|  * @since 2023-02-21 |  * @since 2023-03-03 | ||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| @TableName("t_wo_packaging_box_substrate") | @TableName("t_wo_packaging_box_substrate") | ||||||
| @@ -74,7 +74,7 @@ public class WoPackagingBoxSubstrate implements Serializable { | |||||||
|  |  | ||||||
|     private LocalDateTime lastUpdateTime; |     private LocalDateTime lastUpdateTime; | ||||||
|  |  | ||||||
|     @ApiModelProperty("补偿pmpp") |     @ApiModelProperty("补偿后的功率,pmpp") | ||||||
|     private Float pmpp; |     private Float pmpp; | ||||||
|  |  | ||||||
|     @ApiModelProperty("订单名") |     @ApiModelProperty("订单名") | ||||||
| @@ -140,6 +140,9 @@ public class WoPackagingBoxSubstrate implements Serializable { | |||||||
|  |  | ||||||
|     private Float uocFl2; |     private Float uocFl2; | ||||||
|  |  | ||||||
|  |     @ApiModelProperty("真实PMPP") | ||||||
|  |     private Float actualPmpp; | ||||||
|  |  | ||||||
|  |  | ||||||
|     public static final String ID = "ID"; |     public static final String ID = "ID"; | ||||||
|  |  | ||||||
| @@ -239,5 +242,6 @@ public class WoPackagingBoxSubstrate implements Serializable { | |||||||
|  |  | ||||||
|     public static final String UOC_FL2 = "UOC_FL2"; |     public static final String UOC_FL2 = "UOC_FL2"; | ||||||
|  |  | ||||||
|  |     public static final String ACTUAL_PMPP = "ACTUAL_PMPP"; | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -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"; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -16,41 +16,20 @@ import java.util.Date; | |||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| public class ChangePackagingBoxHistoryExcel { | public class ChangePackagingBoxHistoryExcel { | ||||||
|     @Excel(name = "ID") |  | ||||||
|     private Long id; |     @Excel(name = "基板ID") | ||||||
|     @Excel(name = "基板ID或模组id") |  | ||||||
|     private String substrateId; |     private String substrateId; | ||||||
|     @Excel(name = "源包装箱box no, 关联t_wo_packaging_box.box_no 字段") |     @Excel(name = "源包装箱") | ||||||
|     private String sourceBoxNo; |     private String sourceBoxNo; | ||||||
|     @Excel(name = "源箱slot") |     @Excel(name = "源位置") | ||||||
|     private Integer sourceSlot; |     private Integer sourceSlot; | ||||||
|     @Excel(name = "离开时间") |     @Excel(name = "目的包装箱") | ||||||
|     private LocalDateTime leaveTime; |  | ||||||
|     @Excel(name = "目标箱box no, 关联t_wo_packaging_box.box_no 字段") |  | ||||||
|     private String targetBoxNo; |     private String targetBoxNo; | ||||||
|     @Excel(name = "目标箱slot") |     @Excel(name = "目的位置") | ||||||
|     private Integer targetSlot; |     private Integer targetSlot; | ||||||
|     @Excel(name = "进入时间") |     @Excel(name = "操作类型") | ||||||
|     private LocalDateTime inputTime; |     private String type1; | ||||||
|     @Excel(name = "等级") |     @Excel(name = "操作时间") | ||||||
|     private String grade; |     private String createTime1; | ||||||
|     @Excel(name = "类型,1=加入包装箱;2=移除包装箱;3=换箱") |  | ||||||
|     private Integer type; |  | ||||||
|     @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; |  | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -52,5 +52,7 @@ public class PrintModelExcel { | |||||||
|     private String content; |     private String content; | ||||||
|     @Excel(name = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") |     @Excel(name = "线体,1=F ; 2=S (用于过程1比对,和包装打印)(设备传给我们的)") | ||||||
|     private Integer lineBody; |     private Integer lineBody; | ||||||
|  |     @Excel(name = "是否启用,0 停用;1 启用") | ||||||
|  |     private Integer isEnable; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -1,6 +1,7 @@ | |||||||
| package com.cnbm.packing.excel; | package com.cnbm.packing.excel; | ||||||
|  |  | ||||||
| import cn.afterturn.easypoi.excel.annotation.Excel; | import cn.afterturn.easypoi.excel.annotation.Excel; | ||||||
|  | import io.swagger.annotations.ApiModelProperty; | ||||||
| import lombok.Data; | import lombok.Data; | ||||||
|  |  | ||||||
| import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||||
| @@ -16,104 +17,28 @@ import java.util.Date; | |||||||
|  */ |  */ | ||||||
| @Data | @Data | ||||||
| public class WoPackagingBoxSubstrateExcel { | public class WoPackagingBoxSubstrateExcel { | ||||||
|     @Excel(name = "ID") |  | ||||||
|     private Long id; |  | ||||||
|     @Excel(name = "包装箱ID,BoxId") |  | ||||||
|     private String packagingBoxId; |  | ||||||
|     @Excel(name = "基板ID") |  | ||||||
|     private String woSubstrateId; |  | ||||||
|     @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; |  | ||||||
|     @Excel(name = "箱中位置") |  | ||||||
|     private Integer slot; |  | ||||||
|     @Excel(name = "进入时间") |  | ||||||
|     private LocalDateTime inputTime; |  | ||||||
|     @Excel(name = "删除标志,是否有效:1 可用 0不可用") |  | ||||||
|     private Integer valid; |  | ||||||
|     @Excel(name = "SAP MATERIAL,从t_wo_power_level 对应过来的") |  | ||||||
|     private String sapMaterial; |  | ||||||
|     @Excel(name = "线体,从t_wo_power_level 对应过来的,1=F ; 2=S") |  | ||||||
|     private Integer lineBody; |  | ||||||
|     @Excel(name = "功率等级") |  | ||||||
|     private String powerLevel; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private LocalDateTime lastUpdateTime; |  | ||||||
|     @Excel(name = "补偿pmpp") |  | ||||||
|     private Float pmpp; |  | ||||||
|     @Excel(name = "订单名") |  | ||||||
|     private String orderName; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Long binclassFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Long binclassFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float etaFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float etaFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float ffFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float ffFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float imppFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float imppFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolflashcontrolFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolflashcontrolFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolmppFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolmppFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolvocFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolvocFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float insolFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float iscFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float iscFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private LocalDateTime measTimeFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private LocalDateTime measTimeFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float pmppFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float pmppFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float tcellFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float tcellFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float tmonicellFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float tmonicellFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float umppFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float umppFl2; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float uocFl1; |  | ||||||
|     @Excel(name = "") |  | ||||||
|     private Float uocFl2; |  | ||||||
|  |  | ||||||
|  |     @Excel(name = "创建时间") | ||||||
|  |     private String boxCreateTime1; | ||||||
|  |     @Excel(name = "模组ID") | ||||||
|  |     private String woSubstrateId; | ||||||
|  |     @Excel(name = "BoxID") | ||||||
|  |     private String packagingBoxId; | ||||||
|  |     @Excel(name = "模组所在包装箱位置") | ||||||
|  |     private Integer slot; | ||||||
|  |     @Excel(name = "订单号") | ||||||
|  |     private String orderName; | ||||||
|  |     @Excel(name = "SAP物料号") | ||||||
|  |     private String sapMaterial; | ||||||
|  |     @Excel(name = "档位功率") | ||||||
|  |     private String powerLevel; | ||||||
|  |     @Excel(name = "补偿功率") | ||||||
|  |     private Float pmpp; | ||||||
|  |     @Excel(name = "实测功率") | ||||||
|  |     private Float actualPmpp; | ||||||
|  |     @Excel(name = "线体") | ||||||
|  |     private Integer lineBody; | ||||||
|  |     @Excel(name = "最近打印时间") | ||||||
|  |     private String printTime1; | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -0,0 +1,32 @@ | |||||||
|  | package com.cnbm.packing.excel; | ||||||
|  |  | ||||||
|  | import cn.afterturn.easypoi.excel.annotation.Excel; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * 包装箱基板关联表 ( 基板表 ) | ||||||
|  |  * | ||||||
|  |  * @author codeGenerator | ||||||
|  |  * @since  2023-02-21 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class WoPackagingBoxSubstrateManualExcel { | ||||||
|  |  | ||||||
|  |     @Excel(name = "创建时间") | ||||||
|  |     private String boxCreateTime1; | ||||||
|  |     @Excel(name = "模组ID") | ||||||
|  |     private String woSubstrateId; | ||||||
|  |     @Excel(name = "BoxID") | ||||||
|  |     private String packagingBoxId; | ||||||
|  |     @Excel(name = "模组所在包装箱位置") | ||||||
|  |     private Integer slot; | ||||||
|  |     @Excel(name = "SAP物料号") | ||||||
|  |     private String sapMaterial; | ||||||
|  |     @Excel(name = "功率等级") | ||||||
|  |     private String powerLevel; | ||||||
|  |     @Excel(name = "线体") | ||||||
|  |     private Integer lineBody; | ||||||
|  |     @Excel(name = "最近打印时间") | ||||||
|  |     private String printTime1; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -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; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -1,6 +1,8 @@ | |||||||
| package com.cnbm.packing.mapper; | package com.cnbm.packing.mapper; | ||||||
|  |  | ||||||
| import com.cnbm.packing.dto.CamlineExtendArgDTO; | import com.cnbm.packing.dto.CamlineExtendArgDTO; | ||||||
|  | import com.cnbm.packing.dto.CamlineSubIdDTO; | ||||||
|  | import com.cnbm.packing.dto.CamlineSubIdForImportDTO; | ||||||
| import org.apache.ibatis.annotations.Mapper; | import org.apache.ibatis.annotations.Mapper; | ||||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||||
|  |  | ||||||
| @@ -26,4 +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); | ||||||
|  |  | ||||||
|  |     List<CamlineSubIdForImportDTO> getSubIdByCamlineForImpoet(@Param("subIds") String[] subIds); | ||||||
| } | } | ||||||
| @@ -6,6 +6,7 @@ import com.cnbm.packing.entity.ChangePackagingBoxHistory; | |||||||
| import org.apache.ibatis.annotations.Mapper; | import org.apache.ibatis.annotations.Mapper; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
|  | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 包装箱拆合箱历史表 |  * 包装箱拆合箱历史表 | ||||||
| @@ -16,6 +17,6 @@ import java.util.List; | |||||||
| @Mapper | @Mapper | ||||||
| public interface ChangePackagingBoxHistoryMapper extends BaseDao<ChangePackagingBoxHistory> { | public interface ChangePackagingBoxHistoryMapper extends BaseDao<ChangePackagingBoxHistory> { | ||||||
|  |  | ||||||
|     List<ChangePackagingBoxHistoryDTO> list(); |     List<ChangePackagingBoxHistoryDTO> list(Map<String, Object> params); | ||||||
|      |      | ||||||
| } | } | ||||||
| @@ -1,10 +1,22 @@ | |||||||
| package com.cnbm.packing.mapper; | package com.cnbm.packing.mapper; | ||||||
|  | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||||
|  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||||
|  | import com.cnbm.packing.dto.PowerReportDTO; | ||||||
|  | import com.cnbm.packing.dto.WoPackagingBoxSubstrateDTO; | ||||||
|  | import com.cnbm.packing.param.PackingInfoQueryParam; | ||||||
|  | import com.cnbm.packing.param.PowerReportQueryParam; | ||||||
|  | import com.cnbm.packing.param.SubIdQueryParam; | ||||||
|  | import com.cnbm.packing.vo.SubIdPageVo; | ||||||
| import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||||
|  |  | ||||||
| import com.cnbm.common.dao.BaseDao; | import com.cnbm.common.dao.BaseDao; | ||||||
| import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | ||||||
| import org.apache.ibatis.annotations.Mapper; | import org.apache.ibatis.annotations.Mapper; | ||||||
|  |  | ||||||
|  | import java.time.LocalDateTime; | ||||||
|  | import java.util.List; | ||||||
|  | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
|  * 包装箱基板关联表 |  * 包装箱基板关联表 | ||||||
|  * |  * | ||||||
| @@ -15,5 +27,15 @@ import org.apache.ibatis.annotations.Mapper; | |||||||
| public interface WoPackagingBoxSubstrateMapper extends BaseDao<WoPackagingBoxSubstrate> { | public interface WoPackagingBoxSubstrateMapper extends BaseDao<WoPackagingBoxSubstrate> { | ||||||
|     WoPackagingBoxSubstrate getOneByWoSubstrateId(@Param("woSubstrateId") String woSubstrateId); |     WoPackagingBoxSubstrate getOneByWoSubstrateId(@Param("woSubstrateId") String woSubstrateId); | ||||||
|  |  | ||||||
|     int updatePackagingBoxIdByWoSubstrateId(@Param("packagingBoxId") String packagingBoxId, @Param("woSubstrateId") String woSubstrateId); |  | ||||||
|  |     int updatePackagingBoxIdAndSlotByWoSubstrateId(@Param("packagingBoxId") String packagingBoxId, @Param("slot") Integer slot, @Param("woSubstrateId") String woSubstrateId); | ||||||
|  |  | ||||||
|  |     List<PowerReportDTO> powerReport(@Param("queryParam") PowerReportQueryParam queryParam); | ||||||
|  |     List<String> orderNameList(); | ||||||
|  |  | ||||||
|  |     List<WoPackagingBoxSubstrateDTO> substrateList(Map<String, Object> params); | ||||||
|  |     //List<WoPackagingBoxSubstrateDTO> substrateList(@Param("woSubstrateId") String woSubstrateId); | ||||||
|  |     IPage<WoPackagingBoxSubstrateDTO> substratePage(Page<?> page, @Param("param")PackingInfoQueryParam param); | ||||||
|  |  | ||||||
|  |     IPage<SubIdPageVo> subIdPage(Page<?> page, @Param("param") SubIdQueryParam param); | ||||||
| } | } | ||||||
| @@ -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(); | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,21 @@ | |||||||
|  | package com.cnbm.packing.param; | ||||||
|  |  | ||||||
|  | import com.cnbm.packing.vo.BasePageParam; | ||||||
|  | import io.swagger.annotations.ApiImplicitParam; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | import java.time.LocalDateTime; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @Desc: "" | ||||||
|  |  * @Author: yanyang | ||||||
|  |  * @DATE: 2023/3/27 16:00 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class PackingInfoQueryParam extends BasePageParam { | ||||||
|  |     private LocalDateTime startTime; | ||||||
|  |     private LocalDateTime endTime; | ||||||
|  |     private Integer model; | ||||||
|  |     private String packagingBoxId; | ||||||
|  |     private String woSubstrateId; | ||||||
|  | } | ||||||
| @@ -0,0 +1,22 @@ | |||||||
|  | package com.cnbm.packing.param; | ||||||
|  |  | ||||||
|  | import com.fasterxml.jackson.annotation.JsonFormat; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | import java.time.LocalDateTime; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @Desc: "" | ||||||
|  |  * @Author: caixiang | ||||||
|  |  * @DATE: 2023/2/15 19:05 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class PowerReportQueryParam { | ||||||
|  |     //@JsonFormat(shape=JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") | ||||||
|  |     private LocalDateTime begin; | ||||||
|  |     //@JsonFormat(shape= JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss") | ||||||
|  |     private LocalDateTime end; | ||||||
|  |     private String orderName; | ||||||
|  |     private Integer model; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -0,0 +1,15 @@ | |||||||
|  | package com.cnbm.packing.param; | ||||||
|  |  | ||||||
|  | import com.cnbm.packing.vo.BasePageParam; | ||||||
|  | import lombok.Data; | ||||||
|  |  | ||||||
|  | /** | ||||||
|  |  * @Desc: "" | ||||||
|  |  * @Author: caixiang | ||||||
|  |  * @DATE: 2023/2/15 19:05 | ||||||
|  |  */ | ||||||
|  | @Data | ||||||
|  | public class SubIdQueryParam extends BasePageParam { | ||||||
|  |     private String boxNo; | ||||||
|  |  | ||||||
|  | } | ||||||
| @@ -3,9 +3,9 @@ package com.cnbm.packing.service; | |||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.CrudService; | import com.cnbm.common.service.CrudService; | ||||||
| import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; | import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; | ||||||
| import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; |  | ||||||
| import com.cnbm.packing.entity.ChangePackagingBoxHistory; | import com.cnbm.packing.entity.ChangePackagingBoxHistory; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -26,4 +26,8 @@ public interface ChangePackagingBoxHistoryServiceBiz extends CrudService<ChangeP | |||||||
|  |  | ||||||
|     void delete(Long[] ids); |     void delete(Long[] ids); | ||||||
|  |  | ||||||
|  |     List<ChangePackagingBoxHistoryDTO> list(Map<String, Object> params); | ||||||
|  |  | ||||||
|  |     List<ChangePackagingBoxHistory> historyList(Map<String, Object> params); | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -2,6 +2,8 @@ package com.cnbm.packing.service; | |||||||
|  |  | ||||||
| import com.cnbm.dynamic.datasource.annotation.DataSource; | import com.cnbm.dynamic.datasource.annotation.DataSource; | ||||||
| import com.cnbm.packing.dto.CamlineExtendArgDTO; | import com.cnbm.packing.dto.CamlineExtendArgDTO; | ||||||
|  | import com.cnbm.packing.dto.CamlineSubIdDTO; | ||||||
|  | import com.cnbm.packing.dto.CamlineSubIdForImportDTO; | ||||||
| import com.cnbm.packing.dto.WoPowerLevelDTO; | import com.cnbm.packing.dto.WoPowerLevelDTO; | ||||||
| import com.cnbm.packing.mapper.CamlineMapper; | import com.cnbm.packing.mapper.CamlineMapper; | ||||||
|  |  | ||||||
| @@ -29,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){ | ||||||
| @@ -41,10 +47,22 @@ public class DynamicDataSourceService { | |||||||
|         return mapper.getOrderNameBySubId(subId); |         return mapper.getOrderNameBySubId(subId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @DataSource("camline") | ||||||
|  |     @Transactional | ||||||
|  |     public CamlineSubIdDTO getSubIdByCamline(String subId){ | ||||||
|  |         return mapper.getSubIdByCamline(subId); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     @DataSource("camline") |     @DataSource("camline") | ||||||
|     @Transactional |     @Transactional | ||||||
|     public CamlineExtendArgDTO getExtendArgFromCamline(String subId){ |     public CamlineExtendArgDTO getExtendArgFromCamline(String subId){ | ||||||
|         return mapper.getExtendArgFromCamline(subId); |         return mapper.getExtendArgFromCamline(subId); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @DataSource("camline") | ||||||
|  |     @Transactional | ||||||
|  |     public List<CamlineSubIdForImportDTO> getAlllCamlineSubForImp(String[] subIds){ | ||||||
|  |         return mapper.getSubIdByCamlineForImpoet(subIds); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
|   | |||||||
| @@ -3,7 +3,6 @@ package com.cnbm.packing.service; | |||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.CrudService; | import com.cnbm.common.service.CrudService; | ||||||
| import com.cnbm.packing.dto.PrintModelDTO; | import com.cnbm.packing.dto.PrintModelDTO; | ||||||
| import com.cnbm.packing.dto.PrintModelDTO; |  | ||||||
| import com.cnbm.packing.entity.PrintModel; | import com.cnbm.packing.entity.PrintModel; | ||||||
|  |  | ||||||
| import java.util.List; | import java.util.List; | ||||||
| @@ -31,4 +30,6 @@ public interface PrintModelServiceBiz extends CrudService<PrintModel, PrintModel | |||||||
|     List<PrintModelDTO> list(); |     List<PrintModelDTO> list(); | ||||||
|  |  | ||||||
|     String getCode(); |     String getCode(); | ||||||
|  |  | ||||||
|  |     PrintModelDTO getByLineBody(Integer lineBody); | ||||||
| } | } | ||||||
| @@ -2,7 +2,6 @@ package com.cnbm.packing.service; | |||||||
|  |  | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.CrudService; | import com.cnbm.common.service.CrudService; | ||||||
| import com.cnbm.packing.dto.CompensationPowerXSDTO; |  | ||||||
| import com.cnbm.packing.dto.WoCompensationPowerDTO; | import com.cnbm.packing.dto.WoCompensationPowerDTO; | ||||||
| import com.cnbm.packing.entity.WoCompensationPower; | import com.cnbm.packing.entity.WoCompensationPower; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -1,11 +1,21 @@ | |||||||
| package com.cnbm.packing.service; | package com.cnbm.packing.service; | ||||||
|  |  | ||||||
|  | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||||
|  | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.CrudService; | import com.cnbm.common.service.CrudService; | ||||||
| import com.cnbm.packing.dto.IdVo; | import com.cnbm.packing.dto.IdVo; | ||||||
|  | import com.cnbm.packing.dto.PowerReportDTO; | ||||||
| import com.cnbm.packing.dto.WoPackagingBoxDTO; | import com.cnbm.packing.dto.WoPackagingBoxDTO; | ||||||
| import com.cnbm.packing.entity.WoPackagingBox; | import com.cnbm.packing.entity.WoPackagingBox; | ||||||
|  | import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | ||||||
|  | import com.cnbm.packing.param.PowerReportQueryParam; | ||||||
|  | import com.cnbm.packing.param.SubIdQueryParam; | ||||||
|  | import com.cnbm.packing.vo.R; | ||||||
|  | import com.cnbm.packing.vo.SubIdPageVo; | ||||||
|  | import org.apache.ibatis.annotations.Param; | ||||||
|  |  | ||||||
|  | import java.time.LocalDateTime; | ||||||
| import java.util.List; | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| @@ -31,6 +41,19 @@ public interface WoPackagingBoxServiceBiz extends CrudService<WoPackagingBox, Wo | |||||||
|  |  | ||||||
|     WoPackagingBoxDTO printList(Long id); |     WoPackagingBoxDTO printList(Long id); | ||||||
|  |  | ||||||
|  |     List<WoPackagingBoxSubstrate> substrateList (Map<String, Object> params); | ||||||
|  |  | ||||||
|  |     List<WoPackagingBox> boxList (String woSubstrateId); | ||||||
|  |  | ||||||
|  |     IdVo insertSubstrateManual(WoPackagingBoxDTO dto); | ||||||
|  |  | ||||||
|  |     void editSubstrateManual(WoPackagingBoxDTO dto); | ||||||
|  |  | ||||||
|  |  | ||||||
|     int updateIsArrivedByBoxNo(Integer isArrived, String boxNo); |     int updateIsArrivedByBoxNo(Integer isArrived, String boxNo); | ||||||
|  |  | ||||||
|  |     List<PowerReportDTO> powerReport(PowerReportQueryParam queryParam); | ||||||
|  |     List<String> orderNameList(); | ||||||
|  |  | ||||||
|  |     R<IPage<SubIdPageVo>> subIdPage(SubIdQueryParam param); | ||||||
| } | } | ||||||
| @@ -5,7 +5,9 @@ import com.cnbm.common.service.CrudService; | |||||||
| import com.cnbm.packing.dto.ChangePackingBoxDTO; | import com.cnbm.packing.dto.ChangePackingBoxDTO; | ||||||
| import com.cnbm.packing.dto.WoPackagingBoxSubstrateDTO; | import com.cnbm.packing.dto.WoPackagingBoxSubstrateDTO; | ||||||
| import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | import com.cnbm.packing.entity.WoPackagingBoxSubstrate; | ||||||
|  | import com.cnbm.packing.param.PackingInfoQueryParam; | ||||||
|  |  | ||||||
|  | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -32,8 +34,16 @@ public interface WoPackagingBoxSubstrateServiceBiz extends CrudService<WoPackagi | |||||||
|  |  | ||||||
|     void replaceSubstrate(ChangePackingBoxDTO[] dtos); |     void replaceSubstrate(ChangePackingBoxDTO[] dtos); | ||||||
|  |  | ||||||
|     void insertSubstrateManual(ChangePackingBoxDTO dto); |     void insertSubstrateManual(ChangePackingBoxDTO[] dtos); | ||||||
|  |  | ||||||
|  |     void updateSubstrateManual(ChangePackingBoxDTO[] dtos); | ||||||
|  |  | ||||||
|     WoPackagingBoxSubstrate getBySubId(String subId); |     WoPackagingBoxSubstrate getBySubId(String subId); | ||||||
|     int updatePackagingBoxIdByWoSubstrateId(String packagingBoxId,String woSubstrateId); |  | ||||||
|  |     List<WoPackagingBoxSubstrateDTO> substrateList (Map<String, Object> params); | ||||||
|  |  | ||||||
|  |     PageData<WoPackagingBoxSubstrateDTO> substratePage (PackingInfoQueryParam param); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |     int updatePackagingBoxIdAndSlotByWoSubstrateId(String packagingBoxId,Integer slot,String woSubstrateId); | ||||||
| } | } | ||||||
| @@ -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); | ||||||
|  | } | ||||||
| @@ -3,22 +3,22 @@ package com.cnbm.packing.service.impl; | |||||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||||
| import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | ||||||
|  | import com.cnbm.admin.utils.BaseSupportUtils; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.impl.CrudServiceImpl; | import com.cnbm.common.service.impl.CrudServiceImpl; | ||||||
| import com.cnbm.common.utils.ConvertUtils; | import com.cnbm.common.utils.ConvertUtils; | ||||||
| import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; | import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; | ||||||
| import com.cnbm.packing.dto.ChangePackagingBoxHistoryDTO; |  | ||||||
| import com.cnbm.packing.entity.ChangePackagingBoxHistory; | import com.cnbm.packing.entity.ChangePackagingBoxHistory; | ||||||
| import com.cnbm.packing.entity.ChangePackagingBoxHistory; |  | ||||||
| import com.cnbm.packing.entity.WoPowerLevel; |  | ||||||
| import com.cnbm.packing.mapper.ChangePackagingBoxHistoryMapper; | import com.cnbm.packing.mapper.ChangePackagingBoxHistoryMapper; | ||||||
| import com.cnbm.packing.service.ChangePackagingBoxHistoryServiceBiz; | import com.cnbm.packing.service.ChangePackagingBoxHistoryServiceBiz; | ||||||
| import org.apache.commons.lang3.StringUtils; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||||
|  |  | ||||||
| import java.time.LocalDateTime; | import java.time.LocalDateTime; | ||||||
|  | import java.time.format.DateTimeFormatter; | ||||||
| import java.util.Arrays; | import java.util.Arrays; | ||||||
|  | import java.util.List; | ||||||
| import java.util.Map; | import java.util.Map; | ||||||
|  |  | ||||||
| /** | /** | ||||||
| @@ -30,18 +30,28 @@ import java.util.Map; | |||||||
| @Service | @Service | ||||||
| public class ChangePackagingBoxHistoryServiceBizImpl extends CrudServiceImpl<ChangePackagingBoxHistoryMapper, ChangePackagingBoxHistory, ChangePackagingBoxHistoryDTO> implements ChangePackagingBoxHistoryServiceBiz { | public class ChangePackagingBoxHistoryServiceBizImpl extends CrudServiceImpl<ChangePackagingBoxHistoryMapper, ChangePackagingBoxHistory, ChangePackagingBoxHistoryDTO> implements ChangePackagingBoxHistoryServiceBiz { | ||||||
|  |  | ||||||
|  |     @Autowired | ||||||
|  |     private ChangePackagingBoxHistoryMapper mapper; | ||||||
|  |  | ||||||
|     @Override |     @Override | ||||||
|     public QueryWrapper<ChangePackagingBoxHistory> getWrapper(Map<String, Object> params){ |     public QueryWrapper<ChangePackagingBoxHistory> getWrapper(Map<String, Object> params){ | ||||||
|         LocalDateTime startTime = (LocalDateTime) params.get("startTime"); |  | ||||||
|         LocalDateTime endTime = (LocalDateTime) params.get("endTime"); |  | ||||||
|  |  | ||||||
|         QueryWrapper<ChangePackagingBoxHistory> wrapper = new QueryWrapper<>(); |         QueryWrapper<ChangePackagingBoxHistory> wrapper = new QueryWrapper<>(); | ||||||
|         wrapper.between(startTime!=null && endTime!=null,ChangePackagingBoxHistory.INPUT_TIME, startTime, endTime); |  | ||||||
|         wrapper.between(startTime!=null && endTime!=null,ChangePackagingBoxHistory.LEAVE_TIME, startTime, endTime); |         DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); | ||||||
|  |         if(params.get("startTime")!=null && params.get("endTime")!=null){ | ||||||
|  |             LocalDateTime startTime = LocalDateTime.parse(params.get("startTime").toString(),df); | ||||||
|  |             LocalDateTime endTime = LocalDateTime.parse(params.get("endTime").toString(),df); | ||||||
|  |             wrapper.between(startTime!=null && endTime!=null,ChangePackagingBoxHistory.CREATE_TIME, startTime, endTime); | ||||||
|  |         } | ||||||
|         if(params.get("type")!=null) { |         if(params.get("type")!=null) { | ||||||
|             Integer type = Integer.parseInt( params.get("type").toString()); |             Integer type = Integer.parseInt( params.get("type").toString()); | ||||||
|             wrapper.eq(ObjectUtils.isNotNull(type), ChangePackagingBoxHistory.TYPE, type); |             wrapper.eq(ObjectUtils.isNotNull(type), ChangePackagingBoxHistory.TYPE, type); | ||||||
|         } |         } | ||||||
|  |         if(params.get("startTime")==null && params.get("endTime")==null && params.get("type")==null){ | ||||||
|  |             wrapper.apply(true, "TO_DAYS(NOW())-TO_DAYS(create_time) = 0"); | ||||||
|  |         } | ||||||
|  |         wrapper.orderByDesc(ChangePackagingBoxHistory.CREATE_TIME); | ||||||
|  |  | ||||||
|         return wrapper; |         return wrapper; | ||||||
|     } |     } | ||||||
| @@ -49,8 +59,8 @@ public class ChangePackagingBoxHistoryServiceBizImpl extends CrudServiceImpl<Cha | |||||||
|     @Override |     @Override | ||||||
|     public PageData<ChangePackagingBoxHistoryDTO> page (Map<String, Object> params){ |     public PageData<ChangePackagingBoxHistoryDTO> page (Map<String, Object> params){ | ||||||
|         IPage<ChangePackagingBoxHistory> page = baseDao.selectPage( |         IPage<ChangePackagingBoxHistory> page = baseDao.selectPage( | ||||||
|                 getPage(params, ChangePackagingBoxHistory.CREATE_TIME, true), |             getPage(params, ChangePackagingBoxHistory.CREATE_TIME, false), | ||||||
|                 getWrapper(params) |             getWrapper(params) | ||||||
|         ); |         ); | ||||||
|         return getPageData(page, ChangePackagingBoxHistoryDTO.class); |         return getPageData(page, ChangePackagingBoxHistoryDTO.class); | ||||||
|     } |     } | ||||||
| @@ -65,6 +75,7 @@ public class ChangePackagingBoxHistoryServiceBizImpl extends CrudServiceImpl<Cha | |||||||
|     @Transactional(rollbackFor = Exception.class) |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void save(ChangePackagingBoxHistoryDTO dto) { |     public void save(ChangePackagingBoxHistoryDTO dto) { | ||||||
|         ChangePackagingBoxHistory entity = ConvertUtils.sourceToTarget(dto, ChangePackagingBoxHistory.class); |         ChangePackagingBoxHistory entity = ConvertUtils.sourceToTarget(dto, ChangePackagingBoxHistory.class); | ||||||
|  |         BaseSupportUtils.setCommonField(entity); | ||||||
|         insert(entity); |         insert(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -72,6 +83,7 @@ public class ChangePackagingBoxHistoryServiceBizImpl extends CrudServiceImpl<Cha | |||||||
|     @Transactional(rollbackFor = Exception.class) |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void update(ChangePackagingBoxHistoryDTO dto) { |     public void update(ChangePackagingBoxHistoryDTO dto) { | ||||||
|         ChangePackagingBoxHistory entity = ConvertUtils.sourceToTarget(dto, ChangePackagingBoxHistory.class); |         ChangePackagingBoxHistory entity = ConvertUtils.sourceToTarget(dto, ChangePackagingBoxHistory.class); | ||||||
|  |         BaseSupportUtils.setUpdateCommonField(entity); | ||||||
|         updateById(entity); |         updateById(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -82,4 +94,19 @@ public class ChangePackagingBoxHistoryServiceBizImpl extends CrudServiceImpl<Cha | |||||||
|         deleteBatchIds(Arrays.asList(ids)); |         deleteBatchIds(Arrays.asList(ids)); | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|  |     public List<ChangePackagingBoxHistoryDTO> list(Map<String, Object> params) { | ||||||
|  |         List<ChangePackagingBoxHistoryDTO> list = mapper.list(params); | ||||||
|  |         return list; | ||||||
|  |     } | ||||||
|  |  | ||||||
|  |     @Override | ||||||
|  |     @Transactional(rollbackFor = Exception.class) | ||||||
|  |     public List<ChangePackagingBoxHistory> historyList(Map<String, Object> params) { | ||||||
|  |         QueryWrapper<ChangePackagingBoxHistory> wrapper = getWrapper(params); | ||||||
|  |         List<ChangePackagingBoxHistory> historyList = mapper.selectList(wrapper); | ||||||
|  |         return historyList; | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -3,6 +3,7 @@ package com.cnbm.packing.service.impl; | |||||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||||
| import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | ||||||
|  | import com.cnbm.admin.utils.BaseSupportUtils; | ||||||
| import com.cnbm.admin.utils.CodeGeneratorHelper; | import com.cnbm.admin.utils.CodeGeneratorHelper; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.impl.CrudServiceImpl; | import com.cnbm.common.service.impl.CrudServiceImpl; | ||||||
| @@ -46,6 +47,10 @@ public class PrintModelServiceBizImpl extends CrudServiceImpl<PrintModelMapper, | |||||||
|             Integer lineBody = Integer.parseInt(params.get("lineBody").toString()); |             Integer lineBody = Integer.parseInt(params.get("lineBody").toString()); | ||||||
|             wrapper.eq(ObjectUtils.isNotNull(lineBody), PrintModel.LINE_BODY, lineBody); |             wrapper.eq(ObjectUtils.isNotNull(lineBody), PrintModel.LINE_BODY, lineBody); | ||||||
|         } |         } | ||||||
|  |         if(params.get("isEnable")!=null) { | ||||||
|  |             Integer isEnable = Integer.parseInt(params.get("isEnable").toString()); | ||||||
|  |             wrapper.eq(ObjectUtils.isNotNull(isEnable), PrintModel.IS_ENABLE, isEnable); | ||||||
|  |         } | ||||||
|  |  | ||||||
|         return wrapper; |         return wrapper; | ||||||
|     } |     } | ||||||
| @@ -53,7 +58,7 @@ public class PrintModelServiceBizImpl extends CrudServiceImpl<PrintModelMapper, | |||||||
|     @Override |     @Override | ||||||
|     public PageData<PrintModelDTO> page (Map<String, Object> params){ |     public PageData<PrintModelDTO> page (Map<String, Object> params){ | ||||||
|         IPage<PrintModel> page = baseDao.selectPage( |         IPage<PrintModel> page = baseDao.selectPage( | ||||||
|                 getPage(params, PrintModel.ID, true), |                 getPage(params, PrintModel.CREATE_TIME, false), | ||||||
|                 getWrapper(params) |                 getWrapper(params) | ||||||
|         ); |         ); | ||||||
|         return getPageData(page, PrintModelDTO.class); |         return getPageData(page, PrintModelDTO.class); | ||||||
| @@ -69,6 +74,7 @@ public class PrintModelServiceBizImpl extends CrudServiceImpl<PrintModelMapper, | |||||||
|     @Transactional(rollbackFor = Exception.class) |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void save(PrintModelDTO dto) { |     public void save(PrintModelDTO dto) { | ||||||
|         PrintModel entity = ConvertUtils.sourceToTarget(dto, PrintModel.class); |         PrintModel entity = ConvertUtils.sourceToTarget(dto, PrintModel.class); | ||||||
|  |         BaseSupportUtils.setCommonField(entity); | ||||||
|         insert(entity); |         insert(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -76,6 +82,7 @@ public class PrintModelServiceBizImpl extends CrudServiceImpl<PrintModelMapper, | |||||||
|     @Transactional(rollbackFor = Exception.class) |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void update(PrintModelDTO dto) { |     public void update(PrintModelDTO dto) { | ||||||
|         PrintModel entity = ConvertUtils.sourceToTarget(dto, PrintModel.class); |         PrintModel entity = ConvertUtils.sourceToTarget(dto, PrintModel.class); | ||||||
|  |         BaseSupportUtils.setUpdateCommonField(entity); | ||||||
|         updateById(entity); |         updateById(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -100,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); | ||||||
|  |     } | ||||||
|  |  | ||||||
| } | } | ||||||
| @@ -3,18 +3,16 @@ package com.cnbm.packing.service.impl; | |||||||
| import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; | ||||||
| import com.baomidou.mybatisplus.core.metadata.IPage; | import com.baomidou.mybatisplus.core.metadata.IPage; | ||||||
| import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | import com.baomidou.mybatisplus.core.toolkit.ObjectUtils; | ||||||
|  | import com.cnbm.admin.utils.BaseSupportUtils; | ||||||
| import com.cnbm.common.page.PageData; | import com.cnbm.common.page.PageData; | ||||||
| import com.cnbm.common.service.impl.CrudServiceImpl; | import com.cnbm.common.service.impl.CrudServiceImpl; | ||||||
| import com.cnbm.common.utils.ConvertUtils; | import com.cnbm.common.utils.ConvertUtils; | ||||||
| import com.cnbm.packing.dto.CompensationPowerXSDTO; | import com.cnbm.packing.dto.CompensationPowerXSDTO; | ||||||
| import com.cnbm.packing.dto.WoCompensationPowerDTO; | import com.cnbm.packing.dto.WoCompensationPowerDTO; | ||||||
| import com.cnbm.packing.entity.WoCompensationPower; | import com.cnbm.packing.entity.WoCompensationPower; | ||||||
| import com.cnbm.packing.entity.WoPowerLevel; |  | ||||||
| import com.cnbm.packing.mapper.WoCompensationPowerMapper; | import com.cnbm.packing.mapper.WoCompensationPowerMapper; | ||||||
| import com.cnbm.packing.param.CompensationQueryParam; | import com.cnbm.packing.param.CompensationQueryParam; | ||||||
| import com.cnbm.packing.service.WoCompensationPowerServiceBiz; | import com.cnbm.packing.service.WoCompensationPowerServiceBiz; | ||||||
| import lombok.var; |  | ||||||
| import org.apache.commons.lang3.StringUtils; |  | ||||||
| import org.springframework.beans.factory.annotation.Autowired; | import org.springframework.beans.factory.annotation.Autowired; | ||||||
| import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||||
| import org.springframework.transaction.annotation.Transactional; | import org.springframework.transaction.annotation.Transactional; | ||||||
| @@ -50,7 +48,7 @@ public class WoCompensationPowerServiceBizImpl extends CrudServiceImpl<WoCompens | |||||||
|     @Override |     @Override | ||||||
|     public PageData<WoCompensationPowerDTO> page (Map<String, Object> params){ |     public PageData<WoCompensationPowerDTO> page (Map<String, Object> params){ | ||||||
|         IPage<WoCompensationPower> page = baseDao.selectPage( |         IPage<WoCompensationPower> page = baseDao.selectPage( | ||||||
|                 getPage(params, WoCompensationPower.ID, true), |                 getPage(params, WoCompensationPower.CREATE_TIME, false), | ||||||
|                 getWrapper(params) |                 getWrapper(params) | ||||||
|         ); |         ); | ||||||
|         return getPageData(page, WoCompensationPowerDTO.class); |         return getPageData(page, WoCompensationPowerDTO.class); | ||||||
| @@ -66,6 +64,7 @@ public class WoCompensationPowerServiceBizImpl extends CrudServiceImpl<WoCompens | |||||||
|     @Transactional(rollbackFor = Exception.class) |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void save(WoCompensationPowerDTO dto) { |     public void save(WoCompensationPowerDTO dto) { | ||||||
|         WoCompensationPower entity = ConvertUtils.sourceToTarget(dto, WoCompensationPower.class); |         WoCompensationPower entity = ConvertUtils.sourceToTarget(dto, WoCompensationPower.class); | ||||||
|  |         BaseSupportUtils.setCommonField(entity); | ||||||
|         insert(entity); |         insert(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -73,6 +72,7 @@ public class WoCompensationPowerServiceBizImpl extends CrudServiceImpl<WoCompens | |||||||
|     @Transactional(rollbackFor = Exception.class) |     @Transactional(rollbackFor = Exception.class) | ||||||
|     public void update(WoCompensationPowerDTO dto) { |     public void update(WoCompensationPowerDTO dto) { | ||||||
|         WoCompensationPower entity = ConvertUtils.sourceToTarget(dto, WoCompensationPower.class); |         WoCompensationPower entity = ConvertUtils.sourceToTarget(dto, WoCompensationPower.class); | ||||||
|  |         BaseSupportUtils.setUpdateCommonField(entity); | ||||||
|         updateById(entity); |         updateById(entity); | ||||||
|     } |     } | ||||||
|  |  | ||||||
| @@ -98,8 +98,11 @@ public class WoCompensationPowerServiceBizImpl extends CrudServiceImpl<WoCompens | |||||||
|  |  | ||||||
|  |  | ||||||
|         CompensationPowerXSDTO conffBySubIdAndLineBody = mapper.getConffBySubIdAndLineBody(compensationQueryParam); |         CompensationPowerXSDTO conffBySubIdAndLineBody = mapper.getConffBySubIdAndLineBody(compensationQueryParam); | ||||||
|         float res = pmpp*conffBySubIdAndLineBody.getA()+conffBySubIdAndLineBody.getB(); |         if(conffBySubIdAndLineBody!=null){ | ||||||
|         return res; |             return pmpp*conffBySubIdAndLineBody.getA()+conffBySubIdAndLineBody.getB(); | ||||||
|  |         }else { | ||||||
|  |             return pmpp; | ||||||
|  |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |  | ||||||
|   | |||||||
Some files were not shown because too many files have changed in this diff Show More
		Reference in New Issue
	
	Block a user