123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
- package com.ruoyi.base.service.impl;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.stream.Collectors;
- import com.baomidou.mybatisplus.core.toolkit.Wrappers;
- import com.ruoyi.base.constant.Constant;
- import com.ruoyi.base.domain.BaseLocationInfo;
- import com.ruoyi.base.domain.vo.BasLocationTreeSelectVO;
- import com.ruoyi.base.domain.vo.TreeSelectVO;
- import com.ruoyi.common.utils.DateUtils;
- import org.springframework.beans.factory.annotation.Autowired;
- import org.springframework.stereotype.Service;
- import com.ruoyi.base.mapper.BaseLocationZoneMapper;
- import com.ruoyi.base.domain.BaseLocationZone;
- import com.ruoyi.base.service.IBaseLocationZoneService;
- /**
- * 库区Service业务层处理
- *
- * @author andy
- * @date 2022-02-15
- */
- @Service
- public class BaseLocationZoneServiceImpl implements IBaseLocationZoneService
- {
- @Autowired
- private BaseLocationZoneMapper baseLocationZoneMapper;
- /**
- * 查询库区
- *
- * @param zoneId 库区主键
- * @return 库区
- */
- @Override
- public BaseLocationZone selectBaseLocationZoneByZoneId(Long zoneId)
- {
- return baseLocationZoneMapper.selectBaseLocationZoneByZoneId(zoneId);
- }
- /**
- * 查询库区列表
- *
- * @param baseLocationZone 库区
- * @return 库区
- */
- @Override
- public List<BaseLocationZone> selectBaseLocationZoneList(BaseLocationZone baseLocationZone)
- {
- return baseLocationZoneMapper.selectBaseLocationZoneList(baseLocationZone);
- }
- @Override
- public List<BaseLocationZone> selectBaseLocationZoneList() {
- return baseLocationZoneMapper.selectList(Wrappers.<BaseLocationZone>lambdaQuery()
- .eq(BaseLocationZone::getStatus, Constant.ZoneStatus.ENABLE.getCode()));
- }
- /**
- * pda查询库区列表
- *
- * @param baseLocationZone 库区
- * @return 库区
- */
- @Override
- public List<BaseLocationZone> selectBaseLocationZoneList1(BaseLocationZone baseLocationZone)
- {
- return baseLocationZoneMapper.selectBaseLocationZoneList1(baseLocationZone);
- }
- /**
- * 新增库区
- *
- * @param baseLocationZone 库区
- * @return 结果
- */
- @Override
- public int insertBaseLocationZone(BaseLocationZone baseLocationZone)
- {
- baseLocationZone.setCreateTime(DateUtils.getNowDate());
- return baseLocationZoneMapper.insertBaseLocationZone(baseLocationZone);
- }
- /**
- * 修改库区
- *
- * @param baseLocationZone 库区
- * @return 结果
- */
- @Override
- public int updateBaseLocationZone(BaseLocationZone baseLocationZone)
- {
- baseLocationZone.setUpdateTime(DateUtils.getNowDate());
- return baseLocationZoneMapper.updateBaseLocationZone(baseLocationZone);
- }
- /**
- * 批量删除库区
- *
- * @param zoneIds 需要删除的库区主键
- * @return 结果
- */
- @Override
- public int deleteBaseLocationZoneByZoneIds(Long[] zoneIds)
- {
- return baseLocationZoneMapper.deleteBaseLocationZoneByZoneIds(zoneIds);
- }
- /**
- * 删除库区信息
- *
- * @param zoneId 库区主键
- * @return 结果
- */
- @Override
- public int deleteBaseLocationZoneByZoneId(Long zoneId)
- {
- return baseLocationZoneMapper.deleteBaseLocationZoneByZoneId(zoneId);
- }
- @Override
- public List<TreeSelectVO> buildLocationTreeSelect() {
- List<BasLocationTreeSelectVO> locationTrees = buildLocationTree(0L);
- return locationTrees.stream().map(TreeSelectVO::new).collect(Collectors.toList());
- }
- @Override
- public List<BasLocationTreeSelectVO> buildLocationTree(Long zoneId) {
- // 查询区域,库位树把区域也组装进去
- BaseLocationZone queryZone = new BaseLocationZone();
- queryZone.setStatus("0");
- List<BaseLocationZone> zoneList = baseLocationZoneMapper.selectBaseLocationZoneList(queryZone);
- List<BasLocationTreeSelectVO> locationTreeSelectVOList = new ArrayList<>();
- //循环遍历每个区域的库位
- for (BaseLocationZone zone : zoneList) {
- BasLocationTreeSelectVO parent = new BasLocationTreeSelectVO();
- List<BasLocationTreeSelectVO> children = new ArrayList<>();
- BaseLocationInfo query = new BaseLocationInfo();
- query.setZoneId(zone.getZoneId());
- parent.setId(zone.getZoneId());
- parent.setTreeName(zone.getZoneName());
- parent.setChildren(children);
- locationTreeSelectVOList.add(parent);
- }
- return locationTreeSelectVOList;
- }
- }
|