后台-类型排序
This commit is contained in:
parent
bdf5485a89
commit
e3cbbe4a16
|
|
@ -0,0 +1,79 @@
|
|||
package com.bonus.canteen.core.device.api;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bonus.canteen.core.device.manage.service.DeviceInfoService;
|
||||
import com.bonus.canteen.core.device.manage.service.DeviceMetadataService;
|
||||
import com.bonus.common.houqin.constant.LeConstants;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Lazy;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class DeviceV2Api {
|
||||
private static final Logger log = LoggerFactory.getLogger(DeviceV2Api.class);
|
||||
@Resource
|
||||
@Lazy
|
||||
private DeviceInfoService deviceInfoService;
|
||||
@Resource
|
||||
@Lazy
|
||||
private DeviceMetadataService deviceMetadataService;
|
||||
|
||||
// public void insert(DeviceDTO dto) {
|
||||
// this.deviceInfoService.insert(dto);
|
||||
// }
|
||||
//
|
||||
// public void update(DeviceDTO dto) {
|
||||
// this.deviceInfoService.update(dto);
|
||||
// }
|
||||
//
|
||||
// public void delete(Long deviceId) {
|
||||
// this.deviceInfoService.delete(deviceId);
|
||||
// }
|
||||
//
|
||||
// public DeviceInfoVO getDeviceInfoVoByNum(String deviceNum) {
|
||||
// return this.deviceInfoService.getDeviceInfoVoByNum(deviceNum);
|
||||
// }
|
||||
//
|
||||
// public List<DeviceInfoVO> getDeviceInfoVoByNumList(List<String> deviceNumList) {
|
||||
// return this.deviceInfoService.getDeviceInfoVoByNumList(deviceNumList);
|
||||
// }
|
||||
//
|
||||
// public DeviceInfoVO getDeviceInfoVoById(Long deviceId) {
|
||||
// return this.deviceInfoService.getDeviceInfoVoById(deviceId);
|
||||
// }
|
||||
//
|
||||
// public List<DeviceInfoVO> getPrintDeviceInfoVoByCanteenandStallId(String canteenId, String stallId) {
|
||||
// List<DeviceInfoVO> deviceInfoVOList = this.deviceInfoService.listDeviceInfoVoByType(SourceTypeEnum.PRINTER.getKey());
|
||||
// List<DeviceInfoVO> deviceInfoVOS = (List)deviceInfoVOList.stream().filter((s) -> {
|
||||
// return ObjectUtil.isNotEmpty(s.getDeviceMetadata()) && ObjectUtil.equals(s.getDeviceMetadata().get("canteenId"), canteenId) && ObjectUtil.contains(s.getDeviceMetadata().get("stallId"), stallId) && ObjectUtil.equals(LeConstants.COMMON_YES, s.getIfEnable());
|
||||
// }).collect(Collectors.toList());
|
||||
// return ObjectUtil.isNotEmpty(deviceInfoVOS) ? deviceInfoVOS : (List)deviceInfoVOList.stream().filter((s) -> {
|
||||
// return ObjectUtil.isNotEmpty(s.getDeviceMetadata()) && ObjectUtil.equals(s.getDeviceMetadata().get("canteenId"), canteenId) && ObjectUtil.isEmpty(s.getDeviceMetadata().get("stallId")) && ObjectUtil.equals(LeConstants.COMMON_YES, s.getIfEnable());
|
||||
// }).collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// public List<DeviceInfoVO> getPrintDeviceInfoVoBysupermarketIdId(String supermarketId) {
|
||||
// List<DeviceInfoVO> deviceInfoVOList = this.deviceInfoService.listDeviceInfoVoByType(SourceTypeEnum.PRINTER.getKey());
|
||||
// return (List)deviceInfoVOList.stream().filter((s) -> {
|
||||
// return ObjectUtil.isNotEmpty(s.getDeviceMetadata()) && ObjectUtil.equals(s.getDeviceMetadata().get("supermarketId"), supermarketId) && ObjectUtil.equals(LeConstants.COMMON_YES, s.getIfEnable());
|
||||
// }).collect(Collectors.toList());
|
||||
// }
|
||||
//
|
||||
// public List<DeviceInfoVO> getPrintDeviceInfoVoByFlag(String flag) {
|
||||
// List<DeviceInfoVO> deviceInfoVOList = this.deviceInfoService.listDeviceInfoVoByType(SourceTypeEnum.PRINTER.getKey());
|
||||
// return (List)deviceInfoVOList.stream().filter((s) -> {
|
||||
// return ObjectUtil.isNotEmpty(s.getDeviceMetadata()) && ObjectUtil.equals(s.getDeviceMetadata().get(flag), String.valueOf(LeConstants.COMMON_YES)) && ObjectUtil.equals(LeConstants.COMMON_YES, s.getIfEnable());
|
||||
// }).collect(Collectors.toList());
|
||||
// }
|
||||
|
||||
public Map<Integer, Integer> getDeviceTypeCountMap() {
|
||||
return this.deviceInfoService.getDeviceTypeCountMap();
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,22 @@
|
|||
package com.bonus.canteen.core.device.manage.dto;
|
||||
|
||||
public class DeviceTypeDto {
|
||||
private Integer deviceType;
|
||||
private Integer deviceCount;
|
||||
|
||||
public Integer getDeviceType() {
|
||||
return this.deviceType;
|
||||
}
|
||||
|
||||
public Integer getDeviceCount() {
|
||||
return this.deviceCount;
|
||||
}
|
||||
|
||||
public void setDeviceType(final Integer deviceType) {
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public void setDeviceCount(final Integer deviceCount) {
|
||||
this.deviceCount = deviceCount;
|
||||
}
|
||||
}
|
||||
|
|
@ -2,6 +2,7 @@ package com.bonus.canteen.core.device.manage.mapper;
|
|||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.device.manage.dto.DeviceSearchDTO;
|
||||
import com.bonus.canteen.core.device.manage.dto.DeviceTypeDto;
|
||||
import com.bonus.canteen.core.device.manage.model.DeviceInfo;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
import org.apache.ibatis.annotations.Param;
|
||||
|
|
@ -22,7 +23,7 @@ public interface DeviceInfoMapper extends BaseMapper<DeviceInfo> {
|
|||
//
|
||||
// List<MarketDeviceTreeVO> listTenantDevice(@Param("deviceTypes") List<Integer> deviceTypes, @Param("canteenIds") List<Long> canteenIds, @Param("stallIds") List<Long> stallIds);
|
||||
//
|
||||
// List<DeviceTypeDto> getDeviceTypeCountMap();
|
||||
List<DeviceTypeDto> getDeviceTypeCountMap();
|
||||
//
|
||||
// List<String> listLocaltionDevices(@Param("param") DeviceSearchDTO param);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil;
|
|||
import com.baomidou.mybatisplus.core.conditions.Wrapper;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.bonus.canteen.core.device.manage.dto.DeviceSearchDTO;
|
||||
import com.bonus.canteen.core.device.manage.dto.DeviceTypeDto;
|
||||
import com.bonus.canteen.core.device.manage.mapper.DeviceInfoMapper;
|
||||
import com.bonus.canteen.core.device.manage.model.DeviceInfo;
|
||||
import com.bonus.canteen.core.device.manage.vo.*;
|
||||
|
|
@ -936,10 +937,11 @@ public class DeviceInfoService {
|
|||
// }
|
||||
// }
|
||||
//
|
||||
// public Map<Integer, Integer> getDeviceTypeCountMap() {
|
||||
// List<DeviceTypeDto> deviceTypeDtos = this.deviceInfoMapper.getDeviceTypeCountMap();
|
||||
// return (Map)deviceTypeDtos.stream().collect(Collectors.toMap(DeviceTypeDto::getDeviceType, DeviceTypeDto::getDeviceCount));
|
||||
// }
|
||||
public Map<Integer, Integer> getDeviceTypeCountMap() {
|
||||
List<DeviceTypeDto> deviceTypeDtos = this.deviceInfoMapper.getDeviceTypeCountMap();
|
||||
return deviceTypeDtos.stream()
|
||||
.collect(Collectors.toMap(DeviceTypeDto::getDeviceType, DeviceTypeDto::getDeviceCount));
|
||||
}
|
||||
//
|
||||
// public List<String> listLocaltionDevices(DeviceSearchDTO deviceSearchDTO) {
|
||||
// return this.deviceInfoMapper.listLocaltionDevices(deviceSearchDTO);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,66 @@
|
|||
package com.bonus.canteen.core.menu.constant;
|
||||
|
||||
public enum MenuBindTypeEnum {
|
||||
CURRENT(1, "当餐点餐"),
|
||||
RESERVE(2, "预订餐"),
|
||||
WEEK(3, "一周菜谱"),
|
||||
QR_CODE(4, "扫码点餐"),
|
||||
SELF_MACHINE(5, "自助终端"),
|
||||
MEAL_LINE(6, "自助餐线/小碗菜餐线"),
|
||||
TABLE(7, "智慧餐台/消费机"),
|
||||
PAD(8, "点餐机/手持机/平板"),
|
||||
SCREEN(9, "信息发布屏"),
|
||||
DISHES_IDENTIFY(10, "菜品识别"),
|
||||
NUTRITIONAL_PRICE_TAG(11, "营养价签");
|
||||
|
||||
private final Integer key;
|
||||
private final String value;
|
||||
|
||||
private MenuBindTypeEnum(Integer key, String value) {
|
||||
this.key = key;
|
||||
this.value = value;
|
||||
}
|
||||
|
||||
public static Integer getKey(String value) {
|
||||
MenuBindTypeEnum[] enums = values();
|
||||
MenuBindTypeEnum[] var2 = enums;
|
||||
int var3 = enums.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
MenuBindTypeEnum temp = var2[var4];
|
||||
if (temp.value().equals(value)) {
|
||||
return temp.key();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static String getValue(Integer key) {
|
||||
MenuBindTypeEnum[] enums = values();
|
||||
MenuBindTypeEnum[] var2 = enums;
|
||||
int var3 = enums.length;
|
||||
|
||||
for(int var4 = 0; var4 < var3; ++var4) {
|
||||
MenuBindTypeEnum temp = var2[var4];
|
||||
if (temp.key().equals(key)) {
|
||||
return temp.value();
|
||||
}
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public Integer key() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String value() {
|
||||
return this.value;
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
private static MenuBindTypeEnum[] $values() {
|
||||
return new MenuBindTypeEnum[]{CURRENT, RESERVE, WEEK, QR_CODE, SELF_MACHINE, MEAL_LINE, TABLE, PAD, SCREEN, DISHES_IDENTIFY, NUTRITIONAL_PRICE_TAG};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,67 @@
|
|||
package com.bonus.canteen.core.menu.constant;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public enum MenuRecipeSortEnum {
|
||||
MEALLINE(1, "自助餐线/小碗菜餐线", MenuBindTypeEnum.MEAL_LINE.key(), Arrays.asList(35, 32, 44, 30, 55, 58)),
|
||||
TABLE(2, "智慧餐台/消费机", MenuBindTypeEnum.TABLE.key(), Arrays.asList(20, 23, 41, 47, 21, 34)),
|
||||
BUFFET(3, "点餐机/手持机/平板", MenuBindTypeEnum.PAD.key(), Arrays.asList(41, 22, 36, 46, 63)),
|
||||
ISSUE(4, "信息发布屏", MenuBindTypeEnum.SCREEN.key(), Arrays.asList(40, 45)),
|
||||
ANDROID_SELF_RECHARGE(5, "自助终端菜谱公示", MenuBindTypeEnum.SELF_MACHINE.key(), Collections.singletonList(25)),
|
||||
MOBILE_CURRENT(6, "移动端当餐点餐", MenuBindTypeEnum.CURRENT.key(), new ArrayList()),
|
||||
MOBILE_RESERVE(7, "移动端预订餐", MenuBindTypeEnum.RESERVE.key(), new ArrayList()),
|
||||
MOBILE_WEEK(8, "移动端一周菜谱", MenuBindTypeEnum.WEEK.key(), new ArrayList()),
|
||||
DISHES_IDENTIFY(9, "菜品识别", MenuBindTypeEnum.DISHES_IDENTIFY.key(), Arrays.asList(50, 51)),
|
||||
NUTRITIONAL_PRICE_TAG(10, "营养价签", MenuBindTypeEnum.NUTRITIONAL_PRICE_TAG.key(), Collections.singletonList(57));
|
||||
|
||||
private final Integer key;
|
||||
private final String name;
|
||||
private final Integer bindType;
|
||||
private final List<Integer> deviceType;
|
||||
|
||||
private MenuRecipeSortEnum(Integer key, String name, Integer bindType, List deviceType) {
|
||||
this.key = key;
|
||||
this.name = name;
|
||||
this.bindType = bindType;
|
||||
this.deviceType = deviceType;
|
||||
}
|
||||
|
||||
public static Map<Integer, MenuRecipeSortEnum> getKeyMap() {
|
||||
return (Map)Arrays.stream(values()).collect(Collectors.toMap(MenuRecipeSortEnum::getKey, Function.identity()));
|
||||
}
|
||||
|
||||
public static Map<Integer, MenuRecipeSortEnum> getBindTypeMap() {
|
||||
return (Map)Arrays.stream(values()).collect(Collectors.toMap(MenuRecipeSortEnum::getBindType, Function.identity()));
|
||||
}
|
||||
|
||||
public static MenuRecipeSortEnum getByKey(Integer key) {
|
||||
return (MenuRecipeSortEnum)getKeyMap().get(key);
|
||||
}
|
||||
|
||||
public Integer getKey() {
|
||||
return this.key;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Integer getBindType() {
|
||||
return this.bindType;
|
||||
}
|
||||
|
||||
public List<Integer> getDeviceType() {
|
||||
return this.deviceType;
|
||||
}
|
||||
|
||||
public static List<Integer> getDeviceBindTypes() {
|
||||
return Arrays.asList(MEALLINE.getBindType(), TABLE.getBindType(), BUFFET.getBindType(), ISSUE.getBindType(), ANDROID_SELF_RECHARGE.getBindType(), NUTRITIONAL_PRICE_TAG.getBindType());
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
private static MenuRecipeSortEnum[] $values() {
|
||||
return new MenuRecipeSortEnum[]{MEALLINE, TABLE, BUFFET, ISSUE, ANDROID_SELF_RECHARGE, MOBILE_CURRENT, MOBILE_RESERVE, MOBILE_WEEK, DISHES_IDENTIFY, NUTRITIONAL_PRICE_TAG};
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,32 @@
|
|||
package com.bonus.canteen.core.menu.controller;
|
||||
|
||||
import com.bonus.canteen.core.menu.dto.MenuRecipeSortVo;
|
||||
import com.bonus.canteen.core.menu.service.MenuRecipeBindSortService;
|
||||
import com.bonus.common.core.web.domain.AjaxResult;
|
||||
import io.swagger.annotations.ApiOperation;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@RequestMapping({"/menu/type/sort"})
|
||||
public class MenuRecipeBindSortController {
|
||||
@Resource
|
||||
private MenuRecipeBindSortService menuRecipeBindSortService;
|
||||
|
||||
@PostMapping({"/query"})
|
||||
@ApiOperation("获取类型排序功能")
|
||||
public AjaxResult querySort() {
|
||||
return AjaxResult.success(this.menuRecipeBindSortService.querySort());
|
||||
}
|
||||
|
||||
@PostMapping({"/save"})
|
||||
@ApiOperation("保存类型排序功能")
|
||||
public AjaxResult saveSort(@RequestBody List<MenuRecipeSortVo> dto) {
|
||||
return AjaxResult.success(this.menuRecipeBindSortService.saveSort(dto));
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,74 @@
|
|||
package com.bonus.canteen.core.menu.dto;
|
||||
|
||||
|
||||
import com.bonus.canteen.core.menu.constant.MenuRecipeSortEnum;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class MenuRecipeSortVo {
|
||||
private Integer id;
|
||||
private String name;
|
||||
private Integer bindType;
|
||||
private Integer sortNum;
|
||||
private Integer hidden = 1;
|
||||
private List<Integer> deviceTypes;
|
||||
|
||||
public MenuRecipeSortVo() {
|
||||
}
|
||||
|
||||
public MenuRecipeSortVo(MenuRecipeSortEnum menuRecipeSortEnum) {
|
||||
this.id = menuRecipeSortEnum.getKey();
|
||||
this.name = menuRecipeSortEnum.getName();
|
||||
this.bindType = menuRecipeSortEnum.getBindType();
|
||||
this.deviceTypes = menuRecipeSortEnum.getDeviceType();
|
||||
}
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public String getName() {
|
||||
return this.name;
|
||||
}
|
||||
|
||||
public Integer getBindType() {
|
||||
return this.bindType;
|
||||
}
|
||||
|
||||
public Integer getSortNum() {
|
||||
return this.sortNum;
|
||||
}
|
||||
|
||||
public Integer getHidden() {
|
||||
return this.hidden;
|
||||
}
|
||||
|
||||
public List<Integer> getDeviceTypes() {
|
||||
return this.deviceTypes;
|
||||
}
|
||||
|
||||
public void setId(final Integer id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public void setName(final String name) {
|
||||
this.name = name;
|
||||
}
|
||||
|
||||
public void setBindType(final Integer bindType) {
|
||||
this.bindType = bindType;
|
||||
}
|
||||
|
||||
public void setSortNum(final Integer sortNum) {
|
||||
this.sortNum = sortNum;
|
||||
}
|
||||
|
||||
public void setHidden(final Integer hidden) {
|
||||
this.hidden = hidden;
|
||||
}
|
||||
|
||||
public void setDeviceTypes(final List<Integer> deviceTypes) {
|
||||
this.deviceTypes = deviceTypes;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,48 @@
|
|||
package com.bonus.canteen.core.menu.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import com.baomidou.mybatisplus.extension.activerecord.Model;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
|
||||
@TableName("menu_app_recipe")
|
||||
public class MenuAppRecipe extends Model<MenuAppRecipe> {
|
||||
private static final long serialVersionUID = 1L;
|
||||
private Long recipeId;
|
||||
private Integer bindType;
|
||||
private Long mealLineId;
|
||||
private LocalDateTime bindTime;
|
||||
|
||||
public Long getRecipeId() {
|
||||
return this.recipeId;
|
||||
}
|
||||
|
||||
public Integer getBindType() {
|
||||
return this.bindType;
|
||||
}
|
||||
|
||||
public Long getMealLineId() {
|
||||
return this.mealLineId;
|
||||
}
|
||||
|
||||
public LocalDateTime getBindTime() {
|
||||
return this.bindTime;
|
||||
}
|
||||
|
||||
public void setRecipeId(final Long recipeId) {
|
||||
this.recipeId = recipeId;
|
||||
}
|
||||
|
||||
public void setBindType(final Integer bindType) {
|
||||
this.bindType = bindType;
|
||||
}
|
||||
|
||||
public void setMealLineId(final Long mealLineId) {
|
||||
this.mealLineId = mealLineId;
|
||||
}
|
||||
|
||||
public void setBindTime(final LocalDateTime bindTime) {
|
||||
this.bindTime = bindTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
package com.bonus.canteen.core.menu.entity;
|
||||
|
||||
import com.baomidou.mybatisplus.annotation.IdType;
|
||||
import com.baomidou.mybatisplus.annotation.TableId;
|
||||
import com.baomidou.mybatisplus.annotation.TableName;
|
||||
import io.swagger.annotations.ApiModel;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
@TableName("menu_recipe_bind_sort")
|
||||
@ApiModel(
|
||||
value = "MenuRecipeBindSort对象",
|
||||
description = ""
|
||||
)
|
||||
public class MenuRecipeBindSort implements Serializable {
|
||||
private static final long serialVersionUID = 1L;
|
||||
@TableId(
|
||||
value = "id",
|
||||
type = IdType.AUTO
|
||||
)
|
||||
private Integer id;
|
||||
private Integer sortNum;
|
||||
|
||||
public Integer getId() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
public Integer getSortNum() {
|
||||
return this.sortNum;
|
||||
}
|
||||
|
||||
public MenuRecipeBindSort setId(final Integer id) {
|
||||
this.id = id;
|
||||
return this;
|
||||
}
|
||||
|
||||
public MenuRecipeBindSort setSortNum(final Integer sortNum) {
|
||||
this.sortNum = sortNum;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,7 @@
|
|||
package com.bonus.canteen.core.menu.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.menu.entity.MenuAppRecipe;
|
||||
import com.bonus.canteen.core.menu.vo.AppletReserveCanteenVO;
|
||||
import com.bonus.canteen.core.menu.vo.AppletWeekCanteenVO;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
|
@ -8,7 +10,7 @@ import java.util.List;
|
|||
import java.util.Set;
|
||||
|
||||
@Mapper
|
||||
public interface MenuAppRecipeMapper {
|
||||
public interface MenuAppRecipeMapper extends BaseMapper<MenuAppRecipe> {
|
||||
List<AppletWeekCanteenVO> selectWeekCanteenList(@Param("effIdSet") Set<Long> effIdSet);
|
||||
|
||||
List<Long> selectWeekRecipeId(@Param("recipeId") Long recipeId, @Param("effIdSet") Set<Long> effIdSet);
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
package com.bonus.canteen.core.menu.mapper;
|
||||
|
||||
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
|
||||
import com.bonus.canteen.core.menu.entity.MenuRecipeBindSort;
|
||||
import org.apache.ibatis.annotations.Mapper;
|
||||
|
||||
@Mapper
|
||||
public interface MenuRecpieBindSortMapper extends BaseMapper<MenuRecipeBindSort> {
|
||||
}
|
||||
|
|
@ -0,0 +1,16 @@
|
|||
package com.bonus.canteen.core.menu.service;
|
||||
|
||||
|
||||
import com.baomidou.mybatisplus.extension.service.IService;
|
||||
import com.bonus.canteen.core.menu.dto.MenuRecipeSortVo;
|
||||
import com.bonus.canteen.core.menu.entity.MenuRecipeBindSort;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public interface MenuRecipeBindSortService extends IService<MenuRecipeBindSort> {
|
||||
List<MenuRecipeSortVo> querySort();
|
||||
|
||||
Boolean saveSort(List<MenuRecipeSortVo> content);
|
||||
|
||||
void deleteByDevice(Integer deviceType);
|
||||
}
|
||||
|
|
@ -0,0 +1,114 @@
|
|||
package com.bonus.canteen.core.menu.service.impl;
|
||||
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
||||
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
||||
import com.bonus.canteen.core.device.api.DeviceV2Api;
|
||||
import com.bonus.canteen.core.menu.constant.MenuRecipeSortEnum;
|
||||
import com.bonus.canteen.core.menu.dto.MenuRecipeSortVo;
|
||||
import com.bonus.canteen.core.menu.entity.MenuAppRecipe;
|
||||
import com.bonus.canteen.core.menu.entity.MenuRecipeBindSort;
|
||||
import com.bonus.canteen.core.menu.mapper.MenuAppRecipeMapper;
|
||||
import com.bonus.canteen.core.menu.mapper.MenuRecpieBindSortMapper;
|
||||
import com.bonus.canteen.core.menu.service.MenuRecipeBindSortService;
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import javax.annotation.Resource;
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Service
|
||||
public class MenuRecipeBindSortServiceImpl extends ServiceImpl<MenuRecpieBindSortMapper, MenuRecipeBindSort> implements MenuRecipeBindSortService {
|
||||
@Resource
|
||||
private DeviceV2Api deviceV2Api;
|
||||
@Resource
|
||||
private MenuAppRecipeMapper menuAppRecipeMapper;
|
||||
|
||||
@Override
|
||||
public List<MenuRecipeSortVo> querySort() {
|
||||
Map<Integer, MenuRecipeSortEnum> bindTypeMap = MenuRecipeSortEnum.getKeyMap();
|
||||
List<MenuRecipeBindSort> list = this.list();
|
||||
List<MenuRecipeSortVo> res;
|
||||
if (ObjectUtil.isNotEmpty(list)) {
|
||||
res = list.stream().map((item) -> {
|
||||
MenuRecipeSortEnum menuRecipeSortEnum = bindTypeMap.get(item.getId());
|
||||
MenuRecipeSortVo menuRecipeSortVo = new MenuRecipeSortVo(menuRecipeSortEnum);
|
||||
menuRecipeSortVo.setSortNum(item.getSortNum());
|
||||
return menuRecipeSortVo;
|
||||
}).collect(Collectors.toList());
|
||||
Set<Integer> keys = bindTypeMap.keySet();
|
||||
List<Integer> haveKeys = list.stream().map(MenuRecipeBindSort::getId).collect(Collectors.toList());
|
||||
Objects.requireNonNull(keys);
|
||||
haveKeys.forEach(keys::remove);
|
||||
Iterator var6 = keys.iterator();
|
||||
|
||||
while(var6.hasNext()) {
|
||||
Integer key = (Integer)var6.next();
|
||||
MenuRecipeSortEnum menuRecipeSortEnum = bindTypeMap.get(key);
|
||||
MenuRecipeSortVo menuRecipeSortVo = new MenuRecipeSortVo(menuRecipeSortEnum);
|
||||
menuRecipeSortVo.setSortNum(key);
|
||||
res.add(menuRecipeSortVo);
|
||||
}
|
||||
} else {
|
||||
res = bindTypeMap.values().stream().map((item) -> {
|
||||
MenuRecipeSortVo menuRecipeSortVo = new MenuRecipeSortVo(item);
|
||||
menuRecipeSortVo.setSortNum(item.getKey());
|
||||
return menuRecipeSortVo;
|
||||
}).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
Map<Integer, Integer> countMap = this.deviceV2Api.getDeviceTypeCountMap();
|
||||
return res.stream().peek((item) -> {
|
||||
if (ObjectUtil.isEmpty(item.getDeviceTypes())) {
|
||||
item.setHidden(0);
|
||||
} else {
|
||||
Iterator var2 = item.getDeviceTypes().iterator();
|
||||
|
||||
while(var2.hasNext()) {
|
||||
Integer deviceType = (Integer)var2.next();
|
||||
Integer count = countMap.get(deviceType);
|
||||
if (count != null && count > 0) {
|
||||
item.setHidden(0);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}).sorted(Comparator.comparing(MenuRecipeSortVo::getSortNum)).collect(Collectors.toList());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean saveSort(List<MenuRecipeSortVo> content) {
|
||||
this.remove(Wrappers.lambdaQuery());
|
||||
List<MenuRecipeBindSort> menuRecipeBindSorts = BeanUtil.copyToList(content, MenuRecipeBindSort.class);
|
||||
super.saveBatch(menuRecipeBindSorts);
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void deleteByDevice(Integer deviceType) {
|
||||
Map<Integer, Integer> countMap = this.deviceV2Api.getDeviceTypeCountMap();
|
||||
Arrays.stream(MenuRecipeSortEnum.values()).filter((item) -> {
|
||||
return item.getDeviceType().contains(deviceType);
|
||||
}).findFirst().ifPresent((item) -> {
|
||||
List<Integer> deviceTypes = item.getDeviceType();
|
||||
Boolean removeFlage = true;
|
||||
Iterator var5 = deviceTypes.iterator();
|
||||
|
||||
while(var5.hasNext()) {
|
||||
Integer type = (Integer)var5.next();
|
||||
Integer count = (Integer)countMap.get(type);
|
||||
if (count != null && count > 0) {
|
||||
removeFlage = false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (removeFlage) {
|
||||
this.menuAppRecipeMapper.delete(Wrappers.lambdaQuery(MenuAppRecipe.class).eq(MenuAppRecipe::getBindType, item.getBindType()));
|
||||
}
|
||||
|
||||
});
|
||||
}
|
||||
}
|
||||
|
|
@ -521,9 +521,9 @@
|
|||
<!-- )-->
|
||||
<!-- </select>-->
|
||||
|
||||
<!-- <select id="getDeviceTypeCountMap" resultType="net.xnzn.core.device.manage.dto.DeviceTypeDto">-->
|
||||
<!-- select device_type ,count(1) as deviceCount from device_info group by device_type-->
|
||||
<!-- </select>-->
|
||||
<select id="getDeviceTypeCountMap" resultType="com.bonus.canteen.core.device.manage.dto.DeviceTypeDto">
|
||||
select device_type ,count(1) as deviceCount from device_info group by device_type
|
||||
</select>
|
||||
<!-- <select id="listLocaltionDevices" resultType="java.lang.String"-->
|
||||
<!-- parameterType="net.xnzn.core.device.manage.dto.DeviceSearchDTO">-->
|
||||
<!-- SELECT-->
|
||||
|
|
|
|||
Loading…
Reference in New Issue