diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/api/DeviceV2Api.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/api/DeviceV2Api.java new file mode 100644 index 00000000..4e1a83f0 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/api/DeviceV2Api.java @@ -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 getDeviceInfoVoByNumList(List deviceNumList) { +// return this.deviceInfoService.getDeviceInfoVoByNumList(deviceNumList); +// } +// +// public DeviceInfoVO getDeviceInfoVoById(Long deviceId) { +// return this.deviceInfoService.getDeviceInfoVoById(deviceId); +// } +// +// public List getPrintDeviceInfoVoByCanteenandStallId(String canteenId, String stallId) { +// List deviceInfoVOList = this.deviceInfoService.listDeviceInfoVoByType(SourceTypeEnum.PRINTER.getKey()); +// List 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 getPrintDeviceInfoVoBysupermarketIdId(String supermarketId) { +// List 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 getPrintDeviceInfoVoByFlag(String flag) { +// List 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 getDeviceTypeCountMap() { + return this.deviceInfoService.getDeviceTypeCountMap(); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/dto/DeviceTypeDto.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/dto/DeviceTypeDto.java new file mode 100644 index 00000000..de49cc32 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/dto/DeviceTypeDto.java @@ -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; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/mapper/DeviceInfoMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/mapper/DeviceInfoMapper.java index 0fc23dc7..08b87498 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/mapper/DeviceInfoMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/mapper/DeviceInfoMapper.java @@ -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 { // // List listTenantDevice(@Param("deviceTypes") List deviceTypes, @Param("canteenIds") List canteenIds, @Param("stallIds") List stallIds); // -// List getDeviceTypeCountMap(); + List getDeviceTypeCountMap(); // // List listLocaltionDevices(@Param("param") DeviceSearchDTO param); } diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/service/DeviceInfoService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/service/DeviceInfoService.java index 5ce83320..be3c6fd3 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/service/DeviceInfoService.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/device/manage/service/DeviceInfoService.java @@ -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 getDeviceTypeCountMap() { -// List deviceTypeDtos = this.deviceInfoMapper.getDeviceTypeCountMap(); -// return (Map)deviceTypeDtos.stream().collect(Collectors.toMap(DeviceTypeDto::getDeviceType, DeviceTypeDto::getDeviceCount)); -// } + public Map getDeviceTypeCountMap() { + List deviceTypeDtos = this.deviceInfoMapper.getDeviceTypeCountMap(); + return deviceTypeDtos.stream() + .collect(Collectors.toMap(DeviceTypeDto::getDeviceType, DeviceTypeDto::getDeviceCount)); + } // // public List listLocaltionDevices(DeviceSearchDTO deviceSearchDTO) { // return this.deviceInfoMapper.listLocaltionDevices(deviceSearchDTO); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/constant/MenuBindTypeEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/constant/MenuBindTypeEnum.java new file mode 100644 index 00000000..c4c25eee --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/constant/MenuBindTypeEnum.java @@ -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}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/constant/MenuRecipeSortEnum.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/constant/MenuRecipeSortEnum.java new file mode 100644 index 00000000..9d79cf75 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/constant/MenuRecipeSortEnum.java @@ -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 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 getKeyMap() { + return (Map)Arrays.stream(values()).collect(Collectors.toMap(MenuRecipeSortEnum::getKey, Function.identity())); + } + + public static Map 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 getDeviceType() { + return this.deviceType; + } + + public static List 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}; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuRecipeBindSortController.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuRecipeBindSortController.java new file mode 100644 index 00000000..b9a4f111 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/controller/MenuRecipeBindSortController.java @@ -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 dto) { + return AjaxResult.success(this.menuRecipeBindSortService.saveSort(dto)); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuRecipeSortVo.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuRecipeSortVo.java new file mode 100644 index 00000000..9b61fb60 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/dto/MenuRecipeSortVo.java @@ -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 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 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 deviceTypes) { + this.deviceTypes = deviceTypes; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/entity/MenuAppRecipe.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/entity/MenuAppRecipe.java new file mode 100644 index 00000000..419c0d5a --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/entity/MenuAppRecipe.java @@ -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 { + 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; + } + +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/entity/MenuRecipeBindSort.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/entity/MenuRecipeBindSort.java new file mode 100644 index 00000000..92e3b7fd --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/entity/MenuRecipeBindSort.java @@ -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; + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuAppRecipeMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuAppRecipeMapper.java index 773519dc..dabf407a 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuAppRecipeMapper.java +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuAppRecipeMapper.java @@ -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 { List selectWeekCanteenList(@Param("effIdSet") Set effIdSet); List selectWeekRecipeId(@Param("recipeId") Long recipeId, @Param("effIdSet") Set effIdSet); diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuRecpieBindSortMapper.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuRecpieBindSortMapper.java new file mode 100644 index 00000000..61ce42ee --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/mapper/MenuRecpieBindSortMapper.java @@ -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 { +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/MenuRecipeBindSortService.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/MenuRecipeBindSortService.java new file mode 100644 index 00000000..aa628d12 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/MenuRecipeBindSortService.java @@ -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 { + List querySort(); + + Boolean saveSort(List content); + + void deleteByDevice(Integer deviceType); +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeBindSortServiceImpl.java b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeBindSortServiceImpl.java new file mode 100644 index 00000000..96bbda07 --- /dev/null +++ b/bonus-modules/bonus-smart-canteen/src/main/java/com/bonus/canteen/core/menu/service/impl/MenuRecipeBindSortServiceImpl.java @@ -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 implements MenuRecipeBindSortService { + @Resource + private DeviceV2Api deviceV2Api; + @Resource + private MenuAppRecipeMapper menuAppRecipeMapper; + + @Override + public List querySort() { + Map bindTypeMap = MenuRecipeSortEnum.getKeyMap(); + List list = this.list(); + List 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 keys = bindTypeMap.keySet(); + List 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 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 content) { + this.remove(Wrappers.lambdaQuery()); + List menuRecipeBindSorts = BeanUtil.copyToList(content, MenuRecipeBindSort.class); + super.saveBatch(menuRecipeBindSorts); + return true; + } + + @Override + public void deleteByDevice(Integer deviceType) { + Map countMap = this.deviceV2Api.getDeviceTypeCountMap(); + Arrays.stream(MenuRecipeSortEnum.values()).filter((item) -> { + return item.getDeviceType().contains(deviceType); + }).findFirst().ifPresent((item) -> { + List 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())); + } + + }); + } +} diff --git a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/manage/DeviceInfoMapper.xml b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/manage/DeviceInfoMapper.xml index 95a594cb..f8029320 100644 --- a/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/manage/DeviceInfoMapper.xml +++ b/bonus-modules/bonus-smart-canteen/src/main/resources/mapper/device/manage/DeviceInfoMapper.xml @@ -521,9 +521,9 @@ - - - +