| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | | import org.jeecg.common.system.vo.LoginUser; |
| | | import org.jeecg.modules.andon.dto.AndonButtonDTO; |
| | | import org.jeecg.modules.andon.dto.AndonOrdeDto; |
| | | import org.jeecg.modules.andon.entity.AndonButtonConfig; |
| | | import org.jeecg.modules.andon.entity.AndonOrder; |
| | | import org.jeecg.modules.andon.entity.AndonResponseConfig; |
| | |
| | | } |
| | | |
| | | @Override |
| | | public List<AndonButtonDTO> queryAndonButtonList(String factoryId) { |
| | | return Collections.emptyList(); |
| | | public String getProductionLineIdByButtonId(String buttonId) { |
| | | QueryWrapper<AndonResponseConfig> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("button_id", buttonId); |
| | | AndonResponseConfig config = this.getOne(queryWrapper); |
| | | return config != null ? config.getFactoryId() : null; |
| | | } |
| | | |
| | | @Override |
| | | public void sendAndonNotification(AndonButtonDTO andonButtonDTO) { |
| | | public String getResponderByButtonId(String buttonId,String factoryId) { |
| | | QueryWrapper<AndonResponseConfig> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("button_id", buttonId); |
| | | queryWrapper.eq("factory_id", factoryId); // 假设factory_id对应产线ID |
| | | AndonResponseConfig config = this.getOne(queryWrapper, false); |
| | | return config != null ? config.getFirsterResponder() : null; |
| | | } |
| | | |
| | | @Override |
| | | public AndonResponseConfig getResponseConfigByButtonIdAndFactoryId(String buttonId, String factoryId) { |
| | | QueryWrapper<AndonResponseConfig> queryWrapper = new QueryWrapper<>(); |
| | | queryWrapper.eq("button_id", buttonId); |
| | | queryWrapper.eq("factory_id", factoryId); |
| | | // 使用false参数,当查询到多条记录时不会抛出异常,而是返回第一条 |
| | | return this.getOne(queryWrapper, false); |
| | | } |
| | | |
| | | |
| | | @Override |
| | | public void sendAndonNotification(AndonOrdeDto andonButtonDTO) { |
| | | /** |
| | | * 1. 验证工单状态 |
| | | */ |
| | |
| | | log.warn("请求参数为空"); |
| | | throw new IllegalArgumentException("请求参数不能为空"); |
| | | } |
| | | |
| | | /** |
| | | * 2. 获取响应配置 |
| | | */ |
| | | AndonResponseConfig andonResponseConfig = this.getById(andonButtonDTO.getId()); |
| | | AndonResponseConfig andonResponseConfig = getResponseConfigByButtonIdAndFactoryId(andonButtonDTO.getButtonId(), andonButtonDTO.getFactoryId()); |
| | | |
| | | AndonOrder andonOrder = andonOrderService.getById(andonButtonDTO.getOrderIds()); |
| | | AndonOrder andonOrder = andonOrderService.getById(andonButtonDTO.getId()); |
| | | if (andonOrder == null) { |
| | | log.warn("未找到ID为[{}]的安灯订单"); |
| | | throw new IllegalArgumentException("未找到对应的安灯订单"); |
| | | } |
| | | // 获取当前登录用户 |
| | | LoginUser loginUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (loginUser != null) { |
| | | log.warn("未找到当前用户"); |
| | | |
| | | } |
| | | assert loginUser != null; |
| | | andonOrder.setResponder(loginUser.getId()); |
| | | String orderStatus = andonOrder.getOrderStatus(); |
| | | andonButtonDTO.setOrderStatus(orderStatus); |
| | | if (andonResponseConfig == null) { |