BaseLocationZoneServiceImpl.java 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. package com.ruoyi.base.service.impl;
  2. import java.util.ArrayList;
  3. import java.util.List;
  4. import java.util.stream.Collectors;
  5. import com.baomidou.mybatisplus.core.toolkit.Wrappers;
  6. import com.ruoyi.base.constant.Constant;
  7. import com.ruoyi.base.domain.BaseLocationInfo;
  8. import com.ruoyi.base.domain.vo.BasLocationTreeSelectVO;
  9. import com.ruoyi.base.domain.vo.TreeSelectVO;
  10. import com.ruoyi.common.utils.DateUtils;
  11. import org.springframework.beans.factory.annotation.Autowired;
  12. import org.springframework.stereotype.Service;
  13. import com.ruoyi.base.mapper.BaseLocationZoneMapper;
  14. import com.ruoyi.base.domain.BaseLocationZone;
  15. import com.ruoyi.base.service.IBaseLocationZoneService;
  16. /**
  17. * 库区Service业务层处理
  18. *
  19. * @author andy
  20. * @date 2022-02-15
  21. */
  22. @Service
  23. public class BaseLocationZoneServiceImpl implements IBaseLocationZoneService
  24. {
  25. @Autowired
  26. private BaseLocationZoneMapper baseLocationZoneMapper;
  27. /**
  28. * 查询库区
  29. *
  30. * @param zoneId 库区主键
  31. * @return 库区
  32. */
  33. @Override
  34. public BaseLocationZone selectBaseLocationZoneByZoneId(Long zoneId)
  35. {
  36. return baseLocationZoneMapper.selectBaseLocationZoneByZoneId(zoneId);
  37. }
  38. /**
  39. * 查询库区列表
  40. *
  41. * @param baseLocationZone 库区
  42. * @return 库区
  43. */
  44. @Override
  45. public List<BaseLocationZone> selectBaseLocationZoneList(BaseLocationZone baseLocationZone)
  46. {
  47. return baseLocationZoneMapper.selectBaseLocationZoneList(baseLocationZone);
  48. }
  49. @Override
  50. public List<BaseLocationZone> selectBaseLocationZoneList() {
  51. return baseLocationZoneMapper.selectList(Wrappers.<BaseLocationZone>lambdaQuery()
  52. .eq(BaseLocationZone::getStatus, Constant.ZoneStatus.ENABLE.getCode()));
  53. }
  54. /**
  55. * pda查询库区列表
  56. *
  57. * @param baseLocationZone 库区
  58. * @return 库区
  59. */
  60. @Override
  61. public List<BaseLocationZone> selectBaseLocationZoneList1(BaseLocationZone baseLocationZone)
  62. {
  63. return baseLocationZoneMapper.selectBaseLocationZoneList1(baseLocationZone);
  64. }
  65. /**
  66. * 新增库区
  67. *
  68. * @param baseLocationZone 库区
  69. * @return 结果
  70. */
  71. @Override
  72. public int insertBaseLocationZone(BaseLocationZone baseLocationZone)
  73. {
  74. baseLocationZone.setCreateTime(DateUtils.getNowDate());
  75. return baseLocationZoneMapper.insertBaseLocationZone(baseLocationZone);
  76. }
  77. /**
  78. * 修改库区
  79. *
  80. * @param baseLocationZone 库区
  81. * @return 结果
  82. */
  83. @Override
  84. public int updateBaseLocationZone(BaseLocationZone baseLocationZone)
  85. {
  86. baseLocationZone.setUpdateTime(DateUtils.getNowDate());
  87. return baseLocationZoneMapper.updateBaseLocationZone(baseLocationZone);
  88. }
  89. /**
  90. * 批量删除库区
  91. *
  92. * @param zoneIds 需要删除的库区主键
  93. * @return 结果
  94. */
  95. @Override
  96. public int deleteBaseLocationZoneByZoneIds(Long[] zoneIds)
  97. {
  98. return baseLocationZoneMapper.deleteBaseLocationZoneByZoneIds(zoneIds);
  99. }
  100. /**
  101. * 删除库区信息
  102. *
  103. * @param zoneId 库区主键
  104. * @return 结果
  105. */
  106. @Override
  107. public int deleteBaseLocationZoneByZoneId(Long zoneId)
  108. {
  109. return baseLocationZoneMapper.deleteBaseLocationZoneByZoneId(zoneId);
  110. }
  111. @Override
  112. public List<TreeSelectVO> buildLocationTreeSelect() {
  113. List<BasLocationTreeSelectVO> locationTrees = buildLocationTree(0L);
  114. return locationTrees.stream().map(TreeSelectVO::new).collect(Collectors.toList());
  115. }
  116. @Override
  117. public List<BasLocationTreeSelectVO> buildLocationTree(Long zoneId) {
  118. // 查询区域,库位树把区域也组装进去
  119. BaseLocationZone queryZone = new BaseLocationZone();
  120. queryZone.setStatus("0");
  121. List<BaseLocationZone> zoneList = baseLocationZoneMapper.selectBaseLocationZoneList(queryZone);
  122. List<BasLocationTreeSelectVO> locationTreeSelectVOList = new ArrayList<>();
  123. //循环遍历每个区域的库位
  124. for (BaseLocationZone zone : zoneList) {
  125. BasLocationTreeSelectVO parent = new BasLocationTreeSelectVO();
  126. List<BasLocationTreeSelectVO> children = new ArrayList<>();
  127. BaseLocationInfo query = new BaseLocationInfo();
  128. query.setZoneId(zone.getZoneId());
  129. parent.setId(zone.getZoneId());
  130. parent.setTreeName(zone.getZoneName());
  131. parent.setChildren(children);
  132. locationTreeSelectVOList.add(parent);
  133. }
  134. return locationTreeSelectVOList;
  135. }
  136. }