feat:大屏
This commit is contained in:
1 parent
488c348666
commit
91954e042a
7 files changed
+142
-12
No files matched your search
+1
@@ -11,6 +11,7 @@ public enum MerchantTypeEnum {
|
||||
SUPERMARKET("2", "合作商家"),
|
||||
SELF_SUPERMARKET("3", "自营商家"),
|
||||
THIRD_APP("4", "第三方应用"),
|
||||
FARMER("5", "共富商城(助农)"),
|
||||
;
|
||||
|
||||
/**
|
||||
|
||||
+3
@@ -7,6 +7,7 @@ import lombok.Data;
|
||||
import lombok.NoArgsConstructor;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.List;
|
||||
|
||||
@Data
|
||||
@Builder
|
||||
@@ -18,6 +19,8 @@ public class PanelCanteenDto {
|
||||
|
||||
private LocalDateTime[] totalTimeList;
|
||||
|
||||
private List<String> mchTypeCodes;
|
||||
|
||||
private String hourType;
|
||||
|
||||
private Long limit;
|
||||
|
||||
+58
-1
@@ -2,14 +2,21 @@ package com.bsd.pjcloud.hard.controller.panel;
|
||||
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.DateRangeTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.MerchantTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.util.DateRangeTool;
|
||||
import com.bsd.pjcloud.common.core.util.R;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardOrderStatusEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.order.HardOrderDto;
|
||||
import com.bsd.pjcloud.hard.api.dto.panel.PanelCanteenDto;
|
||||
import com.bsd.pjcloud.hard.api.vo.hard.PanelCanteenVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderCsVo;
|
||||
import com.bsd.pjcloud.hard.api.vo.order.HardOrderVo;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderService;
|
||||
import com.bsd.pjcloud.hard.service.HardOrderTotalService;
|
||||
import com.bsd.pjcloud.hard.service.PanelCanteenService;
|
||||
import com.bsd.pjcloud.wallet.api.feign.RemoteMchService;
|
||||
import com.bsd.pjcloud.wallet.api.vo.MchManageVo;
|
||||
import io.swagger.v3.oas.annotations.Operation;
|
||||
import io.swagger.v3.oas.annotations.security.SecurityRequirement;
|
||||
import io.swagger.v3.oas.annotations.tags.Tag;
|
||||
@@ -22,6 +29,7 @@ import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RestController;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@RestController
|
||||
@@ -32,7 +40,11 @@ import java.util.List;
|
||||
public class PanelCanteenController {
|
||||
|
||||
private final PanelCanteenService panelCanteenService;
|
||||
|
||||
private final HardOrderService hardwareOrderService;
|
||||
private final HardOrderTotalService hardOrderTotalService;
|
||||
|
||||
private final RemoteMchService mchService;
|
||||
|
||||
@PostMapping(value = "/group/by-time-and-hour-type")
|
||||
@Operation(summary = "用餐数据统计(根据时间段和日期分类统计)")
|
||||
@@ -40,6 +52,7 @@ public class PanelCanteenController {
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
return R.ok(panelCanteenService.groupByTimeAndHourType(dto));
|
||||
}
|
||||
|
||||
@@ -49,6 +62,7 @@ public class PanelCanteenController {
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
return R.ok(panelCanteenService.groupByTimeAndCustomHour(dto));
|
||||
}
|
||||
|
||||
@@ -58,6 +72,7 @@ public class PanelCanteenController {
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getTotalTimeList())) {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
return R.ok(panelCanteenService.mchPayPersonCount(dto));
|
||||
}
|
||||
|
||||
@@ -68,6 +83,7 @@ public class PanelCanteenController {
|
||||
LocalDateTime.now().minusDays(8).withHour(0).withMinute(0).withSecond(0),
|
||||
LocalDateTime.now().withHour(23).withMinute(59).withSecond(59)
|
||||
});
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
return R.ok(panelCanteenService.groupByTimeAndHourType(dto));
|
||||
}
|
||||
|
||||
@@ -78,15 +94,56 @@ public class PanelCanteenController {
|
||||
dto.setTotalTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setLimit(5L);
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
return R.ok(panelCanteenService.mchPayCountTop(dto));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/report")
|
||||
@Operation(summary = "食堂报表")
|
||||
public R<List<HardOrderCsVo>> canteenReport(@RequestBody HardOrderDto dto) {
|
||||
dto.setOrderStatusCodes(HardOrderStatusEnum.getPaySuccessCodes());
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
List<Long> mchDtoIds = new ArrayList<>();
|
||||
if (ObjectUtil.isNotEmpty(dto.getMerchantId())) {
|
||||
List<MchManageVo> mchList = mchService.getByParentId(dto.getMerchantId()).getData();
|
||||
if (ObjectUtil.isNotEmpty(mchList)) {
|
||||
List<Long> mchIds = mchList.stream().map(MchManageVo::getId).toList();
|
||||
mchDtoIds.add(dto.getMerchantId());
|
||||
mchDtoIds.addAll(mchIds);
|
||||
dto.setMerchantId(null);
|
||||
dto.setMchIds(mchDtoIds);
|
||||
}
|
||||
}
|
||||
return R.ok(hardOrderTotalService.listCs(dto));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/new-page")
|
||||
@Operation(summary = "最新的吃饭数据")
|
||||
public R<Page<HardOrderVo>> newPage(@ParameterObject Page page, HardOrderDto dto) {
|
||||
public R<Page<HardOrderVo>> newPage(@ParameterObject Page page, @RequestBody HardOrderDto dto) {
|
||||
if (ObjectUtil.isNotEmpty(dto.getDateRangeType()) && ObjectUtil.isEmpty(dto.getCreateTimeList())) {
|
||||
dto.setCreateTimeList(DateRangeTool.transitionDateTypeToDateTimeList(dto.getDateRangeType()));
|
||||
}
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
return R.ok(hardwareOrderService.scopePageList(page, dto, null));
|
||||
}
|
||||
|
||||
@PostMapping(value = "/recently")
|
||||
@Operation(summary = "最近吃饭数据")
|
||||
public R<HardOrderVo> recently() {
|
||||
LocalDateTime now = LocalDateTime.now();
|
||||
LocalDateTime[] localDate = new LocalDateTime[]{
|
||||
now.minusMinutes(1),
|
||||
now.plusMinutes(1)
|
||||
};
|
||||
|
||||
HardOrderDto dto = new HardOrderDto();
|
||||
dto.setCreateTimeList(localDate);
|
||||
dto.setMchTypeCodes(List.of(MerchantTypeEnum.CANTEEN.getType(), MerchantTypeEnum.SUPERMARKET.getType()));
|
||||
List<HardOrderVo> list = hardwareOrderService.scopeList(dto, null);
|
||||
if (ObjectUtil.isEmpty(list)) {
|
||||
return R.ok();
|
||||
}
|
||||
return R.ok(list.get(0));
|
||||
}
|
||||
|
||||
}
|
||||
+2
@@ -141,6 +141,8 @@ public interface HardOrderMapper extends PjcloudBaseMapper<HardOrderEntity> {
|
||||
*/
|
||||
List<PanelCanteenVo> groupByTimeAndHourType(@Param("dto") PanelCanteenDto dto);
|
||||
|
||||
List<PanelCanteenVo> groupByMonthAndHourType(@Param("dto") PanelCanteenDto dto);
|
||||
|
||||
/**
|
||||
* 用餐数据统计(根据商户统计)
|
||||
*/
|
||||
|
||||
+6
-2
@@ -149,8 +149,12 @@ public class HardOrderTotalServiceImpl implements HardOrderTotalService {
|
||||
@Override
|
||||
public List<HardOrderCsVo> listCs(HardOrderDto dto) {
|
||||
PjcloudUser user = SecurityUtils.getUser();
|
||||
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
|
||||
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
|
||||
if (ObjectUtil.isEmpty(dto.getMchTypeCodes())) {
|
||||
CurrentUserHardTypeInfoDto hardTypeInfo = hardManagerService.getCurrentUserHardTypeInfo(user);
|
||||
dto.setMchTypeCodes(hardTypeInfo.getHardTypeList());
|
||||
} else {
|
||||
dto.setMchTypeCodes(dto.getMchTypeCodes());
|
||||
}
|
||||
// 查询总流水
|
||||
HardOrderDto totalDto = BeanUtil.toBean(dto, HardOrderDto.class);
|
||||
totalDto.setOrderStatusCodes(HardOrderStatusEnum.getPayPrice());
|
||||
|
||||
+25
-8
@@ -3,6 +3,7 @@ package com.bsd.pjcloud.hard.service.impl.panel;
|
||||
import cn.hutool.core.bean.BeanUtil;
|
||||
import cn.hutool.core.date.LocalDateTimeUtil;
|
||||
import cn.hutool.core.util.ObjectUtil;
|
||||
import com.bsd.pjcloud.common.core.constant.enums.DateRangeTypeEnum;
|
||||
import com.bsd.pjcloud.common.core.util.CollectionUtils;
|
||||
import com.bsd.pjcloud.hard.api.constant.order.HardHourTypeEnum;
|
||||
import com.bsd.pjcloud.hard.api.dto.panel.PanelCanteenDto;
|
||||
@@ -40,15 +41,20 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
@Override
|
||||
public PanelCanteenVo.HourTypeVo groupByTimeAndHourType(PanelCanteenDto dto) {
|
||||
RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
|
||||
List<PanelCanteenVo> dateList = generatePanelCanteenList(dto.getTotalTimeList());
|
||||
List<PanelCanteenVo> dateList = generatePanelCanteenList(dto.getTotalTimeList(), dto.getDateRangeType());
|
||||
PanelCanteenVo.HourTypeVo result = new PanelCanteenVo.HourTypeVo();
|
||||
|
||||
List<HardHourTypeEnum> hourTypeList = List.of(HardHourTypeEnum.MORNING, HardHourTypeEnum.NOONING, HardHourTypeEnum.NIGHT);
|
||||
hourTypeList.stream().map(hourType -> CompletableFuture.runAsync(() -> {
|
||||
for (CompletableFuture<Void> voidCompletableFuture : hourTypeList.stream().map(hourType -> CompletableFuture.runAsync(() -> {
|
||||
RequestContextHolder.setRequestAttributes(requestAttributes);
|
||||
PanelCanteenDto queryDto = BeanUtil.toBean(dto, PanelCanteenDto.class);
|
||||
queryDto.setHourType(hourType.getType());
|
||||
List<PanelCanteenVo> sqlList = hardOrderMapper.groupByTimeAndHourType(queryDto);
|
||||
List<PanelCanteenVo> sqlList = new ArrayList<>();
|
||||
if (ObjectUtil.equals(dto.getDateRangeType(), DateRangeTypeEnum.THIS_YEAR.getType())) {
|
||||
sqlList = hardOrderMapper.groupByMonthAndHourType(queryDto);
|
||||
} else {
|
||||
sqlList = hardOrderMapper.groupByTimeAndHourType(queryDto);
|
||||
}
|
||||
// 处理查询出来的数据
|
||||
List<PanelCanteenVo> resultList = BeanUtil.copyToList(dateList, PanelCanteenVo.class);
|
||||
for (PanelCanteenVo v : resultList) {
|
||||
@@ -73,7 +79,9 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
result.setEvening(vo);
|
||||
break;
|
||||
}
|
||||
})).toList().forEach(CompletableFuture::join);
|
||||
})).toList()) {
|
||||
voidCompletableFuture.join();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -137,7 +145,7 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
return list;
|
||||
}
|
||||
|
||||
private List<PanelCanteenVo> generatePanelCanteenList(LocalDateTime[] totalTimeList) {
|
||||
private List<PanelCanteenVo> generatePanelCanteenList(LocalDateTime[] totalTimeList, DateRangeTypeEnum dateRangeType) {
|
||||
List<PanelCanteenVo> dateList = new LinkedList<>();
|
||||
LocalDate startTime = totalTimeList[0].toLocalDate();
|
||||
LocalDate endTime = totalTimeList[1].toLocalDate();
|
||||
@@ -147,10 +155,19 @@ public class PanelCanteenServiceImpl implements PanelCanteenService {
|
||||
entity.setPersonCount(0L);
|
||||
entity.setBuyCount(0L);
|
||||
entity.setBuyProductCount(0L);
|
||||
entity.setTime(currentDate);
|
||||
entity.setWeekStr(LocalDateTimeUtil.dayOfWeek(currentDate).toChinese());
|
||||
if (ObjectUtil.equals(dateRangeType, DateRangeTypeEnum.THIS_YEAR)) {
|
||||
entity.setTime(currentDate.withDayOfMonth(1));
|
||||
entity.setWeekStr("");
|
||||
} else {
|
||||
entity.setTime(currentDate);
|
||||
entity.setWeekStr(LocalDateTimeUtil.dayOfWeek(currentDate).toChinese());
|
||||
}
|
||||
dateList.add(entity);
|
||||
currentDate = currentDate.plusDays(1);
|
||||
if (ObjectUtil.equals(dateRangeType, DateRangeTypeEnum.THIS_YEAR)) {
|
||||
currentDate = currentDate.plusMonths(1);
|
||||
} else {
|
||||
currentDate = currentDate.plusDays(1);
|
||||
}
|
||||
}
|
||||
return dateList;
|
||||
}
|
||||
|
||||
+47
-1
@@ -570,8 +570,49 @@
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
group by date(o.create_time), o.hour_type
|
||||
order by date(o.create_time) desc
|
||||
<if test="dto.limit != null">
|
||||
limit #{dto.limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
<select id="groupByMonthAndHourType" resultType="com.bsd.pjcloud.hard.api.vo.hard.PanelCanteenVo">
|
||||
select
|
||||
date(o.create_time) as time,
|
||||
o.hour_type as hourType,
|
||||
SUM(a.product_count) as buyProductCount,
|
||||
SUM(a.total_price) as totalPrice,
|
||||
count(distinct o.id) as buyCount,
|
||||
count(distinct o.user_id) as personCount
|
||||
from hard_car a
|
||||
inner join hard_parent_car p on a.parent_car_id = p.id and p.del_flag = '0'
|
||||
inner join hard_order o on o.parent_car_id = p.id and o.del_flag = '0' and o.hour_type is not null and
|
||||
o.hour_type not in ('-1', 'null')
|
||||
<where>
|
||||
a.del_flag = '0'
|
||||
<if test="dto.totalTimeList != null and dto.totalTimeList.length == 2">
|
||||
and o.create_time between #{dto.totalTimeList[0]} and #{dto.totalTimeList[1]}
|
||||
</if>
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
group by date_format(o.create_time, '%Y-%m'), o.hour_type
|
||||
order by date_format(o.create_time, '%Y-%m') desc
|
||||
<if test="dto.limit != null">
|
||||
limit #{dto.limit}
|
||||
</if>
|
||||
@@ -595,6 +636,12 @@
|
||||
<if test="dto.hourType != null and dto.hourType != '' ">
|
||||
and o.hour_type = #{dto.hourType}
|
||||
</if>
|
||||
<if test="dto.mchTypeCodes != null and dto.mchTypeCodes.size() != 0">
|
||||
and o.merchant_type in
|
||||
<foreach collection="dto.mchTypeCodes" item="v" open="(" close=")" separator=",">
|
||||
#{v}
|
||||
</foreach>
|
||||
</if>
|
||||
</where>
|
||||
group by o.merchant_id
|
||||
order by sum(a.product_count) desc
|
||||
@@ -602,5 +649,4 @@
|
||||
limit #{dto.limit}
|
||||
</if>
|
||||
</select>
|
||||
|
||||
</mapper>
|
||||
Reference in new issue
Block a user