ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TDataStatisticsController.java
@@ -322,9 +322,9 @@ List<PersonnelStatisticsVO> personnelStatisticsVOS = orderMealService.personnelStatistics(query); personnelStatisticsAndSumVO.setPersonnelStatisticsVOS(personnelStatisticsVOS); if(!CollectionUtils.isEmpty(personnelStatisticsVOS)){ personnelStatisticsAndSumVO.setPersonCountSum(personnelStatisticsVOS.stream().mapToInt(PersonnelStatisticsVO::getPersonCount).sum()); personnelStatisticsAndSumVO.setPersonCountSum(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToInt(PersonnelStatisticsVO::getPersonCount).sum()); // 计算列表中平均金额乘以人数的总和 personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().mapToDouble(personnelStatisticsVO -> personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()).sum()); personnelStatisticsAndSumVO.setTotalMoney(personnelStatisticsVOS.stream().filter(e->e.getPersonCount() != null).mapToDouble(personnelStatisticsVO -> personnelStatisticsVO.getAvgAmount().doubleValue() * personnelStatisticsVO.getPersonCount()).sum()); } return AjaxResult.success(personnelStatisticsAndSumVO); } ruoyi-admin/src/main/java/com/ruoyi/web/controller/api/TFoundationPersonController.java
@@ -15,6 +15,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.web.bind.annotation.*; import java.time.LocalDateTime; import java.util.List; /** @@ -52,6 +53,7 @@ @ApiOperation( value = "添加基础设置") @PostMapping(value = "/add") public AjaxResult<Boolean> add(@RequestBody TFoundationPersonDTO dto) { dto.setCreateTime(LocalDateTime.now()); foundationPersonService.add(dto); return AjaxResult.success(); } ruoyi-system/src/main/java/com/ruoyi/system/domain/TFoundationPerson.java
@@ -4,12 +4,14 @@ import com.baomidou.mybatisplus.annotation.TableField; import com.baomidou.mybatisplus.annotation.TableId; import com.baomidou.mybatisplus.annotation.TableName; import com.fasterxml.jackson.annotation.JsonFormat; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; import lombok.Data; import lombok.EqualsAndHashCode; import java.io.Serializable; import java.time.LocalDateTime; /** * <p> @@ -33,6 +35,14 @@ @ApiModelProperty(value = "用餐人数") @TableField("mealCount") private Integer mealCount; @ApiModelProperty(value = "店铺id") @TableField("shopId") private Long shopId; @ApiModelProperty(value = "创建时间") @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8") @TableField("createTime") private LocalDateTime createTime; } ruoyi-system/src/main/java/com/ruoyi/system/mapper/TFoundationConfigMapper.java
@@ -3,6 +3,7 @@ import com.baomidou.mybatisplus.core.mapper.BaseMapper; import com.ruoyi.system.domain.TFoundationConfig; import com.ruoyi.system.vo.TFoundationConfigVO; import org.apache.ibatis.annotations.Param; import java.util.List; @@ -20,6 +21,6 @@ * 查询所有的人数用餐标准 * @return */ List<TFoundationConfigVO> getList(); List<TFoundationConfigVO> getList(@Param("shopId") Long shopId); } ruoyi-system/src/main/java/com/ruoyi/system/service/TFoundationConfigService.java
@@ -20,6 +20,6 @@ * 查询所有的人数用餐标准 * @return */ List<TFoundationConfigVO> getList(); List<TFoundationConfigVO> getList(Long shopId); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TDataGeneratorServiceImpl.java
@@ -90,11 +90,19 @@ this.save(dataGenerator); long start = System.currentTimeMillis(); // 查询所有的人数用餐标准 List<TFoundationConfigVO> foundationConfigs = foundationConfigService.getList(); List<TFoundationConfigVO> foundationConfigs = foundationConfigService.getList(dto.getShopId()); // 查询所有桌子 List<TBoard> boards = boardService.list(); List<TBoard> boards = boardService.list(Wrappers.lambdaQuery(TBoard.class) .eq(TBoard::getShopId,dto.getShopId())); if(CollectionUtils.isEmpty(boards)){ throw new ServiceException("请先添加桌台信息"); } // 查询所有菜品 List<TGoods> goods = goodsService.list(); List<TGoods> goods = goodsService.list(Wrappers.lambdaQuery(TGoods.class) .eq(TGoods::getShopId,dto.getShopId())); if(CollectionUtils.isEmpty(goods)){ throw new ServiceException("请先添加菜品信息"); } // 循环待生成订单列表,添加到集合中,批量插入 List<OrderMealGeneratorCountDTO> orderMealGeneratorCountDTOS = dto.getOrderMealGeneratorCountDTOS(); List<TOrderMeal> orderMeals = new ArrayList<>(); @@ -141,14 +149,16 @@ } } }); orderMeal.setMealOrderGoods(orderMealGoods); orderMeal.setOrderMoney(orderMealGoods.stream().map(TOrderMealGoods::getGoodsSalePrice).reduce(BigDecimal::add).get()); orderMeal.setPayMoney(orderMealGoods.stream().map(TOrderMealGoods::getGoodsSalePrice).reduce(BigDecimal::add).get()); orderMeals.add(orderMeal); if(!CollectionUtils.isEmpty(orderMealGoods)){ orderMeal.setMealOrderGoods(orderMealGoods); orderMeal.setOrderMoney(orderMealGoods.stream().map(TOrderMealGoods::getGoodsSalePrice).reduce(BigDecimal::add).get()); orderMeal.setPayMoney(orderMealGoods.stream().map(TOrderMealGoods::getGoodsSalePrice).reduce(BigDecimal::add).get()); orderMeals.add(orderMeal); } } } BigDecimal sumMoney = orderMeals.stream().map(TOrderMeal::getPayMoney).reduce(BigDecimal::add).get(); if(sumMoney.compareTo(dto.getMinMoney()) <= 0 || sumMoney.compareTo(dto.getMaxMoney()) >= 0){ if(sumMoney.compareTo(dto.getMinMoney()) >= 0 && sumMoney.compareTo(dto.getMaxMoney()) <= 0){ int weiXin = getRandomPayType(orderMeals.size(), dto.getWeiXinProportion()); int ali = getRandomPayType(orderMeals.size(), dto.getAliProportion()); int card = getRandomPayType(orderMeals.size(), dto.getCardProportion()); @@ -222,6 +232,7 @@ long end = System.currentTimeMillis() - start; System.err.println("相差时间========="+end); }else { this.removeById(dataGenerator); throw new ServiceException("数据生成不在营业额范围内"); } ruoyi-system/src/main/java/com/ruoyi/system/service/impl/TFoundationConfigServiceImpl.java
@@ -21,7 +21,7 @@ public class TFoundationConfigServiceImpl extends ServiceImpl<TFoundationConfigMapper, TFoundationConfig> implements TFoundationConfigService { @Override public List<TFoundationConfigVO> getList() { return this.baseMapper.getList(); public List<TFoundationConfigVO> getList(Long shopId) { return this.baseMapper.getList(shopId); } } ruoyi-system/src/main/java/com/ruoyi/system/vo/TFoundationConfigVO.java
@@ -11,5 +11,7 @@ @ApiModelProperty(value = "用餐人数") private Integer mealCount; @ApiModelProperty(value = "店铺id") private Long shopId; } ruoyi-system/src/main/resources/mapper/system/TDataGeneratorMapper.xml
@@ -55,6 +55,7 @@ </if> AND tdg.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where> ORDER BY tdg.createTime DESC </select> </mapper> ruoyi-system/src/main/resources/mapper/system/TFoundationConfigMapper.xml
@@ -16,9 +16,10 @@ id, personId,typeId, minCount, maxCount </sql> <select id="getList" resultType="com.ruoyi.system.vo.TFoundationConfigVO"> SELECT tfc.id, tfc.personId,tfc.typeId, tfc.minCount, tfc.maxCount,tfp.mealCount SELECT tfc.id, tfc.personId,tfc.typeId, tfc.minCount, tfc.maxCount,tfp.mealCount,tfp.shopId FROM t_foundation_config tfc LEFT JOIN t_foundation_person tfp ON tfp.id = tfc.personId where tfp.shopId = #{shopId} </select> </mapper> ruoyi-system/src/main/resources/mapper/system/TFoundationPersonMapper.xml
@@ -6,16 +6,19 @@ <resultMap id="BaseResultMap" type="com.ruoyi.system.domain.TFoundationPerson"> <id column="id" property="id" /> <result column="mealCount" property="mealCount" /> <result column="createTime" property="createTime" /> <result column="shopId" property="shopId" /> </resultMap> <!-- 通用查询结果列 --> <sql id="Base_Column_List"> id, mealCount id, mealCount,createTime </sql> <select id="getList" resultType="com.ruoyi.system.vo.TFoundationPersonVO"> select <include refid="Base_Column_List"/> from t_foundation_person ORDER BY createTime DESC </select> </mapper> ruoyi-system/src/main/resources/mapper/system/TOrderMealMapper.xml
@@ -53,18 +53,19 @@ and tom.shopId = #{query.shopId} </if> <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime}) AND (tom.mealTime BETWEEN #{query.startTime} AND #{query.endTime}) </if> AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} AND tom.isCover = 1 </where> ORDER BY tom.createTime DESC ORDER BY tom.mealTime DESC </select> <select id="amountSum" resultType="com.ruoyi.system.vo.AmountSumVO"> select COUNT(tom.id) AS orderCount, SUM(tom.orderMoney) AS saleAmount, SUM(tom.payMoney) AS payAmount, SUM(tom.orderMoney - tom.payMoney) AS obligation IFNULL(SUM(tom.orderMoney),0) AS saleAmount, IFNULL(SUM(tom.payMoney),0) AS payAmount, IFNULL(SUM(tom.orderMoney - tom.payMoney),0) AS obligation from t_order_meal tom left join t_board tb on tb.id = tom.boardId <where> @@ -78,15 +79,16 @@ and tom.status = #{query.status} </if> <if test="query.orderNum != null and query.orderNum"> and tom.orderNum LIKE concat('%',#{query.status},'%') and tom.orderNum LIKE concat('%',#{query.orderNum},'%') </if> <if test="query.shopId != null"> and tom.shopId = #{query.shopId} </if> <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> AND (tom.createTime BETWEEN #{query.startTime} AND #{query.endTime}) AND (tom.mealTime BETWEEN #{query.startTime} AND #{query.endTime}) </if> AND tom.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} AND tom.isCover = 1 </where> </select> <select id="salesVolume" resultType="com.ruoyi.system.vo.SalesVolumeVO"> @@ -102,7 +104,7 @@ and shopId = #{query.shopId} </if> <if test="query.startTime != null and query.startTime != '' and query.endTime != null and query.endTime != ''"> AND (createTime BETWEEN #{query.startTime} AND #{query.endTime}) AND (mealTime BETWEEN #{query.startTime} AND #{query.endTime}) </if> AND disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()} </where>