diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/controller/AllocCanteenController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/controller/AllocCanteenController.java index ff93ce67..d6e5936b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/controller/AllocCanteenController.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/controller/AllocCanteenController.java @@ -1,5 +1,6 @@ package com.bonus.canteen.core.allocation.canteen.controller; +import cn.hutool.core.lang.tree.Tree; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.bonus.canteen.core.allocation.canteen.business.AllocCanteenBusiness; import com.bonus.canteen.core.allocation.canteen.dto.AllocMobileCanteenQueryDTO; @@ -7,6 +8,7 @@ import com.bonus.canteen.core.allocation.canteen.dto.ModifyCanteenIfReserveDTO; import com.bonus.canteen.core.allocation.canteen.dto.ModifyCanteenStateDTO; import com.bonus.canteen.core.allocation.canteen.dto.ModifyStallIfReserveDTO; import com.bonus.canteen.core.allocation.canteen.model.*; +import com.bonus.canteen.core.allocation.canteen.param.AllocAreaParam; import com.bonus.canteen.core.allocation.canteen.param.AllocCanteenNumParam; import com.bonus.canteen.core.allocation.canteen.param.AllocCanteenStallPageParam; import com.bonus.canteen.core.allocation.canteen.param.AllocCanteenStallParam; @@ -76,6 +78,12 @@ public class AllocCanteenController { return AjaxResult.success(this.allocStallService.listReserveDate(bean)); } + @ApiOperation("集团版--权限区域食堂档口树") + @PostMapping({"/tenant-group-area/tree"}) + public List> getTenantGroupAreaTree(@RequestBody AllocAreaParam param) { + return this.allocCanteenService.getTenantGroupCanteenTree(param); + } + @ApiOperation("分页查询食堂列表") @PostMapping({"/page-canteen"}) public Page pageCanteen(@RequestBody AllocCanteenStallPageParam request) { diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocCanteenMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocCanteenMapper.java index 38b37cbf..8ac0e45b 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocCanteenMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocCanteenMapper.java @@ -71,5 +71,5 @@ public interface AllocCanteenMapper extends BaseMapper { ) List listAllAuthCanteen(@Param("canteenType") Integer canteenType, @Param("areaIdList") List areaIdList); - + List listCanteenIdByAreaIdList(@Param("areaIdList") List areaIdList); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocStallMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocStallMapper.java index 756c4ef7..824693b9 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocStallMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/mapper/AllocStallMapper.java @@ -106,4 +106,6 @@ public interface AllocStallMapper extends BaseMapper { List listAuthStall(@Param("canteenIdList") List canteenIdList); List listStallByCanteenId(@Param("canteenId") Long canteenId); + + List listStallIdByAreaIdList(@Param("areaIdList") List areaIdList); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/AllocCanteenService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/AllocCanteenService.java index 17e6e4c0..d38784a0 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/AllocCanteenService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/AllocCanteenService.java @@ -1,11 +1,13 @@ package com.bonus.canteen.core.allocation.canteen.service; +import cn.hutool.core.lang.tree.Tree; import com.baomidou.mybatisplus.extension.plugins.pagination.Page; import com.baomidou.mybatisplus.extension.service.IService; import com.bonus.canteen.core.allocation.canteen.dto.AllocCanteenModifyDTO; import com.bonus.canteen.core.allocation.canteen.dto.MarketCanteenSaveDTO; import com.bonus.canteen.core.allocation.canteen.dto.ModifyCanteenIfReserveDTO; import com.bonus.canteen.core.allocation.canteen.model.AllocCanteen; +import com.bonus.canteen.core.allocation.canteen.param.AllocAreaParam; import com.bonus.canteen.core.allocation.canteen.param.AllocCanteenStallPageParam; import com.bonus.canteen.core.allocation.canteen.param.AllocCanteenStallParam; import com.bonus.canteen.core.allocation.canteen.vo.AllocCanteenAuthVO; @@ -26,6 +28,8 @@ public interface AllocCanteenService extends IService { AllocCanteen getAllocCanteenCache(Long canteenId); + List> getTenantGroupCanteenTree(AllocAreaParam param); + Page pageCanteen(AllocCanteenStallPageParam param); void checkCanteenNameExist(String canteenName, Long canteenId); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java index 81dc9f33..8036a3ad 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/allocation/canteen/service/impl/AllocCanteenServiceImpl.java @@ -1,6 +1,9 @@ package com.bonus.canteen.core.allocation.canteen.service.impl; import cn.hutool.core.collection.CollUtil; +import cn.hutool.core.lang.tree.Tree; +import cn.hutool.core.lang.tree.TreeNodeConfig; +import cn.hutool.core.lang.tree.TreeUtil; import cn.hutool.core.text.CharSequenceUtil; import cn.hutool.core.util.ObjectUtil; import cn.hutool.json.JSONUtil; @@ -12,18 +15,22 @@ import com.bonus.canteen.core.allocation.api.AllocPayMetadataApi; import com.bonus.canteen.core.allocation.canteen.dto.AllocCanteenModifyDTO; import com.bonus.canteen.core.allocation.canteen.dto.MarketCanteenSaveDTO; import com.bonus.canteen.core.allocation.canteen.dto.ModifyCanteenIfReserveDTO; +import com.bonus.canteen.core.allocation.canteen.enums.AllocCanteenTreeTypeEnum; import com.bonus.canteen.core.allocation.canteen.mapper.AllocAreaMapper; import com.bonus.canteen.core.allocation.canteen.mapper.AllocCanteenMapper; import com.bonus.canteen.core.allocation.canteen.mapper.AllocStallMapper; import com.bonus.canteen.core.allocation.canteen.model.AllocCanteen; import com.bonus.canteen.core.allocation.canteen.model.AllocStall; +import com.bonus.canteen.core.allocation.canteen.param.AllocAreaParam; import com.bonus.canteen.core.allocation.canteen.param.AllocCanteenStallPageParam; import com.bonus.canteen.core.allocation.canteen.param.AllocCanteenStallParam; import com.bonus.canteen.core.allocation.canteen.service.AllocAreaService; import com.bonus.canteen.core.allocation.canteen.service.AllocCanteenService; import com.bonus.canteen.core.allocation.canteen.vo.AllocCanteenAuthVO; import com.bonus.canteen.core.allocation.canteen.vo.AllocCanteenStallVO; +import com.bonus.canteen.core.allocation.canteen.vo.AllocCanteenTreeVO; import com.bonus.canteen.core.allocation.canteen.vo.AllocCanteenVO; +import com.bonus.canteen.core.auth.api.MgrAuthApi; import com.bonus.canteen.core.common.constant.LeMqConstant; import com.bonus.canteen.core.common.enums.AllocBusinessStateEnum; import com.bonus.canteen.core.common.enums.AllocCanteenTypeEnum; @@ -35,6 +42,7 @@ import com.bonus.canteen.core.menu.vo.AppletReserveStallVO; import com.bonus.canteen.core.order.mq.MqUtil; import com.bonus.canteen.core.order.utils.LeNumUtil; import com.bonus.common.core.exception.ServiceException; +import com.bonus.common.houqin.constant.DelFlagEnum; import com.bonus.common.houqin.constant.LeConstants; import com.bonus.common.houqin.i18n.I18n; import com.bonus.common.houqin.utils.LeBeanUtil; @@ -55,6 +63,9 @@ public class AllocCanteenServiceImpl extends ServiceImpl> getTenantGroupCanteenTree(AllocAreaParam param) { + List systemCanteenList = this.mgrAuthApi.getTenantCanteen(LeConstants.COMMON_NO, DelFlagEnum.DEL_FALSE.key(), true); + if (CollUtil.isNotEmpty(param.getDataSelectList())) { + this.integrationGroupArea(param, systemCanteenList); + } + + TreeNodeConfig treeNodeConfig = new TreeNodeConfig(); + treeNodeConfig.setNameKey("treeName"); + treeNodeConfig.setWeightKey("treeType"); + return TreeUtil.build(systemCanteenList, LeConstants.DATA_DEFAULT_LONG, treeNodeConfig, (canteen, treeNode) -> { + treeNode.setId(canteen.getId()); + treeNode.setName(canteen.getTreeName()); + treeNode.setParentId(canteen.getParentId()); + treeNode.putExtra("treeType", canteen.getTreeType()); + treeNode.putExtra("halfSelect", canteen.getHalfSelect()); + }); + } + + private void integrationGroupArea(AllocAreaParam param, List systemCanteenList) { + List queryAreaIdList = new ArrayList(); + List viewAreaIdList = new ArrayList(); + + AllocAreaParam.DataSelectDTO dataSelectDTO; + for(Iterator var5 = param.getDataSelectList().iterator(); var5.hasNext(); viewAreaIdList.add(dataSelectDTO.getDataId())) { + dataSelectDTO = (AllocAreaParam.DataSelectDTO)var5.next(); + if (LeConstants.COMMON_YES.equals(dataSelectDTO.getHalfSelect())) { + queryAreaIdList.add(dataSelectDTO.getDataId()); + } + } + + List canteenIdList = ((AllocCanteenMapper)this.baseMapper).listCanteenIdByAreaIdList(queryAreaIdList); + List stallIdList = this.allocStallMapper.listStallIdByAreaIdList(queryAreaIdList); + Iterator it = systemCanteenList.iterator(); + + while(true) { + while(it.hasNext()) { + AllocCanteenTreeVO treeVO = (AllocCanteenTreeVO)it.next(); + if (AllocCanteenTreeTypeEnum.AREA.getKey().equals(treeVO.getTreeType()) && !viewAreaIdList.contains(treeVO.getId())) { + it.remove(); + } else { + this.filterCanteen(canteenIdList, stallIdList, it, treeVO); + } + } + + return; + } + } + + private void filterCanteen(List canteenIdList, List stallIdList, Iterator it, AllocCanteenTreeVO treeVO) { + if (AllocCanteenTreeTypeEnum.CANTEEN.getKey().equals(treeVO.getTreeType()) && (!CollUtil.isNotEmpty(canteenIdList) || !canteenIdList.contains(treeVO.getId()))) { + it.remove(); + } else { + if (AllocCanteenTreeTypeEnum.STALL.getKey().equals(treeVO.getTreeType()) && (!CollUtil.isNotEmpty(stallIdList) || !stallIdList.contains(treeVO.getId()))) { + it.remove(); + } + + } + } + public Page pageCanteen(AllocCanteenStallPageParam param) { param.setCanteenName(LeBeanUtil.fieldLikeHandle(param.getCanteenName())); param.setIfDel(LeConstants.COMMON_NO); diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocCanteenMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocCanteenMapper.xml index 5be06587..ba42f391 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocCanteenMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocCanteenMapper.xml @@ -109,4 +109,20 @@ + + + diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocStallMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocStallMapper.xml index e7fadd8b..722722fa 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocStallMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/alloc/canteen/AllocStallMapper.xml @@ -244,4 +244,20 @@ FROM alloc_stall WHERE canteen_id = #{canteenId} + + +