BaseLocationZoneServiceImpl.java 3.9 KB

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