| | |
| | | import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
| | | import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
| | | import lombok.RequiredArgsConstructor; |
| | | import org.dromara.eims.domain.EimsEqu; |
| | | import org.dromara.eims.domain.EimsEquType; |
| | | import org.dromara.eims.domain.vo.EimsEquTypeVo; |
| | | import org.dromara.eims.mapper.EimsEquTypeMapper; |
| | | import org.springframework.stereotype.Service; |
| | | import org.dromara.eims.domain.bo.EimsInventoryDetailBo; |
| | | import org.dromara.eims.domain.vo.EimsInventoryDetailVo; |
| | |
| | | import org.dromara.eims.mapper.EimsInventoryDetailMapper; |
| | | import org.dromara.eims.service.IEimsInventoryDetailService; |
| | | |
| | | import java.util.ArrayList; |
| | | import java.util.List; |
| | | import java.util.Map; |
| | | import java.util.Collection; |
| | |
| | | public class EimsInventoryDetailServiceImpl implements IEimsInventoryDetailService { |
| | | |
| | | private final EimsInventoryDetailMapper baseMapper; |
| | | private final EimsEquTypeMapper equTypeMapper; |
| | | |
| | | /** |
| | | * 查询盘点明细 |
| | |
| | | qw.eq(StringUtils.isNotBlank(bo.getStatus()), "a.status", bo.getStatus()); |
| | | |
| | | qw.like(StringUtils.isNotBlank(bo.getEquName()), "c.equ_name", bo.getEquName()); |
| | | qw.like(StringUtils.isNotBlank(bo.getEquCode()), "c.equ_code", bo.getEquCode()); |
| | | qw.like(StringUtils.isNotBlank(bo.getEquAssetNo()), "c.asset_no", bo.getEquAssetNo()); |
| | | qw.like(StringUtils.isNotBlank(bo.getLocation()), "c.location", bo.getLocation()); |
| | | qw.like(StringUtils.isNotBlank(bo.getEquStatus()), "c.status", bo.getEquStatus()); |
| | | /** |
| | | * equTypeId = 0 时查询所有设备(默认根目录id为0,详见SysEquTypeServiceImpl中selectEquTypeTreeList) |
| | | * equTypeId 为其他值时只查当前设备类型id和后代设备类型id |
| | | */ |
| | | if (bo.getEquTypeId() != null && bo.getEquTypeId() > 0) { |
| | | List<Long> allDescendantIds = getAllDescendantIds(bo.getEquTypeId()); |
| | | qw.in("c.equ_type_id", allDescendantIds); |
| | | } |
| | | |
| | | return qw; |
| | | } |
| | | |
| | | /** |
| | | * 根据id,获取所有后代id |
| | | * @param rootId |
| | | * @return |
| | | */ |
| | | public List<Long> getAllDescendantIds(Long rootId) { |
| | | List<Long> result = new ArrayList<>(); |
| | | result.add(rootId); |
| | | collectDescendants(rootId, result); |
| | | return result; |
| | | } |
| | | |
| | | private void collectDescendants(Long currentId, List<Long> collector) { |
| | | QueryWrapper<EimsEquType> equTypeWrapper = new QueryWrapper<>(); |
| | | equTypeWrapper.lambda().eq(EimsEquType::getParentId, currentId); |
| | | |
| | | List<EimsEquTypeVo> children = equTypeMapper.selectVoList(equTypeWrapper); |
| | | if (children != null && !children.isEmpty()) { |
| | | for (EimsEquTypeVo child : children) { |
| | | Long childId = child.getEquTypeId(); |
| | | collector.add(childId); |
| | | collectDescendants(childId, collector); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增盘点明细 |
| | | * |
| | | * @param bo 盘点明细 |