| | |
| | | import org.jeecg.common.util.PasswordUtil; |
| | | import org.jeecg.common.util.RestUtil; |
| | | import org.jeecg.common.util.oConvertUtils; |
| | | import org.jeecg.modules.andon.dto.AndonButtonDTO; |
| | | import org.jeecg.modules.andon.dto.AndonOrdeDto; |
| | | import org.jeecg.modules.mes.entity.FeishuUser; |
| | | import org.jeecg.modules.system.entity.SysUser; |
| | | import org.jeecg.modules.system.service.ISysUserService; |
| | |
| | | * 2. 一级响应时长后检查状态,未处理则发送二级 |
| | | * 3. 二级响应时长后检查状态,未处理则发送三级 |
| | | */ |
| | | public boolean sendAndonNotification(String accessToken, AndonButtonDTO andonOrde) { |
| | | public boolean sendAndonNotification(String accessToken, AndonOrdeDto andonOrde) { |
| | | try { |
| | | String currentTime = sdf.format(new Date()); |
| | | log.info("【{}】触发一级响应(初级响应),安灯ID: {}", currentTime, andonOrde.getId()); |
| | |
| | | * 发送指定级别的通知 |
| | | * @param level 1-一级,2-二级,3-三级 |
| | | */ |
| | | private boolean sendLevelNotification(String accessToken, AndonButtonDTO andonOrde, int level) { |
| | | private boolean sendLevelNotification(String accessToken, AndonOrdeDto andonOrde, int level) { |
| | | try { |
| | | String levelDesc = getLevelDesc(level); |
| | | String openId = getResponderOpenId(andonOrde, level); |
| | |
| | | * @param currentLevel 当前级别 |
| | | * @param delayMinutes 延迟分钟数(由当前级别响应时长决定) |
| | | */ |
| | | private void scheduleNextLevelNotification(String accessToken, AndonButtonDTO andonOrde, int currentLevel, int delayMinutes) { |
| | | private void scheduleNextLevelNotification(String accessToken, AndonOrdeDto andonOrde, int currentLevel, int delayMinutes) { |
| | | int nextLevel = currentLevel + 1; |
| | | if (nextLevel > 3) { |
| | | log.info("已到达最高级别通知,无需继续调度,安灯ID: {}", andonOrde.getId()); |
| | |
| | | /** |
| | | * 构建通知内容(优化分隔符,提升可读性) |
| | | */ |
| | | private String buildNotificationContent(AndonButtonDTO andonOrde, int level) { |
| | | private String buildNotificationContent(AndonOrdeDto andonOrde, int level) { |
| | | // 获取工厂名称和产线名称,做空值保护 |
| | | String parentFactoryName = andonOrde.getParentFactoryName() != null ? andonOrde.getParentFactoryName() : "未知工厂"; |
| | | String factoryName = andonOrde.getFactoryName() != null ? andonOrde.getFactoryName() : "未知产线"; |
| | |
| | | /** |
| | | * 验证通知相关参数 |
| | | */ |
| | | private boolean validateNotificationParams(AndonButtonDTO andonOrde) { |
| | | private boolean validateNotificationParams(AndonOrdeDto andonOrde) { |
| | | if (andonOrde == null) { |
| | | log.error("安灯订单信息为空"); |
| | | return false; |
| | |
| | | } |
| | | |
| | | // 工具方法:获取响应人openId |
| | | private String getResponderOpenId(AndonButtonDTO andonOrde, int level) { |
| | | private String getResponderOpenId(AndonOrdeDto andonOrde, int level) { |
| | | switch (level) { |
| | | case 1: return andonOrde.getResponderOpenId(); |
| | | case 2: return andonOrde.getSecondResponderOpenId(); |
| | |
| | | } |
| | | |
| | | // 工具方法:获取响应人名称 |
| | | private String getResponderName(AndonButtonDTO andonOrde, int level) { |
| | | private String getResponderName(AndonOrdeDto andonOrde, int level) { |
| | | String name = null; |
| | | switch (level) { |
| | | case 1: |
| | |
| | | } |
| | | |
| | | // 工具方法:获取响应时长(一级=二级延迟,二级=三级延迟) |
| | | private int getResponseDuration(AndonButtonDTO andonOrde, int level) { |
| | | private int getResponseDuration(AndonOrdeDto andonOrde, int level) { |
| | | int duration = 0; |
| | | switch (level) { |
| | | case 1: |
| | |
| | | } |
| | | |
| | | // 工具方法:判断指定级别响应人是否有效 |
| | | private boolean hasValidResponder(AndonButtonDTO andonOrde, int level) { |
| | | private boolean hasValidResponder(AndonOrdeDto andonOrde, int level) { |
| | | String openId = getResponderOpenId(andonOrde, level); |
| | | return openId != null && !openId.isEmpty(); |
| | | } |