大屏接口
This commit is contained in:
		| @ -4,18 +4,21 @@ import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.order.vo.OrderDetailsReqVO; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.order.vo.OrderDetailsRespVO; | ||||
| import cn.iocoder.yudao.module.member.controller.app.orderdetail.vo.AppOrderDetailRespVO; | ||||
| import cn.iocoder.yudao.module.member.service.order.OrderService; | ||||
| import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RequestParam; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import javax.validation.Valid; | ||||
| import java.util.Map; | ||||
| import java.util.List; | ||||
|  | ||||
| @Tag(name = "管理后台 - 会员订单") | ||||
| @RestController | ||||
| @ -25,6 +28,8 @@ public class OrderController { | ||||
|  | ||||
|     @Resource | ||||
|     private OrderService orderService; | ||||
|     @Resource | ||||
|     private OrderDetailService detailService; | ||||
|     // | ||||
|     //@PostMapping("/create") | ||||
|     //@Operation(summary = "创建会员订单") | ||||
| @ -92,5 +97,18 @@ public class OrderController { | ||||
|     public CommonResult<PageResult<OrderDetailsRespVO>> getPageResult(@Valid    OrderDetailsReqVO reqVO){ | ||||
|         return CommonResult.success(orderService.getPageOrderDetails(reqVO)); | ||||
|     } | ||||
|  | ||||
|     /*================后台管理-订单管理-订单详情========================*/ | ||||
|     @GetMapping("/get") | ||||
|     @Operation(summary = "获得会员订单明细") | ||||
|     @PreAuthorize("@ss.hasPermission('member:order:query')") | ||||
|     public CommonResult<List<AppOrderDetailRespVO>> getOrderDetails(@RequestParam("orderId")Long orderId){ | ||||
|         return CommonResult.success(detailService.selectListByOrderId(orderId)); | ||||
|     } | ||||
|     /*================后台管理-订单管理-订单明细与用户信息========================*/ | ||||
|     @GetMapping("/get-details") | ||||
|     @Operation(summary = "获得会员订单明细与用户信息") | ||||
|     @PreAuthorize("@ss.hasPermission('member:order:query')") | ||||
|     public CommonResult<OrderDetailsRespVO> getOrderDetailsAndUser(@RequestParam("orderId")Long orderId){ | ||||
|         return CommonResult.success(orderService.getOrderDetailsAndUser(orderId)); | ||||
|     } | ||||
| } | ||||
| @ -5,6 +5,7 @@ import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
| @ -21,8 +22,10 @@ public class OrderDetailsReqVO extends PageParam { | ||||
|     @Schema(description = "门店Id", example = "24217") | ||||
|     private String storeId; | ||||
|     @Schema(description = "开始时间", example = "2024-4-12 9:00:00") | ||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
|     private LocalDateTime startDate; | ||||
|     @Schema(description = "结束时间", example = "2024-4-12 18:00:00") | ||||
|     @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") | ||||
|     private LocalDateTime endDate; | ||||
|     @Schema(description = "订单号", example = "20240401085810236196705") | ||||
|     private String orderId; | ||||
|  | ||||
| @ -40,6 +40,8 @@ public class OrderDetailsRespVO { | ||||
|     @Schema(description = "工号", example = "15111956918") | ||||
|     @ExcelProperty("工号") | ||||
|     private String userJob; | ||||
|     @Schema(description = "用户头像", example = "15111956918") | ||||
|     private String avatar; | ||||
|  | ||||
|     @Schema(description = "订单交易时间", example = "2024-04-01 09:06:19") | ||||
|     @ExcelProperty("订单交易时间") | ||||
|  | ||||
| @ -1,18 +1,23 @@ | ||||
| package cn.iocoder.yudao.module.member.controller.admin.screen; | ||||
|  | ||||
| import cn.hutool.core.date.DatePattern; | ||||
| import cn.hutool.core.date.DateTime; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.CustomerTrafficRespVO; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.screen.vo.DishVo; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDetailDO; | ||||
| import cn.iocoder.yudao.module.member.service.customertraffic.CustomerTrafficService; | ||||
| import cn.iocoder.yudao.module.member.service.order.OrderService; | ||||
| import cn.iocoder.yudao.module.member.service.orderdetail.OrderDetailService; | ||||
| import cn.iocoder.yudao.module.member.service.storeevaluate.StoreEvaluateService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import org.springframework.web.bind.annotation.GetMapping; | ||||
| import org.springframework.web.bind.annotation.RequestMapping; | ||||
| import org.springframework.web.bind.annotation.RequestParam; | ||||
| import org.springframework.web.bind.annotation.RestController; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| @ -56,6 +61,20 @@ public class ScreenController { | ||||
|         return success(BeanUtils.toBean(data, CustomerTrafficRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/half-hour") | ||||
|     @Operation(summary = "食堂今日半小时刻度顾客流量") | ||||
|     @PermitAll | ||||
|     public CommonResult<List<CustomerTrafficDetailDO>> getHalfHour(@RequestParam(value = "storeId",required = false) Long storeId, | ||||
|                                                                    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) | ||||
|                                                                    @RequestParam(value = "start")DateTime start, | ||||
|                                                                    @DateTimeFormat(pattern = DatePattern.NORM_DATETIME_PATTERN) | ||||
|                                                                    @RequestParam(value = "end") DateTime end){ | ||||
|         return success(customerTrafficService.getHalfHour(storeId, start,end)); | ||||
|     } | ||||
|  | ||||
|  | ||||
|  | ||||
|  | ||||
|     @GetMapping("/getUserCount") | ||||
|     @Operation(summary = "获取总顾客流量") | ||||
|     @PermitAll | ||||
|  | ||||
| @ -18,6 +18,7 @@ import cn.iocoder.yudao.module.member.service.user.MemberUserService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| @ -115,6 +116,13 @@ public class MemberUserController { | ||||
|                 convertSet(pageResult.getList(), MemberUserDO::getGroupId)); | ||||
|         return success(MemberUserConvert.INSTANCE.convertPage(pageResult, tags, levels, groups)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/heat") | ||||
|     @Operation(summary = "获得会员热量分析") | ||||
|     public CommonResult<List<Map>> getUserHeat(@RequestParam(value = "userId",required = false) Long userId, | ||||
|                                                @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "startDate",required = false) LocalDateTime startDate, | ||||
|                                                @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") @RequestParam(value = "endDate",required = false) LocalDateTime endDate, | ||||
|                                                @RequestParam(value = "orderId",required = false)Long orderId){ | ||||
|         return success(memberUserService.getUserHeat(userId,startDate,endDate,orderId)); | ||||
|     } | ||||
|  | ||||
| } | ||||
|  | ||||
| @ -16,7 +16,8 @@ public class AppOrderDetailRespVO { | ||||
|     @Schema(description = "编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "20679") | ||||
|     @ExcelProperty("编号") | ||||
|     private Long id; | ||||
|  | ||||
|     @Schema(description = "门店id",  example = "20679") | ||||
|     private Long storeId; | ||||
|     @Schema(description = "订单ID", example = "31077") | ||||
|     @ExcelProperty("订单ID") | ||||
|     private Long orderId; | ||||
| @ -36,7 +37,9 @@ public class AppOrderDetailRespVO { | ||||
|     @Schema(description = "热量") | ||||
|     @ExcelProperty("热量") | ||||
|     private Double heat; | ||||
|  | ||||
|     @Schema(description = "价格") | ||||
|     @ExcelProperty("价格") | ||||
|     private BigDecimal price; | ||||
|     @Schema(description = "创建时间", requiredMode = Schema.RequiredMode.REQUIRED) | ||||
|     @ExcelProperty("创建时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
| @ -0,0 +1,13 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.dataobject.customertraffic; | ||||
|  | ||||
| import lombok.Data; | ||||
|  | ||||
| /** | ||||
|  * @Author:qjq | ||||
|  * @Date:2024/4/19 下午3:30 | ||||
|  */ | ||||
| @Data | ||||
| public class CustomerTrafficDetailDO extends CustomerTrafficDO{ | ||||
|       private  String storesName; | ||||
|  | ||||
| } | ||||
| @ -1,13 +1,17 @@ | ||||
| package cn.iocoder.yudao.module.member.dal.mysql.customertraffic; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.hutool.core.date.DateTime; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.CustomerTrafficPageReqVO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDetailDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.*; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
| import org.apache.ibatis.annotations.Select; | ||||
|  | ||||
| import java.util.List; | ||||
|  | ||||
| /** | ||||
|  * 顾客流量 Mapper | ||||
| @ -25,5 +29,17 @@ public interface CustomerTrafficMapper extends BaseMapperX<CustomerTrafficDO> { | ||||
|                 .betweenIfPresent(CustomerTrafficDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(CustomerTrafficDO::getId)); | ||||
|     } | ||||
|  | ||||
|     @Select("<script>"+"SELECT\n" + | ||||
|             "\ta.customer_num,\n" + | ||||
|             "\ta.id,\n" + | ||||
|             "\ta.time_point,\n" + | ||||
|             "\ta.store_id,a.create_time,\n" + | ||||
|             "\tb.stores_name \n" + | ||||
|             "FROM\n" + | ||||
|             "\tmember_customer_traffic AS a\n" + | ||||
|             "\tINNER JOIN t_carteen AS b ON a.store_id = b.id \n" + | ||||
|             "\tAND a.create_time BETWEEN  #{start} AND #{end} "+ | ||||
|             "<if test=' storeId != null'> and a.store_id= #{storeId} </if>" | ||||
|             +"</script>") | ||||
|     List<CustomerTrafficDetailDO> getAllCustomerNum(@Param("storeId")Long storeId,@Param("start")DateTime start,@Param("end")DateTime end); | ||||
| } | ||||
| @ -204,17 +204,17 @@ public class CarteenMoneyServiceImpl implements CarteenMoneyService { | ||||
|         //根据设备分组 | ||||
|         Map<String, List<OrderDetailDO>> collect = dos.stream().collect(Collectors.groupingBy(OrderDetailDO::getSn)); | ||||
|         for (Map.Entry<String, List<OrderDetailDO>> map : collect.entrySet()) { | ||||
|             //设备流水 | ||||
|             DeviceRespVO deviceRespVO = new DeviceRespVO(); | ||||
|             List<OrderDetailDO> value = map.getValue(); | ||||
|             //设置设备ip | ||||
|             deviceRespVO.setDeviceIp(map.getKey()); | ||||
|             deviceRespVO.setDeviceName(deviceInfoApi.getDeviceInfoName(map.getKey())); | ||||
|             //根据时间进行时间段赋值 | ||||
|             value.forEach(v -> v.setCreator(TimePeriodEnum.getTimeName(v.getCreateTime()))); | ||||
|             //根据时间段分组 | ||||
|             value.stream().collect(Collectors.groupingBy(OrderDetailDO::getCreator)) | ||||
|                     .forEach((k, v) -> { | ||||
|                         //设备流水 | ||||
|                         DeviceRespVO deviceRespVO = new DeviceRespVO(); | ||||
|                         //设置设备ip | ||||
|                         deviceRespVO.setDeviceIp(map.getKey()); | ||||
|                         deviceRespVO.setDeviceName(deviceInfoApi.getDeviceInfoName(map.getKey())); | ||||
|                         //根据时间段进行金额统计 | ||||
|                         BigDecimal sum = v.stream() | ||||
|                                 .map(OrderDetailDO::getPrice) | ||||
| @ -222,8 +222,9 @@ public class CarteenMoneyServiceImpl implements CarteenMoneyService { | ||||
|                                 .reduce(BigDecimal.ZERO, BigDecimal::add); | ||||
|                         deviceRespVO.setTime(k); | ||||
|                         deviceRespVO.setMoney(sum); | ||||
|                         bean.getDeviceRespVOList().add(deviceRespVO); | ||||
|                     }); | ||||
|             bean.getDeviceRespVOList().add(deviceRespVO); | ||||
|  | ||||
|         } | ||||
|         return bean; | ||||
|     } | ||||
|  | ||||
| @ -1,9 +1,11 @@ | ||||
| package cn.iocoder.yudao.module.member.service.customertraffic; | ||||
|  | ||||
| import cn.hutool.core.date.DateTime; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.CustomerTrafficPageReqVO; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.CustomerTrafficSaveReqVO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDetailDO; | ||||
|  | ||||
| import javax.validation.Valid; | ||||
| import java.util.List; | ||||
| @ -60,5 +62,11 @@ public interface CustomerTrafficService { | ||||
|      * 获取最新7个时间节点的数据 | ||||
|      */ | ||||
|     List<CustomerTrafficDO> getData(Long storeId); | ||||
|  | ||||
|     /** | ||||
|      * @Description: 半小时刻度,查询最新7个时间点的数据 | ||||
|      * @Author: qjq | ||||
|      * @Date: 2024/4/19 下午2:39 | ||||
|      * @return | ||||
|      */ | ||||
|     List<CustomerTrafficDetailDO>  getHalfHour(Long storeId, DateTime start, DateTime end); | ||||
| } | ||||
| @ -1,18 +1,26 @@ | ||||
| package cn.iocoder.yudao.module.member.service.customertraffic; | ||||
|  | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.collection.ListUtil; | ||||
| import cn.hutool.core.date.DateTime; | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import cn.hutool.core.util.ObjUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.CustomerTrafficPageReqVO; | ||||
| import cn.iocoder.yudao.module.member.controller.admin.customertraffic.vo.CustomerTrafficSaveReqVO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDO; | ||||
| import cn.iocoder.yudao.module.member.dal.dataobject.customertraffic.CustomerTrafficDetailDO; | ||||
| import cn.iocoder.yudao.module.member.dal.mysql.customertraffic.CustomerTrafficMapper; | ||||
| import com.baomidou.mybatisplus.core.toolkit.Wrappers; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
| import java.util.List; | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| import static cn.iocoder.yudao.module.member.enums.ErrorCodeConstants.CUSTOMER_TRAFFIC_NOT_EXISTS; | ||||
| @ -28,7 +36,9 @@ public class CustomerTrafficServiceImpl implements CustomerTrafficService { | ||||
|  | ||||
|     @Resource | ||||
|     private CustomerTrafficMapper customerTrafficMapper; | ||||
|  | ||||
|     private static  final  String ZC="ZC"; //早餐 | ||||
|     private static  final  String WC="WC"; //午餐 | ||||
|     private static  final  String W="W"; //晚餐 | ||||
|     @Override | ||||
|     public Long createCustomerTraffic(CustomerTrafficSaveReqVO createReqVO) { | ||||
|         // 插入 | ||||
| @ -86,4 +96,45 @@ public class CustomerTrafficServiceImpl implements CustomerTrafficService { | ||||
|                 .last("limit 7")); | ||||
|         return customerTrafficDOS; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param storeId | ||||
|      * @return | ||||
|      * @Description: 半小时刻度,查询最新7个时间点的数据 | ||||
|      * @Author: qjq | ||||
|      * @Date: 2024/4/19 下午2:39 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<CustomerTrafficDetailDO> getHalfHour(Long storeId, DateTime startDate,DateTime endDate) { | ||||
|         if(ObjUtil.isEmpty(storeId)){ | ||||
|             DateTime end = DateUtil.endOfDay(DateUtil.date()); | ||||
|             DateTime begin = DateUtil.beginOfDay(end); | ||||
|             List<CustomerTrafficDetailDO> list=new ArrayList<>(); | ||||
|             customerTrafficMapper.getAllCustomerNum(null,begin, end) | ||||
|                     .stream() | ||||
|                     .collect(Collectors.groupingBy(CustomerTrafficDetailDO::getStoreId)) | ||||
|                     .forEach((k,v)->{ | ||||
|                         BigDecimal reduce = v.stream() | ||||
|                                 .map(f -> BigDecimal.valueOf(f.getCustomerNum())) | ||||
|                                 .filter(ObjUtil::isNotNull) | ||||
|                                 .reduce(BigDecimal.ZERO, BigDecimal::add); | ||||
|                         CustomerTrafficDetailDO aDo = BeanUtil.toBean(v.get(0), CustomerTrafficDetailDO.class); | ||||
|                         aDo.setCustomerNum(reduce.intValue()); | ||||
|                         list.add(aDo); | ||||
|                     }); | ||||
|             return   list; | ||||
|         }else{ | ||||
|             List<CustomerTrafficDetailDO> all = customerTrafficMapper.getAllCustomerNum(storeId, startDate, endDate); | ||||
|             all.sort(Comparator.comparing(CustomerTrafficDetailDO::getCustomerNum)); | ||||
|             List<CustomerTrafficDetailDO> list=new ArrayList<>(); | ||||
|             //拆分 | ||||
|             List<List<CustomerTrafficDetailDO>> split = ListUtil.split(list, 3); | ||||
|             for (List<CustomerTrafficDetailDO> dos : split) { | ||||
|                 CustomerTrafficDetailDO aDo = BeanUtil.toBean(dos.get(0), CustomerTrafficDetailDO.class); | ||||
|                 aDo.setCustomerNum(dos.stream().mapToInt(CustomerTrafficDetailDO::getCustomerNum).sum()); | ||||
|                 list.add(aDo); | ||||
|             } | ||||
|             return list; | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -84,6 +84,7 @@ public interface OrderService { | ||||
|     List<DishOrderDO> getDishOrderByTime(LocalDateTime startTime ,LocalDateTime endTime ); | ||||
|  | ||||
|     PageResult<OrderDetailsRespVO> getPageOrderDetails(OrderDetailsReqVO reqVO); | ||||
|     OrderDetailsRespVO getOrderDetailsAndUser(Long orderId); | ||||
|  | ||||
|     /** | ||||
|      * 获取今日顾客总量 | ||||
|  | ||||
| @ -31,7 +31,6 @@ import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| import java.time.LocalDate; | ||||
| import java.time.LocalDateTime; | ||||
| import java.time.LocalTime; | ||||
| import java.time.format.DateTimeFormatter; | ||||
| import java.util.ArrayList; | ||||
| import java.util.Collections; | ||||
| @ -168,15 +167,29 @@ public class OrderServiceImpl implements OrderService { | ||||
|         List<OrderDetailsRespVO> list=new ArrayList<>(); | ||||
|         for (DishOrderDO dishOrderDO : pageResult.getList()) { | ||||
|             OrderDetailsRespVO bean = BeanUtils.toBean(dishOrderDO, OrderDetailsRespVO.class); | ||||
|             MemberUserDO userDO = memberUserMapper.selectById(bean.getUserId()); | ||||
|             bean.setUserName(userDO.getName()); | ||||
|             bean.setUserJob(userDO.getMobile()); | ||||
|             bean.setUserAccount(userDO.getMobile()); | ||||
|             bean.setTimePeriod(TimePeriodEnum.MIDDAY.getTimePeriod(bean.getCreateTime())); | ||||
|             userDetails(bean); | ||||
|             list.add(bean); | ||||
|         } | ||||
|         return new PageResult<>(list,pageResult.getTotal()); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public OrderDetailsRespVO getOrderDetailsAndUser(Long orderId) { | ||||
|         OrderDetailsRespVO bean = BeanUtils.toBean(dishOrderMapper.selectById(orderId), OrderDetailsRespVO.class); | ||||
|         userDetails(bean); | ||||
|         return bean; | ||||
|     } | ||||
|  | ||||
|     private void userDetails(OrderDetailsRespVO bean) { | ||||
|         MemberUserDO userDO = memberUserMapper.selectById(bean.getUserId()); | ||||
|         bean.setUserName(userDO.getNickname()); | ||||
|         bean.setUserJob(userDO.getMobile()); | ||||
|         bean.setAvatar(userDO.getAvatar()); | ||||
|         bean.setPayMethods("钱包"); | ||||
|         bean.setUserAccount(userDO.getMobile()); | ||||
|         bean.setTimePeriod(TimePeriodEnum.getTimeName(bean.getCreateTime())); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @Description: 数据类型对标 {@link CostTypeEnum} | ||||
|      * @Author: qjq | ||||
|  | ||||
| @ -161,8 +161,11 @@ public class OrderDetailServiceImpl implements OrderDetailService { | ||||
|  | ||||
|     @Override | ||||
|     public List<AppOrderDetailRespVO> selectListByOrderId(Long orderId) { | ||||
|         Long storeId = dishOrderMapper.selectById(orderId).getStoreId(); | ||||
|         List<OrderDetailDO> orderDetailDOS = orderDetailMapper.selectList(Wrappers.<OrderDetailDO>lambdaQuery().eq(OrderDetailDO::getOrderId, orderId)); | ||||
|         return BeanUtils.toBean(orderDetailDOS, AppOrderDetailRespVO.class); | ||||
|         List<AppOrderDetailRespVO> bean = BeanUtils.toBean(orderDetailDOS, AppOrderDetailRespVO.class); | ||||
|         bean.forEach(f->f.setStoreId(storeId)); | ||||
|         return bean; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|  | ||||
| @ -1,33 +1,33 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.carteen; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenRespVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenWeekSalesRespVo; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO; | ||||
| import cn.iocoder.yudao.module.system.service.carteen.CarteenService; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import javax.validation.Valid; | ||||
| import java.io.IOException; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||||
|  | ||||
|  | ||||
| @Tag(name = "管理后台 - 门店管理") | ||||
| @ -92,5 +92,11 @@ public class CarteenController { | ||||
|         ExcelUtils.write(response, "门店管理.xls", "数据", CarteenRespVO.class, | ||||
|                         BeanUtils.toBean(list, CarteenRespVO.class)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/week/sales") | ||||
|     @Operation(summary = "获得门店销量") | ||||
|     @PreAuthorize("@ss.hasPermission('t:carteen:query')") | ||||
| //    @PermitAll | ||||
|     public CommonResult<Map<String, List<CarteenWeekSalesRespVo>>> getCarteenSales(CarteenPageReqVO pageReqVO) { | ||||
|         return success(carteenService.getCarteenWeekSales(pageReqVO)); | ||||
|     } | ||||
| } | ||||
| @ -1,10 +1,12 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.carteen.vo; | ||||
|  | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
| import lombok.EqualsAndHashCode; | ||||
| import lombok.ToString; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
|  | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND; | ||||
| @ -33,6 +35,12 @@ public class CarteenPageReqVO extends PageParam { | ||||
|     @Schema(description = "联系电话") | ||||
|     private String phone; | ||||
|  | ||||
|     @Schema(description = "类型,(all:全部)空为单个") | ||||
|     private String type; | ||||
|  | ||||
|     @Schema(description = "门店id") | ||||
|     private Long carteenId; | ||||
|  | ||||
|     @Schema(description = "创建时间") | ||||
|     @DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND) | ||||
|     private LocalDateTime[] createTime; | ||||
|  | ||||
| @ -0,0 +1,33 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.carteen.vo; | ||||
|  | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| import java.time.LocalDateTime; | ||||
|  | ||||
| /** | ||||
|  * @Author:qjq | ||||
|  * @Date:2024/4/19 上午10:00 | ||||
|  */ | ||||
| @Schema(description = "管理后台 - 门店周报 Response VO") | ||||
| @Data | ||||
| @ExcelIgnoreUnannotated | ||||
| public class CarteenWeekSalesRespVo { | ||||
|     @Schema(description = "门店id") | ||||
|     private Long carteenId; | ||||
|  | ||||
|     @Schema(description = "食堂名称") | ||||
|     private String carteenName; | ||||
|  | ||||
|     @Schema(description = "时间类型") | ||||
|     private String timeType; | ||||
|  | ||||
|     @Schema(description = "时间") | ||||
|     private LocalDateTime createTime; | ||||
|  | ||||
|     @Schema(description = "菜品销量(kg)") | ||||
|     private BigDecimal sales; | ||||
|     //TODO 需要什么字段再加 | ||||
| } | ||||
| @ -1,35 +1,33 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.dishes; | ||||
|  | ||||
| import cn.hutool.core.util.NumberUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO; | ||||
| import cn.iocoder.yudao.module.system.service.dishes.DishesService; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import cn.iocoder.yudao.module.system.service.dishesnutrition.DishesNutritionService; | ||||
| import cn.iocoder.yudao.module.system.service.dishesraw.DishesRawService; | ||||
| import io.swagger.v3.oas.annotations.Operation; | ||||
| import io.swagger.v3.oas.annotations.Parameter; | ||||
| import io.swagger.v3.oas.annotations.tags.Tag; | ||||
| import org.springframework.security.access.prepost.PreAuthorize; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import org.springframework.web.bind.annotation.*; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import javax.validation.*; | ||||
| import javax.servlet.http.*; | ||||
| import java.util.*; | ||||
| import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletResponse; | ||||
| import javax.validation.Valid; | ||||
| import java.io.IOException; | ||||
| import java.util.List; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.pojo.CommonResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.excel.core.util.ExcelUtils; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.operatelog.core.annotations.OperateLog; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.*; | ||||
| import static cn.iocoder.yudao.framework.operatelog.core.enums.OperateTypeEnum.EXPORT; | ||||
|  | ||||
|  | ||||
| @Tag(name = "管理后台 - 菜品管理") | ||||
| @ -40,6 +38,10 @@ public class DishesController { | ||||
|  | ||||
|     @Resource | ||||
|     private DishesService dishesService; | ||||
|     @Resource | ||||
|     private DishesNutritionService dishesNutritionService; | ||||
|     @Resource | ||||
|     private DishesRawService dishesRawService; | ||||
|  | ||||
|     @PostMapping("/create") | ||||
|     @Operation(summary = "创建菜品管理") | ||||
| @ -70,8 +72,7 @@ public class DishesController { | ||||
|     @Parameter(name = "id", description = "编号", required = true, example = "1024") | ||||
|     @PreAuthorize("@ss.hasPermission('t:dishes:query')") | ||||
|     public CommonResult<DishesRespVO> getDishes(@RequestParam("id") Long id) { | ||||
|         DishesDO dishes = dishesService.getDishes(id); | ||||
|         return success(BeanUtils.toBean(dishes, DishesRespVO.class)); | ||||
|         return success(dishesService.getDishes1(id)); | ||||
|     } | ||||
|  | ||||
|     @GetMapping("/page") | ||||
|  | ||||
| @ -1,13 +1,16 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.dishes.vo; | ||||
|  | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesraw.vo.DishesRawSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishesnutrition.DishesNutritionDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishesraw.DishesRawDO; | ||||
| import com.alibaba.excel.annotation.ExcelIgnoreUnannotated; | ||||
| import com.alibaba.excel.annotation.ExcelProperty; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import java.util.*; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.math.BigDecimal; | ||||
| import org.springframework.format.annotation.DateTimeFormat; | ||||
| import java.time.LocalDateTime; | ||||
| import com.alibaba.excel.annotation.*; | ||||
| import java.util.List; | ||||
|  | ||||
| @Schema(description = "管理后台 - 菜品管理 Response VO") | ||||
| @Data | ||||
| @ -65,4 +68,9 @@ public class DishesRespVO { | ||||
|  | ||||
|     @Schema(description = "菜品总重量") | ||||
|     private BigDecimal dishesNumber; | ||||
|  | ||||
|     @Schema(description = "菜品营养", example = "1") | ||||
|     private List<DishesNutritionDO> dishesNutritionList; | ||||
|     @Schema(description = "菜品原材料", example = "1") | ||||
|     private List<DishesRawDO> dishesRawList; | ||||
| } | ||||
| @ -1,11 +1,12 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.dishes.vo; | ||||
|  | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesnutrition.vo.DishesNutritionSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesraw.vo.DishesRawSaveReqVO; | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import lombok.Data; | ||||
|  | ||||
| import javax.validation.constraints.*; | ||||
| import java.math.BigDecimal; | ||||
| import java.util.List; | ||||
|  | ||||
| @Schema(description = "管理后台 - 菜品管理新增/修改 Request VO") | ||||
| @Data | ||||
| @ -57,4 +58,9 @@ public class DishesSaveReqVO { | ||||
|     private BigDecimal dishesSumPrice; | ||||
|     @Schema(description = "菜品总重量", example = "1") | ||||
|     private BigDecimal dishesNumber; | ||||
|  | ||||
|     @Schema(description = "菜品营养", example = "1") | ||||
|     private List<DishesNutritionSaveReqVO> dishesNutritionList; | ||||
|     @Schema(description = "菜品原材料", example = "1") | ||||
|     private List<DishesRawSaveReqVO> dishesRawList; | ||||
| } | ||||
| @ -1,9 +1,7 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.dishesnutrition.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import java.util.*; | ||||
| import javax.validation.constraints.*; | ||||
| import lombok.Data; | ||||
|  | ||||
| @Schema(description = "管理后台 - 菜品营养新增/修改 Request VO") | ||||
| @Data | ||||
| @ -22,7 +20,7 @@ public class DishesNutritionSaveReqVO { | ||||
|     private String dishesNumber; | ||||
|  | ||||
|     @Schema(description = "菜品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "5929") | ||||
|     @NotNull(message = "菜品编号不能为空") | ||||
| //    @NotNull(message = "菜品编号不能为空") | ||||
|     private Long dishesId; | ||||
|  | ||||
|     @Schema(description = "营养占比") | ||||
|  | ||||
| @ -1,11 +1,8 @@ | ||||
| package cn.iocoder.yudao.module.system.controller.admin.dishesraw.vo; | ||||
|  | ||||
| import io.swagger.v3.oas.annotations.media.Schema; | ||||
| import lombok.*; | ||||
| import org.springframework.web.multipart.MultipartFile; | ||||
| import lombok.Data; | ||||
|  | ||||
| import java.util.*; | ||||
| import javax.validation.constraints.*; | ||||
| import java.math.BigDecimal; | ||||
|  | ||||
| @Schema(description = "管理后台 - 菜品原材料新增/修改 Request VO") | ||||
| @ -19,13 +16,13 @@ public class DishesRawSaveReqVO { | ||||
|     private String rawName; | ||||
|  | ||||
|     @Schema(description = "原材料图片", example = "https://www.iocoder.cn") | ||||
|     private MultipartFile rawImgUrl; | ||||
|     private String rawImgUrl; | ||||
|  | ||||
|     @Schema(description = "原材料描述") | ||||
|     private String rawDescribe; | ||||
|  | ||||
|     @Schema(description = "菜品编号", requiredMode = Schema.RequiredMode.REQUIRED, example = "23140") | ||||
|     @NotNull(message = "菜品编号不能为空") | ||||
| //    @NotNull(message = "菜品编号不能为空") | ||||
|     private Long dishesId; | ||||
|  | ||||
|     @Schema(description = "原材料产地") | ||||
|  | ||||
| @ -17,6 +17,7 @@ import javax.annotation.Resource; | ||||
| import javax.annotation.security.PermitAll; | ||||
| import javax.validation.Valid; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.pojo.CommonResult.success; | ||||
|  | ||||
| @ -109,4 +110,9 @@ public class DevuceController { | ||||
|     public CommonResult<Long> getCarteenId() { | ||||
|         return success(devuceService.getCarteenIdByIp()); | ||||
|     } | ||||
|     @GetMapping("/nutrition") | ||||
|     @Operation(summary = "根据ip获取门店id") | ||||
|     public CommonResult<List<Map>> getDishesNutrition(@RequestParam("dishesId") Long dishesId) { | ||||
|         return success(devuceService.getDishesNutrition( dishesId)); | ||||
|     } | ||||
| } | ||||
| @ -1,13 +1,17 @@ | ||||
| package cn.iocoder.yudao.module.system.dal.mysql.carteen; | ||||
|  | ||||
| import java.util.*; | ||||
|  | ||||
| import cn.hutool.core.date.DateTime; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenWeekSalesRespVo; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO; | ||||
| import org.apache.ibatis.annotations.Mapper; | ||||
| import org.apache.ibatis.annotations.Param; | ||||
| import org.apache.ibatis.annotations.Select; | ||||
|  | ||||
| import java.util.LinkedList; | ||||
|  | ||||
| /** | ||||
|  * 门店管理 Mapper | ||||
| @ -28,5 +32,31 @@ public interface CarteenMapper extends BaseMapperX<CarteenDO> { | ||||
|                 .betweenIfPresent(CarteenDO::getCreateTime, reqVO.getCreateTime()) | ||||
|                 .orderByDesc(CarteenDO::getId)); | ||||
|     } | ||||
|     @Select("<script>"+"SELECT\n" + | ||||
|             "\tA.weigh as sales,\n" + | ||||
|             "\tA.carteen_id  AS carteenId,\n" + | ||||
|             "\tA.create_time AS createTime,\n" + | ||||
|             "\tB.stores_name as carteenName\n" + | ||||
|             "FROM\n" + | ||||
|             "\tt_business AS  A  \n" + | ||||
|             "INNER JOIN t_carteen as B on B.id=A.carteen_id\n" + | ||||
|             "WHERE\n" + | ||||
|             "\tA.create_time BETWEEN #{beginDate} and #{endDate}  ORDER BY A.create_time"+ | ||||
|             "<if test='carteenId != null'> and A.carteen_id= #{carteenId} </if>"+ | ||||
|             "</script>") | ||||
|     LinkedList<CarteenWeekSalesRespVo> selectWeekSales(@Param("carteenId") Long carteenId,@Param("beginDate") DateTime beginDate, @Param("endDate") DateTime endDate); | ||||
|  | ||||
|     @Select("<script>"+"SELECT\n" + | ||||
|             "\tb.create_time AS createTime,\n" + | ||||
|             "\tb.store_name as carteenName,\n" + | ||||
|             "\tb.store_id as carteenId,\n" + | ||||
|             "\ta.weight as sales\n" + | ||||
|             "FROM\n" + | ||||
|             "\tmember_order_detail AS a\n" + | ||||
|             "\tINNER JOIN member_dish_order AS b ON a.order_id = b.id\n" + | ||||
|             "\n" + | ||||
|             "\twhere a.create_time BETWEEN #{beginDate} and #{endDate} "+ | ||||
|             "<if test='carteenId != null'> and b.store_id= #{carteenId} </if>"+ | ||||
|             "</script>") | ||||
|     LinkedList<CarteenWeekSalesRespVo>  getCarteenSales(@Param("carteenId")Long carteenId,@Param("beginDate") DateTime beginDate, @Param("endDate") DateTime endDate); | ||||
| } | ||||
| @ -1,11 +1,14 @@ | ||||
| package cn.iocoder.yudao.module.system.service.carteen; | ||||
|  | ||||
| import javax.validation.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenWeekSalesRespVo; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| import javax.validation.Valid; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * 门店管理 Service 接口 | ||||
| @ -52,4 +55,11 @@ public interface CarteenService { | ||||
|      */ | ||||
|     PageResult<CarteenDO> getCarteenPage(CarteenPageReqVO pageReqVO); | ||||
|  | ||||
|     /** | ||||
|      * @Description: 获取门店一周卖出多少销量 千克 | ||||
|      * @Author: qjq | ||||
|      * @Date: 2024/4/19 上午9:55 | ||||
|      * @return | ||||
|      */ | ||||
|     Map<String, List<CarteenWeekSalesRespVo>> getCarteenWeekSales(CarteenPageReqVO pageReqVO); | ||||
| } | ||||
| @ -1,10 +1,16 @@ | ||||
| package cn.iocoder.yudao.module.system.service.carteen; | ||||
|  | ||||
| import cn.hutool.core.bean.BeanUtil; | ||||
| import cn.hutool.core.date.DateTime; | ||||
| import cn.hutool.core.date.DateUtil; | ||||
| import cn.hutool.core.date.LocalDateTimeUtil; | ||||
| import cn.hutool.core.util.ObjectUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.carteen.vo.CarteenWeekSalesRespVo; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.carteen.CarteenDO; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.carteen.CarteenMapper; | ||||
| import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; | ||||
| @ -13,8 +19,10 @@ import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.util.Arrays; | ||||
| import java.util.Set; | ||||
| import java.math.BigDecimal; | ||||
| import java.math.RoundingMode; | ||||
| import java.util.*; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
|  | ||||
| @ -31,6 +39,12 @@ public class CarteenServiceImpl implements CarteenService { | ||||
|     private CarteenMapper carteenMapper; | ||||
|     @Resource | ||||
|     private PermissionService permissionService; | ||||
|     private static final String ALL="all"; | ||||
|     //这周字段 | ||||
|     private static final String THISWEEK="week"; | ||||
|     //上周 | ||||
|     private static final String LASTWEEK="LastWeek"; | ||||
|  | ||||
|     @Override | ||||
|     public Long createCarteen(CarteenSaveReqVO createReqVO) { | ||||
|         // 插入 | ||||
| @ -78,4 +92,82 @@ public class CarteenServiceImpl implements CarteenService { | ||||
|         return carteenMapper.selectPage(pageReqVO); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param req | ||||
|      * @return | ||||
|      * @Description: 获取门店一周卖出多少销量 千克 | ||||
|      * @Author: qjq | ||||
|      * @Date: 2024/4/19 上午9:55 | ||||
|      */ | ||||
|     @Override | ||||
|     public Map<String, List<CarteenWeekSalesRespVo>> getCarteenWeekSales(CarteenPageReqVO req) { | ||||
|         //获取这周时间 | ||||
|         DateTime endTime =DateUtil.endOfDay(DateUtil.date()); | ||||
|         DateTime startTime1=DateUtil.beginOfDay(endTime); | ||||
|         //获取偏移时间单位 | ||||
|         DateTime startTime=DateUtil.offsetDay(startTime1,-6); | ||||
|         //获取上周时间 | ||||
|         DateTime endTime2=DateUtil.endOfDay(DateUtil.offsetDay(startTime,-1)); | ||||
|         DateTime startTime2 =DateUtil.beginOfDay(DateUtil.offsetDay(endTime2,-6)); | ||||
|         Map<String, List<CarteenWeekSalesRespVo>> listMap=new HashMap<>(); | ||||
|         //这周时间 | ||||
|         //获取所有门店的销售量 | ||||
|         List<CarteenWeekSalesRespVo> list = this.getCarteenWeekSalesByType(req, startTime, endTime); | ||||
|         list.addAll(this.getCarteenSales(req, startTime1, endTime)); | ||||
|         if(ALL.equals(req.getType())){ | ||||
|             listMap.put(THISWEEK,this.getComputeCarteenWeekSales(list)); | ||||
|             //上周时间 | ||||
|             listMap.put(LASTWEEK,this.getCarteenWeekSalesByType(req, startTime2, endTime2)); | ||||
|         }else{ | ||||
|             listMap.put(THISWEEK,list); | ||||
|             listMap.put(LASTWEEK,this.getCarteenWeekSalesByType(req, startTime2, endTime2)); | ||||
|         } | ||||
|         //进行时间处理 | ||||
|         listMap.forEach((v,k)->{ | ||||
|             k.sort(Comparator.comparing(CarteenWeekSalesRespVo::getCreateTime)); | ||||
|             k.forEach(f-> f.setTimeType(LocalDateTimeUtil.dayOfWeek(f.getCreateTime().toLocalDate()).toChinese())); | ||||
|         }); | ||||
|         return listMap; | ||||
|     } | ||||
|     public List<CarteenWeekSalesRespVo> getComputeCarteenWeekSales(List<CarteenWeekSalesRespVo> list) { | ||||
|         List<CarteenWeekSalesRespVo> list1= new ArrayList<>(); | ||||
|         list.forEach(f-> f.setTimeType(LocalDateTimeUtil.dayOfWeek(f.getCreateTime().toLocalDate()).toChinese())); | ||||
|         list.stream() | ||||
|                 .collect(Collectors.groupingBy(CarteenWeekSalesRespVo::getCarteenId)) | ||||
|                 .forEach((k,v)->{ | ||||
|                     CarteenWeekSalesRespVo bean = BeanUtil.toBean(v.get(0), CarteenWeekSalesRespVo.class); | ||||
|                     BigDecimal sum = v.stream() | ||||
|                             .map(CarteenWeekSalesRespVo::getSales) | ||||
|                             .filter(ObjectUtil::isNotEmpty) | ||||
|                             .reduce(BigDecimal.ZERO, BigDecimal::add).setScale(2, RoundingMode.HALF_UP); | ||||
|                     bean.setSales(sum); | ||||
|                     list1.add(bean); | ||||
|                 }); | ||||
|         return list1; | ||||
|     } | ||||
|     public List<CarteenWeekSalesRespVo> getCarteenWeekSalesByType(CarteenPageReqVO req, | ||||
|                                                                   DateTime startDate, | ||||
|                                                                   DateTime endDate){ | ||||
|         if(ALL.equals(req.getType())){ | ||||
|             return this.getComputeCarteenWeekSales(carteenMapper.selectWeekSales(null,startDate,endDate)); | ||||
|         }else{ | ||||
|  | ||||
|             return carteenMapper.selectWeekSales(req.getCarteenId(),startDate,endDate); | ||||
|         } | ||||
|     } | ||||
|     /** | ||||
|      * @Description: 今日门店销售量 | ||||
|      * @Author: qjq | ||||
|      * @Date: 2024/4/19 上午11:35 | ||||
|      * @return | ||||
|      */ | ||||
|     public List<CarteenWeekSalesRespVo> getCarteenSales(CarteenPageReqVO req, DateTime startDate, | ||||
|                                                         DateTime endDate){ | ||||
|         if(ALL.equals(req.getType())){ | ||||
|             return carteenMapper.getCarteenSales(null,startDate,endDate); | ||||
|         } | ||||
|         else{ | ||||
|             return carteenMapper.getCarteenSales(req.getCarteenId(),startDate,endDate); | ||||
|         } | ||||
|     } | ||||
| } | ||||
| @ -9,6 +9,7 @@ import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO; | ||||
|  | ||||
| import javax.validation.Valid; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
|  | ||||
| /** | ||||
|  * 设备 Service 接口 | ||||
| @ -78,4 +79,11 @@ public interface DevuceService { | ||||
|          * @return | ||||
|          */ | ||||
|     Long getCarteenIdByIp(); | ||||
|     /** | ||||
|      * @Description: 获取菜品营养与菜品名称 | ||||
|      * @Author: qjq | ||||
|      * @Date: 2024/4/19 下午2:44 | ||||
|      * @return | ||||
|      */ | ||||
|     List<Map> getDishesNutrition(Long dishesId); | ||||
| } | ||||
| @ -9,10 +9,12 @@ import cn.iocoder.yudao.module.system.controller.app.devuce.vo.DevuceSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.deviceInfo.DeviceInfoDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.devuce.DevuceDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishesnutrition.DishesNutritionDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishestype.DishesTypeDO; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.deviceInfo.DeviceInfoMapper; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.devuce.DevuceMapper; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.dishesnutrition.DishesNutritionMapper; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.dishestype.DishesTypeMapper; | ||||
| import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; | ||||
| import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; | ||||
| @ -22,6 +24,7 @@ import org.springframework.validation.annotation.Validated; | ||||
| import javax.annotation.Resource; | ||||
| import javax.servlet.http.HttpServletRequest; | ||||
| import java.util.List; | ||||
| import java.util.Map; | ||||
| import java.util.stream.Collectors; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
| @ -45,6 +48,8 @@ public class DevuceServiceImpl implements DevuceService { | ||||
|     private HttpServletRequest httpServletRequest; | ||||
|     @Resource | ||||
|     private DeviceInfoMapper deviceInfoMapper; | ||||
|     @Resource | ||||
|     private DishesNutritionMapper dishesNutritionMapper; | ||||
|     @Override | ||||
|     public Long createDevuce(DevuceSaveReqVO createReqVO) { | ||||
|         // 插入 | ||||
| @ -174,6 +179,27 @@ public class DevuceServiceImpl implements DevuceService { | ||||
|         return dishesTypeMapper.selectList(new LambdaQueryWrapperX<DishesTypeDO>().eq(DishesTypeDO::getCarteenId,carteenId)); | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @param dishesId | ||||
|      * @return | ||||
|      * @Description: 获取菜品营养与菜品名称 | ||||
|      * @Author: qjq | ||||
|      * @Date: 2024/4/19 下午2:44 | ||||
|      */ | ||||
|     @Override | ||||
|     public List<Map> getDishesNutrition(Long dishesId) { | ||||
|  | ||||
|         List<DishesNutritionDO> rawDOS = dishesNutritionMapper.selectList(new LambdaQueryWrapperX<DishesNutritionDO>() | ||||
|                 .eqIfPresent(DishesNutritionDO::getDishesId, dishesId)); | ||||
|         List<Map> maps = BeanUtil.copyToList(rawDOS, Map.class); | ||||
|         maps.forEach(f ->{ | ||||
|             DishesDO dishesDO = dishesMapper.selectById(dishesId); | ||||
|             f.put("dishesName",dishesDO.getDishesName()); | ||||
|             f.put("dishesImageUrl",dishesDO.getDishesImageUrl()); | ||||
|         }); | ||||
|         return maps; | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * @return | ||||
|      * @Description: 根据ip获取门店id | ||||
|  | ||||
| @ -1,11 +1,12 @@ | ||||
| package cn.iocoder.yudao.module.system.service.dishes; | ||||
|  | ||||
| import javax.validation.*; | ||||
|  | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
|  | ||||
| import javax.validation.Valid; | ||||
|  | ||||
| /** | ||||
|  * 菜品管理 Service 接口 | ||||
| @ -43,6 +44,7 @@ public interface DishesService { | ||||
|      * @return 菜品管理 | ||||
|      */ | ||||
|     DishesDO getDishes(Long id); | ||||
|     DishesRespVO getDishes1(Long id); | ||||
|  | ||||
|     /** | ||||
|      * 获得菜品管理分页 | ||||
|  | ||||
| @ -1,19 +1,31 @@ | ||||
| package cn.iocoder.yudao.module.system.service.dishes; | ||||
|  | ||||
| import cn.hutool.core.util.NumberUtil; | ||||
| import cn.hutool.core.util.ObjUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageParam; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesRespVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishes.vo.DishesSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesnutrition.vo.DishesNutritionPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesnutrition.vo.DishesNutritionSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesraw.vo.DishesRawPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesraw.vo.DishesRawSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishes.DishesDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishesnutrition.DishesNutritionDO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishesraw.DishesRawDO; | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.dishes.DishesMapper; | ||||
| import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; | ||||
| import cn.iocoder.yudao.module.system.service.dishesnutrition.DishesNutritionService; | ||||
| import cn.iocoder.yudao.module.system.service.dishesraw.DishesRawService; | ||||
| import lombok.SneakyThrows; | ||||
| import org.springframework.stereotype.Service; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.math.BigDecimal; | ||||
| import java.util.List; | ||||
|  | ||||
| import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception; | ||||
|  | ||||
| @ -28,6 +40,10 @@ public class DishesServiceImpl implements DishesService { | ||||
|  | ||||
|     @Resource | ||||
|     private DishesMapper dishesMapper; | ||||
|     @Resource | ||||
|     private DishesNutritionService dishesNutritionService; | ||||
|     @Resource | ||||
|     private DishesRawService dishesRawService; | ||||
|     @Override | ||||
|     @SneakyThrows | ||||
|     public Long createDishes(DishesSaveReqVO createReqVO) { | ||||
| @ -45,6 +61,16 @@ public class DishesServiceImpl implements DishesService { | ||||
|             dishes.setDishesBasePrice(div); | ||||
|         } | ||||
|         dishesMapper.insert(dishes); | ||||
|         List<DishesNutritionSaveReqVO> list = createReqVO.getDishesNutritionList(); | ||||
|         List<DishesRawSaveReqVO> dishesRawList = createReqVO.getDishesRawList(); | ||||
|         if(ObjUtil.isNotEmpty(list)){ | ||||
|             list.forEach(f-> f.setDishesId(dishes.getId())); | ||||
|             dishesNutritionService.createDishesNutritionList(list); | ||||
|         } | ||||
|         if(ObjUtil.isNotEmpty(dishesRawList)){ | ||||
|             dishesRawList.forEach(f-> f.setDishesId(dishes.getId())); | ||||
|             dishesRawService.createDishesRawList(dishesRawList); | ||||
|         } | ||||
|         // 返回 | ||||
|         return dishes.getId(); | ||||
|     } | ||||
| @ -53,13 +79,19 @@ public class DishesServiceImpl implements DishesService { | ||||
|     public void updateDishes(DishesSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateDishesExists(updateReqVO.getId()); | ||||
| //        //把图片转换为base64 | ||||
| //        String img = Base64.getEncoder().encodeToString(updateReqVO.getFile().getBytes()); | ||||
|         // 更新 | ||||
|         DishesDO updateObj = BeanUtils.toBean(updateReqVO, DishesDO.class); | ||||
| //        updateObj.setDishesImageUrl(img); | ||||
|         dishesMapper.updateById(updateObj); | ||||
|  | ||||
|         List<DishesNutritionSaveReqVO> list = updateReqVO.getDishesNutritionList(); | ||||
|         List<DishesRawSaveReqVO> dishesRawList = updateReqVO.getDishesRawList(); | ||||
|         if(ObjUtil.isNotEmpty(list)){ | ||||
|             list.forEach(f-> f.setDishesId(updateReqVO.getId())); | ||||
|             dishesNutritionService.updateDishesNutritionList(list); | ||||
|         } | ||||
|         if(ObjUtil.isNotEmpty(dishesRawList)){ | ||||
|             dishesRawList.forEach(f-> f.setDishesId(updateReqVO.getId())); | ||||
|             dishesRawService.updateDishesRawList(dishesRawList); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
| @ -76,11 +108,30 @@ public class DishesServiceImpl implements DishesService { | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     /** | ||||
|      * 获得菜品管理 | ||||
|      * | ||||
|      * @param id 编号 | ||||
|      * @return 菜品管理 | ||||
|      */ | ||||
|     @Override | ||||
|     public DishesDO getDishes(Long id) { | ||||
|         return dishesMapper.selectById(id); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public DishesRespVO getDishes1(Long id) { | ||||
|         DishesRespVO bean = BeanUtils.toBean(dishesMapper.selectById(id), DishesRespVO.class); | ||||
|         List<DishesNutritionDO> dishesNutritionList = dishesNutritionService.getDishesNutritionList(new DishesNutritionPageReqVO().setDishesId(id)); | ||||
|         DishesRawPageReqVO dishesRawPageReqVO = new DishesRawPageReqVO(); | ||||
|         dishesRawPageReqVO.setDishesId(id); | ||||
|         dishesRawPageReqVO.setPageSize(PageParam.PAGE_SIZE_NONE); | ||||
|         List<DishesRawDO> dishesRawList = dishesRawService.getDishesRawPage(dishesRawPageReqVO).getList(); | ||||
|         bean.setDishesNutritionList(dishesNutritionList); | ||||
|         bean.setDishesRawList(dishesRawList); | ||||
|         return bean; | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public PageResult<DishesDO> getDishesPage(DishesPageReqVO pageReqVO) { | ||||
|         return dishesMapper.selectPage(pageReqVO); | ||||
|  | ||||
| @ -31,6 +31,8 @@ public interface DishesNutritionService { | ||||
|      */ | ||||
|     void updateDishesNutrition(@Valid DishesNutritionSaveReqVO updateReqVO); | ||||
|  | ||||
|     void updateDishesNutritionList(@Valid List<DishesNutritionSaveReqVO> updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除菜品营养 | ||||
|      * | ||||
|  | ||||
| @ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.dishesnutrition; | ||||
|  | ||||
| import cn.hutool.core.util.NumberUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesnutrition.vo.DishesNutritionPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesnutrition.vo.DishesNutritionSaveReqVO; | ||||
| @ -9,11 +10,9 @@ import cn.iocoder.yudao.module.system.dal.dataobject.dishesnutrition.DishesNutri | ||||
| import cn.iocoder.yudao.module.system.dal.mysql.dishesnutrition.DishesNutritionMapper; | ||||
| import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
|  | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.math.BigDecimal; | ||||
| import java.util.List; | ||||
|  | ||||
| @ -43,12 +42,21 @@ public class DishesNutritionServiceImpl implements DishesNutritionService { | ||||
|     @Override | ||||
|     public void updateDishesNutrition(DishesNutritionSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateDishesNutritionExists(updateReqVO.getId()); | ||||
|         try { | ||||
|             validateDishesNutritionExists(updateReqVO.getId()); | ||||
|         } catch (Exception e) { | ||||
|             this.createDishesNutrition(updateReqVO); | ||||
|         } | ||||
|         // 更新 | ||||
|         DishesNutritionDO updateObj = BeanUtils.toBean(updateReqVO, DishesNutritionDO.class); | ||||
|         dishesNutritionMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateDishesNutritionList(List<DishesNutritionSaveReqVO> updateReqVO) { | ||||
|         updateReqVO.forEach(this::updateDishesNutrition); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteDishesNutrition(Long id) { | ||||
|         // 校验存在 | ||||
|  | ||||
| @ -30,6 +30,7 @@ public interface DishesRawService { | ||||
|      * @param updateReqVO 更新信息 | ||||
|      */ | ||||
|     void updateDishesRaw(@Valid DishesRawSaveReqVO updateReqVO); | ||||
|     void updateDishesRawList(@Valid List<DishesRawSaveReqVO> updateReqVO); | ||||
|  | ||||
|     /** | ||||
|      * 删除菜品原材料 | ||||
|  | ||||
| @ -2,6 +2,7 @@ package cn.iocoder.yudao.module.system.service.dishesraw; | ||||
|  | ||||
| import cn.hutool.core.util.ObjUtil; | ||||
| import cn.iocoder.yudao.framework.common.pojo.PageResult; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesraw.vo.DishesRawPageReqVO; | ||||
| import cn.iocoder.yudao.module.system.controller.admin.dishesraw.vo.DishesRawSaveReqVO; | ||||
| import cn.iocoder.yudao.module.system.dal.dataobject.dishesraw.DishesRawDO; | ||||
| @ -9,11 +10,9 @@ import cn.iocoder.yudao.module.system.dal.mysql.dishesraw.DishesRawMapper; | ||||
| import cn.iocoder.yudao.module.system.enums.ErrorCodeConstants; | ||||
| import lombok.SneakyThrows; | ||||
| import org.springframework.stereotype.Service; | ||||
| import javax.annotation.Resource; | ||||
| import org.springframework.validation.annotation.Validated; | ||||
| import cn.iocoder.yudao.framework.common.util.object.BeanUtils; | ||||
|  | ||||
|  | ||||
| import javax.annotation.Resource; | ||||
| import java.util.Base64; | ||||
| import java.util.List; | ||||
|  | ||||
| @ -42,13 +41,22 @@ public class DishesRawServiceImpl implements DishesRawService { | ||||
|  | ||||
|     @Override | ||||
|     public void updateDishesRaw(DishesRawSaveReqVO updateReqVO) { | ||||
|         // 校验存在 | ||||
|         validateDishesRawExists(updateReqVO.getId()); | ||||
|         try { | ||||
|             // 校验存在 | ||||
|             validateDishesRawExists(updateReqVO.getId()); | ||||
|         } catch (Exception e) { | ||||
|             this.createDishesRaw(updateReqVO); | ||||
|         } | ||||
|         // 更新 | ||||
|         DishesRawDO updateObj = BeanUtils.toBean(updateReqVO, DishesRawDO.class); | ||||
|         dishesRawMapper.updateById(updateObj); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void updateDishesRawList(List<DishesRawSaveReqVO> updateReqVO) { | ||||
|         updateReqVO.forEach(this::updateDishesRaw); | ||||
|     } | ||||
|  | ||||
|     @Override | ||||
|     public void deleteDishesRaw(Long id) { | ||||
|         // 校验存在 | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 qjq
					qjq