diff --git a/src/main/java/com/huaheng/pc/agv/controller/AgvPortController.java b/src/main/java/com/huaheng/pc/agv/controller/AgvPortController.java index 71ec5b9..aae8be2 100644 --- a/src/main/java/com/huaheng/pc/agv/controller/AgvPortController.java +++ b/src/main/java/com/huaheng/pc/agv/controller/AgvPortController.java @@ -10,6 +10,8 @@ import com.huaheng.framework.web.page.PageDomain; import com.huaheng.framework.web.page.TableDataInfo; import com.huaheng.framework.web.page.TableSupport; import com.huaheng.common.utils.StringUtils; +import com.huaheng.pc.agv.service.IWorkStationFlowService; +import com.huaheng.pc.agv.service.IWorkStationService; import org.apache.shiro.authz.annotation.RequiresPermissions; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; @@ -46,6 +48,12 @@ public class AgvPortController extends BaseController { @Resource private IAgvPortService agvPortService; + @Resource + private IWorkStationService workStationService; + + @Resource + private IWorkStationFlowService workStationFlowService; + @RequiresPermissions("agv:agvport:view") @GetMapping() public String agvPort() { @@ -86,6 +94,23 @@ public class AgvPortController extends BaseController { } /** + * 取当前工位上下游工位点位 + * @return + */ + @RequiresPermissions("agv:agvport:view") + @PostMapping("/getAgvPortFlow") + @ResponseBody + public AjaxResult<List<AgvPort>> getAgvPortFlow(Long workStationId, String agvPortType) { + List<Long> ids = workStationFlowService.getWorkStationFlowIds(workStationId); + LambdaQueryWrapper<AgvPort> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.in(AgvPort::getWorkStationId, ids) + .eq(StringUtils.isNotEmpty(agvPortType), AgvPort::getType, agvPortType) + .orderByAsc(AgvPort::getWorkStationId); + List<AgvPort> retList = agvPortService.list(queryWrapper); + return AjaxResult.success(retList); + } + + /** * 新增【请填写功能名称】 */ @GetMapping("/add") diff --git a/src/main/java/com/huaheng/pc/agv/service/IWorkStationFlowService.java b/src/main/java/com/huaheng/pc/agv/service/IWorkStationFlowService.java index 8a5adc7..f2b1f7d 100644 --- a/src/main/java/com/huaheng/pc/agv/service/IWorkStationFlowService.java +++ b/src/main/java/com/huaheng/pc/agv/service/IWorkStationFlowService.java @@ -11,7 +11,7 @@ import java.util.List; * @date 2022-07-26 */ public interface IWorkStationFlowService extends IService<WorkStationFlow> { - + List<Long> getWorkStationFlowIds(Long workStationId); } diff --git a/src/main/java/com/huaheng/pc/agv/service/impl/WorkStationFlowServiceImpl.java b/src/main/java/com/huaheng/pc/agv/service/impl/WorkStationFlowServiceImpl.java index b62553b..4f42ac7 100644 --- a/src/main/java/com/huaheng/pc/agv/service/impl/WorkStationFlowServiceImpl.java +++ b/src/main/java/com/huaheng/pc/agv/service/impl/WorkStationFlowServiceImpl.java @@ -1,11 +1,15 @@ package com.huaheng.pc.agv.service.impl; +import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.huaheng.pc.agv.service.IWorkStationFlowService; import com.huaheng.pc.agv.domain.WorkStationFlow; import com.huaheng.pc.agv.mapper.WorkStationFlowMapper; import org.springframework.stereotype.Service; +import java.util.List; +import java.util.stream.Collectors; + /** * 维护工位的上下游关系 服务层实现 @@ -16,4 +20,11 @@ import org.springframework.stereotype.Service; @Service public class WorkStationFlowServiceImpl extends ServiceImpl<WorkStationFlowMapper, WorkStationFlow> implements IWorkStationFlowService { + @Override + public List<Long> getWorkStationFlowIds(Long workStationId) { + LambdaQueryWrapper<WorkStationFlow> queryWrapper = new LambdaQueryWrapper<>(); + queryWrapper.eq(WorkStationFlow::getWorkStationId, workStationId); + List<WorkStationFlow> list = list(queryWrapper); + return list.stream().map(WorkStationFlow::getWorkStationIdRelated).distinct().collect(Collectors.toList()); + } }