| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; |
| | | import com.baomidou.mybatisplus.core.metadata.IPage; |
| | | import com.baomidou.mybatisplus.extension.plugins.pagination.Page; |
| | | import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
| | | import org.apache.commons.lang3.StringUtils; |
| | | import org.apache.shiro.SecurityUtils; |
| | |
| | | import org.jeecg.modules.eam.service.IEamEquipmentService; |
| | | import org.jeecg.modules.eam.tree.FindsEquipmentProductionUtil; |
| | | import org.jeecg.modules.eam.vo.EamEquipmentTree; |
| | | import org.jeecg.modules.eam.vo.EquipmentSearchResult; |
| | | import org.jeecg.modules.system.entity.MdcProduction; |
| | | import org.jeecg.modules.system.service.IMdcProductionService; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | |
| | | return ipage; |
| | | } |
| | | |
| | | @Override |
| | | public List<EquipmentSearchResult> asyncLoadEquipment(String keyword, Integer pageSize) { |
| | | IPage<EamEquipment> page = new Page<>(1, pageSize); |
| | | QueryWrapper<EamEquipment> queryWrapper = new QueryWrapper<>(); |
| | | //用户数据权限 |
| | | LoginUser sysUser = (LoginUser) SecurityUtils.getSubject().getPrincipal(); |
| | | if (sysUser == null) { |
| | | return Collections.emptyList(); |
| | | } |
| | | if (StringUtils.isNotBlank(sysUser.getEquipmentIds())) { |
| | | //选择了设备,根据设备id过滤设备 |
| | | List<String> equipArr = Arrays.asList(sysUser.getEquipmentIds().split(",")); |
| | | queryWrapper.in("equipment_code", equipArr); |
| | | } else { |
| | | //没有选择设备,根据车间过滤设备 |
| | | queryWrapper.exists("select 1 from mdc_user_production t where t.user_id={0} and t.pro_id=org_id", sysUser.getId()); |
| | | } |
| | | if (StringUtils.isNotBlank(keyword)) { |
| | | queryWrapper.like("equipment_code", keyword); |
| | | queryWrapper.or().like("equipment_name", keyword); |
| | | } |
| | | IPage<EamEquipment> pageResult = eamEquipmentMapper.queryPageList(page, queryWrapper); |
| | | if (pageResult != null && CollectionUtil.isNotEmpty(pageResult.getRecords())) { |
| | | List<EquipmentSearchResult> resultList = new ArrayList<>(); |
| | | pageResult.getRecords().forEach((record) -> { |
| | | resultList.add(new EquipmentSearchResult(record)); |
| | | }); |
| | | return resultList; |
| | | } |
| | | return Collections.emptyList(); |
| | | } |
| | | |
| | | /** |
| | | * 获取所有的产线id(包含所有上级) |
| | | */ |